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