Started working on casting items from the caststack
This commit is contained in:
parent
fe61d63f26
commit
617bb0aa3f
224
bot/bot.iss
224
bot/bot.iss
@ -1,32 +1,38 @@
|
|||||||
|
|
||||||
|
|
||||||
; objectdef CombatHelper
|
|
||||||
; {
|
|
||||||
; variable collection:CastStackAbility CastStack
|
|
||||||
; variable queue:CastStackAbility PrirortyAbilityQueue
|
|
||||||
|
|
||||||
; method Initialize(jsonvalueref jsonCastStackConfig)
|
|
||||||
; {
|
|
||||||
; CastStack:FromJSON[jsonCastStackConfig]
|
|
||||||
; }
|
|
||||||
|
|
||||||
; member:CastStackAbility CastNextAbility()
|
|
||||||
; {
|
|
||||||
; if ${PriorityAbilityQueue.Peek(exists)}
|
|
||||||
; {
|
|
||||||
|
|
||||||
; }
|
|
||||||
; }
|
|
||||||
|
|
||||||
; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
objectdef BotController
|
objectdef BotController
|
||||||
{
|
{
|
||||||
variable bool IsBotRunning = FALSE
|
variable bool IsBotRunning = FALSE
|
||||||
variable bool IsShowingSettings = FALSE
|
variable bool IsShowingSettings = FALSE
|
||||||
|
variable jsonvalue savedSettings = "{}"
|
||||||
|
variable jsonvalue currentProfile = "{}"
|
||||||
|
variable jsoniterator castStackIterator
|
||||||
|
variable jsonvalue abilities = "{}"
|
||||||
|
|
||||||
|
method Initialize()
|
||||||
|
{
|
||||||
|
LGUI2:LoadPackageFile["bot.json"]
|
||||||
|
|
||||||
|
savedSettings:ParseFile["${LavishScript.HomeDirectory}/scripts/mr/bot/profiles/${Me.Name}_${Me.SubClass}.json"]
|
||||||
|
if ${savedSettings.Type.NotEqual["object"]}
|
||||||
|
{
|
||||||
|
echo "Error parsing saved settings"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
abilities:ParseFile["${LavishScript.HomeDirectory}/scripts/mr/bot/ability_exports/${Me.Name}_${Me.SubClass}.json"]
|
||||||
|
if ${jo.Type.NotEqual["object"]}
|
||||||
|
{
|
||||||
|
echo "Error parsing ability list"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
currentProfile:SetValue["${savedSettings.Get[${savedSettings.Get["default"]}]}"]
|
||||||
|
currentProfile.Get["castStack"]:GetIterator[castStackIterator]
|
||||||
|
}
|
||||||
|
|
||||||
|
method Shutdown()
|
||||||
|
{
|
||||||
|
LGUI2:UnloadPackageFile["bot.json"]
|
||||||
|
}
|
||||||
|
|
||||||
member:string StartButtonText()
|
member:string StartButtonText()
|
||||||
{
|
{
|
||||||
@ -52,43 +58,6 @@ objectdef BotController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
; member:string GetSettingsCheckBoxes()
|
|
||||||
; {
|
|
||||||
; variable jsonvalue checkboxes = "[]"
|
|
||||||
; variable jsoniterator settingKeysIterator
|
|
||||||
|
|
||||||
; setttingKeys:GetIterator[settingsKeyIterator]
|
|
||||||
; if ${settingKeysIterator:First(exists)}
|
|
||||||
; {
|
|
||||||
; echo "items"
|
|
||||||
; do
|
|
||||||
; {
|
|
||||||
; echo "looping"
|
|
||||||
; checkboxes:Add[$$>
|
|
||||||
; {
|
|
||||||
; "type": "checkbox",
|
|
||||||
; "name": "${settingKeysIterator.Value.key}",
|
|
||||||
; "content": "${settingKeysIterator.display_name}"
|
|
||||||
; }
|
|
||||||
; <$$]
|
|
||||||
; }
|
|
||||||
; while ${settingKeysIterator:Next(exists)}
|
|
||||||
; }
|
|
||||||
; echo "here ${checkboxes.AsJSON~}"
|
|
||||||
|
|
||||||
; return ${checkboxes.AsJSON~}
|
|
||||||
; }
|
|
||||||
|
|
||||||
method Initialize()
|
|
||||||
{
|
|
||||||
LGUI2:LoadPackageFile["bot.json"]
|
|
||||||
}
|
|
||||||
|
|
||||||
method Shutdown()
|
|
||||||
{
|
|
||||||
LGUI2:UnloadPackageFile["bot.json"]
|
|
||||||
}
|
|
||||||
|
|
||||||
method OnClose()
|
method OnClose()
|
||||||
{
|
{
|
||||||
Script:End
|
Script:End
|
||||||
@ -119,47 +88,104 @@ objectdef BotController
|
|||||||
IsShowingSettings:Set[${IsShowingSettings.Not}]
|
IsShowingSettings:Set[${IsShowingSettings.Not}]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
member:jsonvalueref GetHighestVersionOfAbility(string abilityName)
|
||||||
|
{
|
||||||
|
if !${abilityName(exists)}
|
||||||
|
{
|
||||||
|
echo "ability name not set"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
variable jsonvalueref highestVersion = "{}"
|
||||||
|
variable jsoniterator abilityIterator
|
||||||
|
abilities.Get["${abilityName}"]:GetIterator[abilityIterator]
|
||||||
|
|
||||||
|
if ${abilityIterator:First(exists)}
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if !${highestVersion.Get["level"]}
|
||||||
|
{
|
||||||
|
highestVersion:SetReference[abilityIterator.Value]
|
||||||
|
}
|
||||||
|
elseif ${highestVersion.Get["level"]} < ${abilityIterator.Value.Get["level"]}
|
||||||
|
{
|
||||||
|
highestVersion:SetReference[abilityIterator.Value]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while ${abilityIterator:Next(exists)}
|
||||||
|
}
|
||||||
|
|
||||||
|
return highestVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
member:string GetBuiltinAlias(string aliasName)
|
||||||
|
{
|
||||||
|
if ${aliasName.Equal["@Me"]}
|
||||||
|
{
|
||||||
|
return Me.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
member:string GetActualTarget(string givenTarget)
|
||||||
|
{
|
||||||
|
if ${givenTarget.Left[1].Equal["*"]}
|
||||||
|
{
|
||||||
|
; look up alias
|
||||||
|
}
|
||||||
|
elseif ${givenTarget.Left[1].Equal["@"]}
|
||||||
|
{
|
||||||
|
; built up alias
|
||||||
|
return This.GetBuiltinAlias[${givenTarget}]
|
||||||
|
}
|
||||||
|
elseif ${givenTarget.Left[4].Equal["Pet:"]}
|
||||||
|
{
|
||||||
|
; pet
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return givenTarget
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
method Pulse()
|
method Pulse()
|
||||||
{
|
{
|
||||||
; if ${IsBotRunning.Not}
|
if ${IsBotRunning.Not}
|
||||||
; {
|
{
|
||||||
; return
|
return
|
||||||
; }
|
}
|
||||||
|
|
||||||
; echo "Test: ${settings.IsSettingChecked["test"]}"
|
variable int64 currentAbilityId
|
||||||
; if ${Me.InCombat}
|
variable string abilityTarget
|
||||||
; {
|
|
||||||
; variable jsoniterator CastStackIterator
|
|
||||||
; settings.CastStack:GetIterator[CastStackIterator]
|
|
||||||
|
|
||||||
; if ${CastStackIterator:First(exists)}
|
if ${Me.CastingSpell}
|
||||||
; {
|
{
|
||||||
; do
|
return
|
||||||
; {
|
}
|
||||||
; if ${CastStackIterator.Value.Get["AbilityType"].Equal["Heal"]} && ${Me.Health} < ${CastStackIterator.Value.Get["Percentage"]}
|
if ${castStackIterator:First(exists)}
|
||||||
; {
|
{
|
||||||
; echo "Casting Heal ${CastStackIterator.Value.Name}"
|
do
|
||||||
; return
|
{
|
||||||
; }
|
if ${castStackIterator.Value.Get["action"].Equal["ability"]} && ${castStackIterator.Value.Get["type"].Equal["Buff"]}
|
||||||
; elseif ${CastStackIterator.Value.Get["AbilityType"].Equal["Combat"]} && !${AbilityUsed.Element[${CastStackIterator.Value.Get["Name"]}]}
|
{
|
||||||
; {
|
currentAbilityId:Set[${This.GetHighestVersionOfAbility[${castStackIterator.Key}].Get["id"]}]
|
||||||
; AbilityUsed:Set[${CastStackIterator.Value.Get["Name"]}, TRUE]
|
|
||||||
; echo "using Combat ${CastStackIterator.Value.Get["Name"]}"
|
if ${currentAbilityId} > 0
|
||||||
; return
|
{
|
||||||
; }
|
if ${Me.Ability[id, ${currentAbilityId}].IsReady}
|
||||||
; elseif ${CastStackIterator.Value.Get["AbilityType"].Equal["CA"]} && !${AbilityUsed.Element[${CastStackIterator.Value.Get["Name"]}]}
|
{
|
||||||
; {
|
abilityTarget:Set[]
|
||||||
; AbilityUsed:Set[${CastStackIterator.Value.Get["Name"]}, TRUE]
|
echo "Target ${castStackIterator.Value.Get["target"]}"
|
||||||
; echo "using CA ${CastStackIterator.Value.Get["Name"]}"
|
echo "Casting ${castStackIterator.Key}"
|
||||||
; return
|
Me.Ability[id, ${currentAbilityId}]:Use
|
||||||
; }
|
return
|
||||||
; else
|
}
|
||||||
; {
|
}
|
||||||
; }
|
}
|
||||||
; }
|
|
||||||
; while ${CastStackIterator:Next(exists)}
|
}
|
||||||
; }
|
while ${castStackIterator:Next(exists)}
|
||||||
; }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
"type": "textblock",
|
"type": "textblock",
|
||||||
"horizontalAlignment": "stretch",
|
"horizontalAlignment": "stretch",
|
||||||
"textBinding": {
|
"textBinding": {
|
||||||
"pullFormat": "${_CONTEXTITEMDATA_.Get[Name]}"
|
"pullFormat": "${_CONTEXTITEMDATA_.Get[name]}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -193,7 +193,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "textbox",
|
"type": "textbox",
|
||||||
"name": "castStack.targetCount",
|
"name": "castStack.ability.targetCount",
|
||||||
"horizontalAlignment": "stretch",
|
"horizontalAlignment": "stretch",
|
||||||
"textBinding": {
|
"textBinding": {
|
||||||
"pullFormat": "${MRSettingsController.SafeGetNewCastStackItemProperty[targetCount]}",
|
"pullFormat": "${MRSettingsController.SafeGetNewCastStackItemProperty[targetCount]}",
|
||||||
@ -536,7 +536,7 @@
|
|||||||
"horizontalAlignment": "stretch",
|
"horizontalAlignment": "stretch",
|
||||||
"heightFactor": 0.9,
|
"heightFactor": 0.9,
|
||||||
"itemsBinding": {
|
"itemsBinding": {
|
||||||
"pullFormat": "${MRSettingsController.CastOrder}"
|
"pullFormat": "${MRSettingsController.profile.Get[castStack].Keys}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,6 +4,7 @@ objectdef SettingsController
|
|||||||
{
|
{
|
||||||
|
|
||||||
variable jsonvalue abilityListItems = "[]"
|
variable jsonvalue abilityListItems = "[]"
|
||||||
|
variable jsonvalue profile = "{}"
|
||||||
variable jsonvalue currentCastStack = "[]"
|
variable jsonvalue currentCastStack = "[]"
|
||||||
variable int currentSelectedAvailableAbilityIndex = -1
|
variable int currentSelectedAvailableAbilityIndex = -1
|
||||||
variable jsonvalue newCastStackItem = "{}"
|
variable jsonvalue newCastStackItem = "{}"
|
||||||
@ -13,7 +14,7 @@ objectdef SettingsController
|
|||||||
LavishScript:RegisterEvent[onNewCastStackItemChanged]
|
LavishScript:RegisterEvent[onNewCastStackItemChanged]
|
||||||
variable jsonvalue jo
|
variable jsonvalue jo
|
||||||
|
|
||||||
jo:ParseFile["${LavishScript.HomeDirectory}/scripts/mr/bot/ability_exports/Ihaihu_shadowknight.json"]
|
jo:ParseFile["${LavishScript.HomeDirectory}/scripts/mr/bot/ability_exports/${Me.Name}_${Me.SubClass}.json"]
|
||||||
if ${jo.Type.NotEqual["object"]}
|
if ${jo.Type.NotEqual["object"]}
|
||||||
{
|
{
|
||||||
echo "Error parsing ability list"
|
echo "Error parsing ability list"
|
||||||
@ -31,17 +32,26 @@ objectdef SettingsController
|
|||||||
if ${jo.Get["${key}"].Get[1, "spellBookType"]} < 2
|
if ${jo.Get["${key}"].Get[1, "spellBookType"]} < 2
|
||||||
{
|
{
|
||||||
abilityItem:SetValue["$$>{
|
abilityItem:SetValue["$$>{
|
||||||
"Name": "${key~}",
|
"name": "${key~}",
|
||||||
"TargetType": ${jo.Get["${key}"].Get[1, "targetType"]},
|
"targertType": ${jo.Get["${key}"].Get[1, "targetType"]},
|
||||||
"IsBeneficial": ${jo.Get["${key}"].Get[1, "isBeneficial"]},
|
"isBeneficial": ${jo.Get["${key}"].Get[1, "isBeneficial"]},
|
||||||
"GroupRestricted": ${jo.Get["${key}"].Get[1, "groupRestricted"]},
|
"groupRestricted": ${jo.Get["${key}"].Get[1, "groupRestricted"]},
|
||||||
"MaxAoeTargets": ${jo.Get["${key}"].Get[1, "maxAoeTargets"]}
|
"maxAoeTargets": ${jo.Get["${key}"].Get[1, "maxAoeTargets"]}
|
||||||
|
|
||||||
}<$$"]
|
}<$$"]
|
||||||
abilityListItems:Add["${abilityItem.AsJSON}"]
|
abilityListItems:Add["${abilityItem.AsJSON}"]
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jo:ParseFile["${LavishScript.HomeDirectory}/scripts/mr/bot/profiles/ihaihu_shadowknight.json"]
|
||||||
|
if ${jo.Type.NotEqual["object"]}
|
||||||
|
{
|
||||||
|
echo "Error parsing profile"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
profile:SetValue["${jo.Get[${jo.Get["default"]}].AsJSON}"]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
method Shutdown()
|
method Shutdown()
|
||||||
@ -56,26 +66,37 @@ objectdef SettingsController
|
|||||||
{
|
{
|
||||||
if ${abilityListItems.Get[${selectedAbilityIndex}, "TargetType"]} != 1
|
if ${abilityListItems.Get[${selectedAbilityIndex}, "TargetType"]} != 1
|
||||||
{
|
{
|
||||||
echo "Hide target: ${abilityListItems.Get[${selectedAbilityIndex}, "TargetType"]}"
|
|
||||||
LGUI2.Element["castStack.ability.target"].Parent:SetVisibility[Hidden]
|
LGUI2.Element["castStack.ability.target"].Parent:SetVisibility[Hidden]
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
echo "Show target: ${abilityListItems.Get[${selectedAbilityIndex}, "TargetType"]}"
|
|
||||||
LGUI2.Element["castStack.ability.target"].Parent:SetVisibility[Visible]
|
LGUI2.Element["castStack.ability.target"].Parent:SetVisibility[Visible]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
method ToggleNumTargetsBySelectedAbilityId(int selectedAbilityIndex)
|
||||||
|
{
|
||||||
|
if ${abilityListItems.Get[${selectedAbilityIndex}, "MaxAoeTargets"]} > 1
|
||||||
|
{
|
||||||
|
LGUI2.Element["castStack.ability.targetCount"].Parent:SetVisibility[Visible]
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LGUI2.Element["castStack.ability.targetCount"].Parent:SetVisibility[Hidden]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
method SetCurrentAbility(int selectedIndex)
|
method SetCurrentAbility(int selectedIndex)
|
||||||
{
|
{
|
||||||
|
|
||||||
This:ToggleTargetVisibilityBySelectedAbility[${selectedIndex}]
|
This:ToggleTargetVisibilityBySelectedAbility[${selectedIndex}]
|
||||||
|
This:ToggleNumTargetsBySelectedAbilityId[${selectedIndex}]
|
||||||
|
|
||||||
currentSelectedAvailableAbilityIndex:Set[${selectedIndex}]
|
currentSelectedAvailableAbilityIndex:Set[${selectedIndex}]
|
||||||
LGUI2.Element[MRSettingsController.events]:FireEventHandler[onNewCastStackItemChanged]
|
LGUI2.Element[MRSettingsController.events]:FireEventHandler[onNewCastStackItemChanged]
|
||||||
newCastStackItem:SetValue["$$>{
|
newCastStackItem:SetValue["$$>{
|
||||||
"action": "ability",
|
"action": "ability",
|
||||||
"name": "${abilityListItems.Get[${selectedIndex}, "Name"]}"
|
"name": "${abilityListItems.Get[${selectedIndex}, "name"]}"
|
||||||
}<$$"]
|
}<$$"]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +142,7 @@ objectdef SettingsController
|
|||||||
|
|
||||||
method AddAbility()
|
method AddAbility()
|
||||||
{
|
{
|
||||||
echo "AddAbility: ${newCastStackItem.AsJSON[multiline]~}"
|
currentCastStack:Add["${newCastStackItem.AsJSON}"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user