share/hedgewars/Data/Scripts/Multiplayer/Frenzy.lua
author Wuzzy <Wuzzy2@mail.ru>
Tue, 24 Jul 2018 20:07:58 +0200
branch0.9.24
changeset 13550 d42237d16acf
parent 12337 75b41f029aaa
child 14413 04231f066ada
permissions -rw-r--r--
Limit max droplet count to 50 (fix for 0.9.24 branch only) This fixes the issue with insane amounts of droplets in 0.9.24. It's temporary, the real fix is in default branch, but would be desyncing.

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

HedgewarsScriptLoad("/Scripts/Locale.lua")

local cTimer = 0
local cn = 0

local frenzyAmmos = {
	amBazooka,
	amGrenade,
	amMolotov,
	amShotgun,
	amFirePunch,
	amMine,
	amJetpack,
	amBlowTorch,
	amTeleport,
	amLowGravity
}

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)") .. "| |"
	for i=1, #frenzyAmmos do
		ruleSet = ruleSet .. string.format(loc("Slot %d: %s"), i, GetAmmoName(frenzyAmmos[i])) .. "|"
	end

	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()
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

-- Keyboard slot shortcuts
function ChangeWep(s)

	if s >= 0 and s <= 9 then
		SetWeapon(frenzyAmmos[s+1])
	end

end

function onAmmoStoreInit()
	-- Add frenzy ammos
	for i=1, #frenzyAmmos do
		SetAmmo(frenzyAmmos[i], 9, 0, 0, 0)
	end
	SetAmmo(amSkip, 9, 0, 0, 0)
end