17,105
edits
m (Add modifier GPFromFiremaking) |
(Amend combat triangle modifier functions to use game provided data) |
||
Line 331: | Line 331: | ||
[6] = 'Insane'} | [6] = 'Insane'} | ||
function p.getTriangleAttribute(attribute, attackerStyle, targetStyle, mode) | |||
if type(attribute) ~= 'string' then | |||
error("Parameter 'attribute' must be a string", 2) | |||
elseif type(attackerStyle) ~= 'string' then | |||
error("Parameter 'attackerStyle' must be a string", 2) | |||
elseif type(targetStyle) ~= 'string' then | |||
error("Parameter 'targetStyle' must be a string", 2) | |||
elseif type(mode) ~= 'string' then | |||
error("Parameter 'mode' must be a string", 2) | |||
end | |||
local modeID = p.getGamemodeID(mode) | |||
if modeID == nil then | |||
error("Invalid gamemode '" .. mode .. "'", 2) | |||
end | |||
} | |||
local attStyle, targStyle = string.lower(attackerStyle), string.lower(targetStyle) | |||
local validStyles = { 'magic', 'melee', 'ranged' } | |||
if not Shared.contains(validStyles, string.lower(attStyle)) then | |||
error("Invalid value for parameter 'attackerStyle'", 2) | |||
elseif not Shared.contains(validStyles, string.lower(targStyle)) then | |||
error("Invalid value for parameter 'targetStyle'", 2) | |||
end | |||
local triangleID = ConstantData.Gamemode.Data[modeID + 1].combatTriangle | |||
local attrData = ConstantData.CombatTriangle[triangleID + 1][attribute] | |||
if attrData == nil then | |||
error("No such attribute: " .. attribute) | |||
else | else | ||
return | return attrData[attStyle][targStyle] | ||
end | end | ||
end | |||
function p.getTriangleDamageModifier(attackerStyle, targetStyle, mode) | |||
return p.getTriangleAttribute('damageModifier', attackerStyle, targetStyle, mode) | |||
end | end | ||
--Syntax is like p.getTriangleDRModifier('Melee', 'Ranged', 'Normal') | --Syntax is like p.getTriangleDRModifier('Melee', 'Ranged', 'Normal') | ||
--Returns a multiplier that can be multiplied with base DR to get the post-Triangle result | --Returns a multiplier that can be multiplied with base DR to get the post-Triangle result | ||
function p.getTriangleDRModifier( | function p.getTriangleDRModifier(attackerStyle, targetStyle, mode) | ||
return p.getTriangleAttribute('reductionModifier', attackerStyle, targetStyle, mode) | |||
end | end | ||
Line 396: | Line 392: | ||
function p.getEquipmentSlotID(name) | function p.getEquipmentSlotID(name) | ||
return ConstantData.equipmentSlot[name] | return ConstantData.equipmentSlot[name] | ||
end | |||
function p.getGamemodeName(id) | |||
return ConstantData.Gamemode.Enum[id] | |||
end | |||
function p.getGamemodeID(name) | |||
return ConstantData.Gamemode.Enum[name] | |||
end | end | ||