author | nemo |
Sun, 10 Jun 2012 14:36:40 -0400 | |
changeset 7218 | 9ecd5bc9810b |
parent 7176 | fb4b0c6dfdbd |
child 7272 | 71df899c4163 |
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; |
|
7168
8defaabce92e
warp sound when AI survival hog respawns. attempt at a bit of a crate spawn animation (moar sparkles and a quick fadein)
nemo
parents:
7093
diff
changeset
|
249 |
gear^.Elasticity:= _0_3; |
8defaabce92e
warp sound when AI survival hog respawns. attempt at a bit of a crate spawn animation (moar sparkles and a quick fadein)
nemo
parents:
7093
diff
changeset
|
250 |
gear^.Timer:= 0 |
6581 | 251 |
end; |
252 |
gtExplosives: begin |
|
253 |
gear^.ImpactSound:= sndGrenadeImpact; |
|
254 |
gear^.nImpactSounds:= 1; |
|
255 |
gear^.Radius:= 16; |
|
256 |
gear^.Elasticity:= _0_4; |
|
257 |
gear^.Friction:= _0_995; |
|
258 |
gear^.Density:= _6; |
|
259 |
gear^.Health:= cBarrelHealth; |
|
260 |
gear^.Z:= cHHZ-1 |
|
261 |
end; |
|
262 |
gtDEagleShot: begin |
|
263 |
gear^.Radius:= 1; |
|
264 |
gear^.Health:= 50 |
|
265 |
end; |
|
266 |
gtSniperRifleShot: begin |
|
267 |
gear^.Radius:= 1; |
|
268 |
gear^.Health:= 50 |
|
269 |
end; |
|
270 |
gtDynamite: begin |
|
271 |
gear^.Radius:= 3; |
|
272 |
gear^.Elasticity:= _0_55; |
|
273 |
gear^.Friction:= _0_03; |
|
274 |
gear^.Density:= _2; |
|
275 |
gear^.Timer:= 5000; |
|
276 |
end; |
|
277 |
gtCluster: begin |
|
278 |
gear^.Radius:= 2; |
|
279 |
gear^.Density:= _1_5; |
|
280 |
gear^.RenderTimer:= true |
|
281 |
end; |
|
282 |
gtShover: gear^.Radius:= 20; |
|
283 |
gtFlame: begin |
|
284 |
gear^.Tag:= GetRandom(32); |
|
285 |
gear^.Radius:= 1; |
|
286 |
gear^.Health:= 5; |
|
287 |
gear^.Density:= _1; |
|
288 |
if (gear^.dY.QWordValue = 0) and (gear^.dX.QWordValue = 0) then |
|
289 |
begin |
|
7001 | 290 |
gear^.dY:= (getrandomf - _0_8) * _0_03; |
291 |
gear^.dX:= (getrandomf - _0_5) * _0_4 |
|
6581 | 292 |
end |
293 |
end; |
|
294 |
gtFirePunch: begin |
|
295 |
gear^.Radius:= 15; |
|
296 |
gear^.Tag:= Y |
|
297 |
end; |
|
298 |
gtAirBomb: begin |
|
299 |
gear^.Radius:= 5; |
|
300 |
gear^.Density:= _2; |
|
301 |
end; |
|
302 |
gtBlowTorch: begin |
|
303 |
gear^.Radius:= cHHRadius + cBlowTorchC; |
|
304 |
gear^.Timer:= 7500 |
|
305 |
end; |
|
306 |
gtSwitcher: begin |
|
307 |
gear^.Z:= cCurrHHZ |
|
308 |
end; |
|
309 |
gtTarget: begin |
|
310 |
gear^.ImpactSound:= sndGrenadeImpact; |
|
311 |
gear^.nImpactSounds:= 1; |
|
312 |
gear^.Radius:= 10; |
|
313 |
gear^.Elasticity:= _0_3; |
|
314 |
gear^.Timer:= 0 |
|
315 |
end; |
|
316 |
gtTardis: begin |
|
317 |
gear^.Timer:= 0; |
|
318 |
gear^.Pos:= 1; |
|
319 |
gear^.Z:= cCurrHHZ+1; |
|
320 |
end; |
|
321 |
gtMortar: begin |
|
322 |
gear^.Radius:= 4; |
|
323 |
gear^.Elasticity:= _0_2; |
|
324 |
gear^.Friction:= _0_08; |
|
325 |
gear^.Density:= _1; |
|
326 |
end; |
|
327 |
gtWhip: gear^.Radius:= 20; |
|
328 |
gtHammer: gear^.Radius:= 20; |
|
329 |
gtKamikaze: begin |
|
330 |
gear^.Health:= 2048; |
|
331 |
gear^.Radius:= 20 |
|
332 |
end; |
|
333 |
gtCake: begin |
|
334 |
gear^.Health:= 2048; |
|
335 |
gear^.Radius:= 7; |
|
336 |
gear^.Z:= cOnHHZ; |
|
337 |
gear^.RenderTimer:= true; |
|
338 |
gear^.DirAngle:= -90 * hwSign(Gear^.dX); |
|
339 |
if not dX.isNegative then |
|
340 |
gear^.Angle:= 1 |
|
341 |
else |
|
342 |
gear^.Angle:= 3 |
|
343 |
end; |
|
344 |
gtHellishBomb: begin |
|
345 |
gear^.ImpactSound:= sndHellishImpact1; |
|
346 |
gear^.nImpactSounds:= 4; |
|
347 |
gear^.AdvBounce:= 1; |
|
348 |
gear^.Radius:= 4; |
|
349 |
gear^.Elasticity:= _0_5; |
|
350 |
gear^.Friction:= _0_96; |
|
351 |
gear^.Density:= _1_5; |
|
352 |
gear^.RenderTimer:= true; |
|
353 |
gear^.Timer:= 5000 |
|
354 |
end; |
|
355 |
gtDrill: begin |
|
356 |
if gear^.Timer = 0 then |
|
357 |
gear^.Timer:= 5000; |
|
358 |
// Tag for drill strike. if 1 then first impact occured already |
|
359 |
gear^.Tag := 0; |
|
360 |
gear^.Radius:= 4; |
|
361 |
gear^.Density:= _1; |
|
362 |
end; |
|
363 |
gtBall: begin |
|
364 |
gear^.ImpactSound:= sndGrenadeImpact; |
|
365 |
gear^.nImpactSounds:= 1; |
|
366 |
gear^.AdvBounce:= 1; |
|
367 |
gear^.Radius:= 5; |
|
368 |
gear^.Tag:= random(8); |
|
369 |
gear^.Timer:= 5000; |
|
370 |
gear^.Elasticity:= _0_7; |
|
371 |
gear^.Friction:= _0_995; |
|
372 |
gear^.Density:= _1_5; |
|
373 |
end; |
|
374 |
gtBallgun: begin |
|
375 |
gear^.Timer:= 5001; |
|
376 |
end; |
|
377 |
gtRCPlane: begin |
|
378 |
gear^.Timer:= 15000; |
|
379 |
gear^.Health:= 3; |
|
380 |
gear^.Radius:= 8 |
|
381 |
end; |
|
382 |
gtJetpack: begin |
|
383 |
gear^.Health:= 2000; |
|
384 |
gear^.Damage:= 100 |
|
385 |
end; |
|
386 |
gtMolotov: begin |
|
387 |
gear^.Radius:= 6; |
|
388 |
gear^.Density:= _2; |
|
389 |
end; |
|
390 |
gtBirdy: begin |
|
391 |
gear^.Radius:= 16; // todo: check |
|
392 |
gear^.Timer:= 0; |
|
393 |
gear^.Health := 2000; |
|
394 |
gear^.FlightTime := 2; |
|
395 |
end; |
|
396 |
gtEgg: begin |
|
397 |
gear^.Radius:= 4; |
|
398 |
gear^.Elasticity:= _0_6; |
|
399 |
gear^.Friction:= _0_96; |
|
400 |
gear^.Density:= _1; |
|
401 |
if gear^.Timer = 0 then |
|
402 |
gear^.Timer:= 3000 |
|
403 |
end; |
|
404 |
gtPortal: begin |
|
405 |
gear^.ImpactSound:= sndMelonImpact; |
|
406 |
gear^.nImpactSounds:= 1; |
|
407 |
gear^.AdvBounce:= 0; |
|
408 |
gear^.Radius:= 17; |
|
409 |
// set color |
|
410 |
gear^.Tag:= 2 * gear^.Timer; |
|
411 |
gear^.Timer:= 15000; |
|
412 |
gear^.RenderTimer:= false; |
|
413 |
gear^.Health:= 100; |
|
414 |
end; |
|
415 |
gtPiano: begin |
|
416 |
gear^.Radius:= 32; |
|
417 |
gear^.Density:= _50; |
|
418 |
end; |
|
419 |
gtSineGunShot: begin |
|
420 |
gear^.Radius:= 5; |
|
421 |
gear^.Health:= 6000; |
|
422 |
end; |
|
423 |
gtFlamethrower: begin |
|
424 |
gear^.Tag:= 10; |
|
425 |
gear^.Timer:= 10; |
|
426 |
gear^.Health:= 500; |
|
427 |
gear^.Damage:= 100; |
|
428 |
end; |
|
429 |
gtLandGun: begin |
|
430 |
gear^.Tag:= 10; |
|
431 |
gear^.Timer:= 10; |
|
432 |
gear^.Health:= 1000; |
|
433 |
gear^.Damage:= 100; |
|
434 |
end; |
|
435 |
gtPoisonCloud: begin |
|
436 |
gear^.Timer:= 5000; |
|
437 |
gear^.dY:= int2hwfloat(-4 + longint(getRandom(8))) / 1000; |
|
438 |
end; |
|
439 |
gtResurrector: begin |
|
440 |
gear^.Radius := 100; |
|
441 |
gear^.Tag := 0 |
|
442 |
end; |
|
443 |
gtWaterUp: begin |
|
444 |
gear^.Tag := 47; |
|
445 |
end; |
|
446 |
gtNapalmBomb: begin |
|
447 |
gear^.Timer:= 1000; |
|
448 |
gear^.Radius:= 5; |
|
449 |
gear^.Density:= _1_5; |
|
450 |
end; |
|
451 |
gtStructure: begin |
|
452 |
gear^.Elasticity:= _0_55; |
|
453 |
gear^.Friction:= _0_995; |
|
454 |
gear^.Density:= _0_9; |
|
455 |
gear^.Radius:= 13; |
|
456 |
gear^.Health:= 200; |
|
457 |
gear^.Timer:= 0; |
|
458 |
gear^.Tag:= TotalRounds + 3; |
|
459 |
gear^.Pos:= 1; |
|
460 |
end; |
|
7093 | 461 |
gtIceGun: gear^.Health:= 1000; |
6581 | 462 |
end; |
463 |
||
464 |
InsertGearToList(gear); |
|
465 |
AddGear:= gear; |
|
466 |
||
467 |
ScriptCall('onGearAdd', gear^.uid); |
|
468 |
end; |
|
469 |
||
470 |
procedure DeleteGear(Gear: PGear); |
|
471 |
var team: PTeam; |
|
472 |
t,i: Longword; |
|
473 |
k: boolean; |
|
474 |
begin |
|
475 |
||
476 |
ScriptCall('onGearDelete', gear^.uid); |
|
477 |
||
478 |
DeleteCI(Gear); |
|
479 |
||
480 |
FreeTexture(Gear^.Tex); |
|
481 |
Gear^.Tex:= nil; |
|
482 |
||
483 |
// make sure that portals have their link removed before deletion |
|
484 |
if (Gear^.Kind = gtPortal) then |
|
485 |
begin |
|
486 |
if (Gear^.IntersectGear <> nil) then |
|
487 |
if (Gear^.IntersectGear^.IntersectGear = Gear) then |
|
488 |
Gear^.IntersectGear^.IntersectGear:= nil; |
|
489 |
end |
|
490 |
else if Gear^.Kind = gtHedgehog then |
|
491 |
(* |
|
492 |
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 |
|
493 |
if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then |
|
494 |
begin |
|
495 |
AttackBar:= 0; |
|
496 |
Gear^.Message:= gmDestroy; |
|
497 |
CurAmmoGear^.Message:= gmDestroy; |
|
498 |
exit |
|
499 |
end |
|
500 |
else*) |
|
501 |
begin |
|
6792
f72c8b5d421c
Ensure flawless is false if any hog is lost, unless it was lost doing a kamikaze
nemo
parents:
6700
diff
changeset
|
502 |
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
|
503 |
Gear^.Hedgehog^.Team^.Clan^.Flawless:= false; |
6581 | 504 |
if (hwRound(Gear^.Y) >= cWaterLine) then |
505 |
begin |
|
506 |
t:= max(Gear^.Damage, Gear^.Health); |
|
507 |
Gear^.Damage:= t; |
|
6982 | 508 |
if ((not SuddenDeathDmg and (WaterOpacity < $FF)) or (SuddenDeathDmg and (WaterOpacity < $FF))) |
6581 | 509 |
and (hwRound(Gear^.Y) < cWaterLine + 256) then |
510 |
spawnHealthTagForHH(Gear, t); |
|
511 |
end; |
|
512 |
||
513 |
team:= Gear^.Hedgehog^.Team; |
|
514 |
if CurrentHedgehog^.Gear = Gear then |
|
515 |
begin |
|
516 |
AttackBar:= 0; |
|
517 |
FreeActionsList; // to avoid ThinkThread on drawned gear |
|
518 |
if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) |
|
519 |
and (CurrentHedgehog^.MultiShootAttacks > 0) then |
|
520 |
OnUsedAmmo(CurrentHedgehog^); |
|
521 |
end; |
|
522 |
||
523 |
Gear^.Hedgehog^.Gear:= nil; |
|
524 |
if Gear^.Hedgehog^.King then |
|
525 |
begin |
|
526 |
// are there any other kings left? Just doing nil check. Presumably a mortally wounded king will get reaped soon enough |
|
527 |
k:= false; |
|
528 |
for i:= 0 to Pred(team^.Clan^.TeamsNumber) do |
|
529 |
if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then |
|
530 |
k:= true; |
|
531 |
if not k then |
|
532 |
for i:= 0 to Pred(team^.Clan^.TeamsNumber) do |
|
533 |
begin |
|
534 |
team^.Clan^.Teams[i]^.hasGone:= true; |
|
535 |
TeamGoneEffect(team^.Clan^.Teams[i]^) |
|
536 |
end |
|
537 |
end; |
|
538 |
||
539 |
// should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog |
|
540 |
// same stand for CheckHHDamage |
|
541 |
if (Gear^.LastDamage <> nil) then |
|
542 |
uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true) |
|
543 |
else |
|
544 |
uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true); |
|
545 |
||
546 |
inc(KilledHHs); |
|
547 |
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
|
548 |
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Effects[heResurrectable] <> 0) and |
7176
fb4b0c6dfdbd
Make watching AI v AI on ai survival a bit more entertaining
nemo
parents:
7168
diff
changeset
|
549 |
//(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then |
fb4b0c6dfdbd
Make watching AI v AI on ai survival a bit more entertaining
nemo
parents:
7168
diff
changeset
|
550 |
(Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan) then |
6581 | 551 |
with CurrentHedgehog^ do |
552 |
begin |
|
553 |
inc(Team^.stats.AIKills); |
|
554 |
FreeTexture(Team^.AIKillsTex); |
|
555 |
Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); |
|
556 |
end |
|
557 |
end; |
|
558 |
with Gear^ do |
|
559 |
AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind)); |
|
560 |
||
561 |
if CurAmmoGear = Gear then |
|
562 |
CurAmmoGear:= nil; |
|
563 |
if FollowGear = Gear then |
|
564 |
FollowGear:= nil; |
|
565 |
if lastGearByUID = Gear then |
|
566 |
lastGearByUID := nil; |
|
567 |
RemoveGearFromList(Gear); |
|
568 |
Dispose(Gear) |
|
569 |
end; |
|
570 |
||
571 |
end. |