share/hedgewars/Data/Scripts/Multiplayer/Capture_the_Flag.lua
author Wuzzy <almikes@aol.com>
Wed, 20 Apr 2016 17:53:07 +0200
changeset 12031 6bc9a499c60b
parent 11912 ce9e0f8e43f4
child 12084 8f222872d432
permissions -rw-r--r--
HedgeEditor: Improve secondary message E.g. mine timers are displayed with unit, etc.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
     1
---------------------------------------
5819
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
     2
-- CAPTURE_THE_FLAG GAMEPLAY MODE 0.5
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
     3
-- by mikade
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
     4
---------------------------------------
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
     5
11911
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
     6
---- Script parameter
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
     7
-- With “captures=<number>” you can set your own capture limit, e.g. “captures=5” for 5 captures.
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
     8
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
     9
-- Version History
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    10
---------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    11
-- 0.1
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    12
---------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    13
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    14
-- [conversion from map-dependant CTF_Blizzard to map independant Capture the Flag]
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    15
-- added an intial starting stage where flagspawn is decided by the players (weapon set will require a jetpack unless I set)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    16
-- changed the flag from a crate to a visual gear, and all associated methods and checks relating to flags (five hours later, lol)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    17
-- changed starting/respawning positioning to accommodate different map sizes
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    18
-- added another circle to mark flag spawn
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    19
-- added gameFlag filter
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    20
-- changed scoring feedback
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    21
-- cleaned up some code
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    22
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    23
-- removing own flag from spawning point no longer possible
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    24
-- destroying flags no longer possible.
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    25
-- added basic glowing circle effect to spawn area
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    26
-- added expanding circle to fgear itself
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    27
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    28
-- removed teleporters
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    29
-- removed random crate drops (this should be decided by scheme)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    30
-- removed set map criteria like minesNum, turnTime, explosives etc. except for sudden death
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    31
-- removed weapon defintions
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    32
-- removed placement and respawning methods, hopefully divideTeams will have this covered
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    33
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    34
---------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    35
-- 0.2
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    36
---------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    37
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    38
-- [now with user friendliness]
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    39
-- flag is now placed wherever you end up at the end of your first turn, this ensures that it is always placed by turn 3
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    40
-- removed a bunch of backup code and no-longer needed variables / methods from CTF_Blizzard days
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    41
-- removed an aura that was still mistakenly hanging about
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    42
-- added an in-game note about placements
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    43
-- added an in-game note about the rules of the game
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    44
-- added translation support and loc()'ed everything
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    45
-- changed things so the seed is no longer always the same...
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    46
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    47
-- In this version:
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    48
---------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    49
-- 0.3
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    50
---------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    51
-- [fufufufu kamikaze fix]
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    52
-- added nill checks to make sure the player doesn't generate errors by producing a nil value in hhs[] when he uses kamikaze
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    53
-- added a check to make sure the player doesn't kamikaze straight down and make the flag's starting point underwater
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    54
-- added a check to make sure the player drops the flag if he has it and he uses kamikaze
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    55
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
    56
--------
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
    57
-- 0.4
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
    58
--------
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
    59
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
    60
-- remove user-branding and version numbers
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
    61
-- removed some stuff that wasn't needed
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
    62
-- fix piano strike exploit
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
    63
-- changed delay to allow for better portals
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
    64
-- changed starting feedback a little
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
    65
-- increased the radius around the circle indicating the flag thief so that it doesn't obscure his health
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
    66
5819
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
    67
--------
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
    68
-- 0.5
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
    69
--------
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
    70
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
    71
-- add support for more players
5821
afb988c1a2fe Allow limited form of SuddenDeath (WaterRise = 0) in both CTF modes
mikade
parents: 5819
diff changeset
    72
-- allow limited sudden death
5819
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
    73
-- stop TimeBox ruining my life
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
    74
-- profit???
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
    75
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    76
-----------------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    77
--SCRIPT BEGINS
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    78
-----------------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    79
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    80
-- enable awesome translaction support so we can use loc() wherever we want
8043
da083f8d95e6 We need custom script loading function in lua now
unc0rr
parents: 7838
diff changeset
    81
HedgewarsScriptLoad("/Scripts/Locale.lua")
11911
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
    82
