Commit b739184a222317bf9aef1a9d0656b4d92e3576ad

Authored by DarkGod
2 parents a887cce0 74d14fd6

Merge branch 'callbackOnAITalentTactics' into 'master'

Add a new hook/callback, ActorAI:aiTalentTactics/callbackOnAITalentTactics

This hook/callback allows modifying talent tactical table. It is useful for sustains that modify other talents' behavior, like Arcane Combat, and allows more fine-grained AI management.
This modification may significantly buff Arcane Blade npcs.

See merge request !729
@@ -6073,6 +6073,7 @@ local sustainCallbackCheck = { @@ -6073,6 +6073,7 @@ local sustainCallbackCheck = {
6073 callbackOnPartyRemove = "talents_on_party_remove", 6073 callbackOnPartyRemove = "talents_on_party_remove",
6074 callbackOnTargeted = "talents_on_targeted", 6074 callbackOnTargeted = "talents_on_targeted",
6075 callbackOnCloned = "talents_on_cloned", 6075 callbackOnCloned = "talents_on_cloned",
  6076 + callbackOnAITalentTactics = "talents_on_ai_talent_tactics",
6076 } 6077 }
6077 _M.sustainCallbackCheck = sustainCallbackCheck 6078 _M.sustainCallbackCheck = sustainCallbackCheck
6078 6079
@@ -1386,6 +1386,10 @@ function _M:aiTalentTactics(t, aitarget, target_list, tactic, tg, wt_mod) @@ -1386,6 +1386,10 @@ function _M:aiTalentTactics(t, aitarget, target_list, tactic, tg, wt_mod)
1386 end --(DEBUGGING transitional) 1386 end --(DEBUGGING transitional)
1387 if type(tactical) == "function" then tactical = tactical(self, t, aitarget) end 1387 if type(tactical) == "function" then tactical = tactical(self, t, aitarget) end
1388 end 1388 end
  1389 + local hd = {"ActorAI:aiTalentTactics", tactical=table.clone(tactical, true), t=t, ai_target=ai_target}
  1390 + self:triggerHook(hd)
  1391 + self:fireTalentCheck("callbackOnAITalentTactics", hd)
  1392 + tactical = hd.tactical
1389 if log_detail >= 2 then print("[aiTalentTactics]__ using talent tactical table for", t.id) table.print(tactical, "\t___") end 1393 if log_detail >= 2 then print("[aiTalentTactics]__ using talent tactical table for", t.id) table.print(tactical, "\t___") end
1390 if not tactical then return false end 1394 if not tactical then return false end
1391 1395
@@ -28,7 +28,7 @@ newTalent{ @@ -28,7 +28,7 @@ newTalent{
28 range = 1, 28 range = 1,
29 stamina = 20, 29 stamina = 20,
30 require = spells_req1, 30 require = spells_req1,
31 - tactical = { ATTACK = 0.2 }, 31 + tactical = { ATTACK = {weapon = 2} },
32 is_melee = true, 32 is_melee = true,
33 on_pre_use = function(self, t, silent) if not self:hasMHWeapon() then if not silent then game.logPlayer(self, "You require a weapon to use this talent.") end return false end return true end, 33 on_pre_use = function(self, t, silent) if not self:hasMHWeapon() then if not silent then game.logPlayer(self, "You require a weapon to use this talent.") end return false end return true end,
34 requires_target = true, 34 requires_target = true,
@@ -29,6 +29,23 @@ newTalent{ @@ -29,6 +29,23 @@ newTalent{
29 cooldown = 5, 29 cooldown = 5,
30 tactical = { BUFF = 2 }, 30 tactical = { BUFF = 2 },
31 getChance = function(self, t) return self:combatLimit(self:getTalentLevel(t) * (1 + self:getCun(9, true)), 100, 20, 0, 70, 50) end, -- Limit < 100% 31 getChance = function(self, t) return self:combatLimit(self:getTalentLevel(t) * (1 + self:getCun(9, true)), 100, 20, 0, 70, 50) end, -- Limit < 100%
  32 + callbackOnAITalentTactics = function(self, t, hd)
  33 + local p = self:isTalentActive(t.id)
  34 + if not p then return end
  35 + if hd.t.allow_for_arcane_combat then
  36 + hd.tactical = {}
  37 + end
  38 + if hd.tactical then
  39 + local tactical = hd.tactical
  40 + if tactical.attack and type(tactical.attack) == "table" and tactical.attack.weapon then
  41 + tactical.attack.weapon = tactical.attack.weapon + 1
  42 + end
  43 + if tactical.attackarea and type(tactical.attackarea) == "table" and tactical.attackarea.weapon then
  44 + tactical.attackarea.weapon = tactical.attackarea.weapon + 1
  45 + end
  46 + end
  47 + return true
  48 + end,
32 canUseTalent = function(self, t, proc) -- Returns true if the actor can currently trigger the "proc" talent with Arcane Combat 49 canUseTalent = function(self, t, proc) -- Returns true if the actor can currently trigger the "proc" talent with Arcane Combat
33 local talent = self:getTalentFromId(proc) 50 local talent = self:getTalentFromId(proc)
34 if not talent or not talent.allow_for_arcane_combat then return false end 51 if not talent or not talent.allow_for_arcane_combat then return false end