Module:AuronTest: Difference between revisions

From Melvor Idle
mNo edit summary
m (Test Items module without cloning in order to assess impact on memory consumption)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
--This module contains all sorts of functions for getting data on items
--Several functions related to use tables can be found at Module:Items/UseTables
--Functions related to source tables can be found at Module:Items/SourceTables
--Other functions moved to Module:Items/ComparisonTables
local p = {}
local p = {}


local ConstantData = mw.loadData('Module:AuronTest/data')
local ItemData = mw.loadData('Module:Items/data')
local ItemData = mw.loadData('Module:Items/data')


local Constants = require('Module:Constants')
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Icons = require('Module:Icons')


--Just hardcoding these because I guess that's where we're at
p.EasterEggs = {'Amulet of Calculated Promotion', 'Clue Chasers Insignia', '8', 'Lemon', 'Easter Egg', 'Abnormal Log', 'Red Herring', 'Cool Glasses'}
local modifierTypes = {
p.EventItems = {'Christmas Cracker', 'Christmas Coal', 'Christmas Sweater',
  ["MeleeStrengthBonus"] = { text = "{V}% Melee Strength Bonus", skills = {'Combat'} },
'Christmas Wreath', 'Candy Cane', 'Santa Hat',
  ["DamageToDungeonMonsters"] = { text = "{V}% Damage To Dungeon Monsters", skills = {'Combat'} },
'Friendship Bracelet', 'Event Clue 1', 'Event Clue 2',
  ["GlobalMasteryXP"] = { text = "{V}% Global Mastery XP", skills = {'Woodcutting', 'Fishing', 'Firemaking', 'Cooking', 'Mining', 'Smithing', 'Thieving', 'Farming', 'Fletching', 'Crafting', 'Runecrafting', 'Herblore', 'Agility', 'Summoning', 'Astrology'} },
'Event Clue 3', 'Event Clue 4', 'Candle', 'Cake Base',
  ["ChanceRandomPotionHerblore"] = { text = "{V}% chance to gain a second potion of a random tier", skills = {'Herblore'} },
'Magical Flavouring', 'Magical Icing', 'Birthday Cake',
  ["FlatPrayerCostReduction"] = { text = "{V} Prayer Point Cost for Prayers", inverseSign = true, skills = {'Prayer'} },
'Purple Party Hat', 'Birthday Token', 'Christmas Present (Yellow)',
  ["MinEarthSpellDmg"] = { text = "{VX} Min Earth Spell Dmg", skills = {'Magic'} },
'Christmas Present (Blue)', 'Christmas Present (Green)', 'Christmas Present (White)',
  ["SlayerTaskLength"] = { text = "{V}% Slayer Task Length/Qty", skills = {'Slayer'} },
'Christmas Present (Purple)', 'Christmas Present (Standard)', 'Event Token - Holiday 2021',
  ["ChanceToDoubleLootCombat"] = { text = "{V}% Chance To Double Loot in Combat", skills = {'Combat'} },
'Holiday Scarf', 'Gingerbread House', 'Gingerbread Man', 'Edible Candy Cane',
  ["GPFromAgility"] = { text = "{V}% GP From Agility", skills = {'Agility'} },
'Locked Chest', 'Locked Chest Key', 'Event Token (Holiday 2021)'}
  ["SkillXP"] = { text = "{V}% {SV0} Skill XP" },
p.OtherShopItems = {'Cooking Gloves', 'Mining Gloves', 'Gem Gloves', 'Smithing Gloves', 'Thieving Gloves'}
  ["MiningNodeHP"] = { text = "{V} Mining Node HP", skills = {'Mining'} },
--This is hardcoded, so there's no easy way to scrape it. Hopefully it doesn't change
  ["FarmingYield"] = { text = "{V}% Farming Yield", skills = {'Farming'} },
p.GemTable = {["Topaz"] = {name = 'Topaz', id = 128, chance = 50},
  ["GPFromMonstersFlat"] = { text = "{V} GP From Monsters", skills = {'Combat'} },
["Sapphire"] = {name = "Sapphire", id = 129, chance = 17.5},
  ["GlobalPreservationChance"] = { text = "{V}% Chance to Preserve Resources in Skills" },
["Ruby"] = {name = "Ruby", id = 130, chance = 17.5},
  ["RunePreservation"] = { text = "{V}% Rune Preservation", skills = {'Magic'} },
["Emerald"] = {name = "Emerald", id = 131, chance = 10},
  ["MaxHitpoints"] = { text = "{VX} Maximum Hitpoints", skills = {'Combat'} },
["Diamond"] = {name = "Diamond", id = 132, chance = 5}}
  ["ChanceToDoubleItemsSkill"] = { text = "{V}% Chance to Double Items in {SV0}" },
--The base chance to receive a gem while mining
  ["autoSlayerUnlocked"] = { text = "{V} Auto Slayer Unlocked", skills = {'Slayer'} },
p.GemChance = .01
  ["HitpointRegeneration"] = { text = "{V}% Hitpoint Regeneration", skills = {'Combat'} },
--The number of different fishing junk items
  ["PotionChargesFlat"] = { text = "{V} Charges per Potion" },
p.junkCount = 8
  ["SkillInterval"] = { text = "{VMS}s {SV0} Interval", isIncreaseNegative = true },
--Items (aside from bars & gems) which can be created via Alt Magic
  ["BankSpace"] = { text = "{V} Bank Space" },
p.AltMagicProducts = {'Rune Essence', 'Bones', 'Holy Dust'}
  ["MinHitBasedOnMaxHit"] = { text = "{V}% of Maximum Hit added to Minimum Hit", skills = {'Combat'} },
--The kinds of gloves with cost & charges
  ["DamageToSlayerTasks"] = { text = "{V}% Damage To Slayer Tasks", skills = {'Combat'} },
p.GloveTable = {['Cooking Gloves'] = {cost=50000, charges=500},
  ["Lifesteal"] = { text = "{V}% Lifesteal", skills = {'Combat'} },
['Mining Gloves'] = {cost=75000, charges=500},
  ["HPRegenFlat"] = { text = "{VX} Flat HP Regen", skills = {'Combat'} },
['Smithing Gloves'] = {cost=100000, charges=500},
  ["ChanceToDoubleOres"] = { text = "{V}% Chance to Double Ores in Mining", skills = {'Combat'} },
['Thieving Gloves'] = {cost=100000, charges=500},
  ["MonsterRespawnTimer"] = { text = "{VMS}s Monster Respawn Timer", isIncreaseNegative = true, skills = {'Combat'} },
['Gem Gloves'] = {cost=500000, charges=2000}}
  ["SkillPreservationChance"] = { text = "{V}% Chance to Preserve Resources in {SV0}" },
  ["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 = "{V} 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'} },
  ["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'} },
  ["SlayerAreaEffectNegationFlat"] = { text = "{V}% Flat Slayer Area Effect Negation", skills = {'Combat'} },
  ["MagicAccuracyBonus"] = { text = "{V}% Magic Accuracy Bonus", skills = {'Combat'} },
  ["SkillIntervalPercent"] = { text = "{V}% {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'} },
  ["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'} },
  ["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 = "{V}% {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'} },
  ["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 = "{V}% Chance to gain +1 additional resource in {SV0}. Cannot be doubled" },
  ["AttackIntervalPercent"] = { text = "{V}% Attack Interval", 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 = "{VX100}% of regenerated health gained as GP", 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_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_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_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 = "{V}% Smithing & Runecrafting Preservation Chance."},
  ["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_13_14"] = {text = "{V}% Hitpoints Regeneration if you have less than 75% Current HP.", skills = {"Combat"}},
  ["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'}},
  -- New 0.21 modifiers
  ["AgilityObstacleCost"] = { text = "{V}% Agility Obstacle Build Costs", skills = {'Agility'}, isIncreaseNegative = true },
  ["allowAttackAugmentingMagic"] = { text = "Magic Curses and Auroras can be used without a magic weapon", skills = {'Combat'} },
  ["allowSignetDrops"] = { text = "Something else drops instead of Gold Topaz Ring" },
  ["aprilFoolsDecreasedCarrotGang"] = { text = "{V} Carrot Gang reputation points", isIncreaseNegative = true, inverseSign = true, skills = {'Combat'} },
  ["aprilFoolsDecreasedLemonGang"] = { text = "{V} Lemon Gang reputation points", isIncreaseNegative = true, inverseSign = true, skills = {'Combat'} },
  ["aprilFoolsDecreasedMovementSpeed"] = { text = "{V} Movement Speed", isIncreaseNegative = true, inverseSign = true },
  ["aprilFoolsDecreasedTeleportCost"] = { text = "{V}% Rune cost for Teleportation Spells", inverseSign = true },
  ["aprilFoolsDecreasedUpdateDelay"] = { text = "{V} days next Major Update has been delayed", inverseSign = true },
  ["aprilFoolsIncreasedCarrotGang"] = { text = "{V} Carrot Gang reputation points", skills = {'Combat'} },
  ["aprilFoolsIncreasedLemonGang"] = { text = "{V} Lemon Gang reputation points", skills = {'Combat'} },
  ["aprilFoolsIncreasedMovementSpeed"] = { text = "{V} Movement Speed" },
  ["aprilFoolsIncreasedTeleportCost"] = { text = "{V}% Rune cost for Teleportation Spells", isIncreaseNegative = true },
  ["aprilFoolsIncreasedUpdateDelay"] = { text = "{V} days next Major Update has been delayed", isIncreaseNegative = true },
  ["AttackInterval"] = { text = "{VMS}s Attack Interval", isIncreaseNegative = true, skills = {'Combat'} },
  ["autoBurying"] = { text = "Bones are automatically buried for {V+100}% of their prayer point value", skills = {'Prayer'} },
  ["autoLooting"] = { text = "Combat loot is automatically collected", skills = {'Combat'} },
  ["bleedImmunity"] = { text = "Immune to bleeding", skills = {'Combat'} },
  ["BleedLifesteal"] = { text = "{V}% Bleed lifsteal", skills = {'Combat'} },
  ["BonusCoalMining"] = { text = "{V} Coal Ore per Ore Mined. (Item doubling does not apply)", skills = {'Mining'} },
  ["bonusCoalOnDungeonCompletion"] = { text = "1% chance to recieve {V} Coal when completing a dungeon", skills = {'Combat'} },
  ["burnImmunity"] = { text = "Immune to burning", skills = {'Combat'} },
  ["BurnLifesteal"] = { text = "{V}% Burn lifesteal", skills = {'Combat'} },
  ["bypassSlayerItems"] = { text = "Bypass Slayer Area item requirements", skills = {'Slayer'} },
  ["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'} },
  ["Confusion"] = { text = "Take {V}% of remaining HP as damage on a succesful attack", isIncreaseNegative = true, skills = {'Combat'} },
  ["curseImmunity"] = { text = "Immune to curses", skills = {'Combat'} },
  ["DamageReductionPercent"] = { text = "{V}% increased damage reduction", skills = {'Combat'} },
  ["DamageTaken"] = { text = "Take {V}% more Damage from attacks", isIncreaseNegative = true, 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'} },
  ["doubleItemsSkill"] = { text = "x{VMUL} Items recieved from {SV0}" },
  ["doubleOresMining"] = { text = "x{VMUL} Ores recieved from Mining", skills = {'Mining'} },
  ["DragonBreathDamage"] = { text = "{V}% damage taken from dragonbreath", isIncreaseNegative = true, skills = {'Combat'} },
  ["FiremakingCoalChance"] = { text = "{V}% chance to recieve coal when burning logs in Firemaking", skills = {'Firemaking'} },
  ["FlatMaxHitpoints"] = { text = "{VX} Maximum Hitpoints", skills = {'Hitpoints'} },
  ["FlatMinHit"] = { text = "{VX} Minimum Hit", skills = {'Combat'} },
  ["FlatReflectDamage"] = { text = "{VX} Reflect Damage", skills = {'Combat'} },
  ["freeCompost"] = { text = "Composting crops in Farming is free", skills = {'Farming'} },
  ["GlobalEvasion"] = { text = "{V}% increased Evasion Ratings", skills = {'Combat'} },
  ["golbinRaidIncreasedMaximumAmmo"] = { text = "{V}% Maximum Ammo in Golbin Raid", skills = {'Combat'} },
  ["golbinRaidIncreasedMaximumRunes"] = { text = "{V}% Maximum Runes in Golbin Raid", skills = {'Combat'} },
  ["golbinRaidIncreasedMinimumFood"] = { text = "{V} Minimum Food in Golbin Raid", skills = {'Combat'} },
  ["golbinRaidIncreasedPrayerLevel"] = { text = "{V} Prayer Levels in Golbin Raid", skills = {'Prayer'} },
  ["golbinRaidIncreasedPrayerPointsStart"] = { text = "{V} Starting Prayer Points in Golbin Raid", skills = {'Prayer'} },
  ["golbinRaidIncreasedPrayerPointsWave"] = { text = "{V} Prayer Points per Wave in Golbin Raid", skills = {'Prayer'} },
  ["golbinRaidPassiveSlotUnlocked"] = { text = "Unlocked Passive Slot in Golbin Raid", skills = {'Combat'} },
  ["golbinRaidPrayerUnlocked"] = { text = "Unlocked Prayer in Golbin Raid", skills = {'Prayer'} },
  ["golbinRaidWaveSkipCostReduction"] = { text = "{V}% Golbin Raid wave Skip Cost", inverseSign = true, skills = {'Combat'} },
  ["GPMultiplierCap"] = { text = "{VD}% maximum gp per damage dealt", skills = {'Combat'} },
  ["GPMultiplierMin"] = { text = "{VD}% minimum gp per damage dealt", skills = {'Combat'} },
  ["GPMultiplierPer1MGP"] = { text = "{VD}% GP per damage dealt for every 1M GP owned", skills = {'Combat'} },
  ["itemProtection"] = { text = "Items are not lost on death", skills = {'Combat'} },
  ["MagicCritChance"] = { text = "{V}% Magic critical hit chance", skills = {'Magic'} },
  ["MagicLifesteal"] = { text = "{V}% Magic lifesteal", skills = {'Magic'} },
  ["MagicMaxHit"] = { text = "{V}% Magic Max Hit", skills = {'Magic'} },
  ["magicProtection"] = { text = "You have a set {V}% chance to dodge Magic attacks", skills = {'Magic'} },
  ["MasteryPoolProgress"] = { text = "{V}% to effective Mastery Pool progress" },
  ["MaxAirSpellDmg"] = { text = "{MX} Max Air Spell Dmg", skills = {'Magic'} },
  ["MaxEarthSpellDmg"] = { text = "{MX} Max Earth Spell Dmg", skills = {'Magic'} },
  ["MaxFireSpellDmg"] = { text = "{MX} Max Fire Spell Dmg", skills = {'Magic'} },
  ["MaxWaterSpellDmg"] = { text = "{MX} Max Water Spell Dmg", skills = {'Magic'} },
  ["MeleeCritChance"] = { text = "{V}% Melee critical hit chance", skills = {'Combat'} },
  ["MeleeLifesteal"] = { text = "{V}% Melee Lifesteal", skills = {'Combat'} },
  ["MeleeMaxHit"] = { text = "{V}% Melee Max Hit", skills = {'Combat'} },
  ["meleeProtection"] = { text = "You have a set {V}% chance to dodge Melee attacks", skills = {'Combat'} },
  ["MeleeStunThreshold"] = { text = "Melee attacks stun the target when they deal {V}% of max hit", skills = {'Combat'} },
  ["MiningGemChance"] = { text = "{V}% Chance to recieve gems from Mining (Does not work for Rune Essence)", skills = {'Combat'} },
  ["OffItemChance"] = { text = "{V}% increased chance to recieve an off-item (An item from a skill that is not the main resource you are gathering)" },
  ["poisonImmunity"] = { text = "Immune to poison", skills = {'Combat'} },
  ["PoisonLifesteal"] = { text = "{V}% Poison lifesteal", skills = {'Combat'} },
  ["PrayerCost"] = { text = "{V}% Prayer Point Cost for Prayers", isIncreaseNegative = true, skills = {'Prayer'} },
  ["RangedCritChance"] = { text = "{V}% Ranged critical hit chance", skills = {'Ranged'} },
  ["RangedLifesteal"] = { text = "{V}% Ranged Lifesteal", skills = {'Ranged'} },
  ["RangedMaxHit"] = { text = "{V}% Ranged Max Hit", skills = {'Ranged'} },
  ["rangedProtection"] = { text = "You have a set {V}% chance to dodge Ranged attacks", skills = {'Ranged'} },
  ["RebirthChance"] = { text = "{V}% chance to respawn with full hitpoints upon reaching 0 hitpoints", skills = {'Combat'} },
  ["RedemptionPercent"] = { text = "{V}% of max hitpoints healed on redemption", skills = {'Combat'} },
  ["RedemptionThreshold"] = { text = "{V}% redemption threshold", skills = {'Combat'} },
  ["RolledReflectDamage"] = { text = "{S}0-{V} Reflect Damage", isIncreaseNegative = true, unsigned = true, skills = {'Combat'} },
  ["RuneProvision"] = { text = "Rune providing items provide {VMUL}x as many runes", skills = {'Combat'} },
  ["SecondaryFoodBurnChance"] = { text = "{V}% Secondary Chance to burn food when Cooking", isIncreaseNegative = true, skills = {'Cooking'} },
  ["sleepImmunity"] = { text = "Immune to Sleep", skills = {'Combat'} },
  ["SmithingCoalCost"] = { text = "{V}% Coal Costs for Smithing", skills = {'Smithing'}, isIncreaseNegative = true },
  ["stunImmunity"] = { text = "Immune to Stuns and Freezes", skills = {'Combat'} },
  ["summoningSynergy_9_19"] = { text = "" },
  -- 0.22 Modifiers
  ["AllotmentSeedCost"] = { text = "{V} seed cost to plant Allotments in Farming", isIncreaseNegative = true, skills = {'Farming'} },
  ["AltMagicRunePreservation"] = { text = "{V}% Rune Preservation for Alt. Magic Spells", skills = {'Magic'} },
  ["autoEquipFoodUnlocked"] = { text = "Auto Equip Food Unlocked", skills = {'Combat', 'Cooking'} },
  ["autoSwapFoodUnlocked"] = { text = "Auto Swap Food Unlocked", skills = {'Combat'} },
  ["ChancePerfectCookFire"] = { text = "{V}% Perfect Cook chance for items cooked on Cooking Fire", skills = {'Cooking'} },
  ["ChancePerfectCookFurnace"] = { text = "{V}% Perfect Cook chance for items cooked in Furnace", skills = {'Cooking'} },
  ["ChancePerfectCookGlobal"] = { text = "{V}% Global Perfect Cook chance.", skills = {'Cooking'} },
  ["ChancePerfectCookPot"] = { text = "{V}% Perfect Cook chance for items cooked in Pot", skills = {'Cooking'} },
  ["ChanceSuccessfulCook"] = { text = "{V}% chance to successfully Cook an item.", skills = {'Cooking'} },
  ["FishingSpecialChance"] = { text = "{V}% chance to receive Special Items from Fishing", skills = {'Fishing'} },
  ["Frostburn"] = { text = "{V}% of Current HP taken as damage per Attack", isIncreaseNegative = true, skills = {'Combat'} },
  ["masteryToken"] = { text = "Grants Mastery Pool XP equal to {V}% of the maximum Mastery Pool XP for the respective skill",
    skills = {'Woodcutting', 'Fishing', 'Firemaking', 'Cooking', 'Mining', 'Smithing', 'Thieving', 'Farming',
            'Fletching', 'Crafting', 'Runecrafting', 'Herblore', 'Agility', 'Summoning', 'Astrology'} },
  ["MinThievingGP"] = { text = "{V}% minimum GP from Thieving", skills = {'Thieving'} },
  ["RunecraftingEssencePreservation"] = { text = "{V}% chance to preserve resources when Runecrafting runes", skills = {'Runecrafting'} },
  ["SummoningMaxHit"] = { text = "{V}% Summoning Max Hit", skills = {'Combat'} },
  ["ThievingStealth"] = { text = "{V} Stealth while Thieving", skills = {'Thieving'} },
  -- 1.0 Modifiers
  ["AfflictionChance"] = { text = "{V}% chance to apply affliction when attacking", skills = {'Combat'} },
  ["allowLootContainerStacking"] = { text = "Items other than bones stack within the loot container", skills = {'Combat'} },
  ["BaseStardustDropQty"] = { text = "{V}% to base drop quantity of Stardust and Golden Stardust from Astrology", skills = {'Astrology'} },
  ["BleedReflectChance"] = { text = "{V}% chance to inflict a bleed that does 100% of the attack's damage to attackers when hit", skills = {'Combat'} },
  ["ChanceForDiamondFiremaking"] = { text = "{V}% chance to receive a Diamond per action in Firemaking (Cannot be doubled)", skills = {'Firemaking'} },
  ["ChanceToApplyFrostburn"] = { text = "{V}% chance to apply Frostburn when attacking", skills = {'Combat'} },
  ["ChanceToApplyPoison"] = { text = "{V}% chance to apply Poison when hitting with an attack", skills = {'Combat'} },
  ["ChanceToIncreaseStunDuration"] = { text = "{V}% chance to increase the length of stuns inflicted by 1 turn", 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'} },
  ["EndOfTurnHealing2"] = { text = "{V}% of current hitpoints every 2 turns", skills = {'Combat'} },
  ["EndOfTurnHealing3"] = { text = "{V}% of current hitpoints every 3 turns", skills = {'Combat'} },
  ["EndOfTurnHealing5"] = { text = "{V}% of current hitpoints every 5 turns", skills = {'Combat'} },
  ["freeProtectItem"] = { text = "The Protect Item Prayer costs nothing", skills = {'Prayer'} },
  ["frostBurnImmunity"] = { text = "{V}% chance to ignore Frostburn", skills = {'Combat'} },
  ["globalEvasionHPScaling"] = { text = "Evasion Ratings are multiplied by {V} times current Hitpoints percent", skills = {'Combat'} },
  ["infiniteLootContainer"] = { text = "The loot container has an infinite amount of slots", skills = {'Combat'} },
  ["magicImmunity"] = { text = "Immune to Magic attacks", skills = {'Combat'} },
  ["meleeImmunity"] = { text = "Immune to Melee attacks", skills = {'Combat'} },
  ["MeleeStunChance"] = { text = "{V}% chance to stun when hitting with a Melee attack (once per turn)", skills = {'Combat'} },
  ["MinNatureSpellDamageBasedOnMaxHit"] = { text = "{V}% of Maximum Hit added to Minimum Hit when using Nature spells", skills = {'Combat'} },
  ["NonMagicPoisonChance"] = { text = "{V}% chance to apply poison when hitting with a Melee or Ranged attack", skills = {'Combat'} },
  ["OnHitSlowMagnitude"] = { text = "Inflict a slow that increases the target's attack interval by {V}% when hitting with an attack", skills = {'Combat'} },
  ["otherStyleImmunity"] = { text = "Immune to all attack types other than their own", skills = {'Combat'} },
  ["PoisonReflectChance"] = { text = "{V}% chance to poison attackers when hit", skills = {'Combat'} },
  ["rangedImmunity"] = { text = "Immune to Ranged attacks", skills = {'Combat'} },
  ["RegenerationInterval"] = { text = "{V}% Hitpoint Regeneration interval", skills = {'Combat'} },
  ["slowImmunity"] = { text = "{V}% chance to ignore Slow effects", skills = {'Combat'} },
  ["SurgeSpellAccuracy"] = { text = "{V}% Accuracy Rating when using Surge spells", skills = {'Combat'} },
  ["SurgeSpellMaxHit"] = { text = "{V}% Max Hit when using Surge spells", skills = {'Combat'} },
  ["TotalBleedDamage"] = { text = "{VX} total damage to bleeds inflicted", skills = {'Combat'} },
  -- The below are not present in 1.0 but are left here for now until everything is fully-migrated to 1.0
  ["CombatStoppingThreshold"] = { text = "{V}% automatic combat stopping threshold", skills = {'Combat'} },
  ["MagicCritMult"] = { text = "{V}% Magic critical hit multiplier", skills = {'Magic'} },
  ["MeleeCritMult"] = { text = "{V}% Melee critical hit multiplier", skills = {'Combat'} },
  ["RangedCritMult"] = { text = "{V}% Ranged critical hit multiplier", skills = {'Ranged'} },
}


--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
p.specialFishWt = 6722
local CombatTriangle = {
p.specialFishLoot = {{128, 2000}, {129, 1600}, {130, 1400}, {131, 1000}, {132, 400}, {667, 10}, {668, 10}, {902, 1}, {670, 1}, {669, 50}, {120, 250}}
  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.buildSpecialFishingTable()
  if CombatTriangle[playerStyle].bonus == enemyStyle then
--This shouldn't ever be included in a page
    return CombatTriangle.damageBonus
--This is for generating the above 'specialFishLoot' variable if it ever needs to change
  elseif CombatTriangle[playerStyle].penalty == enemyStyle then
--To re-run, edit the module, type in "console.log(p.buildSpecialFishingTable())" and copy+paste the result as the new value of the variable
    if mode == 'Hardcore' or mode == 'Adventure' then
--Also gives you the total fishing weight for saving time later
      return CombatTriangle.damagePenalty.Hardcore
local lootArray = {}
    else
local totalWt = 0
      return CombatTriangle.damagePenalty.Normal
 
    end
for i, item in pairs(ItemData.Items) do
  else
if item.fishingCatchWeight ~= nil then
    return 1
totalWt = totalWt + item.fishingCatchWeight
  end
table.insert(lootArray, '{'..(i - 1)..', '..item.fishingCatchWeight..'}')
end
end
 
local result = 'p.specialFishWt = '..totalWt..'\r\n'
result = result..'p.specialFishLoot = {'..table.concat(lootArray, ', ')..'}'
return result
end
end


--Syntax is like p.getTriangleDRModifier('Melee', 'Ranged', 'Normal')
function p.getItemByID(ID)
--Returns a multiplier that can be multiplied with base DR to get the post-Triangle result
return ItemData.Items[ID + 1]
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.getItem(name)
  return Difficulties[difficulty]
name = string.gsub(name, "%%27", "'")
name = string.gsub(name, "'", "'")
for i, item in ipairs(ItemData.Items) do
local itemName = string.gsub(item.name, '#', '')
if name == itemName then
return item
end
end
return nil
end
end


function p.getSkillName(skillID)
function p.getItems(checkFunc)
  return type(skillID) == 'number' and ConstantData.skill[skillID]
local result = {}
local itemCount = 0
for i, item in ipairs(ItemData.Items) do
if checkFunc(item) then
itemCount = itemCount + 1
result[itemCount] = item
end
end
return result
end
end


function p.getSkillID(skillName)
function p._getItemStat(item, StatName, ZeroIfNil)
  return type(skillName) == 'string' and ConstantData.skill[skillName]
local result = item[StatName]
--Special Overrides:
-- Equipment stats first
if Shared.contains(ItemData.EquipmentStatKeys, StatName) and item.equipmentStats ~= nil then
result = item.equipmentStats[StatName]
elseif StatName == 'isTwoHanded' then
if item.validSlots ~= nil and item.occupiesSlots ~= nil then
result = Shared.contains(item.validSlots, 'Weapon') and Shared.contains(item.occupiesSlots, 'Shield')
else
result = false
end
elseif string.find(StatName, '^(.+)LevelRequired$') ~= nil and item.equipRequirements ~= nil and item.equipRequirements.Level ~= nil then
local skillName = Shared.titleCase(string.match(StatName, '^(.+)LevelRequired$'))
if skillName ~= nil then
local skillID = Constants.getSkillID(skillName)
if skillID ~= nil then
result = item.equipRequirements.Level[skillID]
end
end
elseif StatName == 'attackType' then
result = p._getWeaponAttackType(item)
elseif StatName == 'description' then
result = item.description
if result == nil or result == '' then result = 'No Description' end
elseif StatName == 'completionReq' then
if item.ignoreCompletion == nil or not item.ignoreCompletion then
result = 'Yes'
else
result = 'No'
end
elseif StatName == 'slayerBonusXP' then
return p._getItemModifier(item, 'increasedSkillXP', 'Slayer', false)
elseif StatName == 'hasCombatStats' then
return tostring(p.hasCombatStats(item) or p._hasLevelRequirements(item))
end
if result == nil and ZeroIfNil then result = 0 end
return result
end
end


function p.getEquipmentSlotName(id)
function p.getItemStat(frame)
  return type(id) == 'number' and ConstantData.equipmentSlot[id] or 'Invalid'
local args = frame.args ~= nil and frame.args or frame
local ItemName = args[1]
local StatName = args[2]
local ZeroIfNil = args.ForceZero ~= nil and args.ForceZero ~= '' and args.ForceZero ~= 'false'
local formatNum = args.formatNum ~= nil and args.formatNum ~= '' and args.formatNum ~= 'false'
local item = p.getItem(ItemName)
if item == nil then
return "ERROR: No item named "..ItemName.." exists in the data module[[Category:Pages with script errors]]"
end
local result = p._getItemStat(item, StatName, ZeroIfNil)
if formatNum then result = Shared.formatnum(result) end
return result
end
end


function p.getEquipmentSlotID(name)
--Gets the value of a given modifier for a given item
  return type(name) == 'string' and ConstantData.equipmentSlot[name]
--asString is false by default, when true it writes the full bonus text
end
function p._getItemModifier(item, modifier, skill, asString)
if asString == nil then asString = false end
if skill == '' then
skill = nil
elseif type(skill) == 'string' then
skill = Constants.getSkillID(skill)
end


function p.getCombatStyleName(styleNum)
local result = 0
  return type(styleNum) == 'number' and Shared.titleCase(ConstantData.attackType[styleNum]) or "ERROR: Invalid combat style[[Category:Pages with script errors]]"
end


function p.getSlayerTierName(tier)
if item.modifiers ~= nil and item.modifiers[modifier] ~= nil then
  return type(tier) == 'number' and ConstantData.slayerTier[tier] or "ERROR: Invalid Slayer tier[[Category:Pages with script errors]]"
if type(item.modifiers[modifier]) == 'table' then
end
for i, subVal in Shared.skpairs(item.modifiers[modifier]) do
if subVal[1] == skill then
result = subVal[2]
break
end
end
else
result = item.modifiers[modifier]
end
end


function p.getSlayerTierNameByLevel(lvl)
if asString then
  for i, tier in Shared.skpairs(ConstantData.Slayer.Tiers) do
if skill ~= nil then
    if tier.minLevel <= lvl and (tier.maxLevel == nil or tier.maxLevel >= lvl) then
return Constants._getModifierText(modifier, {skill, result})
      return tier.display
else
    end
return Constants._getModifierText(modifier, result)
  end
end
  return 'N/A'
else
return result
end
end
end


function p.getSlayerTier(name)
function p.hasCombatStats(item)
  for i, tier in Shared.skpairs(ConstantData.Slayer.Tiers) do
if item.isEquipment or (item.validSlots == nil and item.equipmentStats ~= nil) then
    if tier.display == name then
-- Ensure at least one stat has a non-zero value
      local result = Shared.clone(tier)
for statName, statVal in pairs(item.equipmentStats) do
      result.id = i - 1
if statVal ~= 0 then return true end
      return result
end
    end
end
  end
return false
end
end


function p.getSlayerTierByID(tierID)
function p._hasLevelRequirements(item)
  if ConstantData.Slayer.Tiers[tierID + 1] == nil then
--Function true if an item has at least one level requirement to equip
    return nil
if item.equipRequirements ~= nil and item.equipRequirements.Level ~= nil then
  end
for skillID, lvl in pairs(item.equipRequirements.Level) do
 
if lvl ~= nil and lvl > 1 then
  local result = Shared.clone(ConstantData.Slayer.Tiers[tierID + 1])
return true
  result.id = tierID
end
  return result
end
return false
else
return false
end
end
end


--Turns a modifier name like 'increasedMeleeAccuracyBonus' into several pieces of data:
function p.getItemModifier(frame)
--Base Name, Text, Sign, and IsNegative
local itemName = frame.args ~= nil and frame.args[1] or frame[1]
--ex. "MeleeAccuracyBonus", "+{V}% Melee Accuracy", "+", false
local modName = frame.args ~= nil and frame.args[2] or frame[2]
function p.getModifierDetails(modifierName)
local skillName = frame.args ~= nil and frame.args[3] or frame[3]
  local baseName = modifierName
local asString = frame.args ~= nil and frame.args[4] or frame[4]
  local isIncrease = true
if asString ~= nil then
  local isNegative = false
asString = (string.upper(asString) ~= 'FALSE')
  local valueUnsigned = false
end


  if Shared.startsWith(modifierName, "increased") or Shared.startsWith(modifierName, "decreased") then
local item = p.getItem(itemName)
    baseName = string.sub(modifierName, 10)
if item == nil then
    isIncrease = Shared.startsWith(modifierName, "increased")
return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
  end
end


  local modifier = modifierTypes[baseName]
return p._getItemModifier(item, modName, skillName, asString)
  if modifier == nil then
end
    return nil
  end


  local isPositive = isIncrease
function p._getWeaponAttackType(item)
  if modifier.isIncreaseNegative then
if item.isEquipment == true and (item.validSlots ~= nil and Shared.contains(item.validSlots, 'Weapon')) or
    isPositive = not isPositive
(item.occupiesSlots ~= nil and Shared.contains(item.occupiesSlots, 'Weapon')) then
  end
if Shared.contains({'melee', 'ranged', 'magic'}, item.attackType) then
local iconType = item.attackType ~= 'melee' and 'skill' or nil
return Icons.Icon({Shared.titleCase(item.attackType), type=iconType, nolink='true'})
end
end
return 'Invalid'
end


  local sign = "+"
function p.getWeaponAttackType(frame)
  if (not isIncrease and not modifier.inverseSign) or (isIncrease and modifier.inverseSign) then
local itemName = frame.args ~= nil and frame.args[1] or frame
    sign = "-"
local item = p.getItem(itemName)
  end
if item == nil then
 
return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
  if type(modifier.unsigned) == 'boolean' then valueUnsigned = modifier.unsigned end
end
 
return p._getWeaponAttackType(item)
  return baseName, modifier.text, sign, not isPositive, valueUnsigned
end
end


function p._getModifierText(modifier, value, doColor)
function p.getPotionTable(frame)
  if doColor == nil then doColor = true end
local potionName = frame.args ~= nil and frame.args[1] or frame
  local modName, modText, sign, isNegative, valueUnsigned = p.getModifierDetails(modifier)
local tiers = {'I', 'II', 'III', 'IV'}


  if modName == nil then
local resultPart = {}
    return 'ERROR: Invalid modifier type for ' .. modifier .. '[[Category:Pages with script errors]]'
table.insert(resultPart, '{| class="wikitable"')
  end
table.insert(resultPart, '\r\n!Potion!!Tier!!Charges!!Effect')


  local result = modText
local tier1potion = p.getItem(potionName..' I')
if tier1potion == nil then
return 'ERROR: No potion named "' .. potionName .. '" was found[[Category:Pages with script errors]]'
end
for i, tier in pairs(tiers) do
local tierName = potionName..' '..tier
local potion = p.getItemByID(tier1potion.id + i - 1)
if potion ~= nil then
table.insert(resultPart, '\r\n|-')
table.insert(resultPart, '\r\n|'..Icons.Icon({tierName, type='item', notext=true, size='60'}))
table.insert(resultPart, '||'..Icons.Icon({tierName, tier, type='item', noicon=true}))
table.insert(resultPart, '||'..potion.potionCharges..'||'..potion.description)
end
end


  if type(value) == 'table' then
table.insert(resultPart, '\r\n|}')
    if Shared.tableCount(value) > 0 and type(value[1]) == 'table' then
return table.concat(resultPart)
      --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 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
function p._getOtherItemBoxText(item)
    if isNegative ~= nil and isNegative then
resultPart = {}
      result = '<span style="color:red">'..result..'</span>'
--For equipment, show the slot they go in
    else
if item.validSlots ~= nil then
      result = '<span style="color:green">'..result..'</span>'
local slotLinkMap = {
    end
["Helmet"] = 'Equipment#Helmets',
  end
["Platebody"] = 'Equipment#Platebodies',
 
["Platelegs"] = 'Equipment#Platelegs',
  return result
["Boots"] = 'Equipment#Boots',
["Weapon"] = 'Equipment#Weapons',
["Shield"] = 'Equipment#Offhand',
["Amulet"] = 'Equipment#Amulets',
["Ring"] = 'Equipment#Rings',
["Gloves"] = 'Equipment#Gloves',
["Quiver"] = 'Equipment#Ammunition',
["Cape"] = 'Equipment#Capes',
["Passive"] = 'Combat Passive Slot',
["Summon1"] = 'Summoning',
["Summon2"] = 'Summoning'
}
local slotText = {}
for i, slot in ipairs(item.validSlots) do
local slotLink = slotLinkMap[slot]
if slotLink == nil then
table.insert(slotText, slot)
else
table.insert(slotText, '[[' .. slotLink .. '|' .. slot .. ']]')
end
end
table.insert(resultPart, "\r\n|-\r\n|'''Equipment Slot:''' "..table.concat(slotText, ', '))
end
--For weapons with a special attack, show the details
if item.hasSpecialAttack then
table.insert(resultPart, "\r\n|-\r\n|'''Special Attack:'''")
for i, spAtt in ipairs(item.specialAttacks) do
table.insert(resultPart, '\r\n* ' .. spAtt.defaultChance .. '% chance for ' .. spAtt.name .. ':')
table.insert(resultPart, '\r\n** ' .. spAtt.description)
end
end
--For potions, show the number of charges
if item.potionCharges ~= nil then
table.insert(resultPart, "\r\n|-\r\n|'''Charges:''' "..item.potionCharges)
end
--For food, show how much it heals for
if item.healsFor ~= nil then
table.insert(resultPart, "\r\n|-\r\n|'''Heals for:''' "..Icons.Icon({"Hitpoints", type="skill", notext="true"})..' '..(item.healsFor * 10))
end
--For Prayer Points, show how many you get
if item.prayerPoints ~= nil then
table.insert(resultPart, "\r\n|-\r\n|'''"..Icons.Icon({'Prayer', type='skill'}).." Points:''' "..item.prayerPoints)
end
--For items with modifiers, show what those are
if item.modifiers ~= nil and Shared.tableCount(item.modifiers) > 0 then
table.insert(resultPart, "\r\n|-\r\n|'''Modifiers:'''\r\n"..Constants.getModifiersText(item.modifiers, true))
end
return table.concat(resultPart)
end
end


function p.getModifierText(frame)
function p.getOtherItemBoxText(frame)
  local modifier = frame.args ~= nil and frame.args[1] or frame[1]
local itemName = frame.args ~= nil and frame.args[1] or frame
  local value = frame.args ~= nil and frame.args[2] or frame[2]
local item = p.getItem(itemName)
  local skill = frame.args ~= nil and frame.args.skill or frame.skill
local asList = false
  local doColor = frame.args ~= nil and frame.args[3] or frame[3]
if frame.args ~= nil then
asList = frame.args.asList ~= nil and frame.args.asList ~= '' and frame.args.asList ~= 'false'
end
if item == nil then
return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
end


  if doColor ~= nil then
return p._getOtherItemBoxText(item, asList)
    doColor = string.upper(doColor) ~= 'FALSE'
end
  end


  if skill ~= nil and skill ~= '' then
function p._getItemCategories(item)
    value = {p.getSkillID(skill), value}
local resultPart = {}
  end
if item.category ~= nil then table.insert(resultPart, '[[Category:'..item.category..']]') end
 
if item.type ~= nil then table.insert(resultPart, '[[Category:'..item.type..']]') end
  return p._getModifierText(modifier, value, doColor)
if item.tier ~= nil then table.insert(resultPart, '[[Category:'..Shared.titleCase(item.tier)..' '..item.type..']]') end
if item.hasSpecialAttack then table.insert(resultPart, '[[Category:Items With Special Attacks]]') end
if item.validSlots ~= nil then
local slotRemap = {
['Passive'] = 'Passive Items',
['Summon1'] = 'Summoning Familiars',
['Summon2'] = ''
}
for i, slotName in ipairs(item.validSlots) do
local slotRemapName = slotName
if slotRemap[slotName] ~= nil then slotRemapName = slotRemap[slotName] end
if slotRemapName ~= '' then table.insert(resultPart, '[[Category:' .. slotRemapName .. ']]') end
end
end
if item.modifiers ~= nil then
local modsDL = {
'increasedChanceToDoubleLootCombat',
'decreasedChanceToDoubleLootCombat',
'increasedChanceToDoubleLootThieving',
'decreasedChanceToDoubleLootThieving',
'increasedChanceToDoubleItemsGlobal',
'decreasedChanceToDoubleItemsGlobal'
}
for modName, val in pairs(item.modifiers) do
if Shared.contains(modsDL, modName) then
table.insert(resultPart, '[[Category:Double Loot Chance Items]]')
break
end
end
end
return table.concat(resultPart)
end
end


function p.getModifiersText(modifiers, doColor)
function p.getItemCategories(frame)
  if modifiers == nil or Shared.tableCount(modifiers) == 0 then
local itemName = frame.args ~= nil and frame.args[1] or frame
    return ''
local item = p.getItem(itemName)
  end
if item == nil then
return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
end


  local modArray = {}
return p._getItemCategories(item)
  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.getSkillcapeTable(frame)
  local skillArray = {}
local skillName = frame.args ~= nil and frame.args[1] or frame
local cape = p.getItem(skillName..' Skillcape')
local resultPart = {}
table.insert(resultPart, '{| class="wikitable"\r\n')
table.insert(resultPart, '!Skillcape!!Name!!Effect')
table.insert(resultPart, '\r\n|-\r\n|'..Icons.Icon({cape.name, type='item', size='60', notext=true}))
table.insert(resultPart, '||'..Icons.Icon({cape.name, type='item', noicon=true})..'||'..cape.description)
table.insert(resultPart, '\r\n|}')
return table.concat(resultPart)
end


  for modifier, value in Shared.skpairs(modifiers) do
function p.getItemGrid(frame)
    if type(value) == 'table' then
local resultPart = {}
      for i, subVal in Shared.skpairs(value) do
table.insert(resultPart, '{|')
        local skillName = p.getSkillName(subVal[1])
for i, item in Shared.skpairs(ItemData.Items) do
        if not Shared.contains(skillArray, skillName) then
if i % 17 == 1 then
          table.insert(skillArray, skillName)
table.insert(resultPart, '\r\n|-\r\n|')
        end
else
      end
table.insert(resultPart, '||')
    end
end
table.insert(resultPart, 'style="padding:3px"|'..Icons.Icon({item.name, type='item', notext=true, size='40'}))
end
table.insert(resultPart, '\r\n|}')
return table.concat(resultPart)
end


    local baseName = p.getModifierDetails(modifier)
function p.getWeaponStatsBox(frame)
    if baseName == nil then
local itemName = frame.args ~= nil and frame.args[1] or frame
      return { 'ERROR: Modifier '..modifier..' is invalid' }
local item = p.getItem(itemName)
    end
if item == nil then
 
return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
    if modifierTypes[baseName].skills ~= nil then
end
      for i, skillName in Shared.skpairs(modifierTypes[baseName].skills) do
        if not Shared.contains(skillArray, skillName) then
local ico = {
          table.insert(skillArray, skillName)
["Attack"] = Icons.Icon({'Attack', type='skill', notext=true}),
        end
["Combat"] = Icons.Icon({'Combat', notext=true}),
      end
["Defence"] = Icons.Icon({'Defence', type='skill', notext=true}),
    end
["Magic"] = Icons.Icon({'Magic', type='skill', notext=true}),
  end
["Ranged"] = Icons.Icon({'Ranged', type='skill', notext=true}),
["Strength"] = Icons.Icon({'Strength', type='skill', notext=true}),
["Slayer"] = Icons.Icon({'Slayer', type='skill', notext=true})
}
local resultPart = {}
table.insert(resultPart, '{| class="wikitable"\r\n|-\r\n!colspan="4" style="border-bottom:solid medium black;"| Weapon Stats')
table.insert(resultPart, '\r\n|-\r\n!colspan="2" style="border-bottom:solid thin black;"| Offensive Stats')
table.insert(resultPart, '\r\n!colspan="2" style="border-bottom:solid thin black;"| Defensive Stats')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| Attack Speed')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. Shared.round(p._getItemStat(item, 'attackSpeed', true) / 1000, 3, 1) .. 's')
table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Defence'] .. ' Defence Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'meleeDefenceBonus', true))
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| Attack Type')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'attackType'))
table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Defence'] .. ' Damage Reduction')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'damageReduction', true) .. '%')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Strength'] .. ' Strength Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'meleeStrengthBonus', true))
table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Defence Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedDefenceBonus', true))
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Combat'] .. ' Stab Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'stabAttackBonus', true))
table.insert(resultPart, '\r\n!style="text-align:right;border-bottom:solid thin black;"| ' .. ico['Magic'] .. ' Defence Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;border-bottom:solid thin black;"| ' .. p._getItemStat(item, 'magicDefenceBonus', true))
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Combat'] .. ' Slash Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'slashAttackBonus', true))
table.insert(resultPart, '\r\n!colspan="2" style="border-bottom:solid thin black;"| Other')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Combat'] .. ' Block Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'blockAttackBonus', true))
table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Slayer'] .. ' Bonus Slayer XP')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'slayerBonusXP', true) .. '%')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Attack Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedAttackBonus', true))
table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Attack'] .. ' Level Required')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'attackLevelRequired', true))
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Strength Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedStrengthBonus', true))
table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Level Required')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedLevelRequired', true))
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Magic'] .. ' Attack Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'magicAttackBonus', true))
table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Magic'] .. ' Level Required')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'magicLevelRequired', true))
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Magic'] .. ' % Damage Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'magicDamageBonus', true) .. '%')
table.insert(resultPart, '\r\n!style="text-align:right;"| Two Handed?')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. (p._getItemStat(item, 'isTwoHanded') and 'Yes' or 'No'))
table.insert(resultPart, '\r\n|}')
return table.concat(resultPart)
end


  return skillArray
