share/hedgewars/Data/Scripts/Multiplayer/Frenzy.lua
author Wuzzy <almikes@aol.com>
Sun, 27 Nov 2016 06:24:43 +0100
changeset 12092 9fe7eb1f7df2
parent 11015 7a905f0070ce
child 12337 75b41f029aaa
permissions -rw-r--r--
Construction Mode: Turn crate limit into a script parameter
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
HedgewarsScriptLoad("/Scripts/Tracker.lua")
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
     8
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
     9
local cTimer = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    10
local cn = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    11
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    12
function initialSetup(gear)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    13
	SetHealth(gear, 75) -- official is 80, but that assumes bazookas/grenades that do 50 damage
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    14
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    15
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    16
function showStartingInfo()
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    17
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    18
	ruleSet = "" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    19
	loc("RULES") .. ": " .. "|" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    20
	loc("Each turn is only ONE SECOND!") .. "|" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    21
	loc("Use your ready time to think.") .. "|" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    22
	loc("Slot keys save time! (F1-F10 by default)") .. "|" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    23
	" |" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    24
	loc("SLOTS") .. ": " .. "|" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    25
	loc("Slot") .. " 1 - " .. loc("Bazooka") .. "|" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    26
	loc("Slot") .. " 2 - " .. loc("Grenade") .. "|" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    27
	loc("Slot") .. " 3 - " .. loc("Shotgun") .. "|" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    28
	loc("Slot") .. " 4 - " .. loc("Shoryuken") .. "|" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    29
	loc("Slot") .. " 5 - " .. loc("Mine") .. "|" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    30
	loc("Slot") .. " 6 - " .. loc("Teleport") .. "|" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    31
	loc("Slot") .. " 7 - " .. loc("Blowtorch") .. "|" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    32
	loc("Slot") .. " 8 - " .. loc("Flying Saucer") .. "|" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    33
	loc("Slot") .. " 9 - " .. loc("Molotov") .. "|" ..
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    34
	loc("Slot") .. " 10 - " .. loc("Low Gravity")
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    35
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    36
	ShowMission(loc("FRENZY"),
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    37
                loc("a frenetic Hedgewars mini-game"),
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    38
                ruleSet, 0, 4000)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    39
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    40
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    41
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    42
function onGameInit()
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    43
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    44
	if TurnTime > 10001 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    45
		Ready = 8000
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    46
	else
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    47
		Ready = TurnTime
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    48
	end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    49
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    50
	TurnTime = 1000
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    51
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    52
	--These are the official settings, but I think I prefer allowing customization in this regard
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    53
	--MinesNum = 8
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    54
	--MinesTime = 3000
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    55
	--MinesDudPercent = 30
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    56
	--Explosives = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    57
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    58
	--Supposedly official settings
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    59
	HealthCaseProb = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    60
	CrateFreq = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    61
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    62
	--Approximation of Official Settings
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    63
	--SuddenDeathTurns = 10
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    64
	--WaterRise = 47
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    65
	--HealthDecrease = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    66
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    67
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    68
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    69
function onGameStart()
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    70
	showStartingInfo()
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    71
	runOnHogs(initialSetup)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    72
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    73
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    74
function onSlot(sln)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    75
	cTimer = 8
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    76
	cn = sln
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 onGameTick()
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    80
	if cTimer ~= 0 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    81
		cTimer = cTimer -1
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    82
		if cTimer == 1 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    83
			ChangeWep(cn)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    84
			cn = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    85
			cTimer = 0
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    86
		end
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
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    90
function ChangeWep(s)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    91
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    92
	if s == 0 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    93
		SetWeapon(amBazooka)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    94
	elseif s == 1 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    95
		SetWeapon(amGrenade)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    96
	elseif s == 2 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    97
		SetWeapon(amShotgun)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    98
	elseif s == 3 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
    99
		SetWeapon(amFirePunch)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   100
	elseif s == 4 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   101
		SetWeapon(amMine)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   102
	elseif s == 5 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   103
		SetWeapon(amTeleport)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   104
	elseif s == 6 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   105
		SetWeapon(amBlowTorch)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   106
	elseif s == 7 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   107
		SetWeapon(amJetpack)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   108
	elseif s == 8 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   109
		SetWeapon(amMolotov)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   110
	elseif s == 9 then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   111
		SetWeapon(amLowGravity)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   112
	end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   113
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   114
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   115
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   116
function onGearAdd(gear)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   117
	if GetGearType(gear) == gtHedgehog then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   118
		trackGear(gear)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   119
	end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   120
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   121
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   122
function onGearDelete(gear)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   123
	if GetGearType(gear) == gtHedgehog then
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   124
		trackDeletion(gear)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   125
	end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   126
end
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   127
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   128
function onAmmoStoreInit()
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   129
	SetAmmo(amBazooka, 9, 0, 0, 0)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   130
	SetAmmo(amGrenade, 9, 0, 0, 0)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   131
	SetAmmo(amMolotov, 9, 0, 0, 0)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   132
	SetAmmo(amShotgun, 9, 0, 0, 0)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   133
	--SetAmmo(amFlamethrower, 9, 0, 0, 0) -- this was suggested on hw.org but it's not present on base
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   134
	SetAmmo(amFirePunch, 9, 0, 0, 0)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   135
	SetAmmo(amMine, 9, 0, 0, 0)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   136
	--SetAmmo(amCake, 1, 0, 2, 0) -- maybe it's beefcake?
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   137
	SetAmmo(amJetpack, 9, 0, 0, 0)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   138
	SetAmmo(amBlowTorch, 9, 0, 0, 0)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   139
	SetAmmo(amTeleport, 9, 0, 0, 0)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   140
	SetAmmo(amLowGravity, 9, 0, 0, 0)
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   141
	--SetAmmo(amSkipGo, 9, 0, 0, 0) -- not needed with 1s turn time
7a905f0070ce CRLF purge
nemo
parents: 10289
diff changeset
   142
end