share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua
author Wuzzy <Wuzzy2@mail.ru>
Fri, 07 Jun 2019 15:09:42 +0200
changeset 15135 13e7d4eccb67
parent 14563 90c215f83273
permissions -rw-r--r--
CTF/Control: Fix incomplete hedgehog loop bounds
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
     1
----------------------------------
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
     2
-- THE SPECIALISTS
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
     3
-- original style by mikade
5277
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
14523
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
     6
-- SCRIPT PARAMETER SYNTAX
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
     7
--[[
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
     8
With the script parameter, you can change the order of specialists per team.
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
     9
14524
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    10
== Changing the specialists for all teams ==
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    11
In the script parameter, put:
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    12
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    13
    t=XXXXXXXX
14523
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    14
14524
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    15
Where 'X' is a “specialist letter” (see below). Each letter stands for
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    16
the role of a hedgehog in the team (in that order).
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    17
If you leave out a letter, that hedgehog will be the default.
14523
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    18
14524
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    19
== Changing the specialists for on a per-team basis ==
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    20
Same as above, but instead of “t”, you use “t1”, “t2”, ... “t8” for
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    21
each of the teams (team 1 to team 8).
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    22
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    23
== Specialist letters ==
14523
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    24
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    25
  S = Soldier
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    26
  E = Engineer
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    27
  N = Ninja
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    28
  D = Demo
14563
90c215f83273 TS: Restore 2 of the "specialist" letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14528
diff changeset
    29
  X = Sniper
90c215f83273 TS: Restore 2 of the "specialist" letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14528
diff changeset
    30
  H = Saint
14523
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    31
  P = Pyro
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    32
  L = Loon
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    33
14524
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    34
== Examples ==
14523
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    35
Example 1:
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    36
14524
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    37
    t=SSSSPPPP
14523
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    38
14524
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    39
4 soldiers and 4 pyros for all teams.
14523
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    40
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    41
Example 2:
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    42
14563
90c215f83273 TS: Restore 2 of the "specialist" letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14528
diff changeset
    43
    t1=LPHXDNES,t2=NNNNNNNN
14523
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    44
14524
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    45
Team 1: Loon, Pyro, Saint, Sniper, Demo, Ninja, Engineer, Soldier.
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    46
Team 2: All-ninja team.
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    47
All other teams use the default settings.
14523
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    48
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    49
]]
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
    50
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
    51
--------------------
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
    52
-- TODO
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
    53
--------------------
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
    54
-- add proper gameflag checking, maybe (so that we can throw in a .cfg and let the users break everything)
5362
5f0c46e78e50 Enable autoswitch on turn start for The Specialists Mode.
mikade
parents: 5277
diff changeset
    55
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    56
8043
da083f8d95e6 We need custom script loading function in lua now
unc0rr
parents: 7143
diff changeset
    57
HedgewarsScriptLoad("/Scripts/Locale.lua")
da083f8d95e6 We need custom script loading function in lua now
unc0rr
parents: 7143
diff changeset
    58
HedgewarsScriptLoad("/Scripts/Tracker.lua")
14521
f5487302d53b Allow customising the teams
nemo
parents: 14406
diff changeset
    59
HedgewarsScriptLoad("/Scripts/Params.lua")
f5487302d53b Allow customising the teams
nemo
parents: 14406
diff changeset
    60
f5487302d53b Allow customising the teams
nemo
parents: 14406
diff changeset
    61
-- default team values
f5487302d53b Allow customising the teams
nemo
parents: 14406
diff changeset
    62
local currTeamIdx = 0;
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
    63
