Anonymous

Module:Constants: Difference between revisions

From Melvor Idle
Correct modifier definition
(getModifierSkills: Fix)
(Correct modifier definition)
(45 intermediate revisions by 6 users not shown)
Line 21: Line 21:
["GlobalPreservationChance"] = { text = "{V}% Chance to Preserve Resources in Skills" },
["GlobalPreservationChance"] = { text = "{V}% Chance to Preserve Resources in Skills" },
["RunePreservation"] = { text = "{V}% Rune Preservation", skills = {'Magic'} },
["RunePreservation"] = { text = "{V}% Rune Preservation", skills = {'Magic'} },
["MaxHitpoints"] = { text = "{VX} Maximum Hitpoints", skills = {'Combat'} },
["MaxHitpoints"] = { text = "{VX} Maximum Hitpoints", skills = {'Combat', 'Hitpoints'} },
["ChanceToDoubleItemsSkill"] = { text = "{V}% Chance to Double Items in {SV0}" },
["ChanceToDoubleItemsSkill"] = { text = "{V}% Chance to Double Items in {SV0}" },
["autoSlayerUnlocked"] = { text = "{V} Auto Slayer Unlocked", skills = {'Slayer'} },
["autoSlayerUnlocked"] = { text = "{V} Auto Slayer Unlocked", skills = {'Slayer'} },
["HitpointRegeneration"] = { text = "{V}% Hitpoint Regeneration", skills = {'Combat'} },
["HitpointRegeneration"] = { text = "{V}% Hitpoint Regeneration", skills = {'Combat', 'Hitpoints'} },
["PotionChargesFlat"] = { text = "{V} Charges per Potion" },
["PotionChargesFlat"] = { text = "{V} Charges per Potion" },
["SkillInterval"] = { text = "{VMS}s {SV0} Interval", isIncreaseNegative = true, isSkill = true },
["SkillInterval"] = { text = "{VMS}s {SV0} Interval", isIncreaseNegative = true, isSkill = true },
Line 31: Line 31:
["DamageToSlayerTasks"] = { text = "{V}% Damage To Slayer Tasks", skills = {'Combat'} },
["DamageToSlayerTasks"] = { text = "{V}% Damage To Slayer Tasks", skills = {'Combat'} },
["Lifesteal"] = { text = "{V}% Lifesteal", skills = {'Combat'} },
["Lifesteal"] = { text = "{V}% Lifesteal", skills = {'Combat'} },
["HPRegenFlat"] = { text = "{VX} Flat HP Regen", skills = {'Combat'} },
["HPRegenFlat"] = { text = "{VX} Flat HP Regen", skills = {'Combat', 'Hitpoints'} },
["ChanceToDoubleOres"] = { text = "{V}% Chance to Double Ores in Mining", skills = {'Combat'} },
["ChanceToDoubleOres"] = { text = "{V}% Chance to Double Ores in Mining", skills = {'Mining'} },
["MonsterRespawnTimer"] = { text = "{VMS}s Monster Respawn Timer", isIncreaseNegative = true, skills = {'Combat'} },
["MonsterRespawnTimer"] = { text = "{VMS}s Monster Respawn Timer", isIncreaseNegative = true, skills = {'Combat'} },
["SkillPreservationChance"] = { text = "{V}% Chance to Preserve Resources in {SV0}" },
["SkillPreservationChance"] = { text = "{V}% Chance to Preserve Resources in {SV0}" },
Line 68: Line 68:
["ChanceToDoubleItemsGlobal"] = { text = "{V}% Chance to Double Items Globally" },
["ChanceToDoubleItemsGlobal"] = { text = "{V}% Chance to Double Items Globally" },
["GPGlobal"] = { text = "{V}% GP from all sources (Except Item Selling)", skills = {'Combat', 'Thieving', 'Agility'} },
["GPGlobal"] = { text = "{V}% GP from all sources (Except Item Selling)", skills = {'Combat', 'Thieving', 'Agility'} },
["RangedAccuracyBonus"] = { text = "{V} Ranged Accuracy Bonus", skills = {'Combat'} },
["RangedAccuracyBonus"] = { text = "{V}% Ranged Accuracy Bonus", skills = {'Combat'} },
["AutoEatThreshold"] = { text = "{V}% Auto Eat Threshold", skills = {'Combat'} },
["AutoEatThreshold"] = { text = "{V}% Auto Eat Threshold", skills = {'Combat'} },
["freeBonfires"] = { text = "+ Automatically relight bonfires for free", skills = {'Firemaking'} },
["freeBonfires"] = { text = "+ Automatically relight bonfires for free", skills = {'Firemaking'} },
Line 109: Line 109:
["summoningSynergy_1_12"] = {text = "If the Enemy is your current Slayer Task, {V}% Enemy Accuracy Rating.", skills = {"Combat"}, inverseSign = true},
["summoningSynergy_1_12"] = {text = "If the Enemy is your current Slayer Task, {V}% Enemy Accuracy Rating.", skills = {"Combat"}, inverseSign = true},
["summoningSynergy_1_13"] = {text = "Grants flat Melee & Ranged Defence Bonus equal to your Damage Reduction", skills = {"Combat"}},
["summoningSynergy_1_13"] = {text = "Grants flat Melee & Ranged Defence Bonus equal to your Damage Reduction", skills = {"Combat"}},
["summoningSynergy_1_14"] = {text = "If the Enemy has more combined Evasion Ratings than the Player, grants {V}% Hitpoint Regeneration.", skills = {"Combat"}},
["summoningSynergy_1_14"] = {text = "If the Enemy has more combined Evasion Ratings than the Player, grants {V}% Hitpoint Regeneration.", skills = {"Combat", "Hitpoints"}},
["summoningSynergy_1_15"] = {text = "If the Player is BURNING, grants {V} Melee, Ranged and Magic Defence Bonus.", skills = {"Combat"}},
["summoningSynergy_1_15"] = {text = "If the Player is BURNING, grants {V} Melee, Ranged and Magic Defence Bonus.", skills = {"Combat"}},
["summoningSynergy_2_12"] = {text = "Grants Slayer Coins equal to {V}% of HP leeched from Lifesteal.", skills = {"Slayer"}},
["summoningSynergy_2_12"] = {text = "Grants Slayer Coins equal to {V}% of HP leeched from Lifesteal.", skills = {"Slayer"}},
Line 141: Line 141:
["summoningSynergy_6_12"] = {text = "While fighting your current Slayer Task, grants {V}% of your Melee Max Hit as Minimum Damage.", skills = {"Combat", 'Melee'}},
["summoningSynergy_6_12"] = {text = "While fighting your current Slayer Task, grants {V}% of your Melee Max Hit as Minimum Damage.", skills = {"Combat", 'Melee'}},
["summoningSynergy_6_13"] = {text = "While fighting a Ranged Enemy, grants {V}% Damage Reduction.", skills = {"Combat"}},
["summoningSynergy_6_13"] = {text = "While fighting a Ranged Enemy, grants {V}% Damage Reduction.", skills = {"Combat"}},
["summoningSynergy_6_14"] = {text = "While using a Melee Weapon, grants {V}% of your Melee Max Hit as Flat HP Regen.", skills = {"Combat", 'Melee'}},
["summoningSynergy_6_14"] = {text = "While using a Melee Weapon, grants {V}% of your Melee Max Hit as Flat HP Regen.", skills = {"Combat", 'Melee', 'Hitpoints'}},
["summoningSynergy_6_15"] = {text = "If the Enemy is BURNING, effects from the Minotaur Familiar are tripled.", skills = {"Combat", 'Melee'}},
["summoningSynergy_6_15"] = {text = "If the Enemy is BURNING, effects from the Minotaur Familiar are tripled.", skills = {"Combat", 'Melee'}},
["summoningSynergy_7_8"] = {text = "While fighting a Magic Enemy, grants {V} Ranged Accuracy Bonus and {V} Ranged Strength Bonus.", skills = {"Combat", 'Ranged'}},
["summoningSynergy_7_8"] = {text = "While fighting a Magic Enemy, grants {V} Ranged Accuracy Bonus and {V} Ranged Strength Bonus.", skills = {"Combat", 'Ranged'}},
["summoningSynergy_7_12"] = {text = "While fighting your current Slayer Task, grants {V}% of your Ranged Max Hit as Minimum Damage.", skills = {"Combat", 'Ranged'}},
["summoningSynergy_7_12"] = {text = "While fighting your current Slayer Task, grants {V}% of your Ranged Max Hit as Minimum Damage.", skills = {"Combat", 'Ranged'}},
["summoningSynergy_7_13"] = {text = "While fighting a Magic Enemy, grants {V}% Damage Reduction.", skills = {"Combat"}},
["summoningSynergy_7_13"] = {text = "While fighting a Magic Enemy, grants {V}% Damage Reduction.", skills = {"Combat"}},
["summoningSynergy_7_14"] = {text = "While using a Ranged Weapon, grants {V}% of your Ranged Max Hit as HP Regeneration.", skills = {"Combat", 'Ranged'}},
["summoningSynergy_7_14"] = {text = "While using a Ranged Weapon, grants {V}% of your Ranged Max Hit as HP Regeneration.", skills = {"Combat", 'Ranged', 'Hitpoints'}},
["summoningSynergy_7_15"] = {text = "Your Ranged Attacks now have {V}% to inflict BURNING on the Enemy.", skills = {"Combat", 'Ranged'}},
["summoningSynergy_7_15"] = {text = "Your Ranged Attacks now have {V}% to inflict BURNING on the Enemy.", skills = {"Combat", 'Ranged'}},
["summoningSynergy_8_12"] = {text = "Grants Slayer Coins equal to {V}% of your Magic Damage while on Slayer Task.", skills = {'Slayer'}},
["summoningSynergy_8_12"] = {text = "Grants Slayer Coins equal to {V}% of your Magic Damage while on Slayer Task.", skills = {'Slayer'}},
["summoningSynergy_8_13"] = {text = "While fighting a Melee Enemy, grants {V}% Damage Reduction.", skills = {"Combat"}},
["summoningSynergy_8_13"] = {text = "While fighting a Melee Enemy, grants {V}% Damage Reduction.", skills = {"Combat"}},
["summoningSynergy_8_14"] = {text = "Grants {V}% of your Max Hit as HP Regeneration if using a Magic Attack Style.", skills = {"Combat", 'Magic'}},
["summoningSynergy_8_14"] = {text = "Grants {V}% of your Max Hit as HP Regeneration if using a Magic Attack Style.", skills = {"Combat", 'Magic', 'Hitpoints'}},
["summoningSynergy_9_11"] = {text = "The Chef in Thieving now deals no damage to you.", skills = {'Thieving'}},
["summoningSynergy_9_11"] = {text = "The Chef in Thieving now deals no damage to you.", skills = {'Thieving'}},
["summoningSynergy_9_16"] = {text = "Crafting Recipes that require Dragonhide now use {V} quantity to create. Recipe cost cannot go below 1.", skills = {'Crafting'}, inverseSign = true},
["summoningSynergy_9_16"] = {text = "Crafting Recipes that require Dragonhide now use {V} quantity to create. Recipe cost cannot go below 1.", skills = {'Crafting'}, inverseSign = true},
Line 157: Line 157:
["summoningSynergy_10_11"] = {text = "Successfully pickpocketting the Miner in Thieving will now grant {V} Rune Essence.", skills = {'Thieving'}},
["summoningSynergy_10_11"] = {text = "Successfully pickpocketting the Miner in Thieving will now grant {V} Rune Essence.", skills = {'Thieving'}},
["summoningSynergy_10_16"] = {text = "{V}% chance to double when creating Leather, Hard Leather or Dragonhide Armour in Crafting.", skills = {'Crafting'}},
["summoningSynergy_10_16"] = {text = "{V}% chance to double when creating Leather, Hard Leather or Dragonhide Armour in Crafting.", skills = {'Crafting'}},
["summoningSynergy_10_17"] = {text = "{V}% Smithing & Runecrafting Preservation Chance."},
["summoningSynergy_10_17"] = {text = "{V}% Smithing & Runecrafting Preservation Chance.", skills = {'Smithing', 'Runecrafting'}},
["summoningSynergy_10_18"] = {text = "While the Elemental Potion is active in Runecrafting, grants a chance to get random Combination Runes. The chance and quantity is equal to that of the Elemental Potion.", skills = {'Runecrafting'}},
["summoningSynergy_10_18"] = {text = "While the Elemental Potion is active in Runecrafting, grants a chance to get random Combination Runes. The chance and quantity is equal to that of the Elemental Potion.", skills = {'Runecrafting'}},
["summoningSynergy_10_19"] = {text = "Grants {V} Fire Runes while creating Elemental Runes.", skills = {'Runecrafting'}},
["summoningSynergy_10_19"] = {text = "Grants {V} Fire Runes while creating Elemental Runes.", skills = {'Runecrafting'}},
Line 165: Line 165:
["summoningSynergy_11_19"] = {text = "While Thieving any NPC, 50% chance to grant +100% GP, 35% chance to grant 4x Items, or 15% chance to receive no items or GP at all.", skills = {'Thieving'}},
["summoningSynergy_11_19"] = {text = "While Thieving any NPC, 50% chance to grant +100% GP, 35% chance to grant 4x Items, or 15% chance to receive no items or GP at all.", skills = {'Thieving'}},
["summoningSynergy_12_13"] = {text = "While fighting your current Slayer Task, {V}% Damage Reduction.", skills = {"Combat"}},
["summoningSynergy_12_13"] = {text = "While fighting your current Slayer Task, {V}% Damage Reduction.", skills = {"Combat"}},
["summoningSynergy_12_14"] = {text = "While fighting your current Slayer Task, {V}% Hitpoints Regeneration.", skills = {"Combat"}},
["summoningSynergy_12_14"] = {text = "While fighting your current Slayer Task, {V}% Hitpoints Regeneration.", skills = {"Combat", "Hitpoints"}},
["summoningSynergy_13_14"] = {text = "{V}% Hitpoints Regeneration if you have less than 75% Current HP.", skills = {"Combat"}},
["summoningSynergy_13_14"] = {text = "{V}% Hitpoints Regeneration if you have less than 75% Current HP.", skills = {"Combat", "Hitpoints"}},
["summoningSynergy_16_17"] = {text = "{V}% chance to preserve resources in Crafting when creating Rings or Amulets only.", skills = {'Crafting'}},
["summoningSynergy_16_17"] = {text = "{V}% chance to preserve resources in Crafting when creating Rings or Amulets only.", skills = {'Crafting'}},
["summoningSynergy_16_18"] = {text = "Crafting Potions now last twice as long. Bonus is applied when a new potion is activated. Charges are used per Crafting action.", skills = {'Crafting'}},
["summoningSynergy_16_18"] = {text = "Crafting Potions now last twice as long. Bonus is applied when a new potion is activated. Charges are used per Crafting action.", skills = {'Crafting'}},
Line 199: Line 199:
["ChanceToConvertSeedDrops"] = { text = "{V}% chance to convert combat seed drops to herbs", skills = {'Combat'} },
["ChanceToConvertSeedDrops"] = { text = "{V}% chance to convert combat seed drops to herbs", skills = {'Combat'} },
["CompostPreservationChance"] = { text = "{V}% Chance to preserve Compost or Weird Gloop applied to Farming Plots when harvesting", skills = {'Farming'} },
["CompostPreservationChance"] = { text = "{V}% Chance to preserve Compost or Weird Gloop applied to Farming Plots when harvesting", skills = {'Farming'} },
["Confusion"] = { text = "Take {V}% of remaining HP as damage on a succesful attack", isIncreaseNegative = true, skills = {'Combat'} },
["Confusion"] = { text = "{V}% of remaining Hitpoints taken as damage on a successful attack (once per turn)", isIncreaseNegative = true, skills = {'Combat'} },
["curseImmunity"] = { text = "Immune to curses", skills = {'Combat'} },
["curseImmunity"] = { text = "Immune to curses", skills = {'Combat'} },
["DamageReductionPercent"] = { text = "{V}% increased damage reduction", skills = {'Combat'} },
["DamageReductionPercent"] = { text = "{V}% Damage Reduction", skills = {'Combat'} },
["DamageTaken"] = { text = "Take {V}% more Damage from attacks", isIncreaseNegative = true, skills = {'Combat'} },
["DamageTaken"] = { text = "{V}% more Damage taken", isIncreaseNegative = true, skills = {'Combat'} },
["debuffImmunity"] = { text = "Immune to debuffs", skills = {'Combat'} },
["debuffImmunity"] = { text = "Immune to debuffs", skills = {'Combat'} },
["Decay"] = { text = "Take {V}% of Max HP as damage on a succesful attack", isIncreaseNegative = true, skills = {'Combat'} },
["Decay"] = { text = "{V}% of Maximum Hitpoints taken as damage on a successful attack (once per turn)", isIncreaseNegative = true, skills = {'Combat'} },
["doubleItemsSkill"] = { text = "x{VMUL} Items received from {SV0}", unsigned = true },
["doubleItemsSkill"] = { text = "x{VMUL} Items received from {SV0}", unsigned = true },
["doubleOresMining"] = { text = "x{VMUL} Ores received from Mining", unsigned = true, skills = {'Mining'} },
["doubleOresMining"] = { text = "x{VMUL} Ores received from Mining", unsigned = true, skills = {'Mining'} },
Line 213: Line 213:
["FlatReflectDamage"] = { text = "{VX} Reflect Damage", skills = {'Combat'} },
["FlatReflectDamage"] = { text = "{VX} Reflect Damage", skills = {'Combat'} },
["freeCompost"] = { text = "Composting crops in Farming is free", skills = {'Farming'} },
["freeCompost"] = { text = "Composting crops in Farming is free", skills = {'Farming'} },
["GlobalEvasion"] = { text = "{V}% increased Evasion Ratings", skills = {'Combat'} },
["GlobalEvasion"] = { text = "{V}% Global Evasion", skills = {'Combat'} },
["golbinRaidIncreasedMaximumAmmo"] = { text = "{V}% Maximum Ammo in Golbin Raid", skills = {'Combat'} },
["golbinRaidIncreasedMaximumAmmo"] = { text = "{V}% Maximum Ammo in Golbin Raid", skills = {'Combat'} },
["golbinRaidIncreasedMaximumRunes"] = { text = "{V}% Maximum Runes in Golbin Raid", skills = {'Combat'} },
["golbinRaidIncreasedMaximumRunes"] = { text = "{V}% Maximum Runes in Golbin Raid", skills = {'Combat'} },
Line 290: Line 290:
["ChanceToPreserveFood"] = { text = "{V}% chance to Preserve Food when eaten", skills = {'Combat'} },
["ChanceToPreserveFood"] = { text = "{V}% chance to Preserve Food when eaten", skills = {'Combat'} },
["ElementalEffectChance"] = { text = "{V}% chance to apply Burn, Frostburn or Freeze when hitting with a Magic attack (once per turn)", skills = {'Combat'} },
["ElementalEffectChance"] = { text = "{V}% chance to apply Burn, Frostburn or Freeze when hitting with a Magic attack (once per turn)", skills = {'Combat'} },
["EndOfTurnHealing2"] = { text = "{V}% of current hitpoints every 2 turns", skills = {'Combat'} },
["EndOfTurnHealing2"] = { text = "{V}% of current hitpoints every 2 turns", skills = {'Combat', 'Hitpoints'} },
["EndOfTurnHealing3"] = { text = "{V}% of current hitpoints every 3 turns", skills = {'Combat'} },
["EndOfTurnHealing3"] = { text = "{V}% of current hitpoints every 3 turns", skills = {'Combat', 'Hitpoints'} },
["EndOfTurnHealing5"] = { text = "{V}% of current hitpoints every 5 turns", skills = {'Combat'} },
["EndOfTurnHealing5"] = { text = "{V}% of current hitpoints every 5 turns", skills = {'Combat', 'Hitpoints'} },
["freeProtectItem"] = { text = "The Protect Item Prayer costs nothing", skills = {'Prayer'} },
["freeProtectItem"] = { text = "The Protect Item Prayer costs nothing", skills = {'Prayer'} },
["frostBurnImmunity"] = { text = "{V}% chance to ignore Frostburn", skills = {'Combat'} },
["frostBurnImmunity"] = { text = "{V}% chance to ignore Frostburn", skills = {'Combat'} },
Line 307: Line 307:
["PoisonReflectChance"] = { text = "{V}% chance to poison attackers when hit", skills = {'Combat'} },
["PoisonReflectChance"] = { text = "{V}% chance to poison attackers when hit", skills = {'Combat'} },
["rangedImmunity"] = { text = "Immune to Ranged attacks", skills = {'Combat'} },
["rangedImmunity"] = { text = "Immune to Ranged attacks", skills = {'Combat'} },
["RegenerationInterval"] = { text = "{VMS}s Hitpoint Regeneration interval", isIncreaseNegative = true, skills = {'Combat'} },
["RegenerationInterval"] = { text = "{VMS}s Hitpoint Regeneration interval", isIncreaseNegative = true, skills = {'Combat', 'Hitpoints'} },
["slowImmunity"] = { text = "{V}% chance to ignore Slow effects", skills = {'Combat'} },
["slowImmunity"] = { text = "{V}% chance to ignore Slow effects", skills = {'Combat'} },
["SurgeSpellAccuracy"] = { text = "{V}% Accuracy Rating when using Surge spells", skills = {'Combat'} },
["SurgeSpellAccuracy"] = { text = "{V}% Accuracy Rating when using Surge spells", skills = {'Combat'} },
Line 317: Line 317:
["MeleeCritMult"] = { text = "{V}% Melee critical hit multiplier", skills = {'Combat'} },
["MeleeCritMult"] = { text = "{V}% Melee critical hit multiplier", skills = {'Combat'} },
["RangedCritMult"] = { text = "{V}% Ranged critical hit multiplier", skills = {'Ranged'} },
["RangedCritMult"] = { text = "{V}% Ranged critical hit multiplier", skills = {'Ranged'} },
-- New 1.1 modifiers, TODO add actual descriptions and the sort
-- New 1.1 modifiers
["15SlowStunChance2Turns"] = { text = "TODO 15SlowStunChance2Turns", isIncreaseNegative = false, inverseSign = false, skills = {} },
["15SlowStunChance2Turns"] = { text = "{V}% chance to apply a 15% Slow for 2 Attack Turns when hitting with any attack (once per turn)", skills = {'Combat'} },
["30Slow5TurnsChance"] = { text = "TODO 30Slow5TurnsChance", isIncreaseNegative = false, inverseSign = false, skills = {} },
["30Slow5TurnsChance"] = { text = "{V}% chance to inflict a Slow that increases the target's attack interval by 30% for 5 target turns when hitting with an attack", skills = {'Combat'} },
["5DROnBeingHit"] = { text = "TODO 5DROnBeingHit", isIncreaseNegative = false, inverseSign = false, skills = {} },
["5DROnBeingHit"] = { text = "When hit by an Enemy, gain +5% Damage Reduction for 1 Enemy Turn (Does not Stack)", skills = {'Combat'} },
["AbsorbingSkin"] = { text = "TODO AbsorbingSkin", isIncreaseNegative = false, inverseSign = false, skills = {} },
["AbsorbingSkin"] = { text = "Target gains +3% Damage Reduction for every successful hit by the Attacker (Stacks up to 10 times)", skills = {'Combat'} },
["AdditionalAshInFiremaking"] = { text = "TODO AdditionalAshInFiremaking", isIncreaseNegative = false, inverseSign = false, skills = {} },
["AdditionalAshInFiremaking"] = { text = "{V} Ash per burn in Firemaking (Cannot be doubled)", isIncreaseNegative = true, skills = {'Firemaking'} },
["AgilityPillarCost"] = { text = "TODO AgilityPillarCost", isIncreaseNegative = false, inverseSign = false, skills = {} },
["AgilityPillarCost"] = { text = "{V}% Agility Pillar build costs", isIncreaseNegative = true, skills = {'Agility'} },
["allowNonMagicCurses"] = { text = "TODO allowNonMagicCurses", isIncreaseNegative = false, inverseSign = false, skills = {} },
["allowNonMagicCurses"] = { text = "Magic Curses can be used without a Magic weapon
["applyDespairCurseOnSpawn"] = { text = "TODO applyDespairCurseOnSpawn", isIncreaseNegative = false, inverseSign = false, skills = {} },
["applyMadnessCurseOnSpawn"] = { text = "TODO applyMadnessCurseOnSpawn", isIncreaseNegative = false, inverseSign = false, skills = {}
}
}