HedgewarsScriptLoad("/Scripts/Params.lua")
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    83
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    84
---------------------------------------------------------------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    85
----------lots of bad variables and things
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    86
----------because someone is too lazy
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    87
----------to read about tables properly
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    88
------------------ "Oh well, they probably have the memory"
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    89
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    90
local gameStarted = false
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
    91
local gameTurns = 0
11911
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
    92
local captureLimit = 3
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    93
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    94
--------------------------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    95
-- hog and team tracking variales
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    96
--------------------------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    97
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    98
local numhhs = 0 -- store number of hedgehogs
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
    99
local hhs = {} -- store hedgehog gears
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   100
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   101
local numTeams --  store the number of teams in the game
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   102
local teamNameArr = {}	-- store the list of teams
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   103
local teamSize = {}	-- store how many hogs per team
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   104
local teamIndex = {} -- at what point in the hhs{} does each team begin
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   105
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   106
-------------------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   107
-- flag variables
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   108
-------------------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   109
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   110
local fPlaced = {} -- has the flag been placed TRUE/FALSE
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   111
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   112
local fGear = {}	-- pointer to the visual gears that represent the flag
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   113
local fGearX = {}
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   114
local fGearY = {}
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   115
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   116
local fThief = {}	-- pointer to the hogs who stole the flags
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   117
local fIsMissing = {}	-- have the flags been destroyed or captured
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   118
local fNeedsRespawn = {}	-- do the flags need to be respawned
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   119
local fCaptures = {}	-- the team "scores" how many captures
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   120
local fSpawnX = {}		-- spawn X for flags
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   121
local fSpawnY = {}		-- spawn Y for flags
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   122
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   123
local fThiefX = {}
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   124
local fThiefY = {}
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   125
local FTTC = 0 -- flag thief tracker counter
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   126
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   127
local fSpawnC = {} -- spawn circle marker
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   128
local fCirc = {} -- flag/carrier marker circles
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   129
local fCol = {} -- colour of the clans
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   130
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   131
local fGearRad = 0
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   132
local fGearRadMin = 5
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   133
local fGearRadMax = 33
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   134
local fGearTimer = 0
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   135
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   136
------------------------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   137
--flag methods
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   138
------------------------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   139
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   140
function CheckScore(teamID)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   141
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   142
	if teamID == 0 then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   143
		alt = 1
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   144
	elseif teamID == 1 then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   145
		alt = 0
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   146
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   147
11911
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   148
	if fCaptures[teamID] == captureLimit then
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   149
		for i = 0, (numhhs-1) do
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   150
			if hhs[i] ~= nil then
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   151
				if GetHogClan(hhs[i]) == alt then
7838
5c2337f8dbb2 Issue #443 - change in syntax for effects
nemo
parents: 5827
diff changeset
   152
					SetEffect(hhs[i], heResurrectable, 0)
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   153
					SetHealth(hhs[i],0)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   154
				end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   155
			end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   156
		end
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   157
		if CurrentHedgehog ~= nil then
11910
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   158
			AddCaption(string.format(loc("Victory for %s!"), GetHogTeamName(CurrentHedgehog)))
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   159
			showMissionAndScorebar()
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   160
		end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   161
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   162
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   163
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   164
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   165
function DoFlagStuff(gear)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   166
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   167
	if (gear == fGear[0]) then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   168
		wtf = 0
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   169
		bbq = 1
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   170
	elseif (gear == fGear[1]) then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   171
		wtf = 1
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   172
		bbq = 0
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   173
	end
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   174
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   175
	-- player has successfully captured the enemy flag
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   176
	if (GetHogClan(CurrentHedgehog) == wtf) and (CurrentHedgehog == fThief[bbq]) and (fIsMissing[wtf] == false) then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   177
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   178
		DeleteVisualGear(fGear[wtf])
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   179
		fGear[wtf] = nil -- the flag has now disappeared
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   180
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   181
		fIsMissing[wtf] = false
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   182
		fNeedsRespawn[wtf] = true
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   183
		fIsMissing[bbq] = false
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   184
		fNeedsRespawn[bbq] = true
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   185
		fCaptures[wtf] = fCaptures[wtf] +1
11910
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   186
		AddCaption(string.format(loc("%s has scored!"), GetHogName(CurrentHedgehog)))
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   187
		showMissionAndScorebar()
