author | nemo |
Sun, 17 May 2009 14:25:45 +0000 | |
changeset 2072 | 6e0fcbcc3f60 |
parent 2042 | 905c554d62e6 |
child 2124 | d39c61eaca15 |
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 |
|
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2040
diff
changeset
|
21 |
uses SDLh, uConsts, uKeys, uGears, uRandom, uFloat, uStats, uVisualGears, |
1906 | 22 |
{$IFDEF IPHONE} |
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; |
|
36 |
||
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; |
|
55 |
||
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; |
78 |
||
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; |
|
96 |
CurMinAngle, CurMaxAngle: Longword; |
|
4 | 97 |
|
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
98 |
function AddTeam(TeamColor: Longword): PTeam; |
4 | 99 |
procedure SwitchHedgehog; |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
100 |
procedure AfterSwitchHedgehog; |
4 | 101 |
procedure InitTeams; |
102 |
function TeamSize(p: PTeam): Longword; |
|
47 | 103 |
procedure RecountTeamHealth(team: PTeam); |
72 | 104 |
procedure RestoreTeamsFromSave; |
1058
c53c5c4e7b48
- Proper turns counting, split SwitchHedgehog into two functions
unc0rr
parents:
1011
diff
changeset
|
105 |
function CheckForWin: boolean; |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
106 |
procedure TeamGone(s: shortstring); |
2040 | 107 |
procedure TeamGoneEffect(var Team: TTeam); |
4 | 108 |
|
109 |
implementation |
|
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2040
diff
changeset
|
110 |
uses uMisc, uWorld, uAI, uLocale, uConsole, uAmmos, uChat; |
371 | 111 |
const MaxTeamHealth: LongInt = 0; |
4 | 112 |
|
113 |
procedure FreeTeamsList; forward; |
|
114 |
||
92
0c359a7a2356
- Fix win message to appear only after all hedgehogs death
unc0rr
parents:
89
diff
changeset
|
115 |
function CheckForWin: boolean; |
576 | 116 |
var AliveClan: PClan; |
306 | 117 |
s: shortstring; |
1011 | 118 |
t, AliveCount, i, j: LongInt; |
83 | 119 |
begin |
548 | 120 |
AliveCount:= 0; |
549 | 121 |
for t:= 0 to Pred(ClansCount) do |
1299 | 122 |
if ClansArray[t]^.ClanHealth > 0 then |
123 |
begin |
|
124 |
inc(AliveCount); |
|
125 |
AliveClan:= ClansArray[t] |
|
126 |
end; |
|
548 | 127 |
|
1299 | 128 |
if (AliveCount > 1) |
129 |
or ((AliveCount = 1) and ((GameFlags and gfOneClanMode) <> 0)) then exit(false); |
|
351 | 130 |
CheckForWin:= true; |
83 | 131 |
|
132 |
TurnTimeLeft:= 0; |
|
548 | 133 |
if AliveCount = 0 then |
1011 | 134 |
begin // draw |
135 |
AddCaption(trmsg[sidDraw], $FFFFFF, capgrpGameState); |
|
136 |
SendStat(siGameResult, trmsg[sidDraw]); |
|
137 |
AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) |
|
138 |
end else // win |
|
139 |
with AliveClan^ do |
|
140 |
begin |
|
141 |
if TeamsNumber = 1 then |
|
142 |
s:= Format(trmsg[sidWinner], Teams[0]^.TeamName) // team wins |
|
143 |
else |
|
144 |
s:= Format(trmsg[sidWinner], Teams[0]^.TeamName); // clan wins |
|
549 | 145 |
|
1011 | 146 |
for j:= 0 to Pred(TeamsNumber) do |
147 |
with Teams[j]^ do |
|
148 |
for i:= 0 to cMaxHHIndex do |
|
149 |
with Hedgehogs[i] do |
|
150 |
if (Gear <> nil) then |
|
151 |
Gear^.State:= gstWinner; |
|
152 |
||
153 |
AddCaption(s, $FFFFFF, capgrpGameState); |
|
154 |
SendStat(siGameResult, s); |
|
155 |
AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) |
|
156 |
end; |
|
307 | 157 |
SendStats |
83 | 158 |
end; |
159 |
||
4 | 160 |
procedure SwitchHedgehog; |
551 | 161 |
var c: LongWord; |
552 | 162 |
PrevHH, PrevTeam: LongWord; |
4 | 163 |
begin |
164 |
FreeActionsList; |
|
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 |
1922 | 211 |
SwitchNotHeldAmmo(CurrentHedgehog^); |
602 | 212 |
with CurrentHedgehog^ do |
1299 | 213 |
begin |
214 |
with Gear^ do |
|
215 |
begin |
|
216 |
Z:= cCurrHHZ; |
|
217 |
State:= gstHHDriven; |
|
218 |
Active:= true |
|
219 |
end; |
|
220 |
RemoveGearFromList(Gear); |
|
221 |
InsertGearToList(Gear); |
|
222 |
FollowGear:= Gear |
|
223 |
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
|
224 |
|
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
927
diff
changeset
|
225 |
inc(CurrentTeam^.Clan^.TurnNumber); |
b5222ddafe1f
- Fix bug with picking up ammos from cases, when total ammo count may become more than AMMO_INFINITE
unc0rr
parents:
927
diff
changeset
|
226 |
|
4 | 227 |
ResetKbd; |
351 | 228 |
|
229 |
cWindSpeed:= rndSign(GetRandom * cMaxWindSpeed); |
|
498 | 230 |
g:= AddGear(0, 0, gtATSmoothWindCh, 0, _0, _0, 1); |
351 | 231 |
g^.Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed); |
4 | 232 |
{$IFDEF DEBUGFILE}AddFileLog('Wind = '+FloatToStr(cWindSpeed));{$ENDIF} |
602 | 233 |
ApplyAmmoChanges(CurrentHedgehog^); |
800 | 234 |
|
1650
a65681cc27c2
Don't fallback to default binds set when switching to remotely driven team
unc0rr
parents:
1495
diff
changeset
|
235 |
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
|
236 |
|
176 | 237 |
bShowFinger:= true; |
800 | 238 |
|
801 | 239 |
if (CurrentTeam^.ExtDriven or (CurrentHedgehog^.BotLevel > 0)) then |
1669 | 240 |
PlaySound(sndIllGetYou, false, CurrentTeam^.voicepack) |
801 | 241 |
else |
1669 | 242 |
PlaySound(sndYesSir, false, CurrentTeam^.voicepack); |
800 | 243 |
|
4 | 244 |
TurnTimeLeft:= cHedgehogTurnTime |
245 |
end; |
|
246 |
||
549 | 247 |
function AddTeam(TeamColor: Longword): PTeam; |
351 | 248 |
var Result: PTeam; |
549 | 249 |
c: LongInt; |
4 | 250 |
begin |
1170 | 251 |
TryDo(TeamsCount < cMaxTeams, 'Too many teams', true); |
17 | 252 |
New(Result); |
80 | 253 |
TryDo(Result <> nil, 'AddTeam: Result = nil', true); |
4 | 254 |
FillChar(Result^, sizeof(TTeam), 0); |
351 | 255 |
Result^.AttackBar:= 2; |
256 |
Result^.CurrHedgehog:= cMaxHHIndex; |
|
547 | 257 |
|
258 |
TeamsArray[TeamsCount]:= Result; |
|
259 |
inc(TeamsCount); |
|
260 |
||
549 | 261 |
c:= Pred(ClansCount); |
262 |
while (c >= 0) and (ClansArray[c]^.Color <> TeamColor) do dec(c); |
|
263 |
if c < 0 then |
|
264 |
begin |
|
265 |
new(Result^.Clan); |
|
266 |
FillChar(Result^.Clan^, sizeof(TClan), 0); |
|
267 |
ClansArray[ClansCount]:= Result^.Clan; |
|
268 |
inc(ClansCount); |
|
269 |
with Result^.Clan^ do |
|
270 |
begin |
|
550 | 271 |
ClanIndex:= Pred(ClansCount); |
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
272 |
Color:= TeamColor |
549 | 273 |
end |
274 |
end else |
|
275 |
begin |
|
276 |
Result^.Clan:= ClansArray[c]; |
|
277 |
end; |
|
278 |
||
279 |
with Result^.Clan^ do |
|
280 |
begin |
|
281 |
Teams[TeamsNumber]:= Result; |
|
282 |
inc(TeamsNumber) |
|
283 |
end; |
|
284 |
||
351 | 285 |
CurrentTeam:= Result; |
286 |
AddTeam:= Result |
|
4 | 287 |
end; |
288 |
||
289 |
procedure FreeTeamsList; |
|
547 | 290 |
var t: LongInt; |
4 | 291 |
begin |
547 | 292 |
for t:= 0 to Pred(TeamsCount) do Dispose(TeamsArray[t]); |
293 |
TeamsCount:= 0 |
|
4 | 294 |
end; |
295 |
||
47 | 296 |
procedure RecountAllTeamsHealth; |
547 | 297 |
var t: LongInt; |
298 |
begin |
|
299 |
for t:= 0 to Pred(TeamsCount) do |
|
300 |
RecountTeamHealth(TeamsArray[t]) |
|
47 | 301 |
end; |
302 |
||
303 |
procedure InitTeams; |
|
547 | 304 |
var i, t: LongInt; |
371 | 305 |
th: LongInt; |
47 | 306 |
begin |
547 | 307 |
for t:= 0 to Pred(TeamsCount) do |
308 |
with TeamsArray[t]^ do |
|
47 | 309 |
begin |
310 |
th:= 0; |
|
4 | 311 |
for i:= 0 to cMaxHHIndex do |
547 | 312 |
if Hedgehogs[i].Gear <> nil then |
313 |
inc(th, Hedgehogs[i].Gear^.Health); |
|
47 | 314 |
if th > MaxTeamHealth then MaxTeamHealth:= th; |
4 | 315 |
end; |
47 | 316 |
RecountAllTeamsHealth |
4 | 317 |
end; |
318 |
||
319 |
function TeamSize(p: PTeam): Longword; |
|
351 | 320 |
var i, Result: Longword; |
4 | 321 |
begin |
322 |
Result:= 0; |
|
323 |
for i:= 0 to cMaxHHIndex do |
|
351 | 324 |
if p^.Hedgehogs[i].Gear <> nil then inc(Result); |
325 |
TeamSize:= Result |
|
4 | 326 |
end; |
327 |
||
549 | 328 |
procedure RecountClanHealth(clan: PClan); |
329 |
var i: LongInt; |
|
330 |
begin |
|
331 |
with clan^ do |
|
332 |
begin |
|
333 |
ClanHealth:= 0; |
|
334 |
for i:= 0 to Pred(TeamsNumber) do |
|
335 |
inc(ClanHealth, Teams[i]^.TeamHealth) |
|
336 |
end |
|
337 |
end; |
|
338 |
||
47 | 339 |
procedure RecountTeamHealth(team: PTeam); |
371 | 340 |
var i: LongInt; |
47 | 341 |
begin |
342 |
with team^ do |
|
1352
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
343 |
begin |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
344 |
NewTeamHealthBarWidth:= 0; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
345 |
|
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
346 |
if not hasGone then |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
347 |
for i:= 0 to cMaxHHIndex do |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
348 |
if Hedgehogs[i].Gear <> nil then |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
349 |
inc(NewTeamHealthBarWidth, Hedgehogs[i].Gear^.Health); |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
350 |
|
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
351 |
TeamHealth:= NewTeamHealthBarWidth; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
352 |
if NewTeamHealthBarWidth > MaxTeamHealth then |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
353 |
begin |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
354 |
MaxTeamHealth:= NewTeamHealthBarWidth; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
355 |
RecountAllTeamsHealth; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
356 |
end else NewTeamHealthBarWidth:= (NewTeamHealthBarWidth * cTeamHealthWidth) div MaxTeamHealth |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
357 |
end; |
549 | 358 |
|
359 |
RecountClanHealth(team^.Clan); |
|
360 |
||
2005 | 361 |
AddVisualGear(0, 0, vgtTeamHealthSorter) |
47 | 362 |
end; |
363 |
||
72 | 364 |
procedure RestoreTeamsFromSave; |
547 | 365 |
var t: LongInt; |
72 | 366 |
begin |
547 | 367 |
for t:= 0 to Pred(TeamsCount) do |
368 |
TeamsArray[t]^.ExtDriven:= false |
|
72 | 369 |
end; |
370 |
||
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
371 |
procedure TeamGone(s: shortstring); |
2040 | 372 |
var t: LongInt; |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
373 |
begin |
1362 | 374 |
t:= 0; |
1356 | 375 |
while (t < cMaxTeams) |
376 |
and (TeamsArray[t] <> nil) |
|
377 |
and (TeamsArray[t]^.TeamName <> s) do inc(t); |
|
378 |
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
|
379 |
|
1356 | 380 |
with TeamsArray[t]^ do |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
381 |
begin |
1495 | 382 |
AddChatString('** '+ TeamName + ' is gone'); |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
383 |
hasGone:= true |
1355 | 384 |
end; |
385 |
||
1363 | 386 |
RecountTeamHealth(TeamsArray[t]) |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
387 |
end; |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
388 |
|
2040 | 389 |
procedure TeamGoneEffect(var Team: TTeam); |
390 |
var i: LongInt; |
|
391 |
begin |
|
392 |
with Team do |
|
393 |
for i:= 0 to cMaxHHIndex do |
|
394 |
with Hedgehogs[i] do |
|
395 |
if Gear <> nil then |
|
396 |
Gear^.Damage:= Gear^.Health |
|
397 |
end; |
|
398 |
||
4 | 399 |
initialization |
400 |
||
401 |
finalization |
|
402 |
||
403 |
FreeTeamsList |
|
404 |
||
405 |
end. |