author | koda |
Mon, 07 May 2012 14:53:08 +0200 | |
changeset 7031 | d5ea24399a48 |
parent 7028 | 0f60591f3a16 |
child 7069 | bcf9d8e64e92 |
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 |
||
7028 | 36 |
var GCounter: LongWord = 0; // this doesn't get re-initialized, but should be harmless |
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 |
|
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
|
153 |
gear^.Hedgehog^.Effects[heResurrectable] := 0; |
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; |
|
173 |
DirAngle:= random * 360; |
|
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; |
|
460 |
end; |
|
461 |
||
462 |
InsertGearToList(gear); |
|
463 |
AddGear:= gear; |
|
464 |
||
465 |
ScriptCall('onGearAdd', gear^.uid); |
|
466 |
end; |
|
467 |
||
468 |
procedure DeleteGear(Gear: PGear); |
|
469 |
var team: PTeam; |
|
470 |
t,i: Longword; |
|
471 |
k: boolean; |
|
472 |
begin |
|
473 |
||
474 |
ScriptCall('onGearDelete', gear^.uid); |
|
475 |
||
476 |
DeleteCI(Gear); |
|
477 |
||
478 |
FreeTexture(Gear^.Tex); |
|
479 |
Gear^.Tex:= nil; |
|
480 |
||
481 |
// make sure that portals have their link removed before deletion |
|
482 |
if (Gear^.Kind = gtPortal) then |
|
483 |
begin |
|
484 |
if (Gear^.IntersectGear <> nil) then |
|
485 |
if (Gear^.IntersectGear^.IntersectGear = Gear) then |
|
486 |
Gear^.IntersectGear^.IntersectGear:= nil; |
|
487 |
end |
|
488 |
else if Gear^.Kind = gtHedgehog then |
|
489 |
(* |
|
490 |
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 |
|
491 |
if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then |
|
492 |
begin |
|
493 |
AttackBar:= 0; |
|
494 |
Gear^.Message:= gmDestroy; |
|
495 |
CurAmmoGear^.Message:= gmDestroy; |
|
496 |
exit |
|
497 |
end |
|
498 |
else*) |
|
499 |
begin |
|
6792
f72c8b5d421c
Ensure flawless is false if any hog is lost, unless it was lost doing a kamikaze
nemo
parents:
6700
diff
changeset
|
500 |
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
|
501 |
Gear^.Hedgehog^.Team^.Clan^.Flawless:= false; |
6581 | 502 |
if (hwRound(Gear^.Y) >= cWaterLine) then |
503 |
begin |
|
504 |
t:= max(Gear^.Damage, Gear^.Health); |
|
505 |
Gear^.Damage:= t; |
|
6982 | 506 |
if ((not SuddenDeathDmg and (WaterOpacity < $FF)) or (SuddenDeathDmg and (WaterOpacity < $FF))) |
6581 | 507 |
and (hwRound(Gear^.Y) < cWaterLine + 256) then |
508 |
spawnHealthTagForHH(Gear, t); |
|
509 |
end; |
|
510 |
||
511 |
team:= Gear^.Hedgehog^.Team; |
|
512 |
if CurrentHedgehog^.Gear = Gear then |
|
513 |
begin |
|
514 |
AttackBar:= 0; |
|
515 |
FreeActionsList; // to avoid ThinkThread on drawned gear |
|
516 |
if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) |
|
517 |
and (CurrentHedgehog^.MultiShootAttacks > 0) then |
|
518 |
OnUsedAmmo(CurrentHedgehog^); |
|
519 |
end; |
|
520 |
||
521 |
Gear^.Hedgehog^.Gear:= nil; |
|
522 |
if Gear^.Hedgehog^.King then |
|
523 |
begin |
|
524 |
// are there any other kings left? Just doing nil check. Presumably a mortally wounded king will get reaped soon enough |
|
525 |
k:= false; |
|
526 |
for i:= 0 to Pred(team^.Clan^.TeamsNumber) do |
|
527 |
if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then |
|
528 |
k:= true; |
|
529 |
if not k then |
|
530 |
for i:= 0 to Pred(team^.Clan^.TeamsNumber) do |
|
531 |
begin |
|
532 |
team^.Clan^.Teams[i]^.hasGone:= true; |
|
533 |
TeamGoneEffect(team^.Clan^.Teams[i]^) |
|
534 |
end |
|
535 |
end; |
|
536 |
||
537 |
// should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog |
|
538 |
// same stand for CheckHHDamage |
|
539 |
if (Gear^.LastDamage <> nil) then |
|
540 |
uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true) |
|
541 |
else |
|
542 |
uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true); |
|
543 |
||
544 |
inc(KilledHHs); |
|
545 |
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
|
546 |
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
|
547 |
(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then |
6581 | 548 |
with CurrentHedgehog^ do |
549 |
begin |
|
550 |
inc(Team^.stats.AIKills); |
|
551 |
FreeTexture(Team^.AIKillsTex); |
|
552 |
Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); |
|
553 |
end |
|
554 |
end; |
|
555 |
with Gear^ do |
|
556 |
AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind)); |
|
557 |
||
558 |
if CurAmmoGear = Gear then |
|
559 |
CurAmmoGear:= nil; |
|
560 |
if FollowGear = Gear then |
|
561 |
FollowGear:= nil; |
|
562 |
if lastGearByUID = Gear then |
|
563 |
lastGearByUID := nil; |
|
564 |
RemoveGearFromList(Gear); |
|
565 |
Dispose(Gear) |
|
566 |
end; |
|
567 |
||
568 |
end. |