Line 617: Line 625:
local mode = GameData.getEntityByName('gamemodes', modeName)
local mode = GameData.getEntityByName('gamemodes', modeName)
if mode == nil then
if mode == nil then
error("Invalid gamemode '" .. mode .. "'", 2)
error("Invalid gamemode '" .. modeName .. "'", 2)
end
end
Line 670: Line 678:


function p.getEquipmentSlotName(id)
function p.getEquipmentSlotName(id)
return type(id) == 'number' and GameData.rawData.equipmentSlots[id] or 'Invalid'
local slotData = GameData.getEntityByID('equipmentSlots', id)
if slotData ~= nil then
return slotData.name
end
end
end


function p.getEquipmentSlotID(name)
function p.getEquipmentSlotID(name)
return GameData.rawData.equipmentSlots[name]
local slotData = GameData.getEntityByName('equipmentSlots', name)
if slotData ~= nil then
return slotData.id
end
end
end


Line 686: Line 700:
return Shared.titleCase(styleNum)
return Shared.titleCase(styleNum)
end
end
return "ERROR: Invalid combat style[[Category:Pages with script errors]]"
return Shared.printError('Invalid combat style')
end
end


Line 706: Line 720:
function p.getSlayerTierByLevel(level)
function p.getSlayerTierByLevel(level)
if type(level) ~= 'number' or level < 1 then
if type(level) ~= 'number' or level < 1 then
return "ERROR: Invalid Slayer level [[Category:Pages with script errors]]"
return Shared.printError('Invalid Slayer level')
end
end
Line 727: Line 741:
end
end
end
end
return "ERROR: Invalid Slayer tier[[Category:Pages with script errors]]"
return Shared.printError('Invalid Slayer tier')
end
end


