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