12,787
edits
(Amend sleep effect definition to include Siren) |
(Support Lifesteal) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
["Burn"] = { | ["Burn"] = { | ||
{ | { | ||
[" | ["effectType"] = 'Burn' | ||
}, | }, | ||
-- Alternative definition specifically for familiars like Dragon | -- Alternative definition specifically for familiars like Dragon | ||
Line 22: | Line 21: | ||
}, | }, | ||
["Poison"] = { | ["Poison"] = { | ||
["effectType"] = 'Poison' | |||
}, | |||
["Deadly Poison"] = { | |||
["effectType"] = 'DeadlyPoison' | |||
}, | }, | ||
["Slow"] = { | ["Slow"] = { | ||
Line 51: | Line 52: | ||
["modifiers"] = { | ["modifiers"] = { | ||
["include"] = { 'increasedAfflictionChance' } | ["include"] = { 'increasedAfflictionChance' } | ||
} | } | ||
} | } | ||
Line 72: | Line 67: | ||
} | } | ||
} | } | ||
}, | |||
["Slow"] = { | |||
["effectType"] = 'Slow' | |||
}, | }, | ||
["Freeze"] = { | ["Freeze"] = { | ||
Line 84: | Line 82: | ||
["type"] = 'DOT', | ["type"] = 'DOT', | ||
["subtype"] = 'Regen' | ["subtype"] = 'Regen' | ||
}, | |||
["Lifesteal"] = { | |||
["attFunc"] = function(attack) | |||
return type(attack.lifesteal) == 'number' and attack.lifesteal > 0 | |||
end | |||
} | } | ||
-- TODO Implement curses | -- TODO Implement curses | ||
Line 113: | Line 116: | ||
end | end | ||
-- | -- Convert effect definition into list of definitions to be checked | ||
function p. | function p.getEffectDefnList(effectDefn) | ||
-- Some effects (e.g. Burn) have multiple definitions, so handle these correctly | -- Some effects (e.g. Burn) have multiple definitions, so handle these correctly | ||
if type(effectDefn[1]) == 'table' then | |||
if type( | |||
-- Definition is actually multiple definitions | -- Definition is actually multiple definitions | ||
return effectDefn | |||
else | else | ||
-- Definition is singular, wrap it within a table so we can iterate | -- Definition is singular, wrap it within a table so we can iterate | ||
return { effectDefn } | |||
end | end | ||
end | |||
for i, effectDefn in pairs(effectDefnList) do | -- Determines if attack applies the effect defined in effectDefinition | ||
function p.attackHasEffect(attack, effectDefnRaw) | |||
if type(attack) == 'table' and type(effectDefnRaw) == 'table' then | |||
local effectDefnList = p.getEffectDefnList(effectDefnRaw) | |||
for i, effectDefn in pairs(effectDefnList) do | |||
if effectDefn.attFunc ~= nil then | |||
-- Attack level check, for effects like lifesteal | |||
if effectDefn.attFunc(attack) then | |||
return true | |||
end | |||
else | |||
-- Process pre-hit effects | |||
for i, effect in ipairs(attack.prehitEffects) do | |||
if p.effectMatchesDefn(effect, effectDefn) then | |||
return true | |||
end | |||
end | |||
-- Process on hit effects | |||
for i, effect in ipairs(attack.onhitEffects) do | |||
if p.effectMatchesDefn(effect, effectDefn) then | |||
return true | |||
end | |||
end | |||
end | |||
end | end | ||
end | end | ||
Line 151: | Line 157: | ||
end | end | ||
function p. | function p.effectMatchesDefn(effect, effectDefn) | ||
if effectDefn.type ~= effect.type then | if effectDefn.type ~= effect.type then | ||
-- Effect's type doesn't match that of the effect definition | -- Effect's type doesn't match that of the effect definition |