function p.getArmourStatsBox(frame)
local itemName = frame.args ~= nil and frame.args[1] or frame
local item = p.getItem(itemName)
if item == nil then
return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
end
local ico = {
["Attack"] = Icons.Icon({'Attack', type='skill', notext=true}),
["Combat"] = Icons.Icon({'Combat', notext=true}),
["Defence"] = Icons.Icon({'Defence', type='skill', notext=true}),
["Magic"] = Icons.Icon({'Magic', type='skill', notext=true}),
["Ranged"] = Icons.Icon({'Ranged', type='skill', notext=true}),
["Strength"] = Icons.Icon({'Strength', type='skill', notext=true}),
["Slayer"] = Icons.Icon({'Slayer', type='skill', notext=true})
}
local resultPart = {}
table.insert(resultPart, '{| class="wikitable"\r\n|-\r\n!colspan="4" style="border-bottom:solid medium black;"| Armour Stats')
table.insert(resultPart, '\r\n|-\r\n!colspan="2" style="border-bottom:solid thin black;"| Offensive Stats')
table.insert(resultPart, '\r\n!colspan="2" style="border-bottom:solid thin black;"| Defensive Stats')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Strength'] .. ' Strength Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'meleeStrengthBonus', true))
table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Defence'] .. ' Defence Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'meleeDefenceBonus', true))
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Combat'] .. ' Stab Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'stabAttackBonus', 0))
table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Defence'] .. ' Damage Reduction')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'damageReduction', true) .. '%')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Combat'] .. ' Slash Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'slashAttackBonus', true))
table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Defence Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedDefenceBonus', true))
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Combat'] .. ' Block Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'blockAttackBonus', true))
table.insert(resultPart, '\r\n!style="text-align:right;border-bottom:solid thin black;"| ' .. ico['Magic'] .. ' Defence Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;border-bottom:solid thin black;"| ' .. p._getItemStat(item, 'magicDefenceBonus', true))
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Attack Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedAttackBonus', true))
table.insert(resultPart, '\r\n!colspan="2" style="border-bottom:solid thin black;"| Other')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Strength Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedStrengthBonus', true))
table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Slayer'] .. ' Bonus Slayer XP')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'slayerBonusXP', true) .. '%')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Magic'] .. ' Attack Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'magicAttackBonus', true))
table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Defence'] .. ' Level Required')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'defenceLevelRequired', true))
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Magic'] .. ' % Damage Bonus')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'magicDamageBonus', true) .. '%')
table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Level Required')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedLevelRequired', true))
table.insert(resultPart, '\r\n|-\r\n| colspan="2"|')
table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Magic'] .. ' Level Required')
table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'magicLevelRequired', true))
table.insert(resultPart, '\r\n|}')
return table.concat(resultPart)
end
end


