Module:Constants: Difference between revisions

From Melvor Idle
(Added isIncreaseNegative to SummoningShardCost modifier)
No edit summary
 
(118 intermediate revisions by 7 users not shown)
Line 1: Line 1:
local p = {}
local p = {}
local ConstantData = mw.loadData('Module:Constants/data')
local ItemData = mw.loadData('Module:Items/data')


local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local GameData = require('Module:GameData')
local Modifiers = require('Module:Modifiers')


--Just hardcoding these because I guess that's where we're at
function p.getTriangleAttribute(attribute, attackerStyle, targetStyle, modeName)
local modifierTypes = {
if type(attribute) ~= 'string' then
  ["MeleeStrengthBonus"] = { text = "{V}% Melee Strength Bonus", skills = {'Combat'} },
error("Parameter 'attribute' must be a string", 2)
  ["DamageToDungeonMonsters"] = { text = "{V}% Damage To Dungeon Monsters", skills = {'Combat'} },
elseif type(attackerStyle) ~= 'string' then
  ["GlobalMasteryXP"] = { text = "{V}% Global Mastery XP", skills = {'Woodcutting', 'Fishing', 'Firemaking', 'Cooking', 'Mining', 'Smithing', 'Thieving', 'Farming', 'Fletching', 'Crafting', 'Runecrafting', 'Herblore', 'Agility', 'Summoning'} },
error("Parameter 'attackerStyle' must be a string", 2)
  ["ChanceRandomPotionHerblore"] = { text = "{V}% chance to gain a second potion of a random tier", skills = {'Herblore'} },
elseif type(targetStyle) ~= 'string' then
  ["FlatPrayerCostReduction"] = { text = "{V} Prayer Point Cost for Prayers", inverseSign = true, skills = {'Prayer'} },
error("Parameter 'targetStyle' must be a string", 2)
  ["MinEarthSpellDmg"] = { text = "{VX} Min Earth Spell Dmg", skills = {'Magic'} },
elseif type(modeName) ~= 'string' then
  ["SlayerTaskLength"] = { text = "{V}% Slayer Task Length/Qty", skills = {'Slayer'} },
error("Parameter 'modeName' must be a string", 2)
  ["ChanceToDoubleLootCombat"] = { text = "{V}% Chance To Double Loot in Combat", skills = {'Combat'} },
end
  ["GPFromAgility"] = { text = "{V}% GP From Agility", skills = {'Agility'} },
  ["SkillXP"] = { text = "{V1}% {SV0} Skill XP" },
local mode = GameData.getEntityByName('gamemodes', modeName)
  ["MiningNodeHP"] = { text = "{V} Mining Node HP", skills = {'Mining'} },
if mode == nil then
  ["StaminaPerObstacle"] = { text = "{V} Stamina per Agility Obstacle Completion", skills = {'Agility'} },
error("Invalid gamemode '" .. modeName .. "'", 2)
  ["ChanceToDoubleItems"] = { text = "{V} Chance To Double Items" },
end
  ["FarmingYield"] = { text = "{V}% Farming Yield", skills = {'Farming'} },
  ["GPFromMonstersFlat"] = { text = "{V} GP From Monsters", skills = {'Combat'} },
local attStyle, targStyle = string.lower(attackerStyle), string.lower(targetStyle)
  ["GlobalPreservationChance"] = { text = "{V}% Chance to Preserve Resources in Skills" },
local validStyles = { 'magic', 'melee', 'ranged' }
  ["RunePreservation"] = { text = "{V}% Rune Preservation", skills = {'Magic'} },
if not Shared.contains(validStyles, string.lower(attStyle)) then
  ["MaxHitpoints"] = { text = "{VX} Maximum Hitpoints", skills = {'Combat'} },
error("Invalid value for parameter 'attackerStyle'", 2)
  ["ChanceToDoubleItemsSkill"] = { text = "{V1}% Chance to Double Items in {SV0}" },
elseif not Shared.contains(validStyles, string.lower(targStyle)) then
  ["autoSlayerUnlocked"] = { text = "{V} Auto Slayer Unlocked", skills = {'Slayer'} },
error("Invalid value for parameter 'targetStyle'", 2)
  ["HitpointRegeneration"] = { text = "{V}% Hitpoint Regeneration", skills = {'Combat'} },
end
  ["SlayerXP"] = { text = "{V}% Slayer XP", skills = {'Slayer'} },
  ["PotionChargesFlat"] = { text = "{V} Charges per Potion" },
local combatTriangle = GameData.getEntityByID('combatTriangles', mode.combatTriangle)
  ["SkillInterval"] = { text = "{VMS1}s {SV0} Interval", isIncreaseNegative = true },
if combatTriangle == nil then
  ["BankSpace"] = { text = "{V} Bank Space" },
error("No such combat triangle: " .. mode.combatTriangle)
  ["MinHitBasedOnMaxHit"] = { text = "{V}% of Maximum Hit added to Minimum Hit", skills = {'Combat'} },
end
  ["DamageToSlayerTasks"] = { text = "{V}% Damage To Slayer Tasks", skills = {'Combat'} },
local attrData = combatTriangle[attribute]
  ["Lifesteal"] = { text = "{V}% Lifesteal", skills = {'Combat'} },
if attrData == nil then
  ["HPRegenFlat"] = { text = "{VX} Flat HP Regen", skills = {'Combat'} },
error("No such attribute: " .. attribute)
  ["ChanceToDoubleOres"] = { text = "{V}% Chance to Double Ores in Mining", skills = {'Combat'} },
else
  ["MaxStamina"] = { text = "{V} Max Stamina" },
return attrData[attStyle][targStyle]
  ["MonsterRespawnTimer"] = { text = "{VMS}s Monster Respawn Timer", isIncreaseNegative = true, skills = {'Combat'} },
end
  ["SkillPreservationChance"] = { text = "{V1}% Chance to Preserve Resources in {SV0}" },
end
  ["DamageToCombatAreaMonsters"] = { text = "{V}% Damage To Combat Area Monsters", skills = {'Combat'} },
  ["TreeCutLimit"] = { text = "{V} Tree Cut Limit", skills = {'Woodcutting'} },
  ["EquipmentSets"] = { text = "{V} Equipment Sets" },
  ["HiddenSkillLevel"] = { text = "{V1} Hidden {SV0} Level" },
  ["ChanceToPreservePrayerPoints"] = { text = "{V}% Chance To Preserve Prayer Points", skills = {'Prayer'} },
  ["ReflectDamage"] = { text = "{V}% Reflect Damage", skills = {'Combat'} },
  ["MeleeEvasion"] = { text = "{V}% Melee Evasion", skills = {'Combat'} },
  ["DamageToSlayerAreaMonsters"] = { text = "{V}% Damage To Slayer Area Monsters", skills = {'Combat'} },
  ["GPFromMonsters"] = { text = "{V}% GP From Monsters", skills = {'Combat'} },
  ["MagicEvasion"] = { text = "{V}% Magic Evasion", skills = {'Combat'} },
  ["PlayerAttackSpeedPercent"] = { text = "{V}% Player Attack Speed", isIncreaseNegative = true, skills = {'Combat'} },
  ["PreservationChance"] = { text = "{V}% Chance to Preserve Resources" },
  ["DamageReduction"] = { text = "{V}% Damage Reduction", skills = {'Combat'} },
  ["MinWaterSpellDmg"] = { text = "{VX} Min Water Spell Dmg", skills = {'Magic'} },
  ["DamageToAllMonsters"] = { text = "{V}% Damage To All Monsters", skills = {'Combat'} },
  ["golbinRaidIncreasedStartingRuneCount"] = { text = "{V} to starting Elemental Rune count" },
  ["FoodHealingValue"] = { text = "{V}% Food Healing Value", skills = {'Combat'} },
  ["MinFireSpellDmg"] = { text = "{VX} Min Fire Spell Dmg", skills = {'Magic'} },
  ["SlayerCoins"] = { text = "{V}% Slayer Coins", skills = {'Slayer'} },
  ["GPFromThievingFlat"] = { text = "{V} GP From Thieving", skills = {'Thieving'} },
  ["GlobalAccuracy"] = { text = "{V}% Global Accuracy", skills = {'Combat'} },
  ["ChanceToDoubleLootThieving"] = { text = "{V}% Chance To Double Loot in Thieving", skills = {'Thieving'} },
  ["SlayerAreaEffectNegationFlat"] = { text = "{V}% Flat Slayer Area Effect Negation", skills = {'Combat'} },
  ["MagicAccuracyBonus"] = { text = "{V}% Magic Accuracy Bonus", skills = {'Combat'} },
  ["SkillIntervalPercent"] = { text = "{V1}% {SV0} Interval", isIncreaseNegative = true },
  ["GlobalSkillXP"] = { text = "{V}% Global Skill XP" },
  ["MeleeAccuracyBonus"] = { text = "{V}% Melee Accuracy Bonus", skills = {'Combat'} },
  ["DamageToBosses"] = { text = "{V}% Damage To Bosses", skills = {'Combat'} },
  ["ChanceToPreservePotionCharge"] = { text = "{V}% Chance To Preserve Potion Charge" },
  ["MaxHitPercent"] = { text = "{V}% Max Hit", skills = {'Combat'} },
  ["AltMagicSkillXP"] = { text = "{V}% Alt. Magic Skill XP", skills = {'Magic'} },
  ["StaminaPreservationChance"] = { text = "{V}% Chance to Preserve Stamina" },
  ["MinAirSpellDmg"] = { text = "{VX} Min Air Spell Dmg", skills = {'Combat'} },
  ["AutoEatEfficiency"] = { text = "{V}% Auto Eat Efficiency", skills = {'Combat'} },
  ["GPFromThieving"] = { text = "{V}% GP From Thieving", skills = {'Thieving'} },
  ["ChanceToDoubleItemsGlobal"] = { text = "{V}% Chance to Double Items Globally" },
  ["GPGlobal"] = { text = "{V}% GP from all sources (Except Item Selling)", skills = {'Combat', 'Thieving', 'Agility'} },
  ["RangedAccuracyBonus"] = { text = "{V} Ranged Accuracy Bonus", skills = {'Combat'} },
  ["AutoEatThreshold"] = { text = "{V}% Auto Eat Threshold", skills = {'Combat'} },
  ["PlayerAttackSpeed"] = { text = "{VMS}s Player Attack Speed", isIncreaseNegative = true, skills = {'Combat'} },
  ["freeBonfires"] = { text = "+ Automatically relight bonfires for free", skills = {'Firemaking'} },
  ["AutoEatHPLimit"] = { text = "{V}% Auto Eat HP Limit", skills = {'Combat'} },
  ["BankSpaceShop"] = { text = "{V} Bank Space from Shop" },
  ["BirdNestDropRate"] = { text = "{V}% Bird Nest drop rate", skills = {'Woodcutting'} },
  ["RangedEvasion"] = { text = "{V}% Ranged Evasion", skills = {'Combat'} },
  ["ChanceDoubleHarvest"] = { text = "{V}% chance for double harvest", skills = {'Farming'} },
  ["golbinRaidStartingWeapon"] = { text = "Start the Golbin Raid with an {IV}" },
  ["AttackRolls"] = { text = "+Lucky Hit Chance (Roll twice, take the better result)", skills = {'Combat'} },
  ["AmmoPreservation"] = { text = "{V}% Ammo Preservation", skills = {'Ranged'} },
  ["RangedStrengthBonus"] = { text = "{V}% Ranged Strength Bonus", skills = {'Combat'} },
  ["MagicDamageBonus"] = { text = "{V}% Magic Damage Bonus", skills = {'Combat'} },
  ["MasteryXP"] = { text = "{V1}% {SV0} Mastery XP" },
  ["dungeonEquipmentSwapping"] = { text = "{V} Dungeon Equipment Swapping", skills = {'Combat'} },
  ["SeeingGoldChance"] = { text = "{V}% chance for Silver Ore to also produce a Gold Bar when smithed", skills = {'Smithing'} },
  ["ElementalRuneGain"] = { text = "{V} runes received when generating random elemental runes", skills = {'Runecrafting'} },
  ["StaminaCost"] = { text = "{V} Stamina Cost per action", isIncreaseNegative = true },
  ["GPFromSales"] = { text = "{V}% GP From Sales" },
  ["MaxHitFlat"] = { text = "{VX} Max Hit", skills = {'Combat'} },
  ["ChanceNoDamageMining"] = { text = "{V}% chance to do zero damage to Ores and Rune Essence", skills = {'Mining'} },
  ["ChanceForElementalRune"] = { text = "{V}% chance to receive random elemental runes per Runecraft", skills = {'Runecrafting'} },
  ["ChanceToApplyBurn"] = { text = "{V}% Chance to apply Burn to Enemy in Combat", skills = {'Combat'} },
  ["SummoningShardCost"] = { text = "{V} Shard Cost when creating Familiars in Summoning", skills = {'Summoning'}, isIncreaseNegative = true },
  ["SummoningCreationCharges"] = { text = "{V} Base Quantity for Summoning Tablet Creation", skills = {'Summoning'} },
  ["SummoningChargePreservation"] = { text = "{V}% Chance to preserve Summoning Charges", skills = {'Summoning'} },
  ["GPOnEnemyHit"] = { text = "{V} GP Gained on successful Enemy Hit", skills = {'Combat'} },
  ["AdditionalRunecraftCountRunes"] = { text = "{V} Additional Runes of the same type in Runecrafting", skills = {'Runecrafting'} },
  ["ChanceAdditionalSkillResource"] = { text = "{V1}% Chance to gain +1 additional resource in {SV0}. Cannot be doubled" },
  ["EnemyMeleeEvasion"] = { text = "{V}% Enemy Melee Evasion", isIncreaseNegative = true, skills = {'Combat'} },
  ["EnemyRangedEvasion"] = { text = "{V}% Enemy Ranged Evasion", isIncreaseNegative = true, skills = {'Combat'} },
  ["EnemyMagicEvasion"] = { text = "{V}% Enemy Magic Evasion", isIncreaseNegative = true, skills = {'Combat'} },
  ["summoningSynergy_0_1"] = {text = "Upon killing an Enemy, grants GP equal to {V}% of their highest base Evasion Rating.", skills = {"Combat",}},
  ["summoningSynergy_0_6"] = {text = "Grants GP equal to {V}% of your MELEE damage dealt.", skills = {"Combat"}},
  ["summoningSynergy_0_7"] = {text = "Grants GP equal to {V}% of your RANGED damage dealt.", skills = {"Combat"}},
  ["summoningSynergy_0_8"] = {text = "Grants GP equal to {V}% of your MAGIC damage dealt.", skills = {"Combat"}},
  ["summoningSynergy_0_12"] = {text = "Upon killing a Slayer Task Enemy, grants {V}% GP.", skills = {"Combat"}},
  ["summoningSynergy_0_13"] = {text = "Upon being hit by an Enemy, grants GP equal to ({V} * Your Damage Reduction). This can only proc once every Enemy Attack Turn.", skills = {"Combat"}},
  ["summoningSynergy_0_14"] = {text = "Every time you regenerate Hitpoints (Not eating), grants GP equal to (${1000/numberMultiplier} * Hitpoints Regenerated).", skills = {"Combat"}},
  ["summoningSynergy_0_15"] = {text = "Upon killing an Enemy that is BURNING, grants {V}% GP.", skills = {"Combat"}},
  ["summoningSynergy_1_2"] = {text = "When player has full HP, effects from the Occultist Familiar are tripled.", skills = {"Combat"}},
  ["summoningSynergy_1_8"] = {text = "{V} Magic Defence Bonus.", skills = {"Combat"}},
  ["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_14"] = {text = "If the Enemy has more combined Evasion Ratings than the Player, grants {V}% Hitpoint Regeneration.", skills = {"Combat"}},
  ["summoningSynergy_1_15"] = {text = "If the Player is BURNING, grants {V} Melee, Ranged and Magic Defence Bonus.", skills = {"Combat"}},
  ["summoningSynergy_2_6"] = {text = "If using a Melee Attack Style, grants {V}% Lifesteal.", skills = {"Combat", 'Melee'}},
  ["summoningSynergy_2_7"] = {text = "If using a Ranged Attack Style, grants {V}% Lifesteal.", skills = {"Combat", 'Ranged'}},
  ["summoningSynergy_2_8"] = {text = "If using a Magic Attack Style, grants {V}% Lifesteal.", skills = {"Combat", 'Magic'}},
  ["summoningSynergy_2_12"] = {text = "Grants Slayer Coins equal to {V}% of HP leeched from Lifesteal.", skills = {"Slayer"}},
  ["summoningSynergy_2_13"] = {text = "Upon attacking an Enemy, heals you for {V}% of your Damage Reduction. This can only proc once every 2 seconds.", skills = {"Combat"}},
  ["summoningSynergy_2_14"] = {text = "{V}% Lifesteal from Bleed damage.", skills = {"Combat", 'Melee'}},
  ["summoningSynergy_2_15"] = {text = "Heals you for all damage dealt by the Wolf & Dragon Familiars.", skills = {"Combat"}},
  ["summoningSynergy_3_4"] = {text = "{V}% chance per action in Woodcutting to gain a random Gem.", skills = {'Woodcutting'}},
  ["summoningSynergy_3_5"] = {text = "{V}% Increased Special Item chance in Fishing. {V}% Increased chance to obtain a Bird Nests in Woodcutting.", skills = {'Fishing'}},
  ["summoningSynergy_3_9"] = {text = "{V}% chance to receive +1 Cooked Food in Cooking. Cannot be doubled.", skills = {'Cooking'}},
  ["summoningSynergy_3_10"] = {text = "{V}% Runecrafting Preservation Chance when creating Staves.", skills = {'Runecrafting'}},
  ["summoningSynergy_3_11"] = {text = "When successfully pickpocketing the Lumberjack in Thieving, grants {V} Bird Nest instead of GP.", skills = {'Thieving'}},
  ["summoningSynergy_3_16"] = {text = "In Woodcutting, {V}% chance for a random Silver or Gold Jewelry to drop instead of a Bird Nest.", skills = {'Woodcutting'}},
  ["summoningSynergy_3_17"] = {text = "{V}% chance to gain +1 Base Logs from Woodcutting, or produced Items from Smithing.", skills = {'Woodcutting'}},
  ["summoningSynergy_3_18"] = {text = "While the Bird Nest Potion is active in Woodcutting, grants {V} minimum Bird Nest.", skills = {'Woodcutting'}},
  ["summoningSynergy_3_19"] = {text = "{V}% of Woodcutting Skill XP is earned as Firemaking Skill XP. Chance to double Logs is halved.", skills = {'Woodcutting', 'Firemaking'}},
  ["summoningSynergy_4_5"] = {text = "When receiving a Gem from Mining or Fishing, there is a {V}% chance to get another random Gem.", skills = {'Fishing', 'Mining'}},
  ["summoningSynergy_4_9"] = {text = "{V}% base burn chance in Cooking. Grants 100 Coal Ore when burning Food.", skills = {'Cooking'}},
  ["summoningSynergy_4_10"] = {text = "Base quantity for Rune Essence in Mining is doubled.", skills = {'Mining'}},
  ["summoningSynergy_4_11"] = {text = "When successfully pickpocketing the Miner in Thieving, {V}% chance to get a random Gem.", skills = {'Thieving'}},
  ["summoningSynergy_4_16"] = {text = "Base quantity for Silver Ore & Gold Ore is doubled in Mining.", skills = {'Mining'}},
  ["summoningSynergy_4_17"] = {text = "{V}% chance to receive a smithed verion of the Ore you are Mining.", skills = {'Mining'}},
  ["summoningSynergy_4_18"] = {text = "While the Perfect Swing Potion is active in Mining, all Mining Nodes have {V} Max HP.", skills = {'Mining'}},
  ["summoningSynergy_4_19"] = {text = "{V}% chance to recieve a Diamond per action in Firemaking.", skills = {'Firemaking'}},
  ["summoningSynergy_5_9"] = {text = "{V}% chance to recieve an extra Fish as a Cooked version while Fishing.", skills = {'Fishing'}},
  ["summoningSynergy_5_10"] = {text = "In Runecrafting, when creating a Combination Rune that requires Water Runes as an ingredient, produce {V} extra Combination Runes.", skills = {'Runecrafting'}},
  ["summoningSynergy_5_11"] = {text = "-50% Thieving Skill Interval for Fisherman only. Also grants +2 Base Thieving Item Qty from Fisherman only.", skills = {'Thieving'}},
  ["summoningSynergy_5_16"] = {text = "33% chance to gain a random Gem while creating Jewelry in Crafting.", skills = {'Crafting'}},
  ["summoningSynergy_5_17"] = {text = "While creating Dragon Gear in Smithing, grants {V}% Smithing Preservation chance.", skills = {'Smithing'}},
  ["summoningSynergy_5_18"] = {text = "{V}% charges when using the Fishermans Potion. Bonus is applied when new Potion is activated. Charges are used each Fishing action.", skills = {'Fishing'}},
  ["summoningSynergy_6_7"] = {text = "While fighting a Ranged Enemy, grants {V} Melee Accuracy Bonus and {V} Melee Strength Bonus.", skills = {"Combat", 'Melee'}},
  ["summoningSynergy_6_8"] = {text = "While fighting your current Slayer Task, grants {V}% of your Magic Max Hit as Minimum Damage.", skills = {"Combat", 'Magic'}},
  ["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_14"] = {text = "While using a Melee Weapon, grants {V}% of your Melee Max Hit as Flat HP Regen.", 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_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_14"] = {text = "While using a Ranged Weapon, grants {V}% of your Ranged Max Hit as HP Regeneration.", 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_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_9_10"] = {text = "{V}% chance to preserve resources in Cooking, and when creating Runes in Runecrafting.", skills = {'Runecrafting'}},
  ["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_17"] = {text = "-{VMS}s Skill Interval for Cooking & Smithing.", skills = {'Cooking', 'Smithing'}},
  ["summoningSynergy_9_18"] = {text = "Generous Cook Potions now provide {V}% charges. This bonus is applied when a new potion is activated.", skills = {'Cooking'}},
  ["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_17"] = {text = "This modifier exists in the game code but doesn't do anything."},
  ["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_11_16"] = {text = "Upon receiving an item in Thieving, grants GP equal to {VX100}% of its sale price.", skills = {'Thieving'}},
  ["summoningSynergy_11_17"] = {text = "Upon successfully pickpocketting an item from the Miner in Thieving, {V}% chance to receive a random Bar.", skills = {'Thieving'}},
  ["summoningSynergy_11_18"] = {text = "{V}% chance to obtain a single Herb Sack while Thieving the Farmer, on top of the original item obtained.", 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_14"] = {text = "While fighting your current Slayer Task, {V}% Hitpoints Regeneration.", skills = {"Combat"}},
  ["summoningSynergy_12_15"] = {text = "You take {V}% less damage from Dragonbreath Special Attacks.", skills = {"Combat"}},
  ["summoningSynergy_13_14"] = {text = "{V}% Hitpoints Regeneration if you have less than 75% Current HP.", skills = {"Combat"}},
  ["summoningSynergy_13_15"] = {text = "You take no damage from BURNING.", skills = {"Combat"}},
  ["summoningSynergy_14_15"] = {text = "You now heal for all BURNING damage you or the Dragon Familiar applies.", skills = {"Combat", 'Magic'}},
  ["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_19"] = {text = "Burning Logs in Firemaking grants GP equal to {V+100}% of its base sale price.", skills = {'Firemaking'}},
  ["summoningSynergy_17_18"] = {text = "While using the Seeing Gold Potion in Smithing, double Silver & Gold Bar output.", skills = {'Smithing'}},
  ["summoningSynergy_17_19"] = {text = "{V} Coal required for Smithing Item production.", skills = {'Smithing'}, inverseSign = true},
  ["summoningSynergy_18_19"] = {text = "While using the Controlled Heat Potions, +5% Firemaking Skill XP and Bonfire duration is doubled. Charges are used per Firemaking action.", skills = {'Firemaking'}},
}
 
--Difficulties are hard coded which is dumb but means hardcoding them here too
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
function p.getTriangleDamageModifier(attackerStyle, targetStyle, mode)
local CombatTriangle = {
return p.getTriangleAttribute('damageModifier', attackerStyle, targetStyle, mode)
  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)
  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


--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


function p.getDifficultyString(difficulty)
function p.getDifficultyString(difficulty)
  return Difficulties[difficulty]
return GameData.rawData.combatAreaDifficulties[difficulty + 1]
end
end


function p.getSkillName(skillID)
function p.getSkillName(skillID)
  for skName, ID in Shared.skpairs(ConstantData.skill) do
local skill = GameData.getSkillData(skillID)
    if ID == skillID then
if skill ~= nil then
      return skName
return skill.name
    end
end
  end
  return nil
end
end


function p.getSkillID(skillName)
function p.getSkillID(skillName)
  return ConstantData.skill[skillName]
for i, skillData in ipairs(GameData.rawData.skillData) do
if skillData.data.name == skillName then
return skillData.skillID
end
end
end
 
function p.getSkillIDText(frame)
local skillName = frame.args ~= nil and frame.args[1] or frame[1]
local id = p.getSkillID(skillName)
if id == nil or id == '' then
return "Unknown"
else
return id
end
end
end


function p.getEquipmentSlotName(id)
function p.getEquipmentSlotName(id)
  for slotName, i in Shared.skpairs(ConstantData.equipmentSlot) do
local slotData = GameData.getEntityByID('equipmentSlots', id)
    if i == id then
if slotData ~= nil then
      return slotName
return slotData.emptyName
    end
end
  end
  return 'Invalid'
end
end


function p.getEquipmentSlotID(name)
function p.getEquipmentSlotID(name)
  return ConstantData.equipmentSlot[name]
local slotData = GameData.getEntityByProperty('equipmentSlots', 'emptyName', name)
if slotData ~= nil then
return slotData.id
end
end
end


function p.getCombatStyleName(styleNum)
function p.getCombatStyleName(styleNum)
  for name, num in Shared.skpairs(ConstantData.attackType) do
if type(styleNum) == 'number' then
    if num == styleNum then
local styleName = GameData.rawData.attackTypes[styleNum]
      return name
if styleName ~= nil then
    end
return Shared.titleCase(styleName)
  end
end
  return "ERROR: Invalid combat style[[Category:Pages with script errors]]"
elseif type(styleNum) == 'string' and type(GameData.rawData.attackTypes[string.lower(styleNum)]) == 'number' then
return Shared.titleCase(styleNum)
end
return Shared.printError('Invalid combat style')
end
end


function p.getSlayerTierName(tier)
  for name, num in Shared.skpairs(ConstantData.slayerTier) do
    if num == tier then
      return name
    end
  end
  return "ERROR: Invalid Slayer tier[[Category:Pages with script errors]]"
end


function p.getSlayerTierNameByLevel(lvl)
--- Slayer functions
  for i, tier in Shared.skpairs(ConstantData.Slayer.Tiers) do
--
    if tier.minLevel <= lvl and (tier.maxLevel >= lvl or tier.maxLevel == -1) then
function p.getSlayerTierByID(tierID)
      return tier.display
if type(tierID) ~= 'number' then
    end
return nil
  end
else
  return 'N/A'
return GameData.rawData.slayerTaskCategories[tierID + 1]
end
end
end


function p.getSlayerTier(name)
function p.getSlayerTier(name)
  for i, tier in Shared.skpairs(ConstantData.Slayer.Tiers) do
return GameData.getEntityByProperty('slayerTiers', 'display', name)
    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.getSlayerTierByLevel(level)
  if ConstantData.Slayer.Tiers[tierID + 1] == nil then
if type(level) ~= 'number' or level < 1 then
    return nil
return Shared.printError('Invalid Slayer level')
  end
end


  local result = Shared.clone(ConstantData.Slayer.Tiers[tierID + 1])
for i, tier in ipairs(GameData.rawData.slayerTaskCategories) do
  result.id = tierID
if tier.type == 'CombatLevel' and tier.minLevel <= level and (tier.maxLevel == nil or tier.maxLevel >= level) then
  return result
return tier
end
end
end
end


--Turns a modifier name like 'increasedMeleeAccuracyBonus' into several pieces of data:
--
--Base Name, Text, Sign, and IsNegative
-- the following functions just return subsets of the slayer functions above
--ex. "MeleeAccuracyBonus", "+{V}% Melee Accuracy", "+", false
--
function p.getModifierDetails(modifierName)
  local baseName = modifierName
  local isIncrease = true
  local isNegative = false


  if Shared.startsWith(modifierName, "increased") or Shared.startsWith(modifierName, "decreased") then
function p.getSlayerTierName(tierID)
    baseName = string.sub(modifierName, 10)
if type(tierID) == 'number' then
    isIncrease = Shared.startsWith(modifierName, "increased")
local tier = p.getSlayerTierByID(tierID)
  end
if tier ~= nil then
return tier.display
end
end
return Shared.printError('Invalid Slayer tier')
end


  local modifier = modifierTypes[baseName]
function p.getSlayerTierNameByLevel(lvl)
  if modifier == nil then
local tier = p.getSlayerTierByLevel(lvl)
    return nil
if type(tier) == 'table' then
  end
return tier.display
 
else
  local isPositive = isIncrease
return Shared.printError('Invalid Slayer tier')
  if modifier.isIncreaseNegative then
end
    isPositive = not isPositive
  end
 
  local sign = "+"
  if (not isIncrease and not modifier.inverseSign) or (isIncrease and modifier.inverseSign) then
    sign = "-"
  end
 
  return baseName, modifier.text, sign, not isPositive
end
end


function p._getModifierText(modifier, value, doColor)
--
  if doColor == nil then doColor = true end
--- End of slayer functions
  local modName, modText, sign, isNegative = p.getModifierDetails(modifier)


  if modName == nil then
--Turns a modifier name like 'increasedHPRegenFlat' into several pieces of data:
    return 'ERROR: Invalid modifier type [[Category:Pages with script errors]]'
--Base Name, Description, IsNegative, and modifyValue
  end
--ex. "HPRegenFlat", "+${value} Flat Hitpoints Regeneration", false, "multiplyByNumberMultiplier"
function p.getModifierDetails(modifierName)
-- Unsupported
error('Function is no longer supported', 2)
--[==[
local baseName = modifierName
local modifier = GameData.rawData.modifierData[modifierName]


  local result = modText
if modifier == nil then
return nil
end


  if type(value) == 'table' then
if Shared.startsWith(modifierName, "increased") or Shared.startsWith(modifierName, "decreased") then
    if Shared.tableCount(value) > 0 and type(value[1]) == 'table' then
baseName = string.sub(modifierName, 10)
      --Potentially return multiple rows if necessary
end
      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
        result = string.gsub(result, '{V1}', sign..value[2])
        result = string.gsub(result, '{VMS1}', sign..(value[2] / 1000))
      end
    end
  else
    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}', sign..value)
    result = string.gsub(result, '{VMS}', sign..(value / 1000))
    result = string.gsub(result, '{VX}', sign..(value * 10))
    result = string.gsub(result, '{VX100}', sign..(value * 100))
    result = string.gsub(result, '{V+100}', sign..(value + 100))
  end


  if doColor then
return baseName, modifier.description, modifier.isNegative, modifier.modifyValue
    if isNegative ~= nil and isNegative then
--]==]
      result = '<span style="color:red">'..result..'</span>'
