author | unc0rr |
Fri, 29 Jun 2012 01:23:43 +0400 | |
changeset 7325 | a68eca3ad1fe |
parent 7276 | e570bc0df33c |
child 7337 | c224cd2d32f3 |
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]; |
|
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset
|
103 |
gear^.CollisionMask:= $FFFF; |
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset
|
104 |
|
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset
|
105 |
if CurrentHedgehog <> nil then gear^.Hedgehog:= CurrentHedgehog; |
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset
|
106 |
|
6581 | 107 |
if Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then |
108 |
gear^.Z:= cHHZ+1 |
|
109 |
else gear^.Z:= cUsualZ; |
|
110 |
||
111 |
||
112 |
case Kind of |
|
113 |
gtGrenade, |
|
114 |
gtClusterBomb, |
|
115 |
gtGasBomb: begin |
|
116 |
gear^.ImpactSound:= sndGrenadeImpact; |
|
117 |
gear^.nImpactSounds:= 1; |
|
118 |
gear^.AdvBounce:= 1; |
|
119 |
gear^.Radius:= 5; |
|
120 |
gear^.Elasticity:= _0_8; |
|
121 |
gear^.Friction:= _0_8; |
|
122 |
gear^.Density:= _1_5; |
|
123 |
gear^.RenderTimer:= true; |
|
124 |
if gear^.Timer = 0 then |
|
125 |
gear^.Timer:= 3000 |
|
126 |
end; |
|
127 |
gtWatermelon: begin |
|
128 |
gear^.ImpactSound:= sndMelonImpact; |
|
129 |
gear^.nImpactSounds:= 1; |
|
130 |
gear^.AdvBounce:= 1; |
|
131 |
gear^.Radius:= 6; |
|
132 |
gear^.Elasticity:= _0_8; |
|
133 |
gear^.Friction:= _0_995; |
|
134 |
gear^.Density:= _2; |
|
135 |
gear^.RenderTimer:= true; |
|
136 |
if gear^.Timer = 0 then |
|
137 |
gear^.Timer:= 3000 |
|
138 |
end; |
|
139 |
gtMelonPiece: begin |
|
140 |
gear^.Density:= _2; |
|
141 |
end; |
|
142 |
gtHedgehog: begin |
|
143 |
gear^.AdvBounce:= 1; |
|
144 |
gear^.Radius:= cHHRadius; |
|
145 |
gear^.Elasticity:= _0_35; |
|
146 |
gear^.Friction:= _0_999; |
|
147 |
gear^.Angle:= cMaxAngle div 2; |
|
148 |
gear^.Density:= _3; |
|
149 |
gear^.Z:= cHHZ; |
|
150 |
if (GameFlags and gfAISurvival) <> 0 then |
|
151 |
if gear^.Hedgehog^.BotLevel > 0 then |
|
7077 | 152 |
gear^.Hedgehog^.Effects[heResurrectable] := 1; |
6581 | 153 |
end; |
154 |
gtShell: begin |
|
155 |
gear^.Radius:= 4; |
|
156 |
gear^.Density:= _1; |
|
157 |
end; |
|
158 |
gtSnowball: begin |
|
159 |
gear^.ImpactSound:= sndMudballImpact; |
|
160 |
gear^.nImpactSounds:= 1; |
|
161 |
gear^.Radius:= 4; |
|
162 |
gear^.Elasticity:= _1; |
|
163 |
gear^.Friction:= _1; |
|
164 |
gear^.Density:= _0_5; |
|
165 |
end; |
|
166 |
||
167 |
gtFlake: begin |
|
168 |
with Gear^ do |
|
169 |
begin |
|
170 |
Pos:= 0; |
|
171 |
Radius:= 1; |
|
7069 | 172 |
DirAngle:= random(360); |
6581 | 173 |
if State and gstTmpFlag = 0 then |
174 |
begin |
|
175 |
dx.isNegative:= GetRandom(2) = 0; |
|
176 |
dx.QWordValue:= GetRandom(100000000); |
|
177 |
dy.isNegative:= false; |
|
178 |
dy.QWordValue:= GetRandom(70000000); |
|
179 |
if GetRandom(2) = 0 then |
|
180 |
dx := -dx |
|
181 |
end; |
|
182 |
State:= State or gstInvisible; |
|
183 |
Health:= random(vobFrameTicks); |
|
184 |
Timer:= random(vobFramesCount); |
|
185 |
Angle:= (random(2) * 2 - 1) * (1 + random(10000)) * vobVelocity |
|
186 |
end |
|
187 |
end; |
|
188 |
gtGrave: begin |
|
189 |
gear^.ImpactSound:= sndGraveImpact; |
|
190 |
gear^.nImpactSounds:= 1; |
|
191 |
gear^.Radius:= 10; |
|
192 |
gear^.Elasticity:= _0_6; |
|
193 |
end; |
|
194 |
gtBee: begin |
|
195 |
gear^.Radius:= 5; |
|
196 |
gear^.Timer:= 500; |
|
197 |
gear^.RenderTimer:= true; |
|
198 |
gear^.Elasticity:= _0_9; |
|
199 |
gear^.Tag:= 0; |
|
200 |
end; |
|
201 |
gtSeduction: begin |
|
202 |
gear^.Radius:= 250; |
|
203 |
end; |
|
204 |
gtShotgunShot: begin |
|
205 |
gear^.Timer:= 900; |
|
206 |
gear^.Radius:= 2 |
|
207 |
end; |
|
208 |
gtPickHammer: begin |
|
209 |
gear^.Radius:= 10; |
|
210 |
gear^.Timer:= 4000 |
|
211 |
end; |
|
212 |
gtHammerHit: begin |
|
213 |
gear^.Radius:= 8; |
|
214 |
gear^.Timer:= 125 |
|
215 |
end; |
|
216 |
gtRope: begin |
|
217 |
gear^.Radius:= 3; |
|
218 |
gear^.Friction:= _450 * _0_01 * cRopePercent; |
|
219 |
RopePoints.Count:= 0; |
|
220 |
end; |
|
221 |
gtMine: begin |
|
222 |
gear^.ImpactSound:= sndMineImpact; |
|
223 |
gear^.nImpactSounds:= 1; |
|
224 |
gear^.Health:= 10; |
|
225 |
gear^.State:= gear^.State or gstMoving; |
|
226 |
gear^.Radius:= 2; |
|
227 |
gear^.Elasticity:= _0_55; |
|
228 |
gear^.Friction:= _0_995; |
|
229 |
gear^.Density:= _0_9; |
|
230 |
if cMinesTime < 0 then |
|
231 |
gear^.Timer:= getrandom(51)*100 |
|
232 |
else |
|
233 |
gear^.Timer:= cMinesTime; |
|
234 |
end; |
|
235 |
gtSMine: begin |
|
236 |
gear^.Health:= 10; |
|
237 |
gear^.State:= gear^.State or gstMoving; |
|
238 |
gear^.Radius:= 2; |
|
239 |
gear^.Elasticity:= _0_55; |
|
240 |
gear^.Friction:= _0_995; |
|
241 |
gear^.Density:= _0_9; |
|
242 |
gear^.Timer:= 500; |
|
243 |
end; |
|
244 |
gtCase: begin |
|
245 |
gear^.ImpactSound:= sndGraveImpact; |
|
246 |
gear^.nImpactSounds:= 1; |
|
247 |
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
|
248 |
gear^.Elasticity:= _0_3; |
7276 | 249 |
gear^.Timer:= 500 |
6581 | 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 |
|
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset
|
485 |
if (Gear^.LinkedGear <> nil) then |
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset
|
486 |
if (Gear^.LinkedGear^.LinkedGear = Gear) then |
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset
|
487 |
Gear^.LinkedGear^.LinkedGear:= nil; |
6581 | 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 |
7176
fb4b0c6dfdbd
Make watching AI v AI on ai survival a bit more entertaining
nemo
parents:
7168
diff
changeset
|
548 |
//(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then |
fb4b0c6dfdbd
Make watching AI v AI on ai survival a bit more entertaining
nemo
parents:
7168
diff
changeset
|
549 |
(Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan) then |
6581 | 550 |
with CurrentHedgehog^ do |
551 |
begin |
|
552 |
inc(Team^.stats.AIKills); |
|
553 |
FreeTexture(Team^.AIKillsTex); |
|
554 |
Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); |
|
555 |
end |
|
556 |
end; |
|
557 |
with Gear^ do |
|
558 |
AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind)); |
|
559 |
||
560 |
if CurAmmoGear = Gear then |
|
561 |
CurAmmoGear:= nil; |
|
562 |
if FollowGear = Gear then |
|
563 |
FollowGear:= nil; |
|
564 |
if lastGearByUID = Gear then |
|
565 |
lastGearByUID := nil; |
|
566 |
RemoveGearFromList(Gear); |
|
567 |
Dispose(Gear) |
|
568 |
end; |
|
569 |
||
570 |
end. |