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