end
    else
      result = '<span style="color:green">'..result..'</span>'
    end
  end


  return result
function p._getModifierText(modifier, value, doColor)
return Modifiers.getModifierText(modifier, value, doColor)
end
end


function p.getModifierText(frame)
function p.getModifierText(frame)
  local modifier = frame.args ~= nil and frame.args[1] or frame[1]
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 value = frame.args ~= nil and frame.args[2] or frame[2]
  local skill = frame.args ~= nil and frame.args.skill or frame.skill
local skill = frame.args ~= nil and frame.args.skill or frame.skill
  local doColor = frame.args ~= nil and frame.args[3] or frame[3]
local doColor = frame.args ~= nil and frame.args[3] or frame[3]


  if doColor ~= nil then
if doColor ~= nil then
    doColor = string.upper(doColor) ~= 'FALSE'
doColor = string.upper(doColor) ~= 'FALSE'
  end
end


  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


  return p._getModifierText(modifier, value, doColor)
return p._getModifierText(modifier, value, doColor)
end
end


function p.getModifiersText(modifiers, doColor)
function p.getModifiersText(modifiers, doColor, inline, maxVisible)
  if modifiers == nil or Shared.tableCount(modifiers) == 0 then
return Modifiers.getModifiersText(modifiers, doColor, inline, maxVisible)
    return ''
