4,687
edits
(Fix colour for "CookingIntervalForBasicSoup") |
(Updated getModifierDetails to use modifiers from gameData) |
||
Line 5: | Line 5: | ||
--Just hardcoding these because I guess that's where we're at | --Just hardcoding these because I guess that's where we're at | ||
--getModifierSkills still needs skills, otherwise this can be removed | |||
local modifierTypes = { | local modifierTypes = { | ||
["MeleeStrengthBonus"] = { text = "{V}% Melee Strength Bonus from Equipment", skills = {'Combat'} }, | ["MeleeStrengthBonus"] = { text = "{V}% Melee Strength Bonus from Equipment", skills = {'Combat'} }, | ||
Line 907: | Line 908: | ||
--- End of slayer functions | --- End of slayer functions | ||
--Turns a modifier name like ' | --Turns a modifier name like 'increasedHPRegenFlat' into several pieces of data: | ||
--Base Name, | --Base Name, Description, IsNegative, and modifyValue | ||
--ex. " | --ex. "HPRegenFlat", "+${value} Flat Hitpoints Regeneration", false, "multiplyByNumberMultiplier" | ||
function p.getModifierDetails(modifierName) | function p.getModifierDetails(modifierName) | ||
local baseName = modifierName | local baseName = modifierName | ||
local | local modifier = GameData.rawData.modifierData[modifierName] | ||
if Shared.startsWith(modifierName, "increased") or Shared.startsWith(modifierName, "decreased") then | if Shared.startsWith(modifierName, "increased") or Shared.startsWith(modifierName, "decreased") then | ||
baseName = string.sub(modifierName, 10) | baseName = string.sub(modifierName, 10) | ||
end | end | ||
if modifier == nil then | if modifier == nil then | ||
return nil | return nil | ||
end | end | ||
return baseName, modifier.description, modifier.isNegative, modifier.modifyValue | |||
return baseName, modifier. | |||
end | end | ||
function p._getModifierText(modifier, value, doColor) | function p._getModifierText(modifier, value, doColor) | ||
if doColor == nil then doColor = true end | if doColor == nil then doColor = true end | ||
local modName, modText | local modName, modText, isNegative, modifyValue = p.getModifierDetails(modifier) | ||
if modName == nil then | if modName == nil then | ||
return Shared.printError('Invalid modifier type for "' .. modifier .. '"') | return Shared.printError('Invalid modifier type for "' .. modifier .. '"') | ||
end | end | ||
local formatModValue = function(value, rule) | local formatModValue = function(value, rule) | ||
local ruleFunctions = { | |||
['value'] = function(val) return val end, | |||
['multiplyByNumberMultiplier'] = function(val) return val * 10 end, | |||
['divideByNumberMultiplier'] = function(val) return val / 10 end, | |||
['milliToSeconds'] = function(val) return val / 1000 end, | |||
['(value)=>value*100'] = function(val) return val * 100 end, | |||
['(value)=>100+value'] = function(val) return val + 100 end, | |||
['(value)=>value+1'] = function(val) return val + 1 end, | |||
['(value)=>Math.pow(2,value)'] = function(val) return 2^val end, | |||
['(value)=>game.golbinRaid.startingWeapons[value].name'] = function(val) | |||
-- For golbin raid starting weapons | |||
local startingWeapons = { 'melvorD:Bronze_Scimitar', 'melvorD:Adamant_Scimitar' } | |||
local itemID = startingWeapons[val + 1] | |||
local item = GameData.getEntityByID('items', itemID) | |||
if item ~= nil then | |||
return item.name | |||
else | |||
return 'Unknown' | |||
end | |||
end | end | ||
} | |||
local ruleFunc = ruleFunctions[modifyValue] or ruleFunctions['value'] | |||
if type(value) == 'table' then | |||
-- If table is a pair of values then format both & add a separator | |||
return ruleFunc(value[1]) .. '-' .. ruleFunc(value[2]) | |||
else | |||
return ruleFunc(value) | |||
end | end | ||
end | |||
local valueArray, resultArray = nil, {} | local valueArray, resultArray = nil, {} | ||
Line 996: | Line 981: | ||
local skillName = p.getSkillName(subVal.skillID) | local skillName = p.getSkillName(subVal.skillID) | ||
if skillName ~= nil then | if skillName ~= nil then | ||
resultText = string.gsub(resultText, '{ | resultText = string.gsub(resultText, '${skillName}', skillName) | ||
end | end | ||
else | else | ||
Line 1,003: | Line 988: | ||
end | end | ||
resultText = string.gsub(resultText, '${value}', function(rule) return (formatModValue(modMagnitude, rule) or '') end) | |||
resultText = string.gsub(resultText, '{ | |||
if doColor then | if doColor then |