return p
return p

Latest revision as of 21:51, 27 February 2022

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

--This module contains all sorts of functions for getting data on items
--Several functions related to use tables can be found at Module:Items/UseTables
--Functions related to source tables can be found at Module:Items/SourceTables
--Other functions moved to Module:Items/ComparisonTables

local p = {}

local ItemData = mw.loadData('Module:Items/data')

local Constants = require('Module:Constants')
local Shared = require('Module:Shared')
local Icons = require('Module:Icons')

p.EasterEggs = {'Amulet of Calculated Promotion', 'Clue Chasers Insignia', '8', 'Lemon', 'Easter Egg', 'Abnormal Log', 'Red Herring', 'Cool Glasses'}
p.EventItems = {'Christmas Cracker', 'Christmas Coal', 'Christmas Sweater',
				'Christmas Wreath', 'Candy Cane', 'Santa Hat',
				'Friendship Bracelet', 'Event Clue 1', 'Event Clue 2',
				'Event Clue 3', 'Event Clue 4', 'Candle', 'Cake Base',
				'Magical Flavouring', 'Magical Icing', 'Birthday Cake',
				'Purple Party Hat', 'Birthday Token', 'Christmas Present (Yellow)',
				'Christmas Present (Blue)', 'Christmas Present (Green)', 'Christmas Present (White)',
				'Christmas Present (Purple)', 'Christmas Present (Standard)', 'Event Token - Holiday 2021',
				'Holiday Scarf', 'Gingerbread House', 'Gingerbread Man', 'Edible Candy Cane',
				'Locked Chest', 'Locked Chest Key', 'Event Token (Holiday 2021)'}
