author | unc0rr |
Thu, 27 Aug 2009 17:33:01 +0000 | |
changeset 2335 | 0a61a3c2efc4 |
parent 2289 | cb850ba733bd |
child 2376 | ece7b87f1334 |
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, |
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; |
|
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; |
|
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; |
|
153 |
||
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 |
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 |
2124 | 310 |
if (not ExtDriven) and (Hedgehogs[0].BotLevel = 0) then |
311 |
LocalClan:= Clan^.ClanIndex + 1; |
|
47 | 312 |
th:= 0; |
4 | 313 |
for i:= 0 to cMaxHHIndex do |
547 | 314 |
if Hedgehogs[i].Gear <> nil then |
315 |
inc(th, Hedgehogs[i].Gear^.Health); |
|
47 | 316 |
if th > MaxTeamHealth then MaxTeamHealth:= th; |
4 | 317 |
end; |
47 | 318 |
RecountAllTeamsHealth |
4 | 319 |
end; |
320 |
||
321 |
function TeamSize(p: PTeam): Longword; |
|
351 | 322 |
var i, Result: Longword; |
4 | 323 |
begin |
324 |
Result:= 0; |
|
325 |
for i:= 0 to cMaxHHIndex do |
|
351 | 326 |
if p^.Hedgehogs[i].Gear <> nil then inc(Result); |
327 |
TeamSize:= Result |
|
4 | 328 |
end; |
329 |
||
549 | 330 |
procedure RecountClanHealth(clan: PClan); |
331 |
var i: LongInt; |
|
332 |
begin |
|
333 |
with clan^ do |
|
334 |
begin |
|
335 |
ClanHealth:= 0; |
|
336 |
for i:= 0 to Pred(TeamsNumber) do |
|
337 |
inc(ClanHealth, Teams[i]^.TeamHealth) |
|
338 |
end |
|
339 |
end; |
|
340 |
||
47 | 341 |
procedure RecountTeamHealth(team: PTeam); |
371 | 342 |
var i: LongInt; |
47 | 343 |
begin |
344 |
with team^ do |
|
1352
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
345 |
begin |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
346 |
NewTeamHealthBarWidth:= 0; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
347 |
|
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
348 |
if not hasGone then |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
349 |
for i:= 0 to cMaxHHIndex do |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
350 |
if Hedgehogs[i].Gear <> nil then |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
351 |
inc(NewTeamHealthBarWidth, Hedgehogs[i].Gear^.Health); |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
352 |
|
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
353 |
TeamHealth:= NewTeamHealthBarWidth; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
354 |
if NewTeamHealthBarWidth > MaxTeamHealth then |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
355 |
begin |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
356 |
MaxTeamHealth:= NewTeamHealthBarWidth; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
357 |
RecountAllTeamsHealth; |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
358 |
end else NewTeamHealthBarWidth:= (NewTeamHealthBarWidth * cTeamHealthWidth) div MaxTeamHealth |
405ad07cf875
Add more support for handling disconnects while playing (not fully tested)
unc0rr
parents:
1351
diff
changeset
|
359 |
end; |
549 | 360 |
|
361 |
RecountClanHealth(team^.Clan); |
|
362 |
||
2005 | 363 |
AddVisualGear(0, 0, vgtTeamHealthSorter) |
47 | 364 |
end; |
365 |
||
72 | 366 |
procedure RestoreTeamsFromSave; |
547 | 367 |
var t: LongInt; |
72 | 368 |
begin |
547 | 369 |
for t:= 0 to Pred(TeamsCount) do |
370 |
TeamsArray[t]^.ExtDriven:= false |
|
72 | 371 |
end; |
372 |
||
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
373 |
procedure TeamGone(s: shortstring); |
2040 | 374 |
var t: LongInt; |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
375 |
begin |
1362 | 376 |
t:= 0; |
1356 | 377 |
while (t < cMaxTeams) |
378 |
and (TeamsArray[t] <> nil) |
|
379 |
and (TeamsArray[t]^.TeamName <> s) do inc(t); |
|
380 |
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
|
381 |
|
1356 | 382 |
with TeamsArray[t]^ do |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
383 |
begin |
1495 | 384 |
AddChatString('** '+ TeamName + ' is gone'); |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
385 |
hasGone:= true |
1355 | 386 |
end; |
387 |
||
1363 | 388 |
RecountTeamHealth(TeamsArray[t]) |
1351
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
389 |
end; |
aa7aefec5c1b
Add partial implementation of handling disconnects while playing via network
unc0rr
parents:
1299
diff
changeset
|
390 |
|
2040 | 391 |
procedure TeamGoneEffect(var Team: TTeam); |
392 |
var i: LongInt; |
|
393 |
begin |
|
394 |
with Team do |
|
395 |
for i:= 0 to cMaxHHIndex do |
|
396 |
with Hedgehogs[i] do |
|
397 |
if Gear <> nil then |
|
398 |
Gear^.Damage:= Gear^.Health |
|
399 |
end; |
|
400 |
||
4 | 401 |
initialization |
402 |
||
403 |
finalization |
|
404 |
||
405 |
FreeTeamsList |
|
406 |
||
407 |
end. |