Anonymous

Module:Constants: Difference between revisions

From Melvor Idle
Amend combat triangle modifier functions to use game provided data
m (Add modifier GPFromFiremaking)
(Amend combat triangle modifier functions to use game provided data)
Line 331: Line 331:
[6] = 'Insane'}
[6] = 'Insane'}


--07/03/21: Hardcoding in Combat Triangle Modifiers
function p.getTriangleAttribute(attribute, attackerStyle, targetStyle, mode)
local CombatTriangle = {
if type(attribute) ~= 'string' then
damageBonus = 1.1,  
error("Parameter 'attribute' must be a string", 2)
drBonus = 1.25,
elseif type(attackerStyle) ~= 'string' then
damagePenalty = { Normal = 0.85,
error("Parameter 'attackerStyle' must be a string", 2)
Hardcore = 0.75 },
elseif type(targetStyle) ~= 'string' then
drPenalty = { Melee = { Normal = 0.5,
error("Parameter 'targetStyle' must be a string", 2)
Hardcore = 0.25 },
elseif type(mode) ~= 'string' then
Ranged = { Normal = 0.95,
error("Parameter 'mode' must be a string", 2)
Hardcore = 0.75 },
end
Magic = { Normal = 0.85,
Hardcore = 0.75 }},
local modeID = p.getGamemodeID(mode)
Melee = { bonus = "Ranged", penalty = "Magic" },
if modeID == nil then
Ranged = { bonus = "Magic", penalty = "Melee" },
error("Invalid gamemode '" .. mode .. "'", 2)
Magic = { bonus = "Melee", penalty = "Ranged" },
end
}
 
local attStyle, targStyle = string.lower(attackerStyle), string.lower(targetStyle)
function p.getTriangleDamageModifier(playerStyle, enemyStyle, mode)
local validStyles = { 'magic', 'melee', 'ranged' }
if CombatTriangle[playerStyle].bonus == enemyStyle then
if not Shared.contains(validStyles, string.lower(attStyle)) then
return CombatTriangle.damageBonus
error("Invalid value for parameter 'attackerStyle'", 2)
elseif CombatTriangle[playerStyle].penalty == enemyStyle then
elseif not Shared.contains(validStyles, string.lower(targStyle)) then
if mode == 'Hardcore' or mode == 'Adventure' then
error("Invalid value for parameter 'targetStyle'", 2)
return CombatTriangle.damagePenalty.Hardcore
end
else
return CombatTriangle.damagePenalty.Normal
local triangleID = ConstantData.Gamemode.Data[modeID + 1].combatTriangle
end
local attrData = ConstantData.CombatTriangle[triangleID + 1][attribute]
if attrData == nil then
error("No such attribute: " .. attribute)
else
else
return 1
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(playerStyle, enemyStyle, mode)
function p.getTriangleDRModifier(attackerStyle, targetStyle, mode)
if CombatTriangle[playerStyle].bonus == enemyStyle then
return p.getTriangleAttribute('reductionModifier', attackerStyle, targetStyle, mode)
return CombatTriangle.drBonus
elseif CombatTriangle[playerStyle].penalty == enemyStyle then
if mode == 'Hardcore' or mode == 'Adventure' then
return CombatTriangle.drPenalty[playerStyle].Hardcore
else
return CombatTriangle.drPenalty[playerStyle].Normal
end
else
return 1
end
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