p.OtherShopItems = {'Cooking Gloves', 'Mining Gloves', 'Gem Gloves', 'Smithing Gloves', 'Thieving Gloves'}
--This is hardcoded, so there's no easy way to scrape it. Hopefully it doesn't change
p.GemTable = {["Topaz"] = {name = 'Topaz', id = 128, chance = 50},
				["Sapphire"] = {name = "Sapphire", id = 129, chance = 17.5},
				["Ruby"] = {name = "Ruby", id = 130, chance = 17.5},
				["Emerald"] = {name = "Emerald", id = 131, chance = 10},
				["Diamond"] = {name = "Diamond", id = 132, chance = 5}}
--The base chance to receive a gem while mining
p.GemChance = .01
--The number of different fishing junk items
p.junkCount = 8
--Items (aside from bars & gems) which can be created via Alt Magic
p.AltMagicProducts = {'Rune Essence', 'Bones', 'Holy Dust'}
--The kinds of gloves with cost & charges
p.GloveTable = {['Cooking Gloves'] = {cost=50000, charges=500},
				['Mining Gloves'] = {cost=75000, charges=500},
				['Smithing Gloves'] = {cost=100000, charges=500},
				['Thieving Gloves'] = {cost=100000, charges=500},
				['Gem Gloves'] = {cost=500000, charges=2000}}


