share/hedgewars/Data/Scripts/Multiplayer/Frenzy.lua
author Wuzzy <Wuzzy2@mail.ru>
Tue, 22 Jan 2019 07:15:55 +0100
changeset 14663 93a7b78259fb
parent 14419 6843c4551cde
child 15074 e16f906224fd
permissions -rw-r--r--
HedgeEditor: More efficient gear info tag handling
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11015
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
     1
-------------------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
     2
-- FRENZY
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
     3
-- a hedgewars mode inspired by Hysteria
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
     4
-------------------------------------------
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
     5
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
     6
HedgewarsScriptLoad("/Scripts/Locale.lua")
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
     7
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
     8
local cTimer = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
     9
local cn = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    10
12342
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    11
local frenzyAmmos = {
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    12
	amBazooka,
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    13
	amGrenade,
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    14
	amMolotov,
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    15
	amShotgun,
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    16
	amFirePunch,
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    17
	amMine,
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    18
	amJetpack,
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    19
	amBlowTorch,
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    20
	amTeleport,
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    21
	amLowGravity
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    22
}
11015
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    23
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    24
function showStartingInfo()
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    25
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    26
	ruleSet = "" ..
12342
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    27
	loc("RULES:") .. " |" ..
11015
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    28
	loc("Each turn is only ONE SECOND!") .. "|" ..
14418
04231f066ada Frenzy: Hide slot key info in Touch (there are no slot keys in Touch)
Wuzzy <Wuzzy2@mail.ru>
parents: 12342
diff changeset
    29
	loc("Use your ready time to think.")
04231f066ada Frenzy: Hide slot key info in Touch (there are no slot keys in Touch)
Wuzzy <Wuzzy2@mail.ru>
parents: 12342
diff changeset
    30
	if INTERFACE ~= "touch" then
04231f066ada Frenzy: Hide slot key info in Touch (there are no slot keys in Touch)
Wuzzy <Wuzzy2@mail.ru>
parents: 12342
diff changeset
    31
		ruleSet = ruleSet .. "|" ..
04231f066ada Frenzy: Hide slot key info in Touch (there are no slot keys in Touch)
Wuzzy <Wuzzy2@mail.ru>
parents: 12342
diff changeset
    32
		loc("Slot keys save time! (F1-F10 by default)") .. "| |"
04231f066ada Frenzy: Hide slot key info in Touch (there are no slot keys in Touch)
Wuzzy <Wuzzy2@mail.ru>
parents: 12342
diff changeset
    33
		for i=1, #frenzyAmmos do
04231f066ada Frenzy: Hide slot key info in Touch (there are no slot keys in Touch)
Wuzzy <Wuzzy2@mail.ru>
parents: 12342
diff changeset
    34
			ruleSet = ruleSet .. string.format(loc("Slot %d: %s"), i, GetAmmoName(frenzyAmmos[i])) .. "|"
04231f066ada Frenzy: Hide slot key info in Touch (there are no slot keys in Touch)
Wuzzy <Wuzzy2@mail.ru>
parents: 12342
diff changeset
    35
		end
12342
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    36
	end
11015
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    37
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    38
	ShowMission(loc("FRENZY"),
12342
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    39
                loc("A frenetic Hedgewars mini-game"),
11015
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    40
                ruleSet, 0, 4000)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    41
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    42
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    43
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    44
function onGameInit()
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    45
14419
6843c4551cde Frenzy: More consistent ready time setting
Wuzzy <Wuzzy2@mail.ru>
parents: 14418
diff changeset
    46
	if TurnTime > 8000 then
11015
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    47
		Ready = 8000
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    48
	else
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    49
		Ready = TurnTime
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    50
	end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    51
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    52
	TurnTime = 1000
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    53
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    54
	--These are the official settings, but I think I prefer allowing customization in this regard
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    55
	--MinesNum = 8
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    56
	--MinesTime = 3000
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    57
	--MinesDudPercent = 30
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    58
	--Explosives = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    59
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    60
	--Supposedly official settings
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    61
	HealthCaseProb = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    62
	CrateFreq = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    63
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    64
	--Approximation of Official Settings
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    65
	--SuddenDeathTurns = 10
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    66
	--WaterRise = 47
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    67
	--HealthDecrease = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    68
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    69
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    70
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    71
function onGameStart()
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    72
	showStartingInfo()
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    73
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    74
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    75
function onSlot(sln)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    76
	cTimer = 8
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    77
	cn = sln
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    78
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    79
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    80
function onGameTick()
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    81
	if cTimer ~= 0 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    82
		cTimer = cTimer -1
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    83
		if cTimer == 1 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    84
			ChangeWep(cn)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    85
			cn = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    86
			cTimer = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    87
		end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    88
	end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    89
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    90
12342
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    91
-- Keyboard slot shortcuts
11015
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    92
function ChangeWep(s)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    93
12342
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    94
	if s >= 0 and s <= 9 then
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    95
		SetWeapon(frenzyAmmos[s+1])
11015
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    96
	end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    97
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    98
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    99
12342
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
   100
function onAmmoStoreInit()
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
   101
	-- Add frenzy ammos
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
   102
	for i=1, #frenzyAmmos do
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
   103
		SetAmmo(frenzyAmmos[i], 9, 0, 0, 0)
11015
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   104
	end
12342
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
   105
	SetAmmo(amSkip, 9, 0, 0, 0)
11015
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   106
end