share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua
author belphegorr <szabibibi@gmail.com>
Mon, 16 Jul 2012 20:56:55 +0300
changeset 7255 93cf6b3b89be
parent 7143 cd86f95b46c9
child 8043 da083f8d95e6
permissions -rw-r--r--
Fixed a visual gear in Mission 5 Animate.lua: added an optional boolean parameter to AnimVisualGear - follow
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
     1
----------------------------------
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
     2
-- THE SPECIALISTS MODE 0.7
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
     3
-- by mikade
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
     4
----------------------------------
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
     5
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
     6
-- version history
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
     7
-----------------
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
     8
-- version 0.1
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
     9
-----------------
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    10
-- concept test
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    11
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    12
----------------
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    13
-- version 0.2
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    14
----------------
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    15
-- added gfRandomOrder to gameflags
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    16
-- removed some deprecated variables/methods
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    17
-- fixed lack of portal reset
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    18
5362
5f0c46e78e50 Enable autoswitch on turn start for The Specialists Mode.
mikade
parents: 5277
diff changeset
    19
----------------
5f0c46e78e50 Enable autoswitch on turn start for The Specialists Mode.
mikade
parents: 5277
diff changeset
    20
-- version 0.3
5f0c46e78e50 Enable autoswitch on turn start for The Specialists Mode.
mikade
parents: 5277
diff changeset
    21
----------------
5f0c46e78e50 Enable autoswitch on turn start for The Specialists Mode.
mikade
parents: 5277
diff changeset
    22
-- added switching on start
5f0c46e78e50 Enable autoswitch on turn start for The Specialists Mode.
mikade
parents: 5277
diff changeset
    23
-- removed switch from engineer weaponset
5f0c46e78e50 Enable autoswitch on turn start for The Specialists Mode.
mikade
parents: 5277
diff changeset
    24
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
    25
----------------
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
    26
-- version 0.4
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
    27
----------------
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
    28
-- Attempted to:
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
    29
-- fix potential switch explit
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
    30
-- improve user feedback on start
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
    31
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    32
----------------
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    33
-- version 0.5
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    34
----------------
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    35
-- provision for variable minetimer / demo mines set to 5000ms
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    36
-- don't autoswitch if player only has 1 hog on his team
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    37
5817
70208e400a59 For now, don't spawn anything other than health crates.
mikade
parents: 5797
diff changeset
    38
----------------
70208e400a59 For now, don't spawn anything other than health crates.
mikade
parents: 5797
diff changeset
    39
-- version 0.6
70208e400a59 For now, don't spawn anything other than health crates.
mikade
parents: 5797
diff changeset
    40
----------------
70208e400a59 For now, don't spawn anything other than health crates.
mikade
parents: 5797
diff changeset
    41
-- for the meanwhile, don't drop any crates except health crates
70208e400a59 For now, don't spawn anything other than health crates.
mikade
parents: 5797
diff changeset
    42
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    43
----------------
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    44
-- version 0.7
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    45
----------------
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    46
-- perhogadmsdf :D :D :D :D
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    47
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    48
--------------------
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    49
--TO DO
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    50
--------------------
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    51
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    52
-- balance hog health, maybe
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    53
-- add proper gameflag checking, maybe (so that we can throw in a .cfg and let the users break everything)
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    54
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    55
loadfile(GetDataPath() .. "Scripts/Locale.lua")()
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    56
loadfile(GetDataPath() .. "Scripts/Tracker.lua")()
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    57
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
    58
local numhhs = 0
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
    59
local hhs = {}
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    60
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
    61
local currName
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    62
local lastName
5362
5f0c46e78e50 Enable autoswitch on turn start for The Specialists Mode.
mikade
parents: 5277
diff changeset
    63
local started = false
5f0c46e78e50 Enable autoswitch on turn start for The Specialists Mode.
mikade
parents: 5277
diff changeset
    64
