4,951
edits
m (Fix modifier typos) |
Falterfire (talk | contribs) (Attempting to indent via find & replace) |
||
Line 8: | Line 8: | ||
--Just hardcoding these because I guess that's where we're at | --Just hardcoding these because I guess that's where we're at | ||
local modifierTypes = { | local modifierTypes = { | ||
["MeleeStrengthBonus"] = { text = "{V}% Melee Strength Bonus", skills = {'Combat'} }, | |||
["DamageToDungeonMonsters"] = { text = "{V}% Damage To Dungeon Monsters", skills = {'Combat'} }, | |||
["GlobalMasteryXP"] = { text = "{V}% Global Mastery XP", skills = {'Woodcutting', 'Fishing', 'Firemaking', 'Cooking', 'Mining', 'Smithing', 'Thieving', 'Farming', 'Fletching', 'Crafting', 'Runecrafting', 'Herblore', 'Agility', 'Summoning', 'Astrology'} }, | |||
["ChanceRandomPotionHerblore"] = { text = "{V}% chance to gain a second potion of a random tier", skills = {'Herblore'} }, | |||
["FlatPrayerCostReduction"] = { text = "{V} Prayer Point Cost for Prayers", inverseSign = true, skills = {'Prayer'} }, | |||
["MinEarthSpellDmg"] = { text = "{VX} Min Earth Spell Dmg", skills = {'Magic'} }, | |||
["SlayerTaskLength"] = { text = "{V}% Slayer Task Length/Qty", skills = {'Slayer'} }, | |||
["ChanceToDoubleLootCombat"] = { text = "{V}% Chance To Double Loot in Combat", skills = {'Combat' | |||
} | } | ||
--Difficulties are hard coded which is dumb but means hardcoding them here too | --Difficulties are hard coded which is dumb but means hardcoding them here too | ||
local Difficulties = { | local Difficulties = { | ||
[0] = 'Very Easy', | |||
[1] = 'Easy', | |||
[2] = 'Medium', | |||
[3] = 'Hard', | |||
[4] = 'Very Hard', | |||
[5] = 'Elite', | |||
[6] = 'Insane'} | |||
--07/03/21: Hardcoding in Combat Triangle Modifiers | --07/03/21: Hardcoding in Combat Triangle Modifiers | ||
local CombatTriangle = { | local CombatTriangle = { | ||
damageBonus = 1.1, | |||
drBonus = 1.25, | |||
damagePenalty = { Normal = 0.85, | |||
Hardcore = 0.75 }, | |||
drPenalty = { Melee = { Normal = 0.5, | |||
Hardcore = 0.25 }, | |||
Ranged = { Normal = 0.95, | |||
Hardcore = 0.75 }, | |||
Magic = { Normal = 0.85, | |||
Hardcore = 0.75 }}, | |||
Melee = { bonus = "Ranged", penalty = "Magic" }, | |||
Ranged = { bonus = "Magic", penalty = "Melee" }, | |||
Magic = { bonus = "Melee", penalty = "Ranged" }, | |||
} | } | ||
function p.getTriangleDamageModifier(playerStyle, enemyStyle, mode) | function p.getTriangleDamageModifier(playerStyle, enemyStyle, mode) | ||
if CombatTriangle[playerStyle].bonus == enemyStyle then | |||
return CombatTriangle.damageBonus | |||
elseif CombatTriangle[playerStyle].penalty == enemyStyle then | |||
if mode == 'Hardcore' or mode == 'Adventure' then | |||
return CombatTriangle.damagePenalty.Hardcore | |||
else | |||
return CombatTriangle.damagePenalty.Normal | |||
end | |||
else | |||
return 1 | |||
end | |||
end | end | ||
Line 364: | Line 364: | ||
--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(playerStyle, enemyStyle, mode) | ||
if CombatTriangle[playerStyle].bonus == enemyStyle then | |||
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 | ||
function p.getDifficultyString(difficulty) | function p.getDifficultyString(difficulty) | ||
return Difficulties[difficulty] | |||
end | end | ||
Line 390: | Line 390: | ||
function p.getEquipmentSlotName(id) | function p.getEquipmentSlotName(id) | ||
return type(id) == 'number' and ConstantData.equipmentSlot[id] or 'Invalid' | |||
end | end | ||
function p.getEquipmentSlotID(name) | function p.getEquipmentSlotID(name) | ||
return ConstantData.equipmentSlot[name] | |||
end | end | ||
function p.getCombatStyleName(styleNum) | function p.getCombatStyleName(styleNum) | ||
if type(styleNum) == 'number' then | |||
local styleName = ConstantData.attackType[styleNum] | |||
if styleName ~= nil then | |||
return Shared.titleCase(styleName) | |||
end | |||
end | |||
return "ERROR: Invalid combat style[[Category:Pages with script errors]]" | |||
end | end | ||
function p.getSlayerTierName(tier) | function p.getSlayerTierName(tier) | ||
return type(tier) == 'number' and ConstantData.slayerTier[tier] or "ERROR: Invalid Slayer tier[[Category:Pages with script errors]]" | |||
end | end | ||
function p.getSlayerTierNameByLevel(lvl) | function p.getSlayerTierNameByLevel(lvl) | ||
for i, tier in Shared.skpairs(ConstantData.Slayer.Tiers) do | |||
if tier.minLevel <= lvl and (tier.maxLevel == nil or tier.maxLevel >= lvl) then | |||
return tier.display | |||
end | |||
end | |||
return 'N/A' | |||
end | end | ||
function p.getSlayerTier(name) | function p.getSlayerTier(name) | ||
for i, tier in Shared.skpairs(ConstantData.Slayer.Tiers) do | |||
if tier.display == name then | |||
local result = Shared.clone(tier) | |||
result.id = i - 1 | |||
return result | |||
end | |||
end | |||
end | end | ||
function p.getSlayerTierByID(tierID) | function p.getSlayerTierByID(tierID) | ||
if ConstantData.Slayer.Tiers[tierID + 1] == nil then | |||
return nil | |||
end | |||
local result = Shared.clone(ConstantData.Slayer.Tiers[tierID + 1]) | |||
result.id = tierID | |||
return result | |||
end | end | ||
Line 444: | Line 444: | ||
--ex. "MeleeAccuracyBonus", "+{V}% Melee Accuracy", "+", false | --ex. "MeleeAccuracyBonus", "+{V}% Melee Accuracy", "+", false | ||
function p.getModifierDetails(modifierName) | function p.getModifierDetails(modifierName) | ||
local baseName = modifierName | |||
local isIncrease = true | |||
local isNegative = false | |||
local valueUnsigned = false | |||
if Shared.startsWith(modifierName, "increased") or Shared.startsWith(modifierName, "decreased") then | |||
baseName = string.sub(modifierName, 10) | |||
isIncrease = Shared.startsWith(modifierName, "increased") | |||
end | |||
local modifier = modifierTypes[baseName] | |||
if modifier == nil then | |||
return nil | |||
end | |||
local isPositive = isIncrease | |||
if modifier.isIncreaseNegative then | |||
isPositive = not isPositive | |||
end | |||
local sign = "+" | |||
if (not isIncrease and not modifier.inverseSign) or (isIncrease and modifier.inverseSign) then | |||
sign = "-" | |||
end | |||
if type(modifier.unsigned) == 'boolean' then valueUnsigned = modifier.unsigned end | |||
return baseName, modifier.text, sign, not isPositive, valueUnsigned, modifier | |||
end | end | ||
function p._getModifierText(modifier, value, doColor) | function p._getModifierText(modifier, value, doColor) | ||
if doColor == nil then doColor = true end | |||
local modName, modText, sign, isNegative, valueUnsigned = p.getModifierDetails(modifier) | |||
if modName == nil then | |||
return 'ERROR: Invalid modifier type for ' .. modifier .. '[[Category:Pages with script errors]]' | |||
end | |||
local result = modText | |||
if type(value) == 'table' then | |||
if Shared.tableCount(value) > 0 and type(value[1]) == 'table' then | |||
--Potentially return multiple rows if necessary | |||
local resultArray = {} | |||
for i, subVal in Shared.skpairs(value) do | |||
table.insert(resultArray, p._getModifierText(modifier, subVal, doColor)) | |||
end | |||
return table.concat(resultArray, '<br/>') | |||
else | |||
if value[1] ~= nil then | |||
local skillName = p.getSkillName(value[1]) | |||
if skillName ~= nil then | |||
result = string.gsub(result, '{SV0}', p.getSkillName(value[1])) | |||
end | |||
end | |||
if value[2] ~= nil then value = value[2] end | |||
end | |||
end | |||
-- Re-check the type of value, as it may have been modified above even if it was originally a table | |||
if type(value) ~= 'table' then | |||
local valSign = (valueUnsigned and '' or sign) | |||
if string.find(result, '{IV}', 1, true) ~= nil and tonumber(value) ~= nil then | |||
local item = ItemData.Items[tonumber(value) + 1] | |||
if item ~= nil then | |||
result = string.gsub(result, '{IV}', item.name) | |||
end | |||
end | |||
result = string.gsub(result, '{V}', valSign..value) | |||
result = string.gsub(result, '{VD}', valSign..(value / 10)) | |||
result = string.gsub(result, '{VMS}', valSign..(value / 1000)) | |||
result = string.gsub(result, '{VX}', valSign..(value * 10)) | |||
result = string.gsub(result, '{VX100}', valSign..(value * 100)) | |||
result = string.gsub(result, '{V%+100}', valSign..(value + 100)) | |||
result = string.gsub(result, '{VMUL}', 2^value) | |||
result = string.gsub(result, '{S}', sign) | |||
end | |||
if doColor then | |||
if isNegative ~= nil and isNegative then | |||
result = '<span style="color:red">'..result..'</span>' | |||
else | |||
result = '<span style="color:green">'..result..'</span>' | |||
end | |||
end | |||
return result | |||
end | end | ||
function p.getModifierText(frame) | function p.getModifierText(frame) | ||
local modifier = frame.args ~= nil and frame.args[1] or frame[1] | |||
local value = frame.args ~= nil and frame.args[2] or frame[2] | |||
local skill = frame.args ~= nil and frame.args.skill or frame.skill | |||
local doColor = frame.args ~= nil and frame.args[3] or frame[3] | |||
if doColor ~= nil then | |||
doColor = string.upper(doColor) ~= 'FALSE' | |||
end | |||
if skill ~= nil and skill ~= '' then | |||
value = {p.getSkillID(skill), value} | |||
end | |||
return p._getModifierText(modifier, value, doColor) | |||
end | end | ||
function p.getModifiersText(modifiers, doColor) | function p.getModifiersText(modifiers, doColor) | ||
if modifiers == nil or Shared.tableCount(modifiers) == 0 then | |||
return '' | |||
end | |||
local modArray = {} | |||
for bonus, value in Shared.skpairs(modifiers) do | |||
table.insert(modArray, p._getModifierText(bonus, value, doColor)) | |||
end | |||
return table.concat(modArray, "<br/>") | |||
end | end | ||
function p.getModifierSkills(modifiers) | function p.getModifierSkills(modifiers) | ||
local skillArray = {} | |||
for modifier, value in Shared.skpairs(modifiers) do | |||
if type(value) == 'table' then | |||
for i, subVal in Shared.skpairs(value) do | |||
local skillName = p.getSkillName(subVal[1]) | |||
if not Shared.contains(skillArray, skillName) then | |||
table.insert(skillArray, skillName) | |||
end | |||
end | |||
end | |||
local baseName = p.getModifierDetails(modifier) | |||
if baseName == nil then | |||
return { 'ERROR: Modifier '..modifier..' is invalid' } | |||
end | |||
if modifierTypes[baseName].skills ~= nil then | |||
for i, skillName in Shared.skpairs(modifierTypes[baseName].skills) do | |||
if not Shared.contains(skillArray, skillName) then | |||
table.insert(skillArray, skillName) | |||
end | |||
end | |||
end | |||
end | |||
return skillArray | |||
end | end | ||
return p | return p |