share/hedgewars/Data/Scripts/Multiplayer/Frenzy.lua
author Wuzzy <Wuzzy2@mail.ru>
Mon, 13 Nov 2017 22:14:45 +0100
changeset 12836 8610462e3d33
parent 12337 75b41f029aaa
child 14434 04231f066ada
permissions -rw-r--r--
Remove 2 unused number tags in Construction Mode GUI These numbers are shown aside the power tag, but the numbers never change. They don't serve any purpose and are just visual clutter and annoying, since they partially overlap. They are probably a leftover from copying code over from other scripts. With this changeset, only the power and turn time are left visible, as it is supposed to.

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