author | unc0rr |
Wed, 17 Nov 2010 20:36:35 +0300 | |
changeset 4363 | e944cc43f7a4 |
parent 4361 | 64ea345ab655 |
child 4368 | b89235e401e5 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
883 | 3 |
* Copyright (c) 2004-2008 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 5 |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
4 | 8 |
* |
183 | 9 |
* This program is distributed in the hope that it will be useful, |
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
4 | 13 |
* |
183 | 14 |
* You should have received a copy of the GNU General Public License |
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
4 | 17 |
*) |
18 |
||
2599 | 19 |
{$INCLUDE "options.inc"} |
2587
0dfa56a8513c
fix a segfault in the iphone simulator by moving options.inc at the beginning of the file
koda
parents:
2586
diff
changeset
|
20 |
|
4 | 21 |
unit uTeams; |
22 |
interface |
|
4357
a1fcfc341a52
Introduce unit uTypes in order to remove some cyclic unit dependencies
unC0Rr
parents:
4218
diff
changeset
|
23 |
uses uConsts, uKeys, uGears, uRandom, uFloat, uStats, uVisualGears, uCollisions, GLunit, uSound, uTypes; |
534 | 24 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2695
diff
changeset
|
25 |
var CurrentTeam: PTeam; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2695
diff
changeset
|
26 |
PreviousTeam: PTeam; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2695
diff
changeset
|
27 |
CurrentHedgehog: PHedgehog; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2695
diff
changeset
|
28 |
TeamsArray: array[0..Pred(cMaxTeams)] of PTeam; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2695
diff
changeset
|
29 |
TeamsCount: Longword; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2695
diff
changeset
|
30 |
ClansArray: array[0..Pred(cMaxTeams)] of PClan; |
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2695
diff
changeset
|
31 |
ClansCount: Longword; |
2856
cc70797a0b75
Adjust LocalClan when shuffling, set to -1 in case all local clans are bots.
nemo
parents:
2855
diff
changeset
|
32 |
LocalClan: LongInt; // last non-bot, non-extdriven clan |
cc70797a0b75
Adjust LocalClan when shuffling, set to -1 in case all local clans are bots.
nemo
parents:
2855
diff
changeset
|
33 |
LocalAmmo: LongInt; // last non-bot, non-extdriven clan's first team's ammo index |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2695
diff
changeset
|
34 |
CurMinAngle, CurMaxAngle: Longword; |
4014
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
35 |
GameOver: boolean; |
4 | 36 |
|
3038 | 37 |
procedure initModule; |
38 |
procedure freeModule; |
|
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
39 |
function AddTeam(TeamColor: Longword): PTeam; |
4 | 40 |
procedure SwitchHedgehog; |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
41 |
procedure AfterSwitchHedgehog; |
4 | 42 |
procedure InitTeams; |
43 |
function TeamSize(p: PTeam): Longword; |
|
47 | 44 |
procedure RecountTeamHealth(team: PTeam); |
72 | 45 |
procedure RestoreTeamsFromSave; |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
46 |
function CheckForWin: boolean; |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
47 |
procedure TeamGone(s: shortstring); |
2040 | 48 |
procedure TeamGoneEffect(var Team: TTeam); |
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
3890
diff
changeset
|
49 |
function GetTeamStatString(p: PTeam): shortstring; |
4 | 50 |
|
51 |
implementation |
|
4359 | 52 |
uses uMisc, uWorld, uLocale, uAmmos, uChat, uMobile, uVariables; |
371 | 53 |
const MaxTeamHealth: LongInt = 0; |
4 | 54 |
|
92
0c359a7a2356
- Fix win message to appear only after all hedgehogs death
unc0rr
parents:
89
diff
changeset
|
55 |
function CheckForWin: boolean; |
576 | 56 |
var AliveClan: PClan; |
306 | 57 |
s: shortstring; |
1011 | 58 |
t, AliveCount, i, j: LongInt; |
83 | 59 |
begin |
548 | 60 |
AliveCount:= 0; |
549 | 61 |
for t:= 0 to Pred(ClansCount) do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
62 |
if ClansArray[t]^.ClanHealth > 0 then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
63 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
64 |
inc(AliveCount); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
65 |
AliveClan:= ClansArray[t] |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
66 |
end; |
548 | 67 |
|
1299 | 68 |
if (AliveCount > 1) |
69 |
or ((AliveCount = 1) and ((GameFlags and gfOneClanMode) <> 0)) then exit(false); |
|
351 | 70 |
CheckForWin:= true; |
83 | 71 |
|
72 |
TurnTimeLeft:= 0; |
|
3774 | 73 |
ReadyTimeLeft:= 0; |
4014
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
74 |
if not GameOver then |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
75 |
begin |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
76 |
if AliveCount = 0 then |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
77 |
begin // draw |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
78 |
AddCaption(trmsg[sidDraw], cWhiteColor, capgrpGameState); |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
79 |
SendStat(siGameResult, trmsg[sidDraw]); |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
80 |
AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
81 |
end else // win |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
82 |
with AliveClan^ do |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
83 |
begin |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
84 |
if TeamsNumber = 1 then |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
85 |
s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName) // team wins |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
86 |
else |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
87 |
s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName); // clan wins |
549 | 88 |
|
4014
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
89 |
for j:= 0 to Pred(TeamsNumber) do |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
90 |
with Teams[j]^ do |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
91 |
for i:= 0 to cMaxHHIndex do |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
92 |
with Hedgehogs[i] do |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
93 |
if (Gear <> nil) then |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
94 |
Gear^.State:= gstWinner; |
2376 | 95 |
|
4014
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
96 |
AddCaption(s, cWhiteColor, capgrpGameState); |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
97 |
SendStat(siGameResult, s); |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
98 |
AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
99 |
end; |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
100 |
SendStats; |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
101 |
end; |
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
102 |
GameOver:= true |
83 | 103 |
end; |
104 |
||
4 | 105 |
procedure SwitchHedgehog; |
551 | 106 |
var c: LongWord; |
552 | 107 |
PrevHH, PrevTeam: LongWord; |
4 | 108 |
begin |
109 |
TargetPoint.X:= NoPointX; |
|
89 | 110 |
TryDo(CurrentTeam <> nil, 'nil Team', true); |
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
111 |
with CurrentHedgehog^ do |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
112 |
if (PreviousTeam <> nil) and PlacingHogs and Unplaced then |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
113 |
begin |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
114 |
Unplaced:= false; |
3697 | 115 |
if Gear <> nil then |
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
116 |
begin |
2763
f21d3ca74ef2
Do CI correctly. Still need to allow for mode in case of no teleports in ammo
nemo
parents:
2762
diff
changeset
|
117 |
DeleteCI(Gear); |
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
118 |
FindPlace(Gear, false, 0, LAND_WIDTH); |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
119 |
if Gear <> nil then AddGearCI(Gear) |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
120 |
end |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
121 |
end; |
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
122 |
|
1678 | 123 |
PreviousTeam:= CurrentTeam; |
547 | 124 |
|
944 | 125 |
with CurrentHedgehog^ do |
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
126 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
127 |
if Gear <> nil then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
128 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
129 |
MultiShootAttacks:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
130 |
Gear^.Message:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
131 |
Gear^.Z:= cHHZ; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
132 |
RemoveGearFromList(Gear); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
133 |
InsertGearToList(Gear) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
134 |
end |
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
135 |
end; |
4 | 136 |
|
550 | 137 |
c:= CurrentTeam^.Clan^.ClanIndex; |
4 | 138 |
repeat |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
139 |
inc(c); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
140 |
if c = ClansCount then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
141 |
begin |
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
142 |
if not PlacingHogs then inc(TotalRounds); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
143 |
c:= 0 |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
144 |
end; |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
145 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
146 |
with ClansArray[c]^ do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
147 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
148 |
PrevTeam:= CurrTeam; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
149 |
repeat |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
150 |
CurrTeam:= Succ(CurrTeam) mod TeamsNumber; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
151 |
CurrentTeam:= Teams[CurrTeam]; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
152 |
with CurrentTeam^ do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
153 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
154 |
PrevHH:= CurrHedgehog mod HedgehogsNumber; // prevent infinite loop when CurrHedgehog = 7, but HedgehogsNumber < 8 (team is destroyed before its first turn) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
155 |
repeat |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
156 |
CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
157 |
until (Hedgehogs[CurrHedgehog].Gear <> nil) or (CurrHedgehog = PrevHH) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
158 |
end |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
159 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (PrevTeam = CurrTeam); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
160 |
end |
2040 | 161 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
83 | 162 |
|
3928
2560731c860d
move all mobile-related functions in their own module, provides a structure for future mobile ports
koda
parents:
3890
diff
changeset
|
163 |
CurrentHedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]); |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
164 |
end; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
165 |
|
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
166 |
procedure AfterSwitchHedgehog; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
167 |
var g: PGear; |
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
168 |
i, t: LongInt; |
3960
ada50f8d4186
Remove bit of debug code from prior, don't switch weapons on end of turn (stick with whatever the last weapon was)
nemo
parents:
3935
diff
changeset
|
169 |
CurWeapon: PAmmo; |
ada50f8d4186
Remove bit of debug code from prior, don't switch weapons on end of turn (stick with whatever the last weapon was)
nemo
parents:
3935
diff
changeset
|
170 |
|
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
171 |
begin |
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
172 |
if PlacingHogs then |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
173 |
begin |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
174 |
PlacingHogs:= false; |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
175 |
for t:= 0 to Pred(TeamsCount) do |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
176 |
for i:= 0 to cMaxHHIndex do |
3697 | 177 |
if (TeamsArray[t]^.Hedgehogs[i].Gear <> nil) and (TeamsArray[t]^.Hedgehogs[i].Unplaced) then |
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
178 |
PlacingHogs:= true; |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
179 |
|
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
180 |
if not PlacingHogs then // Reset various things I mucked with |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
181 |
begin |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
182 |
for i:= 0 to ClansCount do |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
183 |
if ClansArray[i] <> nil then ClansArray[i]^.TurnNumber:= 0; |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
184 |
ResetWeapons |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
185 |
end |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
186 |
end; |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
187 |
|
2431
23242609c44b
Real fix to ammo slot overflow (bug triggered by r2411 fix)
unc0rr
parents:
2376
diff
changeset
|
188 |
inc(CurrentTeam^.Clan^.TurnNumber); |
23242609c44b
Real fix to ammo slot overflow (bug triggered by r2411 fix)
unc0rr
parents:
2376
diff
changeset
|
189 |
|
3960
ada50f8d4186
Remove bit of debug code from prior, don't switch weapons on end of turn (stick with whatever the last weapon was)
nemo
parents:
3935
diff
changeset
|
190 |
CurWeapon:= GetAmmoEntry(CurrentHedgehog^); |
ada50f8d4186
Remove bit of debug code from prior, don't switch weapons on end of turn (stick with whatever the last weapon was)
nemo
parents:
3935
diff
changeset
|
191 |
if CurWeapon^.Count = 0 then CurrentHedgehog^.CurAmmoType:= amNothing; |
2431
23242609c44b
Real fix to ammo slot overflow (bug triggered by r2411 fix)
unc0rr
parents:
2376
diff
changeset
|
192 |
|
602 | 193 |
with CurrentHedgehog^ do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
194 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
195 |
with Gear^ do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
196 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
197 |
Z:= cCurrHHZ; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
198 |
State:= gstHHDriven; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
199 |
Active:= true |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
200 |
end; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
201 |
RemoveGearFromList(Gear); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
202 |
InsertGearToList(Gear); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
203 |
FollowGear:= Gear |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
204 |
end; |
941
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
927
diff
changeset
|
205 |
|
4 | 206 |
ResetKbd; |
351 | 207 |
|
4218 | 208 |
if (GameFlags and gfDisableWind) = 0 then |
209 |
begin |
|
210 |
cWindSpeed:= rndSign(GetRandom * 2 * cMaxWindSpeed); |
|
211 |
// cWindSpeedf:= cWindSpeed.QWordValue / _1.QWordValue throws 'Internal error 200502052' on Darwin |
|
212 |
// see http://mantis.freepascal.org/view.php?id=17714 |
|
213 |
cWindSpeedf:= SignAs(cWindSpeed,cWindSpeed).QWordValue / SignAs(_1,_1).QWordValue; |
|
214 |
if cWindSpeed.isNegative then |
|
215 |
CWindSpeedf := -cWindSpeedf; |
|
216 |
g:= AddGear(0, 0, gtATSmoothWindCh, 0, _0, _0, 1); |
|
217 |
g^.Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed); |
|
4 | 218 |
{$IFDEF DEBUGFILE}AddFileLog('Wind = '+FloatToStr(cWindSpeed));{$ENDIF} |
4218 | 219 |
end; |
220 |
||
602 | 221 |
ApplyAmmoChanges(CurrentHedgehog^); |
800 | 222 |
|
1650
a65681cc27c2
Don't fallback to default binds set when switching to remotely driven team
unc0rr
parents:
1495
diff
changeset
|
223 |
if not CurrentTeam^.ExtDriven then SetBinds(CurrentTeam^.Binds); |
a65681cc27c2
Don't fallback to default binds set when switching to remotely driven team
unc0rr
parents:
1495
diff
changeset
|
224 |
|
176 | 225 |
bShowFinger:= true; |
800 | 226 |
|
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
227 |
if PlacingHogs then |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
228 |
begin |
3024 | 229 |
if CurrentHedgehog^.Unplaced then TurnTimeLeft:= 15000 |
2762
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
230 |
else TurnTimeLeft:= 0 |
2fbc8d35eb52
Mode to place hogs at start of game. Will probably need a bit more testing.
nemo
parents:
2758
diff
changeset
|
231 |
end |
4198 | 232 |
else TurnTimeLeft:= cHedgehogTurnTime; |
3774 | 233 |
if (TurnTimeLeft > 0) and (CurrentHedgehog^.BotLevel = 0) then |
234 |
begin |
|
3798 | 235 |
if CurrentTeam^.ExtDriven then |
236 |
PlaySound(sndIllGetYou, CurrentTeam^.voicepack) |
|
237 |
else |
|
238 |
PlaySound(sndYesSir, CurrentTeam^.voicepack); |
|
4198 | 239 |
if PlacingHogs or (cHedgehogTurnTime < 1000000) then ReadyTimeLeft:= cReadyDelay; |
3799 | 240 |
AddCaption(Format(shortstring(trmsg[sidReady]), CurrentTeam^.TeamName), cWhiteColor, capgrpGameState) |
3774 | 241 |
end |
242 |
else |
|
3798 | 243 |
begin |
244 |
if TurnTimeLeft > 0 then |
|
245 |
PlaySound(sndIllGetYou, CurrentTeam^.voicepack); |
|
246 |
ReadyTimeLeft:= 0 |
|
3952
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3935
diff
changeset
|
247 |
end; |
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3935
diff
changeset
|
248 |
|
d6412423da45
moved some utilities to a separate column with round buttons
koda
parents:
3935
diff
changeset
|
249 |
perfExt_NewTurnBeginning(); |
4 | 250 |
end; |
251 |
||
549 | 252 |
function AddTeam(TeamColor: Longword): PTeam; |
2695 | 253 |
var team: PTeam; |
549 | 254 |
c: LongInt; |
4 | 255 |
begin |
1170 | 256 |
TryDo(TeamsCount < cMaxTeams, 'Too many teams', true); |
2695 | 257 |
New(team); |
258 |
TryDo(team <> nil, 'AddTeam: team = nil', true); |
|
259 |
FillChar(team^, sizeof(TTeam), 0); |
|
260 |
team^.AttackBar:= 2; |
|
2806 | 261 |
team^.CurrHedgehog:= 0; |
2747 | 262 |
team^.Flag:= 'hedgewars'; |
547 | 263 |
|
2695 | 264 |
TeamsArray[TeamsCount]:= team; |
547 | 265 |
inc(TeamsCount); |
266 |
||
549 | 267 |
c:= Pred(ClansCount); |
268 |
while (c >= 0) and (ClansArray[c]^.Color <> TeamColor) do dec(c); |
|
269 |
if c < 0 then |
|
270 |
begin |
|
2695 | 271 |
new(team^.Clan); |
272 |
FillChar(team^.Clan^, sizeof(TClan), 0); |
|
273 |
ClansArray[ClansCount]:= team^.Clan; |
|
549 | 274 |
inc(ClansCount); |
2695 | 275 |
with team^.Clan^ do |
549 | 276 |
begin |
550 | 277 |
ClanIndex:= Pred(ClansCount); |
3379 | 278 |
Color:= TeamColor; |
549 | 279 |
end |
280 |
end else |
|
281 |
begin |
|
2695 | 282 |
team^.Clan:= ClansArray[c]; |
549 | 283 |
end; |
284 |
||
2695 | 285 |
with team^.Clan^ do |
549 | 286 |
begin |
2695 | 287 |
Teams[TeamsNumber]:= team; |
549 | 288 |
inc(TeamsNumber) |
289 |
end; |
|
290 |
||
2695 | 291 |
CurrentTeam:= team; |
292 |
AddTeam:= team; |
|
4 | 293 |
end; |
294 |
||
47 | 295 |
procedure RecountAllTeamsHealth; |
547 | 296 |
var t: LongInt; |
2376 | 297 |
begin |
547 | 298 |
for t:= 0 to Pred(TeamsCount) do |
299 |
RecountTeamHealth(TeamsArray[t]) |
|
47 | 300 |
end; |
301 |
||
302 |
procedure InitTeams; |
|
547 | 303 |
var i, t: LongInt; |
2784 | 304 |
th, h: LongInt; |
47 | 305 |
begin |
2726 | 306 |
|
547 | 307 |
for t:= 0 to Pred(TeamsCount) do |
4101
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
308 |
with TeamsArray[t]^ do |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
309 |
begin |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
310 |
if (not ExtDriven) and (Hedgehogs[0].BotLevel = 0) then |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
311 |
begin |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
312 |
LocalClan:= Clan^.ClanIndex; |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
313 |
LocalAmmo:= Hedgehogs[0].AmmoStore |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
314 |
end; |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
315 |
th:= 0; |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
316 |
for i:= 0 to cMaxHHIndex do |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
317 |
if Hedgehogs[i].Gear <> nil then |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
318 |
inc(th, Hedgehogs[i].Gear^.Health); |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
319 |
if th > MaxTeamHealth then MaxTeamHealth:= th; |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
320 |
// Some initial King buffs |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
321 |
if (GameFlags and gfKing) <> 0 then |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
322 |
begin |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
323 |
Hedgehogs[0].King:= true; |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
324 |
Hedgehogs[0].Hat:= 'crown'; |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
325 |
Hedgehogs[0].Effects[hePoisoned] := false; |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
326 |
h:= Hedgehogs[0].Gear^.Health; |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
327 |
Hedgehogs[0].Gear^.Health:= hwRound(int2hwFloat(th)*_0_375); |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
328 |
if Hedgehogs[0].Gear^.Health > h then |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
329 |
begin |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
330 |
dec(th, h); |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
331 |
inc(th, Hedgehogs[0].Gear^.Health); |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
332 |
if th > MaxTeamHealth then MaxTeamHealth:= th |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
333 |
end |
4102
96efb3bbf8e3
Extend shoppa hack to disable health crates to saucer and portal modes as well
nemo
parents:
4101
diff
changeset
|
334 |
else Hedgehogs[0].Gear^.Health:= h; |
96efb3bbf8e3
Extend shoppa hack to disable health crates to saucer and portal modes as well
nemo
parents:
4101
diff
changeset
|
335 |
Hedgehogs[0].InitialHealth:= Hedgehogs[0].Gear^.Health |
4101
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
336 |
end; |
c5967f360beb
Apply the reset to all hogs on all teams in uGears. Make InitialHealth same type as Health to avoid issues w/ initial health > 255. Update InitialHealth with the king buff.
nemo
parents:
4099
diff
changeset
|
337 |
end; |
2726 | 338 |
|
47 | 339 |
RecountAllTeamsHealth |
4 | 340 |
end; |
341 |
||
342 |
function TeamSize(p: PTeam): Longword; |
|
2695 | 343 |
var i, value: Longword; |
4 | 344 |
begin |
2695 | 345 |
value:= 0; |
4 | 346 |
for i:= 0 to cMaxHHIndex do |
2695 | 347 |
if p^.Hedgehogs[i].Gear <> nil then inc(value); |
348 |
TeamSize:= value; |
|
4 | 349 |
end; |
350 |
||
549 | 351 |
procedure RecountClanHealth(clan: PClan); |
352 |
var i: LongInt; |
|
353 |
begin |
|
354 |
with clan^ do |
|
355 |
begin |
|
356 |
ClanHealth:= 0; |
|
357 |
for i:= 0 to Pred(TeamsNumber) do |
|
358 |
inc(ClanHealth, Teams[i]^.TeamHealth) |
|
359 |
end |
|
360 |
end; |
|
361 |
||
47 | 362 |
procedure RecountTeamHealth(team: PTeam); |
371 | 363 |
var i: LongInt; |
47 | 364 |
begin |
365 |
with team^ do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
366 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
367 |
NewTeamHealthBarWidth:= 0; |
2376 | 368 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
369 |
if not hasGone then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
370 |
for i:= 0 to cMaxHHIndex do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
371 |
if Hedgehogs[i].Gear <> nil then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
372 |
inc(NewTeamHealthBarWidth, Hedgehogs[i].Gear^.Health); |
1352
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
373 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
374 |
TeamHealth:= NewTeamHealthBarWidth; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
375 |
if NewTeamHealthBarWidth > MaxTeamHealth then |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
376 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
377 |
MaxTeamHealth:= NewTeamHealthBarWidth; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
378 |
RecountAllTeamsHealth; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
379 |
end else NewTeamHealthBarWidth:= (NewTeamHealthBarWidth * cTeamHealthWidth) div MaxTeamHealth |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
380 |
end; |
549 | 381 |
|
382 |
RecountClanHealth(team^.Clan); |
|
383 |
||
2005 | 384 |
AddVisualGear(0, 0, vgtTeamHealthSorter) |
47 | 385 |
end; |
386 |
||
72 | 387 |
procedure RestoreTeamsFromSave; |
547 | 388 |
var t: LongInt; |
72 | 389 |
begin |
547 | 390 |
for t:= 0 to Pred(TeamsCount) do |
391 |
TeamsArray[t]^.ExtDriven:= false |
|
72 | 392 |
end; |
393 |
||
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
394 |
procedure TeamGone(s: shortstring); |
2040 | 395 |
var t: LongInt; |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
396 |
begin |
1362 | 397 |
t:= 0; |
1356 | 398 |
while (t < cMaxTeams) |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
399 |
and (TeamsArray[t] <> nil) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
400 |
and (TeamsArray[t]^.TeamName <> s) do inc(t); |
1356 | 401 |
if (t = cMaxTeams) or (TeamsArray[t] = nil) then exit; |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
402 |
|
1356 | 403 |
with TeamsArray[t]^ do |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
404 |
begin |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
405 |
AddChatString('** '+ TeamName + ' is gone'); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
406 |
hasGone:= true |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
407 |
end; |
2376 | 408 |
|
1363 | 409 |
RecountTeamHealth(TeamsArray[t]) |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
410 |
end; |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
411 |
|
2040 | 412 |
procedure TeamGoneEffect(var Team: TTeam); |
413 |
var i: LongInt; |
|
414 |
begin |
|
415 |
with Team do |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
416 |
for i:= 0 to cMaxHHIndex do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
417 |
with Hedgehogs[i] do |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
418 |
if Gear <> nil then |
2826
fbcfc86ef477
Remove invulnerability protection from the team gone effect
nemo
parents:
2806
diff
changeset
|
419 |
begin |
fbcfc86ef477
Remove invulnerability protection from the team gone effect
nemo
parents:
2806
diff
changeset
|
420 |
Gear^.Invulnerable:= false; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
421 |
Gear^.Damage:= Gear^.Health |
2826
fbcfc86ef477
Remove invulnerability protection from the team gone effect
nemo
parents:
2806
diff
changeset
|
422 |
end |
2040 | 423 |
end; |
424 |
||
3379 | 425 |
function GetTeamStatString(p: PTeam): shortstring; |
426 |
var s: ansistring; |
|
427 |
begin |
|
428 |
s:= p^.TeamName + ':' + inttostr(p^.TeamHealth) + ':'; |
|
429 |
GetTeamStatString:= s; |
|
430 |
end; |
|
431 |
||
3038 | 432 |
procedure initModule; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2695
diff
changeset
|
433 |
begin |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
434 |
CurrentTeam:= nil; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
435 |
PreviousTeam:= nil; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
436 |
CurrentHedgehog:= nil; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
437 |
TeamsCount:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
438 |
ClansCount:= 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
439 |
LocalClan:= -1; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2905
diff
changeset
|
440 |
LocalAmmo:= -1; |
4014
e9baae83370b
Avoid doing this stuff twice, even if CheckForWin is called twice
nemo
parents:
3996
diff
changeset
|
441 |
GameOver:= false |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2695
diff
changeset
|
442 |
end; |
4 | 443 |
|
3038 | 444 |
procedure freeModule; |
3051 | 445 |
var i: LongWord; |
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2695
diff
changeset
|
446 |
begin |
3051 | 447 |
if TeamsCount > 0 then |
448 |
begin |
|
449 |
for i:= 0 to Pred(TeamsCount) do Dispose(TeamsArray[i]); |
|
450 |
for i:= 0 to Pred(ClansCount) do Dispose(ClansArray[i]); |
|
451 |
end; |
|
452 |
TeamsCount:= 0; |
|
453 |
ClansCount:= 0 |
|
2699
249adefa9c1c
replace initialization/finalization statements with custom init functions
koda
parents:
2695
diff
changeset
|
454 |
end; |
4 | 455 |
|
456 |
end. |