author | koda |
Sun, 10 Jan 2010 00:52:20 +0000 | |
changeset 2691 | c0da3a98c01c |
parent 2619 | bc2786a00fb8 |
child 2695 | ed789a7ef68d |
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 |
|
2376 | 23 |
uses SDLh, uConsts, uKeys, uGears, uRandom, uFloat, uStats, uVisualGears, |
2152 | 24 |
{$IFDEF GLES11} |
1906 | 25 |
gles11, |
26 |
{$ELSE} |
|
27 |
GL, |
|
28 |
{$ENDIF} |
|
29 |
uSound; |
|
534 | 30 |
|
31 |
type PHHAmmo = ^THHAmmo; |
|
1299 | 32 |
THHAmmo = array[0..cMaxSlotIndex, 0..cMaxSlotAmmoIndex] of TAmmo; |
534 | 33 |
|
1299 | 34 |
PHedgehog = ^THedgehog; |
35 |
PTeam = ^TTeam; |
|
36 |
PClan = ^TClan; |
|
2376 | 37 |
|
1299 | 38 |
THedgehog = record |
39 |
Name: string[MAXNAMELEN]; |
|
40 |
Gear: PGear; |
|
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2040
diff
changeset
|
41 |
SpeechGear: PVisualGear; |
1299 | 42 |
NameTagTex, |
43 |
HealthTagTex, |
|
44 |
HatTex: PTexture; |
|
45 |
Ammo: PHHAmmo; |
|
46 |
AmmoStore: Longword; |
|
47 |
CurSlot, CurAmmo: LongWord; |
|
48 |
Team: PTeam; |
|
2608 | 49 |
MultiShootAttacks: Longword; |
1299 | 50 |
visStepPos: LongWord; |
51 |
BotLevel : LongWord; // 0 - Human player |
|
52 |
HatVisibility: GLfloat; |
|
53 |
stats: TStatistics; |
|
54 |
Hat: String; |
|
55 |
end; |
|
2376 | 56 |
|
1299 | 57 |
TTeam = record |
58 |
Clan: PClan; |
|
59 |
TeamName: string[MAXNAMELEN]; |
|
60 |
ExtDriven: boolean; |
|
61 |
Binds: TBinds; |
|
62 |
Hedgehogs: array[0..cMaxHHIndex] of THedgehog; |
|
63 |
CurrHedgehog: LongWord; |
|
64 |
NameTagTex: PTexture; |
|
65 |
CrosshairTex, |
|
66 |
GraveTex, |
|
67 |
HealthTex: PTexture; |
|
68 |
GraveName: string; |
|
69 |
FortName: string; |
|
70 |
TeamHealth: LongInt; |
|
71 |
TeamHealthBarWidth, |
|
72 |
NewTeamHealthBarWidth: LongInt; |
|
73 |
DrawHealthY: LongInt; |
|
74 |
AttackBar: LongWord; |
|
75 |
HedgehogsNumber: Longword; |
|
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
76 |
hasGone: boolean; |
1654 | 77 |
voicepack: PVoicepack; |
1299 | 78 |
end; |
2376 | 79 |
|
1299 | 80 |
TClan = record |
81 |
Color: Longword; |
|
82 |
Teams: array[0..Pred(cMaxTeams)] of PTeam; |
|
83 |
TeamsNumber: Longword; |
|
84 |
CurrTeam: LongWord; |
|
85 |
ClanHealth: LongInt; |
|
86 |
ClanIndex: LongInt; |
|
87 |
TurnNumber: LongWord; |
|
88 |
end; |
|
4 | 89 |
|
90 |
var CurrentTeam: PTeam = nil; |
|
1678 | 91 |
PreviousTeam: PTeam = nil; |
1299 | 92 |
CurrentHedgehog: PHedgehog = nil; |
93 |
TeamsArray: array[0..Pred(cMaxTeams)] of PTeam; |
|
94 |
TeamsCount: Longword = 0; |
|
95 |
ClansArray: array[0..Pred(cMaxTeams)] of PClan; |
|
96 |
ClansCount: Longword = 0; |
|
2124 | 97 |
LocalClan: Longword = 0; // first non-bot, non-extdriven clan |
1299 | 98 |
CurMinAngle, CurMaxAngle: Longword; |
4 | 99 |
|
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
100 |
function AddTeam(TeamColor: Longword): PTeam; |
4 | 101 |
procedure SwitchHedgehog; |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
102 |
procedure AfterSwitchHedgehog; |
4 | 103 |
procedure InitTeams; |
104 |
function TeamSize(p: PTeam): Longword; |
|
47 | 105 |
procedure RecountTeamHealth(team: PTeam); |
72 | 106 |
procedure RestoreTeamsFromSave; |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
107 |
function CheckForWin: boolean; |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
108 |
procedure TeamGone(s: shortstring); |
2040 | 109 |
procedure TeamGoneEffect(var Team: TTeam); |
4 | 110 |
|
111 |
implementation |
|
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2040
diff
changeset
|
112 |
uses uMisc, uWorld, uAI, uLocale, uConsole, uAmmos, uChat; |
371 | 113 |
const MaxTeamHealth: LongInt = 0; |
4 | 114 |
|
115 |
procedure FreeTeamsList; forward; |
|
116 |
||
92
0c359a7a2356
- Fix win message to appear only after all hedgehogs death
unc0rr
parents:
89
diff
changeset
|
117 |
function CheckForWin: boolean; |
576 | 118 |
var AliveClan: PClan; |
306 | 119 |
s: shortstring; |
1011 | 120 |
t, AliveCount, i, j: LongInt; |
83 | 121 |
begin |
548 | 122 |
AliveCount:= 0; |
549 | 123 |
for t:= 0 to Pred(ClansCount) do |
1299 | 124 |
if ClansArray[t]^.ClanHealth > 0 then |
125 |
begin |
|
126 |
inc(AliveCount); |
|
127 |
AliveClan:= ClansArray[t] |
|
128 |
end; |
|
548 | 129 |
|
1299 | 130 |
if (AliveCount > 1) |
131 |
or ((AliveCount = 1) and ((GameFlags and gfOneClanMode) <> 0)) then exit(false); |
|
351 | 132 |
CheckForWin:= true; |
83 | 133 |
|
134 |
TurnTimeLeft:= 0; |
|
548 | 135 |
if AliveCount = 0 then |
1011 | 136 |
begin // draw |
2619 | 137 |
AddCaption(trmsg[sidDraw], cWhiteColor, capgrpGameState); |
1011 | 138 |
SendStat(siGameResult, trmsg[sidDraw]); |
139 |
AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) |
|
140 |
end else // win |
|
141 |
with AliveClan^ do |
|
142 |
begin |
|
143 |
if TeamsNumber = 1 then |
|
144 |
s:= Format(trmsg[sidWinner], Teams[0]^.TeamName) // team wins |
|
145 |
else |
|
146 |
s:= Format(trmsg[sidWinner], Teams[0]^.TeamName); // clan wins |
|
549 | 147 |
|
1011 | 148 |
for j:= 0 to Pred(TeamsNumber) do |
149 |
with Teams[j]^ do |
|
150 |
for i:= 0 to cMaxHHIndex do |
|
151 |
with Hedgehogs[i] do |
|
152 |
if (Gear <> nil) then |
|
153 |
Gear^.State:= gstWinner; |
|
2376 | 154 |
|
2619 | 155 |
AddCaption(s, cWhiteColor, capgrpGameState); |
1011 | 156 |
SendStat(siGameResult, s); |
157 |
AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) |
|
158 |
end; |
|
307 | 159 |
SendStats |
83 | 160 |
end; |
161 |
||
4 | 162 |
procedure SwitchHedgehog; |
551 | 163 |
var c: LongWord; |
552 | 164 |
PrevHH, PrevTeam: LongWord; |
4 | 165 |
begin |
166 |
TargetPoint.X:= NoPointX; |
|
89 | 167 |
TryDo(CurrentTeam <> nil, 'nil Team', true); |
1678 | 168 |
PreviousTeam:= CurrentTeam; |
547 | 169 |
|
944 | 170 |
with CurrentHedgehog^ do |
1299 | 171 |
if Gear <> nil then |
172 |
begin |
|
2608 | 173 |
MultiShootAttacks:= 0; |
1299 | 174 |
Gear^.Message:= 0; |
175 |
Gear^.Z:= cHHZ; |
|
176 |
RemoveGearFromList(Gear); |
|
177 |
InsertGearToList(Gear) |
|
178 |
end; |
|
4 | 179 |
|
550 | 180 |
c:= CurrentTeam^.Clan^.ClanIndex; |
4 | 181 |
repeat |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
182 |
inc(c); |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
183 |
if c = ClansCount then |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
184 |
begin |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
185 |
inc(TotalRounds); |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
186 |
c:= 0 |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
187 |
end; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
188 |
|
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
189 |
with ClansArray[c]^ do |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
190 |
begin |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
191 |
PrevTeam:= CurrTeam; |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
192 |
repeat |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
193 |
CurrTeam:= Succ(CurrTeam) mod TeamsNumber; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
194 |
CurrentTeam:= Teams[CurrTeam]; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
195 |
with CurrentTeam^ do |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
196 |
begin |
1687
a73c8cda1ed1
Fix engine freeze when one of the teams is killed before its first turn, number of hedgehogs in that team < 8, and game still goes on
unc0rr
parents:
1678
diff
changeset
|
197 |
PrevHH:= CurrHedgehog mod HedgehogsNumber; // prevent infinite loop when CurrHedgehog = 7, but HedgehogsNumber < 8 (team is destroyed before its first turn |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
198 |
repeat |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
199 |
CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
200 |
until (Hedgehogs[CurrHedgehog].Gear <> nil) or (CurrHedgehog = PrevHH) |
1299 | 201 |
end |
2040 | 202 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (PrevTeam = CurrTeam); |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
203 |
end |
2040 | 204 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
83 | 205 |
|
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
206 |
CurrentHedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]) |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
207 |
end; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
208 |
|
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
209 |
procedure AfterSwitchHedgehog; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
210 |
var g: PGear; |
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
211 |
begin |
2431
23242609c44b
Real fix to ammo slot overflow (bug triggered by r2411 fix)
unc0rr
parents:
2376
diff
changeset
|
212 |
inc(CurrentTeam^.Clan^.TurnNumber); |
23242609c44b
Real fix to ammo slot overflow (bug triggered by r2411 fix)
unc0rr
parents:
2376
diff
changeset
|
213 |
|
1922 | 214 |
SwitchNotHeldAmmo(CurrentHedgehog^); |
2431
23242609c44b
Real fix to ammo slot overflow (bug triggered by r2411 fix)
unc0rr
parents:
2376
diff
changeset
|
215 |
|
602 | 216 |
with CurrentHedgehog^ do |
1299 | 217 |
begin |
218 |
with Gear^ do |
|
219 |
begin |
|
220 |
Z:= cCurrHHZ; |
|
221 |
State:= gstHHDriven; |
|
222 |
Active:= true |
|
223 |
end; |
|
224 |
RemoveGearFromList(Gear); |
|
225 |
InsertGearToList(Gear); |
|
226 |
FollowGear:= Gear |
|
227 |
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
|
228 |
|
4 | 229 |
ResetKbd; |
351 | 230 |
|
231 |
cWindSpeed:= rndSign(GetRandom * cMaxWindSpeed); |
|
498 | 232 |
g:= AddGear(0, 0, gtATSmoothWindCh, 0, _0, _0, 1); |
351 | 233 |
g^.Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed); |
4 | 234 |
{$IFDEF DEBUGFILE}AddFileLog('Wind = '+FloatToStr(cWindSpeed));{$ENDIF} |
602 | 235 |
ApplyAmmoChanges(CurrentHedgehog^); |
800 | 236 |
|
2586
204e6b2885bc
added little/big endian checks, added symbol for touch input, simplified iphoneos definitions
koda
parents:
2579
diff
changeset
|
237 |
{$IFNDEF TOUCHINPUT} |
1650
a65681cc27c2
Don't fallback to default binds set when switching to remotely driven team
unc0rr
parents:
1495
diff
changeset
|
238 |
if not CurrentTeam^.ExtDriven then SetBinds(CurrentTeam^.Binds); |
2579 | 239 |
{$ENDIF} |
1650
a65681cc27c2
Don't fallback to default binds set when switching to remotely driven team
unc0rr
parents:
1495
diff
changeset
|
240 |
|
176 | 241 |
bShowFinger:= true; |
800 | 242 |
|
801 | 243 |
if (CurrentTeam^.ExtDriven or (CurrentHedgehog^.BotLevel > 0)) then |
1669 | 244 |
PlaySound(sndIllGetYou, false, CurrentTeam^.voicepack) |
801 | 245 |
else |
1669 | 246 |
PlaySound(sndYesSir, false, CurrentTeam^.voicepack); |
800 | 247 |
|
4 | 248 |
TurnTimeLeft:= cHedgehogTurnTime |
249 |
end; |
|
250 |
||
549 | 251 |
function AddTeam(TeamColor: Longword): PTeam; |
351 | 252 |
var Result: PTeam; |
549 | 253 |
c: LongInt; |
4 | 254 |
begin |
1170 | 255 |
TryDo(TeamsCount < cMaxTeams, 'Too many teams', true); |
17 | 256 |
New(Result); |
80 | 257 |
TryDo(Result <> nil, 'AddTeam: Result = nil', true); |
4 | 258 |
FillChar(Result^, sizeof(TTeam), 0); |
351 | 259 |
Result^.AttackBar:= 2; |
260 |
Result^.CurrHedgehog:= cMaxHHIndex; |
|
547 | 261 |
|
262 |
TeamsArray[TeamsCount]:= Result; |
|
263 |
inc(TeamsCount); |
|
264 |
||
549 | 265 |
c:= Pred(ClansCount); |
266 |
while (c >= 0) and (ClansArray[c]^.Color <> TeamColor) do dec(c); |
|
267 |
if c < 0 then |
|
268 |
begin |
|
269 |
new(Result^.Clan); |
|
270 |
FillChar(Result^.Clan^, sizeof(TClan), 0); |
|
271 |
ClansArray[ClansCount]:= Result^.Clan; |
|
272 |
inc(ClansCount); |
|
273 |
with Result^.Clan^ do |
|
274 |
begin |
|
550 | 275 |
ClanIndex:= Pred(ClansCount); |
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
276 |
Color:= TeamColor |
549 | 277 |
end |
278 |
end else |
|
279 |
begin |
|
280 |
Result^.Clan:= ClansArray[c]; |
|
281 |
end; |
|
282 |
||
283 |
with Result^.Clan^ do |
|
284 |
begin |
|
285 |
Teams[TeamsNumber]:= Result; |
|
286 |
inc(TeamsNumber) |
|
287 |
end; |
|
288 |
||
351 | 289 |
CurrentTeam:= Result; |
290 |
AddTeam:= Result |
|
4 | 291 |
end; |
292 |
||
293 |
procedure FreeTeamsList; |
|
547 | 294 |
var t: LongInt; |
4 | 295 |
begin |
547 | 296 |
for t:= 0 to Pred(TeamsCount) do Dispose(TeamsArray[t]); |
297 |
TeamsCount:= 0 |
|
4 | 298 |
end; |
299 |
||
47 | 300 |
procedure RecountAllTeamsHealth; |
547 | 301 |
var t: LongInt; |
2376 | 302 |
begin |
547 | 303 |
for t:= 0 to Pred(TeamsCount) do |
304 |
RecountTeamHealth(TeamsArray[t]) |
|
47 | 305 |
end; |
306 |
||
307 |
procedure InitTeams; |
|
547 | 308 |
var i, t: LongInt; |
371 | 309 |
th: LongInt; |
47 | 310 |
begin |
547 | 311 |
for t:= 0 to Pred(TeamsCount) do |
312 |
with TeamsArray[t]^ do |
|
47 | 313 |
begin |
2124 | 314 |
if (not ExtDriven) and (Hedgehogs[0].BotLevel = 0) then |
315 |
LocalClan:= Clan^.ClanIndex + 1; |
|
47 | 316 |
th:= 0; |
4 | 317 |
for i:= 0 to cMaxHHIndex do |
547 | 318 |
if Hedgehogs[i].Gear <> nil then |
319 |
inc(th, Hedgehogs[i].Gear^.Health); |
|
47 | 320 |
if th > MaxTeamHealth then MaxTeamHealth:= th; |
4 | 321 |
end; |
47 | 322 |
RecountAllTeamsHealth |
4 | 323 |
end; |
324 |
||
325 |
function TeamSize(p: PTeam): Longword; |
|
351 | 326 |
var i, Result: Longword; |
4 | 327 |
begin |
328 |
Result:= 0; |
|
329 |
for i:= 0 to cMaxHHIndex do |
|
351 | 330 |
if p^.Hedgehogs[i].Gear <> nil then inc(Result); |
331 |
TeamSize:= Result |
|
4 | 332 |
end; |
333 |
||
549 | 334 |
procedure RecountClanHealth(clan: PClan); |
335 |
var i: LongInt; |
|
336 |
begin |
|
337 |
with clan^ do |
|
338 |
begin |
|
339 |
ClanHealth:= 0; |
|
340 |
for i:= 0 to Pred(TeamsNumber) do |
|
341 |
inc(ClanHealth, Teams[i]^.TeamHealth) |
|
342 |
end |
|
343 |
end; |
|
344 |
||
47 | 345 |
procedure RecountTeamHealth(team: PTeam); |
371 | 346 |
var i: LongInt; |
47 | 347 |
begin |
348 |
with team^ do |
|
1352
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
349 |
begin |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
350 |
NewTeamHealthBarWidth:= 0; |
2376 | 351 |
|
1352
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
352 |
if not hasGone then |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
353 |
for i:= 0 to cMaxHHIndex do |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
354 |
if Hedgehogs[i].Gear <> nil then |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
355 |
inc(NewTeamHealthBarWidth, Hedgehogs[i].Gear^.Health); |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
356 |
|
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
357 |
TeamHealth:= NewTeamHealthBarWidth; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
358 |
if NewTeamHealthBarWidth > MaxTeamHealth then |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
359 |
begin |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
360 |
MaxTeamHealth:= NewTeamHealthBarWidth; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
361 |
RecountAllTeamsHealth; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
362 |
end else NewTeamHealthBarWidth:= (NewTeamHealthBarWidth * cTeamHealthWidth) div MaxTeamHealth |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
363 |
end; |
549 | 364 |
|
365 |
RecountClanHealth(team^.Clan); |
|
366 |
||
2005 | 367 |
AddVisualGear(0, 0, vgtTeamHealthSorter) |
47 | 368 |
end; |
369 |
||
72 | 370 |
procedure RestoreTeamsFromSave; |
547 | 371 |
var t: LongInt; |
72 | 372 |
begin |
547 | 373 |
for t:= 0 to Pred(TeamsCount) do |
374 |
TeamsArray[t]^.ExtDriven:= false |
|
72 | 375 |
end; |
376 |
||
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
377 |
procedure TeamGone(s: shortstring); |
2040 | 378 |
var t: LongInt; |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
379 |
begin |
1362 | 380 |
t:= 0; |
1356 | 381 |
while (t < cMaxTeams) |
382 |
and (TeamsArray[t] <> nil) |
|
383 |
and (TeamsArray[t]^.TeamName <> s) do inc(t); |
|
384 |
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
|
385 |
|
1356 | 386 |
with TeamsArray[t]^ do |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
387 |
begin |
1495 | 388 |
AddChatString('** '+ TeamName + ' is gone'); |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
389 |
hasGone:= true |
1355 | 390 |
end; |
2376 | 391 |
|
1363 | 392 |
RecountTeamHealth(TeamsArray[t]) |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
393 |
end; |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
394 |
|
2040 | 395 |
procedure TeamGoneEffect(var Team: TTeam); |
396 |
var i: LongInt; |
|
397 |
begin |
|
398 |
with Team do |
|
399 |
for i:= 0 to cMaxHHIndex do |
|
400 |
with Hedgehogs[i] do |
|
401 |
if Gear <> nil then |
|
402 |
Gear^.Damage:= Gear^.Health |
|
403 |
end; |
|
404 |
||
4 | 405 |
initialization |
406 |
||
407 |
finalization |
|
408 |
||
409 |
FreeTeamsList |
|
410 |
||
411 |
end. |