Module:TowerDefenseWaves: Difference between revisions

From IdleOn MMO Wiki
imported>Kiokurashi
No edit summary
mNo edit summary
 
(22 intermediate revisions by one other user not shown)
Line 7: Line 7:
t = {}
t = {}
for str in string.gmatch(list, "([^" .. delimiter .. "]+)") do
for str in string.gmatch(list, "([^" .. delimiter .. "]+)") do
table.insert(t, str)
table.insert(t, tonumber(str))
end
end
return t
return t
Line 13: Line 13:


function p.generateWaves(frame)
function p.generateWaves(frame)
local ret = "{{#tag:tabber|\n1-30=\n{{TDwaves/head|Waves}}\n"
local ret = [[1-30={{TDwaves/head|Waves}}]]
local countList = explode(frame.args.MonsterCount, ",")
local countList = explode(frame.args.MonsterCount, ",")
local skull = explode(frame.args.Skull, ",")
local skull = explode(frame.args.Skull, ",")
local size = explode(frame.args.Size, ",")
local size = explode(frame.args.Size, ",")
local color = explode(frame.args.Type, ",")
local color = explode(frame.args.Type, ",")
local waves = frame.args.MaxWave
local waves = tonumber(frame.args.MaxWave)
local baseHP = frame.args.BaseHealth
local baseHP = tonumber(frame.args.BaseHealth)
local sizeText = {"Null", "Zoomo", "Normo", "Largo", "Gigao", "last"}
local sizeText = {"Zoomo", "Normo", "Largo", "Gigao"}
local colorText = {"first", "Grey", "Red", "Blue", "Green", "Yellow", "Purple"}
local colorText = {"Grey", "Red", "Blue", "Green", "Yellow", "Purple"}
-- For the formula (or the main part of it) it is floating around there so search for ` _customBlock_2inputs("WorshipMobHpMulti" ` to find the general area.
for i = 1, waves do
for i = 1, waves do
local wavePos = i % 30
local wavePos
local multi = math.floor(i / 30)
if((i % 30) > 0) then wavePos = i % 30 end
local waveSkull = math.min(skull[wavePos] + (2 * multi), 16)
if((i % 30) == 0) then wavePos = 30 end -- We want to keep 30 instead of getting 0.
local enemyNum = countList[wavePos] + (math.ceil(countList[wavePos] / 3) * multi)
local multi = math.floor((i-1) / 30) -- Increase value every 30 waves starting from 0.
local health = math.ceil(baseHP * (3 ^ (size[wavePos] - 2)) * ((3 + 0.3 * waveSkull)^waveSkull))
local waveSkull = math.min(skull[wavePos] + (2 * multi), 16) -- 17 skull types. Modular based on wave count.
local enemyNum = math.ceil(countList[wavePos] * (1 + multi / 3)) -- Increases every 30 waves.
local health = math.ceil(baseHP * (3 ^ (size[wavePos] - 2)) * ((3 + 0.3 * waveSkull)^waveSkull)) -- Increases by Skull level.
-- Ceil(BaseHP * (3 ^ (size - 2)) * ((3 + 0.3 * skull)^skull))
-- Ceil(BaseHP * (3 ^ (size - 2)) * ((3 + 0.3 * skull)^skull))
if((i > 1) and (wavePos == 1)) then ret = ret .. "\n{{!}}-{{!}}\n" .. i .. "-" .. (i + 29) .."=\n{{TDwaves/head|Waves}}\n" end
local sizeW = size[wavePos] -- Enemy size modifier.
local colorW = color[wavePos] + 1 -- Enemy color/ability modifier.
if(i > 2 and (wavePos == 1)) then ret = ret .. "\n|-|\n" .. i .. "-" .. (i + 29) .. [[={{TDwaves/head|Waves}}]] end
-- {{TDwaves/row|31|3|Skull2|Normo|Grey|52|156}}  
-- {{TDwaves/row|31|3|Skull2|Normo|Grey|52|156}}  
ret = ret .. "{{TDwaves/row|" .. i .. "|" .. enemyNum .. "|Skull" .. waveSkull .. "|" .. sizeText[size[wavePos]] .. "|" .. colorText[color[wavePos]] .. "|" .. health .. "|" .. (health * enemyNum) .. "}}\n";
ret = ret .. "{{TDwaves/row|" .. i .. "|" .. enemyNum .. "|Skull" .. waveSkull .. "|" .. sizeText[sizeW] ..  
"|" .. colorText[colorW] .. "|{{Numdisplay|" .. health .. "}}|{{Numdisplay|" .. (health * enemyNum) .. "}}}}";
end
end
ret = ret .. "}}\n"
return ret
return ret
end
end
return p
return p

Latest revision as of 13:24, 9 May 2023

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

local p = {}

local function explode(list, delimiter)
    if delimiter == nil then
		delimiter = "%s"
	end
	t = {}
	for str in string.gmatch(list, "([^" .. delimiter .. "]+)") do
		table.insert(t, tonumber(str))
	end
	return t
end

function p.generateWaves(frame)
	local ret = [[1-30={{TDwaves/head|Waves}}]]
	local countList = explode(frame.args.MonsterCount, ",")
	local skull = explode(frame.args.Skull, ",")
	local size = explode(frame.args.Size, ",")
	local color = explode(frame.args.Type, ",")
	local waves = tonumber(frame.args.MaxWave)
	local baseHP = tonumber(frame.args.BaseHealth)
	local sizeText = {"Zoomo", "Normo", "Largo", "Gigao"}
	local colorText = {"Grey", "Red", "Blue", "Green", "Yellow", "Purple"}
	
	-- For the formula (or the main part of it) it is floating around there so search for ` _customBlock_2inputs("WorshipMobHpMulti" ` to find the general area.
	for i = 1, waves do
		local wavePos
		if((i % 30) > 0) then wavePos = i % 30 end
		if((i % 30) == 0) then wavePos = 30 end -- We want to keep 30 instead of getting 0.
		local multi = math.floor((i-1) / 30) -- Increase value every 30 waves starting from 0.
		local waveSkull = math.min(skull[wavePos] + (2 * multi), 16) -- 17 skull types. Modular based on wave count.
		local enemyNum = math.ceil(countList[wavePos] * (1 + multi / 3)) -- Increases every 30 waves.
		local health = math.ceil(baseHP * (3 ^ (size[wavePos] - 2)) * ((3 + 0.3 * waveSkull)^waveSkull)) -- Increases by Skull level.
		-- Ceil(BaseHP * (3 ^ (size - 2)) * ((3 + 0.3 * skull)^skull))
		local sizeW = size[wavePos] -- Enemy size modifier.
		local colorW = color[wavePos] + 1 -- Enemy color/ability modifier.
		if(i > 2 and (wavePos == 1)) then ret = ret .. "\n|-|\n" .. i .. "-" .. (i + 29) .. [[={{TDwaves/head|Waves}}]] end
		-- {{TDwaves/row|31|3|Skull2|Normo|Grey|52|156}} 
		
		ret = ret .. "{{TDwaves/row|" .. i .. "|" .. enemyNum .. "|Skull" .. waveSkull .. "|" .. sizeText[sizeW] .. 
			"|" .. colorText[colorW] .. "|{{Numdisplay|" .. health .. "}}|{{Numdisplay|" .. (health * enemyNum) .. "}}}}";
	end
	return ret
end
	
return p