end
  end


  local modArray = {}
function p.getModifierSkills(modifiers)
  for bonus, value in Shared.skpairs(modifiers) do
return Modifiers.getModifierSkills(modifiers)
    table.insert(modArray, p._getModifierText(bonus, value, doColor))
  end
  return table.concat(modArray, "<br/>")
end
end


function p.getModifierSkills(modifiers)
-- Returns a modifiers table indicating modifiersNew less modifiersOld
  local skillArray = {}
-- 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


  for modifier, value in Shared.skpairs(modifiers) do
if type(value) == 'table' then
    if type(value) == 'table' then
-- Skill specific modifier
      for i, subVal in Shared.skpairs(value) do
if modDiffBase[modBaseName] == nil then
        local skillName = p.getSkillName(subVal[1])
modDiffBase[modBaseName] = {}
        if not Shared.contains(skillArray, skillName) then
end
          table.insert(skillArray, skillName)
for j, subVal in ipairs(value) do
        end
if type(subVal) == 'table' and subVal.skillID ~= nil then
      end
modDiffBase[modBaseName][subVal.skillID] = (modDiffBase[modBaseName][subVal.skillID] or 0) + subVal.value * modMult
    end
end
end
else
modDiffBase[modBaseName] = (modDiffBase[modBaseName] or 0) + value * modMult
end
end
end


    local baseName = p.getModifierDetails(modifier)
