author | Xeli |
Wed, 23 May 2012 21:16:44 +0200 | |
changeset 7117 | 7df6386f7090 |
parent 7093 | 2d7f1fb73335 |
child 7168 | 8defaabce92e |
permissions | -rw-r--r-- |
6581 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
6700 | 3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
6581 | 4 |
* |
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 |
|
8 |
* |
|
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. |
|
13 |
* |
|
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 |
|
17 |
*) |
|
18 |
||
19 |
{$INCLUDE "options.inc"} |
|
20 |
unit uGearsList; |
|
21 |
||
22 |
interface |
|
23 |
uses uFloat, uTypes; |
|
24 |
||
25 |
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
|
26 |
procedure DeleteGear(Gear: PGear); |
|
27 |
procedure InsertGearToList(Gear: PGear); |
|
28 |
procedure RemoveGearFromList(Gear: PGear); |
|
29 |
||
30 |
implementation |
|
31 |
||
32 |
uses uRandom, uUtils, uConsts, uVariables, uAmmos, uTeams, uStats, |
|
33 |
uTextures, uScript, uRenderUtils, uAI, uCollisions, |
|
34 |
uGearsRender, uGearsUtils; |
|
35 |
||
7093 | 36 |
var GCounter: LongWord = 0; // this does not get re-initialized, but should be harmless |
7028 | 37 |
|
6581 | 38 |
procedure InsertGearToList(Gear: PGear); |
39 |
var tmp, ptmp: PGear; |
|
40 |
begin |
|
41 |
tmp:= GearsList; |
|
42 |
ptmp:= GearsList; |
|
43 |
while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do |
|
44 |
begin |
|
45 |
ptmp:= tmp; |
|
46 |
tmp:= tmp^.NextGear |
|
47 |
end; |
|
48 |
||
49 |
if ptmp <> tmp then |
|
50 |
begin |
|
51 |
Gear^.NextGear:= ptmp^.NextGear; |
|
52 |
Gear^.PrevGear:= ptmp; |
|
53 |
if ptmp^.NextGear <> nil then |
|
54 |
ptmp^.NextGear^.PrevGear:= Gear; |
|
55 |
ptmp^.NextGear:= Gear |
|
56 |
end |
|
57 |
else |
|
58 |
begin |
|
59 |
Gear^.NextGear:= GearsList; |
|
60 |
if Gear^.NextGear <> nil then |
|
61 |
Gear^.NextGear^.PrevGear:= Gear; |
|
62 |
GearsList:= Gear; |
|
63 |
end; |
|
64 |
end; |
|
65 |
||
66 |
procedure RemoveGearFromList(Gear: PGear); |
|
67 |
begin |
|
68 |
if Gear^.NextGear <> nil then |
|
69 |
Gear^.NextGear^.PrevGear:= Gear^.PrevGear; |
|
70 |
if Gear^.PrevGear <> nil then |
|
71 |
Gear^.PrevGear^.NextGear:= Gear^.NextGear |
|
72 |
else |
|
73 |
GearsList:= Gear^.NextGear |
|
74 |
end; |
|
75 |
||
76 |
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
|
77 |
var gear: PGear; |
|
78 |
begin |
|
7028 | 79 |
inc(GCounter); |
80 |
AddFileLog('AddGear: #' + inttostr(GCounter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind)); |
|
6581 | 81 |
|
82 |
New(gear); |
|
83 |
FillChar(gear^, sizeof(TGear), 0); |
|
84 |
gear^.X:= int2hwFloat(X); |
|
85 |
gear^.Y:= int2hwFloat(Y); |
|
86 |
gear^.Target.X:= NoPointX; |
|
87 |
gear^.Kind := Kind; |
|
88 |
gear^.State:= State; |
|
89 |
gear^.Active:= true; |
|
90 |
gear^.dX:= dX; |
|
91 |
gear^.dY:= dY; |
|
92 |
gear^.doStep:= doStepHandlers[Kind]; |
|
93 |
gear^.CollisionIndex:= -1; |
|
94 |
gear^.Timer:= Timer; |
|
95 |
gear^.FlightTime:= 0; |
|
7028 | 96 |
gear^.uid:= GCounter; |
6581 | 97 |
gear^.SoundChannel:= -1; |
98 |
gear^.ImpactSound:= sndNone; |
|
99 |
gear^.nImpactSounds:= 0; |
|
100 |
gear^.Density:= _1; |
|
101 |
// Define ammo association, if any. |
|
102 |
gear^.AmmoType:= GearKindAmmoTypeMap[Kind]; |
|
103 |
if Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then |
|
104 |
gear^.Z:= cHHZ+1 |
|
105 |
else gear^.Z:= cUsualZ; |
|
106 |
||
107 |
if CurrentHedgehog <> nil then |
|
108 |
begin |
|
109 |
gear^.Hedgehog:= CurrentHedgehog; |
|
110 |
gear^.IntersectGear:= CurrentHedgehog^.Gear |
|
111 |
end; |
|
112 |
||
113 |
case Kind of |
|
114 |
gtGrenade, |
|
115 |
gtClusterBomb, |
|
116 |
gtGasBomb: begin |
|
117 |
gear^.ImpactSound:= sndGrenadeImpact; |
|
118 |
gear^.nImpactSounds:= 1; |
|
119 |
gear^.AdvBounce:= 1; |
|
120 |
gear^.Radius:= 5; |
|
121 |
gear^.Elasticity:= _0_8; |
|
122 |
gear^.Friction:= _0_8; |
|
123 |
gear^.Density:= _1_5; |
|
124 |
gear^.RenderTimer:= true; |
|
125 |
if gear^.Timer = 0 then |
|
126 |
gear^.Timer:= 3000 |
|
127 |
end; |
|
128 |
gtWatermelon: begin |
|
129 |
gear^.ImpactSound:= sndMelonImpact; |
|
130 |
gear^.nImpactSounds:= 1; |
|
131 |
gear^.AdvBounce:= 1; |
|
132 |
gear^.Radius:= 6; |
|
133 |
gear^.Elasticity:= _0_8; |
|
134 |
gear^.Friction:= _0_995; |
|
135 |
gear^.Density:= _2; |
|
136 |
gear^.RenderTimer:= true; |
|
137 |
if gear^.Timer = 0 then |
|
138 |
gear^.Timer:= 3000 |
|
139 |
end; |
|
140 |
gtMelonPiece: begin |
|
141 |
gear^.Density:= _2; |
|
142 |
end; |
|
143 |
gtHedgehog: begin |
|
144 |
gear^.AdvBounce:= 1; |
|
145 |
gear^.Radius:= cHHRadius; |
|
146 |
gear^.Elasticity:= _0_35; |
|
147 |
gear^.Friction:= _0_999; |
|
148 |
gear^.Angle:= cMaxAngle div 2; |
|
149 |
gear^.Density:= _3; |
|
150 |
gear^.Z:= cHHZ; |
|
151 |
if (GameFlags and gfAISurvival) <> 0 then |
|
152 |
if gear^.Hedgehog^.BotLevel > 0 then |
|
7077 | 153 |
gear^.Hedgehog^.Effects[heResurrectable] := 1; |
6581 | 154 |
end; |
155 |
gtShell: begin |
|
156 |
gear^.Radius:= 4; |
|
157 |
gear^.Density:= _1; |
|
158 |
end; |
|
159 |
gtSnowball: begin |
|
160 |
gear^.ImpactSound:= sndMudballImpact; |
|
161 |
gear^.nImpactSounds:= 1; |
|
162 |
gear^.Radius:= 4; |
|
163 |
gear^.Elasticity:= _1; |
|
164 |
gear^.Friction:= _1; |
|
165 |
gear^.Density:= _0_5; |
|
166 |
end; |
|
167 |
||
168 |
gtFlake: begin |
|
169 |
with Gear^ do |
|
170 |
begin |
|
171 |
Pos:= 0; |
|
172 |
Radius:= 1; |
|
7069 | 173 |
DirAngle:= random(360); |
6581 | 174 |
if State and gstTmpFlag = 0 then |
175 |
begin |
|
176 |
dx.isNegative:= GetRandom(2) = 0; |
|
177 |
dx.QWordValue:= GetRandom(100000000); |
|
178 |
dy.isNegative:= false; |
|
179 |
dy.QWordValue:= GetRandom(70000000); |
|
180 |
if GetRandom(2) = 0 then |
|
181 |
dx := -dx |
|
182 |
end; |
|
183 |
State:= State or gstInvisible; |
|
184 |
Health:= random(vobFrameTicks); |
|
185 |
Timer:= random(vobFramesCount); |
|
186 |
Angle:= (random(2) * 2 - 1) * (1 + random(10000)) * vobVelocity |
|
187 |
end |
|
188 |
end; |
|
189 |
gtGrave: begin |
|
190 |
gear^.ImpactSound:= sndGraveImpact; |
|
191 |
gear^.nImpactSounds:= 1; |
|
192 |
gear^.Radius:= 10; |
|
193 |
gear^.Elasticity:= _0_6; |
|
194 |
end; |
|
195 |
gtBee: begin |
|
196 |
gear^.Radius:= 5; |
|
197 |
gear^.Timer:= 500; |
|
198 |
gear^.RenderTimer:= true; |
|
199 |
gear^.Elasticity:= _0_9; |
|
200 |
gear^.Tag:= 0; |
|
201 |
end; |
|
202 |
gtSeduction: begin |
|
203 |
gear^.Radius:= 250; |
|
204 |
end; |
|
205 |
gtShotgunShot: begin |
|
206 |
gear^.Timer:= 900; |
|
207 |
gear^.Radius:= 2 |
|
208 |
end; |
|
209 |
gtPickHammer: begin |
|
210 |
gear^.Radius:= 10; |
|
211 |
gear^.Timer:= 4000 |
|
212 |
end; |
|
213 |
gtHammerHit: begin |
|
214 |
gear^.Radius:= 8; |
|
215 |
gear^.Timer:= 125 |
|
216 |
end; |
|
217 |
gtRope: begin |
|
218 |
gear^.Radius:= 3; |
|
219 |
gear^.Friction:= _450 * _0_01 * cRopePercent; |
|
220 |
RopePoints.Count:= 0; |
|
221 |
end; |
|
222 |
gtMine: begin |
|
223 |
gear^.ImpactSound:= sndMineImpact; |
|
224 |
gear^.nImpactSounds:= 1; |
|
225 |
gear^.Health:= 10; |
|
226 |
gear^.State:= gear^.State or gstMoving; |
|
227 |
gear^.Radius:= 2; |
|
228 |
gear^.Elasticity:= _0_55; |
|
229 |
gear^.Friction:= _0_995; |
|
230 |
gear^.Density:= _0_9; |
|
231 |
if cMinesTime < 0 then |
|
232 |
gear^.Timer:= getrandom(51)*100 |
|
233 |
else |
|
234 |
gear^.Timer:= cMinesTime; |
|
235 |
end; |
|
236 |
gtSMine: begin |
|
237 |
gear^.Health:= 10; |
|
238 |
gear^.State:= gear^.State or gstMoving; |
|
239 |
gear^.Radius:= 2; |
|
240 |
gear^.Elasticity:= _0_55; |
|
241 |
gear^.Friction:= _0_995; |
|
242 |
gear^.Density:= _0_9; |
|
243 |
gear^.Timer:= 500; |
|
244 |
end; |
|
245 |
gtCase: begin |
|
246 |
gear^.ImpactSound:= sndGraveImpact; |
|
247 |
gear^.nImpactSounds:= 1; |
|
248 |
gear^.Radius:= 16; |
|
249 |
gear^.Elasticity:= _0_3 |
|
250 |
end; |
|
251 |
gtExplosives: begin |
|
252 |
gear^.ImpactSound:= sndGrenadeImpact; |
|
253 |
gear^.nImpactSounds:= 1; |
|
254 |
gear^.Radius:= 16; |
|
255 |
gear^.Elasticity:= _0_4; |
|
256 |
gear^.Friction:= _0_995; |
|
257 |
gear^.Density:= _6; |
|
258 |
gear^.Health:= cBarrelHealth; |
|
259 |
gear^.Z:= cHHZ-1 |
|
260 |
end; |
|
261 |
gtDEagleShot: begin |
|
262 |
gear^.Radius:= 1; |
|
263 |
gear^.Health:= 50 |
|
264 |
end; |
|
265 |
gtSniperRifleShot: begin |
|
266 |
gear^.Radius:= 1; |
|
267 |
gear^.Health:= 50 |
|
268 |
end; |
|
269 |
gtDynamite: begin |
|
270 |
gear^.Radius:= 3; |
|
271 |
gear^.Elasticity:= _0_55; |
|
272 |
gear^.Friction:= _0_03; |
|
273 |
gear^.Density:= _2; |
|
274 |
gear^.Timer:= 5000; |
|
275 |
end; |
|
276 |
gtCluster: begin |
|
277 |
gear^.Radius:= 2; |
|
278 |
gear^.Density:= _1_5; |
|
279 |
gear^.RenderTimer:= true |
|
280 |
end; |
|
281 |
gtShover: gear^.Radius:= 20; |
|
282 |
gtFlame: begin |
|
283 |
gear^.Tag:= GetRandom(32); |
|
284 |
gear^.Radius:= 1; |
|
285 |
gear^.Health:= 5; |
|
286 |
gear^.Density:= _1; |
|
287 |
if (gear^.dY.QWordValue = 0) and (gear^.dX.QWordValue = 0) then |
|
288 |
begin |
|
7001 | 289 |
gear^.dY:= (getrandomf - _0_8) * _0_03; |
290 |
gear^.dX:= (getrandomf - _0_5) * _0_4 |
|
6581 | 291 |
end |
292 |
end; |
|
293 |
gtFirePunch: begin |
|
294 |
gear^.Radius:= 15; |
|
295 |
gear^.Tag:= Y |
|
296 |
end; |
|
297 |
gtAirBomb: begin |
|
298 |
gear^.Radius:= 5; |
|
299 |
gear^.Density:= _2; |
|
300 |
end; |
|
301 |
gtBlowTorch: begin |
|
302 |
gear^.Radius:= cHHRadius + cBlowTorchC; |
|
303 |
gear^.Timer:= 7500 |
|
304 |
end; |
|
305 |
gtSwitcher: begin |
|
306 |
gear^.Z:= cCurrHHZ |
|
307 |
end; |
|
308 |
gtTarget: begin |
|
309 |
gear^.ImpactSound:= sndGrenadeImpact; |
|
310 |
gear^.nImpactSounds:= 1; |
|
311 |
gear^.Radius:= 10; |
|
312 |
gear^.Elasticity:= _0_3; |
|
313 |
gear^.Timer:= 0 |
|
314 |
end; |
|
315 |
gtTardis: begin |
|
316 |
gear^.Timer:= 0; |
|
317 |
gear^.Pos:= 1; |
|
318 |
gear^.Z:= cCurrHHZ+1; |
|
319 |
end; |
|
320 |
gtMortar: begin |
|
321 |
gear^.Radius:= 4; |
|
322 |
gear^.Elasticity:= _0_2; |
|
323 |
gear^.Friction:= _0_08; |
|
324 |
gear^.Density:= _1; |
|
325 |
end; |
|
326 |
gtWhip: gear^.Radius:= 20; |
|
327 |
gtHammer: gear^.Radius:= 20; |
|
328 |
gtKamikaze: begin |
|
329 |
gear^.Health:= 2048; |
|
330 |
gear^.Radius:= 20 |
|
331 |
end; |
|
332 |
gtCake: begin |
|
333 |
gear^.Health:= 2048; |
|
334 |
gear^.Radius:= 7; |
|
335 |
gear^.Z:= cOnHHZ; |
|
336 |
gear^.RenderTimer:= true; |
|
337 |
gear^.DirAngle:= -90 * hwSign(Gear^.dX); |
|
338 |
if not dX.isNegative then |
|
339 |
gear^.Angle:= 1 |
|
340 |
else |
|
341 |
gear^.Angle:= 3 |
|
342 |
end; |
|
343 |
gtHellishBomb: begin |
|
344 |
gear^.ImpactSound:= sndHellishImpact1; |
|
345 |
gear^.nImpactSounds:= 4; |
|
346 |
gear^.AdvBounce:= 1; |
|
347 |
gear^.Radius:= 4; |
|
348 |
gear^.Elasticity:= _0_5; |
|
349 |
gear^.Friction:= _0_96; |
|
350 |
gear^.Density:= _1_5; |
|
351 |
gear^.RenderTimer:= true; |
|
352 |
gear^.Timer:= 5000 |
|
353 |
end; |
|
354 |
gtDrill: begin |
|
355 |
if gear^.Timer = 0 then |
|
356 |
gear^.Timer:= 5000; |
|
357 |
// Tag for drill strike. if 1 then first impact occured already |
|
358 |
gear^.Tag := 0; |
|
359 |
gear^.Radius:= 4; |
|
360 |
gear^.Density:= _1; |
|
361 |
end; |
|
362 |
gtBall: begin |
|
363 |
gear^.ImpactSound:= sndGrenadeImpact; |
|
364 |
gear^.nImpactSounds:= 1; |
|
365 |
gear^.AdvBounce:= 1; |
|
366 |
gear^.Radius:= 5; |
|
367 |
gear^.Tag:= random(8); |
|
368 |
gear^.Timer:= 5000; |
|
369 |
gear^.Elasticity:= _0_7; |
|
370 |
gear^.Friction:= _0_995; |
|
371 |
gear^.Density:= _1_5; |
|
372 |
end; |
|
373 |
gtBallgun: begin |
|
374 |
gear^.Timer:= 5001; |
|
375 |
end; |
|
376 |
gtRCPlane: begin |
|
377 |
gear^.Timer:= 15000; |
|
378 |
gear^.Health:= 3; |
|
379 |
gear^.Radius:= 8 |
|
380 |
end; |
|
381 |
gtJetpack: begin |
|
382 |
gear^.Health:= 2000; |
|
383 |
gear^.Damage:= 100 |
|
384 |
end; |
|
385 |
gtMolotov: begin |
|
386 |
gear^.Radius:= 6; |
|
387 |
gear^.Density:= _2; |
|
388 |
end; |
|
389 |
gtBirdy: begin |
|
390 |
gear^.Radius:= 16; // todo: check |
|
391 |
gear^.Timer:= 0; |
|
392 |
gear^.Health := 2000; |
|
393 |
gear^.FlightTime := 2; |
|
394 |
end; |
|
395 |
gtEgg: begin |
|
396 |
gear^.Radius:= 4; |
|
397 |
gear^.Elasticity:= _0_6; |
|
398 |
gear^.Friction:= _0_96; |
|
399 |
gear^.Density:= _1; |
|
400 |
if gear^.Timer = 0 then |
|
401 |
gear^.Timer:= 3000 |
|
402 |
end; |
|
403 |
gtPortal: begin |
|
404 |
gear^.ImpactSound:= sndMelonImpact; |
|
405 |
gear^.nImpactSounds:= 1; |
|
406 |
gear^.AdvBounce:= 0; |
|
407 |
gear^.Radius:= 17; |
|
408 |
// set color |
|
409 |
gear^.Tag:= 2 * gear^.Timer; |
|
410 |
gear^.Timer:= 15000; |
|
411 |
gear^.RenderTimer:= false; |
|
412 |
gear^.Health:= 100; |
|
413 |
end; |
|
414 |
gtPiano: begin |
|
415 |
gear^.Radius:= 32; |
|
416 |
gear^.Density:= _50; |
|
417 |
end; |
|
418 |
gtSineGunShot: begin |
|
419 |
gear^.Radius:= 5; |
|
420 |
gear^.Health:= 6000; |
|
421 |
end; |
|
422 |
gtFlamethrower: begin |
|
423 |
gear^.Tag:= 10; |
|
424 |
gear^.Timer:= 10; |
|
425 |
gear^.Health:= 500; |
|
426 |
gear^.Damage:= 100; |
|
427 |
end; |
|
428 |
gtLandGun: begin |
|
429 |
gear^.Tag:= 10; |
|
430 |
gear^.Timer:= 10; |
|
431 |
gear^.Health:= 1000; |
|
432 |
gear^.Damage:= 100; |
|
433 |
end; |
|
434 |
gtPoisonCloud: begin |
|
435 |
gear^.Timer:= 5000; |
|
436 |
gear^.dY:= int2hwfloat(-4 + longint(getRandom(8))) / 1000; |
|
437 |
end; |
|
438 |
gtResurrector: begin |
|
439 |
gear^.Radius := 100; |
|
440 |
gear^.Tag := 0 |
|
441 |
end; |
|
442 |
gtWaterUp: begin |
|
443 |
gear^.Tag := 47; |
|
444 |
end; |
|
445 |
gtNapalmBomb: begin |
|
446 |
gear^.Timer:= 1000; |
|
447 |
gear^.Radius:= 5; |
|
448 |
gear^.Density:= _1_5; |
|
449 |
end; |
|
450 |
gtStructure: begin |
|
451 |
gear^.Elasticity:= _0_55; |
|
452 |
gear^.Friction:= _0_995; |
|
453 |
gear^.Density:= _0_9; |
|
454 |
gear^.Radius:= 13; |
|
455 |
gear^.Health:= 200; |
|
456 |
gear^.Timer:= 0; |
|
457 |
gear^.Tag:= TotalRounds + 3; |
|
458 |
gear^.Pos:= 1; |
|
459 |
end; |
|
7093 | 460 |
gtIceGun: gear^.Health:= 1000; |
6581 | 461 |
end; |
462 |
||
463 |
InsertGearToList(gear); |
|
464 |
AddGear:= gear; |
|
465 |
||
466 |
ScriptCall('onGearAdd', gear^.uid); |
|
467 |
end; |
|
468 |
||
469 |
procedure DeleteGear(Gear: PGear); |
|
470 |
var team: PTeam; |
|
471 |
t,i: Longword; |
|
472 |
k: boolean; |
|
473 |
begin |
|
474 |
||
475 |
ScriptCall('onGearDelete', gear^.uid); |
|
476 |
||
477 |
DeleteCI(Gear); |
|
478 |
||
479 |
FreeTexture(Gear^.Tex); |
|
480 |
Gear^.Tex:= nil; |
|
481 |
||
482 |
// make sure that portals have their link removed before deletion |
|
483 |
if (Gear^.Kind = gtPortal) then |
|
484 |
begin |
|
485 |
if (Gear^.IntersectGear <> nil) then |
|
486 |
if (Gear^.IntersectGear^.IntersectGear = Gear) then |
|
487 |
Gear^.IntersectGear^.IntersectGear:= nil; |
|
488 |
end |
|
489 |
else if Gear^.Kind = gtHedgehog then |
|
490 |
(* |
|
491 |
This behaviour dates back to revision 4, and I accidentally encountered it with TARDIS. I don't think it must apply to any modern weapon, since if it was actually hit, the best the gear could do would be to destroy itself immediately, and you'd still end up with two graves. I believe it should be removed |
|
492 |
if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then |
|
493 |
begin |
|
494 |
AttackBar:= 0; |
|
495 |
Gear^.Message:= gmDestroy; |
|
496 |
CurAmmoGear^.Message:= gmDestroy; |
|
497 |
exit |
|
498 |
end |
|
499 |
else*) |
|
500 |
begin |
|
6792
f72c8b5d421c
Ensure flawless is false if any hog is lost, unless it was lost doing a kamikaze
nemo
parents:
6700
diff
changeset
|
501 |
if (Gear <> CurrentHedgehog^.Gear) or (CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtKamikaze) then |
f72c8b5d421c
Ensure flawless is false if any hog is lost, unless it was lost doing a kamikaze
nemo
parents:
6700
diff
changeset
|
502 |
Gear^.Hedgehog^.Team^.Clan^.Flawless:= false; |
6581 | 503 |
if (hwRound(Gear^.Y) >= cWaterLine) then |
504 |
begin |
|
505 |
t:= max(Gear^.Damage, Gear^.Health); |
|
506 |
Gear^.Damage:= t; |
|
6982 | 507 |
if ((not SuddenDeathDmg and (WaterOpacity < $FF)) or (SuddenDeathDmg and (WaterOpacity < $FF))) |
6581 | 508 |
and (hwRound(Gear^.Y) < cWaterLine + 256) then |
509 |
spawnHealthTagForHH(Gear, t); |
|
510 |
end; |
|
511 |
||
512 |
team:= Gear^.Hedgehog^.Team; |
|
513 |
if CurrentHedgehog^.Gear = Gear then |
|
514 |
begin |
|
515 |
AttackBar:= 0; |
|
516 |
FreeActionsList; // to avoid ThinkThread on drawned gear |
|
517 |
if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) |
|
518 |
and (CurrentHedgehog^.MultiShootAttacks > 0) then |
|
519 |
OnUsedAmmo(CurrentHedgehog^); |
|
520 |
end; |
|
521 |
||
522 |
Gear^.Hedgehog^.Gear:= nil; |
|
523 |
if Gear^.Hedgehog^.King then |
|
524 |
begin |
|
525 |
// are there any other kings left? Just doing nil check. Presumably a mortally wounded king will get reaped soon enough |
|
526 |
k:= false; |
|
527 |
for i:= 0 to Pred(team^.Clan^.TeamsNumber) do |
|
528 |
if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then |
|
529 |
k:= true; |
|
530 |
if not k then |
|
531 |
for i:= 0 to Pred(team^.Clan^.TeamsNumber) do |
|
532 |
begin |
|
533 |
team^.Clan^.Teams[i]^.hasGone:= true; |
|
534 |
TeamGoneEffect(team^.Clan^.Teams[i]^) |
|
535 |
end |
|
536 |
end; |
|
537 |
||
538 |
// should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog |
|
539 |
// same stand for CheckHHDamage |
|
540 |
if (Gear^.LastDamage <> nil) then |
|
541 |
uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true) |
|
542 |
else |
|
543 |
uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true); |
|
544 |
||
545 |
inc(KilledHHs); |
|
546 |
RecountTeamHealth(team); |
|
7010
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
7001
diff
changeset
|
547 |
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Effects[heResurrectable] <> 0) and |
10a0a31804f3
Switch effects to longint for convenience of tracking ice states. I could add a new Hedgehog value, but since we have this effects list being all useless as booleans anyway...
nemo
parents:
7001
diff
changeset
|
548 |
(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then |
6581 | 549 |
with CurrentHedgehog^ do |
550 |
begin |
|
551 |
inc(Team^.stats.AIKills); |
|
552 |
FreeTexture(Team^.AIKillsTex); |
|
553 |
Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); |
|
554 |
end |
|
555 |
end; |
|
556 |
with Gear^ do |
|
557 |
AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind)); |
|
558 |
||
559 |
if CurAmmoGear = Gear then |
|
560 |
CurAmmoGear:= nil; |
|
561 |
if FollowGear = Gear then |
|
562 |
FollowGear:= nil; |
|
563 |
if lastGearByUID = Gear then |
|
564 |
lastGearByUID := nil; |
|
565 |
RemoveGearFromList(Gear); |
|
566 |
Dispose(Gear) |
|
567 |
end; |
|
568 |
||
569 |
end. |