12,714
edits
Falterfire (talk | contribs) (Added p.getOtherMonsterBoxText) |
m (getChestDrops: Added punctuation) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local MonsterData = mw.loadData('Module:Monsters/data') | local MonsterData = mw.loadData('Module:Monsters/data') | ||
local Constants = require('Module:Constants') | |||
local Areas = require('Module:CombatAreas') | local Areas = require('Module:CombatAreas') | ||
local Magic = require('Module:Magic') | local Magic = require('Module:Magic') | ||
Line 103: | Line 103: | ||
local iconText = '' | local iconText = '' | ||
if monster.attackType == | if Constants.getCombatStyleName(monster.attackType) == 'Melee' then | ||
iconText = Icons.Icon({'Melee', notext=notext, nolink=nolink}) | iconText = Icons.Icon({'Melee', notext=notext, nolink=nolink}) | ||
elseif monster.attackType == | elseif Constants.getCombatStyleName(monster.attackType) == 'Ranged' then | ||
iconText = Icons.Icon({'Ranged', type='skill', notext=notext, nolink=nolink}) | iconText = Icons.Icon({'Ranged', type='skill', notext=notext, nolink=nolink}) | ||
elseif Constants.getCombatStyleName(monster.attackType) == 'Magic' then | |||
iconText = Icons.Icon({'Magic', type='skill', notext=notext, nolink=nolink}) | iconText = Icons.Icon({'Magic', type='skill', notext=notext, nolink=nolink}) | ||
end | end | ||
Line 183: | Line 183: | ||
local effAttLvl = 0 | local effAttLvl = 0 | ||
local attBonus = 0 | local attBonus = 0 | ||
if monster.attackType == | if Constants.getCombatStyleName(monster.attackType) == 'Melee' then | ||
effAttLvl = monster.attackLevel + 9 | effAttLvl = monster.attackLevel + 9 | ||
attBonus = monster.attackBonus + 64 | attBonus = monster.attackBonus + 64 | ||
elseif monster.attackType == | elseif Constants.getCombatStyleName(monster.attackType) == 'Ranged' then | ||
effAttLvl = monster.rangedLevel + 9 | effAttLvl = monster.rangedLevel + 9 | ||
attBonus = monster.attackBonusRanged + 64 | attBonus = monster.attackBonusRanged + 64 | ||
elseif monster.attackType == | elseif Constants.getCombatStyleName(monster.attackType) == 'Magic' then | ||
effAttLvl = monster.magicLevel + 9 | effAttLvl = monster.magicLevel + 9 | ||
attBonus = monster.attackBonusMagic + 64 | attBonus = monster.attackBonusMagic + 64 | ||
Line 300: | Line 300: | ||
local specialMaxHit = 0 | local specialMaxHit = 0 | ||
local normalMaxHit = p._getMonsterBaseMaxHit(monster) | local normalMaxHit = p._getMonsterBaseMaxHit(monster) | ||
local hasActiveBuffSpec = false | |||
if monster.hasSpecialAttack then | if monster.hasSpecialAttack then | ||
for i, specID in pairs(monster.specialAttackID) do | for i, specID in pairs(monster.specialAttackID) do | ||
Line 321: | Line 322: | ||
end | end | ||
if thisMax > specialMaxHit then specialMaxHit = thisMax end | if thisMax > specialMaxHit then specialMaxHit = thisMax end | ||
if specAttack.activeBuffs then hasActiveBuffSpec = true 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 then normalMaxHit = 0 end | if normalChance == 0 and not hasActiveBuffSpec then normalMaxHit = 0 end | ||
return math.max(specialMaxHit, normalMaxHit) | return math.max(specialMaxHit, normalMaxHit) | ||
end | end | ||
Line 342: | Line 344: | ||
local effStrLvl = 0 | local effStrLvl = 0 | ||
local strBonus = 0 | local strBonus = 0 | ||
if monster.attackType == | if Constants.getCombatStyleName(monster.attackType) == 'Melee' then | ||
effStrLvl = monster.strengthLevel + 9 | effStrLvl = monster.strengthLevel + 9 | ||
strBonus = monster.strengthBonus | strBonus = monster.strengthBonus | ||
elseif monster.attackType == | elseif Constants.getCombatStyleName(monster.attackType) == 'Ranged' then | ||
effStrLvl = monster.rangedLevel + 9 | effStrLvl = monster.rangedLevel + 9 | ||
strBonus = monster.strengthBonusRanged | strBonus = monster.strengthBonusRanged | ||
elseif monster.attackType == | elseif Constants.getCombatStyleName(monster.attackType) == 'Magic' then | ||
local mSpell = nil | local mSpell = nil | ||
if monster.selectedSpell ~= nil then mSpell = Magic.getSpellByID('Spells', monster.selectedSpell) end | if monster.selectedSpell ~= nil then mSpell = Magic.getSpellByID('Spells', monster.selectedSpell) end | ||
Line 357: | Line 359: | ||
end | end | ||
else | else | ||
error('blah') | |||
return "ERROR: This monster has an invalid attack type somehow[[Category:Pages with script errors]]" | return "ERROR: This monster has an invalid attack type somehow[[Category:Pages with script errors]]" | ||
end | end | ||
Line 387: | Line 390: | ||
local iconText = '' | local iconText = '' | ||
local typeText = '' | local typeText = '' | ||
if monster.attackType == | if Constants.getCombatStyleName(monster.attackType) == 'Melee' then | ||
iconText = Icons.Icon({'Melee', notext=true}) | iconText = Icons.Icon({'Melee', notext=true}) | ||
typeText = 'Melee' | typeText = 'Melee' | ||
elseif monster.attackType == | elseif Constants.getCombatStyleName(monster.attackType) == 'Ranged' then | ||
iconText = Icons.Icon({'Ranged', type='skill', notext=true}) | iconText = Icons.Icon({'Ranged', type='skill', notext=true}) | ||
typeText = 'Ranged' | typeText = 'Ranged' | ||
elseif Constants.getCombatStyleName(monster.attackType) == 'Magic' then | |||
iconText = Icons.Icon({'Magic', type='skill', notext=true}) | iconText = Icons.Icon({'Magic', type='skill', notext=true}) | ||
typeText = 'Magic' | typeText = 'Magic' | ||
Line 456: | Line 459: | ||
local result = '[[Category:Monsters]]' | local result = '[[Category:Monsters]]' | ||
if monster.attackType == | if Constants.getCombatStyleName(monster.attackType) == 'Melee' then | ||
result = result..'[[Category:Melee Monsters]]' | result = result..'[[Category:Melee Monsters]]' | ||
elseif monster.attackType == | elseif Constants.getCombatStyleName(monster.attackType) == 'Ranged' then | ||
result = result..'[[Category:Ranged Monsters]]' | result = result..'[[Category:Ranged Monsters]]' | ||
elseif monster.attackType == | elseif Constants.getCombatStyleName(monster.attackType) == 'Magic' then | ||
result = result..'[[Category:Magic Monsters]]' | result = result..'[[Category:Magic Monsters]]' | ||
end | end | ||
Line 500: | Line 503: | ||
result = result.."\r\n|-\r\n|'''Monster Types:''' "..table.concat(monsterTypes, ", ") | result = result.."\r\n|-\r\n|'''Monster Types:''' "..table.concat(monsterTypes, ", ") | ||
local SlayerTier = 'N/A' | |||
if not p._isDungeonOnlyMonster(monster) then | |||
SlayerTier = Constants.getSlayerTierNameByLevel(p._getMonsterCombatLevel(monster)) | |||
end | |||
result = result.."\r\n|-\r\n|'''"..Icons.Icon({'Slayer', type='skill'}).." [[Slayer#Slayer Tier Monsters|Tier]]:''' "..SlayerTier | |||
return result | return result | ||
Line 537: | Line 547: | ||
avgGp = (monster.dropCoins[1] + monster.dropCoins[2] - 1) / 2 | avgGp = (monster.dropCoins[1] + monster.dropCoins[2] - 1) / 2 | ||
local gpTxt = Icons.GP(monster.dropCoins[1], monster.dropCoins[2] - 1) | local gpTxt = Icons.GP(monster.dropCoins[1], monster.dropCoins[2] - 1) | ||
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 595: | Line 605: | ||
end | end | ||
result = result..'\r\n|}' | result = result..'\r\n|}' | ||
result = result..'\r\nThe loot dropped by the average kill is worth '..Icons.GP(Shared.round(lootValue, 2, 0)).." if sold" | result = result..'\r\nThe loot dropped by the average kill is worth '..Icons.GP(Shared.round(lootValue, 2, 0)).." if sold." | ||
result = result..'<br/>Including GP, the average kill is worth '..Icons.GP(Shared.round(avgGp + lootValue, 2, 0)) | if avgGp > 0 then | ||
result = result..'<br/>Including GP, the average kill is worth '..Icons.GP(Shared.round(avgGp + lootValue, 2, 0))..'.' | |||
end | |||
end | end | ||
Line 664: | Line 676: | ||
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))..'.' | ||
end | end | ||
Line 686: | Line 698: | ||
local monster = p.getMonsterByID(monsterID) | local monster = p.getMonsterByID(monsterID) | ||
tableTxt = tableTxt..'\r\n|-\r\n|'..Icons.Icon({monster.name, type='monster'}) | tableTxt = tableTxt..'\r\n|-\r\n|'..Icons.Icon({monster.name, type='monster'}) | ||
tableTxt = tableTxt..'||'..p. | tableTxt = tableTxt..'||'..p._getMonsterCombatLevel(monster) | ||
tableTxt = tableTxt..'||'..Shared.formatnum(p.getMonsterHP(monster.name)) | tableTxt = tableTxt..'||'..Shared.formatnum(p.getMonsterHP(monster.name)) | ||
tableTxt = tableTxt..'||'..Shared.formatnum(p.getMonsterMaxHit(monster.name)) | tableTxt = tableTxt..'||'..Shared.formatnum(p.getMonsterMaxHit(monster.name)) | ||
Line 723: | Line 735: | ||
if monsterID ~= 1 then | if monsterID ~= 1 then | ||
tableTxt = tableTxt..'\r\n|-\r\n|'..Icons.Icon({name, type='monster'}) | tableTxt = tableTxt..'\r\n|-\r\n|'..Icons.Icon({name, type='monster'}) | ||
tableTxt = tableTxt..'||'..p. | tableTxt = tableTxt..'||'..p._getMonsterCombatLevel(monster) | ||
tableTxt = tableTxt..'||'..Shared.formatnum(p.getMonsterHP(name)) | tableTxt = tableTxt..'||'..Shared.formatnum(p.getMonsterHP(name)) | ||
tableTxt = tableTxt..'||'..Shared.formatnum(p.getMonsterMaxHit(name)) | tableTxt = tableTxt..'||'..Shared.formatnum(p.getMonsterMaxHit(name)) | ||
Line 927: | Line 939: | ||
-- Input validation | -- Input validation | ||
local tier = frame.args ~= nil and frame.args[1] or frame | local tier = frame.args ~= nil and frame.args[1] or frame | ||
local | local slayerTier = nil | ||
if tier == nil then | if tier == nil then | ||
return "ERROR: No tier specified[[Category:Pages with script errors]]" | return "ERROR: No tier specified[[Category:Pages with script errors]]" | ||
end | |||
if tonumber(tier) ~= nil then | |||
slayerTier = Constants.getSlayerTierByID(tonumber(tier)) | |||
else | else | ||
slayerTier = Constants.getSlayerTier(tier) | |||
end | |||
if slayerTier == nil then | |||
return "ERROR: Invalid slayer tier[[Category:Pages with script errors]]" | |||
end | end | ||
-- Obtain required tier details | -- Obtain required tier details | ||
local minLevel, maxLevel = | local minLevel, maxLevel = slayerTier.minLevel, slayerTier.maxLevel | ||
if maxLevel < 0 then | if maxLevel < 0 then | ||
maxLevel = nil | maxLevel = nil | ||
Line 980: | Line 994: | ||
--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 | ||
local | local tableParts = {} | ||
table.insert(tableParts, '{| class="wikitable sortable stickyHeader"') | |||
-- First header row | -- First header row | ||
table.insert(tableParts, '\r\n|- class="headerRow-0"\r\n! colspan="5" | !! colspan="4" |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 !!ID !!Combat Level ') | |||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Hitpoints', type='skill'})) | |||
table.insert(tableParts, '!!Attack Type !!Attack Speed (s) !!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({'Ranged', type='skill', notext=true})) | |||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Magic', type='skill', notext=true})) | |||
table.insert(tableParts, '!!Drop Chance !!Coins !!Bones !!Locations') | |||
-- Generate row per monster | -- Generate row per monster | ||
Line 1,017: | Line 1,032: | ||
end | end | ||
table.insert(tableParts, '\r\n|-\r\n|style="text-align: left;" |' .. Icons.Icon({monster.name, type='monster', size=50, notext=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:left" |[[' .. monster.name .. ']]') | |||
table.insert(tableParts, '\r\n|style="text-align:right" |' .. monsterID) | |||
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="' .. monster.hitpoints .. '" |' .. Shared.formatnum(p._getMonsterHP(monster))) | |||
table.insert(tableParts, '\r\n|style="text-align:right;white-space:nowrap" |' .. p._getMonsterStyleIcon({monster, nolink='true'})) | |||
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: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[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="' .. lootChance .. '" |' .. lootChance .. '%') | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. (gpRange[1] + gpRange[2]) / 2 .. '" |' .. gpTxt) | |||
table.insert(tableParts, '\r\n|style="text-align:center" |' .. boneTxt) | |||
table.insert(tableParts, '\r\n|style="text-align:right;white-space:nowrap" |' .. p._getMonsterAreas(monster, hideDungeons)) | |||
end | end | ||
table.insert(tableParts, '\r\n|}') | |||
return | return table.concat(tableParts) | ||
end | end | ||
return p | return p |