p.specialFishWt = 6722
p.specialFishLoot = {{128, 2000}, {129, 1600}, {130, 1400}, {131, 1000}, {132, 400}, {667, 10}, {668, 10}, {902, 1}, {670, 1}, {669, 50}, {120, 250}}

function p.buildSpecialFishingTable()
	--This shouldn't ever be included in a page
	--This is for generating the above 'specialFishLoot' variable if it ever needs to change
	--To re-run, edit the module, type in "console.log(p.buildSpecialFishingTable())" and copy+paste the result as the new value of the variable
	--Also gives you the total fishing weight for saving time later
	local lootArray = {}
	local totalWt = 0

	for i, item in pairs(ItemData.Items) do
		if item.fishingCatchWeight ~= nil then
			totalWt = totalWt + item.fishingCatchWeight
			table.insert(lootArray, '{'..(i - 1)..', '..item.fishingCatchWeight..'}')
		end
	end

	local result = 'p.specialFishWt = '..totalWt..'\r\n'
	result = result..'p.specialFishLoot = {'..table.concat(lootArray, ', ')..'}'
	return result
end

function p.getItemByID(ID)
	return ItemData.Items[ID + 1]
end

function p.getItem(name)
	name = string.gsub(name, "%%27", "'")
	name = string.gsub(name, "&#39;", "'")
	for i, item in ipairs(ItemData.Items) do
		local itemName = string.gsub(item.name, '#', '')
		if name == itemName then
			return item
		end
	end
	return nil