-- Transform modDiffBase into modDiff with the appropriate mod name within the return value
    if baseName == nil then
for modBaseName, value in pairs(modDiffBase) do
      return { 'ERROR: Modifier '..modifier..' is invalid' }
if type(value) == 'table' then
    end
-- 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)
if GameData.rawData.modifierData[modName] == nil then
modDiff[modName] = nil
end
end
end


    if modifierTypes[baseName].skills ~= nil then
return modDiff
      for i, skillName in Shared.skpairs(modifierTypes[baseName].skills) do
end
        if not Shared.contains(skillArray, skillName) then
          table.insert(skillArray, skillName)
        end
      end
    end
  end


  return skillArray
-- From game version 1.1 onwards, some entities have custom descriptions, while
-- many are generated based on the modifiers associated to that entity. This
-- function handles that logic given a custom description (may be nil) and
-- a modifiers object
function p.getDescription(customDescription, modifiers)
if customDescription ~= nil then
return customDescription
else
return p.getModifiersText(modifiers, false)
end
end
end


return p
return p

Latest revision as of 22:37, 22 June 2024

Documentation for this module may be created at Module:Constants/doc

local p = {}

local Shared = require('Module:Shared')
local GameData = require('Module:GameData')
local Modifiers = require('Module:Modifiers')