local switchStage = 0
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    65
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    66
local hogCounter
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    67
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    68
function CountHog(gear)
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    69
	hogCounter = hogCounter +1
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    70
end
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    71
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    72
function onNewAmmoStore(groupIndex, hogIndex)
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    73
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    74
	SetAmmo(amSkip, 9, 0, 0, 0)
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    75
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    76
	if hogIndex == 0 then
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    77
		SetAmmo(amBazooka, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    78
		SetAmmo(amGrenade, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    79
		SetAmmo(amShotgun, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    80
	elseif hogIndex == 1 then
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    81
		SetAmmo(amGirder, 2, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    82
		SetAmmo(amBlowTorch, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    83
		SetAmmo(amPickHammer, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    84
	elseif hogIndex == 2 then
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    85
		SetAmmo(amRope, 9, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    86
		SetAmmo(amParachute, 9, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    87
		SetAmmo(amFirePunch, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    88
	elseif hogIndex == 3 then
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    89
		SetAmmo(amDynamite, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    90
		SetAmmo(amMine, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    91
		SetAmmo(amDrill, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    92
	elseif hogIndex == 4 then
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    93
		SetAmmo(amSniperRifle, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    94
		SetAmmo(amDEagle, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    95
		SetAmmo(amPortalGun, 2, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    96
	elseif hogIndex == 5 then
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    97
		SetAmmo(amSeduction, 9, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    98
		SetAmmo(amResurrector, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
    99
		SetAmmo(amInvulnerable, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   100
	elseif hogIndex == 6 then
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   101
		SetAmmo(amFlamethrower, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   102
		SetAmmo(amMolotov, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   103
		SetAmmo(amNapalm, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   104
	elseif hogIndex == 7 then
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   105
		SetAmmo(amBaseballBat, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   106
		SetAmmo(amGasBomb, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   107
		SetAmmo(amKamikaze, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   108
	end
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   109
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   110
end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   111
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   112
function CreateTeam()
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   113
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   114
	currTeam = ""
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   115
	lastTeam = ""
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   116
	z = 0
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   117
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   118
	for i = 0, (numhhs-1) do
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   119
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   120
			currTeam = GetHogTeamName(hhs[i])
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   121
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   122
			if currTeam == lastTeam then
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   123
					z = z + 1
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   124
			else
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   125
					z = 1
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   126
			end
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   127
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   128
			if z == 1 then
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   129
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   130
					SetHogName(hhs[i],"Soldier")
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   131
					SetHogHat(hhs[i], "sf_vega")
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   132
					SetHealth(hhs[i],200)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   133
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   134
			elseif z == 2 then
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   135
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   136
					SetHogHat(hhs[i], "Glasses")
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   137
					SetHogName(hhs[i],"Engineer")
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   138
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   139
			elseif z == 3 then
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   140
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   141
					SetHogName(hhs[i],"Ninja")
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   142
					SetHogHat(hhs[i], "NinjaFull")
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   143
					SetHealth(hhs[i],80)
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   144
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   145
			elseif z == 4 then
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   146
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   147
					SetHogName(hhs[i],"Demo")
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   148
					SetHogHat(hhs[i], "Skull")
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   149
					SetHealth(hhs[i],200)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   150
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   151
			elseif z == 5 then
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   152
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   153
					SetHogName(hhs[i],"Sniper")
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   154
					SetHogHat(hhs[i], "Sniper")
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   155
					SetHealth(hhs[i],120)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   156
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   157
			elseif z == 6 then
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   158
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   159
					SetHogName(hhs[i],"Saint")
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   160
					SetHogHat(hhs[i], "angel")
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   161
					SetHealth(hhs[i],300)
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   162
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   163
			elseif z == 7 then
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   164
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   165
					SetHogName(hhs[i],"Pyro")
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   166
					SetHogHat(hhs[i], "Gasmask")
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   167
					SetHealth(hhs[i],150)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   168
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   169
			elseif z == 8 then
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   170
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   171
					SetHogName(hhs[i],"Loon")
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   172
					SetHogHat(hhs[i], "clown")
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   173
					SetHealth(hhs[i],100)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   174
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   175
			end
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   176
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   177
			lastTeam = GetHogTeamName(hhs[i])
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   178
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   179
	end
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   180
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   181
end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   182
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   183
function onGameInit()
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   184
	GameFlags = gfRandomOrder + gfResetWeps + gfInfAttack + gfPlaceHog +gfPerHogAmmo
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   185
	Delay = 10
5817
70208e400a59 For now, don't spawn anything other than health crates.
mikade
parents: 5797
diff changeset
   186
	HealthCaseProb = 100
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   187
end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   188
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   189
function onGameStart()
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   190
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   191
	CreateTeam()
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   192
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   193
	ShowMission     (
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   194
                                loc("THE SPECIALISTS"),
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   195
                                loc("a Hedgewars mini-game"),
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   196
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   197
                                loc("Eliminate the enemy specialists.") .. "|" ..
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   198
                                " " .. "|" ..
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   199
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   200
                                loc("Game Modifiers: ") .. "|" ..
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   201
                                loc("Per-Hog Ammo") .. "|" ..
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   202
                                loc("Weapons Reset") .. "|" ..
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   203
                                loc("Unlimited Attacks") .. "|" ..
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   204
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   205
                                "", 4, 4000
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   206
                                )
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   207
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   208
	trackTeams()
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   209
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   210
end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   211
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   212
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   213
function onNewTurn()
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   214
	currName = GetHogName(CurrentHedgehog)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   215
	lastName = GetHogName(CurrentHedgehog)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   216
	started = true
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   217
	switchStage = 0
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   218
end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   219
7143
cd86f95b46c9 also change specialists
nemo
parents: 6747
diff changeset
   220
function onGameTick20()
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   221
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   222
	if (CurrentHedgehog ~= nil) then
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   223
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   224
		currName = GetHogName(CurrentHedgehog)
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   225
7143
cd86f95b46c9 also change specialists
nemo
parents: 6747
diff changeset
   226
		if (currName ~= lastName) and (switchStage > 5) then
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   227
			AddCaption(loc("Switched to ") .. currName .. "!")
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   228
		end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   229
7143
cd86f95b46c9 also change specialists
nemo
parents: 6747
diff changeset
   230
		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) and (switchStage < 5) then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   231
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   232
			AddCaption(loc("Prepare yourself") .. ", " .. currName .. "!")
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   233
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   234
			hogCounter = 0
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   235
			runOnHogsInTeam(CountHog, GetHogTeamName(CurrentHedgehog) )
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   236
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   237
			if hogCounter > 1 then
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   238
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   239
				switchStage = switchStage + 1
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   240
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   241
				if switchStage == 1 then
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   242
					AddAmmo(CurrentHedgehog, amSwitch, 1)
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   243
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   244
				elseif switchStage == 2 then
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   245
					ParseCommand("setweap " .. string.char(amSwitch))
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   246
				elseif switchStage == 3 then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   247
					SetGearMessage(CurrentHedgehog,gmAttack)
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   248
				elseif switchStage == 4 then
7143
cd86f95b46c9 also change specialists
nemo
parents: 6747
diff changeset
   249
					switchStage = 6
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   250
					AddAmmo(CurrentHedgehog, amSwitch, 0)
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   251
				end
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   252
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   253
			else
7143
cd86f95b46c9 also change specialists
nemo
parents: 6747
diff changeset
   254
				switchStage = 6
5362
5f0c46e78e50 Enable autoswitch on turn start for The Specialists Mode.
mikade
parents: 5277
diff changeset
   255
			end
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   256
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   257
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   258
		end
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   259
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   260
		lastName = currName
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   261
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   262
	end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   263
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   264
end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   265
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   266
function onGearAdd(gear)
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   267
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   268
    if GetGearType(gear) == gtHedgehog then
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   269
		hhs[numhhs] = gear
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   270
		numhhs = numhhs + 1
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   271
	elseif (GetGearType(gear) == gtMine) and (started == true) then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   272
		SetTimer(gear,5000)
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   273
	end
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   274
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   275
	if (GetGearType(gear) == gtHedgehog) or (GetGearType(gear) == gtResurrector) then
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   276
		trackGear(gear)
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   277
	end
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   278
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   279
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   280
end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   281
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   282
function onGearDelete(gear)
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   283
	if (GetGearType(gear) == gtHedgehog) or (GetGearType(gear) == gtResurrector) then
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   284
		trackDeletion(gear)
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   285
	end
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   286
end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   287
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   288
function onAmmoStoreInit()
5362
5f0c46e78e50 Enable autoswitch on turn start for The Specialists Mode.
mikade
parents: 5277
diff changeset
   289
--
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   290
end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   291