end

function p.getItems(checkFunc)
	local result = {}
	local itemCount = 0
	for i, item in ipairs(ItemData.Items) do
		if checkFunc(item) then
			itemCount = itemCount + 1
			result[itemCount] = item
		end
	end
	return result
end

function p._getItemStat(item, StatName, ZeroIfNil)
	local result = item[StatName]
	--Special Overrides:
	-- Equipment stats first
	if Shared.contains(ItemData.EquipmentStatKeys, StatName) and item.equipmentStats ~= nil then
		result = item.equipmentStats[StatName]
	elseif StatName == 'isTwoHanded' then
		if item.validSlots ~= nil and item.occupiesSlots ~= nil then
			result = Shared.contains(item.validSlots, 'Weapon') and Shared.contains(item.occupiesSlots, 'Shield')
		else
			result = false
		end
	elseif string.find(StatName, '^(.+)LevelRequired$') ~= nil and item.equipRequirements ~= nil and item.equipRequirements.Level ~= nil then
		local skillName = Shared.titleCase(string.match(StatName, '^(.+)LevelRequired$'))
		if skillName ~= nil then
			local skillID = Constants.getSkillID(skillName)
			if skillID ~= nil then
				result = item.equipRequirements.Level[skillID]
			end
		end
	elseif StatName == 'attackType' then
		result = p._getWeaponAttackType(item)
	elseif StatName == 'description' then
		result = item.description
		if result == nil or result == '' then result = 'No Description' end
	elseif StatName == 'completionReq' then
		if item.ignoreCompletion == nil or not item.ignoreCompletion then
			result = 'Yes'
		else
			result = 'No'
		end
	elseif StatName == 'slayerBonusXP' then
		return p._getItemModifier(item, 'increasedSkillXP', 'Slayer', false)
	elseif StatName == 'hasCombatStats' then
		return tostring(p.hasCombatStats(item) or p._hasLevelRequirements(item))
	end
	if result == nil and ZeroIfNil then result = 0 end
	return result