local teamRoles = {
14563
90c215f83273 TS: Restore 2 of the "specialist" letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14528
diff changeset
    64
	{'S','E','N','D','X','H','P','L'},
90c215f83273 TS: Restore 2 of the "specialist" letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14528
diff changeset
    65
	{'S','E','N','D','X','H','P','L'},
90c215f83273 TS: Restore 2 of the "specialist" letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14528
diff changeset
    66
	{'S','E','N','D','X','H','P','L'},
90c215f83273 TS: Restore 2 of the "specialist" letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14528
diff changeset
    67
	{'S','E','N','D','X','H','P','L'},
90c215f83273 TS: Restore 2 of the "specialist" letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14528
diff changeset
    68
	{'S','E','N','D','X','H','P','L'},
90c215f83273 TS: Restore 2 of the "specialist" letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14528
diff changeset
    69
	{'S','E','N','D','X','H','P','L'},
90c215f83273 TS: Restore 2 of the "specialist" letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14528
diff changeset
    70
	{'S','E','N','D','X','H','P','L'},
90c215f83273 TS: Restore 2 of the "specialist" letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14528
diff changeset
    71
	{'S','E','N','D','X','H','P','L'}
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
    72
};
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    73
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
    74
local numhhs = 0
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
    75
local hhs = {}
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
    76
5362
5f0c46e78e50 Enable autoswitch on turn start for The Specialists Mode.
mikade
parents: 5277
diff changeset
    77
local started = false
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
    78
14521
f5487302d53b Allow customising the teams
nemo
parents: 14406
diff changeset
    79
function onParameters()
f5487302d53b Allow customising the teams
nemo
parents: 14406
diff changeset
    80
	parseParams()
14524
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    81
	-- All teams
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    82
	if params['t'] ~= nil then
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    83
		for i = 1, 8 do
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    84
			for j = 1, 8 do
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    85
				if string.len(params['t']) >= j  then
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    86
					teamRoles[i][j] = string.upper(string.sub(params['t'],j,j));
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    87
				end
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    88
			end
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    89
		end
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    90
	end
213a636f57fe TS: Add script param to set specialists for all teams at once
Wuzzy <Wuzzy2@mail.ru>
parents: 14523
diff changeset
    91
	-- Specific team
14521
f5487302d53b Allow customising the teams
nemo
parents: 14406
diff changeset
    92
	for i = 1, 8 do
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
    93
		if params['t'..i] ~= nil then
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
    94
			for j = 1, 8 do
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
    95
				if string.len(params['t'..i]) >= j  then
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
    96
					teamRoles[i][j] = string.upper(string.sub(params['t'..i],j,j));
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
    97
				end
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
    98
			end
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
    99
		end
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   100
	end
14521
f5487302d53b Allow customising the teams
nemo
parents: 14406
diff changeset
   101