Line 735: Line 749:
return tier.display
return tier.display
else
else
return "ERROR: Invalid Slayer tier[[Category:Pages with script errors]]"
return Shared.printError('Invalid Slayer tier')
end
end
end
end
Line 781: Line 795:


if modName == nil then
if modName == nil then
return 'ERROR: Invalid modifier type for ' .. modifier .. '[[Category:Pages with script errors]]'
return Shared.printError('Invalid modifier type for "' .. modifier .. '"')
end
end
Line 794: Line 808:
['VMUL'] = function(val) return 2^val end,
['VMUL'] = function(val) return 2^val end,
['VITEM'] = function(val)
['VITEM'] = function(val)
local item = GameData.getEntityByID('items', val)
-- For golbin raid starting weapons
local startingWeapons = { 'melvorD:Bronze_Scimitar', 'melvorD:Adamant_Scimitar' }
local itemID = startingWeapons[val + 1]
local item = GameData.getEntityByID('items', itemID)
if item ~= nil then
if item ~= nil then
return item.name
return item.name
else
return 'Unknown'
end
end
end
end
Line 832: Line 851:
end
end


local valSign = (valueUnsigned and '' or sign)
local valSign = (valueUnsigned and '' or sign or '')
resultText = string.gsub(resultText, '{(V[^}]*)}', function(rule) return valSign .. formatModValue(modMagnitude, rule) end)
resultText = string.gsub(resultText, '{(V[^}]*)}', function(rule) return valSign .. (formatModValue(modMagnitude, rule) or '') end)
resultText = string.gsub(resultText, '{S}', sign)
resultText = string.gsub(resultText, '{S}', sign)


