Module:Mazunki/Monsters: Difference between revisions

From Melvor Idle
m (missed some column headers)
m (gsheets is dumb)
Line 110: Line 110:
table.insert(itemQtyMaxs, droppable[3])
table.insert(itemQtyMaxs, droppable[3])
end
end
table.insert(rowTxt, table.concat(itemIds, ","))
table.insert(rowTxt, table.concat(itemIds, ";"))
table.insert(rowTxt, table.concat(itemWeights, ","))
table.insert(rowTxt, table.concat(itemWeights, ";"))
table.insert(rowTxt, table.concat(itemDenominators, ","))
table.insert(rowTxt, table.concat(itemDenominators, ";"))
table.insert(rowTxt, totalWeight)
table.insert(rowTxt, totalWeight)
table.insert(rowTxt, table.concat(itemQtyMins, ","))
table.insert(rowTxt, table.concat(itemQtyMins, ";"))
table.insert(rowTxt, table.concat(itemQtyMaxs, ","))
table.insert(rowTxt, table.concat(itemQtyMaxs, ";"))


table.insert(rows, table.concat(rowTxt, '||'))
table.insert(rows, table.concat(rowTxt, '||'))

Revision as of 01:14, 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 SourceTables = require('Module:Monsters/SourceTables')
-- local UseTables = require('Module:Monsters/UseTables')

local p = {}

function p.getRawTable(frame)
	local result = '{|\r\n'
	local rows = {}
	local headers = {
		'ID',
		'Name',
		'CombatLevel',
		'Hitpoints',
		'Interval',
		'NormalMaxHit',
		'NormalType',
		'HasSpecial',
		'Accuracy',
		'MeleeEvasion',
		'RangedEvasion',
		'MagicEvasion',
		'GoldDropMin',
		'GoldDropMax',
		'BoneType',
		'BonePrayerValue',
		'Location',
		'SlayerTier', 'SlayerTierName', 'SlayerTierCost',
		'SlayerTierPlayerLevel', 'SlayerTierQtyMin', 'SlayerTierQtyMax', 'SlayerCoinReward',
		'ItemsID', 'ItemsWeight', 'ItemsDenominators', 'ItemsTotalWeight', '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)
		table.insert(rowTxt, tostring(not #(monster.specialAttack or {})))
		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)
		else
			table.insert(rowTxt, tostring(false))
			table.insert(rowTxt, tostring(0))
		end

		table.insert(rowTxt, Monsters._getMonsterAreas(monster, false)) --args[2] is excludeDungeons

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

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

		for _, droppable in pairs(monster.lootTable) do
			table.insert(itemIds, droppable[1])
			table.insert(itemWeights, droppable[2]*monster.lootChance)
			table.insert(itemDenominators, totalWeight*100)
			table.insert(itemQtyMins, 1)
			table.insert(itemQtyMaxs, droppable[3])
		end
		table.insert(rowTxt, table.concat(itemIds, ";"))
		table.insert(rowTxt, table.concat(itemWeights, ";"))
		table.insert(rowTxt, table.concat(itemDenominators, ";"))
		table.insert(rowTxt, totalWeight)
		table.insert(rowTxt, table.concat(itemQtyMins, ";"))
		table.insert(rowTxt, table.concat(itemQtyMaxs, ";"))

		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