end
f5487302d53b Allow customising the teams
nemo
parents: 14406
diff changeset
   102
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   103
function onNewAmmoStore(groupIndex, hogIndex)
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   104
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   105
	SetAmmo(amSkip, 9, 0, 0, 0)
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   106
	groupIndex = groupIndex + 1
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   107
	hogIndex = hogIndex + 1
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   108
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   109
	if teamRoles[groupIndex][hogIndex] == 'S' then
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   110
		SetAmmo(amBazooka, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   111
		SetAmmo(amGrenade, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   112
		SetAmmo(amShotgun, 1, 0, 0, 0)
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   113
	elseif teamRoles[groupIndex][hogIndex] == 'E' then
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   114
		SetAmmo(amGirder, 2, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   115
		SetAmmo(amBlowTorch, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   116
		SetAmmo(amPickHammer, 1, 0, 0, 0)
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   117
	elseif teamRoles[groupIndex][hogIndex] == 'N' then
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   118
		SetAmmo(amRope, 9, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   119
		SetAmmo(amParachute, 9, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   120
		SetAmmo(amFirePunch, 1, 0, 0, 0)
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   121
	elseif teamRoles[groupIndex][hogIndex] == 'D' then
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   122
		SetAmmo(amDynamite, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   123
		SetAmmo(amMine, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   124
		SetAmmo(amDrill, 1, 0, 0, 0)
14563
90c215f83273 TS: Restore 2 of the "specialist" letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14528
diff changeset
   125
	elseif teamRoles[groupIndex][hogIndex] == 'X' then
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   126
		SetAmmo(amSniperRifle, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   127
		SetAmmo(amDEagle, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   128
		SetAmmo(amPortalGun, 2, 0, 0, 0)
14563
90c215f83273 TS: Restore 2 of the "specialist" letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14528
diff changeset
   129
	elseif teamRoles[groupIndex][hogIndex] == 'H' then
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   130
		SetAmmo(amSeduction, 9, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   131
		SetAmmo(amResurrector, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   132
		SetAmmo(amInvulnerable, 1, 0, 0, 0)
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   133
		SetAmmo(amLowGravity, 1, 0, 0, 0)
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   134
	elseif teamRoles[groupIndex][hogIndex] == 'P' then
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   135
		SetAmmo(amFlamethrower, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   136
		SetAmmo(amMolotov, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   137
		SetAmmo(amNapalm, 1, 0, 0, 0)
14523
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
   138
	elseif teamRoles[groupIndex][hogIndex] == 'L' then
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   139
		SetAmmo(amBaseballBat, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   140
		SetAmmo(amGasBomb, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   141
		SetAmmo(amKamikaze, 1, 0, 0, 0)
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   142
	end
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   143
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   144
end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   145
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   146
function CreateTeam()
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   147
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   148
	currTeam = ""
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   149
	lastTeam = ""
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   150
	z = 0
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   151
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   152
	for i = 0, (numhhs-1) do
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   153
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   154
		currTeam = GetHogTeamName(hhs[i])
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   155
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   156
		if currTeam == lastTeam then
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   157
			z = z + 1
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   158
		else
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   159
			z = 1
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   160
			currTeamIdx = currTeamIdx + 1;
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   161
		end
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   162
14528
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   163
		-- Scale health of each hog with “initial health” setting from game scheme.
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   164
		-- 100 = default health
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   165
		-- 200 = double health for all hogs
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   166
		-- 50 = half health for all hogs
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   167
		local function scaleHealth(health)
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   168
			local newHealth = div(health * InitHealth, 100)
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   169
			-- At least 1 health
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   170
			if newHealth <= 0 then
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   171
				newHealth = 1
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   172
			end
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   173
			return newHealth
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   174
		end
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   175
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   176
		if teamRoles[currTeamIdx][z] == 'S' then
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   177
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   178
			SetHogName(hhs[i],loc("Soldier"))
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   179
			SetHogHat(hhs[i], "sf_vega")
14528
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   180
			SetHealth(hhs[i], scaleHealth(200))
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   181
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   182
		elseif teamRoles[currTeamIdx][z] == 'E' then
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   183
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   184
			SetHogHat(hhs[i], "Glasses")
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   185
			SetHogName(hhs[i],loc("Engineer"))
14528
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   186
			SetHealth(hhs[i], scaleHealth(100))
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   187
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   188
		elseif teamRoles[currTeamIdx][z] == 'N' then
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   189
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   190
			SetHogName(hhs[i],loc("Ninja"))
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   191
			SetHogHat(hhs[i], "NinjaFull")
14528
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   192
			SetHealth(hhs[i], scaleHealth(80))
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   193
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   194
		elseif teamRoles[currTeamIdx][z] == 'D' then
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   195
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   196
			SetHogName(hhs[i],loc("Demo"))
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   197
			SetHogHat(hhs[i], "Skull")
14528
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   198
			SetHealth(hhs[i], scaleHealth(200))
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   199
14563
90c215f83273 TS: Restore 2 of the "specialist" letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14528
diff changeset
   200
		elseif teamRoles[currTeamIdx][z] == 'X' then
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   201
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   202
			SetHogName(hhs[i],loc("Sniper"))
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   203
			SetHogHat(hhs[i], "Sniper")
14528
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   204
			SetHealth(hhs[i], scaleHealth(120))
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   205
14563
90c215f83273 TS: Restore 2 of the "specialist" letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14528
diff changeset
   206
		elseif teamRoles[currTeamIdx][z] == 'H' then
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   207
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   208
			SetHogName(hhs[i],loc("Saint"))
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   209
			SetHogHat(hhs[i], "angel")
14528
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   210
			SetHealth(hhs[i], scaleHealth(300))
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   211
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   212
		elseif teamRoles[currTeamIdx][z] == 'P' then
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   213
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   214
			SetHogName(hhs[i],loc("Pyro"))
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   215
			SetHogHat(hhs[i], "Gasmask")
14528
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   216
			SetHealth(hhs[i], scaleHealth(150))
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   217
14523
a97216ff1c51 Document TS script param syntax, change some letters
Wuzzy <Wuzzy2@mail.ru>
parents: 14522
diff changeset
   218
		elseif teamRoles[currTeamIdx][z] == 'L' then
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   219
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   220
			SetHogName(hhs[i],loc("Loon"))
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   221
			SetHogHat(hhs[i], "clown")
14528
e176bf229649 TS: Scale health with the “initial health” setting from game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14526
diff changeset
   222
			SetHealth(hhs[i], scaleHealth(100))
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   223
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   224
		end
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   225
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   226
		lastTeam = GetHogTeamName(hhs[i])
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   227
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   228
	end
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   229
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   230
end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   231
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   232
function onGameInit()
14526
8a11548cb1d2 TS: Improve configurability by game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   233
	-- Force-disable harmful game flags
8a11548cb1d2 TS: Improve configurability by game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   234
	DisableGameFlags(gfSharedAmmo, gfKing)
8a11548cb1d2 TS: Improve configurability by game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   235
	-- Force-enable game-critical game flags
8a11548cb1d2 TS: Improve configurability by game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   236
	EnableGameFlags(gfPerHogAmmo, gfResetWeps)
8a11548cb1d2 TS: Improve configurability by game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   237
	-- NOTE: For your game scheme, these game flags are recommended: gfResetWeps, gfPlaceHog, gfSwitchHog, gfInfAttack
8a11548cb1d2 TS: Improve configurability by game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   238
8a11548cb1d2 TS: Improve configurability by game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   239
	-- No weapon crates
5817
70208e400a59 For now, don't spawn anything other than health crates.
mikade
parents: 5797
diff changeset
   240
	HealthCaseProb = 100
14526
8a11548cb1d2 TS: Improve configurability by game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   241
8a11548cb1d2 TS: Improve configurability by game scheme
Wuzzy <Wuzzy2@mail.ru>
parents: 14525
diff changeset
   242
	-- Instructions
14525
c96079ee4687 TS: Simplify mission panel, fix bad string concatenation
Wuzzy <Wuzzy2@mail.ru>
parents: 14524
diff changeset
   243
	Goals = loc("The Specialists: Each hedgehog starts with its own weapon set")
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   244
end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   245
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   246
function onGameStart()
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   247
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   248
	CreateTeam()
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   249
	trackTeams()
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   250
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   251
end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   252
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   253
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   254
function onNewTurn()
13278
8f579173b161 The Specialits: Use gfSwitchHog for hog switching and delete the terrible Lua hacks
Wuzzy <Wuzzy2@mail.ru>
parents: 12355
diff changeset
   255
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   256
	started = true
14525
c96079ee4687 TS: Simplify mission panel, fix bad string concatenation
Wuzzy <Wuzzy2@mail.ru>
parents: 14524
diff changeset
   257
	AddCaption(string.format(loc("Prepare yourself, %s!"), GetHogName(CurrentHedgehog)))
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   258
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   259
end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   260
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   261
function onGearAdd(gear)
5382
d5321b22aed2 Altered switch behavior on 'The Specialists'.
mikade
parents: 5362
diff changeset
   262
14522
2fd8f4cd3aa4 Clean up indents and comments in The_Specialists.lua
Wuzzy <Wuzzy2@mail.ru>
parents: 14521
diff changeset
   263
	if GetGearType(gear) == gtHedgehog then
6747
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   264
		hhs[numhhs] = gear
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   265
		numhhs = numhhs + 1
3f85b103f29f use per hog ammo game flag. improves AI play
mikade
parents: 5827
diff changeset
   266
	elseif (GetGearType(gear) == gtMine) and (started == true) then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   267
		SetTimer(gear,5000)
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   268
	end
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   269
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   270
	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
   271
		trackGear(gear)
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   272
	end
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   273
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   274
end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   275
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents:
diff changeset
   276
function onGearDelete(gear)
5457
48fe8e03a9cf Don't activate switch if player only has 1 hog
mikade
parents: 5382
diff changeset
   277
	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
   278
		trackDeletion(gear)
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5817
diff changeset
   279
	end
5277
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