Module:Items/UseTables: Difference between revisions

Re-implement modifier skill checks, and clean up itemUseArray accordingly
(Add Abyssal Compost and current Firemaking Oils)
(Re-implement modifier skill checks, and clean up itemUseArray accordingly)
Line 6: Line 6:
local GameData = require('Module:GameData')
local GameData = require('Module:GameData')
local SkillData = GameData.skillData
local SkillData = GameData.skillData
local Modifiers = require('Module:Modifiers')
local Skills = require('Module:Skills')
local Skills = require('Module:Skills')
local Magic = require('Module:Magic')
local Magic = require('Module:Magic')
Line 19: Line 20:
Agility = {},
Agility = {},
Astrology = {'melvorF:Stardust', 'melvorF:Golden_Stardust', 'melvorItA:Abyssal_Stardust'},
Astrology = {'melvorF:Stardust', 'melvorF:Golden_Stardust', 'melvorItA:Abyssal_Stardust'},
Archaeology = {'melvorAoD:Archaeologist_Gloves'},
Archaeology = {},
Attack = {},
Attack = {},
Cartography = {'melvorD:Crown_of_Rhaelyx'},
Cartography = {},
Combat = {'melvorF:Gold_Emerald_Ring', 'melvorD:Obsidian_Cape', 'melvorF:Throwing_Power_Gloves'},
Combat = {'melvorF:Gold_Emerald_Ring', 'melvorD:Obsidian_Cape', 'melvorF:Throwing_Power_Gloves'},
Cooking = {'melvorD:Cooking_Gloves', 'melvorD:Crown_of_Rhaelyx'},
Cooking = {'melvorD:Cooking_Gloves'},
Crafting = {'melvorD:Crown_of_Rhaelyx', 'melvorItA:Abyssal_Crafting_Gloves', 'melvorAoD:Old_Crafting_Gloves'},
Crafting = {'melvorItA:Abyssal_Crafting_Gloves'},
Defence = {},
Defence = {},
Farming = {'melvorD:Compost', 'melvorD:Weird_Gloop', 'melvorItA:Abyssal_Compost', 'melvorD:Bobs_Rake', 'melvorItA:Bobs_Lost_Gloves', 'melvorItA:Bobs_Lost_Rake'},
Farming = {'melvorD:Compost', 'melvorD:Weird_Gloop', 'melvorItA:Abyssal_Compost', 'melvorD:Bobs_Rake'},
Firemaking = {'melvorD:Crown_of_Rhaelyx', 'melvorItA:Abyssal_Firemaking_Gloves',
Firemaking = {'melvorItA:Abyssal_Firemaking_Gloves'},
'melvorItA:Abyssal_Firemaking_Oil', 'melvorItA:Twisted_Firemaking_Oil', 'melvorItA:Gloom_Firemaking_Oil',
Fishing = {'melvorD:Message_In_A_Bottle', 'melvorD:Barbarian_Gloves'},
'melvorItA:Shadow_Firemaking_Oil', 'melvorItA:Obsidian_Firemaking_Oil', 'melvorItA:Voidfire_Firemaking_Oil'},
Fletching = {'melvorItA:Abyssal_Fletching_Gloves'},
Fishing = {'melvorD:Amulet_of_Fishing', 'melvorD:Message_In_A_Bottle', 'melvorD:Barbarian_Gloves'},
Fletching = {'melvorD:Crown_of_Rhaelyx', 'melvorItA:Abyssal_Fletching_Gloves', 'melvorTotH:Sharp_Fletcher_Gloves'},
Harvesting = {'melvorItA:Abyssal_Harvesting_Gloves'},
Harvesting = {'melvorItA:Abyssal_Harvesting_Gloves'},
Herblore = {'melvorD:Crown_of_Rhaelyx', 'melvorItA:Abyssal_Herblore_Gloves', 'melvorTotH:Toxic_Maker_Gloves'},
Herblore = {'melvorItA:Abyssal_Herblore_Gloves'},
Hitpoints = {},
Hitpoints = {},
Magic = {},
Magic = {},
Line 39: Line 38:
Prayer = {},
Prayer = {},
Ranged = {},
Ranged = {},
Runecrafting = {'melvorD:Crown_of_Rhaelyx', 'melvorItA:Abyssal_Runecrafting_Gloves'},
Runecrafting = {'melvorItA:Abyssal_Runecrafting_Gloves'},
Slayer = {},
Slayer = {},
Smithing = {'melvorD:Smithing_Gloves', 'melvorD:Crown_of_Rhaelyx', 'melvorItA:Abyssal_Smithing_Gloves', 'melvorTotH:Blacksmiths_Gloves'},
Smithing = {'melvorD:Smithing_Gloves', 'melvorItA:Abyssal_Smithing_Gloves'},
Smithing = {},
Strength = {},
Strength = {},
Summoning = {'melvorD:Crown_of_Rhaelyx', 'melvorAoD:Old_Summoning_Gloves'},
Summoning = {},
Thieving = {'melvorF:Chapeau_Noir', 'melvorF:Thieving_Gloves', 'melvorF:Gloves_of_Silence'},
Thieving = {'melvorF:Thieving_Gloves'},
Township = {},
Township = {},
Woodcutting = {'melvorAoD:Old_Woodcutting_Gloves'},
Woodcutting = {},
}
}
 
