4,687
edits
mNo edit summary |
(Synced with live) |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local Constants = require('Module:Constants') | |||
local Constants = require('Module: | |||
local Shared = require('Module:Shared') | local Shared = require('Module:Shared') | ||
local GameData = require('Module:GameData') | |||
local Areas = require('Module:CombatAreas') | |||
local Magic = require('Module:Magic') | |||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
local Items = require('Module: | local Items = require('Module:Items') | ||
function p.getMonster(name) | function p.getMonster(name) | ||
if name == 'Earth Golem (AoD)' then | |||
if name == ' | -- Special case for ambiguous monster name | ||
return p.getMonsterByID( | return p.getMonsterByID('melvorAoD:EarthGolem') | ||
else | |||
return GameData.getEntityByName('monsters', name) | |||
end | |||
end | |||
function p.getMonsterByID(ID) | |||
return GameData.getEntityByID('monsters', ID) | |||
end | end | ||
function p. | function p.getMonsterName(monster) | ||
if monster.id == 'melvorAoD:EarthGolem' then | |||
-- Special case for ambiguous monster name | |||
return 'Earth Golem (AoD)' | |||
return | |||
else | else | ||
return | return monster.name | ||
end | end | ||
end | end | ||
function p.getPassive(name) | function p.getPassive(name) | ||
return GameData.getEntityByName('combatPassives', name) | |||
end | end | ||
function p.getPassiveByID(ID) | function p.getPassiveByID(ID) | ||
return GameData.getEntityByID('combatPassives', ID) | |||
end | end | ||
Line 71: | Line 53: | ||
function p._getMonsterStat(monster, statName) | function p._getMonsterStat(monster, statName) | ||
if statName == 'HP' then | if statName == 'Barrier' then | ||
return p._getMonsterBarrier(monster) | |||
elseif statName == 'HP' then | |||
return p._getMonsterHP(monster) | return p._getMonsterHP(monster) | ||
elseif statName == 'maxHit' then | elseif statName == 'maxHit' then | ||
Line 85: | Line 69: | ||
elseif statName == 'damageReduction' then | elseif statName == 'damageReduction' then | ||
return p.getEquipmentStat(monster, 'damageReduction') | return p.getEquipmentStat(monster, 'damageReduction') | ||
elseif statName == 'drReduction' then | |||
return p._getMonsterDrReduction(monster) | |||
end | end | ||
Line 95: | Line 81: | ||
local monster = p.getMonster(MonsterName) | local monster = p.getMonster(MonsterName) | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
Line 115: | Line 101: | ||
iconText = Icons.Icon({'Magic', type='skill', notext=notext, nolink=nolink}) | iconText = Icons.Icon({'Magic', type='skill', notext=notext, nolink=nolink}) | ||
elseif monster.attackType == 'random' then | elseif monster.attackType == 'random' then | ||
iconText = Icons.Icon({ | iconText = Icons.Icon({p.getMonsterName(monster), notext=notext, nolink=nolink, img='Question'}) | ||
end | end | ||
Line 127: | Line 113: | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
Line 136: | Line 122: | ||
function p._getMonsterHP(monster) | function p._getMonsterHP(monster) | ||
return 10 * p._getMonsterLevel(monster, 'Hitpoints') | return 10 * p._getMonsterLevel(monster, 'Hitpoints') | ||
end | |||
function p._getMonsterBarrier(monster) | |||
--Monster Barrier is a percentage of its max health | |||
local barPercent = 0 | |||
if monster.barrierPercent ~= nil then | |||
barPercent = monster.barrierPercent | |||
end | |||
return p._getMonsterHP(monster) * barPercent * 0.01 | |||
end | end | ||
Line 144: | Line 139: | ||
return math.floor((p._getMonsterHP(monster)/(1 - p._getMonsterStat(monster, 'damageReduction')/100)) + 0.5) | return math.floor((p._getMonsterHP(monster)/(1 - p._getMonsterStat(monster, 'damageReduction')/100)) + 0.5) | ||
else | else | ||
return | return Shared.printError('No monster with that name found') | ||
end | |||
end | |||
function p.getMonsterEffectiveBarrier(frame) | |||
local MonsterName = frame.args ~= nil and frame.args[1] or frame | |||
local monster = p.getMonster(MonsterName) | |||
if monster ~= nil then | |||
return math.floor((p._getMonsterBarrier(monster)/(1 - p._getMonsterStat(monster, 'damageReduction')/100)) + 0.5) | |||
else | |||
return Shared.printError('No monster with that name found') | |||
end | |||
end | |||
function p.getMonsterBarrier(frame) | |||
local MonsterName = frame.args ~= nil and frame.args[1] or frame | |||
local monster = p.getMonster(MonsterName) | |||
if monster ~= nil then | |||
return p._getMonsterBarrier(monster) | |||
else | |||
return Shared.printError('No monster with that name found') | |||
end | end | ||
end | end | ||
Line 154: | Line 169: | ||
return p._getMonsterHP(monster) | return p._getMonsterHP(monster) | ||
else | else | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
end | end | ||
Line 172: | Line 187: | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
Line 179: | Line 194: | ||
function p.getEquipmentStat(monster, statName) | function p.getEquipmentStat(monster, statName) | ||
if monster.equipmentStats == nil then | |||
return 0 | |||
else | |||
return monster.equipmentStats[statName] or 0 | |||
end | |||
end | end | ||
Line 210: | Line 222: | ||
return p._getMonsterAttackSpeed(monster) | return p._getMonsterAttackSpeed(monster) | ||
else | else | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
end | end | ||
Line 227: | Line 239: | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
Line 250: | Line 262: | ||
bonus = p.getEquipmentStat(monster, 'stabAttackBonus') | bonus = p.getEquipmentStat(monster, 'stabAttackBonus') | ||
else | else | ||
return | return Shared.printError('This monster has an invalid attack type somehow') | ||
end | end | ||
Line 261: | Line 273: | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
Line 281: | Line 293: | ||
bonus = p.getEquipmentStat(monster, 'magicDefenceBonus') | bonus = p.getEquipmentStat(monster, 'magicDefenceBonus') | ||
else | else | ||
return | return Shared.printError('Must choose Melee, Ranged, or Magic') | ||
end | end | ||
Line 294: | Line 306: | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
Line 303: | Line 315: | ||
-- item if so, or nil otherwise | -- item if so, or nil otherwise | ||
function p._getMonsterBones(monster) | function p._getMonsterBones(monster) | ||
if monster.bones ~= nil | if monster.bones ~= nil then | ||
local boneItem = Items.getItemByID(monster.bones) | local boneItem = Items.getItemByID(monster.bones.itemID) | ||
local boneObj = { ["item"] = boneItem, ["quantity"] = monster.bones.quantity } | |||
if boneItem.prayerPoints == nil then | if boneItem.prayerPoints == nil then | ||
-- Assume bones without prayer points are shards (from God dungeons), | -- Assume bones without prayer points are shards (from God dungeons), | ||
-- and drop unconditionally | -- and drop unconditionally | ||
return | return boneObj | ||
elseif not monster.isBoss and not p._isDungeonOnlyMonster(monster) then | elseif not monster.isBoss and not p._isDungeonOnlyMonster(monster) then | ||
-- Otherwise, bones drop when the monster isn't dungeon exclusive | -- Otherwise, bones drop when the monster isn't dungeon exclusive | ||
return | return boneObj | ||
end | end | ||
end | end | ||
Line 331: | Line 344: | ||
function p.isDungeonOnlyMonster(frame) | function p.isDungeonOnlyMonster(frame) | ||
local | local monsterName = frame.args ~= nil and frame.args[1] or frame | ||
local monster = p.getMonster( | local monster = p.getMonster(monsterName) | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with name ' .. monsterName .. ' found') | ||
end | end | ||
Line 341: | Line 354: | ||
end | end | ||
function p._getMonsterAreas(monster, excludeDungeons) | function p._getMonsterAreas(monster, excludeDungeons, includeEffects) | ||
if includeEffects == nil then includeEffects = false end | |||
local resultPart = {} | local resultPart = {} | ||
local hideDungeons = excludeDungeons ~= nil and excludeDungeons or false | local hideDungeons = excludeDungeons ~= nil and excludeDungeons or false | ||
Line 347: | Line 361: | ||
for i, area in ipairs(areaList) do | for i, area in ipairs(areaList) do | ||
if area.type ~= 'dungeon' or not hideDungeons then | if area.type ~= 'dungeon' or not hideDungeons then | ||
local imgType = (area.type == 'slayerArea' and 'combatArea') or area.type | |||
local txt = Icons.Icon({area.name, type = imgType}) | |||
if area.type == 'slayerArea' then | |||
local areaDescrip = Areas._getAreaStat(area, 'areaEffectDesc') | |||
if areaDescrip ~= 'None' then | |||
txt = txt.." - ''"..areaDescrip.."''" | |||
end | |||
end | |||
table.insert(resultPart, txt) | |||
end | end | ||
end | end | ||
Line 354: | Line 376: | ||
function p.getMonsterAreas(frame) | function p.getMonsterAreas(frame) | ||
local | local monsterName = frame.args ~= nil and frame.args[1] or frame | ||
local hideDungeons = frame.args ~= nil and frame.args[2] or nil | local hideDungeons = frame.args ~= nil and frame.args[2] or nil | ||
local monster = p.getMonster( | local includeEffects = frame.args ~= nil and frame.args[3] or true | ||
local monster = p.getMonster(monsterName) | |||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with name ' .. monsterName .. ' found') | ||
end | end | ||
return p._getMonsterAreas(monster, hideDungeons) | return p._getMonsterAreas(monster, hideDungeons, includeEffects) | ||
end | end | ||
function p.getSpecAttackMaxHit(specAttack, normalMaxHit) | function p.getSpecAttackMaxHit(specAttack, normalMaxHit, monster) | ||
local | local bestHit = 0 | ||
for i, dmg in pairs(specAttack.damage) do | for i, dmg in pairs(specAttack.damage) do | ||
if dmg.maxRoll == 'Fixed' then | local thisHit = 0 | ||
if dmg.damageType == 'Normal' then | |||
--Account for special attacks that include a normal attack hit | |||
thisHit = normalMaxHit | |||
if dmg.amplitude ~= nil then | |||
thisHit = thisHit * (dmg.amplitude / 100) | |||
end | |||
elseif dmg.maxRoll == 'Fixed' then | |||
thisHit = dmg.maxPercent * 10 | |||
elseif dmg.maxRoll == 'MaxHit' then | elseif dmg.maxRoll == 'MaxHit' then | ||
if dmg.character == 'Target' then | if dmg.character == 'Target' then | ||
--Confusion applied damage based on the player's max hit. Gonna just ignore that one | --Confusion applied damage based on the player's max hit. Gonna just ignore that one | ||
thisHit = 0 | |||
else | else | ||
thisHit = dmg.maxPercent * normalMaxHit * 0.01 | |||
end | |||
elseif Shared.contains(dmg.maxRoll, "Fixed100") then | |||
--Handles attacks that are doubled when conditions are met like Trogark's double damage if the player is burning | |||
thisHit = dmg.maxPercent * 20 | |||
elseif dmg.maxRoll == 'MaxHitScaledByHP2x' then | |||
thisHit = normalMaxHit * 2 | |||
elseif dmg.maxRoll == 'PoisonMax35' then | |||
thisHit = normalMaxHit * 1.35 | |||
elseif dmg.maxRoll == "MaxHitDR" then | |||
local monsterDR = 0 | |||
if monster ~= nil then | |||
monsterDR = p._getMonsterStat(monster, 'damageReduction') | |||
end | end | ||
thisHit = normalMaxHit * dmg.maxPercent * 0.01 * (1 + monsterDR * 0.01) | |||
elseif Shared.contains({'Bleeding', 'Poisoned'}, dmg.maxRoll) then | elseif Shared.contains({'Bleeding', 'Poisoned'}, dmg.maxRoll) then | ||
-- TODO: This is limited in that there is no verification that bleed/poison | -- TODO: This is limited in that there is no verification that bleed/poison | ||
-- can be applied to the target, it is assumed that it can and so this applies | -- can be applied to the target, it is assumed that it can and so this applies | ||
thisHit = thisHit + dmg.maxPercent * 10 | |||
end | |||
if thisHit > bestHit then | |||
bestHit = thisHit | |||
end | end | ||
end | end | ||
return | return bestHit | ||
end | end | ||
function p.canSpecAttackApplyEffect(specAttack, effectType) | function p.canSpecAttackApplyEffect(specAttack, effectType) | ||
local | local effectKeys = { 'prehitEffects', 'onhitEffects' } | ||
for i, effect in pairs(specAttack | for i, effectKey in ipairs(effectKeys) do | ||
if type(specAttack[effectKey]) == 'table' then | |||
for j, effect in pairs(specAttack[effectKey]) do | |||
if effect.type == effectType or p.canModifiersApplyEffect(effect.modifiers, effectType) then | |||
return true | |||
end | |||
end | |||
end | end | ||
end | end | ||
return false | |||
end | |||
function p.canModifiersApplyEffect(modifiers, effectType) | |||
-- List of modifiers which can result in the application of status effects | |||
local statusModsAll = { | |||
["Stun"] = { 'increasedGlobalStunChance', 'increasedMeleeStunChance' }, | |||
["Sleep"] = { 'increasedGlobalSleepChance' }, | |||
["Poison"] = { 'increasedChanceToApplyPoison' }, | |||
["Slow"] = { 'increased15SlowStunChance2Turns', 'increased30Slow5TurnsChance' } | |||
} | |||
for | local statusMods = statusModsAll[effectType] | ||
if statusMods ~= nil and type(modifiers) == 'table' then | |||
for modName, modMagnitude in pairs(modifiers) do | |||
if Shared.contains(statusMods, modName) then | |||
return true | |||
end | |||
end | end | ||
end | end | ||
return | return false | ||
end | end | ||
Line 411: | Line 474: | ||
elseif type(doStuns) == 'string' then | elseif type(doStuns) == 'string' then | ||
doStuns = string.upper(doStuns) == 'TRUE' | doStuns = string.upper(doStuns) == 'TRUE' | ||
end | |||
-- Damage adjustments are defined as follows: | |||
-- multiplier - Damage from modifier 'increasedDamageTaken' & additional damage while | |||
-- stunned, asleep, or poisoned. Defined by in-game function | |||
-- getDamageModifiers(). Applies after other percentage of flat adjustments. | |||
-- percent - Percentage adjustments to the max hit. Applies before flat & multiplier | |||
-- adjustments. | |||
-- flat - Flat adjustments to the max hit. Applies after percent adjustments, and | |||
-- after multiplier adjustments. | |||
local dmgAdjust = { ["percent"] = 100, ["flat"] = 0, ["multiplier"] = 100 } | |||
-- Check passives & effects that apply pre or on hit for damage modifiers | |||
local dmgMods = { | |||
-- List of modifiers which affect damage dealt, and whether they are percentage or flat adjustments | |||
["increasedDamageTaken"] = { type = 'multiplier', mult = 1 }, | |||
["increasedMaxHitPercent"] = { type = 'percent', mult = 1 }, | |||
["increasedMeleeMaxHit"] = { type = 'percent', mult = 1 }, | |||
["increasedRangedMaxHit"] = { type = 'percent', mult = 1 }, | |||
["increasedMagicMaxHit"] = { type = 'percent', mult = 1 }, | |||
["increasedMaxHitFlat"] = { type = 'flat', mult = 10 }, | |||
["increasedMeleeMaxHitFlat"] = { type = 'flat', mult = 10 }, | |||
["increasedRangedMaxHitFlat"] = { type = 'flat', mult = 10 }, | |||
["increasedMagicMaxHitFlat"] = { type = 'flat', mult = 10 }, | |||
-- Rage: +2% max hit per stack, maximum of 10 stacks | |||
["increasedRage"] = { type = 'percent', mult = 1, magnitude = 2, maxStacks = 10 }, | |||
-- Dark Blade: +1% max hit per successful hit, maximum of 30 stacks | |||
["increasedChanceDarkBlade"] = { type = 'percent', mult = 1, magnitude = 1, maxStacks = 30 }, | |||
-- Growing Madness/Moment in Time/Reign Over Time: +2% max hit per stack, maximum of 25 stacks | |||
["growingMadnessPassive"] = { type = 'percent', mult = 1, magnitude = 2, maxStacks = 25 }, | |||
["momentInTimePassive"] = { type = 'percent', mult = 1, magnitude = 2, maxStacks = 25 }, | |||
["reignOverTimePassive"] = { type = 'percent', mult = 1, magnitude = 2, maxStacks = 25 } | |||
} | |||
local effectKeys = { 'prehitEffects', 'onhitEffects' } | |||
local dmgStatuses = { | |||
-- List of status effects which can affect damage dealt | |||
["Stun"] = { type = 'multiplier', magnitude = 30 }, | |||
["Sleep"] = { type = 'multiplier', magnitude = 20 } | |||
} | |||
local canApplyStatus = {} | |||
-- Initialize table | |||
for statusName, def in pairs(dmgStatuses) do | |||
canApplyStatus[statusName] = false | |||
end | |||
local adjustForMod = function(mod, modMagnitude, effect) | |||
local magnitude = mod.magnitude or modMagnitude | |||
local maxStacks = mod.maxStacks or (effect ~= nil and effect.maxStacks) or 1 | |||
dmgAdjust[mod.type] = dmgAdjust[mod.type] + magnitude * mod.mult * maxStacks | |||
end | |||
local adjustForCurse = function(curseID, effect) | |||
local curse = Magic.getSpellByID(curseID, 'curse') | |||
if type(curse) == 'table' and type(curse.targetModifiers) == 'table' then | |||
for modName, modMagnitude in pairs(curse.targetModifiers) do | |||
local mod = dmgMods[modName] | |||
if mod ~= nil then | |||
-- The modifier is one which affects damage dealt | |||
adjustForMod(mod, modMagnitude, effect) | |||
end | |||
end | |||
end | |||
end | |||
-- Check monster passives for modifiers which affect damage dealt, and alo if any modifiers | |||
-- present can apply stun or sleep | |||
if monster ~= nil and type(monster.passives) ~= nil then | |||
for i, passiveID in ipairs(monster.passives) do | |||
local passive = p.getPassiveByID(passiveID) | |||
if passive ~= nil and type(passive.modifiers) == 'table' then | |||
for modName, modMagnitude in pairs(passive.modifiers) do | |||
local mod = dmgMods[modName] | |||
if modName == 'applyRandomCurseOnSpawn' then | |||
-- Special case in which the enemy can apply a random curse. Currently | |||
-- Anguish III is the curse with the highest +% damage taken, so use this. | |||
adjustForCurse('melvorF:AnguishIII') | |||
elseif mod ~= nil then | |||
-- The modifier is one which affects damage dealt | |||
adjustForMod(mod, modMagnitude) | |||
end | |||
end | |||
-- Check for application of relevant status effects | |||
if doStuns then | |||
for statusName, statusDef in pairs(dmgStatuses) do | |||
if not canApplyStatus[statusName] and p.canModifiersApplyEffect(passive.modifiers, statusName) then | |||
canApplyStatus[statusName] = true | |||
end | |||
end | |||
end | |||
end | |||
end | |||
end | end | ||
Line 417: | Line 570: | ||
local normalMaxHit = p._getMonsterBaseMaxHit(monster) | local normalMaxHit = p._getMonsterBaseMaxHit(monster) | ||
local hasActiveBuffSpec = false | local hasActiveBuffSpec = false | ||
if monster.specialAttacks ~= nil then | |||
if monster.specialAttacks | for i, specAttackID in pairs(monster.specialAttacks) do | ||
local | local specAttack = GameData.getEntityByID('attacks', specAttackID) | ||
for i, effectKey in ipairs(effectKeys) do | |||
if type(specAttack[effectKey]) == 'table' then | |||
for j, effect in ipairs(specAttack[effectKey]) do | |||
local countsOnPlayer = (effect.countsOn == nil or effect.countsOn == 'Attacker') | |||
if countsOnPlayer then | |||
-- Check for pre or on hit effects for modifiers which affect damage dealt | |||
if type(effect.modifiers) == 'table' then | |||
for modName, modMagnitude in pairs(effect.modifiers) do | |||
local mod = dmgMods[modName] | |||
if mod ~= nil then | |||
-- The modifier is one which affects damage dealt | |||
adjustForMod(mod, modMagnitude, effect) | |||
end | |||
end | |||
end | |||
-- Check for curses which may cause the player to incur additional damage | |||
if effect.effectType == 'Curse' then | |||
-- If isRandom is true then a random curse is selected. Currently | |||
-- Anguish III is the curse with the highest +% damage taken, so | |||
-- use this. | |||
local curseID = (effect.isRandom and 'melvorF:AnguishIII') or effect.curse | |||
if curseID ~= nil then | |||
adjustForCurse(curseID, effect) | |||
end | |||
end | |||
end | |||
end | |||
end | |||
end | |||
if monster.overrideSpecialChances ~= nil then | if monster.overrideSpecialChances ~= nil then | ||
normalChance = normalChance - monster.overrideSpecialChances[i] | normalChance = normalChance - monster.overrideSpecialChances[i] | ||
Line 426: | Line 608: | ||
normalChance = normalChance - specAttack.defaultChance | normalChance = normalChance - specAttack.defaultChance | ||
end | end | ||
-- Check for application of relevant status effects | |||
if doStuns then | |||
for statusName, statusDef in pairs(dmgStatuses) do | |||
if not canApplyStatus[statusName] and p.canSpecAttackApplyEffect(specAttack, statusName) then | |||
canApplyStatus[statusName] = true | |||
end | |||
end | |||
end | |||
local thisMax = p.getSpecAttackMaxHit(specAttack, normalMaxHit, monster) | |||
if thisMax > specialMaxHit then specialMaxHit = thisMax end | if thisMax > specialMaxHit then specialMaxHit = thisMax end | ||
if Shared.contains(string.upper(specAttack.description), 'NORMAL ATTACK INSTEAD') then | if Shared.contains(string.upper(specAttack.description), 'NORMAL ATTACK INSTEAD') then | ||
Line 436: | Line 625: | ||
end | end | ||
if | if doStuns then | ||
for statusName, statusDef in pairs(dmgStatuses) do | |||
if canApplyStatus[statusName] then | |||
local adjType = statusDef.type | |||
dmgAdjust[adjType] = dmgAdjust[adjType] + statusDef.magnitude | |||
end | |||
end | |||
end | |||
end | end | ||
--Ensure that if the monster never does a normal attack, the normal max hit is irrelevant | --Ensure that if the monster never does a normal attack, the normal max hit is irrelevant | ||
if normalChance == 0 and not hasActiveBuffSpec then normalMaxHit = 0 end | if normalChance == 0 and not hasActiveBuffSpec then normalMaxHit = 0 end | ||
local maxHit = math.floor(math.max(specialMaxHit, normalMaxHit) * dmgAdjust.percent / 100) + dmgAdjust.flat | |||
return math.floor(maxHit * dmgAdjust.multiplier / 100) | |||
end | end | ||
Line 450: | Line 646: | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
Line 470: | Line 666: | ||
result = p.calculateStandardMaxHit(baseLevel, bonus) | result = p.calculateStandardMaxHit(baseLevel, bonus) | ||
elseif monster.attackType == 'magic' then | elseif monster.attackType == 'magic' then | ||
if monster.selectedSpell == nil then | |||
result = 0 | |||
else | |||
local mSpell = Magic.getSpellByID(monster.selectedSpell, 'standard') | |||
if mSpell == nil then | |||
result = 0 | |||
else | |||
baseLevel = p._getMonsterLevel(monster, 'Magic') | |||
bonus = p.getEquipmentStat(monster, 'magicDamageBonus') | |||
result = math.floor(10 * mSpell.maxHit * (1 + bonus / 100) * (1 + (baseLevel + 1) / 200)) | |||
end | |||
end | |||
elseif monster.attackType == 'random' then | elseif monster.attackType == 'random' then | ||
local hitArray = {} | local hitArray = {} | ||
Line 490: | Line 691: | ||
iconText = Icons.Icon({'Magic', type='skill', notext=true}) | iconText = Icons.Icon({'Magic', type='skill', notext=true}) | ||
local magicDmg = 0 | |||
if monster.selectedSpell ~= nil then | |||
local mSpell = Magic.getSpellByID(monster.selectedSpell, 'standard') | |||
if mSpell ~= nil then | |||
baseLevel = p._getMonsterLevel(monster, 'Magic') | |||
bonus = p.getEquipmentStat(monster, 'magicDamageBonus') | |||
magicDmg = math.floor(10 * mSpell.maxHit * (1 + bonus / 100) * (1 + (baseLevel + 1) / 200)) | |||
end | |||
end | |||
table.insert(hitArray, magicDmg) | table.insert(hitArray, magicDmg) | ||
Line 503: | Line 708: | ||
result = max | result = max | ||
else | else | ||
return | return Shared.printError('This monster has an invalid attack type somehow') | ||
end | end | ||
Line 514: | Line 719: | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
Line 525: | Line 730: | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
Line 543: | Line 748: | ||
local buffAttacks = {} | local buffAttacks = {} | ||
local hasActiveBuffSpec = false | local hasActiveBuffSpec = false | ||
local isNormalAttackRelevant = false | |||
local normalAttackChance = 100 | local normalAttackChance = 100 | ||
if monster.specialAttacks | if monster.specialAttacks ~= nil then | ||
for i, | for i, specAttackID in pairs(monster.specialAttacks) do | ||
local specAttack = GameData.getEntityByID('attacks', specAttackID) | |||
local attChance = 0 | local attChance = 0 | ||
if monster.overrideSpecialChances ~= nil then | if monster.overrideSpecialChances ~= nil then | ||
Line 556: | Line 763: | ||
result = result..'\r\n* '..attChance..'% '..iconText..' '..specAttack.name..'\r\n** '..specAttack.description | result = result..'\r\n* '..attChance..'% '..iconText..' '..specAttack.name..'\r\n** '..specAttack.description | ||
--If this special attack applies a curse, let's actually list what that curse does | |||
if specAttack.onhitEffects ~= nil then | |||
for j, hitEffect in ipairs(specAttack.onhitEffects) do | |||
if hitEffect.effectType == 'Curse' then | |||
local curse = Magic.getSpellByID(hitEffect.curse, 'curse') | |||
result = result..'\r\n*** '..Icons.Icon({curse.name, type='curse'})..': '..Magic._getSpellDescription(curse, true) | |||
end | |||
end | |||
end | |||
if Shared.contains(string.upper(specAttack.description), 'NORMAL ATTACK INSTEAD') then | if Shared.contains(string.upper(specAttack.description), 'NORMAL ATTACK INSTEAD') then | ||
table.insert(buffAttacks, specAttack.name) | table.insert(buffAttacks, specAttack.name) | ||
hasActiveBuffSpec = true | hasActiveBuffSpec = true | ||
isNormalAttackRelevant = true | |||
end | |||
if not isNormalAttackRelevant and type(specAttack.damage) == 'table' then | |||
-- Determine if the special attack uses normal damage in some form | |||
for j, dmgData in ipairs(specAttack.damage) do | |||
if dmgData.damageType == 'Normal' then | |||
isNormalAttackRelevant = true | |||
break | |||
end | |||
end | |||
end | end | ||
end | end | ||
end | end | ||
if normalAttackChance | |||
if isNormalAttackRelevant or normalAttackChance > 0 then | |||
--Reformatting slightly - If there are any special attacks, specifically label the Normal Attack | |||
local normalDmgText = ' 1 - '..Shared.formatnum(p._getMonsterBaseMaxHit(monster))..' '..typeText..' Damage' | |||
if normalAttackChance > 0 and normalAttackChance < 100 then | |||
normalDmgText = normalAttackChance .. '% ' ..iconText..' Normal Attack\r\n** '..normalDmgText | |||
elseif hasActiveBuffSpec and normalAttackChance == 0 then | |||
--If the monster normally has a 0% chance of doing a normal attack but some special attacks can't be repeated, include it | |||
--(With a note about when it does it) | |||
normalDmgText = iconText..' Normal Attack\r\n** '..normalDmgText .. ' (Instead of repeating '..table.concat(buffAttacks, ' or ')..' while the effect is already active)' | |||
end | |||
result = '* ' .. normalDmgText .. result | |||
end | end | ||
return result | return result | ||
end | |||
--Function for pulling how much the monster reduces the player DR | |||
--Goes through the passvies to look for the decreasedPlayerDamageReduction modifier | |||
function p._getMonsterDrReduction(monster) | |||
local totalResult = 0 | |||
if type(monster.passives) == 'table' and not Shared.tableIsEmpty(monster.passives) then | |||
for i, passiveID in ipairs(monster.passives) do | |||
local passive = p.getPassiveByID(passiveID) | |||
if passive.modifiers ~= nil then | |||
if passive.modifiers['decreasedPlayerDamageReduction'] ~= nil then | |||
totalResult = totalResult + passive.modifiers['decreasedPlayerDamageReduction'] | |||
end | |||
end | |||
end | |||
end | |||
return totalResult | |||
end | |||
function p.getMonsterDrReduction(frame) | |||
local MonsterName = frame.args ~= nil and frame.args[1] or frame | |||
local monster = p.getMonster(MonsterName) | |||
if monster == nil then | |||
return Shared.printError('No monster with that name found') | |||
end | |||
return p._getMonsterDrReduction(monster) | |||
end | end | ||
Line 581: | Line 843: | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
local result = '' | local result = '' | ||
if type(monster.passives) == 'table' and not Shared.tableIsEmpty(monster.passives) then | |||
result = result .. '===Passives===' | result = result .. '===Passives===' | ||
for i, passiveID in | for i, passiveID in ipairs(monster.passives) do | ||
local passive = p.getPassiveByID(passiveID) | local passive = p.getPassiveByID(passiveID) | ||
result = result .. '\r\n* ' .. passive.name .. '\r\n** ' .. passive. | result = result .. '\r\n* ' .. passive.name .. '\r\n** ' .. Constants.getDescription(passive.customDescription, passive.modifiers) | ||
end | end | ||
end | end | ||
Line 600: | Line 862: | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
Line 613: | Line 875: | ||
end | end | ||
if monster. | if type(monster.passives) == 'table' and not Shared.tableIsEmpty(monster.passives) then | ||
result = result..'[[Category:Monsters with Special Attacks]]' | result = result..'[[Category:Monsters with Special Attacks]]' | ||
end | end | ||
Line 622: | Line 884: | ||
return result | return result | ||
end | |||
function p.getMonsterBoxBarrierText(frame) | |||
local MonsterName = frame.args ~= nil and frame.args[1] or frame | |||
local monster = p.getMonster(MonsterName) | |||
if monster == nil then | |||
return Shared.printError('No monster with that name found') | |||
end | |||
local barrier = p._getMonsterBarrier(monster) | |||
if barrier == 0 then | |||
return '' | |||
end | |||
local result = {} | |||
table.insert(result, '|-\r\n| style="font-weight: bold;" | [[Barrier]]:') | |||
table.insert(result, '\r\n| colspan=15 style="text-align: right" |') | |||
table.insert(result, Icons.Icon({"Barrier", notext="true"})) | |||
table.insert(result, ' '..barrier) | |||
return table.concat(result, '') | |||
end | end | ||
Line 629: | Line 912: | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
Line 639: | Line 922: | ||
local areaList = Areas.getMonsterAreas(monster.id) | local areaList = Areas.getMonsterAreas(monster.id) | ||
local counts = { | local counts = {combatArea = 0, slayerArea = 0, dungeon = 0} | ||
for i, area in | for i, area in ipairs(areaList) do | ||
counts[area.type] = counts[area.type] + 1 | counts[area.type] = counts[area.type] + 1 | ||
end | end | ||
if counts. | if counts.combatArea > 0 then table.insert(monsterTypes, 'Combat Area') end | ||
if counts. | if counts.slayerArea > 0 then table.insert(monsterTypes, 'Slayer Area') end | ||
if counts.dungeon > 0 then table.insert(monsterTypes, 'Dungeon') end | if counts.dungeon > 0 then table.insert(monsterTypes, 'Dungeon') end | ||
Line 670: | Line 953: | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
Line 679: | Line 962: | ||
--Show the bones only if either the monster shows up outside of dungeons _or_ the monster drops shards | --Show the bones only if either the monster shows up outside of dungeons _or_ the monster drops shards | ||
if bones ~= nil then | if bones ~= nil then | ||
local boneQty = ( | local boneQty = (bones.quantity ~= nil and bones.quantity or 1) | ||
result = result.."'''Always Drops:'''" | result = result.."'''Always Drops:'''" | ||
result = result..'\r\n{|class="wikitable" id="bonedrops"' | result = result..'\r\n{|class="wikitable" id="bonedrops"' | ||
result = result..'\r\n!Item !! Qty' | result = result..'\r\n!Item !! Qty' | ||
result = result..'\r\n|-\r\n|'..Icons.Icon({bones.name, type='item'}) | result = result..'\r\n|-\r\n|'..Icons.Icon({bones.item.name, type='item'}) | ||
result = result..'||'..boneQty..'\r\n'..'|}' | result = result..'||'..boneQty..'\r\n'..'|}' | ||
boneVal = boneQty * bones.sellsFor | boneVal = boneQty * bones.item.sellsFor | ||
end | end | ||
Line 696: | Line 979: | ||
local avgGp = 0 | local avgGp = 0 | ||
if monster. | if monster.gpDrops ~= nil then | ||
avgGp = (monster. | avgGp = (monster.gpDrops.min + monster.gpDrops.max) / 2 | ||
local gpTxt = Icons.GP(monster. | local gpTxt = Icons.GP(monster.gpDrops.min, monster.gpDrops.max) | ||
result = result.."\r\nIn addition to loot, the monster will also drop "..gpTxt..'.' | result = result.."\r\nIn addition to loot, the monster will also drop "..gpTxt..'.' | ||
end | end | ||
Line 704: | Line 987: | ||
local multiDrop = Shared.tableCount(monster.lootTable) > 1 | local multiDrop = Shared.tableCount(monster.lootTable) > 1 | ||
local totalWt = 0 | local totalWt = 0 | ||
for i, row in | for i, row in ipairs(monster.lootTable) do | ||
totalWt = totalWt + row | totalWt = totalWt + row.weight | ||
end | end | ||
result = result..'\r\n{|class="wikitable sortable" id="itemdrops"' | result = result..'\r\n{|class="wikitable sortable" id="itemdrops"' | ||
Line 712: | Line 995: | ||
--Sort the loot table by weight in descending order | --Sort the loot table by weight in descending order | ||
table.sort( | local lootTable = Shared.shallowClone(monster.lootTable) | ||
for i, row in ipairs( | table.sort(lootTable, function(a, b) | ||
local thisItem = Items.getItemByID(row | if a.weight == b.weight then | ||
local aItem, bItem = Items.getItemByID(a.itemID), Items.getItemByID(b.itemID) | |||
if aItem ~= nil and bItem ~= nil then | |||
return aItem.name < bItem.name | |||
else | |||
return a.itemID < b.itemID | |||
end | |||
else | |||
return a.weight > b.weight | |||
end | |||
end) | |||
for i, row in ipairs(lootTable) do | |||
local thisItem = Items.getItemByID(row.itemID) | |||
if thisItem ~= nil then | if thisItem ~= nil then | ||
result = result..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'}) | result = result..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'}) | ||
Line 722: | Line 1,016: | ||
result = result..'\r\n|-\r\n|Unknown Item[[Category:Pages with script errors]]' | result = result..'\r\n|-\r\n|Unknown Item[[Category:Pages with script errors]]' | ||
end | end | ||
result = result..'||style="text-align:right" data-sort-value="'.. | result = result..'||style="text-align:right" data-sort-value="'..row.maxQuantity..'"|' | ||
if | if row.maxQuantity > row.minQuantity then | ||
result = result.. ' | result = result .. Shared.formatnum(row.minQuantity) .. ' - ' | ||
end | end | ||
result = result..Shared.formatnum(row | result = result .. Shared.formatnum(row.maxQuantity) | ||
--Adding price columns | --Adding price columns | ||
Line 735: | Line 1,029: | ||
else | else | ||
itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0 | itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0 | ||
if itemPrice == 0 or | if itemPrice == 0 or row.maxQuantity == row.minQuantity then | ||
result = result..'||'..Icons.GP(itemPrice) | result = result..'||'..Icons.GP(itemPrice * row.minQuantity) | ||
else | else | ||
result = result..'||'..Icons.GP(itemPrice, itemPrice * | result = result..'||'..Icons.GP(itemPrice * row.minQuantity, itemPrice * row.maxQuantity) | ||
end | end | ||
end | end | ||
--Getting the drop chance | --Getting the drop chance | ||
local dropChance = (row | local dropChance = (row.weight / totalWt * lootChance) | ||
if dropChance < 100 then | if dropChance < 100 then | ||
--Show fraction as long as it isn't going to be 1/1 | --Show fraction as long as it isn't going to be 1/1 | ||
result = result..'||style="text-align:right" data-sort-value="'..row | result = result..'||style="text-align:right" data-sort-value="'..row.weight..'"' | ||
result = result..'|'..Shared.fraction(row | result = result..'|'..Shared.fraction(row.weight * lootChance, totalWt * 100) | ||
result = result..'||' | result = result..'||' | ||
else | else | ||
result = result..'||colspan="2" data-sort-value="'..row | result = result..'||colspan="2" data-sort-value="'..row.weight..'"' | ||
end | end | ||
-- If chance is less than 0.10% then show 2 significant figures, otherwise 2 decimal places | -- If chance is less than 0.10% then show 2 significant figures, otherwise 2 decimal places | ||
Line 757: | Line 1,051: | ||
--Adding to the average loot value based on price & dropchance | --Adding to the average loot value based on price & dropchance | ||
lootValue = lootValue + (dropChance * 0.01 * itemPrice * (( | lootValue = lootValue + (dropChance * 0.01 * itemPrice * ((row.minQuantity + row.maxQuantity) / 2)) | ||
end | end | ||
if multiDrop then | if multiDrop then | ||
Line 786: | Line 1,080: | ||
function p._getMonsterLootValue(monster) | function p._getMonsterLootValue(monster) | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
Line 795: | Line 1,089: | ||
--Show the bones only if either the monster shows up outside of dungeons _or_ the monster drops shards | --Show the bones only if either the monster shows up outside of dungeons _or_ the monster drops shards | ||
if bones ~= nil then | if bones ~= nil then | ||
local boneQty = | local boneQty = (bones.quantity ~= nil and bones.quantity) or 1 | ||
boneVal = bones.sellsFor * boneQty | boneVal = bones.item.sellsFor * boneQty | ||
result = result + boneVal | result = result + boneVal | ||
end | end | ||
Line 807: | Line 1,101: | ||
local avgGp = 0 | local avgGp = 0 | ||
if monster. | if monster.gpDrops ~= nil then | ||
avgGp = (monster. | avgGp = (monster.gpDrops.min + monster.gpDrops.max) / 2 | ||
end | end | ||
Line 814: | Line 1,108: | ||
local totalWt = 0 | local totalWt = 0 | ||
for i, row in pairs(monster.lootTable) do | for i, row in pairs(monster.lootTable) do | ||
totalWt = totalWt + row | totalWt = totalWt + row.weight | ||
end | end | ||
for i, row in ipairs(monster.lootTable) do | for i, row in ipairs(monster.lootTable) do | ||
local thisItem = Items.getItemByID(row | local thisItem = Items.getItemByID(row.itemID) | ||
--Adding price columns | --Adding price columns | ||
Line 829: | Line 1,121: | ||
--Getting the drop chance | --Getting the drop chance | ||
local dropChance = (row | local dropChance = (row.weight / totalWt * lootChance) | ||
--Adding to the average loot value based on price & dropchance | --Adding to the average loot value based on price & dropchance | ||
lootValue = lootValue + (dropChance * 0.01 * itemPrice * (( | lootValue = lootValue + (dropChance * 0.01 * itemPrice * ((row.minQuantity + row.maxQuantity) / 2)) | ||
end | end | ||
if avgGp > 0 then | if avgGp > 0 then | ||
Line 851: | Line 1,143: | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
if item == nil then | if item == nil then | ||
return | return Shared.printError('No item with that name found') | ||
end | end | ||
Line 868: | Line 1,160: | ||
local dropWt = 0 | local dropWt = 0 | ||
for i, row in ipairs(monster.lootTable) do | for i, row in ipairs(monster.lootTable) do | ||
totalWt = totalWt + row | totalWt = totalWt + row.weight | ||
if item.id == row | if item.id == row.itemID then | ||
dropWt = row | dropWt = row.weight | ||
end | end | ||
end | end | ||
Line 879: | Line 1,171: | ||
function p.getChestDrops(frame) | function p.getChestDrops(frame) | ||
local | local chestName = frame.args ~= nil and frame.args[1] or frame | ||
local chest = Items.getItem( | local chest = Items.getItem(chestName) | ||
if chest == nil then | if chest == nil then | ||
return | return Shared.printError('No item named ' .. chestName .. ' found') | ||
end | end | ||
local result = '' | local result = '' | ||
if chest.dropTable == nil then | if chest.dropTable == nil then | ||
return | return Shared.printError(chestName .. ' does not have a drop table') | ||
else | else | ||
local | local function formatNumRange(minValue, maxValue) | ||
if maxValue ~= nil and maxValue > minValue then | |||
return Shared.formatnum(minValue) .. ' - ' .. Shared.formatnum(maxValue) | |||
else | |||
return Shared.formatnum(minValue) | |||
end | |||
end | |||
local lootValue, foodValue = 0, 0 | |||
local totalWt = 0 | local totalWt = 0 | ||
for i, row in | local isAllFood = true | ||
totalWt = totalWt + row | for i, row in ipairs(chest.dropTable) do | ||
totalWt = totalWt + row.weight | |||
if isAllFood then | |||
-- If the container's contents are entirely food then we add additional | |||
-- information to the output, so we determine this here | |||
local item = Items.getItemByID(row.itemID) | |||
if item ~= nil and item.healsFor == nil then | |||
isAllFood = false | |||
end | |||
end | |||
end | end | ||
result = result..'\r\n{|class="wikitable sortable"' | result = result..'\r\n{|class="wikitable sortable"' | ||
result = result..'\r\n!Item!!Qty' | result = result..'\r\n!Item!!Qty' | ||
result = result..'!!colspan="2"|Chance!!Price' | result = result..'!!colspan="2"|Chance!!Price' .. (isAllFood and '!!Healing' or '') | ||
--Sort the loot table by weight in descending order | --Sort the loot table by weight in descending order | ||
local chestDrops | local chestDrops = Shared.shallowClone(chest.dropTable) | ||
table.sort(chestDrops, function(a, b) return a.weight > b.weight end) | |||
table.sort(chestDrops, function(a, b) return a | |||
for i, row in ipairs(chestDrops) do | for i, row in ipairs(chestDrops) do | ||
local thisItem = Items.getItemByID(row | local thisItem = Items.getItemByID(row.itemID) | ||
result = result..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'}) | result = result..'\r\n|-\r\n|'..Icons.Icon({thisItem.name, type='item'}) | ||
result = result..'||style="text-align:right" data-sort-value="'.. | result = result..'||style="text-align:right" data-sort-value="'..(row.minQuantity + row.maxQuantity)..'"| ' .. formatNumRange(row.minQuantity, row.maxQuantity) | ||
local dropChance = (row.weight / totalWt) * 100 | |||
result = result..'||style="text-align:right" data-sort-value="'..row.weight..'"' | |||
result = result..'|'..Shared.fraction(row.weight, totalWt) | |||
local dropChance = (row | |||
result = result..'||style="text-align:right" data-sort-value="'..row | |||
result = result..'|'..Shared.fraction(row | |||
result = result..'||style="text-align:right"|'..Shared.round(dropChance, 2, 2)..'%' | result = result..'||style="text-align:right"|'..Shared.round(dropChance, 2, 2)..'%' | ||
result = result..'||style="text-align:left" data-sort-value="'..thisItem.sellsFor..'"' | result = result..'||style="text-align:left" data-sort-value="'..thisItem.sellsFor..'"' | ||
if | if thisItem.sellsFor == 0 or row.minQuantity == row.maxQuantity then | ||
result = result..'|'..Icons.GP(thisItem.sellsFor | result = result..'|'..Icons.GP(thisItem.sellsFor * row.minQuantity) | ||
else | else | ||
result = result..'|'..Icons.GP(thisItem.sellsFor) | result = result..'|'..Icons.GP(thisItem.sellsFor * row.minQuantity, thisItem.sellsFor * row.maxQuantity) | ||
end | |||
lootValue = lootValue + (dropChance * 0.01 * thisItem.sellsFor * ((row.minQuantity + row.maxQuantity)/ 2)) | |||
if isAllFood then | |||
local hp = thisItem.healsFor * 10 | |||
local minHeal, maxHeal = hp * row.minQuantity, hp * row.maxQuantity | |||
foodValue = foodValue + (dropChance * 0.01 * (minHeal + maxHeal) / 2) | |||
result = result .. '||data-sort-value="' .. thisItem.healsFor .. '"' | |||
result = result .. '|' .. Icons.Icon({'Hitpoints', type='skill', notext=true, nolink=true}) .. ' ' .. formatNumRange(minHeal, maxHeal) | |||
end | end | ||
end | end | ||
result = result..'\r\n|}' | result = result..'\r\n|}' | ||
result = result..'\r\nThe average value of the contents of one chest is '..Icons.GP(Shared.round(lootValue, 2, 0))..'.' | result = result..'\r\nThe average value of the contents of one chest is '..Icons.GP(Shared.round(lootValue, 2, 0))..'.' | ||
if isAllFood then | |||
result = result..'\r\n\r\nThe average healing of the contents of one chest is ' .. Icons.Icon({'Hitpoints', type='skill', notext=true, nolink=true}) .. ' ' .. Shared.round(foodValue, 2, 0) .. '.' | |||
end | |||
end | end | ||
Line 947: | Line 1,253: | ||
local area = Areas.getArea(areaName) | local area = Areas.getArea(areaName) | ||
if area == nil then | if area == nil then | ||
return | return Shared.printError('Could not find an area named ' .. areaName) | ||
end | end | ||
if area.type == 'dungeon' then | if area.type == 'dungeon' then | ||
return p.getDungeonMonsterTable(frame) | return p.getDungeonMonsterTable(frame) | ||
end | |||
local monsters = {} | |||
local hasBarrier = false | |||
for i, monsterID in ipairs(area.monsterIDs) do | |||
local monster = p.getMonsterByID(monsterID) | |||
if not hasBarrier and p._getMonsterBarrier(monster) > 0 then | |||
hasBarrier = true | |||
end | |||
table.insert(monsters, monster) | |||
end | end | ||
local | local tableBits = {} | ||
table.insert(tableBits, '{| class="wikitable sortable"') | |||
for i, | table.insert(tableBits, '\r\n! Name !! Combat Level ') | ||
local | if hasBarrier then | ||
table.insert(tableBits, '!! [[Barrier]] ') | |||
end | |||
table.insert(tableBits, '!! Hitpoints !! colspan=2| Max Hit !! [[Combat Triangle|Combat Style]]') | |||
for i, monster in ipairs(monsters) do | |||
local rowBits = {} | |||
table.insert(tableBits, '\r\n|-\r\n|'..Icons.Icon({p.getMonsterName(monster), type='monster'})) | |||
table.insert(tableBits, '||'..p._getMonsterCombatLevel(monster)) | |||
if hasBarrier then | |||
table.insert(tableBits, '||'..Shared.formatnum(p._getMonsterBarrier(monster))) | |||
end | |||
table.insert(tableBits, '||'..Shared.formatnum(p._getMonsterHP(monster))) | |||
local drReduction = p._getMonsterDrReduction(monster) | |||
local maxHit = p._getMonsterMaxHit(monster) | |||
if drReduction > 0 then | |||
table.insert(tableBits, '||style="text-align:right" data-sort-value="'..maxHit..'"| -'..drReduction..'% DR') | |||
table.insert(tableBits, '||style="text-align:right"|'..Shared.formatnum(maxHit)) | |||
else | |||
table.insert(tableBits, '||style="text-align:right" colspan="2" data-sort-value="'..maxHit..'"|'..Shared.formatnum(maxHit)) | |||
end | |||
table.insert(tableBits, '||'..p._getMonsterStyleIcon({monster, nolink=true})) | |||
end | end | ||
table.insert(tableBits, '\r\n|}') | |||
return | |||
return table.concat(tableBits, '') | |||
end | end | ||
Line 972: | Line 1,306: | ||
local area = Areas.getArea(areaName) | local area = Areas.getArea(areaName) | ||
if area == nil then | if area == nil then | ||
return | return Shared.printError('Could not find a dungeon named ' .. areaName) | ||
end | end | ||
--For Dungeons, go through and count how many of each monster are in the dungeon first | --For Dungeons, go through and count how many of each monster are in the dungeon first | ||
local monsterCounts = {} | local monsterCounts = {} | ||
for i, monsterID in | local monsters = {} | ||
local hasBarrier = false | |||
for i, monsterID in ipairs(area.monsterIDs) do | |||
if monsterCounts[monsterID] == nil then | if monsterCounts[monsterID] == nil then | ||
monsterCounts[monsterID] = 1 | monsterCounts[monsterID] = 1 | ||
else | else | ||
monsterCounts[monsterID] = monsterCounts[monsterID] + 1 | monsterCounts[monsterID] = monsterCounts[monsterID] + 1 | ||
if monsterID ~= 'melvorF:RandomITM' and monsterID ~= 'melvorTotH:RandomSpiderLair' then | |||
monsters[monsterID] = p.getMonsterByID(monsterID) | |||
if not hasBarrier and p._getMonsterBarrier(monsters[monsterID]) > 0 then | |||
hasBarrier = true | |||
end | |||
end | |||
end | end | ||
end | end | ||
Line 989: | Line 1,331: | ||
-- Declare function for building table rows to avoid repeating code | -- Declare function for building table rows to avoid repeating code | ||
local buildRow = function(entityID, monsterCount, specialType) | local buildRow = function(entityID, monsterCount, specialType) | ||
local monIcon, monLevel, monHP, monMaxHit, monStyle, monCount | local monIcon, monLevel, monHP, monMaxHit, monStyle, monCount, monDrReduce, monBarrier | ||
local monData = {} | local monData = {} | ||
if specialType ~= nil and Shared.contains({'Afflicted', 'SlayerArea'}, specialType) then | if specialType ~= nil and Shared.contains({'Afflicted', 'Spider', 'SlayerArea'}, specialType) then | ||
-- Special handling for Into the Mist | -- Special handling for Into the Mist | ||
if specialType == 'Afflicted' then | if specialType == 'Afflicted' then | ||
local iconQ = Icons.Icon({'Into the Mist', notext=true, nolink=true, img='Question'}) | local iconQ = Icons.Icon({'Into the Mist', notext=true, nolink=true, img='Question'}) | ||
monIcon = Icons.Icon({'Into the Mist', 'Afflicted Monster', nolink=true, img='Question'}) | monIcon = Icons.Icon({'Into the Mist', 'Afflicted Monster', nolink=true, img='Question'}) | ||
monLevel, monHP, monMaxHit, monStyle, monCount = iconQ, iconQ, iconQ, iconQ, monsterCount | monLevel, monBarrier, monHP, monMaxHit, monDrReduce, monStyle, monCount = iconQ, iconQ, iconQ, iconQ, iconQ, iconQ, monsterCount | ||
elseif specialType == 'Spider' then | |||
local iconQ = Icons.Icon({'', notext=true, nolink=true, img='Question'}) | |||
local monIconPart = { 'Any of the following:' } | |||
for i, monsterID in ipairs(GameData.rawData.spiderLairMonsters) do | |||
local monster = p.getMonsterByID(monsterID) | |||
if monster ~= nil then | |||
table.insert(monIconPart, Icons.Icon({p.getMonsterName(monster), type='monster'})) | |||
end | |||
end | |||
monIcon = table.concat(monIconPart, '<br/>') | |||
monLevel, monBarrier, monHP, monMaxHit, monDrReduce, monStyle, monCount = iconQ, iconQ, iconQ, iconQ, iconQ, iconQ, monsterCount | |||
elseif specialType == 'SlayerArea' then | elseif specialType == 'SlayerArea' then | ||
-- entityID corresponds to a slayer area | -- entityID corresponds to a slayer area | ||
local area = Areas.getAreaByID('slayer', entityID) | local area = Areas.getAreaByID('slayer', entityID) | ||
monIcon = Icons.Icon({area.name, type='combatArea'}) .. ' Monsters' | monIcon = Icons.Icon({area.name, type='combatArea'}) .. ' Monsters' | ||
monLevel = {p.getLowHighStat(area. | monLevel = {p.getLowHighStat(area.monsterIDs, function(monster) return p._getMonsterCombatLevel(monster) end)} | ||
monHP = {p.getLowHighStat(area. | if hasBarrier then | ||
local lowMaxHit, highMaxHit = p.getLowHighStat(area. | monBarrier = {p.getLowHighStat(area.monsterIDs, function(monster) return p._getMonsterBarrier(monster) end)} | ||
end | |||
monHP = {p.getLowHighStat(area.monsterIDs, function(monster) return p._getMonsterHP(monster) end)} | |||
local lowMaxHit, highMaxHit = p.getLowHighStat(area.monsterIDs, function(monster) return p._getMonsterMaxHit(monster) end) | |||
local lowDrReduce, highDrReduce = p.getLowHighStat(area.monsterIDs, function(monster) return p._getMonsterDrReduction(monster) end) | |||
monMaxHit = highMaxHit | monMaxHit = highMaxHit | ||
monDrReduce = highDrReduce | |||
monStyle = Icons.Icon({area.name, area.name, notext=true, nolink=true, img='Question'}) | monStyle = Icons.Icon({area.name, area.name, notext=true, nolink=true, img='Question'}) | ||
monCount = monsterCount | monCount = monsterCount | ||
Line 1,011: | Line 1,369: | ||
-- entityID corresponds to a monster | -- entityID corresponds to a monster | ||
local monster = p.getMonsterByID(entityID) | local monster = p.getMonsterByID(entityID) | ||
monIcon = Icons.Icon({monster | monIcon = Icons.Icon({p.getMonsterName(monster), type='monster'}) | ||
monLevel = p._getMonsterCombatLevel(monster) | monLevel = p._getMonsterCombatLevel(monster) | ||
if hasBarrier then | |||
monBarrier = p._getMonsterBarrier(monster) | |||
end | |||
monHP = p._getMonsterHP(monster) | monHP = p._getMonsterHP(monster) | ||
monDrReduce = p._getMonsterDrReduction(monster) | |||
monMaxHit = p._getMonsterMaxHit(monster) | monMaxHit = p._getMonsterMaxHit(monster) | ||
monStyle = p._getMonsterStyleIcon({monster}) | monStyle = p._getMonsterStyleIcon({monster}) | ||
Line 1,046: | Line 1,408: | ||
table.insert(resultPart, '\r\n|-\r\n| ' .. monIcon) | table.insert(resultPart, '\r\n|-\r\n| ' .. monIcon) | ||
table.insert(resultPart, '\r\n|style="text-align:right;" data-sort-value="' .. getValSort(monLevel) .. '"| ' .. getValText(monLevel)) | table.insert(resultPart, '\r\n|style="text-align:right;" data-sort-value="' .. getValSort(monLevel) .. '"| ' .. getValText(monLevel)) | ||
if hasBarrier then | |||
table.insert(resultPart, '\r\n|style="text-align:right;" data-sort-value="' .. getValSort(monBarrier) .. '"| ' .. getValText(monBarrier)) | |||
end | |||
table.insert(resultPart, '\r\n|style="text-align:right;" data-sort-value="' .. getValSort(monHP) .. '"| ' .. getValText(monHP)) | table.insert(resultPart, '\r\n|style="text-align:right;" data-sort-value="' .. getValSort(monHP) .. '"| ' .. getValText(monHP)) | ||
table.insert(resultPart, '\r\n|style="text-align:right | if type(monDrReduce) == 'number' and monDrReduce > 0 then | ||
table.insert(resultPart, '\r\n|style="text-align:right" data-sort-value="'..getValSort(monMaxHit)..'"| -'..monDrReduce..'% DR') | |||
table.insert(resultPart, '\r\n|style="text-align:right"|'..getValText(monMaxHit)) | |||
else | |||
table.insert(resultPart, '\r\n|style="text-align:right" colspan="2" data-sort-value="'..getValSort(monMaxHit)..'"|'..getValText(monMaxHit)) | |||
end | |||
table.insert(resultPart, '\r\n| ' .. monStyle) | table.insert(resultPart, '\r\n| ' .. monStyle) | ||
table.insert(resultPart, '\r\n|style="text-align:right;" data-sort-value="' .. getValSort(monCount) .. '"| ' .. getValText(monCount)) | table.insert(resultPart, '\r\n|style="text-align:right;" data-sort-value="' .. getValSort(monCount) .. '"| ' .. getValText(monCount)) | ||
Line 1,055: | Line 1,425: | ||
local returnPart = {} | local returnPart = {} | ||
table.insert(returnPart, '{| class="wikitable sortable"') | table.insert(returnPart, '{| class="wikitable sortable"') | ||
table.insert(returnPart, '\r\n! Name !! Combat Level !! Hitpoints !! Max Hit !! [[Combat Triangle|Combat Style]] !! Count') | table.insert(returnPart, '\r\n! Name !! Combat Level ') | ||
if hasBarrier then | |||
table.insert(returnPart, '!! [[Barrier]] ') | |||
end | |||
table.insert(returnPart, '!! Hitpoints !! colspan="2" | Max Hit !! [[Combat Triangle|Combat Style]] !! Count') | |||
-- Special handing for Impending Darkness event | -- Special handing for Impending Darkness event | ||
-- TODO needs to be revised once there is a better understanding of how the event works | -- TODO needs to be revised once there is a better understanding of how the event works | ||
for i, monsterID in ipairs(area.monsterIDs) do | |||
if not Shared.contains(usedMonsters, monsterID) then | if not Shared.contains(usedMonsters, monsterID) then | ||
if monsterID | if monsterID == 'melvorF:RandomITM' then | ||
--Special handling for Into the Mist | --Special handling for Into the Mist | ||
table.insert(returnPart, buildRow(monsterID, monsterCounts[monsterID], 'Afflicted')) | table.insert(returnPart, buildRow(monsterID, monsterCounts[monsterID], 'Afflicted')) | ||
elseif monsterID == 'melvorTotH:RandomSpiderLair' then | |||
table.insert(returnPart, buildRow(monsterID, monsterCounts[monsterID], 'Spider')) | |||
else | |||
table.insert(returnPart, buildRow(monsterID, monsterCounts[monsterID], hasBarrier)) | |||
end | end | ||
table.insert(usedMonsters, monsterID) | table.insert(usedMonsters, monsterID) | ||
Line 1,084: | Line 1,453: | ||
local area = Areas.getArea(areaName) | local area = Areas.getArea(areaName) | ||
if area == nil then | if area == nil then | ||
return | return Shared.printError('Could not find a dungeon named ' .. areaName) | ||
end | end | ||
local totalHP = 0 | local totalHP = 0 | ||
for i, monsterID in | for i, monsterID in ipairs(area.monsterIDs) do | ||
local monster = p.getMonsterByID(monsterID) | |||
totalHP = totalHP + p._getMonsterHP(monster) | |||
end | end | ||
return totalHP | return totalHP | ||
Line 1,099: | Line 1,466: | ||
function p._getAreaMonsterList(area) | function p._getAreaMonsterList(area) | ||
local monsterList = {} | local monsterList = {} | ||
for i, monsterID in | for i, monsterID in ipairs(area.monsterIDs) do | ||
local monster = p.getMonsterByID(monsterID) | local monster = p.getMonsterByID(monsterID) | ||
table.insert(monsterList, Icons.Icon({monster | table.insert(monsterList, Icons.Icon({p.getMonsterName(monster), type='monster'})) | ||
end | end | ||
return table.concat(monsterList, '<br/>') | return table.concat(monsterList, '<br/>') | ||
Line 1,108: | Line 1,475: | ||
function p._getDungeonMonsterList(area) | function p._getDungeonMonsterList(area) | ||
local monsterList = {} | local monsterList = {} | ||
local lastID = '' | |||
local lastID = | |||
local count = 0 | local count = 0 | ||
local monsterCounts = {} | |||
for i, monsterID in ipairs(area.monsterIDs) do | |||
if lastID == '' then | |||
for i, monsterID in | |||
lastID = monsterID | lastID = monsterID | ||
count = 1 | count = 1 | ||
elseif lastID == monsterID then | |||
count = count + 1 | |||
else | else | ||
count = count | table.insert(monsterCounts, { id = lastID, count = count }) | ||
lastID = monsterID | |||
count = 1 | |||
end | end | ||
-- | end | ||
table.insert(monsterCounts, { id = lastID, count = count }) | |||
local | |||
table.insert(monsterList, Icons.Icon({ | for i, monster in ipairs(monsterCounts) do | ||
if monster.id == 'melvorF:RandomITM' then | |||
--Special handling for Afflicted Monsters | |||
table.insert(monsterList, Icons.Icon({'Affliction', 'Afflicted Monster', img='Question', qty=monster.count})) | |||
elseif monster.id == 'melvorTotH:RandomSpiderLair' then | |||
local monIconPart = { Shared.formatnum(monster.count) .. ' Spiders:' } | |||
for i, monsterID in ipairs(GameData.rawData.spiderLairMonsters) do | |||
local monster = p.getMonsterByID(monsterID) | |||
if monster ~= nil then | |||
table.insert(monIconPart, ' ' .. Icons.Icon({p.getMonsterName(monster), type='monster'})) | |||
end | |||
end | |||
table.insert(monsterList, table.concat(monIconPart, '<br/>')) | |||
else | |||
local monsterObj = p.getMonsterByID(monster.id) | |||
table.insert(monsterList, Icons.Icon({p.getMonsterName(monsterObj), type='monster', qty=monster.count})) | |||
end | end | ||
end | end | ||
return table.concat(monsterList, '<br/>') | return table.concat(monsterList, '<br/>') | ||
end | end | ||
Line 1,152: | Line 1,519: | ||
local area = Areas.getArea(areaName) | local area = Areas.getArea(areaName) | ||
if area == nil then | if area == nil then | ||
return | return Shared.printError('Could not find an area named ' .. areaName) | ||
end | end | ||
Line 1,164: | Line 1,531: | ||
function p.getFoxyTable(frame) | function p.getFoxyTable(frame) | ||
local result = 'Monster,Min GP,Max GP,Average GP' | local result = 'Monster,Min GP,Max GP,Average GP' | ||
for i, monster in | for i, monster in ipairs(GameData.rawData.monsters) do | ||
if not p._isDungeonOnlyMonster(monster) then | if not p._isDungeonOnlyMonster(monster) then | ||
if monster. | if monster.gpDrops ~= nil and monster.gpDrops.max > 0 then | ||
local avgGp = (monster. | local avgGp = (monster.gpDrops.min + monster.gpDrops.max) / 2 | ||
result = result..'<br/>'..monster | result = result .. '<br/>' .. p.getMonsterName(monster) .. ',' .. monster.gpDrops.min .. ',' .. monster.gpDrops.max .. ',' .. avgGp | ||
end | end | ||
end | end | ||
Line 1,181: | Line 1,548: | ||
local bones = p._getMonsterBones(monster) | local bones = p._getMonsterBones(monster) | ||
if bones ~= nil then | if bones ~= nil then | ||
totalGP = totalGP + bones.sellsFor * | totalGP = totalGP + bones.item.sellsFor * bones.quantity | ||
end | end | ||
Line 1,191: | Line 1,558: | ||
local avgGp = 0 | local avgGp = 0 | ||
if monster. | if monster.gpDrops ~= nil then | ||
avgGp = (monster. | avgGp = (monster.gpDrops.min + monster.gpDrops.max) / 2 | ||
end | end | ||
totalGP = totalGP + avgGp | totalGP = totalGP + avgGp | ||
local totalWt = 0 | local totalWt = 0 | ||
for i, row in | for i, row in ipairs(monster.lootTable) do | ||
totalWt = totalWt + row | totalWt = totalWt + row.weight | ||
end | end | ||
for i, row in | for i, row in ipairs(monster.lootTable) do | ||
local thisItem = Items.getItemByID(row | local thisItem = Items.getItemByID(row.itemID) | ||
local itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0 | local itemPrice = thisItem.sellsFor ~= nil and thisItem.sellsFor or 0 | ||
--Getting the drop chance | --Getting the drop chance | ||
local dropChance = (row | local dropChance = (row.weight / totalWt * lootChance) | ||
--Adding to the average loot value based on price & dropchance | --Adding to the average loot value based on price & dropchance | ||
lootValue = lootValue + (dropChance * 0.01 * itemPrice * (( | lootValue = lootValue + (dropChance * 0.01 * itemPrice * ((row.minQuantity + row.maxQuantity) / 2)) | ||
end | end | ||
Line 1,227: | Line 1,592: | ||
if monster == nil then | if monster == nil then | ||
return | return Shared.printError('No monster with that name found') | ||
end | end | ||
Line 1,236: | Line 1,601: | ||
local result = '{| class="wikitable sortable"' | local result = '{| class="wikitable sortable"' | ||
result = result..'\r\n!Monster!!Combat Level!!Average GP' | result = result..'\r\n!Monster!!Combat Level!!Average GP' | ||
for i, | for i, monster in ipairs(GameData.rawData.monsters) do | ||
if not p._isDungeonOnlyMonster(monster) then | if not p._isDungeonOnlyMonster(monster) then | ||
local monsterGP = p._getMonsterAverageGP(monster) | local monsterGP = p._getMonsterAverageGP(monster) | ||
local combatLevel = p._getMonsterCombatLevel(monster | local combatLevel = p._getMonsterCombatLevel(monster) | ||
result = result..'\r\n|-\r\n|'..Icons.Icon({monster | result = result..'\r\n|-\r\n|'..Icons.Icon({p.getMonsterName(monster), type='monster', noicon=true})..'||'..combatLevel..'||'..monsterGP | ||
end | end | ||
end | end | ||
Line 1,255: | Line 1,618: | ||
if tier == nil then | if tier == nil then | ||
return | return Shared.printError('No tier specified') | ||
end | end | ||
Line 1,265: | Line 1,628: | ||
if slayerTier == nil then | if slayerTier == nil then | ||
return | return Shared.printError('Invalid slayer tier') | ||
end | end | ||
Line 1,274: | Line 1,637: | ||
-- Right now hiddenMonsterIDs is empty | -- Right now hiddenMonsterIDs is empty | ||
local hiddenMonsterIDs = {} | local hiddenMonsterIDs = {} | ||
local | local monsterList = GameData.getEntities('monsters', | ||
function(monster) | |||
if monster.canSlayer and not Shared.contains(hiddenMonsterIDs, monster.id) then | |||
local cmbLevel = p._getMonsterCombatLevel(monster) | |||
return cmbLevel >= minLevel and (maxLevel == nil or cmbLevel <= maxLevel) | |||
end | |||
return false | |||
end) | |||
if Shared. | if Shared.tableIsEmpty(monsterList) then | ||
-- Somehow no monsters are in the tier, return nothing | -- Somehow no monsters are in the tier, return nothing | ||
return '' | return '' | ||
else | else | ||
return p._getMonsterTable( | return p._getMonsterTable(monsterList, true) | ||
end | end | ||
end | end | ||
function p.getFullMonsterTable(frame) | function p.getFullMonsterTable(frame) | ||
return p._getMonsterTable(GameData.rawData.monsters, false) | |||
return p._getMonsterTable( | |||
end | end | ||
function p._getMonsterTable( | function p._getMonsterTable(monsters, excludeDungeons) | ||
--Making a single function for getting a table of monsters given a list of IDs. | --Making a single function for getting a table of monsters given a list of IDs. | ||
local hideDungeons = excludeDungeons ~= nil and excludeDungeons or false | local hideDungeons = excludeDungeons ~= nil and excludeDungeons or false | ||
Line 1,307: | Line 1,664: | ||
table.insert(tableParts, '{| class="wikitable sortable stickyHeader"') | table.insert(tableParts, '{| class="wikitable sortable stickyHeader"') | ||
-- First header row | -- First header row | ||
table.insert(tableParts, '\r\n|- class="headerRow-0"\r\n! colspan=" | table.insert(tableParts, '\r\n|- class="headerRow-0"\r\n! colspan="4" | !! colspan="5" |Offensive Stats !! colspan="3" |Evasion Rating !! colspan="4" |') | ||
-- Second header row | -- Second header row | ||
table.insert(tableParts, '\r\n|- class="headerRow-1"\r\n!Monster !!Name | table.insert(tableParts, '\r\n|- class="headerRow-1"\r\n!Monster !!Name !!Combat Level ') | ||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Hitpoints', type='skill'})) | table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Hitpoints', type='skill'})) | ||
table.insert(tableParts, '!!Attack Speed (s) !!colspan=" | table.insert(tableParts, '!!Attack Speed (s) !!colspan="3"|Max Hit !!Accuracy ') | ||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Defence', type='skill', notext=true})) | table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Defence', type='skill', notext=true})) | ||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Ranged', type='skill', notext=true})) | table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Ranged', type='skill', notext=true})) | ||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Magic', type='skill', notext=true})) | table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Magic', type='skill', notext=true})) | ||
table.insert(tableParts, '!!' .. Icons.Icon({'Coins', notext=true, nolink=true}) .. ' Coins !!Bones !!Locations') | table.insert(tableParts, '!!DR!!' .. Icons.Icon({'Coins', notext=true, nolink=true}) .. ' Coins !!Bones !!Locations') | ||
-- Generate row per monster | -- Generate row per monster | ||
for i, | for i, monster in ipairs(monsters) do | ||
-- Avoid processing monsters without equipment stats. These aren't actual | |||
-- monsters, but instead are placeholders such as 'melvorF:RandomITM' | |||
-- and 'melvorTotH:RandomSpiderLair' to denote a random selection from | |||
-- a pool of monsters | |||
if monster.equipmentStats ~= nil then | |||
local cmbLevel = p._getMonsterCombatLevel(monster) | |||
local atkSpeed = p._getMonsterAttackSpeed(monster) | |||
local maxHit = p._getMonsterMaxHit(monster) | |||
local dr = p._getMonsterStat(monster, 'damageReduction') | |||
local drReduce = p._getMonsterDrReduction(monster) | |||
local accR = p._getMonsterAR(monster) | |||
local evaR = {p._getMonsterER(monster, "Melee"), p._getMonsterER(monster, "Ranged"), p._getMonsterER(monster, "Magic")} | |||
local gpTxt = nil | |||
if monster.gpDrops.min >= monster.gpDrops.max then | |||
gpTxt = Shared.formatnum(monster.gpDrops.min) | |||
else | |||
gpTxt = Shared.formatnum(monster.gpDrops.min) .. ' - ' .. Shared.formatnum(monster.gpDrops.max) | |||
end | |||
local bones = p._getMonsterBones(monster) | |||
local boneTxt = (bones ~= nil and Icons.Icon({bones.item.name, type='item', notext=true})) or 'None' | |||
table.insert(tableParts, '\r\n|-\r\n|style="text-align: center;" |' .. Icons.Icon({p.getMonsterName(monster), type='monster', size=50, notext=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:left" |' .. Icons.Icon({p.getMonsterName(monster), type='monster', noicon=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. cmbLevel .. '" |' .. Shared.formatnum(cmbLevel)) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. p._getMonsterHP(monster) .. '" |' .. Shared.formatnum(p._getMonsterHP(monster))) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. atkSpeed .. '" |' .. Shared.round(atkSpeed, 1, 1)) | |||
if drReduce > 0 then | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. maxHit .. '"| -' .. drReduce..'% DR') | |||
table.insert(tableParts, '\r\n|style="text-align:right;border-right:hidden" |' .. p._getMonsterStyleIcon({monster, notext=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:right" |' .. Shared.formatnum(maxHit)) | |||
else | |||
table.insert(tableParts, '\r\n|style="text-align:right;border-right:hidden" colspan="2" data-sort-value="' .. maxHit .. '"|' .. p._getMonsterStyleIcon({monster, notext=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:right"|' .. Shared.formatnum(maxHit)) | |||
end | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. accR .. '" |' .. Shared.formatnum(accR)) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[1] .. '" |' .. Shared.formatnum(evaR[1])) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[2] .. '" |' .. Shared.formatnum(evaR[2])) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[3] .. '" |' .. Shared.formatnum(evaR[3])) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. dr .. '" |' .. dr..'%') | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. (monster.gpDrops.min + monster.gpDrops.max) / 2 .. '" |' .. gpTxt) | |||
table.insert(tableParts, '\r\n|style="text-align:center" |' .. boneTxt) | |||
table.insert(tableParts, '\r\n|style="text-align:right;width:190px" |' .. p._getMonsterAreas(monster, hideDungeons)) | |||
end | end | ||
end | end | ||
Line 1,370: | Line 1,736: | ||
-- Generate row per monster | -- Generate row per monster | ||
for i, monster in | for i, monster in ipairs(GameData.rawData.monsters) do | ||
if p.getMonsterName(monster) ~= nil then | |||
local cmbLevel = p._getMonsterCombatLevel(monster) | |||
local gpTxt = nil | |||
if monster.gpDrops.min >= monster.gpDrops.max then | |||
gpTxt = Shared.formatnum(monster.gpDrops.min) | |||
else | |||
gpTxt = Shared.formatnum(monster.gpDrops.min) .. ' - ' .. Shared.formatnum(monster.gpDrops.max) | |||
end | |||
local lootVal = p._getMonsterLootValue(monster) | |||
local lootTxt = '0' | |||
if lootVal ~= 0 then | |||
lootTxt = Shared.formatnum(Shared.round(lootVal, 2, 2)) | |||
end | |||
table.insert(tableParts, '\r\n|-\r\n|style="text-align: center;" |' .. Icons.Icon({p.getMonsterName(monster), type='monster', size=50, notext=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:left" |' .. Icons.Icon({p.getMonsterName(monster), type='monster', noicon=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:right" |' .. monster.id) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. cmbLevel .. '" |' .. Shared.formatnum(cmbLevel)) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. p._getMonsterHP(monster) .. '" |' .. Shared.formatnum(p._getMonsterHP(monster))) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. (monster.gpDrops.min + monster.gpDrops.max) / 2 .. '" |' .. gpTxt) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. lootVal .. '" |' .. lootTxt) | |||
table.insert(tableParts, '\r\n|style="text-align:right;width:190px" |' .. p._getMonsterAreas(monster, false)) | |||
end | end | ||
end | end | ||
Line 1,420: | Line 1,784: | ||
-- Generate row per monster | -- Generate row per monster | ||
for i, monster in | for i, monster in ipairs(GameData.rawData.monsters) do | ||
if p.getMonsterName(monster) ~= nil then | |||
local cmbLevel = p._getMonsterCombatLevel(monster) | |||
local gpTxt = nil | |||
if monster.gpDrops.min >= monster.gpDrops.max then | |||
gpTxt = Shared.formatnum(monster.gpDrops.min) | |||
else | |||
gpTxt = Shared.formatnum(monster.gpDrops.min) .. ' - ' .. Shared.formatnum(monster.gpDrops.max) | |||
end | |||
local lootVal = p._getMonsterLootValue(monster) | |||
local lootTxt = '0' | |||
if lootVal ~= 0 then | |||
lootTxt = Shared.formatnum(Shared.round(lootVal, 2, 2)) | |||
end | |||
local atkSpeed = p._getMonsterAttackSpeed(monster) | |||
local maxHit = p._getMonsterMaxHit(monster) | |||
local accR = p._getMonsterAR(monster) | |||
local evaR = {p._getMonsterER(monster, "Melee"), p._getMonsterER(monster, "Ranged"), p._getMonsterER(monster, "Magic")} | |||
local bones = p._getMonsterBones(monster) | |||
local boneTxt = (bones ~= nil and Icons.Icon({bones.item.name, type='item', notext=true})) or 'None' | |||
table.insert(tableParts, '\r\n|-\r\n|style="text-align: center;" |' .. Icons.Icon({p.getMonsterName(monster), type='monster', size=50, notext=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:left" |' .. Icons.Icon({p.getMonsterName(monster), type='monster', noicon=true})) | |||
-- table.insert(tableParts, '\r\n|style="text-align:right" |' .. monster.id) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. cmbLevel .. '" |' .. Shared.formatnum(cmbLevel)) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. p._getMonsterHP(monster) .. '" |' .. Shared.formatnum(p._getMonsterHP(monster))) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[1] .. '" |' .. Shared.formatnum(evaR[1])) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. atkSpeed .. '" |' .. Shared.round(atkSpeed, 1, 1)) | |||
table.insert(tableParts, '\r\n|style="text-align:center;border-right:hidden" |' .. p._getMonsterStyleIcon({monster, notext=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. maxHit .. '" |' .. Shared.formatnum(maxHit)) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. accR .. '" |' .. Shared.formatnum(accR)) | |||
--table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[2] .. '" |' .. Shared.formatnum(evaR[2])) | |||
--table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[3] .. '" |' .. Shared.formatnum(evaR[3])) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. (monster.gpDrops.min + monster.gpDrops.max) / 2 .. '" |' .. gpTxt) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. lootVal .. '" |' .. lootTxt) | |||
table.insert(tableParts, '\r\n|style="text-align:center" |' .. boneTxt) | |||
-- table.insert(tableParts, '\r\n|style="text-align:right;width:190px" |' .. p._getMonsterAreas(monster, hideDungeons)) | |||
end | end | ||
end | end | ||
Line 1,474: | Line 1,836: | ||
local spAttTable = {} | local spAttTable = {} | ||
for i, monster in ipairs( | for i, monster in ipairs(GameData.rawData.monsters) do | ||
if monster.specialAttacks ~= nil and Shared. | if monster.specialAttacks ~= nil and not Shared.tableIsEmpty(monster.specialAttacks) then | ||
local overrideChance = (monster.overrideSpecialChances ~= nil and Shared.tableCount(monster.overrideSpecialChances) > 0) | local overrideChance = (monster.overrideSpecialChances ~= nil and Shared.tableCount(monster.overrideSpecialChances) > 0) | ||
for j, | for j, spAttID in ipairs(monster.specialAttacks) do | ||
local spAtt = GameData.getEntityByID('attacks', spAttID) | |||
local attChance = (overrideChance and monster.overrideSpecialChances[j] or spAtt.defaultChance) | local attChance = (overrideChance and monster.overrideSpecialChances[j] or spAtt.defaultChance) | ||
if spAttTable[spAtt.id] == nil then | if spAttTable[spAtt.id] == nil then | ||
Line 1,485: | Line 1,848: | ||
spAttTable[spAtt.id]['icons'][attChance] = {} | spAttTable[spAtt.id]['icons'][attChance] = {} | ||
end | end | ||
table.insert(spAttTable[spAtt.id]['icons'][attChance], Icons.Icon({ monster | table.insert(spAttTable[spAtt.id]['icons'][attChance], Icons.Icon({ p.getMonsterName(monster), type = 'monster' })) | ||
end | end | ||
end | end | ||
Line 1,519: | Line 1,882: | ||
return table.concat(resultPart) | return table.concat(resultPart) | ||
end | |||
--NOTE: This is not a function that should be called directly. It generates text to be pasted into Chest Loot TablesTemplate:MonsterLootTables | |||
--It exists because I'm too lazy to manually type up all the new monsters - User:Falterfire | |||
function p.getMonsterLootTableText() | |||
local getAreaText = function(area) | |||
local outArray = {} | |||
table.insert(outArray, "==={{ZoneIcon|"..area.name.."|size=50}}===") | |||
table.insert(outArray, "") | |||
for i, monsterID in ipairs(area.monsterIDs) do | |||
local monster = p.getMonsterByID(monsterID) | |||
table.insert(outArray, "===={{MonsterIcon|"..p.getMonsterName(monster).."|size=40}}====") | |||
table.insert(outArray, "{{MonsterDrops|"..p.getMonsterName(monster).."|size=40}}") | |||
end | |||
return table.concat(outArray, "\r\n") | |||
end | |||
local fullArray = {} | |||
local areaArray = Areas.getAreas(function(a) return a.type == 'combatArea' end) | |||
for i, area in ipairs(areaArray) do | |||
table.insert(fullArray, getAreaText(area)) | |||
end | |||
areaArray = Areas.getAreas(function(a) return a.type == 'slayerArea' end) | |||
for i, area in ipairs(areaArray) do | |||
table.insert(fullArray, getAreaText(area)) | |||
end | |||
return table.concat(fullArray, "\r\n\r\n----\r\n") | |||
end | |||
--NOTE: This is not a function that should be called directly. It generates text to be pasted into Chest Loot Tables | |||
--It exists because I'm too lazy to manually type up all the new chests - User:Falterfire | |||
function p.getChestLootTables() | |||
local items = Items.getItems(function(item) return item.dropTable ~= nil end) | |||
local outArray = {} | |||
for i, item in ipairs(items) do | |||
table.insert(outArray, "==={{ItemIcon|"..item.name.."|size=30}}===") | |||
table.insert(outArray, "{{ChestDrops|"..item.name.."}}") | |||
end | |||
return table.concat(outArray, "\r\n") | |||
end | |||
--Returns the expansion icon for the item if it has one | |||
function p.getExpansionIcon(frame) | |||
local monsterName = frame.args ~= nil and frame.args[1] or frame | |||
local monster = p.getMonster(monsterName) | |||
if monster == nil then | |||
return Shared.printError('No monster with that name found') | |||
end | |||
return Icons.getExpansionIcon(monster.id) | |||
end | end | ||
return p | return p |