end

function p.getItemStat(frame)
	local args = frame.args ~= nil and frame.args or frame
	local ItemName = args[1]
	local StatName = args[2]
	local ZeroIfNil = args.ForceZero ~= nil and args.ForceZero ~= '' and args.ForceZero ~= 'false'
	local formatNum = args.formatNum ~= nil and args.formatNum ~= '' and args.formatNum ~= 'false'
	local item = p.getItem(ItemName)
	if item == nil then
		return "ERROR: No item named "..ItemName.." exists in the data module[[Category:Pages with script errors]]"
	end
	local result = p._getItemStat(item, StatName, ZeroIfNil)
	if formatNum then result = Shared.formatnum(result) end
	return result
end

--Gets the value of a given modifier for a given item
--asString is false by default, when true it writes the full bonus text
function p._getItemModifier(item, modifier, skill, asString)
	if asString == nil then asString = false end
	if skill == '' then
		skill = nil
	elseif type(skill) == 'string' then
		skill = Constants.getSkillID(skill)
	end

	local result = 0

	if item.modifiers ~= nil and item.modifiers[modifier] ~= nil then
		if type(item.modifiers[modifier]) == 'table' then
			for i, subVal in Shared.skpairs(item.modifiers[modifier]) do
				if subVal[1] == skill then
					result = subVal[2]
					break
				end
			end
		else
			result = item.modifiers[modifier]
		end
	end

	if asString then
		if skill ~= nil then
			return Constants._getModifierText(modifier, {skill, result})
		else
			return Constants._getModifierText(modifier, result)
		end
	else
		return result
	end
end

function p.hasCombatStats(item)
	if item.isEquipment or (item.validSlots == nil and item.equipmentStats ~= nil) then
		-- Ensure at least one stat has a non-zero value
		for statName, statVal in pairs(item.equipmentStats) do
			if statVal ~= 0 then return true end
		end
	end
	return false
end

function p._hasLevelRequirements(item)
	--Function true if an item has at least one level requirement to equip
	if item.equipRequirements ~= nil and item.equipRequirements.Level ~= nil then
		for skillID, lvl in pairs(item.equipRequirements.Level) do
			if lvl ~= nil and lvl > 1 then
				return true
			end
		end
		return false
	else
		return false
	end
end

function p.getItemModifier(frame)
	local itemName = frame.args ~= nil and frame.args[1] or frame[1]
	local modName = frame.args ~= nil and frame.args[2] or frame[2]
	local skillName = frame.args ~= nil and frame.args[3] or frame[3]
	local asString = frame.args ~= nil and frame.args[4] or frame[4]
	if asString ~= nil then
		asString = (string.upper(asString) ~= 'FALSE')
	end

	local item = p.getItem(itemName)
	if item == nil then
		return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
	end

	return p._getItemModifier(item, modName, skillName, asString)
end

function p._getWeaponAttackType(item)
	if item.isEquipment == true and (item.validSlots ~= nil and Shared.contains(item.validSlots, 'Weapon')) or
									(item.occupiesSlots ~= nil and Shared.contains(item.occupiesSlots, 'Weapon')) then
		if Shared.contains({'melee', 'ranged', 'magic'}, item.attackType) then
			local iconType = item.attackType ~= 'melee' and 'skill' or nil
			return Icons.Icon({Shared.titleCase(item.attackType), type=iconType, nolink='true'})
		end
	end
	return 'Invalid'
end

function p.getWeaponAttackType(frame)
	local itemName = frame.args ~= nil and frame.args[1] or frame
	local item = p.getItem(itemName)
	if item == nil then
		return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
	end
	return p._getWeaponAttackType(item)
end

function p.getPotionTable(frame)
	local potionName = frame.args ~= nil and frame.args[1] or frame
	local tiers = {'I', 'II', 'III', 'IV'}

	local resultPart = {}
	table.insert(resultPart, '{| class="wikitable"')
	table.insert(resultPart, '\r\n!Potion!!Tier!!Charges!!Effect')

	local tier1potion = p.getItem(potionName..' I')
	if tier1potion == nil then
		return 'ERROR: No potion named "' .. potionName .. '" was found[[Category:Pages with script errors]]'
	end
	for i, tier in pairs(tiers) do
		local tierName = potionName..' '..tier
		local potion = p.getItemByID(tier1potion.id + i - 1)
		if potion ~= nil then
			table.insert(resultPart, '\r\n|-')
			table.insert(resultPart, '\r\n|'..Icons.Icon({tierName, type='item', notext=true, size='60'}))
			table.insert(resultPart, '||'..Icons.Icon({tierName, tier, type='item', noicon=true}))
			table.insert(resultPart, '||'..potion.potionCharges..'||'..potion.description)
		end
	end

	table.insert(resultPart, '\r\n|}')
	return table.concat(resultPart)
end

function p._getOtherItemBoxText(item)
	resultPart = {}
	--For equipment, show the slot they go in
	if item.validSlots ~= nil then
		local slotLinkMap = {
			["Helmet"] = 'Equipment#Helmets',
			["Platebody"] = 'Equipment#Platebodies',
			["Platelegs"] = 'Equipment#Platelegs',
			["Boots"] = 'Equipment#Boots',
			["Weapon"] = 'Equipment#Weapons',
			["Shield"] = 'Equipment#Offhand',
			["Amulet"] = 'Equipment#Amulets',
			["Ring"] = 'Equipment#Rings',
			["Gloves"] = 'Equipment#Gloves',
			["Quiver"] = 'Equipment#Ammunition',
			["Cape"] = 'Equipment#Capes',
			["Passive"] = 'Combat Passive Slot',
			["Summon1"] = 'Summoning',
			["Summon2"] = 'Summoning'
		}
		local slotText = {}
		for i, slot in ipairs(item.validSlots) do
			local slotLink = slotLinkMap[slot]
			if slotLink == nil then
				table.insert(slotText, slot)
			else
				table.insert(slotText, '[[' .. slotLink .. '|' .. slot .. ']]')
			end
		end
		table.insert(resultPart, "\r\n|-\r\n|'''Equipment Slot:''' "..table.concat(slotText, ', '))
	end
	--For weapons with a special attack, show the details
	if item.hasSpecialAttack then
		table.insert(resultPart, "\r\n|-\r\n|'''Special Attack:'''")
		for i, spAtt in ipairs(item.specialAttacks) do
			table.insert(resultPart, '\r\n* ' .. spAtt.defaultChance .. '% chance for ' .. spAtt.name .. ':')
			table.insert(resultPart, '\r\n** ' .. spAtt.description)
		end
	end
	--For potions, show the number of charges
	if item.potionCharges ~= nil then
		table.insert(resultPart, "\r\n|-\r\n|'''Charges:''' "..item.potionCharges)
	end
	--For food, show how much it heals for
	if item.healsFor ~= nil then
		table.insert(resultPart, "\r\n|-\r\n|'''Heals for:''' "..Icons.Icon({"Hitpoints", type="skill", notext="true"})..' '..(item.healsFor * 10))
	end
	--For Prayer Points, show how many you get
	if item.prayerPoints ~= nil then
		table.insert(resultPart, "\r\n|-\r\n|'''"..Icons.Icon({'Prayer', type='skill'}).." Points:''' "..item.prayerPoints)
	end
	--For items with modifiers, show what those are
	if item.modifiers ~= nil and Shared.tableCount(item.modifiers) > 0 then
		table.insert(resultPart, "\r\n|-\r\n|'''Modifiers:'''\r\n"..Constants.getModifiersText(item.modifiers, true))
	end
	return table.concat(resultPart)
end

function p.getOtherItemBoxText(frame)
	local itemName = frame.args ~= nil and frame.args[1] or frame
	local item = p.getItem(itemName)
	local asList = false
	if frame.args ~= nil then
		asList = frame.args.asList ~= nil and frame.args.asList ~= '' and frame.args.asList ~= 'false'
	end
	if item == nil then
		return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
	end

	return p._getOtherItemBoxText(item, asList)
