author | nemo |
Sat, 03 Nov 2012 10:18:44 -0400 | |
branch | 0.9.18 |
changeset 7937 | fb17218d891c |
parent 7754 | e81dc9bef8b8 |
child 8026 | 4a4f21070479 |
child 8145 | 6408c0ba4ba1 |
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 |
7754 | 254 |
gear^.Density:= _4; |
255 |
gear^.Radius:= 16 |
|
7733 | 256 |
end; |
6581 | 257 |
gtCase: begin |
258 |
gear^.ImpactSound:= sndGraveImpact; |
|
259 |
gear^.nImpactSounds:= 1; |
|
260 |
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
|
261 |
gear^.Elasticity:= _0_3; |
7276 | 262 |
gear^.Timer:= 500 |
6581 | 263 |
end; |
264 |
gtExplosives: begin |
|
265 |
gear^.ImpactSound:= sndGrenadeImpact; |
|
266 |
gear^.nImpactSounds:= 1; |
|
267 |
gear^.Radius:= 16; |
|
268 |
gear^.Elasticity:= _0_4; |
|
269 |
gear^.Friction:= _0_995; |
|
270 |
gear^.Density:= _6; |
|
271 |
gear^.Health:= cBarrelHealth; |
|
272 |
gear^.Z:= cHHZ-1 |
|
273 |
end; |
|
274 |
gtDEagleShot: begin |
|
275 |
gear^.Radius:= 1; |
|
276 |
gear^.Health:= 50 |
|
277 |
end; |
|
278 |
gtSniperRifleShot: begin |
|
279 |
gear^.Radius:= 1; |
|
280 |
gear^.Health:= 50 |
|
281 |
end; |
|
282 |
gtDynamite: begin |
|
283 |
gear^.Radius:= 3; |
|
284 |
gear^.Elasticity:= _0_55; |
|
285 |
gear^.Friction:= _0_03; |
|
286 |
gear^.Density:= _2; |
|
287 |
gear^.Timer:= 5000; |
|
288 |
end; |
|
289 |
gtCluster: begin |
|
290 |
gear^.Radius:= 2; |
|
291 |
gear^.Density:= _1_5; |
|
292 |
gear^.RenderTimer:= true |
|
293 |
end; |
|
294 |
gtShover: gear^.Radius:= 20; |
|
295 |
gtFlame: begin |
|
296 |
gear^.Tag:= GetRandom(32); |
|
297 |
gear^.Radius:= 1; |
|
298 |
gear^.Health:= 5; |
|
299 |
gear^.Density:= _1; |
|
300 |
if (gear^.dY.QWordValue = 0) and (gear^.dX.QWordValue = 0) then |
|
301 |
begin |
|
7001 | 302 |
gear^.dY:= (getrandomf - _0_8) * _0_03; |
303 |
gear^.dX:= (getrandomf - _0_5) * _0_4 |
|
6581 | 304 |
end |
305 |
end; |
|
306 |
gtFirePunch: begin |
|
307 |
gear^.Radius:= 15; |
|
308 |
gear^.Tag:= Y |
|
309 |
end; |
|
7364 | 310 |
gtAirAttack: gear^.Z:= cHHZ+2; |
6581 | 311 |
gtAirBomb: begin |
312 |
gear^.Radius:= 5; |
|
313 |
gear^.Density:= _2; |
|
314 |
end; |
|
315 |
gtBlowTorch: begin |
|
316 |
gear^.Radius:= cHHRadius + cBlowTorchC; |
|
317 |
gear^.Timer:= 7500 |
|
318 |
end; |
|
319 |
gtSwitcher: begin |
|
320 |
gear^.Z:= cCurrHHZ |
|
321 |
end; |
|
322 |
gtTarget: begin |
|
323 |
gear^.ImpactSound:= sndGrenadeImpact; |
|
324 |
gear^.nImpactSounds:= 1; |
|
325 |
gear^.Radius:= 10; |
|
326 |
gear^.Elasticity:= _0_3; |
|
327 |
gear^.Timer:= 0 |
|
328 |
end; |
|
329 |
gtTardis: begin |
|
330 |
gear^.Timer:= 0; |
|
331 |
gear^.Pos:= 1; |
|
332 |
gear^.Z:= cCurrHHZ+1; |
|
333 |
end; |
|
334 |
gtMortar: begin |
|
335 |
gear^.Radius:= 4; |
|
336 |
gear^.Elasticity:= _0_2; |
|
337 |
gear^.Friction:= _0_08; |
|
338 |
gear^.Density:= _1; |
|
339 |
end; |
|
340 |
gtWhip: gear^.Radius:= 20; |
|
341 |
gtHammer: gear^.Radius:= 20; |
|
342 |
gtKamikaze: begin |
|
343 |
gear^.Health:= 2048; |
|
344 |
gear^.Radius:= 20 |
|
345 |
end; |
|
346 |
gtCake: begin |
|
347 |
gear^.Health:= 2048; |
|
348 |
gear^.Radius:= 7; |
|
349 |
gear^.Z:= cOnHHZ; |
|
350 |
gear^.RenderTimer:= true; |
|
351 |
gear^.DirAngle:= -90 * hwSign(Gear^.dX); |
|
352 |
if not dX.isNegative then |
|
353 |
gear^.Angle:= 1 |
|
354 |
else |
|
355 |
gear^.Angle:= 3 |
|
356 |
end; |
|
357 |
gtHellishBomb: begin |
|
358 |
gear^.ImpactSound:= sndHellishImpact1; |
|
359 |
gear^.nImpactSounds:= 4; |
|
360 |
gear^.AdvBounce:= 1; |
|
361 |
gear^.Radius:= 4; |
|
362 |
gear^.Elasticity:= _0_5; |
|
363 |
gear^.Friction:= _0_96; |
|
364 |
gear^.Density:= _1_5; |
|
365 |
gear^.RenderTimer:= true; |
|
366 |
gear^.Timer:= 5000 |
|
367 |
end; |
|
368 |
gtDrill: begin |
|
369 |
if gear^.Timer = 0 then |
|
370 |
gear^.Timer:= 5000; |
|
371 |
// Tag for drill strike. if 1 then first impact occured already |
|
372 |
gear^.Tag := 0; |
|
373 |
gear^.Radius:= 4; |
|
374 |
gear^.Density:= _1; |
|
375 |
end; |
|
376 |
gtBall: begin |
|
377 |
gear^.ImpactSound:= sndGrenadeImpact; |
|
378 |
gear^.nImpactSounds:= 1; |
|
379 |
gear^.AdvBounce:= 1; |
|
380 |
gear^.Radius:= 5; |
|
381 |
gear^.Tag:= random(8); |
|
382 |
gear^.Timer:= 5000; |
|
383 |
gear^.Elasticity:= _0_7; |
|
384 |
gear^.Friction:= _0_995; |
|
385 |
gear^.Density:= _1_5; |
|
386 |
end; |
|
387 |
gtBallgun: begin |
|
388 |
gear^.Timer:= 5001; |
|
389 |
end; |
|
390 |
gtRCPlane: begin |
|
391 |
gear^.Timer:= 15000; |
|
392 |
gear^.Health:= 3; |
|
393 |
gear^.Radius:= 8 |
|
394 |
end; |
|
395 |
gtJetpack: begin |
|
396 |
gear^.Health:= 2000; |
|
397 |
gear^.Damage:= 100 |
|
398 |
end; |
|
399 |
gtMolotov: begin |
|
400 |
gear^.Radius:= 6; |
|
401 |
gear^.Density:= _2; |
|
402 |
end; |
|
403 |
gtBirdy: begin |
|
404 |
gear^.Radius:= 16; // todo: check |
|
405 |
gear^.Timer:= 0; |
|
406 |
gear^.Health := 2000; |
|
407 |
gear^.FlightTime := 2; |
|
408 |
end; |
|
409 |
gtEgg: begin |
|
410 |
gear^.Radius:= 4; |
|
411 |
gear^.Elasticity:= _0_6; |
|
412 |
gear^.Friction:= _0_96; |
|
413 |
gear^.Density:= _1; |
|
414 |
if gear^.Timer = 0 then |
|
415 |
gear^.Timer:= 3000 |
|
416 |
end; |
|
417 |
gtPortal: begin |
|
418 |
gear^.ImpactSound:= sndMelonImpact; |
|
419 |
gear^.nImpactSounds:= 1; |
|
420 |
gear^.AdvBounce:= 0; |
|
421 |
gear^.Radius:= 17; |
|
422 |
// set color |
|
423 |
gear^.Tag:= 2 * gear^.Timer; |
|
424 |
gear^.Timer:= 15000; |
|
425 |
gear^.RenderTimer:= false; |
|
426 |
gear^.Health:= 100; |
|
427 |
end; |
|
428 |
gtPiano: begin |
|
429 |
gear^.Radius:= 32; |
|
430 |
gear^.Density:= _50; |
|
431 |
end; |
|
432 |
gtSineGunShot: begin |
|
433 |
gear^.Radius:= 5; |
|
434 |
gear^.Health:= 6000; |
|
435 |
end; |
|
436 |
gtFlamethrower: begin |
|
437 |
gear^.Tag:= 10; |
|
438 |
gear^.Timer:= 10; |
|
439 |
gear^.Health:= 500; |
|
440 |
gear^.Damage:= 100; |
|
441 |
end; |
|
442 |
gtLandGun: begin |
|
443 |
gear^.Tag:= 10; |
|
444 |
gear^.Timer:= 10; |
|
445 |
gear^.Health:= 1000; |
|
446 |
gear^.Damage:= 100; |
|
447 |
end; |
|
448 |
gtPoisonCloud: begin |
|
449 |
gear^.Timer:= 5000; |
|
450 |
gear^.dY:= int2hwfloat(-4 + longint(getRandom(8))) / 1000; |
|
451 |
end; |
|
452 |
gtResurrector: begin |
|
453 |
gear^.Radius := 100; |
|
454 |
gear^.Tag := 0 |
|
455 |
end; |
|
456 |
gtWaterUp: begin |
|
457 |
gear^.Tag := 47; |
|
458 |
end; |
|
459 |
gtNapalmBomb: begin |
|
460 |
gear^.Timer:= 1000; |
|
461 |
gear^.Radius:= 5; |
|
462 |
gear^.Density:= _1_5; |
|
463 |
end; |
|
464 |
gtStructure: begin |
|
465 |
gear^.Elasticity:= _0_55; |
|
466 |
gear^.Friction:= _0_995; |
|
467 |
gear^.Density:= _0_9; |
|
468 |
gear^.Radius:= 13; |
|
469 |
gear^.Health:= 200; |
|
470 |
gear^.Timer:= 0; |
|
471 |
gear^.Tag:= TotalRounds + 3; |
|
472 |
gear^.Pos:= 1; |
|
473 |
end; |
|
7093 | 474 |
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
|
475 |
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
|
476 |
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
|
477 |
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
|
478 |
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
|
479 |
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
|
480 |
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
|
481 |
end; |
6581 | 482 |
end; |
483 |
||
484 |
InsertGearToList(gear); |
|
485 |
AddGear:= gear; |
|
486 |
||
487 |
ScriptCall('onGearAdd', gear^.uid); |
|
488 |
end; |
|
489 |
||
490 |
procedure DeleteGear(Gear: PGear); |
|
491 |
var team: PTeam; |
|
492 |
t,i: Longword; |
|
493 |
k: boolean; |
|
494 |
begin |
|
495 |
||
496 |
ScriptCall('onGearDelete', gear^.uid); |
|
497 |
||
498 |
DeleteCI(Gear); |
|
499 |
||
500 |
FreeTexture(Gear^.Tex); |
|
501 |
Gear^.Tex:= nil; |
|
502 |
||
503 |
// make sure that portals have their link removed before deletion |
|
504 |
if (Gear^.Kind = gtPortal) then |
|
505 |
begin |
|
7272
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset
|
506 |
if (Gear^.LinkedGear <> nil) then |
71df899c4163
Second part of the change. Make collision check use the new mask bit.
nemo
parents:
7176
diff
changeset
|
507 |
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
|
508 |
Gear^.LinkedGear^.LinkedGear:= nil; |
6581 | 509 |
end |
510 |
else if Gear^.Kind = gtHedgehog then |
|
511 |
(* |
|
512 |
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 |
|
513 |
if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then |
|
514 |
begin |
|
515 |
AttackBar:= 0; |
|
516 |
Gear^.Message:= gmDestroy; |
|
517 |
CurAmmoGear^.Message:= gmDestroy; |
|
518 |
exit |
|
519 |
end |
|
520 |
else*) |
|
521 |
begin |
|
6792
f72c8b5d421c
Ensure flawless is false if any hog is lost, unless it was lost doing a kamikaze
nemo
parents:
6700
diff
changeset
|
522 |
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
|
523 |
Gear^.Hedgehog^.Team^.Clan^.Flawless:= false; |
6581 | 524 |
if (hwRound(Gear^.Y) >= cWaterLine) then |
525 |
begin |
|
526 |
t:= max(Gear^.Damage, Gear^.Health); |
|
527 |
Gear^.Damage:= t; |
|
6982 | 528 |
if ((not SuddenDeathDmg and (WaterOpacity < $FF)) or (SuddenDeathDmg and (WaterOpacity < $FF))) |
6581 | 529 |
and (hwRound(Gear^.Y) < cWaterLine + 256) then |
530 |
spawnHealthTagForHH(Gear, t); |
|
531 |
end; |
|
532 |
||
533 |
team:= Gear^.Hedgehog^.Team; |
|
534 |
if CurrentHedgehog^.Gear = Gear then |
|
535 |
begin |
|
536 |
AttackBar:= 0; |
|
537 |
FreeActionsList; // to avoid ThinkThread on drawned gear |
|
538 |
if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) |
|
539 |
and (CurrentHedgehog^.MultiShootAttacks > 0) then |
|
540 |
OnUsedAmmo(CurrentHedgehog^); |
|
541 |
end; |
|
542 |
||
543 |
Gear^.Hedgehog^.Gear:= nil; |
|
544 |
if Gear^.Hedgehog^.King then |
|
545 |
begin |
|
546 |
// are there any other kings left? Just doing nil check. Presumably a mortally wounded king will get reaped soon enough |
|
547 |
k:= false; |
|
548 |
for i:= 0 to Pred(team^.Clan^.TeamsNumber) do |
|
549 |
if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then |
|
550 |
k:= true; |
|
551 |
if not k then |
|
552 |
for i:= 0 to Pred(team^.Clan^.TeamsNumber) do |
|
553 |
begin |
|
554 |
team^.Clan^.Teams[i]^.hasGone:= true; |
|
555 |
TeamGoneEffect(team^.Clan^.Teams[i]^) |
|
556 |
end |
|
557 |
end; |
|
558 |
||
559 |
// should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog |
|
560 |
// same stand for CheckHHDamage |
|
561 |
if (Gear^.LastDamage <> nil) then |
|
562 |
uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true) |
|
563 |
else |
|
564 |
uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true); |
|
565 |
||
566 |
inc(KilledHHs); |
|
567 |
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
|
568 |
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
|
569 |
//(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then |
fb4b0c6dfdbd
Make watching AI v AI on ai survival a bit more entertaining
nemo
parents:
7168
diff
changeset
|
570 |
(Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan) then |
6581 | 571 |
with CurrentHedgehog^ do |
572 |
begin |
|
573 |
inc(Team^.stats.AIKills); |
|
574 |
FreeTexture(Team^.AIKillsTex); |
|
575 |
Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); |
|
576 |
end |
|
577 |
end; |
|
578 |
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
|
579 |
begin |
6581 | 580 |
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
|
581 |
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
|
582 |
end; |
6581 | 583 |
if CurAmmoGear = Gear then |
584 |
CurAmmoGear:= nil; |
|
585 |
if FollowGear = Gear then |
|
586 |
FollowGear:= nil; |
|
587 |
if lastGearByUID = Gear then |
|
588 |
lastGearByUID := nil; |
|
589 |
RemoveGearFromList(Gear); |
|
590 |
Dispose(Gear) |
|
591 |
end; |
|
592 |
||
593 |
end. |