function p.getTriangleAttribute(attribute, attackerStyle, targetStyle, modeName)
	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(modeName) ~= 'string' then
		error("Parameter 'modeName' must be a string", 2)
	end
	
	local mode = GameData.getEntityByName('gamemodes', modeName)
	if mode == nil then
		error("Invalid gamemode '" .. modeName .. "'", 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 combatTriangle = GameData.getEntityByID('combatTriangles', mode.combatTriangle)
	if combatTriangle == nil then
		error("No such combat triangle: " .. mode.combatTriangle)
	end
	local attrData = combatTriangle[attribute]
	if attrData == nil then
		error("No such attribute: " .. attribute)
	else
		return attrData[attStyle][targStyle]
	end
end

function p.getTriangleDamageModifier(attackerStyle, targetStyle, mode)
	return p.getTriangleAttribute('damageModifier', attackerStyle, targetStyle, mode)
end

--Syntax is like p.getTriangleDRModifier('Melee', 'Ranged', 'Normal')
--Returns a multiplier that can be multiplied with base DR to get the post-Triangle result
function p.getTriangleDRModifier(attackerStyle, targetStyle, mode)
	return p.getTriangleAttribute('reductionModifier', attackerStyle, targetStyle, mode)
end

function p.getDifficultyString(difficulty)
	return GameData.rawData.combatAreaDifficulties[difficulty + 1]
end

function p.getSkillName(skillID)
	local skill = GameData.getSkillData(skillID)
	if skill ~= nil then
		return skill.name
	end
end

function p.getSkillID(skillName)
	for i, skillData in ipairs(GameData.rawData.skillData) do
		if skillData.data.name == skillName then
			return skillData.skillID
		end
	end
end

function p.getSkillIDText(frame)
	local skillName = frame.args ~= nil and frame.args[1] or frame[1]
	local id = p.getSkillID(skillName)
	
	if id == nil or id == '' then
		return "Unknown"
	else
		return id
	end
end

function p.getEquipmentSlotName(id)
	local slotData = GameData.getEntityByID('equipmentSlots', id)
	if slotData ~= nil then
		return slotData.emptyName
	end
end

function p.getEquipmentSlotID(name)
	local slotData = GameData.getEntityByProperty('equipmentSlots', 'emptyName', name)
	if slotData ~= nil then
		return slotData.id
	end
end

function p.getCombatStyleName(styleNum)
	if type(styleNum) == 'number' then
		local styleName = GameData.rawData.attackTypes[styleNum]
		if styleName ~= nil then
			return Shared.titleCase(styleName)
		end
	elseif type(styleNum) == 'string' and type(GameData.rawData.attackTypes[string.lower(styleNum)]) == 'number' then
		return Shared.titleCase(styleNum)
	end
	return Shared.printError('Invalid combat style')
end


--- Slayer functions
--
function p.getSlayerTierByID(tierID)
	if type(tierID) ~= 'number' then
		return nil
	else
		return GameData.rawData.slayerTaskCategories[tierID + 1]
	end
end

function p.getSlayerTier(name)
	return GameData.getEntityByProperty('slayerTiers', 'display', name)
end

function p.getSlayerTierByLevel(level)
	if type(level) ~= 'number' or level < 1 then
		return Shared.printError('Invalid Slayer level')
	end

	for i, tier in ipairs(GameData.rawData.slayerTaskCategories) do
		if tier.type == 'CombatLevel' and tier.minLevel <= level and (tier.maxLevel == nil or tier.maxLevel >= level) then
			return tier
		end
	end
end

--
-- the following functions just return subsets of the slayer functions above
--

function p.getSlayerTierName(tierID)
	if type(tierID) == 'number' then
		local tier = p.getSlayerTierByID(tierID)
		if tier ~= nil then
			return tier.display
		end
	end
	return Shared.printError('Invalid Slayer tier')
end

function p.getSlayerTierNameByLevel(lvl)
	local tier = p.getSlayerTierByLevel(lvl)
	if type(tier) == 'table' then
		return tier.display
	else
		return Shared.printError('Invalid Slayer tier')
	end
end

--
--- End of slayer functions

--Turns a modifier name like 'increasedHPRegenFlat' into several pieces of data:
--Base Name, Description, IsNegative, and modifyValue
--ex. "HPRegenFlat", "+${value} Flat Hitpoints Regeneration", false, "multiplyByNumberMultiplier"
function p.getModifierDetails(modifierName)
	-- Unsupported
	error('Function is no longer supported', 2)
	--[==[
	local baseName = modifierName
	local modifier = GameData.rawData.modifierData[modifierName]

	if modifier == nil then
		return nil
	end

	if Shared.startsWith(modifierName, "increased") or Shared.startsWith(modifierName, "decreased") then
		baseName = string.sub(modifierName, 10)
	end

	return baseName, modifier.description, modifier.isNegative, modifier.modifyValue
	--]==]
end

function p._getModifierText(modifier, value, doColor)
	return Modifiers.getModifierText(modifier, value, doColor)
end

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 = { { ["skillID"] = p.getSkillID(skill), ["value"] = value } }
	end

	return p._getModifierText(modifier, value, doColor)
end

function p.getModifiersText(modifiers, doColor, inline, maxVisible)
	return Modifiers.getModifiersText(modifiers, doColor, inline, maxVisible)
end

function p.getModifierSkills(modifiers)
	return Modifiers.getModifierSkills(modifiers)
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)
			if GameData.rawData.modifierData[modName] == nil then
				modDiff[modName] = nil
			end
		end
	end

	return modDiff
end

-- From game version 1.1 onwards, some entities have custom descriptions, while
-- many are generated based on the modifiers associated to that entity. This
-- function handles that logic given a custom description (may be nil) and
-- a modifiers object
function p.getDescription(customDescription, modifiers)
	if customDescription ~= nil then
		return customDescription
	else
		return p.getModifiersText(modifiers, false)
	end
end

return p