11912
ce9e0f8e43f4 CTF: Play sound when capturing flag
Wuzzy <almikes@aol.com>
parents: 11911
diff changeset
   188
		PlaySound(sndHomerun)
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   189
		fThief[bbq] = nil -- player no longer has the enemy flag
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   190
		CheckScore(wtf)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   191
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   192
	--if the player is returning the flag
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   193
	elseif (GetHogClan(CurrentHedgehog) == wtf) and (fIsMissing[wtf] == true) then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   194
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   195
		DeleteVisualGear(fGear[wtf])
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   196
		fGear[wtf] = nil -- the flag has now disappeared
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   197
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   198
		fNeedsRespawn[wtf] = true
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   199
		HandleRespawns() -- this will set fIsMissing[wtf] to false :)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   200
		AddCaption(loc("Flag returned!"))
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   201
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   202
	--if the player is taking the enemy flag
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   203
	elseif GetHogClan(CurrentHedgehog) == bbq then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   204
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   205
		DeleteVisualGear(fGear[wtf])
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   206
		fGear[wtf] = nil -- the flag has now disappeared
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   207
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   208
		fIsMissing[wtf] = true
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   209
		for i = 0,numhhs-1 do
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   210
			if CurrentHedgehog ~= nil then
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   211
				if CurrentHedgehog == hhs[i] then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   212
					fThief[wtf] = hhs[i]
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   213
				end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   214
			end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   215
		end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   216
		AddCaption(loc("Flag captured!"))
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   217
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   218
	end
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   219
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   220
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   221
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   222
function CheckFlagProximity()
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   223
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   224
	for i = 0, 1 do
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   225
		if fGear[i] ~= nil then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   226
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   227
			g1X = fGearX[i]
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   228
			g1Y = fGearY[i]
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   229
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   230
			g2X, g2Y = GetGearPosition(CurrentHedgehog)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   231
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   232
			q = g1X - g2X
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   233
			w = g1Y - g2Y
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   234
			dist = (q*q) + (w*w)
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   235
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   236
			if dist < 500 then --1600
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   237
				DoFlagStuff(fGear[i])
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   238
			end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   239
		end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   240
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   241
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   242
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   243
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   244
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   245
function HandleRespawns()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   246
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   247
	for i = 0, 1 do
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   248
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   249
		if fNeedsRespawn[i] == true then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   250
			fGear[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   251
			fGearX[i] = fSpawnX[i]
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   252
			fGearY[i] = fSpawnY[i]
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
   253
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   254
			fNeedsRespawn[i] = false
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   255
			fIsMissing[i] = false -- new, this should solve problems of a respawned flag being "returned" when a player tries to score
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   256
			AddCaption(loc("Flag respawned!"))
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   257
		end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   258
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   259
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   260
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   261
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   262
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   263
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   264
function FlagThiefDead(gear)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   265
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   266
	if (gear == fThief[0]) then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   267
		wtf = 0
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   268
		bbq = 1
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   269
	elseif (gear == fThief[1]) then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   270
		wtf = 1
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   271
		bbq = 0
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   272
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   273
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   274
	if fThief[wtf] ~= nil then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   275
		-- falls into water
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   276
		--ShowMission(LAND_HEIGHT,  fThiefY[wtf], (LAND_HEIGHT - fThiefY[wtf]), 0, 0)
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   277
		if (LAND_HEIGHT - fThiefY[wtf]) < 15 then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   278
			fIsMissing[wtf] = true
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   279
			fNeedsRespawn[wtf] = true
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   280
			HandleRespawns()
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   281
		else	--normally
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   282
			fGearX[wtf]  =  fThiefX[wtf]
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   283
			fGearY[wtf]  =  fThiefY[wtf]
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   284
			fGear[wtf] = AddVisualGear(fGearX[wtf],fGearY[wtf],vgtCircle,0,true)
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   285
		end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   286
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   287
		AddVisualGear(fThiefX[wtf], fThiefY[wtf], vgtBigExplosion, 0, false)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   288
		fThief[wtf] = nil
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   289
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   290
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   291
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   292
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   293
function HandleCircles()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   294
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   295
	fGearTimer = fGearTimer + 1
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   296
	if fGearTimer == 50 then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   297
		fGearTimer = 0
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   298
		fGearRad = fGearRad + 1
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   299
		if fGearRad > fGearRadMax then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   300
			fGearRad = fGearRadMin
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   301
		end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   302
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   303
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   304
	for i = 0, 1 do
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   305
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   306
		--SetVisualGearValues(fSpawnC[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, 50, 3, fCol[i]) -- draw a circ for spawning area
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   307
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   308
		if fIsMissing[i] == false then -- draw a flag marker at the flag's spawning place
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   309
			SetVisualGearValues(fCirc[i], fSpawnX[i],fSpawnY[i], 20, 20, 0, 10, 0, 33, 3, fCol[i])
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   310
			if fGear[i] ~= nil then -- draw the flag gear itself
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   311
				SetVisualGearValues(fGear[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, fGearRad, 2, fCol[i])
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   312
			end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   313
		elseif (fIsMissing[i] == true) and (fNeedsRespawn[i] == false) then
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
   314
			if fThief[i] ~= nil then -- draw circle round flag carrier			-- 33
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
   315
				SetVisualGearValues(fCirc[i], fThiefX[i], fThiefY[i], 20, 200, 0, 0, 100, 50, 3, fCol[i])
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   316
				--AddCaption("circle marking carrier")
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   317
			elseif fThief[i] == nil then -- draw cirle round dropped flag
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   318
				--g1X,g1Y,g4,g5,g6,g7,g8,g9,g10,g11 =  GetVisualGearValues(fGear[i])
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   319
				--SetVisualGearValues(fCirc[i], g1X, g1Y, 20, 200, 0, 0, 100, 33, 2, fCol[i])
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   320
				SetVisualGearValues(fCirc[i], fGearX[i], fGearY[i], 20, 200, 0, 0, 100, 33, 3, fCol[i])
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   321
				--AddCaption('dropped circle marker')
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   322
				if fGear[i] ~= nil then -- flag gear itself
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   323
					--SetVisualGearValues(fGear[i], g1X, g1Y, 20, 200, 0, 0, 100, 10, 4, fCol[i])
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   324
					SetVisualGearValues(fGear[i], fGearX[i], fGearY[i], 20, 200, 0, 0, 100, fGearRad, 2, fCol[i])
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   325
					--AddCaption('dropped flag itself')
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   326
				end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   327
			end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   328
		end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   329
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   330
		if fNeedsRespawn[i] == true then -- if the flag has been destroyed, no need for a circle
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   331
			SetVisualGearValues(fCirc[i], fSpawnX[i],fSpawnY[i], 20, 200, 0, 0, 100, 0, 0, fCol[i])
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   332
			--AddCaption("needs respawn = true. flag 'destroyed'?")
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   333
		end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   334
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   335
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   336
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   337
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   338
------------------------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   339
-- general methods
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   340
------------------------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   341
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   342
function CheckDistance(gear1, gear2)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   343
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   344
	g1X, g1Y = GetGearPosition(gear1)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   345
	g2X, g2Y = GetGearPosition(gear2)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   346
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   347
	g1X = g1X - g2X
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   348
	g1Y = g1Y - g2Y
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   349
	z = (g1X*g1X) + (g1Y*g1Y)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   350
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   351
	dist = z
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   352
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   353
	return dist
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   354
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   355
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   356
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   357
function RebuildTeamInfo()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   358
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   359
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   360
	-- make a list of individual team names
5819
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   361
	for i = 0, (TeamsCount-1) do
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   362
		teamNameArr[i] = i
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   363
		teamSize[i] = 0
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   364
		teamIndex[i] = 0
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   365
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   366
	numTeams = 0
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   367
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   368
	for i = 0, (numhhs-1) do
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   369
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   370
		z = 0
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   371
		unfinished = true
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   372
		while(unfinished == true) do
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   373
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   374
			newTeam = true
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   375
			tempHogTeamName = GetHogTeamName(hhs[i]) -- this is the new name
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   376
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   377
			if tempHogTeamName == teamNameArr[z] then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   378
				newTeam = false
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   379
				unfinished = false
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   380
			end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   381
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   382
			z = z + 1
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   383
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   384
			if z == TeamsCount then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   385
				unfinished = false
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   386
				if newTeam == true then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   387
					teamNameArr[numTeams] = tempHogTeamName
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   388
					numTeams = numTeams + 1
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   389
				end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   390
			end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   391
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   392
		end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   393
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   394
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   395
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   396
	-- find out how many hogs per team, and the index of the first hog in hhs
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   397
	for i = 0, numTeams-1 do
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   398
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   399
		for z = 0, numhhs-1 do
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   400
			if GetHogTeamName(hhs[z]) == teamNameArr[i] then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   401
				if teamSize[i] == 0 then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   402
					teamIndex[i] = z -- should give starting index
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   403
				end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   404
				teamSize[i] = teamSize[i] + 1
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   405
				--add a pointer so this hog appears at i in hhs
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   406
			end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   407
		end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   408
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   409
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   410
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   411
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   412
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   413
function StartTheGame()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   414
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   415
	gameStarted = true
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   416
	AddCaption(loc("Game Started!"))
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   417
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   418
	for i = 0, 1 do
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   419
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   420
		-- if someone uses kamikaze downwards, this can happen as the hog won't respawn
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   421
		if (LAND_HEIGHT - fSpawnY[i]) < 0 then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   422
			tempG = AddGear(0, 0, gtTarget, 0, 0, 0, 0)
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   423
     			FindPlace(tempG, true, 0, LAND_WIDTH, true)
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   424
			fSpawnX[i], fSpawnY[i] = GetGearPosition(tempG)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   425
			DeleteGear(tempG)
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   426
		end
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   427
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   428
		fGear[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   429
		fCirc[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   430
		fSpawnC[i] = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   431
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   432
		fGearX[i] = fSpawnX[i]
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   433
		fGearY[i] = fSpawnY[i]
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   434
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   435
		fCol[i] = GetClanColor(i)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   436
		fIsMissing[i] = false
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   437
		fNeedsRespawn[i] = false
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   438
		fCaptures[i] = 0
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   439
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   440
		--SetVisualGearValues(zxc, 1000,1000, 20, 100, 0,    10,                     1,         100,        5,      GetClanColor(0))
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   441
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   442
		SetVisualGearValues(fSpawnC[i], fSpawnX[i],fSpawnY[i], 20, 100, 0, 10, 0, 75, 5, fCol[i])
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   443
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   444
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   445
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   446
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   447
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   448
------------------------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   449
-- game methods
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   450
------------------------
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   451
11911
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   452
function onParameters()
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   453
	parseParams()
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   454
	if params["captures"] ~= nil then
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   455
		local s = string.match(params["captures"], "(%d*)")
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   456
		if s ~= nil then
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   457
			captureLimit = math.max(1, tonumber(s))
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   458
		end
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   459
	end
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   460
end
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   461
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   462
function onGameInit()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   463
11886
34ede05e4d4f Remove old Fort Mode from frontend
Wuzzy <almikes@aol.com>
parents: 10036
diff changeset
   464
	DisableGameFlags(gfKing)
10036
3be36d2fdca6 use new API for changing GameFlags
sheepluva
parents: 8043
diff changeset
   465
	EnableGameFlags(gfDivideTeams)
3be36d2fdca6 use new API for changing GameFlags
sheepluva
parents: 8043
diff changeset
   466
5821
afb988c1a2fe Allow limited form of SuddenDeath (WaterRise = 0) in both CTF modes
mikade
parents: 5819
diff changeset
   467
	--SuddenDeathTurns = 999 -- suddendeath is off, effectively
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   468
	WaterRise = 0
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   469
	Delay = 10
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   470
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   471
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   472
11910
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   473
function showMissionAndScorebar(instaHide)
11911
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   474
	local captures
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   475
	if captureLimit == 1 then
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   476
		captures = string.format(loc("- First team to capture the flag wins"), captureLimit)
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   477
	else
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   478
		captures = string.format(loc("- First team to score %d captures wins"), captureLimit)
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   479
	end
11910
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   480
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   481
	local rules = loc("Rules:") .. " |" ..
11911
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   482
		loc("- Place your team flag at the end of your first turn") .. "|" ..
11910
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   483
		loc("- Return the enemy flag to your base to score") .."|"..
11911
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   484
		captures .. "|" ..
11910
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   485
		loc("- You may only score when your flag is in your base") .."|"..
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   486
		loc("- Hogs will drop the flag when killed") .."|"..
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   487
		loc("- Dropped flags may be returned or recaptured").."|"..
11911
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   488
		loc("- Hogs will be revived")
11910
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   489
11911
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   490
	local scoreboard = ""
11910
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   491
11911
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   492
	if gameStarted then
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   493
		scoreboard = "|" .. loc("Scores: ") .. "|"
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   494
		for i=0, 1 do
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   495
			scoreboard = scoreboard .. string.format(loc("%s: %d"), teamNameArr[i], fCaptures[i])
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   496
			if i~=1 then scoreboard = scoreboard .. "|" end
11910
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   497
		end
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   498
	end
11911
0e943402b94f CTF: Allow to set capture limit with script param
Wuzzy <almikes@aol.com>
parents: 11910
diff changeset
   499
	local mission = rules .. scoreboard
11910
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   500
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   501
	ShowMission(loc("Capture The Flag"), loc("A Hedgewars minigame"), mission, 0, 0)
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   502
	if instaHide then
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   503
		HideMission()
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   504
	end
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   505
end
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   506
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   507
function onGameStart()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   508
11910
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   509
	showMissionAndScorebar()
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   510
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   511
	RebuildTeamInfo()
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   512
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   513
	-- should gfDivideTeams do this automatically?
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   514
	--[[for i = 0, (TeamsCount-1) do
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   515
		for g = teamIndex[i], (teamIndex[i]+teamSize[i]-1) do
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   516
			if GetHogClan(hhs[g]) == 0 then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   517
				FindPlace(hhs[g], false, 0, LAND_WIDTH/2)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   518
			elseif GetHogClan(hhs[g]) == 1 then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   519
				FindPlace(hhs[g], false, LAND_WIDTH/2, LAND_WIDTH)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   520
			end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   521
		end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   522
	end]]
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   523
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   524
	fPlaced[0] = false
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   525
	fPlaced[1] = false
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   526
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   527
	--zxc = AddVisualGear(fSpawnX[i],fSpawnY[i],vgtCircle,0,true)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   528
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   529
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   530
	--SetVisualGearValues(zxc, 1000,1000, 20, 255, 1,    10,                     0,         200,        1,      GetClanColor(0))
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   531
					--minO,max0 -glowyornot	--pulsate timer	 -- fuckall      -- radius -- width  -- colour
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   532
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   533
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   534
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   535
function onNewTurn()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   536
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   537
	gameTurns = gameTurns + 1
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   538
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   539
	if lastTeam ~= GetHogTeamName(CurrentHedgehog) then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   540
		lastTeam = GetHogTeamName(CurrentHedgehog)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   541
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   542
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   543
	--AddCaption("Handling respawns")
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   544
	if gameStarted == true then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   545
		HandleRespawns()
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   546
	--new method of placing starting flags
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   547
	elseif gameTurns == 1 then
11910
71ebc4c19b7f CTF: Clean up mission panel
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   548
		showMissionAndScorebar()
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   549
	elseif gameTurns == 2 then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   550
		fPlaced[0] = true
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   551
	elseif gameTurns == 3 then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   552
		fPlaced[1] = true
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   553
		StartTheGame()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   554
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   555
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   556
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   557
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   558
function onGameTick()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   559
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   560
	-- onRessurect calls AFTER you have resurrected,
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   561
	-- so keeping track of x,y a few milliseconds before
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   562
	-- is useful
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   563
	--FTTC = FTTC + 1
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   564
	--if FTTC == 100 then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   565
	--	FTTC = 0
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   566
		for i = 0,1 do
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   567
			if fThief[i] ~= nil then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   568
				fThiefX[i] = GetX(fThief[i])
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   569
				fThiefY[i] = GetY(fThief[i])
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   570
			end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   571
		end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   572
	--end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   573
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   574
	-- things we wanna check often
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   575
	if (CurrentHedgehog ~= nil) then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   576
		--AddCaption(LAND_HEIGHT - GetY(CurrentHedgehog))
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   577
		--AddCaption(GetX(CurrentHedgehog) .. "; " .. GetY(CurrentHedgehog))
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   578
		--CheckTeleporters()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   579
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   580
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   581
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   582
	if gameStarted == true then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   583
		HandleCircles()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   584
		if CurrentHedgehog ~= nil then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   585
			CheckFlagProximity()
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   586
		end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   587
	elseif CurrentHedgehog ~= nil then -- if the game hasn't started yet, keep track of where we are gonna put the flags on turn end
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   588
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   589
		if GetHogClan(CurrentHedgehog) == 0 then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   590
			i = 0
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   591
		elseif GetHogClan(CurrentHedgehog) == 1 then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   592
			i = 1
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   593
		end
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   594
11909
930f57e70b49 Capture The Flag: Fix flag of first team spawning at second hog (issue #9)
Wuzzy <almikes@aol.com>
parents: 11886
diff changeset
   595
		if TurnTimeLeft == 0 then
930f57e70b49 Capture The Flag: Fix flag of first team spawning at second hog (issue #9)
Wuzzy <almikes@aol.com>
parents: 11886
diff changeset
   596
			fSpawnX[i] = GetX(CurrentHedgehog)
930f57e70b49 Capture The Flag: Fix flag of first team spawning at second hog (issue #9)
Wuzzy <almikes@aol.com>
parents: 11886
diff changeset
   597
			fSpawnY[i] = GetY(CurrentHedgehog)
930f57e70b49 Capture The Flag: Fix flag of first team spawning at second hog (issue #9)
Wuzzy <almikes@aol.com>
parents: 11886
diff changeset
   598
		end
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   599
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   600
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   601
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   602
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   603
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   604
function onGearResurrect(gear)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   605
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   606
	--AddCaption("A gear has been resurrected!")
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   607
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   608
	-- mark the flag thief as dead if he needed a respawn
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   609
	for i = 0,1 do
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   610
		if gear == fThief[i] then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   611
			FlagThiefDead(gear)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   612
		end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   613
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   614
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   615
	-- should be covered by gfDivideTeams, actually
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   616
	-- place hogs belonging to each clan either left or right side of map
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   617
	--if GetHogClan(gear) == 0 then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   618
	--	FindPlace(gear, false, 0, LAND_WIDTH/2)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   619
	--elseif GetHogClan(gear) == 1 then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   620
	--	FindPlace(gear, false, LAND_WIDTH/2, LAND_WIDTH)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   621
	--end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   622
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   623
	AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   624
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   625
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   626
5819
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   627
function InABetterPlaceNow(gear)
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   628
	for i = 0, (numhhs-1) do
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   629
		if gear == hhs[i] then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   630
5819
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   631
			for i = 0,1 do
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   632
				if gear == fThief[i] then
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   633
					FlagThiefDead(gear)
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   634
				end
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   635
			end
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   636
			hhs[i] = nil
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   637
		end
5819
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   638
	end
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   639
end
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   640
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   641
function onHogHide(gear)
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   642
	 InABetterPlaceNow(gear)
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   643
end
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   644
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   645
function onHogRestore(gear)
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   646
	match = false
5819
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   647
	for i = 0, (numhhs-1) do
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   648
		if (hhs[i] == nil) and (match == false) then
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   649
			hhs[i] = gear
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   650
			--AddCaption(GetHogName(gear) .. " has reappeared it seems!")
5819
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   651
			match = true
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   652
		end
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   653
	end
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   654
end
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   655
e23ced69e03d Add support for more players.
mikade
parents: 5277
diff changeset
   656
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   657
function onGearAdd(gear)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   658
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   659
	if GetGearType(gear) == gtHedgehog then
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   660
		hhs[numhhs] = gear
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   661
		numhhs = numhhs + 1
7838
5c2337f8dbb2 Issue #443 - change in syntax for effects
nemo
parents: 5827
diff changeset
   662
		SetEffect(gear, heResurrectable, 1)
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   663
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
   664
	elseif GetGearType(gear) == gtPiano then
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
   665
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
   666
		for i = 0, 1 do
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
   667
			if CurrentHedgehog == fThief[i] then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   668
				FlagThiefDead(gear)
5277
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
   669
			end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
   670
		end
09beef0752ab PianoStrike exploit fix for Capture The Flag.
mikade
parents: 4662
diff changeset
   671
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   672
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   673
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   674
end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   675
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   676
function onGearDelete(gear)
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   677
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   678
	if GetGearType(gear) == gtHedgehog then
5827
a416f1070fdf we don't need trailing whitespaces... I guess :P
sheepluva
parents: 5821
diff changeset
   679
		InABetterPlaceNow(gear)
4662
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   680
	end
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   681
63aafc9c2a81 Add a bunch of lua from mikade, update translation files
mikade+nemo
parents:
diff changeset
   682
end