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