end

function p._getItemCategories(item)
	local resultPart = {}
	if item.category ~= nil then table.insert(resultPart, '[[Category:'..item.category..']]') end
	if item.type ~= nil then table.insert(resultPart, '[[Category:'..item.type..']]') end
	if item.tier ~= nil then table.insert(resultPart, '[[Category:'..Shared.titleCase(item.tier)..' '..item.type..']]') end
	if item.hasSpecialAttack then table.insert(resultPart, '[[Category:Items With Special Attacks]]') end
	if item.validSlots ~= nil then
		local slotRemap = {
			['Passive'] = 'Passive Items',
			['Summon1'] = 'Summoning Familiars',
			['Summon2'] = ''
		}
		for i, slotName in ipairs(item.validSlots) do
			local slotRemapName = slotName
			if slotRemap[slotName] ~= nil then slotRemapName = slotRemap[slotName] end
			if slotRemapName ~= '' then table.insert(resultPart, '[[Category:' .. slotRemapName .. ']]') end
		end
	end
	if item.modifiers ~= nil then
		local modsDL = {
			'increasedChanceToDoubleLootCombat',
			'decreasedChanceToDoubleLootCombat',
			'increasedChanceToDoubleLootThieving',
			'decreasedChanceToDoubleLootThieving',
			'increasedChanceToDoubleItemsGlobal',
			'decreasedChanceToDoubleItemsGlobal'
		}
		for modName, val in pairs(item.modifiers) do
			if Shared.contains(modsDL, modName) then
				table.insert(resultPart, '[[Category:Double Loot Chance Items]]')
				break
			end
		end
	end
	return table.concat(resultPart)
end

function p.getItemCategories(frame)
	local itemName = frame.args ~= nil and frame.args[1] or frame
	local item = p.getItem(itemName)
	if item == nil then
		return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
	end

	return p._getItemCategories(item)
end

function p.getSkillcapeTable(frame)
	local skillName = frame.args ~= nil and frame.args[1] or frame
	local cape = p.getItem(skillName..' Skillcape')
	local resultPart = {}
	table.insert(resultPart, '{| class="wikitable"\r\n')
	table.insert(resultPart, '!Skillcape!!Name!!Effect')
	table.insert(resultPart, '\r\n|-\r\n|'..Icons.Icon({cape.name, type='item', size='60', notext=true}))
	table.insert(resultPart, '||'..Icons.Icon({cape.name, type='item', noicon=true})..'||'..cape.description)
	table.insert(resultPart, '\r\n|}')
	return table.concat(resultPart)
end

function p.getItemGrid(frame)
	local resultPart = {}
	table.insert(resultPart, '{|')
	for i, item in Shared.skpairs(ItemData.Items) do
		if i % 17 == 1 then
			table.insert(resultPart, '\r\n|-\r\n|')
		else
			table.insert(resultPart, '||')
		end
		table.insert(resultPart, 'style="padding:3px"|'..Icons.Icon({item.name, type='item', notext=true, size='40'}))
	end
	table.insert(resultPart, '\r\n|}')
	return table.concat(resultPart)
end

function p.getWeaponStatsBox(frame)
	local itemName = frame.args ~= nil and frame.args[1] or frame
	local item = p.getItem(itemName)
	if item == nil then
		return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
	end
	
	local ico = {
		["Attack"] = Icons.Icon({'Attack', type='skill', notext=true}),
		["Combat"] = Icons.Icon({'Combat', notext=true}),
		["Defence"] = Icons.Icon({'Defence', type='skill', notext=true}),
		["Magic"] = Icons.Icon({'Magic', type='skill', notext=true}),
		["Ranged"] = Icons.Icon({'Ranged', type='skill', notext=true}),
		["Strength"] = Icons.Icon({'Strength', type='skill', notext=true}),
		["Slayer"] = Icons.Icon({'Slayer', type='skill', notext=true})
	}
	local resultPart = {}
	table.insert(resultPart, '{| class="wikitable"\r\n|-\r\n!colspan="4" style="border-bottom:solid medium black;"| Weapon Stats')
	table.insert(resultPart, '\r\n|-\r\n!colspan="2" style="border-bottom:solid thin black;"| Offensive Stats')
	table.insert(resultPart, '\r\n!colspan="2" style="border-bottom:solid thin black;"| Defensive Stats')
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| Attack Speed')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. Shared.round(p._getItemStat(item, 'attackSpeed', true) / 1000, 3, 1) .. 's')
	table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Defence'] .. ' Defence Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'meleeDefenceBonus', true))
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| Attack Type')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'attackType'))
	table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Defence'] .. ' Damage Reduction')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'damageReduction', true) .. '%')
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Strength'] .. ' Strength Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'meleeStrengthBonus', true))
	table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Defence Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedDefenceBonus', true))
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Combat'] .. ' Stab Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'stabAttackBonus', true))
	table.insert(resultPart, '\r\n!style="text-align:right;border-bottom:solid thin black;"| ' .. ico['Magic'] .. ' Defence Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;border-bottom:solid thin black;"| ' .. p._getItemStat(item, 'magicDefenceBonus', true))
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Combat'] .. ' Slash Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'slashAttackBonus', true))
	table.insert(resultPart, '\r\n!colspan="2" style="border-bottom:solid thin black;"| Other')
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Combat'] .. ' Block Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'blockAttackBonus', true))
	table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Slayer'] .. ' Bonus Slayer XP')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'slayerBonusXP', true) .. '%')
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Attack Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedAttackBonus', true))
	table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Attack'] .. ' Level Required')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'attackLevelRequired', true))
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Strength Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedStrengthBonus', true))
	table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Level Required')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedLevelRequired', true))
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Magic'] .. ' Attack Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'magicAttackBonus', true))
	table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Magic'] .. ' Level Required')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'magicLevelRequired', true))
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Magic'] .. ' % Damage Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'magicDamageBonus', true) .. '%')
	table.insert(resultPart, '\r\n!style="text-align:right;"| Two Handed?')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. (p._getItemStat(item, 'isTwoHanded') and 'Yes' or 'No'))
	
	table.insert(resultPart, '\r\n|}')
	return table.concat(resultPart)
end

function p.getArmourStatsBox(frame)
	local itemName = frame.args ~= nil and frame.args[1] or frame
	local item = p.getItem(itemName)
	if item == nil then
		return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]"
	end
	
	local ico = {
		["Attack"] = Icons.Icon({'Attack', type='skill', notext=true}),
		["Combat"] = Icons.Icon({'Combat', notext=true}),
		["Defence"] = Icons.Icon({'Defence', type='skill', notext=true}),
		["Magic"] = Icons.Icon({'Magic', type='skill', notext=true}),
		["Ranged"] = Icons.Icon({'Ranged', type='skill', notext=true}),
		["Strength"] = Icons.Icon({'Strength', type='skill', notext=true}),
		["Slayer"] = Icons.Icon({'Slayer', type='skill', notext=true})
	}
	local resultPart = {}
	table.insert(resultPart, '{| class="wikitable"\r\n|-\r\n!colspan="4" style="border-bottom:solid medium black;"| Armour Stats')
	table.insert(resultPart, '\r\n|-\r\n!colspan="2" style="border-bottom:solid thin black;"| Offensive Stats')
	table.insert(resultPart, '\r\n!colspan="2" style="border-bottom:solid thin black;"| Defensive Stats')
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Strength'] .. ' Strength Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'meleeStrengthBonus', true))
	table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Defence'] .. ' Defence Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'meleeDefenceBonus', true))
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Combat'] .. ' Stab Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'stabAttackBonus', 0))
	table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Defence'] .. ' Damage Reduction')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'damageReduction', true) .. '%')
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Combat'] .. ' Slash Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'slashAttackBonus', true))
	table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Defence Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedDefenceBonus', true))
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Combat'] .. ' Block Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'blockAttackBonus', true))
	table.insert(resultPart, '\r\n!style="text-align:right;border-bottom:solid thin black;"| ' .. ico['Magic'] .. ' Defence Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;border-bottom:solid thin black;"| ' .. p._getItemStat(item, 'magicDefenceBonus', true))
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Attack Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedAttackBonus', true))
	table.insert(resultPart, '\r\n!colspan="2" style="border-bottom:solid thin black;"| Other')
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Strength Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedStrengthBonus', true))
	table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Slayer'] .. ' Bonus Slayer XP')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'slayerBonusXP', true) .. '%')
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Magic'] .. ' Attack Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'magicAttackBonus', true))
	table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Defence'] .. ' Level Required')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'defenceLevelRequired', true))
	
	table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"| ' .. ico['Magic'] .. ' % Damage Bonus')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'magicDamageBonus', true) .. '%')
	table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Ranged'] .. ' Level Required')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'rangedLevelRequired', true))
	
	table.insert(resultPart, '\r\n|-\r\n| colspan="2"|')
	table.insert(resultPart, '\r\n!style="text-align:right;"| ' .. ico['Magic'] .. ' Level Required')
	table.insert(resultPart, '\r\n|style="text-align:right;"| ' .. p._getItemStat(item, 'magicLevelRequired', true))
	
	table.insert(resultPart, '\r\n|}')
	return table.concat(resultPart)
end

return p