Module:Mazunki/Monsters: Difference between revisions

From Melvor Idle
m (itemList to monsterList didn't work)
m (whoos csv)
 
(46 intermediate revisions by the same user not shown)
Line 1: Line 1:


local Shared = require('Module:Shared')
--local Shared = require('Module:Shared')
local MonsterData = mw.loadData('Module:Monsters/data')
local MonsterData = mw.loadData('Module:Monsters/data')
local Monsters = require('Module:Monsters')
local Monsters = require('Module:Monsters')
local Items = require('Module:Items')
local Items = require('Module:Items')
local Icons = require('Module:Icons')
local Constants = require('Module:Constants')
local Areas = require("Module:CombatAreas")
-- local SourceTables = require('Module:Monsters/SourceTables')
-- local SourceTables = require('Module:Monsters/SourceTables')
-- local UseTables = require('Module:Monsters/UseTables')
-- local UseTables = require('Module:Monsters/UseTables')


local p = {}
local p = {}
local arraySeparatorInSheets = '<br />'
local notext = ''
local zero = 0


function p.getRawTable(frame)
function p.getRawTable(frame)
local result = '{|\r\n'
local result = '{|\r\n'
local rows = {}
local rows = {}
 
local headers = {
-- local monsterList = Monsters.getMonsters(function(item) return true end)
'ID',
-- table.sort(monsterList, function(a, b) return a.id < b.id end)
'Name',
'CombatLevel',
'Hitpoints',
'Interval',
'NormalMaxHit',
'NormalType',
'HasSpecial',
'SpecialAttacksNames',
'SpecialAttacksChance',
'Accuracy',
'MeleeEvasion',
'RangedEvasion',
'MagicEvasion',
'GoldDropMin',
'GoldDropMax',
'BoneType',
'BonePrayerValue',
'BonesObtainable',
'Fragments',
'FragmentsAmount',
'Location',
'LocationNormal',
'LocationSlayer',
'LocationDungeon',
'SlayerTier', 'SlayerTierName', 'SlayerTierCost',
'SlayerTierPlayerLevel', 'SlayerTierQtyMin', 'SlayerTierQtyMax', 'SlayerCoinReward',
'ItemsID', 'ItemsName', 'ItemsWeight', 'ItemsDenominator', 'ItemsNormalised', 'ItemsQtyMin', 'ItemsQtyMax'
}
result = result.."!"..table.concat(headers, "!!")


local monsterID = 0
local monsterID = 0
local monster = Monsters.getMonsterByID(monsterID)
local monster = Monsters.getMonsterByID(monsterID)
while monster ~= nil and monsterID < 2000 do -- as of writing this, there are [0..163] monsters
while monster ~= nil and monsterID < 2000 do -- as of writing this, there are [0..163] monsters
local rowTxt = '|-\r\n'
local rowTxt = {}
table.insert(rowTxt, '|-\r\n')
table.insert(rowTxt, monsterID)
table.insert(rowTxt, monster.name)
local combatLevel = Monsters._getMonsterCombatLevel(monster)
table.insert(rowTxt, combatLevel)


result = result..result..'!!ID'
local hitpoints = Monsters._getMonsterHP(monster)
rowTxt = rowTxt..'|'..monsterID
table.insert(rowTxt, hitpoints)
table.insert(rowTxt, Monsters._getMonsterAttackSpeed(monster))
table.insert(rowTxt, Monsters._getMonsterMaxHit(monster))
table.insert(rowTxt, (monster.attackType:gsub("^%l", string.upper)))
local hasSpecialAttack = false
local spAtks = {}
local spAtksChance = {}
for _, spAtk in pairs(monster.specialAttacks or {}) do
hasSpecialAttack = true
table.insert(spAtks, spAtk.name)
table.insert(spAtksChance, spAtk.defaultChance/100)
end
table.insert(rowTxt, tostring(hasSpecialAttack))
table.insert(rowTxt, table.concat(spAtks, arraySeparatorInSheets))
table.insert(rowTxt, table.concat(spAtksChance, arraySeparatorInSheets))
table.insert(rowTxt, Monsters._getMonsterAR(monster))
table.insert(rowTxt, Monsters._getMonsterER(monster, 'Melee'))
table.insert(rowTxt, Monsters._getMonsterER(monster, 'Ranged'))
table.insert(rowTxt, Monsters._getMonsterER(monster, 'Magic'))
table.insert(rowTxt, monster.dropCoins[1])
table.insert(rowTxt, monster.dropCoins[2])
local bones = Items.getItemByID(monster.bones)
if bones ~= nil and bones.prayerPoints then
table.insert(rowTxt, bones.name)
table.insert(rowTxt, bones.prayerPoints)
table.insert(rowTxt, tostring(not(monster.isBoss)))
table.insert(rowTxt, notext)
table.insert(rowTxt, tostring(0))
elseif bones ~= nil and monster.boneQty then
table.insert(rowTxt, notext)
table.insert(rowTxt, tostring(0))
table.insert(rowTxt, tostring(false))
table.insert(rowTxt, bones.name) -- actually a fragment, not bone
table.insert(rowTxt, monster.boneQty) -- actually a fragment
else
table.insert(rowTxt, notext)
table.insert(rowTxt, tostring(zero))
table.insert(rowTxt, tostring(false))


result = result..'!!Name'
table.insert(rowTxt, notext)
rowTxt = rowTxt..'|'..monster.name
table.insert(rowTxt, tostring(zero))
end


result = result..'!!CombatLevel'
local locationsTable = Areas.getMonsterAreas(monsterID)
local combatlevel = Monsters._getMonsterCombatLevel(monster) -- used for slayer
local isNormalLocation = false
rowTxt = rowTxt..'|'..combatlevel
local isSlayerLocation = false
local isDungeonLocation = false
local locations = {}
for i, location in pairs(locationsTable) do
if location.type == "slayer" then
isSlayerLocation = true
elseif location.type == "dungeon" then
isDungeonLocation = true
elseif location.type == "combat" then
isNormalLocation = true
end
table.insert(locations, tostring(location.name))
end
table.insert(rowTxt, table.concat(locations, arraySeparatorInSheets))
table.insert(rowTxt, tostring(isNormalLocation))
table.insert(rowTxt, tostring(isSlayerLocation))
table.insert(rowTxt, tostring(isDungeonLocation))


result = result..'!!HP'
local slayer = nil
rowTxt = rowTxt..'|'..Monsters._getMonsterHP(monter)
if monster.canSlayer then
 
slayer = Constants.getSlayerTierByLevel(combatLevel)
result = result..'!!Interval'
slayer.reward = math.floor(hitpoints/10)
rowTxt = rowTxt..'|'..Monsters._getMonsterAttackSpeed(monster)
 
result = result..'!!NormalAttackMaxHit'
rowTxt = rowTxt..'|'..Monsters._getMonsterMaxHit(monster)
 
result = result..'!!NormalAttackType'
rowTxt = rowTxt..'|'..monster.attackType
 
result = result..'!!HasSpecial'
rowTxt = rowTxt..'|'..tostring(not #(monster.specialAttack))
 
result = result..'!!Accuracy'
rowTxt = rowTxt..'|'..Monsters._getMonsterAR(monster)
 
result = result..'!!MeleeEvasion'
rowTxt = rowTxt..'|'..Monsters.__getMonsterER(monster, 'Melee')
 
result = result..'!!RangedEvasion'
rowTxt = rowTxt..'|'..Monsters.__getMonsterER(monster, 'Ranged')
 
result = result..'!!MagicEvasion'
rowTxt = rowTxt..'|'..Monsters.__getMonsterER(monster, 'Magic')
 
result = result..'!!GoldDropMin'
rowTxt = rowTxt..'|'..monster.dropCoins[0]
 
result = result..'!!GoldDropMax'
rowTxt = rowTxt..'|'..monster.dropCoins[1]
 
result = result..'!!BoneType'
result = result..'!!BonePrayerValue'
local bones = Items.getItemByID(monster.bones)
if bones.prayerPoints then
rowTxt = rowTxt..'|'..bones.name
rowTxt = rowTxt..'|'..bones.prayerPoints
else
else
rowTxt = rowTxt..'|'..tostring(false)
slayer = {
rowTxt = rowTxt..'|'..tostring(0)
["id"] = notext,
["display"] = notext,
["cost"] = notext,
["slayerLevel"] = notext,
["minQuantity"] = notext,
["maxQuantity"] = notext,
["reward"] = notext
}
end
end
table.insert(rowTxt, tostring(slayer.id))
table.insert(rowTxt, tostring(slayer.display))
table.insert(rowTxt, tostring(slayer.cost))
table.insert(rowTxt, tostring(slayer.slayerLevel))
table.insert(rowTxt, tostring(slayer.minQuantity))
table.insert(rowTxt, tostring(slayer.maxQuantity))
table.insert(rowTxt, tostring(slayer.reward))


result = result..'!!Location'
rowTxt = rowTxt..'|'..Monsters._getMonsterAreas(monster, false) --args[2] is excludeDungeons
result = result..'!!SlayerTier'
rowTxt = rowTxt..'|'..Constants.getSlayerTierByLevel(combatlevel)
result = result..'!!SlayerTierName'
rowTxt = rowTxt..'|'..Constants.getSlayerTierNameByLevel(combatlevel)
result = result..'!!ItemsID'
result = result..'!!ItemsWeight'
result = result..'!!ItemsDenominators'
result = result..'!!ItemsTotalWeight'
result = result..'!!ItemsQtyMin'
result = result..'!!ItemsQtyMax'
local itemIds = {}
local itemIds = {}
local itemNames = {}
local itemWeights = {}
local itemWeights = {}
local itemDenominators = {}
local itemNormalised = {}
local itemQtyMins = {}
local itemQtyMins = {}
local itemQtyMaxs = {}
local itemQtyMaxs = {}
Line 99: Line 163:
totalWeight = totalWeight + droppable[2]
totalWeight = totalWeight + droppable[2]
end
end
local itemDenominator = totalWeight * 100


for _, droppable in pairs(monster.lootTable) do
for _, droppable in pairs(monster.lootTable) do
table.insert(itemIds, droppable[1])
table.insert(itemIds, droppable[1])
table.insert(itemWeights, droppable[2]*monster.lootChance)
table.insert(itemNames, Items.getItemByID(droppable[1]).name)
table.insert(itemDenominators, totalWeight*100)
local numerator = droppable[2]
table.insert(itemWeights, numerator)
table.insert(itemNormalised, itemDenominator/(numerator*monster.lootChance))
table.insert(itemQtyMins, 1)
table.insert(itemQtyMins, 1)
table.insert(itemQtyMaxs, droppable[3])
table.insert(itemQtyMaxs, droppable[3])
end
end
rowTxt = rowTxt..'|'..table.concat(itemIds, ",")
table.insert(rowTxt, table.concat(itemIds, arraySeparatorInSheets))
rowTxt = rowTxt..'|'..table.concat(itemWeights, ",")
table.insert(rowTxt, table.concat(itemNames, arraySeparatorInSheets))
rowTxt = rowTxt..'|'..table.concat(itemDenominators, ",")
table.insert(rowTxt, table.concat(itemWeights, arraySeparatorInSheets))
rowTxt = rowTxt..'|'..table.concat(totalWeight, ",")
table.insert(rowTxt, itemDenominator/monster.lootChance)
rowTxt = rowTxt..'|'..table.concat(itemQtyMins, ",")
table.insert(rowTxt, table.concat(itemNormalised, arraySeparatorInSheets))
rowTxt = rowTxt..'|'..table.concat(itemQtyMaxs, ",")
table.insert(rowTxt, table.concat(itemQtyMins, arraySeparatorInSheets))
table.insert(rowTxt, table.concat(itemQtyMaxs, arraySeparatorInSheets))


table.insert(rows, rowTxt)
table.insert(rows, table.concat(rowTxt, '||'))
monsterId = monsterId + 1
monsterID = monsterID + 1
monster = Monsters.getItemByID(monsterID)
monster = Monsters.getMonsterByID(monsterID)
end
end
 
result = result..'\r\n'..table.concat(rows, '\r\n')..'\r\n|}'
result = result..'\r\n'..table.concat(rows, '\r\n')..'\r\n|}'
return result
return result

Latest revision as of 03:37, 31 January 2022

Documentation for this module may be created at Module:Mazunki/Monsters/doc

--local Shared = require('Module:Shared')
local MonsterData = mw.loadData('Module:Monsters/data')
local Monsters = require('Module:Monsters')
local Items = require('Module:Items')
local Constants = require('Module:Constants')
local Areas = require("Module:CombatAreas")
-- local SourceTables = require('Module:Monsters/SourceTables')
-- local UseTables = require('Module:Monsters/UseTables')

local p = {}
local arraySeparatorInSheets = '<br />'
local notext = ''
local zero = 0

function p.getRawTable(frame)
	local result = '{|\r\n'
	local rows = {}
	local headers = {
		'ID',
		'Name',
		'CombatLevel',
		'Hitpoints',
		'Interval',
		'NormalMaxHit',
		'NormalType',
		'HasSpecial',
		'SpecialAttacksNames',
		'SpecialAttacksChance',
		'Accuracy',
		'MeleeEvasion',
		'RangedEvasion',
		'MagicEvasion',
		'GoldDropMin',
		'GoldDropMax',
		'BoneType',
		'BonePrayerValue',
		'BonesObtainable',
		'Fragments',
		'FragmentsAmount',
		'Location',
		'LocationNormal',
		'LocationSlayer',
		'LocationDungeon',
		'SlayerTier', 'SlayerTierName', 'SlayerTierCost',
		'SlayerTierPlayerLevel', 'SlayerTierQtyMin', 'SlayerTierQtyMax', 'SlayerCoinReward',
		'ItemsID', 'ItemsName', 'ItemsWeight', 'ItemsDenominator', 'ItemsNormalised', 'ItemsQtyMin', 'ItemsQtyMax'
	}
	result = result.."!"..table.concat(headers, "!!")

	local monsterID = 0
	local monster = Monsters.getMonsterByID(monsterID)
	while monster ~= nil and monsterID < 2000 do -- as of writing this, there are [0..163] monsters
		local rowTxt = {}
		table.insert(rowTxt, '|-\r\n')
	
		table.insert(rowTxt, monsterID)
		table.insert(rowTxt, monster.name)
		local combatLevel = Monsters._getMonsterCombatLevel(monster)
		table.insert(rowTxt, combatLevel)

		local hitpoints = Monsters._getMonsterHP(monster)
		
		table.insert(rowTxt, hitpoints)
		table.insert(rowTxt, Monsters._getMonsterAttackSpeed(monster))
		table.insert(rowTxt, Monsters._getMonsterMaxHit(monster))
		table.insert(rowTxt, (monster.attackType:gsub("^%l", string.upper)))
		local hasSpecialAttack = false
		local spAtks = {}
		local spAtksChance = {}
		for _, spAtk in pairs(monster.specialAttacks or {}) do
			hasSpecialAttack = true
			table.insert(spAtks, spAtk.name)
			table.insert(spAtksChance, spAtk.defaultChance/100)
		end
		table.insert(rowTxt, tostring(hasSpecialAttack))
		table.insert(rowTxt, table.concat(spAtks, arraySeparatorInSheets))
		table.insert(rowTxt, table.concat(spAtksChance, arraySeparatorInSheets))
		
		table.insert(rowTxt, Monsters._getMonsterAR(monster))
		table.insert(rowTxt, Monsters._getMonsterER(monster, 'Melee'))
		table.insert(rowTxt, Monsters._getMonsterER(monster, 'Ranged'))
		table.insert(rowTxt, Monsters._getMonsterER(monster, 'Magic'))
		table.insert(rowTxt, monster.dropCoins[1])
		table.insert(rowTxt, monster.dropCoins[2])
		
		local bones = Items.getItemByID(monster.bones) 
		if bones ~= nil and bones.prayerPoints then
			table.insert(rowTxt, bones.name)
			table.insert(rowTxt, bones.prayerPoints)
			table.insert(rowTxt, tostring(not(monster.isBoss)))
			
			table.insert(rowTxt, notext)
			table.insert(rowTxt, tostring(0))
		elseif bones ~= nil and monster.boneQty then
			table.insert(rowTxt, notext)
			table.insert(rowTxt, tostring(0))
			table.insert(rowTxt, tostring(false))
			
			table.insert(rowTxt, bones.name) -- actually a fragment, not bone
			table.insert(rowTxt, monster.boneQty) -- actually a fragment
		else
			table.insert(rowTxt, notext)
			table.insert(rowTxt, tostring(zero))
			table.insert(rowTxt, tostring(false))

			table.insert(rowTxt, notext)
			table.insert(rowTxt, tostring(zero))
		end

		local locationsTable = Areas.getMonsterAreas(monsterID)
		local isNormalLocation = false
		local isSlayerLocation = false
		local isDungeonLocation = false
		local locations = {}
		for i, location in pairs(locationsTable) do
			if location.type == "slayer" then
				isSlayerLocation = true
			elseif location.type == "dungeon" then
				isDungeonLocation = true
			elseif location.type == "combat" then
				isNormalLocation = true
			end
			table.insert(locations, tostring(location.name))
		end
		table.insert(rowTxt, table.concat(locations, arraySeparatorInSheets))
		table.insert(rowTxt, tostring(isNormalLocation))
		table.insert(rowTxt, tostring(isSlayerLocation))
		table.insert(rowTxt, tostring(isDungeonLocation))

		local slayer = nil
		if monster.canSlayer then
			slayer = Constants.getSlayerTierByLevel(combatLevel)
			slayer.reward = math.floor(hitpoints/10)
		else
			slayer = {
				["id"] = notext,
				["display"] = notext,
				["cost"] = notext,
				["slayerLevel"] = notext,
				["minQuantity"] = notext,
				["maxQuantity"] = notext,
				["reward"] = notext
			}
		end
		
		table.insert(rowTxt, tostring(slayer.id))
		table.insert(rowTxt, tostring(slayer.display))
		table.insert(rowTxt, tostring(slayer.cost))
		table.insert(rowTxt, tostring(slayer.slayerLevel))
		table.insert(rowTxt, tostring(slayer.minQuantity))
		table.insert(rowTxt, tostring(slayer.maxQuantity))
		table.insert(rowTxt, tostring(slayer.reward))

		local itemIds = {}
		local itemNames = {}
		local itemWeights = {}
		local itemNormalised = {}
		local itemQtyMins = {}
		local itemQtyMaxs = {}
		local totalWeight = 0
		for _, droppable in pairs(monster.lootTable) do
			totalWeight = totalWeight + droppable[2]
		end
		local itemDenominator = totalWeight * 100

		for _, droppable in pairs(monster.lootTable) do
			table.insert(itemIds, droppable[1])
			table.insert(itemNames, Items.getItemByID(droppable[1]).name)
			local numerator = droppable[2]
			table.insert(itemWeights, numerator)
			table.insert(itemNormalised, itemDenominator/(numerator*monster.lootChance))
			table.insert(itemQtyMins, 1)
			table.insert(itemQtyMaxs, droppable[3])
		end
		table.insert(rowTxt, table.concat(itemIds, arraySeparatorInSheets))
		table.insert(rowTxt, table.concat(itemNames, arraySeparatorInSheets))
		table.insert(rowTxt, table.concat(itemWeights, arraySeparatorInSheets))
		table.insert(rowTxt, itemDenominator/monster.lootChance)
		table.insert(rowTxt, table.concat(itemNormalised, arraySeparatorInSheets))
		table.insert(rowTxt, table.concat(itemQtyMins, arraySeparatorInSheets))
		table.insert(rowTxt, table.concat(itemQtyMaxs, arraySeparatorInSheets))

		table.insert(rows, table.concat(rowTxt, '||'))
		monsterID = monsterID + 1
		monster = Monsters.getMonsterByID(monsterID)
	end
	
	result = result..'\r\n'..table.concat(rows, '\r\n')..'\r\n|}'
	return result
end



function p.getDRValueForMonsterIdForHP(frame)
	local monsterid = frame.args[1]
	local hp = frame.args[2]
	local autoeatlvl = frame.args[3] or 3

	return 100
end

return p