share/hedgewars/Data/Scripts/Multiplayer/Frenzy.lua
author Wuzzy <Wuzzy2@mail.ru>
Sun, 13 Dec 2020 21:16:25 +0100
changeset 15794 95db10dcad71
parent 15154 73d8cc72239e
permissions -rw-r--r--
Fix crash when spawning vgtSmallDamageTag in Lua
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
12337
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
	amShotgun,
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    15
	amFirePunch,
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    16
	amMine,
15154
73d8cc72239e Frenzy: Change ammo slots to be closer to original slots
Wuzzy <Wuzzy2@mail.ru>
parents: 15153
diff changeset
    17
	amMolotov,
73d8cc72239e Frenzy: Change ammo slots to be closer to original slots
Wuzzy <Wuzzy2@mail.ru>
parents: 15153
diff changeset
    18
	amBlowTorch,
12337
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    19
	amJetpack,
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 = "" ..
12337
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!") .. "|" ..
14434
04231f066ada Frenzy: Hide slot key info in Touch (there are no slot keys in Touch)
Wuzzy <Wuzzy2@mail.ru>
parents: 12337
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: 12337
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: 12337
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: 12337
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: 12337
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: 12337
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: 12337
diff changeset
    35
		end
12337
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"),
12337
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    39
                loc("A frenetic Hedgewars mini-game"),
15090
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 14435
diff changeset
    40
                ruleSet, -amMolotov, 4000)
11015
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
14435
6843c4551cde Frenzy: More consistent ready time setting
Wuzzy <Wuzzy2@mail.ru>
parents: 14434
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
15153
378efa87f558 Frenzy: Fix incorrect ammo slot numbers in ammo menu
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
    69
	for s=1, #frenzyAmmos do
378efa87f558 Frenzy: Fix incorrect ammo slot numbers in ammo menu
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
    70
		SetAmmoSlot(frenzyAmmos[s], s)
378efa87f558 Frenzy: Fix incorrect ammo slot numbers in ammo menu
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
    71
	end
378efa87f558 Frenzy: Fix incorrect ammo slot numbers in ammo menu
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
    72
	SetAmmoSlot(amSkip, 10)
11015
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 onGameStart()
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    76
	showStartingInfo()
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    77
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    78
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    79
function onSlot(sln)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    80
	cTimer = 8
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    81
	cn = sln
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    82
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    83
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    84
function onGameTick()
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    85
	if cTimer ~= 0 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    86
		cTimer = cTimer -1
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    87
		if cTimer == 1 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    88
			ChangeWep(cn)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    89
			cn = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    90
			cTimer = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    91
		end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    92
	end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    93
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    94
12337
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    95
-- Keyboard slot shortcuts
11015
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    96
function ChangeWep(s)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    97
12337
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    98
	if s >= 0 and s <= 9 then
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
    99
		SetWeapon(frenzyAmmos[s+1])
11015
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   100
	end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   101
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   102
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   103
12337
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
   104
function onAmmoStoreInit()
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
   105
	-- Add frenzy ammos
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
   106
	for i=1, #frenzyAmmos do
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
   107
		SetAmmo(frenzyAmmos[i], 9, 0, 0, 0)
11015
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   108
	end
12337
75b41f029aaa Refactor Frenzy script
Wuzzy <almikes@aol.com>
parents: 11015
diff changeset
   109
	SetAmmo(amSkip, 9, 0, 0, 0)
11015
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   110
end