Skip to content
Snippets Groups Projects
Commit b79a55e5 authored by Samuel Wegner's avatar Samuel Wegner
Browse files

Support multiple resources for Arcane Combat

-The only visible change in the core game is that Arcane Combat
now interacts correctly with the Hidden Resources prodigy. The rest
of the changes are for addon support.

-Previously, Arcane Combat on_trigger function assumed that allowed
talents cost mana and not other resources. This is fine in the core
game, but if an addon wants to allow triggering a talent that costs
Vim or Paradox, for example, the logic was not appropriate.
Now, all resource types should be handled correctly.

-Added some sanity checks to the allowed talent filtering in case
addon developers set "allow_for_arcane_combat" on inappropriate
talents.
parent fce1e752
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,38 @@ newTalent{
cooldown = 5,
tactical = { BUFF = 2 },
getChance = function(self, t) return self:combatLimit(self:getTalentLevel(t) * (1 + self:getCun(9, true)), 100, 20, 0, 70, 50) end, -- Limit < 100%
canUseTalent = function(self, t) -- Returns true if the actor can currently trigger the talent with Arcane Combat
local talent = self:getTalentFromId(t)
if not talent or not talent.allow_for_arcane_combat then return false end
if talent.mode ~= "activated" then return false end
if not talent.is_spell then return false end
if not self:knowTalent(talent) then return false end
if self:isTalentCoolingDown(talent) then return false end
if not self:attr("force_talent_ignore_ressources") then
-- Check all possible resource types and see if the talent has an associated cost
for _, res_def in ipairs(self.resources_def) do
local rname = res_def.short_name
local cost = talent[rname]
if cost then
cost = (util.getval(cost, self, talent) or 0) * (util.getval(res_def.cost_factor, self, talent) or 1)
if cost ~= 0 then
local rmin, rmax = self[res_def.getMinFunction](self), self[res_def.getMaxFunction](self)
-- Return false if we can't afford the talent cost
if res_def.invert_values then
if rmax and self[res_def.getFunction](self) + cost > rmax then
return false
end
else
if rmin and self[res_def.getFunction](self) - cost < rmin then
return false
end
end
end
end
end
end
return true
end,
do_trigger = function(self, t, target)
if self.x == target.x and self.y == target.y then return nil end
......@@ -45,14 +77,14 @@ newTalent{
local p = self:isTalentActive(t.id)
if p and p.talent then
local talent = self:getTalentFromId(p.talent)
if talent.allow_for_arcane_combat and self:knowTalent(talent) and not self:isTalentCoolingDown(talent) and mana > talent.mana * fatigue then
if t.canUseTalent(self, talent) then
spells[1] = talent.id
end
end
-- If no appropriate spell is selected, pick a random spell
if #spells < 1 then
for _, talent in pairs(self.talents_def) do
if talent.allow_for_arcane_combat and self:knowTalent(talent) and not self:isTalentCoolingDown(talent) and mana > talent.mana * fatigue then
if t.canUseTalent(self, talent) then
spells[#spells+1] = talent.id
end
end
......@@ -104,7 +136,7 @@ newTalent{
info = function(self, t)
local talent_list = ""
for _, talent in pairs(self.talents_def) do
if talent.allow_for_arcane_combat and talent.name then
if talent.allow_for_arcane_combat and talent.mode == "activated" and talent.is_spell and talent.name then
if #talent_list > 0 then talent_list = talent_list .. ", " end
talent_list = talent_list .. talent.name
end
......
......@@ -104,7 +104,7 @@ function _M:generateList()
local chars = {}
for _, t in pairs(self.actor.talents_def) do
if t.allow_for_arcane_combat and self.actor:knowTalent(t) then
if t.allow_for_arcane_combat and t.mode == "activated" and t.is_spell and self.actor:knowTalent(t) then
local status = tstring{{"color", "LIGHT_GREEN"}, "Talents"}
-- Pregenerate icon with the Tiles instance that allows images
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment