author | unc0rr |
Thu, 11 Oct 2012 21:17:56 +0400 | |
changeset 7744 | 75e1d0c0ba72 |
parent 7733 | a1476c09403f |
child 7754 | e81dc9bef8b8 |
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]; |
|
7730
2013733f9ca9
A bit more on the knife. Also add missing files to CMakeLists
nemo
parents:
7726
diff
changeset
|
107 |
gear^.CollisionMask:= $FFFF; |
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset
|
108 |
|
7726
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
109 |
if CurrentHedgehog <> nil then |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
110 |
begin |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
111 |
gear^.Hedgehog:= CurrentHedgehog; |
1137406bce12
Set default collision mask for gears at currenthedgehog X/Y to FF7F, expose mask to scripting as well. This should resolve the collision part of bug #420
nemo
parents:
7721
diff
changeset
|
112 |
if (CurrentHedgehog^.Gear <> nil) and (hwRound(CurrentHedgehog^.Gear^.X) = X) and (hwRound(CurrentHedgehog^.Gear^.Y) = Y) then |
7730
2013733f9ca9
A bit more on the knife. Also add missing files to CMakeLists
nemo
parents:
7726
diff
changeset
|
113 |
gear^.CollisionMask:= $FF7F |
2013733f9ca9
A bit more on the knife. Also add missing files to CMakeLists
nemo
parents:
7726
diff
changeset
|
114 |
end; |
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset
|
115 |
|
7364 | 116 |
if (Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0) then |
6581 | 117 |
gear^.Z:= cHHZ+1 |
118 |
else gear^.Z:= cUsualZ; |
|
119 |
||
120 |
||
121 |
case Kind of |
|
122 |
gtGrenade, |
|
123 |
gtClusterBomb, |
|
124 |
gtGasBomb: begin |
|
125 |
gear^.ImpactSound:= sndGrenadeImpact; |
|
126 |
gear^.nImpactSounds:= 1; |
|
127 |
gear^.AdvBounce:= 1; |
|
128 |
gear^.Radius:= 5; |
|
129 |
gear^.Elasticity:= _0_8; |
|
130 |
gear^.Friction:= _0_8; |
|
131 |
gear^.Density:= _1_5; |
|
132 |
gear^.RenderTimer:= true; |
|
133 |
if gear^.Timer = 0 then |
|
134 |
gear^.Timer:= 3000 |
|
135 |
end; |
|
136 |
gtWatermelon: begin |
|
137 |
gear^.ImpactSound:= sndMelonImpact; |
|
138 |
gear^.nImpactSounds:= 1; |
|
139 |
gear^.AdvBounce:= 1; |
|
140 |
gear^.Radius:= 6; |
|
141 |
gear^.Elasticity:= _0_8; |
|
142 |
gear^.Friction:= _0_995; |
|
143 |
gear^.Density:= _2; |
|
144 |
gear^.RenderTimer:= true; |
|
145 |
if gear^.Timer = 0 then |
|
146 |
gear^.Timer:= 3000 |
|
147 |
end; |
|
148 |
gtMelonPiece: begin |
|
149 |
gear^.Density:= _2; |
|
150 |
end; |
|
151 |
gtHedgehog: begin |
|
152 |
gear^.AdvBounce:= 1; |
|
153 |
gear^.Radius:= cHHRadius; |
|
154 |
gear^.Elasticity:= _0_35; |
|
155 |
gear^.Friction:= _0_999; |
|
156 |
gear^.Angle:= cMaxAngle div 2; |
|
157 |
gear^.Density:= _3; |
|
158 |
gear^.Z:= cHHZ; |
|
159 |
if (GameFlags and gfAISurvival) <> 0 then |
|
160 |
if gear^.Hedgehog^.BotLevel > 0 then |
|
7077 | 161 |
gear^.Hedgehog^.Effects[heResurrectable] := 1; |
6581 | 162 |
end; |
163 |
gtShell: begin |
|
164 |
gear^.Radius:= 4; |
|
165 |
gear^.Density:= _1; |
|
166 |
end; |
|
167 |
gtSnowball: begin |
|
168 |
gear^.ImpactSound:= sndMudballImpact; |
|
169 |
gear^.nImpactSounds:= 1; |
|
170 |
gear^.Radius:= 4; |
|
171 |
gear^.Elasticity:= _1; |
|
172 |
gear^.Friction:= _1; |
|
173 |
gear^.Density:= _0_5; |
|
174 |
end; |
|
175 |
||
176 |
gtFlake: begin |
|
177 |
with Gear^ do |
|
178 |
begin |
|
179 |
Pos:= 0; |
|
180 |
Radius:= 1; |
|
7069 | 181 |
DirAngle:= random(360); |
6581 | 182 |
if State and gstTmpFlag = 0 then |
183 |
begin |
|
184 |
dx.isNegative:= GetRandom(2) = 0; |
|
7721 | 185 |
dx.QWordValue:= $40DA * GetRandom(10000) * 8; |
6581 | 186 |
dy.isNegative:= false; |
7721 | 187 |
dy.QWordValue:= $3AD3 * GetRandom(7000) * 8; |
6581 | 188 |
if GetRandom(2) = 0 then |
189 |
dx := -dx |
|
190 |
end; |
|
191 |
State:= State or gstInvisible; |
|
192 |
Health:= random(vobFrameTicks); |
|
193 |
Timer:= random(vobFramesCount); |
|
7649 | 194 |
Damage:= (random(2) * 2 - 1) * (vobVelocity + random(vobVelocity)) * 8; |
6581 | 195 |
end |
196 |
end; |
|
197 |
gtGrave: begin |
|
198 |
gear^.ImpactSound:= sndGraveImpact; |
|
199 |
gear^.nImpactSounds:= 1; |
|
200 |
gear^.Radius:= 10; |
|
201 |
gear^.Elasticity:= _0_6; |
|
202 |
end; |
|
203 |
gtBee: begin |
|
204 |
gear^.Radius:= 5; |
|
205 |
gear^.Timer:= 500; |
|
206 |
gear^.RenderTimer:= true; |
|
207 |
gear^.Elasticity:= _0_9; |
|
208 |
gear^.Tag:= 0; |
|
209 |
end; |
|
210 |
gtSeduction: begin |
|
211 |
gear^.Radius:= 250; |
|
212 |
end; |
|
213 |
gtShotgunShot: begin |
|
214 |
gear^.Timer:= 900; |
|
215 |
gear^.Radius:= 2 |
|
216 |
end; |
|
217 |
gtPickHammer: begin |
|
218 |
gear^.Radius:= 10; |
|
219 |
gear^.Timer:= 4000 |
|
220 |
end; |
|
221 |
gtHammerHit: begin |
|
222 |
gear^.Radius:= 8; |
|
223 |
gear^.Timer:= 125 |
|
224 |
end; |
|
225 |
gtRope: begin |
|
226 |
gear^.Radius:= 3; |
|
227 |
gear^.Friction:= _450 * _0_01 * cRopePercent; |
|
228 |
RopePoints.Count:= 0; |
|
229 |
end; |
|
230 |
gtMine: begin |
|
231 |
gear^.ImpactSound:= sndMineImpact; |
|
232 |
gear^.nImpactSounds:= 1; |
|
233 |
gear^.Health:= 10; |
|
234 |
gear^.State:= gear^.State or gstMoving; |
|
235 |
gear^.Radius:= 2; |
|
236 |
gear^.Elasticity:= _0_55; |
|
237 |
gear^.Friction:= _0_995; |
|
7602
a620319d377e
Fix throwing things off rope, also make throwing things a bit more generic and gear density dependent (so you can throw mines further, and also throw dynamite a little).
nemo
parents:
7395
diff
changeset
|
238 |
gear^.Density:= _1; |
6581 | 239 |
if cMinesTime < 0 then |
240 |
gear^.Timer:= getrandom(51)*100 |
|
241 |
else |
|
242 |
gear^.Timer:= cMinesTime; |
|
243 |
end; |
|
244 |
gtSMine: begin |
|
245 |
gear^.Health:= 10; |
|
246 |
gear^.State:= gear^.State or gstMoving; |
|
247 |
gear^.Radius:= 2; |
|
248 |
gear^.Elasticity:= _0_55; |
|
249 |
gear^.Friction:= _0_995; |
|
7602
a620319d377e
Fix throwing things off rope, also make throwing things a bit more generic and gear density dependent (so you can throw mines further, and also throw dynamite a little).
nemo
parents:
7395
diff
changeset
|
250 |
gear^.Density:= _1_6; |
6581 | 251 |
gear^.Timer:= 500; |
252 |
end; |
|
7733 | 253 |
gtKnife: begin |
254 |
gear^.Density:= _0_5; |
|
255 |
gear^.Radius:= 1; |
|
256 |
gear^.CollisionMask:= $FF00; |
|
257 |
end; |
|
6581 | 258 |
gtCase: begin |
259 |
gear^.ImpactSound:= sndGraveImpact; |
|
260 |
gear^.nImpactSounds:= 1; |
|
261 |
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
|
262 |
gear^.Elasticity:= _0_3; |
7276 | 263 |
gear^.Timer:= 500 |
6581 | 264 |
end; |
265 |
gtExplosives: begin |
|
266 |
gear^.ImpactSound:= sndGrenadeImpact; |
|
267 |
gear^.nImpactSounds:= 1; |
|
268 |
gear^.Radius:= 16; |
|
269 |
gear^.Elasticity:= _0_4; |
|
270 |
gear^.Friction:= _0_995; |
|
271 |
gear^.Density:= _6; |
|
272 |
gear^.Health:= cBarrelHealth; |
|
273 |
gear^.Z:= cHHZ-1 |
|
274 |
end; |
|
275 |
gtDEagleShot: begin |
|
276 |
gear^.Radius:= 1; |
|
277 |
gear^.Health:= 50 |
|
278 |
end; |
|
279 |
gtSniperRifleShot: begin |
|
280 |
gear^.Radius:= 1; |
|
281 |
gear^.Health:= 50 |
|
282 |
end; |
|
283 |
gtDynamite: begin |
|
284 |
gear^.Radius:= 3; |
|
285 |
gear^.Elasticity:= _0_55; |
|
286 |
gear^.Friction:= _0_03; |
|
287 |
gear^.Density:= _2; |
|
288 |
gear^.Timer:= 5000; |
|
289 |
end; |
|
290 |
gtCluster: begin |
|
291 |
gear^.Radius:= 2; |
|
292 |
gear^.Density:= _1_5; |
|
293 |
gear^.RenderTimer:= true |
|
294 |
end; |
|
295 |
gtShover: gear^.Radius:= 20; |
|
296 |
gtFlame: begin |
|
297 |
gear^.Tag:= GetRandom(32); |
|
298 |
gear^.Radius:= 1; |
|
299 |
gear^.Health:= 5; |
|
300 |
gear^.Density:= _1; |
|
301 |
if (gear^.dY.QWordValue = 0) and (gear^.dX.QWordValue = 0) then |
|
302 |
begin |
|
7001 | 303 |
gear^.dY:= (getrandomf - _0_8) * _0_03; |
304 |
gear^.dX:= (getrandomf - _0_5) * _0_4 |
|
6581 | 305 |
end |
306 |
end; |
|
307 |
gtFirePunch: begin |
|
308 |
gear^.Radius:= 15; |
|
309 |
gear^.Tag:= Y |
|
310 |
end; |
|
7364 | 311 |
gtAirAttack: gear^.Z:= cHHZ+2; |
6581 | 312 |
gtAirBomb: begin |
313 |
gear^.Radius:= 5; |
|
314 |
gear^.Density:= _2; |
|
315 |
end; |
|
316 |
gtBlowTorch: begin |
|
317 |
gear^.Radius:= cHHRadius + cBlowTorchC; |
|
318 |
gear^.Timer:= 7500 |
|
319 |
end; |
|
320 |
gtSwitcher: begin |
|
321 |
gear^.Z:= cCurrHHZ |
|
322 |
end; |
|
323 |
gtTarget: begin |
|
324 |
gear^.ImpactSound:= sndGrenadeImpact; |
|
325 |
gear^.nImpactSounds:= 1; |
|
326 |
gear^.Radius:= 10; |
|
327 |
gear^.Elasticity:= _0_3; |
|
328 |
gear^.Timer:= 0 |
|
329 |
end; |
|
330 |
gtTardis: begin |
|
331 |
gear^.Timer:= 0; |
|
332 |
gear^.Pos:= 1; |
|
333 |
gear^.Z:= cCurrHHZ+1; |
|
334 |
end; |
|
335 |
gtMortar: begin |
|
336 |
gear^.Radius:= 4; |
|
337 |
gear^.Elasticity:= _0_2; |
|
338 |
gear^.Friction:= _0_08; |
|
339 |
gear^.Density:= _1; |
|
340 |
end; |
|
341 |
gtWhip: gear^.Radius:= 20; |
|
342 |
gtHammer: gear^.Radius:= 20; |
|
343 |
gtKamikaze: begin |
|
344 |
gear^.Health:= 2048; |
|
345 |
gear^.Radius:= 20 |
|
346 |
end; |
|
347 |
gtCake: begin |
|
348 |
gear^.Health:= 2048; |
|
349 |
gear^.Radius:= 7; |
|
350 |
gear^.Z:= cOnHHZ; |
|
351 |
gear^.RenderTimer:= true; |
|
352 |
gear^.DirAngle:= -90 * hwSign(Gear^.dX); |
|
353 |
if not dX.isNegative then |
|
354 |
gear^.Angle:= 1 |
|
355 |
else |
|
356 |
gear^.Angle:= 3 |
|
357 |
end; |
|
358 |
gtHellishBomb: begin |
|
359 |
gear^.ImpactSound:= sndHellishImpact1; |
|
360 |
gear^.nImpactSounds:= 4; |
|
361 |
gear^.AdvBounce:= 1; |
|
362 |
gear^.Radius:= 4; |
|
363 |
gear^.Elasticity:= _0_5; |
|
364 |
gear^.Friction:= _0_96; |
|
365 |
gear^.Density:= _1_5; |
|
366 |
gear^.RenderTimer:= true; |
|
367 |
gear^.Timer:= 5000 |
|
368 |
end; |
|
369 |
gtDrill: begin |
|
370 |
if gear^.Timer = 0 then |
|
371 |
gear^.Timer:= 5000; |
|
372 |
// Tag for drill strike. if 1 then first impact occured already |
|
373 |
gear^.Tag := 0; |
|
374 |
gear^.Radius:= 4; |
|
375 |
gear^.Density:= _1; |
|
376 |
end; |
|
377 |
gtBall: begin |
|
378 |
gear^.ImpactSound:= sndGrenadeImpact; |
|
379 |
gear^.nImpactSounds:= 1; |
|
380 |
gear^.AdvBounce:= 1; |
|
381 |
gear^.Radius:= 5; |
|
382 |
gear^.Tag:= random(8); |
|
383 |
gear^.Timer:= 5000; |
|
384 |
gear^.Elasticity:= _0_7; |
|
385 |
gear^.Friction:= _0_995; |
|
386 |
gear^.Density:= _1_5; |
|
387 |
end; |
|
388 |
gtBallgun: begin |
|
389 |
gear^.Timer:= 5001; |
|
390 |
end; |
|
391 |
gtRCPlane: begin |
|
392 |
gear^.Timer:= 15000; |
|
393 |
gear^.Health:= 3; |
|
394 |
gear^.Radius:= 8 |
|
395 |
end; |
|
396 |
gtJetpack: begin |
|
397 |
gear^.Health:= 2000; |
|
398 |
gear^.Damage:= 100 |
|
399 |
end; |
|
400 |
gtMolotov: begin |
|
401 |
gear^.Radius:= 6; |
|
402 |
gear^.Density:= _2; |
|
403 |
end; |
|
404 |
gtBirdy: begin |
|
405 |
gear^.Radius:= 16; // todo: check |
|
406 |
gear^.Timer:= 0; |
|
407 |
gear^.Health := 2000; |
|
408 |
gear^.FlightTime := 2; |
|
409 |
end; |
|
410 |
gtEgg: begin |
|
411 |
gear^.Radius:= 4; |
|
412 |
gear^.Elasticity:= _0_6; |
|
413 |
gear^.Friction:= _0_96; |
|
414 |
gear^.Density:= _1; |
|
415 |
if gear^.Timer = 0 then |
|
416 |
gear^.Timer:= 3000 |
|
417 |
end; |
|
418 |
gtPortal: begin |
|
419 |
gear^.ImpactSound:= sndMelonImpact; |
|
420 |
gear^.nImpactSounds:= 1; |
|
421 |
gear^.AdvBounce:= 0; |
|
422 |
gear^.Radius:= 17; |
|
423 |
// set color |
|
424 |
gear^.Tag:= 2 * gear^.Timer; |
|
425 |
gear^.Timer:= 15000; |
|
426 |
gear^.RenderTimer:= false; |
|
427 |
gear^.Health:= 100; |
|
428 |
end; |
|
429 |
gtPiano: begin |
|
430 |
gear^.Radius:= 32; |
|
431 |
gear^.Density:= _50; |
|
432 |
end; |
|
433 |
gtSineGunShot: begin |
|
434 |
gear^.Radius:= 5; |
|
435 |
gear^.Health:= 6000; |
|
436 |
end; |
|
437 |
gtFlamethrower: begin |
|
438 |
gear^.Tag:= 10; |
|
439 |
gear^.Timer:= 10; |
|
440 |
gear^.Health:= 500; |
|
441 |
gear^.Damage:= 100; |
|
442 |
end; |
|
443 |
gtLandGun: begin |
|
444 |
gear^.Tag:= 10; |
|
445 |
gear^.Timer:= 10; |
|
446 |
gear^.Health:= 1000; |
|
447 |
gear^.Damage:= 100; |
|
448 |
end; |
|
449 |
gtPoisonCloud: begin |
|
450 |
gear^.Timer:= 5000; |
|
451 |
gear^.dY:= int2hwfloat(-4 + longint(getRandom(8))) / 1000; |
|
452 |
end; |
|
453 |
gtResurrector: begin |
|
454 |
gear^.Radius := 100; |
|
455 |
gear^.Tag := 0 |
|
456 |
end; |
|
457 |
gtWaterUp: begin |
|
458 |
gear^.Tag := 47; |
|
459 |
end; |
|
460 |
gtNapalmBomb: begin |
|
461 |
gear^.Timer:= 1000; |
|
462 |
gear^.Radius:= 5; |
|
463 |
gear^.Density:= _1_5; |
|
464 |
end; |
|
465 |
gtStructure: begin |
|
466 |
gear^.Elasticity:= _0_55; |
|
467 |
gear^.Friction:= _0_995; |
|
468 |
gear^.Density:= _0_9; |
|
469 |
gear^.Radius:= 13; |
|
470 |
gear^.Health:= 200; |
|
471 |
gear^.Timer:= 0; |
|
472 |
gear^.Tag:= TotalRounds + 3; |
|
473 |
gear^.Pos:= 1; |
|
474 |
end; |
|
7093 | 475 |
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
|
476 |
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
|
477 |
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
|
478 |
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
|
479 |
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
|
480 |
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
|
481 |
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
|
482 |
end; |
6581 | 483 |
end; |
484 |
||
485 |
InsertGearToList(gear); |
|
486 |
AddGear:= gear; |
|
487 |
||
488 |
ScriptCall('onGearAdd', gear^.uid); |
|
489 |
end; |
|
490 |
||
491 |
procedure DeleteGear(Gear: PGear); |
|
492 |
var team: PTeam; |
|
493 |
t,i: Longword; |
|
494 |
k: boolean; |
|
495 |
begin |
|
496 |
||
497 |
ScriptCall('onGearDelete', gear^.uid); |
|
498 |
||
499 |
DeleteCI(Gear); |
|
500 |
||
501 |
FreeTexture(Gear^.Tex); |
|
502 |
Gear^.Tex:= nil; |
|
503 |
||
504 |
// make sure that portals have their link removed before deletion |
|
505 |
if (Gear^.Kind = gtPortal) then |
|
506 |
begin |
|
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset
|
507 |
if (Gear^.LinkedGear <> nil) then |
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset
|
508 |
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
|
509 |
Gear^.LinkedGear^.LinkedGear:= nil; |
6581 | 510 |
end |
511 |
else if Gear^.Kind = gtHedgehog then |
|
512 |
(* |
|
513 |
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 |
|
514 |
if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then |
|
515 |
begin |
|
516 |
AttackBar:= 0; |
|
517 |
Gear^.Message:= gmDestroy; |
|
518 |
CurAmmoGear^.Message:= gmDestroy; |
|
519 |
exit |
|
520 |
end |
|
521 |
else*) |
|
522 |
begin |
|
6792
f72c8b5d421c
Ensure flawless is false if any hog is lost, unless it was lost doing a kamikaze
nemo
parents:
6700
diff
changeset
|
523 |
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
|
524 |
Gear^.Hedgehog^.Team^.Clan^.Flawless:= false; |
6581 | 525 |
if (hwRound(Gear^.Y) >= cWaterLine) then |
526 |
begin |
|
527 |
t:= max(Gear^.Damage, Gear^.Health); |
|
528 |
Gear^.Damage:= t; |
|
6982 | 529 |
if ((not SuddenDeathDmg and (WaterOpacity < $FF)) or (SuddenDeathDmg and (WaterOpacity < $FF))) |
6581 | 530 |
and (hwRound(Gear^.Y) < cWaterLine + 256) then |
531 |
spawnHealthTagForHH(Gear, t); |
|
532 |
end; |
|
533 |
||
534 |
team:= Gear^.Hedgehog^.Team; |
|
535 |
if CurrentHedgehog^.Gear = Gear then |
|
536 |
begin |
|
537 |
AttackBar:= 0; |
|
538 |
FreeActionsList; // to avoid ThinkThread on drawned gear |
|
539 |
if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) |
|
540 |
and (CurrentHedgehog^.MultiShootAttacks > 0) then |
|
541 |
OnUsedAmmo(CurrentHedgehog^); |
|
542 |
end; |
|
543 |
||
544 |
Gear^.Hedgehog^.Gear:= nil; |
|
545 |
if Gear^.Hedgehog^.King then |
|
546 |
begin |
|
547 |
// are there any other kings left? Just doing nil check. Presumably a mortally wounded king will get reaped soon enough |
|
548 |
k:= false; |
|
549 |
for i:= 0 to Pred(team^.Clan^.TeamsNumber) do |
|
550 |
if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then |
|
551 |
k:= true; |
|
552 |
if not k then |
|
553 |
for i:= 0 to Pred(team^.Clan^.TeamsNumber) do |
|
554 |
begin |
|
555 |
team^.Clan^.Teams[i]^.hasGone:= true; |
|
556 |
TeamGoneEffect(team^.Clan^.Teams[i]^) |
|
557 |
end |
|
558 |
end; |
|
559 |
||
560 |
// should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog |
|
561 |
// same stand for CheckHHDamage |
|
562 |
if (Gear^.LastDamage <> nil) then |
|
563 |
uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true) |
|
564 |
else |
|
565 |
uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true); |
|
566 |
||
567 |
inc(KilledHHs); |
|
568 |
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
|
569 |
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
|
570 |
//(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then |
fb4b0c6dfdbd
Make watching AI v AI on ai survival a bit more entertaining
nemo
parents:
7168
diff
changeset
|
571 |
(Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan) then |
6581 | 572 |
with CurrentHedgehog^ do |
573 |
begin |
|
574 |
inc(Team^.stats.AIKills); |
|
575 |
FreeTexture(Team^.AIKillsTex); |
|
576 |
Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); |
|
577 |
end |
|
578 |
end; |
|
579 |
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
|
580 |
begin |
6581 | 581 |
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
|
582 |
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
|
583 |
end; |
6581 | 584 |
if CurAmmoGear = Gear then |
585 |
CurAmmoGear:= nil; |
|
586 |
if FollowGear = Gear then |
|
587 |
FollowGear:= nil; |
|
588 |
if lastGearByUID = Gear then |
|
589 |
lastGearByUID := nil; |
|
590 |
RemoveGearFromList(Gear); |
|
591 |
Dispose(Gear) |
|
592 |
end; |
|
593 |
||
594 |
end. |