share/hedgewars/Data/Scripts/Multiplayer/Frenzy.lua
author koda
Tue, 21 Jan 2014 23:53:26 +0100
changeset 10044 33e64afccd3b
parent 10017 de822cd3df3a
child 10289 c3a77ff02a23
permissions -rw-r--r--
readd r3be36d2fdca6

-------------------------------------------
-- FRENZY
-- a hedgewars mode inspired by Hysteria
-------------------------------------------

HedgewarsScriptLoad("/Scripts/Locale.lua")
HedgewarsScriptLoad("/Scripts/Tracker.lua")

local cTimer = 0
local cn = 0

function initialSetup(gear)
	SetHealth(gear, 75) -- official is 80, but that assumes bazookas/grenades that do 50 damage
end

function showStartingInfo()

	ruleSet = "" ..
	loc("RULES") .. ": " .. "|" ..
	loc("Each turn is only ONE SECOND!") .. "|" ..
	loc("Use your ready time to think.") .. "|" ..
	loc("Slot keys save time! (F1-F10 by default)") .. "|" ..
	" |" ..
	loc("SLOTS") .. ": " .. "|" ..
	loc("Slot") .. " 1 - " .. loc("Bazooka") .. "|" ..
	loc("Slot") .. " 2 - " .. loc("Grenade") .. "|" ..
	loc("Slot") .. " 3 - " .. loc("Shotgun") .. "|" ..
	loc("Slot") .. " 4 - " .. loc("Shoryuken") .. "|" ..
	loc("Slot") .. " 5 - " .. loc("Mine") .. "|" ..
	loc("Slot") .. " 6 - " .. loc("Teleport") .. "|" ..
	loc("Slot") .. " 7 - " .. loc("Blowtorch") .. "|" ..
	loc("Slot") .. " 8 - " .. loc("Flying Saucer") .. "|" ..
	loc("Slot") .. " 9 - " .. loc("Molotov") .. "|" ..
	loc("Slot") .. " 10 - " .. loc("Low Gravity")

	ShowMission(loc("FRENZY"),
                loc("a frenetic Hedgewars mini-game"),
                ruleSet, 0, 4000)

end

function onGameInit()

	if TurnTime > 10001 then
		Ready = 8000
	else
		Ready = TurnTime
	end

	TurnTime = 1000

	--These are the official settings, but I think I prefer allowing customization in this regard
	--MinesNum = 8
	--MinesTime = 3000
	--MinesDudPercent = 30
	--Explosives = 0

	--Supposedly official settings
	HealthCaseProb = 0
	CrateFreq = 0

	--Approximation of Official Settings
	--SuddenDeathTurns = 10
	--WaterRise = 47
	--HealthDecrease = 0

end

function onGameStart()
	showStartingInfo()
	runOnHogs(initialSetup)
end

function onSlot(sln)
	cTimer = 8
	cn = sln
end

function onGameTick()
	if cTimer ~= 0 then
		cTimer = cTimer -1
		if cTimer == 1 then
			ChangeWep(cn)
			cn = 0
			cTimer = 0
		end
	end
end

function ChangeWep(s)

	if s == 0 then
		ParseCommand("setweap " .. string.char(amBazooka))
	elseif s == 1 then
		ParseCommand("setweap " .. string.char(amGrenade))
	elseif s == 2 then
		ParseCommand("setweap " .. string.char(amShotgun))
	elseif s == 3 then
		ParseCommand("setweap " .. string.char(amFirePunch))
	elseif s == 4 then
		ParseCommand("setweap " .. string.char(amMine))
	elseif s == 5 then
		ParseCommand("setweap " .. string.char(amTeleport))
	elseif s == 6 then
		ParseCommand("setweap " .. string.char(amBlowTorch))
	elseif s == 7 then
		ParseCommand("setweap " .. string.char(amJetpack))
	elseif s == 8 then
		ParseCommand("setweap " .. string.char(amMolotov))
	elseif s == 9 then
		ParseCommand("setweap " .. string.char(amLowGravity))
	end

end

function onGearAdd(gear)
	if GetGearType(gear) == gtHedgehog then
		trackGear(gear)
	end
end

function onGearDelete(gear)
	if GetGearType(gear) == gtHedgehog then
		trackDeletion(gear)
	end
end

function onAmmoStoreInit()
	SetAmmo(amBazooka, 9, 0, 0, 0)
	SetAmmo(amGrenade, 9, 0, 0, 0)
	SetAmmo(amMolotov, 9, 0, 0, 0)
	SetAmmo(amShotgun, 9, 0, 0, 0)
	--SetAmmo(amFlamethrower, 9, 0, 0, 0) -- this was suggested on hw.org but it's not present on base
	SetAmmo(amFirePunch, 9, 0, 0, 0)
	SetAmmo(amMine, 9, 0, 0, 0)
	--SetAmmo(amCake, 1, 0, 2, 0) -- maybe it's beefcake?
	SetAmmo(amJetpack, 9, 0, 0, 0)
	SetAmmo(amBlowTorch, 9, 0, 0, 0)
	SetAmmo(amTeleport, 9, 0, 0, 0)
	SetAmmo(amLowGravity, 9, 0, 0, 0)
	--SetAmmo(amSkipGo, 9, 0, 0, 0) -- not needed with 1s turn time
end