Line 857: Line 876:


if skill ~= nil and skill ~= '' then
if skill ~= nil and skill ~= '' then
value = {p.getSkillID(skill), value}
value = { { ["skillID"] = p.getSkillID(skill), ["value"] = value } }
end
end


Line 863: Line 882:
end
end


function p.getModifiersText(modifiers, doColor)
function p.getModifiersText(modifiers, doColor, inline, maxVisible)
if inline == nil then inline = false end
if type(maxVisible) ~= 'number' then maxVisible = nil end
if modifiers == nil or Shared.tableIsEmpty(modifiers) then
if modifiers == nil or Shared.tableIsEmpty(modifiers) then
return ''
return ''
end
end


local modArray = {}
local modArray = { ["visible"] = {}, ["overflow"] = {} }
local modCount = { ["visible"] = 0, ["overflow"] = 0 }
local insertKey = 'visible'
for bonus, value in pairs(modifiers) do
for bonus, value in pairs(modifiers) do
table.insert(modArray, p._getModifierText(bonus, value, doColor))
-- If there is a single by skill modifier with multiple values, this will
-- appear as multiple rows. Split these so the number of visible lines is
-- always accurate
local valueArray = nil
if type(value) == 'table' then
valueArray = value
else
valueArray = {value}
end
for i, subVal in ipairs(valueArray) do
if type(subVal) == 'table' and subVal.skillID ~= nil then
subVal = {subVal}
end
if maxVisible ~= nil and not inline and insertKey == 'visible' and modCount[insertKey] >= maxVisible then
insertKey = 'overflow'
end
table.insert(modArray[insertKey], p._getModifierText(bonus, subVal, doColor))
modCount[insertKey] = modCount[insertKey] + 1
end
end
if inline then
return table.concat(modArray['visible'], ' and ')
else
if modCount['overflow'] == 1 then
table.insert(modArray['visible'], modArray['overflow'][1])
end
local overflowText = ''
if modCount['overflow'] > 1 then
-- Number of other modifiers has exceeded the specified maximum
overflowText = table.concat({
'<br/><span class="mw-collapsible mw-collapsed" ',
'data-expandtext="Show ' .. Shared.formatnum(modCount['overflow']) .. ' more modifiers" ',
'data-collapsetext="Hide">',
table.concat(modArray['overflow'], '<br/>'),
'</span>'
})
end
return table.concat(modArray['visible'], '<br/>') .. overflowText
end
end
return table.concat(modArray, "<br/>")
end
end


