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