Module:Creatures: Difference between revisions
Jump to navigation
Jump to search
TheGmaster (talk | contribs) No edit summary |
TheGmaster (talk | contribs) mNo edit summary |
||
(293 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function | function p.singleCreature(frame) | ||
local | local creatureArray = mw.loadData("Module:WildCreatureData") -- Array containing wild creature data from another module | ||
local | |||
local creatureName = frame.args[1] | |||
local creatureType = frame.args[2] | |||
local imageOverride = frame.args[3] | |||
local namespace = frame.args[4] | |||
local iconImage = "" | |||
local wikiTable = "" | |||
local array = creatureArray | |||
-- Change the array being pulled from if a valid creatureType is provided, also formats the creatureType to be used in Err messages and sets an iconImage | |||
if string.lower(creatureType) == "strangelands" then | |||
array = mw.loadData("Module:StrangelandsCreatureData") | |||
creatureType = " " .. creatureType .. "" | |||
iconImage = "[[File:icon-strangelands.png|right|50px|link=Strangelands#Strangelands_Creatures|Strangeland Creature]]" | |||
elseif string.lower(creatureType) == "ships" then | |||
array = mw.loadData("Module:ShipCreatureData") | |||
creatureType = " " .. creatureType .. "" | |||
iconImage = "[[File:shipdeed.png|right|30px|link=Ships|Ship Creature]]" | |||
else | |||
creatureType = " wild " | |||
end | |||
local creature = array[creatureName] | |||
if creature then | |||
local formmatedName = string.gsub(string.lower(creatureName), "%s+", "") | |||
local imageName = string.gsub(formmatedName, "%p+", "") .. ".jpg" | |||
if imageOverride and imageOverride ~= "" then | |||
imageName = imageOverride | |||
end | |||
-- Automaticly add categories | |||
if namespace == "" or namespace == nil then | |||
wikiTable = wikiTable .. "[[Category:" .. creature.location .. "]]" | |||
wikiTable = wikiTable .. "[[Category:" .. creature.slayer .. " Creatures]]" | |||
if creature.bosstype ~= "" then | |||
wikiTable = wikiTable .. "[[Category:" .. creature.bosstype .. "es]] [[Category:Bosses]]" | |||
end | |||
end | |||
wikiTable = [=[__NOTOC__ | |||
<table class="wikitable" style="text-align:center"> | |||
<th style="border-right:none; border-bottom:none; width:110px"> | |||
<th colspan="7" style="border-width: 1px 0px 0px; height:100px; vertical-align:bottom;"> [[File:]=] .. | |||
imageName .. [=[|link=]] | |||
<th style="vertical-align:top; border-left:none; border-bottom:none; margin-left: 15px; width:110px>]=] .. | |||
iconImage .. [=[ | |||
<tr> | |||
<th style="border-top:none" colspan="9">[[]=] .. creatureName .. [=[]] | |||
<tr> | |||
<th>Slayer | |||
<th>Difficulty | |||
<th>Gold Value | |||
<th>Hits | |||
<th colspan="2">Melee Damage | |||
<th>Wrestling | |||
<th>Armor | |||
<th>Magic Resist | |||
<tr> | |||
<td>]=] .. creature.slayer .. [=[ | |||
<td>]=] .. creature.difficulty .. [=[ | |||
<td>]=] .. creature.goldvalue .. [=[ | |||
<td>]=] .. creature.hits .. [=[ | |||
<td colspan="2">]=] .. creature.minmeleedmg .. creature.maxmeleedmg .. [=[ | |||
<td>]=] .. creature.wrestling .. [=[ | |||
<td>]=] .. creature.armor .. creature.armormin .. [=[ | |||
<td>]=] .. creature.magicresist .. creature.magicresistmin .. [=[ | |||
<tr> | |||
<th>Parry | |||
<th>Attack Speed | |||
<th>Magery | |||
<th colspan="2">Spell Damage | |||
<th>Poison | |||
<th>Poison Resist | |||
<th>Stealth | |||
<th>AI | |||
<tr> | |||
<td>]=] .. creature.parry .. [=[ | |||
<td>]=] .. creature.atkspd .. [=[ | |||
<td>]=] .. creature.magery .. [=[ | |||
<td colspan="2">]=] .. creature.minspelldmg .. creature.maxspelldmg .. [=[ | |||
<td>]=] .. creature.poisontype .. [=[ | |||
<td>]=] .. creature.poisonresist .. creature.poisonresistmin .. [=[ | |||
<td>]=] .. creature.stealth .. [=[ | |||
<td>]=] .. creature.ai .. "</table>" | |||
return wikiTable | |||
else | |||
return '<h1 style="color:FireBrick;"><big>Creature Table Template Error: No' .. | |||
creatureType .. 'creature by the name "' .. creatureName .. '" was found (Case-sensitive)</big></h1>' | |||
end | |||
end | |||
function p.singleFollower(frame) | |||
local creatureArray = mw.loadData("Module:WildCreatureData") | |||
local tameableArray = mw.loadData("Module:TameableCreatureData") | |||
local summonArray = mw.loadData("Module:SummonableCreatureData") | |||
-- Parameters passed when the function is invoked | |||
local followerName = frame.args[1] -- Sun Wyrm | |||
local imageOverride = frame.args[2] -- sunwyrm.png | |||
local followerType = frame.args[3] -- Tameable/Summon | |||
local namespace = frame.args[4] -- {{NAMESPACE}} | |||
local wikiTable = "" | |||
local creature = creatureArray[followerName] | |||
local tameable = tameableArray[followerName] | |||
local summon = summonArray[followerName] | |||
if string.lower(followerType) ~= "summon" and tameable then | |||
local formmatedName = string.gsub(string.lower(followerName), "%s+", "") | |||
local imageName = string.gsub(formmatedName, "%p+", "") .. ".jpg" | |||
if imageOverride and imageOverride ~= "" then | |||
imageName = imageOverride | |||
end | |||
-- Automaticlly add categories | |||
if namespace == "" or namespace == nil then | |||
if creature then | |||
wikiTable = wikiTable .. "[[Category:" .. creature.location .. "]]" | |||
wikiTable = wikiTable .. "[[Category:" .. creature.slayer .. " Creatures]]" | |||
end | |||
wikiTable = wikiTable .. "[[Category:Tameable Creatures]]" | |||
wikiTable = wikiTable .. "[[Category:" .. tameable.class .. " Class Tameable]]" | |||
wikiTable = wikiTable .. "[[Category:" .. tameable.combat .. " Tameable]]" | |||
end | |||
wikiTable = [=[__NOTOC__ | |||
<table class="wikitable" style="text-align:center"> | |||
<th style="border-right:none; border-bottom:none; width:110px"> | |||
<th colspan="6" style="border-width: 1px 0px 0px; height:100px; vertical-align:bottom;"> [[File:]=] .. | |||
imageName .. [=[|link=]] | |||
<th style="vertical-align:top; border-left:none; border-bottom:none; margin-left: 15px; width:110px>[[File:icon-]=] .. | |||
string.lower(tameable.class) .. [=[class.png|link=Animal_Taming#Tamed_Classes|]=] .. | |||
tameable.class .. [=[ Class|right]] | |||
<tr> | |||
<th style="border-top:none" colspan="8">[[]=] .. followerName .. [=[]] | |||
<tr> | |||
<th>Min Taming | |||
<th>Control Slots | |||
<th>Hits | |||
<th>Class | |||
<th colspan="2">]=] .. tameable.combat .. [=[ Damage | |||
<th>Armor | |||
<th>Wrestling | |||
<tr> | |||
<td>]=] .. tameable.taming .. [=[ | |||
<td>]=] .. tameable.slots .. [=[ | |||
<td>]=] .. tameable.hits .. [=[ | |||
<td>]=] .. tameable.class .. [=[ | |||
<td colspan="2>]=] .. tameable.mindmg .. " - " .. tameable.maxdmg .. [=[ | |||
<td>]=] .. tameable.armor .. tameable.armormin .. [=[ | |||
<td>]=] .. tameable.wrestling .. [=[ | |||
<tr> | |||
<th>Attack Speed | |||
<th>Magic Resist | |||
<th>Poison Resist | |||
<th>Special Resist | |||
<th>Poison | |||
<th>Poisoning | |||
<th>Stealth | |||
<th>Underdog Scalar | |||
<tr> | |||
<td>]=] .. tameable.atkspd .. [=[ | |||
<td>]=] .. tameable.magicresist .. tameable.magicresistmin .. [=[ | |||
<td>]=] .. tameable.poisonresist .. tameable.poisonresistmin .. [=[ | |||
<td>]=] .. tameable.specialresist .. [=[ | |||
<td>]=] .. tameable.poisontype .. [=[ | |||
<td>]=] .. tameable.poisoning .. [=[ | |||
<td>]=] .. tameable.stealth .. [=[ | |||
<td>]=] .. tameable.underdogscalar .. "</table>" | |||
return wikiTable | |||
elseif string.lower(followerType) ~= "tameable" and summon then | |||
local formmatedName = string.gsub(string.lower(followerName), "%s+", "") | |||
local imageName = string.gsub(formmatedName, "%p+", "") .. ".jpg" | |||
local spelliconImage = "[[File:" .. | |||
summon.spellicon .. | |||
".png|44px|link=Spirit Speak#" .. summon.spellname .. "|" .. summon.spellname .. summon.tometier .. "|right]]" | |||
if summon.necro == true then | |||
spelliconImage = spelliconImage .. | |||
"[[File:SpellPlus.png|right]]<br><br>[[File:iconvengefulspirit.png|link=Necromancy#Undead Summons|Vengeful Spirit|right]]" | |||
end | |||
if imageOverride and imageOverride ~= "" then | |||
imageName = imageOverride | |||
end | |||
-- Automaticlly add categories | |||
if namespace == "" or namespace == nil then | |||
if creature then | |||
wikiTable = wikiTable .. "[[Category:" .. creature.location .. "]]" | |||
wikiTable = wikiTable .. "[[Category:" .. creature.slayer .. " Creatures]]" | |||
end | |||
wikiTable = wikiTable .. "[[Category:Summonable Creatures]]" | |||
end | |||
wikiTable = [=[__NOTOC__ | |||
<table class="wikitable" style="text-align:center"> | |||
<th style="border-right:none; border-bottom:none; width:110px"> | |||
<th colspan="5" style="border-width: 1px 0px 0px; height:100px; vertical-align:bottom;"> [[File:]=] .. | |||
imageName .. [=[|link=]] | |||
<th style="vertical-align:top; border-left:none; border-bottom:none; margin-left: 5px; width:110px>]=] .. | |||
spelliconImage .. [=[ | |||
<tr> | |||
<th style="border-top:none" colspan="7">[[]=] .. followerName .. [=[]] | |||
<tr> | |||
<th>Spell | |||
<th>Control Slots | |||
<th>Hits | |||
<th colspan="2">]=] .. summon.combat .. [=[ Damage | |||
<th>Armor | |||
<th>Wrestling | |||
<tr> | |||
<td>]=] .. summon.spellname .. summon.tometier .. [=[ | |||
<td>]=] .. summon.slots .. [=[ | |||
<td>]=] .. summon.hits .. [=[ | |||
<td colspan="2>]=] .. summon.mindmg .. " - " .. summon.maxdmg .. [=[ | |||
<td>]=] .. summon.armor .. summon.armormin .. [=[ | |||
<td>]=] .. summon.wrestling .. [=[ | |||
<tr> | |||
<th>Attack Speed | |||
<th>Magic Resist | |||
<th>Poison Resist | |||
<th>Special Resist | |||
<th>Poison | |||
<th>Poisoning | |||
<th>Stealth | |||
<tr> | |||
<td>]=] .. summon.atkspd .. [=[ | |||
<td>]=] .. summon.magicresist .. summon.magicresistmin .. [=[ | |||
<td>]=] .. summon.poisonresist .. summon.poisonresistmin .. [=[ | |||
<td>]=] .. summon.specialresist .. [=[ | |||
<td>]=] .. summon.poisontype .. [=[ | |||
<td>]=] .. summon.poisoning .. [=[ | |||
<td>]=] .. summon.stealth .. "</table>" | |||
return wikiTable | |||
else | |||
return '<h1 style="color:FireBrick;"><big>FollowerTable Template Error: No tamed/summoned follower found by the name "' .. | |||
followerName .. '" (Case-sensitive)</big></h1>' | |||
end | |||
end | |||
function p.listSlayerGroup(frame) | |||
local creatureArray = mw.loadData("Module:WildCreatureData") | |||
local slayerGroup = frame.args[1] | |||
local position = frame.args[2] | |||
local wikiTable = "" | |||
if position and string.find(string.lower(position), "start") then | |||
wikiTable = [[<table class="wikitable sortable" style="text-align:center"> | |||
<th>Name | |||
<th>Location | |||
<th>Slayer | |||
<th>Difficulty | |||
<th>Gold Value | |||
<th>Hits | |||
<th colspan="2">Melee Dmg | |||
<th>Wrestling | |||
<th>Armor | |||
<th>Magic Resist | |||
<th>Parry | |||
<th>AtkSpd | |||
<th>Magery | |||
<th colspan="2">Spell Dmg | |||
<th>Poison | |||
<th>Poisoning | |||
<th>Poison Resist | |||
<th>Stealth | |||
<th>AI | |||
<th>Speed | |||
<th>Unique Scalar]] | |||
else | |||
wikiTable = "" | |||
end | |||
for creatureName, creature in pairs(creatureArray) do | |||
if creature.slayer == slayerGroup then | |||
wikiTable = wikiTable .. [=[<tr> | |||
<td>[[]=] .. creatureName .. [=[]] | |||
<td>]=] .. creature.location .. [=[ | |||
<td>]=] .. creature.slayer .. [[ | |||
<td>]] .. creature.difficulty .. [[ | |||
<td>]] .. creature.goldvalue .. [[ | |||
<td>]] .. creature.hits .. [[ | |||
<td colspan="2">]] .. creature.minmeleedmg .. creature.maxmeleedmg .. [[ | |||
<td>]] .. creature.wrestling .. [[ | |||
<td>]] .. creature.armor .. creature.armormin .. [[ | |||
<td>]] .. creature.magicresist .. creature.magicresistmin .. [[ | |||
<td>]] .. creature.parry .. [[ | |||
<td>]] .. creature.atkspd .. [[ | |||
<td>]] .. creature.magery .. [[ | |||
<td colspan="2">]] .. creature.minspelldmg .. creature.maxspelldmg .. [[ | |||
<td>]] .. creature.poisontype .. [[ | |||
<td>]] .. creature.poisoning .. [[ | |||
<td>]] .. creature.poisonresist .. creature.poisonresistmin .. [[ | |||
<td>]] .. creature.stealth .. [[ | |||
<td>]] .. creature.ai .. [[ | |||
<td>]] .. creature.speed .. [[ | |||
<td>]] .. creature.uniquescalar | |||
end | |||
end | |||
if position and position and string.find(string.lower(position), "end") then | |||
wikiTable = wikiTable .. "</table>" | |||
end | end | ||
return | return wikiTable | ||
end | end | ||
function p. | function p.listLocationGroup(frame) | ||
local locationGroup = frame.args[1] | |||
local position = frame.args[2] | |||
local wikiTable = "" | |||
local array = creatureArray | |||
if string.lower(locationGroup) == "strangelands" then | |||
array = mw.loadData("Module:StrangelandsCreatureData") | |||
elseif string.lower(locationGroup) == "ships" then | |||
array = mw.loadData("Module:ShipCreatureData") | |||
end | |||
if position and string.find(string.lower(position), "start") then | |||
wikiTable = [[<table class="wikitable sortable" style="text-align:center"> | |||
<th>Name | |||
<th>Slayer | |||
<th>Difficulty | |||
<th>Gold Value | |||
<th>Hits | |||
<th colspan="2">Melee Dmg | |||
<th>Wrestling | |||
<th>Armor | |||
<th>Magic Resist | |||
<th>Parry | |||
<th>AtkSpd | |||
<th>Magery | |||
<th colspan="2">Spell Dmg | |||
<th>Poison | |||
<th>Poisoning | |||
<th>Poison Resist | |||
<th>Stealth | |||
<th>AI | |||
<th>Speed | |||
<th>Unique Scalar]] | |||
end | |||
for creatureName, creature in pairs(array) do | |||
if string.find(creature.location, "[[" .. locationGroup .. "]]") then | |||
wikiTable = wikiTable .. [=[<tr> | |||
<td>[[]=] .. creatureName .. [=[]] | |||
<td>]=] .. creature.slayer .. [[ | |||
<td>]] .. creature.difficulty .. [[ | |||
<td>]] .. creature.goldvalue .. [[ | |||
<td>]] .. creature.hits .. [[ | |||
<td colspan="2">]] .. creature.minmeleedmg .. creature.maxmeleedmg .. [[ | |||
<td>]] .. creature.wrestling .. [[ | |||
<td>]] .. creature.armor .. creature.armormin .. [[ | |||
<td>]] .. creature.magicresist .. creature.magicresistmin .. [[ | |||
<td>]] .. creature.parry .. [[ | |||
<td>]] .. creature.atkspd .. [[ | |||
<td>]] .. creature.magery .. [[ | |||
<td colspan="2">]] .. creature.minspelldmg .. creature.maxspelldmg .. [[ | |||
<td>]] .. creature.poisontype .. [[ | |||
<td>]] .. creature.poisoning .. [[ | |||
<td>]] .. creature.poisonresist .. creature.poisonresistmin .. [[ | |||
<td>]] .. creature.stealth .. [[ | |||
<td>]] .. creature.ai .. [[ | |||
<td>]] .. creature.speed .. [[ | |||
<td>]] .. creature.uniquescalar | |||
end | |||
end | |||
if position and position and string.find(string.lower(position), "end") then | |||
wikiTable = wikiTable .. "</table>" | |||
end | |||
return wikiTable | |||
end | |||
function p.listBosses(frame) | |||
local creatureArray = mw.loadData("Module:WildCreatureData") | |||
local bossesToList = frame.args[1] -- Main Boss | |||
local typeOfBoss = string.lower(bossesToList) | |||
local wikiTable = [[<table class="wikitable sortable" style="text-align:center"> | |||
<th>Name | |||
<th>Location | |||
<th>Slayer | |||
<th>Difficulty | |||
<th>Base Hits | |||
<th colspan="2">Melee Damage | |||
<th>Wrestling | |||
<th>Armor | |||
<th>Magic Resist | |||
<th>Parry | |||
<th>Magery | |||
<th colspan="2">Spell Damage | |||
<th>Poison | |||
<th>Poisoning | |||
<th>Poison Resist | |||
<th>Stealth]] | |||
for creatureName, creature in pairs(creatureArray) do | |||
local | if string.lower(creature.bosstype) == typeOfBoss or typeOfBoss == "all" then | ||
if creature.bosstype ~= "" and creature.bosstype ~= "Boss Summon" then | |||
local imageType = ".jpg" | |||
local imagePrefix = "" | |||
if creature.bosstype == "Main Boss" then | |||
imageType = ".gif" | |||
elseif creature.bosstype == "Shrine Boss" then | |||
imageType = ".png" | |||
elseif creature.bosstype == "Omni Boss" then | |||
imageType = ".gif" | |||
imagePrefix = "omni" | |||
end | end | ||
local formmatedName = string.gsub(string.lower(creatureName), "%s+", "") | |||
local imageName = imagePrefix .. string.gsub(formmatedName, "%p+", "") .. imageType | |||
wikiTable = wikiTable .. [[<tr> | |||
<td>]] .. "[[File:" .. imageName .. "|link=" .. creatureName .. "]]<br />[[" .. creatureName .. [=[]] | |||
<td>]=] .. creature.location .. [=[ | |||
<td>]=] .. creature.slayer .. [[ | |||
<td>]] .. creature.difficulty .. [[ | |||
<td>]] .. creature.hits .. [[ | |||
<td colspan="2">]] .. creature.minmeleedmg .. creature.maxmeleedmg .. [[ | |||
<td>]] .. creature.wrestling .. [[ | |||
<td>]] .. creature.armor .. creature.armormin .. [[ | |||
<td>]] .. creature.magicresist .. creature.magicresistmin .. [[ | |||
<td>]] .. creature.parry .. [[ | |||
<td>]] .. creature.magery .. [[ | |||
<td colspan="2">]] .. creature.minspelldmg .. creature.maxspelldmg .. [[ | |||
<td>]] .. creature.poisontype .. [[ | |||
<td>]] .. creature.poisoning .. [[ | |||
<td>]] .. creature.poisonresist .. creature.poisonresistmin .. [[ | |||
<td>]] .. creature.stealth | |||
end | |||
end | end | ||
end | |||
wikiTable = wikiTable .. "</table>" | |||
return wikiTable | |||
end | |||
function p.listAbilities(frame) | |||
local tameableArray = mw.loadData("Module:TameableCreatureData") | |||
local summonArray = mw.loadData("Module:SummonableCreatureData") | |||
local abilityArray = mw.loadData("Module:FollowerAbilityData") | |||
local creature = frame.args[1] -- Warpig | |||
local followerType = frame.args[2] -- Tameable/Summon | |||
local follower = "" | |||
if string.lower(followerType) ~= "summon" and tameableArray[creature] then | |||
follower = tameableArray[creature] | |||
elseif string.lower(followerType) ~= "tameable" and summonArray[creature] then | |||
follower = summonArray[creature] | |||
else | |||
follower = "undefined" | |||
end | |||
local wikiTable = "" | |||
if follower and follower ~= "undefined" then -- List a follower's abilities if a follower is given | |||
wikiTable = [[<table class="wikitable" style="text-align:center"> | |||
<th>Ability | |||
<th>Type | |||
<th>Description]] | |||
local abilities = {} | |||
for i, creatureAbility in pairs({ follower.cooldownability, follower.innateability, follower.passiveability }) do | |||
if creatureAbility and creatureAbility ~= "" and type(creatureAbility) == "table" then | |||
for index, ability in pairs(creatureAbility) do | |||
table.insert(abilities, ability) | |||
end | |||
elseif creatureAbility and creatureAbility ~= "" then | |||
table.insert(abilities, creatureAbility) | |||
end | end | ||
end | |||
for i, ability in pairs(abilities) do | |||
wikiTable = wikiTable .. [[<tr> | |||
<td>]] .. ability .. [[ | |||
<td>]] .. abilityArray[ability].type .. [[ | |||
<td style="text-align:left">]] .. abilityArray[ability].description | |||
end | |||
elseif follower == "undefined" then -- List all abilities and the followers that have them | |||
wikiTable = [[<table class="wikitable sortable" style="text-align:center"> | |||
<th>Ability | |||
<th>Type | |||
<th>Description | |||
<th>Creatures]] | |||
for abilityName, ability in pairs(abilityArray) do | |||
wikiTable = wikiTable .. [[<tr> | |||
<td>]] .. abilityName .. [[ | |||
<td>]] .. ability.type .. [[ | |||
<td style="text-align:left">]] .. ability.description .. [[<td>]] | |||
-- Find and list any followers with the ability | |||
for i, array in pairs({ tameableArray, summonArray }) do | |||
for followerName, followerStats in pairs(array) do | |||
local followerAbilityType = "" | |||
if ability.type == "Cooldown" then | |||
followerAbilityType = followerStats.cooldownability | |||
elseif ability.type == "Innate" then | |||
followerAbilityType = followerStats.innateability | |||
elseif ability.type == "Passive" then | |||
followerAbilityType = followerStats.passiveability | |||
end | |||
if type(followerAbilityType) == "table" then | |||
for creatureName, value in pairs(followerAbilityType) do | |||
if value == abilityName then | |||
if array == summonArray and tameableArray[followerName] and summonArray[followerName] then | |||
wikiTable = wikiTable .. "[[" .. followerName .. "|"..followerName.." (Summon)]],<br>" | |||
else | |||
wikiTable = wikiTable .. "[[" .. followerName .. "]],<br>" | |||
end | |||
end | |||
end | |||
elseif followerAbilityType == abilityName then | |||
if array == summonArray and tameableArray[followerName] and summonArray[followerName] then | |||
wikiTable = wikiTable .. "[[" .. followerName .. "|"..followerName.." (Summon)]],<br>" | |||
else | |||
wikiTable = wikiTable .. "[[" .. followerName .. "]],<br>" | |||
end | |||
end | |||
end | end | ||
end | |||
-- Cut out the extra line break | |||
if string.find(wikiTable, "<br>") then | |||
wikiTable = string.reverse(wikiTable) | |||
wikiTable = string.sub(wikiTable, 6) | |||
wikiTable = string.reverse(wikiTable) | |||
end | |||
end | |||
else -- If a follower is given but doesn't exist | |||
return | |||
'<h1 style="color:FireBrick;"><big>Follower Ability Table Template Error: No tamed/summoned follower found by the name "' .. | |||
creature .. '" (Case-sensitive)</big></h1>' | |||
end | |||
wikiTable = wikiTable .. "</table>" | |||
return wikiTable | |||
end | |||
function p.summonStatIncrease(frame) | |||
local summonArray = mw.loadData("Module:SummonableCreatureData") | |||
local summonName = frame.args[1] -- A summon given to display, defaults to {{PAGENAME}} | |||
local wikiTable = '<table class="wikitable" style="text-align:center">' | |||
local summon = summonArray[summonName] | |||
if summon then | |||
local stats = { | |||
["hits"] = summon.unformattedhits, | |||
["atkspd"] = summon.atkspd, | |||
["mindmg"] = summon.mindmg, | |||
["maxdmg"] = summon.maxdmg, | |||
["wrestling"] = summon.wrestling, | |||
["armor"] = summon.armor, | |||
["magicresist"] = summon.magicresist | |||
} | |||
for statName, stat in pairs(stats) do | |||
if type(stats[statName]) == "string" then | |||
stats[statName] = 0 | |||
end | |||
end | end | ||
wikiTable = wikiTable .. [=[<th colspan="6">[[File:]=] .. summon.spellicon .. [=[.png|center|link=]]<br>[[]=] .. summonName .. [=[]] | |||
<tr> | |||
<th rowspan="2">Stat | |||
<th colspan="5"> Spirit Speak Skill | |||
<tr> | |||
<th>Base | |||
<th>80 | |||
<th>100 | |||
<th>120 | |||
<th>150 | |||
<tr> | |||
<th>Hits | |||
<td>]=] .. stats.hits .. [[ | |||
<td>]] .. stats.hits * 1.5 * (80 / 100) .. [[ | |||
<td>]] .. stats.hits * 1.5 * (100 / 100) .. [[ | |||
<td>]] .. stats.hits * 1.5 * (120 / 100) .. [[ | |||
<td>]] .. stats.hits * 1.5 * (150 / 100) .. [[ | |||
<tr> | |||
<th>Attack Speed | |||
<td>]] .. stats.atkspd .. [[ | |||
<td>]] .. stats.atkspd * 1.125 * (80 / 100) .. [[ | |||
<td>]] .. stats.atkspd * 1.125 * (100 / 100) .. [[ | |||
<td>]] .. stats.atkspd * 1.125 * (120 / 100) .. [[ | |||
<td>]] .. stats.atkspd * 1.125 * (150 / 100) .. [[ | |||
<tr> | |||
<th>]] .. summon.combat .. [[ Damage | |||
<td>]] .. stats.mindmg .. " - " .. stats.maxdmg .. [[ | |||
<td>]] .. stats.mindmg * 1.25 * (80 / 100) .. " - " .. stats.maxdmg * 1.25 * (80 / 100) .. [[ | |||
<td>]] .. stats.mindmg * 1.25 * (100 / 100) .. " - " .. stats.maxdmg * 1.25 * (100 / 100) .. [[ | |||
<td>]] .. stats.mindmg * 1.25 * (120 / 100) .. " - " .. stats.maxdmg * 1.25 * (120 / 100) .. [[ | |||
<td>]] .. stats.mindmg * 1.25 * (150 / 100) .. " - " .. stats.maxdmg * 1.25 * (150 / 100) .. [[ | |||
<tr> | |||
<th>Wrestling | |||
<td>]] .. stats.wrestling .. [[ | |||
<td>]] .. stats.wrestling * 1.25 * (80 / 100) .. [[ | |||
<td>]] .. stats.wrestling * 1.25 * (100 / 100) .. [[ | |||
<td>]] .. stats.wrestling * 1.25 * (120 / 100) .. [[ | |||
<td>]] .. stats.wrestling * 1.25 * (150 / 100) .. [[ | |||
<tr> | |||
<th>Armor | |||
<td>]] .. stats.armor .. [[ | |||
<td>]] .. stats.armor + (25 * (80 / 100)) .. [[ | |||
<td>]] .. stats.armor + (25 * (100 / 100)) .. [[ | |||
<td>]] .. stats.armor + (25 * (120 / 100)) .. [[ | |||
<td>]] .. stats.armor + (25 * (150 / 100)) .. [[ | |||
<tr> | |||
<th>Magic Resist | |||
<td>]] .. stats.magicresist .. [[ | |||
<td>]] .. stats.magicresist + (50 * (80 / 100)) .. [[ | |||
<td>]] .. stats.magicresist + (50 * (100 / 100)) .. [[ | |||
<td>]] .. stats.magicresist + (50 * (120 / 100)) .. [[ | |||
<td>]] .. stats.magicresist + (50 * (150 / 100)) .. [[ | |||
</table>]] | |||
return wikiTable | return wikiTable | ||
else | |||
return '<h1 style="color:FireBrick;"><big>Summon Stat Table Template Error: No summoned follower found by the name "' .. | |||
summonName .. '" (Case-sensitive)</big></h1>' | |||
end | |||
end | |||
function p.checkCreatureValue(frame) | |||
local creatureName = frame.args[1] -- Name of the creature to check for | |||
local creatureType = frame.args[2] -- Wild/Tameable/Summonable/Ships/Strangelands, defaults to Wild | |||
local creatureStat = frame.args[3] -- location/name/slayer | |||
local value = frame.args[4] -- Aegis Keep/Molten Mongbat/Deamonic/true, defaults to true (has value) | |||
if not creatureStat or creatureStat == "" then | |||
creatureStat = "name" | |||
end | |||
local dataSource | |||
-- Set the requested data source | |||
if creatureType and string.lower(creatureType) == "tameable" then | |||
dataSource = mw.loadData("Module:TameableCreatureData") | |||
elseif creatureType and string.lower(creatureType) == "summonable" then | |||
dataSource = mw.loadData("Module:SummonableCreatureData") | |||
elseif creatureType and string.lower(creatureType) == "ships" then | |||
dataSource = mw.loadData("Module:ShipCreatureData") | |||
elseif creatureType and string.lower(creatureType) == "tameable" then | |||
dataSource = mw.loadData("Module:TameableCreatureData") | |||
elseif creatureType and string.lower(creatureType) == "strangelands" then | |||
dataSource = mw.loadData("Module:StrangelandsCreatureData") | |||
else | |||
dataSource = mw.loadData("Module:WildCreatureData") | |||
end | |||
local creature = dataSource[creatureName] | |||
if creature then | |||
local stat = creature[creatureStat] | |||
if creatureStat == "name" then | |||
return true -- "creature match found in datasource" | |||
elseif not value or value == "" then | |||
if stat then | |||
return true -- "stat exists for this creature" | |||
else | |||
return false -- "stat does not exist for this creature" | |||
end | |||
else | |||
if stat and string.lower(stat) == string.lower(value) then | |||
return true -- "stat is equal to the value" | |||
else | |||
return false -- "stat is not equal to the value or doesn't exist" | |||
end | |||
end | |||
else | |||
return false -- "creature not found in datasource" | |||
end | |||
end | |||
function p.creaturePage(frame) | |||
local creature = frame.args[1] | |||
local imageOverride = frame.args[2] | |||
local page = "" | |||
local creatureArray = mw.loadData("Module:WildCreatureData") | |||
local tameableArray = mw.loadData("Module:TameableCreatureData") | |||
local summonArray = mw.loadData("Module:SummonableCreatureData") | |||
local strangelandsArray = mw.loadData("Module:StrangelandsCreatureData") | |||
local shipsArray = mw.loadData("Module:ShipCreatureData") | |||
if creatureArray[creature] then | |||
page = page.."{{CreatureTable|image="..imageOverride.."}}\n" | |||
end | |||
if shipsArray[creature] then | |||
page = page..[[== Ship Creature Stats == | |||
{{CreatureTable|type=ships|image=]]..imageOverride.."}}\n" | |||
end | |||
if tameableArray[creature] then | |||
page = page..[[== Tameable Stats == | |||
{{FollowerTable|type=tameable|image=]]..imageOverride..[[}} | |||
{{FollowerAbilities|type=tameable}} | |||
{{TamedScalarLevels}}\n]] | |||
end | |||
if summonArray[creature] then | |||
page = page..[[== Summoned Creature Stats == | |||
{{FollowerTable|type=summon|image=]]..imageOverride..[[}} | |||
{{FollowerAbilities|type=summon}} | |||
{{SummonStatIncrease}}\n]] | |||
end | |||
if strangelandsArray[creature] then | |||
page = page..[[== Strangelands Creature Stats== | |||
{{CreatureTable|type=strangelands|image=]]..imageOverride..[[}}\n]] | |||
end | |||
return page | |||
end | end | ||
return p | return p |
Latest revision as of 04:37, 9 November 2024
Documentation for this module may be created at Module:Creatures/doc
local p = {} function p.singleCreature(frame) local creatureArray = mw.loadData("Module:WildCreatureData") -- Array containing wild creature data from another module local creatureName = frame.args[1] local creatureType = frame.args[2] local imageOverride = frame.args[3] local namespace = frame.args[4] local iconImage = "" local wikiTable = "" local array = creatureArray -- Change the array being pulled from if a valid creatureType is provided, also formats the creatureType to be used in Err messages and sets an iconImage if string.lower(creatureType) == "strangelands" then array = mw.loadData("Module:StrangelandsCreatureData") creatureType = " " .. creatureType .. "" iconImage = "[[File:icon-strangelands.png|right|50px|link=Strangelands#Strangelands_Creatures|Strangeland Creature]]" elseif string.lower(creatureType) == "ships" then array = mw.loadData("Module:ShipCreatureData") creatureType = " " .. creatureType .. "" iconImage = "[[File:shipdeed.png|right|30px|link=Ships|Ship Creature]]" else creatureType = " wild " end local creature = array[creatureName] if creature then local formmatedName = string.gsub(string.lower(creatureName), "%s+", "") local imageName = string.gsub(formmatedName, "%p+", "") .. ".jpg" if imageOverride and imageOverride ~= "" then imageName = imageOverride end -- Automaticly add categories if namespace == "" or namespace == nil then wikiTable = wikiTable .. "[[Category:" .. creature.location .. "]]" wikiTable = wikiTable .. "[[Category:" .. creature.slayer .. " Creatures]]" if creature.bosstype ~= "" then wikiTable = wikiTable .. "[[Category:" .. creature.bosstype .. "es]] [[Category:Bosses]]" end end wikiTable = [=[__NOTOC__ <table class="wikitable" style="text-align:center"> <th style="border-right:none; border-bottom:none; width:110px"> <th colspan="7" style="border-width: 1px 0px 0px; height:100px; vertical-align:bottom;"> [[File:]=] .. imageName .. [=[|link=]] <th style="vertical-align:top; border-left:none; border-bottom:none; margin-left: 15px; width:110px>]=] .. iconImage .. [=[ <tr> <th style="border-top:none" colspan="9">[[]=] .. creatureName .. [=[]] <tr> <th>Slayer <th>Difficulty <th>Gold Value <th>Hits <th colspan="2">Melee Damage <th>Wrestling <th>Armor <th>Magic Resist <tr> <td>]=] .. creature.slayer .. [=[ <td>]=] .. creature.difficulty .. [=[ <td>]=] .. creature.goldvalue .. [=[ <td>]=] .. creature.hits .. [=[ <td colspan="2">]=] .. creature.minmeleedmg .. creature.maxmeleedmg .. [=[ <td>]=] .. creature.wrestling .. [=[ <td>]=] .. creature.armor .. creature.armormin .. [=[ <td>]=] .. creature.magicresist .. creature.magicresistmin .. [=[ <tr> <th>Parry <th>Attack Speed <th>Magery <th colspan="2">Spell Damage <th>Poison <th>Poison Resist <th>Stealth <th>AI <tr> <td>]=] .. creature.parry .. [=[ <td>]=] .. creature.atkspd .. [=[ <td>]=] .. creature.magery .. [=[ <td colspan="2">]=] .. creature.minspelldmg .. creature.maxspelldmg .. [=[ <td>]=] .. creature.poisontype .. [=[ <td>]=] .. creature.poisonresist .. creature.poisonresistmin .. [=[ <td>]=] .. creature.stealth .. [=[ <td>]=] .. creature.ai .. "</table>" return wikiTable else return '<h1 style="color:FireBrick;"><big>Creature Table Template Error: No' .. creatureType .. 'creature by the name "' .. creatureName .. '" was found (Case-sensitive)</big></h1>' end end function p.singleFollower(frame) local creatureArray = mw.loadData("Module:WildCreatureData") local tameableArray = mw.loadData("Module:TameableCreatureData") local summonArray = mw.loadData("Module:SummonableCreatureData") -- Parameters passed when the function is invoked local followerName = frame.args[1] -- Sun Wyrm local imageOverride = frame.args[2] -- sunwyrm.png local followerType = frame.args[3] -- Tameable/Summon local namespace = frame.args[4] -- {{NAMESPACE}} local wikiTable = "" local creature = creatureArray[followerName] local tameable = tameableArray[followerName] local summon = summonArray[followerName] if string.lower(followerType) ~= "summon" and tameable then local formmatedName = string.gsub(string.lower(followerName), "%s+", "") local imageName = string.gsub(formmatedName, "%p+", "") .. ".jpg" if imageOverride and imageOverride ~= "" then imageName = imageOverride end -- Automaticlly add categories if namespace == "" or namespace == nil then if creature then wikiTable = wikiTable .. "[[Category:" .. creature.location .. "]]" wikiTable = wikiTable .. "[[Category:" .. creature.slayer .. " Creatures]]" end wikiTable = wikiTable .. "[[Category:Tameable Creatures]]" wikiTable = wikiTable .. "[[Category:" .. tameable.class .. " Class Tameable]]" wikiTable = wikiTable .. "[[Category:" .. tameable.combat .. " Tameable]]" end wikiTable = [=[__NOTOC__ <table class="wikitable" style="text-align:center"> <th style="border-right:none; border-bottom:none; width:110px"> <th colspan="6" style="border-width: 1px 0px 0px; height:100px; vertical-align:bottom;"> [[File:]=] .. imageName .. [=[|link=]] <th style="vertical-align:top; border-left:none; border-bottom:none; margin-left: 15px; width:110px>[[File:icon-]=] .. string.lower(tameable.class) .. [=[class.png|link=Animal_Taming#Tamed_Classes|]=] .. tameable.class .. [=[ Class|right]] <tr> <th style="border-top:none" colspan="8">[[]=] .. followerName .. [=[]] <tr> <th>Min Taming <th>Control Slots <th>Hits <th>Class <th colspan="2">]=] .. tameable.combat .. [=[ Damage <th>Armor <th>Wrestling <tr> <td>]=] .. tameable.taming .. [=[ <td>]=] .. tameable.slots .. [=[ <td>]=] .. tameable.hits .. [=[ <td>]=] .. tameable.class .. [=[ <td colspan="2>]=] .. tameable.mindmg .. " - " .. tameable.maxdmg .. [=[ <td>]=] .. tameable.armor .. tameable.armormin .. [=[ <td>]=] .. tameable.wrestling .. [=[ <tr> <th>Attack Speed <th>Magic Resist <th>Poison Resist <th>Special Resist <th>Poison <th>Poisoning <th>Stealth <th>Underdog Scalar <tr> <td>]=] .. tameable.atkspd .. [=[ <td>]=] .. tameable.magicresist .. tameable.magicresistmin .. [=[ <td>]=] .. tameable.poisonresist .. tameable.poisonresistmin .. [=[ <td>]=] .. tameable.specialresist .. [=[ <td>]=] .. tameable.poisontype .. [=[ <td>]=] .. tameable.poisoning .. [=[ <td>]=] .. tameable.stealth .. [=[ <td>]=] .. tameable.underdogscalar .. "</table>" return wikiTable elseif string.lower(followerType) ~= "tameable" and summon then local formmatedName = string.gsub(string.lower(followerName), "%s+", "") local imageName = string.gsub(formmatedName, "%p+", "") .. ".jpg" local spelliconImage = "[[File:" .. summon.spellicon .. ".png|44px|link=Spirit Speak#" .. summon.spellname .. "|" .. summon.spellname .. summon.tometier .. "|right]]" if summon.necro == true then spelliconImage = spelliconImage .. "[[File:SpellPlus.png|right]]<br><br>[[File:iconvengefulspirit.png|link=Necromancy#Undead Summons|Vengeful Spirit|right]]" end if imageOverride and imageOverride ~= "" then imageName = imageOverride end -- Automaticlly add categories if namespace == "" or namespace == nil then if creature then wikiTable = wikiTable .. "[[Category:" .. creature.location .. "]]" wikiTable = wikiTable .. "[[Category:" .. creature.slayer .. " Creatures]]" end wikiTable = wikiTable .. "[[Category:Summonable Creatures]]" end wikiTable = [=[__NOTOC__ <table class="wikitable" style="text-align:center"> <th style="border-right:none; border-bottom:none; width:110px"> <th colspan="5" style="border-width: 1px 0px 0px; height:100px; vertical-align:bottom;"> [[File:]=] .. imageName .. [=[|link=]] <th style="vertical-align:top; border-left:none; border-bottom:none; margin-left: 5px; width:110px>]=] .. spelliconImage .. [=[ <tr> <th style="border-top:none" colspan="7">[[]=] .. followerName .. [=[]] <tr> <th>Spell <th>Control Slots <th>Hits <th colspan="2">]=] .. summon.combat .. [=[ Damage <th>Armor <th>Wrestling <tr> <td>]=] .. summon.spellname .. summon.tometier .. [=[ <td>]=] .. summon.slots .. [=[ <td>]=] .. summon.hits .. [=[ <td colspan="2>]=] .. summon.mindmg .. " - " .. summon.maxdmg .. [=[ <td>]=] .. summon.armor .. summon.armormin .. [=[ <td>]=] .. summon.wrestling .. [=[ <tr> <th>Attack Speed <th>Magic Resist <th>Poison Resist <th>Special Resist <th>Poison <th>Poisoning <th>Stealth <tr> <td>]=] .. summon.atkspd .. [=[ <td>]=] .. summon.magicresist .. summon.magicresistmin .. [=[ <td>]=] .. summon.poisonresist .. summon.poisonresistmin .. [=[ <td>]=] .. summon.specialresist .. [=[ <td>]=] .. summon.poisontype .. [=[ <td>]=] .. summon.poisoning .. [=[ <td>]=] .. summon.stealth .. "</table>" return wikiTable else return '<h1 style="color:FireBrick;"><big>FollowerTable Template Error: No tamed/summoned follower found by the name "' .. followerName .. '" (Case-sensitive)</big></h1>' end end function p.listSlayerGroup(frame) local creatureArray = mw.loadData("Module:WildCreatureData") local slayerGroup = frame.args[1] local position = frame.args[2] local wikiTable = "" if position and string.find(string.lower(position), "start") then wikiTable = [[<table class="wikitable sortable" style="text-align:center"> <th>Name <th>Location <th>Slayer <th>Difficulty <th>Gold Value <th>Hits <th colspan="2">Melee Dmg <th>Wrestling <th>Armor <th>Magic Resist <th>Parry <th>AtkSpd <th>Magery <th colspan="2">Spell Dmg <th>Poison <th>Poisoning <th>Poison Resist <th>Stealth <th>AI <th>Speed <th>Unique Scalar]] else wikiTable = "" end for creatureName, creature in pairs(creatureArray) do if creature.slayer == slayerGroup then wikiTable = wikiTable .. [=[<tr> <td>[[]=] .. creatureName .. [=[]] <td>]=] .. creature.location .. [=[ <td>]=] .. creature.slayer .. [[ <td>]] .. creature.difficulty .. [[ <td>]] .. creature.goldvalue .. [[ <td>]] .. creature.hits .. [[ <td colspan="2">]] .. creature.minmeleedmg .. creature.maxmeleedmg .. [[ <td>]] .. creature.wrestling .. [[ <td>]] .. creature.armor .. creature.armormin .. [[ <td>]] .. creature.magicresist .. creature.magicresistmin .. [[ <td>]] .. creature.parry .. [[ <td>]] .. creature.atkspd .. [[ <td>]] .. creature.magery .. [[ <td colspan="2">]] .. creature.minspelldmg .. creature.maxspelldmg .. [[ <td>]] .. creature.poisontype .. [[ <td>]] .. creature.poisoning .. [[ <td>]] .. creature.poisonresist .. creature.poisonresistmin .. [[ <td>]] .. creature.stealth .. [[ <td>]] .. creature.ai .. [[ <td>]] .. creature.speed .. [[ <td>]] .. creature.uniquescalar end end if position and position and string.find(string.lower(position), "end") then wikiTable = wikiTable .. "</table>" end return wikiTable end function p.listLocationGroup(frame) local locationGroup = frame.args[1] local position = frame.args[2] local wikiTable = "" local array = creatureArray if string.lower(locationGroup) == "strangelands" then array = mw.loadData("Module:StrangelandsCreatureData") elseif string.lower(locationGroup) == "ships" then array = mw.loadData("Module:ShipCreatureData") end if position and string.find(string.lower(position), "start") then wikiTable = [[<table class="wikitable sortable" style="text-align:center"> <th>Name <th>Slayer <th>Difficulty <th>Gold Value <th>Hits <th colspan="2">Melee Dmg <th>Wrestling <th>Armor <th>Magic Resist <th>Parry <th>AtkSpd <th>Magery <th colspan="2">Spell Dmg <th>Poison <th>Poisoning <th>Poison Resist <th>Stealth <th>AI <th>Speed <th>Unique Scalar]] end for creatureName, creature in pairs(array) do if string.find(creature.location, "[[" .. locationGroup .. "]]") then wikiTable = wikiTable .. [=[<tr> <td>[[]=] .. creatureName .. [=[]] <td>]=] .. creature.slayer .. [[ <td>]] .. creature.difficulty .. [[ <td>]] .. creature.goldvalue .. [[ <td>]] .. creature.hits .. [[ <td colspan="2">]] .. creature.minmeleedmg .. creature.maxmeleedmg .. [[ <td>]] .. creature.wrestling .. [[ <td>]] .. creature.armor .. creature.armormin .. [[ <td>]] .. creature.magicresist .. creature.magicresistmin .. [[ <td>]] .. creature.parry .. [[ <td>]] .. creature.atkspd .. [[ <td>]] .. creature.magery .. [[ <td colspan="2">]] .. creature.minspelldmg .. creature.maxspelldmg .. [[ <td>]] .. creature.poisontype .. [[ <td>]] .. creature.poisoning .. [[ <td>]] .. creature.poisonresist .. creature.poisonresistmin .. [[ <td>]] .. creature.stealth .. [[ <td>]] .. creature.ai .. [[ <td>]] .. creature.speed .. [[ <td>]] .. creature.uniquescalar end end if position and position and string.find(string.lower(position), "end") then wikiTable = wikiTable .. "</table>" end return wikiTable end function p.listBosses(frame) local creatureArray = mw.loadData("Module:WildCreatureData") local bossesToList = frame.args[1] -- Main Boss local typeOfBoss = string.lower(bossesToList) local wikiTable = [[<table class="wikitable sortable" style="text-align:center"> <th>Name <th>Location <th>Slayer <th>Difficulty <th>Base Hits <th colspan="2">Melee Damage <th>Wrestling <th>Armor <th>Magic Resist <th>Parry <th>Magery <th colspan="2">Spell Damage <th>Poison <th>Poisoning <th>Poison Resist <th>Stealth]] for creatureName, creature in pairs(creatureArray) do if string.lower(creature.bosstype) == typeOfBoss or typeOfBoss == "all" then if creature.bosstype ~= "" and creature.bosstype ~= "Boss Summon" then local imageType = ".jpg" local imagePrefix = "" if creature.bosstype == "Main Boss" then imageType = ".gif" elseif creature.bosstype == "Shrine Boss" then imageType = ".png" elseif creature.bosstype == "Omni Boss" then imageType = ".gif" imagePrefix = "omni" end local formmatedName = string.gsub(string.lower(creatureName), "%s+", "") local imageName = imagePrefix .. string.gsub(formmatedName, "%p+", "") .. imageType wikiTable = wikiTable .. [[<tr> <td>]] .. "[[File:" .. imageName .. "|link=" .. creatureName .. "]]<br />[[" .. creatureName .. [=[]] <td>]=] .. creature.location .. [=[ <td>]=] .. creature.slayer .. [[ <td>]] .. creature.difficulty .. [[ <td>]] .. creature.hits .. [[ <td colspan="2">]] .. creature.minmeleedmg .. creature.maxmeleedmg .. [[ <td>]] .. creature.wrestling .. [[ <td>]] .. creature.armor .. creature.armormin .. [[ <td>]] .. creature.magicresist .. creature.magicresistmin .. [[ <td>]] .. creature.parry .. [[ <td>]] .. creature.magery .. [[ <td colspan="2">]] .. creature.minspelldmg .. creature.maxspelldmg .. [[ <td>]] .. creature.poisontype .. [[ <td>]] .. creature.poisoning .. [[ <td>]] .. creature.poisonresist .. creature.poisonresistmin .. [[ <td>]] .. creature.stealth end end end wikiTable = wikiTable .. "</table>" return wikiTable end function p.listAbilities(frame) local tameableArray = mw.loadData("Module:TameableCreatureData") local summonArray = mw.loadData("Module:SummonableCreatureData") local abilityArray = mw.loadData("Module:FollowerAbilityData") local creature = frame.args[1] -- Warpig local followerType = frame.args[2] -- Tameable/Summon local follower = "" if string.lower(followerType) ~= "summon" and tameableArray[creature] then follower = tameableArray[creature] elseif string.lower(followerType) ~= "tameable" and summonArray[creature] then follower = summonArray[creature] else follower = "undefined" end local wikiTable = "" if follower and follower ~= "undefined" then -- List a follower's abilities if a follower is given wikiTable = [[<table class="wikitable" style="text-align:center"> <th>Ability <th>Type <th>Description]] local abilities = {} for i, creatureAbility in pairs({ follower.cooldownability, follower.innateability, follower.passiveability }) do if creatureAbility and creatureAbility ~= "" and type(creatureAbility) == "table" then for index, ability in pairs(creatureAbility) do table.insert(abilities, ability) end elseif creatureAbility and creatureAbility ~= "" then table.insert(abilities, creatureAbility) end end for i, ability in pairs(abilities) do wikiTable = wikiTable .. [[<tr> <td>]] .. ability .. [[ <td>]] .. abilityArray[ability].type .. [[ <td style="text-align:left">]] .. abilityArray[ability].description end elseif follower == "undefined" then -- List all abilities and the followers that have them wikiTable = [[<table class="wikitable sortable" style="text-align:center"> <th>Ability <th>Type <th>Description <th>Creatures]] for abilityName, ability in pairs(abilityArray) do wikiTable = wikiTable .. [[<tr> <td>]] .. abilityName .. [[ <td>]] .. ability.type .. [[ <td style="text-align:left">]] .. ability.description .. [[<td>]] -- Find and list any followers with the ability for i, array in pairs({ tameableArray, summonArray }) do for followerName, followerStats in pairs(array) do local followerAbilityType = "" if ability.type == "Cooldown" then followerAbilityType = followerStats.cooldownability elseif ability.type == "Innate" then followerAbilityType = followerStats.innateability elseif ability.type == "Passive" then followerAbilityType = followerStats.passiveability end if type(followerAbilityType) == "table" then for creatureName, value in pairs(followerAbilityType) do if value == abilityName then if array == summonArray and tameableArray[followerName] and summonArray[followerName] then wikiTable = wikiTable .. "[[" .. followerName .. "|"..followerName.." (Summon)]],<br>" else wikiTable = wikiTable .. "[[" .. followerName .. "]],<br>" end end end elseif followerAbilityType == abilityName then if array == summonArray and tameableArray[followerName] and summonArray[followerName] then wikiTable = wikiTable .. "[[" .. followerName .. "|"..followerName.." (Summon)]],<br>" else wikiTable = wikiTable .. "[[" .. followerName .. "]],<br>" end end end end -- Cut out the extra line break if string.find(wikiTable, "<br>") then wikiTable = string.reverse(wikiTable) wikiTable = string.sub(wikiTable, 6) wikiTable = string.reverse(wikiTable) end end else -- If a follower is given but doesn't exist return '<h1 style="color:FireBrick;"><big>Follower Ability Table Template Error: No tamed/summoned follower found by the name "' .. creature .. '" (Case-sensitive)</big></h1>' end wikiTable = wikiTable .. "</table>" return wikiTable end function p.summonStatIncrease(frame) local summonArray = mw.loadData("Module:SummonableCreatureData") local summonName = frame.args[1] -- A summon given to display, defaults to {{PAGENAME}} local wikiTable = '<table class="wikitable" style="text-align:center">' local summon = summonArray[summonName] if summon then local stats = { ["hits"] = summon.unformattedhits, ["atkspd"] = summon.atkspd, ["mindmg"] = summon.mindmg, ["maxdmg"] = summon.maxdmg, ["wrestling"] = summon.wrestling, ["armor"] = summon.armor, ["magicresist"] = summon.magicresist } for statName, stat in pairs(stats) do if type(stats[statName]) == "string" then stats[statName] = 0 end end wikiTable = wikiTable .. [=[<th colspan="6">[[File:]=] .. summon.spellicon .. [=[.png|center|link=]]<br>[[]=] .. summonName .. [=[]] <tr> <th rowspan="2">Stat <th colspan="5"> Spirit Speak Skill <tr> <th>Base <th>80 <th>100 <th>120 <th>150 <tr> <th>Hits <td>]=] .. stats.hits .. [[ <td>]] .. stats.hits * 1.5 * (80 / 100) .. [[ <td>]] .. stats.hits * 1.5 * (100 / 100) .. [[ <td>]] .. stats.hits * 1.5 * (120 / 100) .. [[ <td>]] .. stats.hits * 1.5 * (150 / 100) .. [[ <tr> <th>Attack Speed <td>]] .. stats.atkspd .. [[ <td>]] .. stats.atkspd * 1.125 * (80 / 100) .. [[ <td>]] .. stats.atkspd * 1.125 * (100 / 100) .. [[ <td>]] .. stats.atkspd * 1.125 * (120 / 100) .. [[ <td>]] .. stats.atkspd * 1.125 * (150 / 100) .. [[ <tr> <th>]] .. summon.combat .. [[ Damage <td>]] .. stats.mindmg .. " - " .. stats.maxdmg .. [[ <td>]] .. stats.mindmg * 1.25 * (80 / 100) .. " - " .. stats.maxdmg * 1.25 * (80 / 100) .. [[ <td>]] .. stats.mindmg * 1.25 * (100 / 100) .. " - " .. stats.maxdmg * 1.25 * (100 / 100) .. [[ <td>]] .. stats.mindmg * 1.25 * (120 / 100) .. " - " .. stats.maxdmg * 1.25 * (120 / 100) .. [[ <td>]] .. stats.mindmg * 1.25 * (150 / 100) .. " - " .. stats.maxdmg * 1.25 * (150 / 100) .. [[ <tr> <th>Wrestling <td>]] .. stats.wrestling .. [[ <td>]] .. stats.wrestling * 1.25 * (80 / 100) .. [[ <td>]] .. stats.wrestling * 1.25 * (100 / 100) .. [[ <td>]] .. stats.wrestling * 1.25 * (120 / 100) .. [[ <td>]] .. stats.wrestling * 1.25 * (150 / 100) .. [[ <tr> <th>Armor <td>]] .. stats.armor .. [[ <td>]] .. stats.armor + (25 * (80 / 100)) .. [[ <td>]] .. stats.armor + (25 * (100 / 100)) .. [[ <td>]] .. stats.armor + (25 * (120 / 100)) .. [[ <td>]] .. stats.armor + (25 * (150 / 100)) .. [[ <tr> <th>Magic Resist <td>]] .. stats.magicresist .. [[ <td>]] .. stats.magicresist + (50 * (80 / 100)) .. [[ <td>]] .. stats.magicresist + (50 * (100 / 100)) .. [[ <td>]] .. stats.magicresist + (50 * (120 / 100)) .. [[ <td>]] .. stats.magicresist + (50 * (150 / 100)) .. [[ </table>]] return wikiTable else return '<h1 style="color:FireBrick;"><big>Summon Stat Table Template Error: No summoned follower found by the name "' .. summonName .. '" (Case-sensitive)</big></h1>' end end function p.checkCreatureValue(frame) local creatureName = frame.args[1] -- Name of the creature to check for local creatureType = frame.args[2] -- Wild/Tameable/Summonable/Ships/Strangelands, defaults to Wild local creatureStat = frame.args[3] -- location/name/slayer local value = frame.args[4] -- Aegis Keep/Molten Mongbat/Deamonic/true, defaults to true (has value) if not creatureStat or creatureStat == "" then creatureStat = "name" end local dataSource -- Set the requested data source if creatureType and string.lower(creatureType) == "tameable" then dataSource = mw.loadData("Module:TameableCreatureData") elseif creatureType and string.lower(creatureType) == "summonable" then dataSource = mw.loadData("Module:SummonableCreatureData") elseif creatureType and string.lower(creatureType) == "ships" then dataSource = mw.loadData("Module:ShipCreatureData") elseif creatureType and string.lower(creatureType) == "tameable" then dataSource = mw.loadData("Module:TameableCreatureData") elseif creatureType and string.lower(creatureType) == "strangelands" then dataSource = mw.loadData("Module:StrangelandsCreatureData") else dataSource = mw.loadData("Module:WildCreatureData") end local creature = dataSource[creatureName] if creature then local stat = creature[creatureStat] if creatureStat == "name" then return true -- "creature match found in datasource" elseif not value or value == "" then if stat then return true -- "stat exists for this creature" else return false -- "stat does not exist for this creature" end else if stat and string.lower(stat) == string.lower(value) then return true -- "stat is equal to the value" else return false -- "stat is not equal to the value or doesn't exist" end end else return false -- "creature not found in datasource" end end function p.creaturePage(frame) local creature = frame.args[1] local imageOverride = frame.args[2] local page = "" local creatureArray = mw.loadData("Module:WildCreatureData") local tameableArray = mw.loadData("Module:TameableCreatureData") local summonArray = mw.loadData("Module:SummonableCreatureData") local strangelandsArray = mw.loadData("Module:StrangelandsCreatureData") local shipsArray = mw.loadData("Module:ShipCreatureData") if creatureArray[creature] then page = page.."{{CreatureTable|image="..imageOverride.."}}\n" end if shipsArray[creature] then page = page..[[== Ship Creature Stats == {{CreatureTable|type=ships|image=]]..imageOverride.."}}\n" end if tameableArray[creature] then page = page..[[== Tameable Stats == {{FollowerTable|type=tameable|image=]]..imageOverride..[[}} {{FollowerAbilities|type=tameable}} {{TamedScalarLevels}}\n]] end if summonArray[creature] then page = page..[[== Summoned Creature Stats == {{FollowerTable|type=summon|image=]]..imageOverride..[[}} {{FollowerAbilities|type=summon}} {{SummonStatIncrease}}\n]] end if strangelandsArray[creature] then page = page..[[== Strangelands Creature Stats== {{CreatureTable|type=strangelands|image=]]..imageOverride..[[}}\n]] end return page end return p