Line 892: Line 951:
local baseName = p.getModifierDetails(modifier)
local baseName = p.getModifierDetails(modifier)
if baseName == nil then
if baseName == nil then
return { 'ERROR: Modifier '..modifier..' is invalid' }
return { Shared.printError('Modifier "' .. modifier .. '" is invalid') }
end
end


Line 905: Line 964:


return skillArray
return skillArray
end
-- Returns a modifiers table indicating modifiersNew less modifiersOld
-- The returned table can be passed to getModifiersText to obtain the
-- result in a human readable format
function p.getModifiersDifference(modifiersOld, modifiersNew)
local modHasPrefix = {}
local modDiff, modDiffBase = {}, {}
local allMods = {
{ ["mods"] = (modifiersNew or {}), ["mult"] = 1 },
{ ["mods"] = (modifiersOld or {}), ["mult"] = -1 }
}
-- Generate modifiers table containing only variances
-- Create modDiffBase with mod base names (less 'increased'/'decreased' prefixes),
for i, modDef in ipairs(allMods) do
for modName, value in pairs(modDef.mods) do
local modBaseName, modIsIncrease = modName, true
if Shared.startsWith(modName, "increased") or Shared.startsWith(modName, "decreased") then
modBaseName = string.sub(modName, 10)
modIsIncrease = Shared.startsWith(modName, "increased")
modHasPrefix[modBaseName] = true
end
local modMult = (modIsIncrease and 1 or -1) * modDef.mult
if type(value) == 'table' then
-- Skill specific modifier
if modDiffBase[modBaseName] == nil then
modDiffBase[modBaseName] = {}
end
for j, subVal in ipairs(value) do
if type(subVal) == 'table' and subVal.skillID ~= nil then
modDiffBase[modBaseName][subVal.skillID] = (modDiffBase[modBaseName][subVal.skillID] or 0) + subVal.value * modMult
end
end
else
modDiffBase[modBaseName] = (modDiffBase[modBaseName] or 0) + value * modMult
end
end
end
-- Transform modDiffBase into modDiff with the appropriate mod name within the return value
for modBaseName, value in pairs(modDiffBase) do
if type(value) == 'table' then
-- Skill specific modifier
for skillID, subVal in pairs(value) do
if subVal ~= 0 then
local modName = nil
if modHasPrefix[modBaseName] then
modName = (subVal < 0 and 'decreased' or 'increased') .. modBaseName
else
modName = modBaseName
end
if modDiff[modName] == nil then
modDiff[modName] = {}
end
table.insert(modDiff[modName], { ["skillID"] = skillID, ["value"] = math.abs(subVal) })
end
end
elseif value ~= 0 then
local modName = nil
if modHasPrefix[modBaseName] then
modName = (value < 0 and 'decreased' or 'increased') .. modBaseName
else
modName = modBaseName
end
modDiff[modName] = (modDiff[modName] or 0) + math.abs(value)
end
end
return modDiff
end
end