-- List of modifier IDs which, if present on an item and not specific to any
-- particular skill, indicate that the item applies to all skills
local allSkillModIDs = {
-- Skill XP
'skillXP',
'nonCombatSkillXP',
'abyssalSkillXP',
-- Mastery
'flatMasteryTokens',
'xpFromMasteryTokens',
'masteryPoolCap',
'masteryXP',
'masteryPoolProgress',
-- Resource preservation
'bypassGlobalPreservationChance',
'skillPreservationChance',
'skillPreservationCap',
-- Other preservation (consumables, summons, potion charges)
'consumablePreservationChance',
'summoningChargePreservationChance',
'potionChargePreservationChance',
-- Item doubling
'globalItemDoublingChance',
-- Resource quantity
'flatBasePrimaryProductQuantity',
'basePrimaryProductQuantity',
'flatBaseRandomProductQuantity',
'flatAdditionalSkillItem',
'flatAdditionalPrimaryProductQuantity',
-- Cost reduction
'skillCostReduction',
-- Off item chance
'offItemChance'
}
 
local function allSkillModCriteriaFromIDs(modIDs)
local modIDsWithProps = {}
for i, modID in ipairs(allSkillModIDs) do
table.insert(modIDsWithProps, {
["id"] = modID,
["type"] = 'id',
["props"] = {
["skillID"] = 'nil',
["modType"] = 'pos'
}
})
end
return Modifiers.getMatchCriteriaFromIDs(modIDsWithProps)
end
 
local allSkillModCriteria = allSkillModCriteriaFromIDs(allSkillModIDs)


function p._getItemUses(item, asList, addCategories)
function p._getItemUses(item, asList, addCategories)
Line 106: Line 158:
-- Mastery tokens
-- Mastery tokens
addUse('Mastery')
addUse('Mastery')
--[=[else
else
local globalMods = {
local modsAllSkills = Modifiers.getMatchingModifiers(item.modifiers, allSkillModCriteria)
'increasedChanceToDoubleItemsGlobal',
if not Shared.tableIsEmpty(modsAllSkills.matched) then
'decreasedChanceToDoubleItemsGlobal',
addUse('AllSkills')
'increasedGlobalSkillIntervalPercent',
else
'decreasedGlobalSkillIntervalPercent',
local skillArray = Modifiers.getModifierSkills(item.modifiers)
'increasedGlobalSkillXP',
'decreasedGlobalSkillXP'
}
for i, globalMod in ipairs(globalMods) do
if item.modifiers[globalMod] ~= nil then
addUse('AllSkills')
break
end
end
if not hasUse('AllSkills') then
local skillArray = Constants.getModifierSkills(item.modifiers)
for i, skillName in ipairs(skillArray) do
for i, skillName in ipairs(skillArray) do
addUse(skillName)
addUse(skillName)
end
end
end--]=]
end
end
end
end
end
Line 334: Line 375:
end
end
--Other things that affect everything
affectsAll = {
'melvorItA:Abyssal_Skilling_Gem',
'melvorItA:Golem_Gloves',
}
if Shared.contains(affectsAll, item.id) then
addUse('AllSkills')
end
--Special note for Charge Stone of Rhaelyx
--Special note for Charge Stone of Rhaelyx
if item.id == 'melvorD:Charge_Stone_of_Rhaelyx' then
if item.id == 'melvorD:Charge_Stone_of_Rhaelyx' then