|
|
(33 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
| local p = {} | | local p = {} |
|
| |
| local MonsterData = mw.loadData('Module:Monsters/data')
| |
| local ItemData = mw.loadData('Module:Items/data')
| |
| local SkillData = mw.loadData('Module:Skills/data')
| |
|
| |
|
| local Constants = require('Module:Constants') | | local Constants = require('Module:Constants') |
| local Shared = require('Module:Shared') | | local Shared = require('Module:Shared') |
| local Magic = require('Module:Magic') | | local GameData = require('Module:GameData') |
| local Areas = require('Module:CombatAreas')
| |
| local Icons = require('Module:Icons') | | local Icons = require('Module:Icons') |
| local Items = require('Module:Items') | | local Items = require('Module:Items') |
| local ItemSourceTables = require('Module:Items/SourceTables')
| |
| local ItemUseTables = require('Module:Items/UseTables')
| |
|
| |
|
| local weaponTypes = {'Magic Staff', 'Magic Wand', 'Ranged Weapon', 'Weapon'} | | local weaponTypes = {'Magic Staff', 'Magic Wand', 'Ranged Weapon', 'Weapon'} |
|
| |
|
| local styleOverrides = { | | local styleOverrides = { |
| Melee = {'Slayer Helmet (Basic)', 'Slayer Platebody (Basic)', 'Paladin Gloves', 'Desert Wrappings', 'Almighty Lute', 'Candy Cane', 'Bob's Rake'},
| | Melee = {'Slayer Helmet (Basic)', 'Slayer Platebody (Basic)', 'Paladin Gloves', 'Desert Wrappings', 'Almighty Lute', 'Candy Cane', 'Bob's Rake', "Knight's Defender", "Ward of Flame Platebody"}, |
| Ranged = {'Slayer Cowl (Basic)', 'Slayer Leather Body (Basic)'},
| | Ranged = {'Slayer Cowl (Basic)', 'Slayer Leather Body (Basic)', 'Ice Arrows'}, |
| Magic = {'Slayer Wizard Hat (Basic)', 'Slayer Wizard Robes (Basic)', 'Enchanted Shield', 'Elementalist Gloves'},
| | Magic = {'Slayer Wizard Hat (Basic)', 'Slayer Wizard Robes (Basic)', 'Enchanted Shield', 'Elementalist Gloves', 'Frostspark Boots', 'Freezing Touch Body', 'Lightning Boots'}, |
| None = {},
| | None = {}, |
| | NotMelee = {'Frostspark Boots', 'Freezing Touch Body', 'Lightning Boots'}, |
| | NotRanged = {}, |
| | NotMagic = {'Torrential Blast Crossbow', 'Spectral Ice Sword', 'Lightning Strike 1H Sword', 'FrostSpark 1H Sword'} |
| } | | } |
|
| |
|
| function p._getEquipmentTable(itemList, includeModifiers, includeDescription) | | function p._getEquipmentTable(itemList, includeModifiers, includeDescription, sortByName) |
| if includeModifiers == nil then includeModifiers = false end
| | if includeModifiers == nil then includeModifiers = false end |
| | | if sortByName == nil then sortByName = false end |
| --Getting some lists set up here that will be used later
| |
| --First, the list of columns used by both weapons & armour
| |
| local statColumns = {'stabAttackBonus', 'slashAttackBonus','blockAttackBonus','rangedAttackBonus', 'magicAttackBonus', 'strengthBonus', 'rangedStrengthBonus', 'magicDamageBonus', 'defenceBonus', 'rangedDefenceBonus', 'magicDefenceBonus', 'damageReduction', 'attackLevelRequired', 'defenceLevelRequired', 'rangedLevelRequired', 'magicLevelRequired'}
| |
| | |
| if(Shared.tableCount(itemList) == 0) then
| |
| return 'ERROR: you must select at least one item to get stats for[[Category:Pages with script errors]]'
| |
| end
| |
| | |
| local isWeaponType = itemList[1].validSlots ~= nil and Shared.contains(itemList[1].validSlots, 'Weapon') and Shared.contains(weaponTypes, itemList[1].type)
| |
| | |
| --Now that we have a preliminary list, let's figure out which columns are irrelevant (IE are zero for all items in the selection)
| |
| local ignoreColumns = Shared.clone(statColumns)
| |
| for i, item in pairs(itemList) do
| |
| local ndx = 1
| |
| while Shared.tableCount(ignoreColumns) >= ndx do
| |
| if Items._getItemStat(item, ignoreColumns[ndx], true) ~= 0 then
| |
| table.remove(ignoreColumns, ndx)
| |
| else
| |
| ndx = ndx + 1
| |
| end
| |
| end
| |
| end
| |
| | |
| --Now to remove the ignored columns (and also we need to track groups like defence bonuses to see how many remain)
| |
| local attBonusCols = 5
| |
| local strBonusCols = 2
| |
| local defBonusCols = 3
| |
| local lvlReqCols = 4
| |
| local ndx = 1
| |
| while Shared.tableCount(statColumns) >= ndx do
| |
| local colName = statColumns[ndx]
| |
| if Shared.contains(ignoreColumns, colName) then
| |
| if Shared.contains(colName, 'AttackBonus') then attBonusCols = attBonusCols - 1 end
| |
| if Shared.contains(colName, 'trengthBonus') then strBonusCols = strBonusCols - 1 end
| |
| if Shared.contains(colName, 'efenceBonus') then defBonusCols = defBonusCols - 1 end
| |
| if Shared.contains(colName, 'LevelRequired') then lvlReqCols = lvlReqCols - 1 end
| |
| table.remove(statColumns, ndx)
| |
| else
| |
| ndx = ndx + 1
| |
| end
| |
| end
| |
|
| |
|
| --Alright, let's start the table by building the shared header
| | --Getting some lists set up here that will be used later |
| local result = '{| class="wikitable sortable stickyHeader"\r\n|-class="headerRow-0"'
| | --First, the list of columns used by both weapons & armour |
| if isWeaponType then
| | local statColumns = {'stabAttackBonus', 'slashAttackBonus','blockAttackBonus','rangedAttackBonus', 'magicAttackBonus', 'meleeStrengthBonus', 'rangedStrengthBonus', 'magicDamageBonus', 'meleeDefenceBonus', 'rangedDefenceBonus', 'magicDefenceBonus', 'damageReduction', 'attackLevelRequired', 'defenceLevelRequired', 'rangedLevelRequired', 'magicLevelRequired'} |
| --Weapons have extra columns here for Attack Speed and "Two Handed?"
| |
| result = result..'\r\n!colspan="4"|'
| |
| else
| |
| result = result..'\r\n!colspan="2"|'
| |
| end
| |
| if attBonusCols > 0 then
| |
| result = result..'\r\n!colspan="'..attBonusCols..'"style="padding:0 0.5em 0 0.5em;"|Attack Bonus'
| |
| end
| |
| if strBonusCols > 0 then
| |
| result = result..'\r\n!colspan="'..strBonusCols..'"style="padding:0 0.5em 0 0.5em;"|Str. Bonus'
| |
| end
| |
| if Shared.contains(statColumns, 'magicDamageBonus') then
| |
| result = result..'\r\n!colspan="1"style="padding:0 0.5em 0 0.5em;"|% Dmg Bonus'
| |
| end
| |
| if defBonusCols > 0 then
| |
| result = result..'\r\n!colspan="'..defBonusCols..'"style="padding:0 0.5em 0 0.5em;"|Defence Bonus'
| |
| end
| |
| if Shared.contains(statColumns, 'damageReduction') then
| |
| result = result..'\r\n!colspan="1"style="padding:0 0.5em 0 0.5em;"|DR'
| |
| end
| |
| if lvlReqCols > 0 then
| |
| result = result..'\r\n!colspan="'..lvlReqCols..'"style="padding:0 0.5em 0 0.5em;"|Lvl Req'
| |
| end
| |
| if includeModifiers and includeDescription then
| |
| result = result..'\r\n!colspan="3"|'
| |
| elseif includeModifiers or includeDescription then
| |
| result = result..'\r\n!colspan="2"|'
| |
| else
| |
| result = result..'\r\n!colspan="1"|'
| |
| end
| |
| --One header row down, one to go
| |
| result = result..'\r\n|-class="headerRow-1"'
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|Item'
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|Name'
| |
| --Weapons have Attack Speed here
| |
| if isWeaponType then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|Attack Speed'
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|Two Handed?'
| |
| end
| |
| --Attack bonuses
| |
| if Shared.contains(statColumns, 'slashAttackBonus') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Attack', type='skill', notext='true'})
| |
| end
| |
| if Shared.contains(statColumns, 'stabAttackBonus') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Strength', type='skill', notext='true'})
| |
| end
| |
| if Shared.contains(statColumns, 'blockAttackBonus') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Defence', type='skill', notext='true'})
| |
| end
| |
| if Shared.contains(statColumns, 'rangedAttackBonus') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Ranged', type='skill', notext='true'})
| |
| end
| |
| if Shared.contains(statColumns, 'magicAttackBonus') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Magic', type='skill', notext='true'})
| |
| end
| |
| --Strength bonuses
| |
| if Shared.contains(statColumns, 'strengthBonus') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Strength', type='skill', notext='true'})
| |
| end
| |
| if Shared.contains(statColumns, 'rangedStrengthBonus') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Ranged', type='skill', notext='true'})
| |
| end
| |
| if Shared.contains(statColumns, 'magicDamageBonus') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Magic', type='skill', notext='true'})
| |
| end
| |
| --Defence bonuses
| |
| if Shared.contains(statColumns, 'defenceBonus') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Defence', type='skill', notext='true'})
| |
| end
| |
| if Shared.contains(statColumns, 'rangedDefenceBonus') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Ranged', type='skill', notext='true'})
| |
| end
| |
| if Shared.contains(statColumns, 'magicDefenceBonus') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Magic', type='skill', notext='true'})
| |
| end
| |
| if Shared.contains(statColumns, 'damageReduction') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Defence', type='skill', notext='true'})
| |
| end
| |
| --Level requirements
| |
| if Shared.contains(statColumns, 'attackLevelRequired') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Attack', type='skill', notext='true'})
| |
| end
| |
| if Shared.contains(statColumns, 'defenceLevelRequired') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Defence', type='skill', notext='true'})
| |
| end
| |
| if Shared.contains(statColumns, 'rangedLevelRequired') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Ranged', type='skill', notext='true'})
| |
| end
| |
| if Shared.contains(statColumns, 'magicLevelRequired') then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|'..Icons.Icon({'Magic', type='skill', notext='true'})
| |
| end
| |
| --If includeModifiers is set to 'true', add the Modifiers column
| |
| if includeModifiers then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|Modifiers'
| |
| end
| |
| --If includeDescription is set to 'true', add the Description column
| |
| if includeDescription then
| |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|Description'
| |
| end
| |
|
| |
|
| --And finally Sources
| | if Shared.tableIsEmpty(itemList) then |
| result = result..'\r\n!style="padding:0 1em 0 0.5em;"|Sources'
| | return 'ERROR: you must select at least one item to get stats for[[Category:Pages with script errors]]' |
| | end |
|
| |
|
| local getStatValue = function(item, statName, equipStats, levelReqs)
| | local isWeaponType = ((itemList[1].validSlots ~= nil and Shared.contains(itemList[1].validSlots, 'Weapon')) |
| if string.find(statName, '^(.+)LevelRequired$') ~= nil then
| | or (itemList[1].occupiesSlots ~= nil and Shared.contains(itemList[1].occupiesSlots, 'Weapon'))) and Shared.contains(weaponTypes, itemList[1].type) |
| -- Level requirement
| |
| local skillName = Shared.titleCase(string.match(statName, '^(.+)LevelRequired$'))
| |
| return levelReqs[skillName] or 0
| |
| elseif Shared.contains(ItemData.EquipmentStatKeys, statName) then
| |
| -- Equipment stat
| |
| return equipStats[statName] or 0
| |
| else
| |
| -- Something else that we'll assume _getItemStat() will handle
| |
| return Items._getItemStat(item, statName, true)
| |
| end
| |
| end
| |
| table.sort(itemList, function(a, b) return a.id < b.id end)
| |
| for i, item in pairs(itemList) do
| |
| local equipStats = Items._processEquipmentStats(item.equipmentStats)
| |
| local levelReqs = Items._processEquipmentLevelReqs(item.equipRequirements)
| |
| if isWeaponType then
| |
| --Building rows for weapons
| |
| result = result..'\r\n|-'
| |
| result = result..'\r\n|style ="text-align: left;padding: 0 0 0 0;"|'..Icons.Icon({item.name, type='item', size=50, notext=true})
| |
| result = result..'\r\n|style ="text-align: left;padding: 0 0.5em 0 0.5em;"|[['..item.name..']]'
| |
| result = result..'\r\n| style ="text-align: right;padding: 0 0.5em 0 0;" |'..Shared.formatnum(equipStats.attackSpeed)
| |
| --That's the first list out of the way, now for 2-Handed
| |
| result = result..'\r\n| style ="text-align: right;"|'
| |
| if Items._getItemStat(item, 'isTwoHanded') then result = result..'Yes' else result = result..'No' end
| |
| for j, statName in pairs(statColumns) do
| |
| local statValue = getStatValue(item, statName, equipStats, levelReqs)
| |
| result = result..'\r\n| style ="text-align: right;padding: 0 0.5em 0 0;'
| |
| if string.find(statName, '^(.+)LevelRequired$') == nil then
| |
| if statValue > 0 then
| |
| result = result..'background-color:lightgreen;'
| |
| elseif statValue < 0 then
| |
| result = result..'background-color:lightpink;'
| |
| end
| |
| end
| |
| result = result..'"|'..Shared.formatnum(statValue)
| |
| if statName == 'magicDamageBonus' or statName == 'damageReduction' then result = result..'%' end
| |
| end
| |
| --If requested, add the item Modifiers
| |
| if includeModifiers then
| |
| result = result..'\r\n|style="text-align:left;white-space:nowrap;padding:0 0.5em 0 0.5em;"|'
| |
| result = result..Constants.getModifiersText(item.modifiers, true)
| |
| end
| |
| --If requested, add description
| |
| if includeDescription then
| |
| result = result..'\r\n|style="text-align:left;padding:0 0.5em 0 0.5em;"|'
| |
| result = result..(item.description ~= nil and item.description or '')
| |
| end
| |
| --Finally, the Sources
| |
| result = result..'\r\n| style ="text-align: right;padding: 0 0.5em 0 0.5em;" |'
| |
| result = result..ItemSourceTables._getItemSources(item)
| |
| else
| |
| --Building rows for armour
| |
| result = result..'\r\n|-'
| |
| result = result..'\r\n|style ="text-align: left;padding: 0 0 0 0;"|'..Icons.Icon({item.name, type='item', size=50, notext=true})
| |
| result = result..'\r\n|style ="text-align: left;padding: 0 0.5em 0 0.5em;"|[['..item.name..']]'
| |
| for j, statName in pairs(statColumns) do
| |
| local statValue = getStatValue(item, statName, equipStats, levelReqs)
| |
| result = result..'\r\n| style ="text-align: right;padding: 0 0.5em 0 0;'
| |
| if statValue > 0 then
| |
| result = result..'background-color:lightgreen;'
| |
| elseif statValue < 0 then
| |
| result = result..'background-color:lightpink;'
| |
| end
| |
| result = result..'"|'..Shared.formatnum(statValue)
| |
| if statName == 'magicDamageBonus' or statName == 'damageReduction' then result = result..'%' end
| |
| end
| |
| --If requested, add the item Modifiers
| |
| if includeModifiers then
| |
| result = result..'\r\n|style="text-align:left;white-space:nowrap;padding:0 0.5em 0 0.5em;"|'
| |
| result = result..Constants.getModifiersText(item.modifiers, true)
| |
| end
| |
| --If requested, add description
| |
| if includeDescription then
| |
| result = result..'\r\n|style="text-align:left;padding:0 0.5em 0 0.5em;"|'
| |
| result = result..(item.description ~= nil and item.description or '')
| |
| end
| |
| --Finally, the Sources
| |
| result = result..'\r\n| style ="text-align: right;padding: 0 0.5em 0 0.5em;" |'
| |
| result = result..ItemSourceTables._getItemSources(item)
| |
| end
| |
| end
| |
|
| |
|
| result = result..'\r\n|}'
| | --Now that we have a preliminary list, let's figure out which columns are irrelevant (IE are zero for all items in the selection) |
| return result
| | local ignoreColumns = Shared.clone(statColumns) |
| end | | for i, item in pairs(itemList) do |
| | local ndx = 1 |
| | while Shared.tableCount(ignoreColumns) >= ndx do |
| | if Items._getItemStat(item, ignoreColumns[ndx], true) ~= 0 then |
| | table.remove(ignoreColumns, ndx) |
| | else |
| | ndx = ndx + 1 |
| | end |
| | end |
| | end |
|
| |
|
| function p.getEquipmentTable(frame)
| | --Now to remove the ignored columns (and also we need to track groups like defence bonuses to see how many remain) |
| local args = frame.args ~= nil and frame.args or frame
| | local attBonusCols = 5 |
| local type = args.type
| | local strBonusCols = 2 |
| local tier = args.tier
| | local defBonusCols = 3 |
| local slot = args.slot
| | local lvlReqCols = 4 |
| local ammoTypeStr = args.ammoType
| | local ndx = 1 |
| local category = args.category ~= nil and args.category or 'Combat'
| | while Shared.tableCount(statColumns) >= ndx do |
| | local colName = statColumns[ndx] |
| | if Shared.contains(ignoreColumns, colName) then |
| | if Shared.contains(colName, 'AttackBonus') then attBonusCols = attBonusCols - 1 end |
| | if Shared.contains(colName, 'trengthBonus') then strBonusCols = strBonusCols - 1 end |
| | if Shared.contains(colName, 'efenceBonus') then defBonusCols = defBonusCols - 1 end |
| | if Shared.contains(colName, 'LevelRequired') then lvlReqCols = lvlReqCols - 1 end |
| | table.remove(statColumns, ndx) |
| | else |
| | ndx = ndx + 1 |
| | end |
| | end |
|
| |
|
| --Find out what Ammo Type we're working with
| | --Alright, let's start the table by building the shared header |
| local ammoType = nil
| | local resultPart = {} |
| if ammoTypeStr ~= nil then
| | table.insert(resultPart, '{| class="wikitable sortable stickyHeader"\r\n|-class="headerRow-0"') |
| if ammoTypeStr == "Arrows" then
| | if isWeaponType then |
| ammoType = 0
| | --Weapons have extra columns here for Attack Speed and "Two Handed?" |
| elseif ammoTypeStr == 'Bolts' then
| | table.insert(resultPart, '\r\n!colspan="4"|') |
| ammoType = 1
| | else |
| elseif ammoTypeStr == 'Javelins' then
| | table.insert(resultPart, '\r\n!colspan="2"|') |
| ammoType = 2
| | end |
| elseif ammoTypeStr == 'Throwing Knives' then
| | if attBonusCols > 0 then |
| ammoType = 3
| | table.insert(resultPart, '\r\n!colspan="'..attBonusCols..'"|Attack Bonus') |
| end
| | end |
| end
| | if strBonusCols > 0 then |
| | table.insert(resultPart, '\r\n!colspan="'..strBonusCols..'"|Str. Bonus') |
| | end |
| | if Shared.contains(statColumns, 'magicDamageBonus') then |
| | table.insert(resultPart, '\r\n!colspan="1"|% Dmg Bonus') |
| | end |
| | if defBonusCols > 0 then |
| | table.insert(resultPart, '\r\n!colspan="'..defBonusCols..'"|Defence Bonus') |
| | end |
| | if Shared.contains(statColumns, 'damageReduction') then |
| | table.insert(resultPart, '\r\n!colspan="1"|DR') |
| | end |
| | if lvlReqCols > 0 then |
| | table.insert(resultPart, '\r\n!colspan="'..lvlReqCols..'"|Lvl Req') |
| | end |
| | if includeModifiers and includeDescription then |
| | table.insert(resultPart, '\r\n!colspan="2"|') |
| | elseif includeModifiers or includeDescription then |
| | table.insert(resultPart, '\r\n!colspan="1"|') |
| | end |
| | --One header row down, one to go |
| | table.insert(resultPart, '\r\n|-class="headerRow-1"') |
| | table.insert(resultPart, '\r\n!Item') |
| | table.insert(resultPart, '\r\n!Name') |
| | --Weapons have Attack Speed here |
| | if isWeaponType then |
| | table.insert(resultPart, '\r\n!Attack Speed') |
| | table.insert(resultPart, '\r\n!Two Handed?') |
| | end |
| | --Attack bonuses |
| | if Shared.contains(statColumns, 'slashAttackBonus') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Attack', type='skill', notext='true'})) |
| | end |
| | if Shared.contains(statColumns, 'stabAttackBonus') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Strength', type='skill', notext='true'})) |
| | end |
| | if Shared.contains(statColumns, 'blockAttackBonus') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Defence', type='skill', notext='true'})) |
| | end |
| | if Shared.contains(statColumns, 'rangedAttackBonus') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Ranged', type='skill', notext='true'})) |
| | end |
| | if Shared.contains(statColumns, 'magicAttackBonus') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Magic', type='skill', notext='true'})) |
| | end |
| | --Strength bonuses |
| | if Shared.contains(statColumns, 'meleeStrengthBonus') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Strength', type='skill', notext='true'})) |
| | end |
| | if Shared.contains(statColumns, 'rangedStrengthBonus') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Ranged', type='skill', notext='true'})) |
| | end |
| | if Shared.contains(statColumns, 'magicDamageBonus') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Magic', type='skill', notext='true'})) |
| | end |
| | --Defence bonuses |
| | if Shared.contains(statColumns, 'meleeDefenceBonus') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Defence', type='skill', notext='true'})) |
| | end |
| | if Shared.contains(statColumns, 'rangedDefenceBonus') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Ranged', type='skill', notext='true'})) |
| | end |
| | if Shared.contains(statColumns, 'magicDefenceBonus') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Magic', type='skill', notext='true'})) |
| | end |
| | if Shared.contains(statColumns, 'damageReduction') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Defence', type='skill', notext='true'})) |
| | end |
| | --Level requirements |
| | if Shared.contains(statColumns, 'attackLevelRequired') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Attack', type='skill', notext='true'})) |
| | end |
| | if Shared.contains(statColumns, 'defenceLevelRequired') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Defence', type='skill', notext='true'})) |
| | end |
| | if Shared.contains(statColumns, 'rangedLevelRequired') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Ranged', type='skill', notext='true'})) |
| | end |
| | if Shared.contains(statColumns, 'magicLevelRequired') then |
| | table.insert(resultPart, '\r\n!'..Icons.Icon({'Magic', type='skill', notext='true'})) |
| | end |
| | --If includeModifiers is set to 'true', add the Modifiers column |
| | if includeModifiers then |
| | table.insert(resultPart, '\r\n!Modifiers') |
| | end |
| | --If includeDescription is set to 'true', add the Description column |
| | if includeDescription then |
| | table.insert(resultPart, '\r\n!Description') |
| | end |
|
| |
|
| local isWeaponType = Shared.contains(weaponTypes, type)
| | if sortByName then |
| | table.sort(itemList, function(a, b) return a.name < b.name end) |
| | end |
| | for i, item in ipairs(itemList) do |
| | if isWeaponType then |
| | --Building rows for weapons |
| | local atkSpeed = Items._getItemStat(item, 'attackSpeed', true) |
| | table.insert(resultPart, '\r\n|-') |
| | table.insert(resultPart, '\r\n|style="text-align: centre;"|'..Icons.Icon({item.name, type='item', size=50, notext=true})) |
| | table.insert(resultPart, '\r\n|' .. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true})) |
| | table.insert(resultPart, '\r\n| data-sort-value="' .. atkSpeed .. '" style="text-align:right;" |'..Shared.round(atkSpeed / 1000, 3, 1) .. 's') |
| | --That's the first list out of the way, now for 2-Handed |
| | table.insert(resultPart, '\r\n| style="text-align: right;"|') |
| | table.insert(resultPart, Items._getItemStat(item, 'isTwoHanded') and 'Yes' or 'No') |
| | for j, statName in pairs(statColumns) do |
| | local statValue = Items._getItemStat(item, statName, true) |
| | table.insert(resultPart, '\r\n| style="text-align:right;" class="') |
| | if string.find(statName, '^(.+)LevelRequired$') == nil then |
| | if statValue > 0 then |
| | table.insert(resultPart, 'table-positive') |
| | elseif statValue < 0 then |
| | table.insert(resultPart, 'table-negative') |
| | end |
| | end |
| | table.insert(resultPart, '"|'..Shared.formatnum(statValue)) |
| | if statName == 'magicDamageBonus' or statName == 'damageReduction' then table.insert(resultPart, '%') end |
| | end |
| | --If requested, add the item Modifiers |
| | if includeModifiers then |
| | table.insert(resultPart, '\r\n|') |
| | local txtLines = {} |
| | local modTxt = Constants.getModifiersText(item.modifiers, true) |
| | if modTxt ~= '' then |
| | table.insert(txtLines, modTxt) |
| | end |
| | --For items with a special attack, show the details |
| | if item.specialAttacks ~= nil and not Shared.tableIsEmpty(item.specialAttacks) then |
| | table.insert(txtLines, "'''Special Attack:'''") |
| | for i, spAttID in ipairs(item.specialAttacks) do |
| | local spAtt = GameData.getEntityByID('attacks', spAttID) |
| | table.insert(txtLines, spAtt.defaultChance .. '% chance for ' .. spAtt.name .. ':') |
| | table.insert(txtLines, spAtt.description) |
| | end |
| | end |
| | table.insert(resultPart, table.concat(txtLines, '<br/>')) |
| | end |
| | --If requested, add description |
| | if includeDescription then |
| | table.insert(resultPart, '\r\n| ') |
| | table.insert(resultPart, Constants.getDescription(item.customDescription, item.modifiers) or '') |
| | end |
| | else |
| | --Building rows for armour |
| | table.insert(resultPart, '\r\n|-') |
| | table.insert(resultPart, '\r\n|'..Icons.Icon({item.name, type='item', size=50, notext=true})) |
| | table.insert(resultPart, '\r\n|' .. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true})) |
| | for j, statName in pairs(statColumns) do |
| | local statValue = Items._getItemStat(item, statName, true) |
| | table.insert(resultPart, '\r\n|style="text-align:right;" class="') |
| | if statValue > 0 then |
| | table.insert(resultPart, 'table-positive') |
| | elseif statValue < 0 then |
| | table.insert(resultPart, 'table-negative') |
| | end |
| | table.insert(resultPart, '"|'..Shared.formatnum(statValue)) |
| | if statName == 'magicDamageBonus' or statName == 'damageReduction' then table.insert(resultPart, '%') end |
| | end |
| | --If requested, add the item Modifiers |
| | if includeModifiers then |
| | table.insert(resultPart, '\r\n| ') |
| | local txtLines = {} |
| | local modTxt = Constants.getModifiersText(item.modifiers, true) |
| | if modTxt ~= '' then |
| | table.insert(txtLines, modTxt) |
| | end |
| | --For items with a special attack, show the details |
| | if item.specialAttacks ~= nil and not Shared.tableIsEmpty(item.specialAttacks) then |
| | table.insert(txtLines, "'''Special Attack:'''") |
| | for i, spAttID in ipairs(item.specialAttacks) do |
| | local spAtt = GameData.getEntityByID('attacks', spAttID) |
| | table.insert(txtLines, spAtt.defaultChance .. '% chance for ' .. spAtt.name .. ':') |
| | table.insert(txtLines, spAtt.description) |
| | end |
| | end |
| | table.insert(resultPart, table.concat(txtLines, '<br/>')) |
| | end |
| | --If requested, add description |
| | if includeDescription then |
| | table.insert(resultPart, '\r\n| ') |
| | table.insert(resultPart, Constants.getDescription(item.customDescription, item.modifiers) or '') |
| | end |
| | end |
| | end |
|
| |
|
| --Now we need to figure out which items are in this list
| | table.insert(resultPart, '\r\n|}') |
| local itemList = {}
| |
| for i, itemBase in pairs(ItemData.Items) do
| |
| local item = Shared.clone(itemBase)
| |
| item.id = i - 1
| |
| local listItem = false
| |
| if isWeaponType then
| |
| listItem = item.type == type and item.category == category
| |
| if ammoType ~= nil then listItem = listItem and item.ammoTypeRequired == ammoType end
| |
| else
| |
| --Now for handling armour
| |
| local levelReqs = Items._processEquipmentLevelReqs(item.equipRequirements)
| |
| if type == "Armour" or type == "Melee" then
| |
| listItem = levelReqs['Defence'] ~= nil or (item.category == 'Combat' and item.type == 'Armour')
| |
| elseif type == "Ranged Armour" or type == "Ranged" then
| |
| listItem = levelReqs['Ranged'] ~= nil or (item.category == 'Combat' and item.type == 'Ranged Armour')
| |
| elseif type == "Magic Armour" or type == "Magic" then
| |
| listItem = levelReqs['Magic'] or (item.category == 'Combat' and item.type == 'Magic Armour')
| |
| else
| |
| listItem = item.type == type and item.category ~= 'Combat'
| |
| end
| |
| if ammoType ~= nil then listItem = listItem and item.ammoType == ammoType end
| |
| if slot ~= nil then listItem = listItem and Shared.contains(item.validSlots, slot) end
| |
| end
| |
| if listItem then
| |
| table.insert(itemList, item)
| |
| end
| |
| end
| |
|
| |
|
| return p._getEquipmentTable(itemList).."[[Category:getEquipmentTable]]"
| | return table.concat(resultPart) |
| end | | end |
|
| |
|
| function p._getCategoryTable(style, slot, other, includeModifiers, includeDescription) | | function p._getCategoryTable(style, slot, other, includeModifiers, includeDescription, sortByName) |
| if type(slot) == 'number' then
| | if type(slot) == 'number' then |
| slot = Constants.getEquipmentSlotName(slot)
| | slot = Constants.getEquipmentSlotName(slot) |
| end
| | end |
| | |
| local itemList = Items.getItems(function(item)
| |
| local isMatch = true
| |
| local levelReqs = Items._processEquipmentLevelReqs(item.equipRequirements)
| |
| if style == 'Melee' then
| |
| if (levelReqs['Defence'] == nil and levelReqs['Attack'] == nil) and not Shared.contains(styleOverrides.Melee, item.name) then isMatch = false end
| |
| elseif style == 'Ranged' then
| |
| if levelReqs['Ranged'] == nil and not Shared.contains(styleOverrides.Ranged, item.name) then isMatch = false end
| |
| elseif style == 'Magic' then
| |
| if levelReqs['Magic'] == nil and not Shared.contains(styleOverrides.Magic, item.name) then isMatch = false end
| |
| elseif style == 'None' then
| |
| if (levelReqs['Defence'] ~= nil or levelReqs['Ranged'] ~= nil or levelReqs['Magic'] ~= nil or
| |
| Shared.contains(styleOverrides.Melee, item.name) or Shared.contains(styleOverrides.Ranged, item.name) or Shared.contains(styleOverrides.Magic, item.name)) and
| |
| not Shared.contains(styleOverrides.None, item.name) then
| |
| isMatch = false
| |
| end
| |
| end
| |
| if slot == nil or not Shared.contains(item.validSlots, slot) then isMatch = false end
| |
|
| |
|
| if isMatch and other ~= nil then
| | local itemList = Items.getItems(function(item) |
| if slot == 'Weapon' then --For quiver slot or weapon slot, 'other' is the ammo type
| | -- Exclude Golbin raid exclusives for now, such that they don't |
| if other == 'Arrows' then
| | -- pollute various equipment tables |
| if item.ammoTypeRequired ~= 0 then isMatch = false end
| | if item.golbinRaidExclusive ~= nil and item.golbinRaidExclusive then |
| elseif other == 'Bolts' then
| | return false |
| if item.ammoTypeRequired ~= 1 then isMatch = false end
| | end |
| end
| | local isMatch = true |
| elseif slot == 'Quiver' then
| | if style == 'Melee' then |
| if other == 'Arrows' then
| | if ((Items._getItemStat(item, 'defenceLevelRequired') == nil and Items._getItemStat(item, 'attackLevelRequired') == nil) and not Shared.contains(styleOverrides.Melee, item.name)) or Shared.contains(styleOverrides.NotMelee, item.name) then isMatch = false end |
| if item.ammoType ~= 0 then isMatch = false end
| | elseif style == 'Ranged' then |
| elseif other == 'Bolts' then
| | if (Items._getItemStat(item, 'rangedLevelRequired') == nil and not Shared.contains(styleOverrides.Ranged, item.name)) or Shared.contains(styleOverrides.NotRanged, item.name) then isMatch = false end |
| if item.ammoType ~= 1 then isMatch = false end
| | elseif style == 'Magic' then |
| elseif other == 'Javelins' then
| | if (Items._getItemStat(item, 'magicLevelRequired') == nil and not Shared.contains(styleOverrides.Magic, item.name)) or Shared.contains(styleOverrides.NotMagic, item.name) then isMatch = false end |
| if item.ammoType ~= 2 then isMatch = false end
| | elseif style == 'None' then |
| elseif other == 'Throwing Knives' then
| | if (Items._getItemStat(item, 'defenceLevelRequired') ~= nil or Items._getItemStat(item, 'rangedLevelRequired') ~= nil or Items._getItemStat(item, 'magicLevelRequired') ~= nil or |
| if item.ammoType ~= 3 then isMatch = false end
| | Shared.contains(styleOverrides.Melee, item.name) or Shared.contains(styleOverrides.Ranged, item.name) or Shared.contains(styleOverrides.Magic, item.name)) and |
| elseif other == 'Thrown' then
| | not Shared.contains(styleOverrides.None, item.name) then |
| if item.ammoType ~= 2 and item.ammoType ~= 3 then isMatch = false end
| | isMatch = false |
| end
| | end |
| end
| | end |
| end
| | if slot == nil or not Shared.contains(item.validSlots, slot) then isMatch = false end |
|
| |
|
| return isMatch
| | if isMatch and other ~= nil then |
| end)
| | if slot == 'Cape' then |
| | -- TODO Would be more reliable if based on items appearing within the relevant shop categories instead |
| | local isSkillcape = Shared.contains(item.name, 'Skillcape') or Shared.contains(item.name, 'Cape of Completion') |
| | if other == 'Skillcapes' then |
| | isMatch = isSkillcape |
| | elseif other == 'No Skillcapes' then |
| | isMatch = not isSkillcape |
| | end |
| | end |
| | if slot == 'Weapon' then --For quiver slot or weapon slot, 'other' is the ammo type |
| | isMatch = other == item.ammoTypeRequired |
| | elseif slot == 'Quiver' then |
| | if other == 'Thrown' and Shared.contains({'Javelins', 'ThrowingKnives'}, item.ammoType) then |
| | isMatch = true |
| | else |
| | isMatch = other == item.ammoType |
| | end |
| | end |
| | end |
|
| |
|
| return p._getEquipmentTable(itemList, includeModifiers, includeDescription)
| | return isMatch |
| | end) |
| | |
| | return p._getEquipmentTable(itemList, includeModifiers, includeDescription, sortByName) |
| end | | end |
|
| |
|
| function p.getCategoryTable(frame) | | function p.getCategoryTable(frame) |
| local style = frame.args ~= nil and frame.args[1] or frame[1]
| | local style = frame.args ~= nil and frame.args[1] or frame[1] |
| local slot = frame.args ~= nil and frame.args[2] or frame[2]
| | local slot = frame.args ~= nil and frame.args[2] or frame[2] |
| local other = frame.args ~= nil and frame.args[3] or frame[3]
| | local other = frame.args ~= nil and frame.args[3] or frame[3] |
| local includeModifiers = frame.args ~= nil and frame.args.includeModifiers or frame.includeModifiers
| | local includeModifiers = frame.args ~= nil and frame.args.includeModifiers or frame.includeModifiers |
| local includeDescription = frame.args ~= nil and frame.args.includeDescription or frame.includeDescription
| | local includeDescription = frame.args ~= nil and frame.args.includeDescription or frame.includeDescription |
| | local sortByName = frame.args ~= nil and frame.args.sortByName or frame.sortByName |
|
| |
|
| includeModifiers = includeModifiers ~= nil and string.upper(includeModifiers) == 'TRUE' or false
| | includeModifiers = includeModifiers ~= nil and string.upper(includeModifiers) == 'TRUE' or false |
| includeDescription = includeDescription ~= nil and string.upper(includeDescription) == 'TRUE' or false
| | includeDescription = includeDescription ~= nil and string.upper(includeDescription) == 'TRUE' or false |
| | sortByName = sortByName ~= nil and string.upper(sortByName) == 'TRUE' or false |
|
| |
|
| return p._getCategoryTable(style, slot, other, includeModifiers, includeDescription)
| | return p._getCategoryTable(style, slot, other, includeModifiers, includeDescription, sortByName) |
| end | | end |
|
| |
|
| function p.getTableForList(frame) | | function p.getTableForList(frame) |
| local stuffString = frame.args ~= nil and frame.args[1] or frame[1]
| | local stuffString = frame.args ~= nil and frame.args[1] or frame[1] |
| local itemNames = Shared.splitString(stuffString, ',')
| | local itemNames = Shared.splitString(stuffString, ',') |
|
| |
|
| local includeModifiers = frame.args ~= nil and frame.args[2] or frame[2]
| | local includeModifiers = frame.args ~= nil and frame.args[2] or frame[2] |
| includeModifiers = includeModifiers ~= nil and string.upper(includeModifiers) == 'TRUE' or false
| | includeModifiers = includeModifiers ~= nil and string.upper(includeModifiers) == 'TRUE' or false |
|
| |
|
| local itemList = {}
| | local itemList = {} |
| local errMsg = 'ERROR: Some items not found in database: [[Category:Pages with script errors]]'
| | local errMsg = 'ERROR: Some items not found in database: [[Category:Pages with script errors]]' |
| local hasErr = false
| | local hasErr = false |
| for i, name in Shared.skpairs(itemNames) do
| | for i, name in Shared.skpairs(itemNames) do |
| local nextItem = Items.getItem(Shared.trim(name))
| | local nextItem = Items.getItem(Shared.trim(name)) |
| if nextItem == nil then
| | if nextItem == nil then |
| errMsg = errMsg.." '"..name.."'"
| | errMsg = errMsg.." '"..name.."'" |
| hasErr = true
| | hasErr = true |
| else
| | else |
| table.insert(itemList, nextItem)
| | table.insert(itemList, nextItem) |
| end
| | end |
| end
| | end |
|
| |
|
| if hasErr then
| | if hasErr then |
| return errMsg
| | return errMsg |
| else
| | else |
| return p._getEquipmentTable(itemList, includeModifiers)
| | return p._getEquipmentTable(itemList, includeModifiers) |
| end
| | end |
| end | | end |
|
| |
|
| function p.getDoubleLootTable(frame) | | function p.getDoubleLootTable(frame) |
| local modsDL = {
| | local modsDL = { |
| 'increasedChanceToDoubleLootCombat',
| | 'increasedChanceToDoubleLootCombat', |
| 'decreasedChanceToDoubleLootCombat',
| | 'decreasedChanceToDoubleLootCombat', |
| 'increasedChanceToDoubleLootThieving',
| | 'increasedChanceToDoubleLootThieving', |
| 'decreasedChanceToDoubleLootThieving',
| | 'decreasedChanceToDoubleLootThieving', |
| 'increasedChanceToDoubleItemsGlobal',
| | 'increasedChanceToDoubleItemsGlobal', |
| 'decreasedChanceToDoubleItemsGlobal'
| | 'decreasedChanceToDoubleItemsGlobal' |
| }
| | } |
| local modDetail = {}
| | local modDetail = {} |
| for i, modName in pairs(modsDL) do
| | for i, modName in pairs(modsDL) do |
| local mName, mText, mSign, mIsNeg, mValUnsigned = Constants.getModifierDetails(modName)
| | local mName, mText, mSign, mIsNeg, mValUnsigned = Constants.getModifierDetails(modName) |
| modDetail[modName] = { mult = (mSign == "+" and 1 or -1) }
| | modDetail[modName] = { mult = (mSign == "+" and 1 or -1) } |
| end
| | end |
| | |
| local itemList = Items.getItems(function(item)
| |
| if item.modifiers ~= nil then
| |
| for modName, val in pairs(item.modifiers) do
| |
| if Shared.contains(modsDL, modName) then return true end
| |
| end
| |
| return false
| |
| end
| |
| end)
| |
| table.sort(itemList, function(a, b) return a.id < b.id end)
| |
| local result = '{| class="wikitable sortable stickyHeader"\r\n|-class="headerRow-0"'
| |
| result = result..'\r\n!colspan="2"|Name!!Bonus!!Description!!Sources'
| |
| for i, item in Shared.skpairs(itemList) do
| |
| local lootValue = 0
| |
| for modName, modDet in pairs(modDetail) do
| |
| lootValue = lootValue + (item.modifiers[modName] or 0) * modDet.mult
| |
| end
| |
| result = result..'\r\n|-'
| |
| result = result..'\r\n|data-sort-value="'..item.name..'"|'..Icons.Icon({item.name, type='item', size=50, notext=true})
| |
| result = result..'||[['..item.name..']]'
| |
| result = result..'||style ="text-align: right;" data-sort-value="'..lootValue..'"|'..lootValue..'%'
| |
| result = result..'||'..item.description
| |
| result = result..'\r\n| style ="text-align: right;white-space: nowrap;padding: 0 0.5em 0 0.5em;" |'
| |
| result = result..ItemSourceTables._getItemSources(item)
| |
| end
| |
| | |
| result = result..'\r\n|}'
| |
| return result
| |
| end | |
|
| |
|
| function p.getItemTableRows(frame) | | local itemList = Items.getItems(function(item) |
| local startID = frame.args ~= nil and frame.args[1] or frame[1]
| | if item.modifiers ~= nil then |
| local rowCount = frame.args ~= nil and frame.args[2] or frame[2]
| | for modName, val in pairs(item.modifiers) do |
| if type(startID ) == 'string' then startID = tonumber(startID) end
| | if Shared.contains(modsDL, modName) then return true end |
| if rowCount == nil then rowCount = 200 end
| | end |
| if type(rowCount) == 'string' then rowCount = tonumber(rowCount) end
| | return false |
| | end |
| | end) |
|
| |
|
| local rowResult = {}
| | local resultPart = {} |
| for i = startID, startID + rowCount - 1, 1 do
| | table.insert(resultPart, '{| class="wikitable sortable stickyHeader"\r\n|-class="headerRow-0"') |
| local item = Items.getItemByID(i)
| | table.insert(resultPart, '\r\n!colspan="2"|Name!!Bonus!!Description') |
| if item == nil then break end
| | for i, item in Shared.skpairs(itemList) do |
| local rowTxt = '|-\r\n|'..Icons.Icon({item.name, type='item', size='50', notext=true})..'||[['..item.name..']]'
| | local lootValue = 0 |
| rowTxt = rowTxt..'||style="text-align:right;"|'..i..'||'..item.category..'||'..item.type
| | for modName, modDet in pairs(modDetail) do |
| rowTxt = rowTxt..'||style="text-align:right;" data-sort-value="'..item.sellsFor..'"|'..Icons.GP(item.sellsFor)
| | lootValue = lootValue + (item.modifiers[modName] or 0) * modDet.mult |
| rowTxt = rowTxt..'||style="text-align:right;"|'..ItemSourceTables._getItemSources(item, false, 'false')
| | end |
| rowTxt = rowTxt..'||style="text-align:right;"|'..ItemUseTables._getItemUses(item, false, 'false')
| | table.insert(resultPart, '\r\n|-') |
| table.insert(rowResult, rowTxt)
| | table.insert(resultPart, '\r\n|data-sort-value="'..item.name..'"|'..Icons.Icon({item.name, type='item', size=50, notext=true})) |
| end
| | table.insert(resultPart, '||' .. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true})) |
| | table.insert(resultPart, '||style ="text-align: right;" data-sort-value="'..lootValue..'"|'..lootValue..'%') |
| | table.insert(resultPart, '||'..(Constants.getDescription(item.customDescription, item.modifiers) or '')) |
| | end |
|
| |
|
| return table.concat(rowResult, '\r\n')
| | table.insert(resultPart, '\r\n|}') |
| | return table.concat(resultPart) |
| end | | end |
|
| |
|
| function p.getStatChangeString(item1, item2) | | function p.getStatChangeString(item1, item2) |
| --Used by getItemUpgradeTable to get the stat change between two items
| | --Used by getItemUpgradeTable to get the stat change between two items |
| local changeArray = {}
| | local changeArray = {} |
| | |
| local getSpecificStatString = function(val1, val2, subStr)
| |
| if val1 == nil then val1 = 0 end
| |
| if val2 == nil then val2 = 0 end
| |
| | |
| if val1 ~= val2 then
| |
| local txt = string.gsub(subStr, '{V}', Shared.numStrWithSign(val1 - val2))
| |
| table.insert(changeArray, txt)
| |
| end
| |
| end
| |
| | |
| --Unfortunately just gonna have to manually check all the changes I think...
| |
| local itemStats = {
| |
| { Stat = Items._processEquipmentStats(item1.equipmentStats), Level = Items._processEquipmentLevelReqs(item1.equipRequirements), SlayBon = Items._getItemModifier(item1, 'increasedSkillXP', 'Slayer') },
| |
| { Stat = Items._processEquipmentStats(item2.equipmentStats), Level = Items._processEquipmentLevelReqs(item2.equipRequirements), SlayBon = Items._getItemModifier(item2, 'increasedSkillXP', 'Slayer') },
| |
| }
| |
| local attBon1 = item1.attackBonus ~= nil and item1.attackBonus or {0, 0, 0}
| |
| local attBon2 = item2.attackBonus ~= nil and item2.attackBonus or {0, 0, 0}
| |
| getSpecificStatString(itemStats[1]['Stat']['stabAttackBonus'], itemStats[2]['Stat']['stabAttackBonus'], '{V} '..Icons.Icon({'Melee', notext=true})..' Stab Bonus')
| |
| getSpecificStatString(itemStats[1]['Stat']['slashAttackBonus'], itemStats[2]['Stat']['slashAttackBonus'], '{V} '..Icons.Icon({'Melee', notext=true})..' Slash Bonus')
| |
| getSpecificStatString(itemStats[1]['Stat']['blockAttackBonus'], itemStats[2]['Stat']['blockAttackBonus'], '{V} '..Icons.Icon({'Melee', notext=true})..' Block Bonus')
| |
| | |
| getSpecificStatString(itemStats[1]['Stat']['meleeStrengthBonus'], itemStats[2]['Stat']['meleeStrengthBonus'], '{V} '..Icons.Icon({'Strength', type='skill', notext=true})..' Strength Bonus')
| |
| getSpecificStatString(itemStats[1]['Stat']['rangedStrengthBonus'], itemStats[2]['Stat']['rangedStrengthBonus'], '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Strength Bonus')
| |
| getSpecificStatString(itemStats[1]['Stat']['magicStrengthBonus'], itemStats[2]['Stat']['magicStrengthBonus'], '{V}% '..Icons.Icon({'Magic', type='skill', notext=true})..' Damage Bonus')
| |
|
| |
|
| getSpecificStatString(itemStats[1]['Stat']['meleeDefenceBonus'], itemStats[2]['Stat']['meleeDefenceBonus'], '{V} '..Icons.Icon({'Defence', type='skill', notext=true})..' Defence Bonus')
| | local getSpecificStatString = function(val1, val2, subStr) |
| getSpecificStatString(itemStats[1]['Stat']['rangedDefenceBonus'], itemStats[2]['Stat']['rangeDefenceBonus'], '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Defence Bonus')
| | if val1 == nil then val1 = 0 end |
| getSpecificStatString(itemStats[1]['Stat']['magicDefenceBonus'], itemStats[2]['Stat']['magicDefenceBonus'], '{V} '..Icons.Icon({'Magic', type='skill', notext=true})..' Defence Bonus')
| | if val2 == nil then val2 = 0 end |
| getSpecificStatString(itemStats[1]['Stat']['damageReduction'], itemStats[2]['Stat']['damageReduction'], '{V}% Damage Reduction')
| |
|
| |
|
| getSpecificStatString(itemStats[1]['SlayBon'], itemStats[2]['SlayBon'], '{V}% '..Icons.Icon({'Slayer', type='skill', notext=true})..' Bonus XP')
| | if val1 ~= val2 then |
| | local txt = string.gsub(subStr, '{V}', Shared.numStrWithSign(val1 - val2)) |
| | table.insert(changeArray, txt) |
| | end |
| | end |
|
| |
|
| getSpecificStatString(itemStats[1]['Level']['Attack'], itemStats[2]['Level']['Attack'], '{V} '..Icons.Icon({'Attack', type='skill', notext=true})..' Level Required')
| | --Unfortunately just gonna have to manually check all the changes I think... |
| getSpecificStatString(itemStats[1]['Level']['Defence'], itemStats[2]['Level']['Defence'], '{V} '..Icons.Icon({'Defence', type='skill', notext=true})..' Level Required')
| | local statList = { |
| getSpecificStatString(itemStats[1]['Level']['Ranged'], itemStats[2]['Level']['Ranged'], '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Level Required')
| | -- {'statName', 'statDescription'} |
| getSpecificStatString(itemStats[1]['Level']['Magic'], itemStats[2]['Level']['Magic'], '{V} '..Icons.Icon({'Magic', type='skill', notext=true})..' Level Required')
| | {'stabAttackBonus', '{V} '..Icons.Icon({'Melee', notext=true})..' Stab Bonus'}, |
| | {'slashAttackBonus', '{V} '..Icons.Icon({'Melee', notext=true})..' Slash Bonus'}, |
| | {'blockAttackBonus', '{V} '..Icons.Icon({'Melee', notext=true})..' Block Bonus'}, |
| | {'meleeStrengthBonus', '{V} '..Icons.Icon({'Strength', type='skill', notext=true})..' Strength Bonus'}, |
| | {'rangedStrengthBonus', '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Strength Bonus'}, |
| | {'magicStrengthBonus', '{V}% '..Icons.Icon({'Magic', type='skill', notext=true})..' Damage Bonus'}, |
| | {'meleeDefenceBonus', '{V} '..Icons.Icon({'Defence', type='skill', notext=true})..' Defence Bonus'}, |
| | {'rangedDefenceBonus', '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Defence Bonus'}, |
| | {'magicDefenceBonus', '{V} '..Icons.Icon({'Magic', type='skill', notext=true})..' Defence Bonus'}, |
| | {'damageReduction', '{V}% Damage Reduction'}, |
| | {'increasedSlayerXP', '{V}% '..Icons.Icon({'Slayer', type='skill', notext=true})..' Bonus XP'}, |
| | {'attackLevelRequired', '{V} '..Icons.Icon({'Attack', type='skill', notext=true})..' Level Required'}, |
| | {'defenceLevelRequired', '{V} '..Icons.Icon({'Defence', type='skill', notext=true})..' Level Required'}, |
| | {'rangedLevelRequired', '{V} '..Icons.Icon({'Ranged', type='skill', notext=true})..' Level Required'}, |
| | {'magicLevelRequired', '{V} '..Icons.Icon({'Magic', type='skill', notext=true})..' Level Required'}, |
| | } |
| | for i, stat in ipairs(statList) do |
| | if stat[1] == 'increasedSlayerXP' then |
| | getSpecificStatString(Items._getItemModifier(item1, stat[1], 'Slayer'), Items._getItemModifier(item2, stat[1], 'Slayer'), stat[2]) |
| | else |
| | getSpecificStatString(Items._getItemStat(item1, stat[1]), Items._getItemStat(item2, stat[1]), stat[2]) |
| | end |
| | end |
|
| |
|
| return table.concat(changeArray, '<br/>')
| | return table.concat(changeArray, '<br/>') |
| end | | end |
|
| |
|
| function p.getItemUpgradeTable(frame) | | function p.getItemUpgradeTable(frame) |
| local category = frame.args ~= nil and frame.args[1] or frame
| | local category = frame.args ~= nil and frame.args[1] or frame |
| local itemArray = {}
| | local upgradeArray = {} |
| local isEquipment = false
| | local isEquipment = false |
| | |
| if string.upper(category) == 'POTION' then
| |
| itemArray = Items.getItems(function(item) return Shared.contains(item.name, 'Potion') and item.itemsRequired ~= nil end)
| |
| elseif string.upper(category) == 'OTHER' then
| |
| itemArray = Items.getItems(function(item)
| |
| return not Shared.contains(item.name, 'Potion') and item.itemsRequired ~= nil and item.validSlots == nil
| |
| end)
| |
| else
| |
| if Constants.getEquipmentSlotID(category) == nil then
| |
| return 'ERROR: Invalid option. Choose either an equipment slot, Potion, or Other[[Category:Pages with script errors]]'
| |
| end
| |
| isEquipment = true
| |
| itemArray = Items.getItems(function(item)
| |
| return item.itemsRequired ~= nil and Shared.contains(item.validSlots, category)
| |
| end)
| |
| end
| |
| table.sort(itemArray, function(a, b) return a.id < b.id end)
| |
|
| |
|
| local result = '{| class="wikitable sortable stickyHeader"'
| | if string.upper(category) == 'POTION' then |
| result = result..'\r\n|- class="headerRow-0"'
| | upgradeArray = GameData.getEntities('itemUpgrades', |
| result = result..'\r\n!colspan="2"|Upgraded Item!!Ingredients'
| | function(upgrade) return Shared.contains(upgrade.upgradedItemID, 'Potion') end |
| if isEquipment then result = result..'!!Stat Change' end
| | ) |
| | elseif string.upper(category) == 'OTHER' then |
| | upgradeArray = GameData.getEntities('itemUpgrades', |
| | function(upgrade) |
| | if not Shared.contains(upgrade.upgradedItemID, 'Potion') then |
| | local item = Items.getItemByID(upgrade.upgradedItemID) |
| | if item ~= nil then |
| | return item.validSlots == nil or Shared.tableIsEmpty(item.validSlots) |
| | end |
| | end |
| | return false |
| | end |
| | ) |
| | else |
| | if Constants.getEquipmentSlotID(category) == nil then |
| | return 'ERROR: Invalid option. Choose either an equipment slot, Potion, or Other[[Category:Pages with script errors]]' |
| | end |
| | isEquipment = true |
| | upgradeArray = GameData.getEntities('itemUpgrades', |
| | function(upgrade) |
| | local item = Items.getItemByID(upgrade.upgradedItemID) |
| | if item ~= nil then |
| | return item.validSlots ~= nil and Shared.contains(item.validSlots, category) |
| | end |
| | return false |
| | end |
| | ) |
| | end |
|
| |
|
| for i, item in Shared.skpairs(itemArray) do
| | local resultPart = {} |
| result = result..'\r\n|-'
| | table.insert(resultPart, '{| class="wikitable sortable stickyHeader"') |
| result = result..'\r\n|'..Icons.Icon({item.name, type='item', size='50', notext=true})..'||[['..item.name..']]'
| | table.insert(resultPart, '\r\n|- class="headerRow-0"') |
| | table.insert(resultPart, '\r\n!colspan="2"|Upgraded Item!!Ingredients') |
| | if isEquipment then table.insert(resultPart, '!!Stat Change') end |
|
| |
|
| local matArray = {}
| | for i, upgrade in ipairs(upgradeArray) do |
| local statChangeString = ''
| | local item = Items.getItemByID(upgrade.upgradedItemID) |
| for i, row in Shared.skpairs(item.itemsRequired) do
| | table.insert(resultPart, '\r\n|-') |
| local mat = Items.getItemByID(row[1])
| | table.insert(resultPart, '\r\n|'..Icons.Icon({item.name, type='item', size='50', notext=true})) |
| table.insert(matArray, Icons.Icon({mat.name, type='item', qty=row[2]}))
| | table.insert(resultPart, '||' .. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true})) |
|
| |
|
| if item.validSlots ~= nil and mat.validSlots ~= nil and statChangeString == '' then
| | local matArray = {} |
| statChangeString = p.getStatChangeString(item, mat)
| | local statChangeString = '' |
| end
| | for i, itemCost in ipairs(upgrade.itemCosts) do |
| end
| | local mat = Items.getItemByID(itemCost.id) |
| if item.trimmedGPCost ~= nil and item.trimmedGPCost > 0 then
| | if mat ~= nil then |
| table.insert(matArray, Icons.GP(item.trimmedGPCost))
| | table.insert(matArray, Icons.Icon({mat.name, type='item', qty=itemCost.quantity})) |
| end
| | if isEquipment and item.validSlots ~= nil and mat.validSlots ~= nil and statChangeString == '' then |
| result = result..'||'..table.concat(matArray, '<br/>')
| | statChangeString = p.getStatChangeString(item, mat) |
| | end |
| | end |
| | end |
| | if upgrade.gpCost ~= nil and upgrade.gpCost > 0 then |
| | table.insert(matArray, Icons.GP(upgrade.gpCost)) |
| | end |
| | if upgrade.scCost ~= nil and upgrade.scCost > 0 then |
| | table.insert(matArray, Icons.SC(upgrade.scCost)) |
| | end |
| | table.insert(resultPart, '||'..table.concat(matArray, '<br/>')) |
|
| |
|
| if isEquipment then
| | if isEquipment then |
| result = result..'||'..statChangeString
| | table.insert(resultPart, '||'..statChangeString) |
| end
| | end |
| end
| | end |
|
| |
|
| result = result..'\r\n|}'
| | table.insert(resultPart, '\r\n|}') |
| return result
| | return table.concat(resultPart) |
| end | | end |
|
| |
|
| return p | | return p |