author | unc0rr |
Sun, 17 Dec 2006 17:55:41 +0000 | |
changeset 302 | 7aca131ecd7f |
parent 300 | be94799f33d2 |
child 303 | 1659c4aad5ab |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
79 | 3 |
* Copyright (c) 2004, 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 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 |
|
4 | 8 |
* |
183 | 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. |
|
4 | 13 |
* |
183 | 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 |
|
4 | 17 |
*) |
18 |
||
19 |
procedure doStepDrowningGear(Gear: PGear); forward; |
|
20 |
||
21 |
function CheckGearDrowning(Gear: PGear): boolean; |
|
22 |
begin |
|
53 | 23 |
Result:= Gear.Y + Gear.Radius >= cWaterLine; |
4 | 24 |
if Result then |
25 |
begin |
|
26 |
Gear.State:= gstDrowning; |
|
27 |
Gear.doStep:= doStepDrowningGear; |
|
28 |
PlaySound(sndSplash) |
|
29 |
end |
|
30 |
end; |
|
31 |
||
32 |
procedure CheckCollision(Gear: PGear); |
|
33 |
begin |
|
108 | 34 |
if TestCollisionXwithGear(Gear, hwSign(Gear.X)) or TestCollisionYwithGear(Gear, hwSign(Gear.Y)) |
4 | 35 |
then Gear.State:= Gear.State or gstCollision |
36 |
else Gear.State:= Gear.State and not gstCollision |
|
37 |
end; |
|
38 |
||
39 |
procedure CheckHHDamage(Gear: PGear); |
|
40 |
begin |
|
71 | 41 |
if Gear.dY > 0.40 then Gear.Damage:= Gear.Damage + 1 + round(70 * (abs(Gear.dY) - 0.40)); |
4 | 42 |
end; |
43 |
||
44 |
//////////////////////////////////////////////////////////////////////////////// |
|
45 |
//////////////////////////////////////////////////////////////////////////////// |
|
46 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
107 | 47 |
var dAngle: Double; |
4 | 48 |
begin |
49 |
dAngle:= (abs(Gear.dX) + abs(Gear.dY))*0.1; |
|
50 |
if Gear.dX >= 0 then Gear.DirAngle:= Gear.DirAngle + dAngle |
|
51 |
else Gear.DirAngle:= Gear.DirAngle - dAngle; |
|
52 |
if Gear.DirAngle < 0 then Gear.DirAngle:= Gear.DirAngle + 16 |
|
53 |
else if Gear.DirAngle >= 16 then Gear.DirAngle:= Gear.DirAngle - 16 |
|
54 |
end; |
|
55 |
||
56 |
//////////////////////////////////////////////////////////////////////////////// |
|
57 |
procedure doStepDrowningGear(Gear: PGear); |
|
58 |
begin |
|
59 |
AllInactive:= false; |
|
60 |
Gear.Y:= Gear.Y + cDrownSpeed; |
|
75 | 61 |
if round(Gear.Y) > Gear.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear) |
4 | 62 |
end; |
63 |
||
64 |
//////////////////////////////////////////////////////////////////////////////// |
|
65 |
procedure doStepFallingGear(Gear: PGear); |
|
66 |
var b: boolean; |
|
67 |
begin |
|
108 | 68 |
if TestCollisionYwithGear(Gear, hwSign(Gear.dY)) then |
4 | 69 |
begin |
70 |
Gear.dX:= Gear.dX * Gear.Friction; |
|
71 |
Gear.dY:= - Gear.dY * Gear.Elasticity; |
|
72 |
b:= false |
|
73 |
end else b:= true; |
|
108 | 74 |
if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then |
4 | 75 |
begin |
76 |
Gear.dX:= - Gear.dX * Gear.Elasticity; |
|
77 |
// Gear.dY:= Gear.dY; |
|
78 |
b:= false |
|
79 |
end; |
|
80 |
if b then |
|
81 |
begin |
|
82 |
Gear.dY:= Gear.dY + cGravity; |
|
83 |
Gear.State:= Gear.State and not gstCollision |
|
84 |
end else |
|
85 |
begin |
|
86 |
if sqr(Gear.dX) + sqr(Gear.dY) < 0.00001 then |
|
87 |
if (Gear.Timer = 0) then Gear.Active:= false |
|
88 |
else begin |
|
89 |
Gear.dX:= 0; |
|
90 |
Gear.dY:= 0 |
|
91 |
end; |
|
92 |
Gear.State:= Gear.State or gstCollision |
|
93 |
end; |
|
94 |
Gear.X:= Gear.X + Gear.dX; |
|
95 |
Gear.Y:= Gear.Y + Gear.dY; |
|
96 |
CheckGearDrowning(Gear); |
|
97 |
if (sqr(Gear.dX) + sqr(Gear.dY) < 0.003) then Gear.State:= Gear.State and not gstMoving |
|
98 |
else Gear.State:= Gear.State or gstMoving |
|
99 |
end; |
|
100 |
||
101 |
//////////////////////////////////////////////////////////////////////////////// |
|
102 |
procedure doStepCloud(Gear: PGear); |
|
103 |
begin |
|
104 |
Gear.X:= Gear.X + cWindSpeed * 200 + Gear.dX; |
|
74 | 105 |
if Gear.Y > -160 then Gear.dY:= Gear.dY - 0.00002 |
106 |
else Gear.dY:= Gear.dY + 0.00002; |
|
107 |
Gear.Y:= Gear.Y + Gear.dY; |
|
108 |
if Gear.X < -cScreenWidth - 256 then Gear.X:= cScreenWidth + 2048 else |
|
4 | 109 |
if Gear.X > cScreenWidth + 2048 then Gear.X:= -cScreenWidth - 256 |
110 |
end; |
|
111 |
||
112 |
//////////////////////////////////////////////////////////////////////////////// |
|
113 |
procedure doStepBomb(Gear: PGear); |
|
78 | 114 |
var i: integer; |
4 | 115 |
begin |
116 |
AllInactive:= false; |
|
117 |
doStepFallingGear(Gear); |
|
118 |
dec(Gear.Timer); |
|
119 |
if Gear.Timer = 0 then |
|
120 |
begin |
|
78 | 121 |
case Gear.Kind of |
122 |
gtAmmo_Bomb: doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound); |
|
123 |
gtClusterBomb: begin |
|
124 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound); |
|
125 |
for i:= 0 to 4 do |
|
79 | 126 |
AddGear(round(Gear.X), round(Gear.Y), gtCluster, 0, (getrandom - 0.5)*0.2, (getrandom - 3) * 0.08); |
78 | 127 |
end |
128 |
end; |
|
4 | 129 |
DeleteGear(Gear); |
130 |
exit |
|
131 |
end; |
|
132 |
CalcRotationDirAngle(Gear); |
|
133 |
if (Gear.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then PlaySound(sndGrenadeImpact) |
|
134 |
end; |
|
135 |
||
78 | 136 |
procedure doStepCluster(Gear: PGear); |
137 |
begin |
|
138 |
AllInactive:= false; |
|
139 |
doStepFallingGear(Gear); |
|
140 |
if (Gear.State and gstCollision) <> 0 then |
|
141 |
begin |
|
142 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 20, EXPLAutoSound); |
|
143 |
DeleteGear(Gear); |
|
144 |
exit |
|
145 |
end; |
|
146 |
if (GameTicks and $1F) = 0 then |
|
147 |
AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0) |
|
148 |
end; |
|
149 |
||
4 | 150 |
//////////////////////////////////////////////////////////////////////////////// |
151 |
procedure doStepGrenade(Gear: PGear); |
|
152 |
begin |
|
153 |
AllInactive:= false; |
|
154 |
Gear.dX:= Gear.dX + cWindSpeed; |
|
155 |
doStepFallingGear(Gear); |
|
156 |
if (Gear.State and gstCollision) <> 0 then |
|
157 |
begin |
|
158 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound); |
|
159 |
DeleteGear(Gear); |
|
160 |
exit |
|
161 |
end; |
|
162 |
if (GameTicks and $3F) = 0 then |
|
163 |
AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0) |
|
164 |
end; |
|
165 |
||
166 |
//////////////////////////////////////////////////////////////////////////////// |
|
95 | 167 |
procedure doStepHealthTagWork(Gear: PGear); |
4 | 168 |
begin |
169 |
AllInactive:= false; |
|
170 |
dec(Gear.Timer); |
|
171 |
Gear.Y:= Gear.Y - 0.07; |
|
172 |
if Gear.Timer = 0 then |
|
173 |
begin |
|
263 | 174 |
PHedgehog(Gear.Hedgehog).Gear.Active:= true; // to let current hh die |
4 | 175 |
DeleteGear(Gear) |
176 |
end |
|
177 |
end; |
|
178 |
||
263 | 179 |
procedure doStepHealthTagWorkUnderWater(Gear: PGear); |
180 |
begin |
|
181 |
AllInactive:= false; |
|
182 |
Gear.Y:= Gear.Y - 0.07; |
|
183 |
if Gear.Y <= cWaterLine + 10 then |
|
184 |
DeleteGear(Gear) |
|
185 |
end; |
|
186 |
||
95 | 187 |
procedure doStepHealthTag(Gear: PGear); |
188 |
var s: shortstring; |
|
189 |
begin |
|
190 |
AllInactive:= false; |
|
191 |
str(Gear.State, s); |
|
192 |
Gear.Surf:= RenderString(s, PHedgehog(Gear.Hedgehog).Team.Color, fnt16); |
|
263 | 193 |
if Gear.Y < cWaterLine then Gear.doStep:= doStepHealthTagWork |
194 |
else Gear.doStep:= doStepHealthTagWorkUnderWater |
|
95 | 195 |
end; |
196 |
||
4 | 197 |
//////////////////////////////////////////////////////////////////////////////// |
198 |
procedure doStepGrave(Gear: PGear); |
|
199 |
begin |
|
200 |
AllInactive:= false; |
|
201 |
if Gear.dY < 0 then |
|
68 | 202 |
if TestCollisionY(Gear, -1) then Gear.dY:= 0; |
4 | 203 |
|
204 |
if Gear.dY >=0 then |
|
68 | 205 |
if TestCollisionY(Gear, 1) then |
4 | 206 |
begin |
207 |
Gear.dY:= - Gear.dY * Gear.Elasticity; |
|
208 |
if Gear.dY > - 0.001 then |
|
209 |
begin |
|
210 |
Gear.Active:= false; |
|
211 |
exit |
|
212 |
end else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact) |
|
213 |
end; |
|
214 |
Gear.Y:= Gear.Y + Gear.dY; |
|
215 |
CheckGearDrowning(Gear); |
|
216 |
Gear.dY:= Gear.dY + cGravity |
|
217 |
end; |
|
218 |
||
219 |
//////////////////////////////////////////////////////////////////////////////// |
|
220 |
procedure doStepUFOWork(Gear: PGear); |
|
107 | 221 |
var t: Double; |
4 | 222 |
begin |
223 |
AllInactive:= false; |
|
224 |
t:= sqrt(sqr(Gear.dX) + sqr(Gear.dY)); |
|
225 |
Gear.dX:= Gear.Elasticity * (Gear.dX + 0.000004 * (TargetPoint.X - trunc(Gear.X))); |
|
226 |
Gear.dY:= Gear.Elasticity * (Gear.dY + 0.000004 * (TargetPoint.Y - trunc(Gear.Y))); |
|
227 |
t:= t / (sqrt(sqr(Gear.dX) + sqr(Gear.dY))); |
|
228 |
Gear.dX:= Gear.dX * t; |
|
229 |
Gear.dY:= Gear.dY * t; |
|
230 |
Gear.X:= Gear.X + Gear.dX; |
|
231 |
Gear.Y:= Gear.Y + Gear.dY; |
|
232 |
CheckCollision(Gear); |
|
233 |
dec(Gear.Timer); |
|
234 |
if ((Gear.State and gstCollision) <> 0) or (Gear.Timer = 0) then |
|
235 |
begin |
|
236 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound); |
|
237 |
DeleteGear(Gear); |
|
238 |
end; |
|
239 |
end; |
|
240 |
||
241 |
procedure doStepUFO(Gear: PGear); |
|
242 |
begin |
|
243 |
AllInactive:= false; |
|
244 |
Gear.X:= Gear.X + Gear.dX; |
|
245 |
Gear.Y:= Gear.Y + Gear.dY; |
|
246 |
Gear.dY:= Gear.dY + cGravity; |
|
247 |
CheckCollision(Gear); |
|
248 |
if (Gear.State and gstCollision) <> 0 then |
|
249 |
begin |
|
250 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound); |
|
251 |
DeleteGear(Gear); |
|
252 |
exit |
|
253 |
end; |
|
254 |
dec(Gear.Timer); |
|
255 |
if Gear.Timer = 0 then |
|
256 |
begin |
|
257 |
Gear.Timer:= 5000; |
|
258 |
Gear.doStep:= doStepUFOWork |
|
259 |
end; |
|
260 |
end; |
|
261 |
||
262 |
//////////////////////////////////////////////////////////////////////////////// |
|
263 |
procedure doStepShotgunShot(Gear: PGear); |
|
264 |
var i: LongWord; |
|
265 |
begin |
|
266 |
AllInactive:= false; |
|
267 |
if Gear.Timer > 0 then |
|
268 |
begin |
|
269 |
dec(Gear.Timer); |
|
95 | 270 |
if Gear.Timer = 0 then PlaySound(sndShotgunFire); |
4 | 271 |
exit |
272 |
end; |
|
273 |
i:= 200; |
|
274 |
repeat |
|
275 |
Gear.X:= Gear.X + Gear.dX; |
|
276 |
Gear.Y:= Gear.Y + Gear.dY; |
|
277 |
CheckCollision(Gear); |
|
278 |
if (Gear.State and gstCollision) <> 0 then |
|
279 |
begin |
|
75 | 280 |
AmmoShove(Gear, 25, 25); |
42 | 281 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 25, EXPLNoDamage or EXPLDoNotTouchHH); |
4 | 282 |
DeleteGear(Gear); |
75 | 283 |
AfterAttack; |
4 | 284 |
exit |
285 |
end; |
|
286 |
dec(i) |
|
287 |
until i = 0; |
|
288 |
if (Gear.X < 0) or (Gear.Y < 0) or (Gear.X > 2048) or (Gear.Y > 1024) then |
|
95 | 289 |
begin |
290 |
DeleteGear(Gear); |
|
291 |
AfterAttack |
|
292 |
end |
|
4 | 293 |
end; |
294 |
||
295 |
//////////////////////////////////////////////////////////////////////////////// |
|
38 | 296 |
procedure doStepDEagleShot(Gear: PGear); |
297 |
var i, x, y: LongWord; |
|
107 | 298 |
oX, oY: Double; |
38 | 299 |
begin |
300 |
AllInactive:= false; |
|
37 | 301 |
i:= 80; |
38 | 302 |
oX:= Gear.X; |
303 |
oY:= Gear.Y; |
|
37 | 304 |
repeat |
38 | 305 |
Gear.X:= Gear.X + Gear.dX; |
306 |
Gear.Y:= Gear.Y + Gear.dY; |
|
307 |
x:= round(Gear.X); |
|
308 |
y:= round(Gear.Y); |
|
309 |
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0) |
|
310 |
and (Land[y, x] <> 0) then inc(Gear.Damage); |
|
75 | 311 |
AmmoShove(Gear, 7, 20); |
38 | 312 |
dec(i) |
313 |
until (i = 0) or (Gear.Damage > Gear.Health); |
|
314 |
if Gear.Damage > 0 then |
|
37 | 315 |
begin |
38 | 316 |
DrawTunnel(oX, oY, Gear.dX, Gear.dY, 82 - i, 1); |
317 |
dec(Gear.Health, Gear.Damage); |
|
318 |
Gear.Damage:= 0 |
|
37 | 319 |
end; |
38 | 320 |
if (Gear.Health <= 0) or (Gear.X < 0) or (Gear.Y < 0) or (Gear.X > 2048) or (Gear.Y > 1024) then |
37 | 321 |
DeleteGear(Gear) |
322 |
end; |
|
323 |
||
324 |
//////////////////////////////////////////////////////////////////////////////// |
|
4 | 325 |
procedure doStepActionTimer(Gear: PGear); |
326 |
begin |
|
83 | 327 |
dec(Gear.Timer); |
328 |
case Gear.Kind of |
|
329 |
gtATStartGame: begin |
|
4 | 330 |
AllInactive:= false; |
83 | 331 |
if Gear.Timer = 0 then |
332 |
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); |
|
4 | 333 |
end; |
83 | 334 |
gtATSmoothWindCh: begin |
6 | 335 |
if Gear.Timer = 0 then |
336 |
begin |
|
337 |
if WindBarWidth < Gear.Tag then inc(WindBarWidth) |
|
83 | 338 |
else if WindBarWidth > Gear.Tag then dec(WindBarWidth); |
339 |
if WindBarWidth <> Gear.Tag then Gear.Timer:= 10; |
|
340 |
end |
|
341 |
end; |
|
342 |
gtATFinishGame: begin |
|
343 |
AllInactive:= false; |
|
344 |
if Gear.Timer = 0 then |
|
113 | 345 |
begin |
346 |
SendIPC('N'); |
|
83 | 347 |
GameState:= gsExit |
113 | 348 |
end |
6 | 349 |
end; |
4 | 350 |
end; |
83 | 351 |
if Gear.Timer = 0 then DeleteGear(Gear) |
4 | 352 |
end; |
353 |
||
354 |
//////////////////////////////////////////////////////////////////////////////// |
|
355 |
procedure doStepPickHammerWork(Gear: PGear); |
|
356 |
var i, ei: integer; |
|
357 |
HHGear: PGear; |
|
358 |
begin |
|
70 | 359 |
AllInactive:= false; |
161 | 360 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
4 | 361 |
dec(Gear.Timer); |
161 | 362 |
if (Gear.Timer = 0)or((Gear.Message and gm_Destroy) <> 0)or((HHGear.State and gstHHDriven) = 0) then |
4 | 363 |
begin |
282 | 364 |
StopSound(sndPickhammer); |
4 | 365 |
DeleteGear(Gear); |
366 |
AfterAttack; |
|
367 |
exit |
|
368 |
end; |
|
369 |
if (Gear.Timer and $3F) = 0 then |
|
370 |
begin |
|
53 | 371 |
i:= round(Gear.X) - Gear.Radius - GetRandom(2); |
372 |
ei:= round(Gear.X) + Gear.Radius + GetRandom(2); |
|
4 | 373 |
while i <= ei do |
374 |
begin |
|
375 |
doMakeExplosion(i, round(Gear.Y) + 3, 3, 0); |
|
376 |
inc(i, 1) |
|
377 |
end; |
|
378 |
Gear.X:= Gear.X + Gear.dX; |
|
42 | 379 |
Gear.Y:= Gear.Y + 1.9; |
380 |
SetAllHHToActive; |
|
4 | 381 |
end; |
382 |
if TestCollisionYwithGear(Gear, 1) then |
|
383 |
begin |
|
384 |
Gear.dY:= 0; |
|
300 | 385 |
SetLittle(HHGear.dX); |
4 | 386 |
HHGear.dY:= 0; |
387 |
end else |
|
388 |
begin |
|
389 |
Gear.dY:= Gear.dY + cGravity; |
|
390 |
Gear.Y:= Gear.Y + Gear.dY; |
|
391 |
if Gear.Y > 1024 then Gear.Timer:= 1 |
|
392 |
end; |
|
393 |
||
394 |
Gear.X:= Gear.X + HHGear.dX; |
|
395 |
HHGear.X:= Gear.X; |
|
53 | 396 |
HHGear.Y:= Gear.Y - cHHRadius; |
4 | 397 |
|
398 |
if (Gear.Message and gm_Attack) <> 0 then |
|
399 |
if (Gear.State and gsttmpFlag) <> 0 then Gear.Timer:= 1 else else |
|
400 |
if (Gear.State and gsttmpFlag) = 0 then Gear.State:= Gear.State or gsttmpFlag; |
|
401 |
if ((Gear.Message and gm_Left) <> 0) then Gear.dX:= -0.3 else |
|
402 |
if ((Gear.Message and gm_Right) <> 0) then Gear.dX:= 0.3 |
|
403 |
else Gear.dX:= 0; |
|
404 |
end; |
|
405 |
||
406 |
procedure doStepPickHammer(Gear: PGear); |
|
407 |
var i, y: integer; |
|
408 |
ar: TRangeArray; |
|
409 |
begin |
|
410 |
i:= 0; |
|
53 | 411 |
y:= round(Gear.Y) - cHHRadius*2; |
4 | 412 |
while y < round(Gear.Y) do |
413 |
begin |
|
53 | 414 |
ar[i].Left := round(Gear.X) - Gear.Radius - GetRandom(2); |
415 |
ar[i].Right:= round(Gear.X) + Gear.Radius + GetRandom(2); |
|
4 | 416 |
inc(y, 2); |
417 |
inc(i) |
|
418 |
end; |
|
53 | 419 |
DrawHLinesExplosions(@ar, 3, round(Gear.Y) - cHHRadius*2, 2, Pred(i)); |
4 | 420 |
Gear.dY:= PHedgehog(Gear.Hedgehog).Gear.dY; |
282 | 421 |
PlaySound(sndPickhammer, true); |
4 | 422 |
doStepPickHammerWork(Gear); |
423 |
Gear.doStep:= doStepPickHammerWork |
|
424 |
end; |
|
425 |
||
426 |
//////////////////////////////////////////////////////////////////////////////// |
|
302 | 427 |
|
428 |
procedure doStepBlowTorch(Gear: PGear); |
|
429 |
var HHGear: PGear; |
|
430 |
begin |
|
431 |
AllInactive:= false; |
|
432 |
dec(Gear.Timer); |
|
433 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
434 |
if Gear.Timer mod cHHStepTicks = 0 then |
|
435 |
begin |
|
436 |
DrawTunnel(HHGear.X, HHGear.Y - 1, Gear.dX, 0, cHHRadius * 2, cHHRadius * 2); |
|
437 |
HHGear.State:= HHGear.State and not gstAttacking; |
|
438 |
if Gear.dX < 0 then HHGear.Message:= gm_Left |
|
439 |
else HHGear.Message:= gm_Right; |
|
440 |
HedgehogStep(HHGear); |
|
441 |
if (HHGear.State and gstFalling) <> 0 then Gear.Timer:= 0 |
|
442 |
end; |
|
443 |
if Gear.Timer = 0 then |
|
444 |
begin |
|
445 |
HHGear.Message:= 0; |
|
446 |
DeleteGear(Gear); |
|
447 |
AfterAttack |
|
448 |
end |
|
449 |
end; |
|
450 |
||
451 |
//////////////////////////////////////////////////////////////////////////////// |
|
452 |
||
4 | 453 |
procedure doStepRopeWork(Gear: PGear); |
70 | 454 |
const flCheck: boolean = false; |
4 | 455 |
var HHGear: PGear; |
107 | 456 |
len, cs, cc, tx, ty: Double; |
108 | 457 |
lx, ly: LongInt; |
4 | 458 |
|
459 |
procedure DeleteMe; |
|
460 |
begin |
|
461 |
with HHGear^ do |
|
462 |
begin |
|
463 |
Message:= Message and not gm_Attack; |
|
464 |
State:= State or gstFalling; |
|
465 |
end; |
|
466 |
DeleteGear(Gear); |
|
113 | 467 |
OnUsedAmmo(PHedgehog(HHGear.Hedgehog)^.Ammo); |
468 |
ApplyAmmoChanges(PHedgehog(HHGear.Hedgehog)^) |
|
4 | 469 |
end; |
470 |
||
471 |
begin |
|
472 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
108 | 473 |
|
80 | 474 |
if ((HHGear.State and gstHHDriven) = 0) |
475 |
or (CheckGearDrowning(HHGear)) then |
|
4 | 476 |
begin |
477 |
DeleteMe; |
|
478 |
exit |
|
479 |
end; |
|
480 |
Gear.dX:= HHGear.X - Gear.X; |
|
481 |
Gear.dY:= HHGear.Y - Gear.Y; |
|
482 |
||
483 |
if (Gear.Message and gm_Left <> 0) then HHGear.dX:= HHGear.dX - 0.0002 else |
|
484 |
if (Gear.Message and gm_Right <> 0) then HHGear.dX:= HHGear.dX + 0.0002; |
|
485 |
||
486 |
if not TestCollisionYwithGear(HHGear, 1) then HHGear.dY:= HHGear.dY + cGravity; |
|
487 |
||
108 | 488 |
cs:= Gear.dY + HHGear.dY; |
489 |
cc:= Gear.dX + HHGear.dX; |
|
490 |
len:= 1 / sqrt(sqr(cc)+sqr(cs)); |
|
491 |
cc:= cc * len; |
|
492 |
cs:= cs * len; |
|
4 | 493 |
|
494 |
flCheck:= not flCheck; |
|
495 |
if flCheck then // check whether rope needs dividing |
|
496 |
begin |
|
497 |
len:= Gear.Elasticity - 20; |
|
498 |
while len > 5 do |
|
499 |
begin |
|
500 |
tx:= cc*len; |
|
501 |
ty:= cs*len; |
|
108 | 502 |
lx:= round(Gear.X + tx) + hwSign(HHGear.dX); |
503 |
ly:= round(Gear.Y + ty) + hwSign(HHGear.dY); |
|
4 | 504 |
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0)and (Land[ly, lx] <> 0) then |
505 |
begin |
|
506 |
with RopePoints.ar[RopePoints.Count] do |
|
507 |
begin |
|
508 |
X:= Gear.X; |
|
509 |
Y:= Gear.Y; |
|
510 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle32(Gear.dY, Gear.dX); |
|
511 |
b:= (cc * HHGear.dY) > (cs * HHGear.dX); |
|
512 |
dLen:= len |
|
513 |
end; |
|
514 |
Gear.X:= Gear.X + tx; |
|
515 |
Gear.Y:= Gear.Y + ty; |
|
516 |
inc(RopePoints.Count); |
|
517 |
Gear.Elasticity:= Gear.Elasticity - len; |
|
518 |
Gear.Friction:= Gear.Friction - len; |
|
519 |
break |
|
520 |
end; |
|
521 |
len:= len - 3 |
|
522 |
end; |
|
523 |
end else |
|
524 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
|
525 |
begin |
|
526 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
527 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
528 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear.X) * (ty - HHGear.Y) > (tx - HHGear.X) * (ty - Gear.Y)) then |
|
529 |
begin |
|
530 |
dec(RopePoints.Count); |
|
531 |
Gear.X:=RopePoints.ar[RopePoints.Count].X; |
|
532 |
Gear.Y:=RopePoints.ar[RopePoints.Count].Y; |
|
533 |
Gear.Elasticity:= Gear.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
|
534 |
Gear.Friction:= Gear.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
535 |
end |
|
536 |
end; |
|
537 |
||
538 |
Gear.dX:= HHGear.X - Gear.X; |
|
539 |
Gear.dY:= HHGear.Y - Gear.Y; |
|
108 | 540 |
|
541 |
cs:= Gear.dY + HHGear.dY; |
|
542 |
cc:= Gear.dX + HHGear.dX; |
|
543 |
len:= 1 / sqrt(sqr(cc)+sqr(cs)); |
|
544 |
cc:= cc * len; |
|
545 |
cs:= cs * len; |
|
4 | 546 |
|
547 |
HHGear.dX:= HHGear.X; |
|
548 |
HHGear.dY:= HHGear.Y; |
|
549 |
||
550 |
if ((Gear.Message and gm_Down) <> 0) and (Gear.Elasticity < Gear.Friction) then |
|
108 | 551 |
if not (TestCollisionXwithGear(HHGear, hwSign(Gear.dX)) |
552 |
or TestCollisionYwithGear(HHGear, hwSign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity + 0.3; |
|
4 | 553 |
|
554 |
if ((Gear.Message and gm_Up) <> 0) and (Gear.Elasticity > 30) then |
|
108 | 555 |
if not (TestCollisionXwithGear(HHGear, -hwSign(Gear.dX)) |
556 |
or TestCollisionYwithGear(HHGear, -hwSign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity - 0.3; |
|
4 | 557 |
|
558 |
HHGear.X:= Gear.X + cc*Gear.Elasticity; |
|
559 |
HHGear.Y:= Gear.Y + cs*Gear.Elasticity; |
|
560 |
||
561 |
HHGear.dX:= HHGear.X - HHGear.dX; |
|
562 |
HHGear.dY:= HHGear.Y - HHGear.dY; |
|
563 |
||
108 | 564 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then |
75 | 565 |
HHGear.dX:= -0.6 * HHGear.dX; |
108 | 566 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear.dY)) then |
75 | 567 |
HHGear.dY:= -0.6 * HHGear.dY; |
4 | 568 |
|
569 |
if (Gear.Message and gm_Attack) <> 0 then |
|
570 |
if (Gear.State and gsttmpFlag) <> 0 then DeleteMe else |
|
571 |
else if (Gear.State and gsttmpFlag) = 0 then Gear.State:= Gear.State or gsttmpFlag; |
|
572 |
end; |
|
573 |
||
574 |
||
575 |
procedure doStepRopeAttach(Gear: PGear); |
|
576 |
var HHGear: PGear; |
|
107 | 577 |
tx, ty, tt: Double; |
4 | 578 |
begin |
113 | 579 |
Gear.X:= Gear.X - Gear.dX; |
580 |
Gear.Y:= Gear.Y - Gear.dY; |
|
4 | 581 |
Gear.Elasticity:= Gear.Elasticity + 1.0; |
582 |
HHGear:= PHedgehog(Gear.Hedgehog)^.Gear; |
|
583 |
if (HHGear.State and gstFalling) <> 0 then |
|
68 | 584 |
if TestCollisionYwithGear(HHGear, 1) then |
4 | 585 |
begin |
586 |
HHGear.dY:= 0; |
|
587 |
CheckHHDamage(HHGear); |
|
588 |
HHGear.State:= HHGear.State and not (gstFalling or gstHHJumping); |
|
589 |
end else |
|
590 |
begin |
|
108 | 591 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then HHGear.dX:= 0.0000001 * hwSign(HHGear.dX); |
4 | 592 |
HHGear.X:= HHGear.X + HHGear.dX; |
593 |
HHGear.Y:= HHGear.Y + HHGear.dY; |
|
594 |
Gear.X:= Gear.X + HHGear.dX; |
|
595 |
Gear.Y:= Gear.Y + HHGear.dY; |
|
596 |
HHGear.dY:= HHGear.dY + cGravity; |
|
597 |
tt:= Gear.Elasticity; |
|
598 |
tx:= 0; |
|
599 |
ty:= 0; |
|
600 |
while tt > 20 do |
|
601 |
begin |
|
108 | 602 |
if TestCollisionXwithXYShift(Gear, round(tx), round(ty), hwSign(Gear.dX)) |
603 |
or TestCollisionYwithXYShift(Gear, round(tx), round(ty), hwSign(Gear.dY)) then |
|
4 | 604 |
begin |
605 |
Gear.X:= Gear.X + tx; |
|
606 |
Gear.Y:= Gear.Y + ty; |
|
607 |
Gear.Elasticity:= tt; |
|
608 |
Gear.doStep:= doStepRopeWork; |
|
609 |
with HHGear^ do State:= State and not gstAttacking; |
|
610 |
tt:= 0 |
|
611 |
end; |
|
113 | 612 |
tx:= tx + Gear.dX - Gear.dX; |
613 |
ty:= ty + Gear.dY - Gear.dY; |
|
4 | 614 |
tt:= tt - 2.0; |
615 |
end; |
|
616 |
end; |
|
617 |
CheckCollision(Gear); |
|
618 |
if (Gear.State and gstCollision) <> 0 then |
|
619 |
begin |
|
620 |
Gear.doStep:= doStepRopeWork; |
|
621 |
with HHGear^ do State:= State and not gstAttacking; |
|
622 |
if Gear.Elasticity < 10 then |
|
623 |
Gear.Elasticity:= 10000; |
|
624 |
end; |
|
625 |
||
626 |
if (Gear.Elasticity >= Gear.Friction) or ((Gear.Message and gm_Attack) = 0) then |
|
627 |
begin |
|
628 |
with PHedgehog(Gear.Hedgehog).Gear^ do |
|
629 |
begin |
|
630 |
State:= State and not gstAttacking; |
|
631 |
Message:= Message and not gm_Attack |
|
632 |
end; |
|
633 |
DeleteGear(Gear) |
|
634 |
end |
|
635 |
end; |
|
636 |
||
637 |
procedure doStepRope(Gear: PGear); |
|
638 |
begin |
|
113 | 639 |
Gear.dX:= - Gear.dX; |
640 |
Gear.dY:= - Gear.dY; |
|
4 | 641 |
Gear.doStep:= doStepRopeAttach |
642 |
end; |
|
643 |
||
644 |
//////////////////////////////////////////////////////////////////////////////// |
|
645 |
procedure doStepSmokeTrace(Gear: PGear); |
|
646 |
begin |
|
647 |
inc(Gear.Timer); |
|
648 |
if Gear.Timer > 64 then |
|
649 |
begin |
|
650 |
Gear.Timer:= 0; |
|
9 | 651 |
dec(Gear.State) |
4 | 652 |
end; |
653 |
Gear.dX:= Gear.dX + cWindSpeed; |
|
654 |
Gear.X:= Gear.X + Gear.dX; |
|
9 | 655 |
if Gear.State = 0 then DeleteGear(Gear) |
4 | 656 |
end; |
9 | 657 |
|
658 |
//////////////////////////////////////////////////////////////////////////////// |
|
659 |
procedure doStepExplosion(Gear: PGear); |
|
660 |
begin |
|
661 |
inc(Gear.Timer); |
|
662 |
if Gear.Timer > 75 then |
|
663 |
begin |
|
664 |
inc(Gear.State); |
|
665 |
Gear.Timer:= 0; |
|
666 |
if Gear.State > 5 then DeleteGear(Gear) |
|
667 |
end; |
|
668 |
end; |
|
10 | 669 |
|
670 |
//////////////////////////////////////////////////////////////////////////////// |
|
671 |
procedure doStepMine(Gear: PGear); |
|
672 |
begin |
|
39 | 673 |
if (Gear.dX <> 0) or (Gear.dY <> 0) then |
10 | 674 |
begin |
53 | 675 |
if Gear.CollIndex < High(Longword) then DeleteCI(Gear); |
10 | 676 |
doStepFallingGear(Gear); |
13 | 677 |
if Gear.Active = false then |
678 |
begin |
|
53 | 679 |
if Gear.CollIndex = High(Longword) then AddGearCI(Gear); |
13 | 680 |
Gear.dX:= 0; |
681 |
Gear.dY:= 0 |
|
682 |
end; |
|
683 |
CalcRotationDirAngle(Gear); |
|
10 | 684 |
AllInactive:= false |
685 |
end; |
|
39 | 686 |
|
10 | 687 |
if ((Gear.State and gsttmpFlag) <> 0) then |
688 |
if ((Gear.State and gstAttacking) = 0) then |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
689 |
begin |
39 | 690 |
if ((GameTicks and $F) = 0) then |
15 | 691 |
if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear.State:= Gear.State or gstAttacking |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
692 |
end else // gstAttacking <> 0 |
10 | 693 |
begin |
694 |
AllInactive:= false; |
|
37 | 695 |
if (Gear.Timer and $FF) = 0 then PlaySound(sndMineTick); |
10 | 696 |
if Gear.Timer = 0 then |
697 |
begin |
|
13 | 698 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound); |
10 | 699 |
DeleteGear(Gear) |
700 |
end; |
|
13 | 701 |
dec(Gear.Timer); |
702 |
end else // gsttmpFlag = 0 |
|
703 |
if TurnTimeLeft = 0 then Gear.State:= Gear.State or gsttmpFlag; |
|
10 | 704 |
end; |
57 | 705 |
|
39 | 706 |
//////////////////////////////////////////////////////////////////////////////// |
707 |
procedure doStepDynamite(Gear: PGear); |
|
708 |
begin |
|
43 | 709 |
doStepFallingGear(Gear); |
710 |
AllInactive:= false; |
|
711 |
if Gear.Timer mod 166 = 0 then inc(Gear.Tag); |
|
712 |
if Gear.Timer = 0 then |
|
39 | 713 |
begin |
46 | 714 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 75, EXPLAutoSound); |
43 | 715 |
DeleteGear(Gear); |
716 |
exit |
|
39 | 717 |
end; |
43 | 718 |
dec(Gear.Timer); |
39 | 719 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
720 |
|
15 | 721 |
//////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
722 |
procedure doStepCase(Gear: PGear); |
89 | 723 |
var i, x, y: integer; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
724 |
begin |
15 | 725 |
if (Gear.Message and gm_Destroy) > 0 then |
726 |
begin |
|
727 |
DeleteGear(Gear); |
|
728 |
exit |
|
729 |
end; |
|
730 |
||
79 | 731 |
if Gear.Damage > 0 then |
732 |
begin |
|
89 | 733 |
x:= round(Gear.X); |
734 |
y:= round(Gear.Y); |
|
79 | 735 |
DeleteGear(Gear); |
89 | 736 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
79 | 737 |
for i:= 0 to 63 do |
89 | 738 |
AddGear(x, y, gtFlame, 0); |
79 | 739 |
exit |
740 |
end; |
|
741 |
||
53 | 742 |
if (Gear.dY <> 0) or (not TestCollisionYwithGear(Gear, 1)) then |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
743 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
744 |
AllInactive:= false; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
745 |
Gear.dY:= Gear.dY + cGravity; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
746 |
Gear.Y:= Gear.Y + Gear.dY; |
53 | 747 |
if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0 else |
748 |
if (Gear.dY >= 0) and TestCollisionYwithGear(Gear, 1) then |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
749 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
750 |
Gear.dY:= - Gear.dY * Gear.Elasticity; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
751 |
if Gear.dY > - 0.001 then Gear.dY:= 0 |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
752 |
else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
753 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
754 |
CheckGearDrowning(Gear); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
755 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
756 |
|
53 | 757 |
if (Gear.CollIndex = High(Longword)) and (Gear.dY = 0) then AddGearCI(Gear) |
758 |
else if (Gear.CollIndex < High(Longword)) and (Gear.dY <> 0) then DeleteCI(Gear); |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
759 |
end; |
49 | 760 |
|
761 |
//////////////////////////////////////////////////////////////////////////////// |
|
762 |
var thexchar: array[0..5] of record |
|
763 |
oy, ny: integer; |
|
764 |
team: PTeam; |
|
765 |
end; |
|
766 |
thexchcnt: Longword; |
|
143 | 767 |
currsorter: PGear; |
49 | 768 |
|
769 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
770 |
var i: integer; |
|
771 |
begin |
|
772 |
AllInactive:= false; |
|
773 |
dec(Gear.Timer); |
|
774 |
if (Gear.Timer and 15) = 0 then |
|
775 |
for i:= 0 to Pred(thexchcnt) do |
|
776 |
with thexchar[i] do |
|
777 |
{$WARNINGS OFF} |
|
778 |
team.DrawHealthY:= ny + (oy - ny) * Gear.Timer div 640; |
|
779 |
{$WARNINGS ON} |
|
143 | 780 |
if (Gear.Timer = 0) or (currsorter <> Gear) then |
781 |
begin |
|
782 |
if currsorter = Gear then currsorter:= nil; |
|
49 | 783 |
DeleteGear(Gear) |
143 | 784 |
end |
49 | 785 |
end; |
786 |
||
787 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
788 |
var team: PTeam; |
|
789 |
i, t: Longword; |
|
790 |
begin |
|
791 |
AllInactive:= false; |
|
792 |
team:= TeamsList; |
|
793 |
i:= 0; |
|
794 |
while team <> nil do |
|
795 |
begin |
|
796 |
thexchar[i].oy:= team.DrawHealthY; |
|
797 |
thexchar[i].team:= team; |
|
798 |
inc(i); |
|
799 |
team:= team.Next |
|
800 |
end; |
|
801 |
thexchcnt:= i; |
|
802 |
for i:= 1 to thexchcnt do |
|
803 |
for t:= 0 to thexchcnt - 2 do |
|
146 | 804 |
if thexchar[t].team.TeamHealthBarWidth > thexchar[Succ(t)].team.TeamHealthBarWidth then |
49 | 805 |
begin |
806 |
thexchar[5]:= thexchar[t]; |
|
807 |
thexchar[t]:= thexchar[Succ(t)]; |
|
808 |
thexchar[Succ(t)]:= thexchar[5] |
|
809 |
end; |
|
810 |
t:= cScreenHeight - 4; |
|
811 |
for i:= 0 to Pred(thexchcnt) do |
|
812 |
with thexchar[i] do |
|
813 |
begin |
|
814 |
dec(t, team.HealthRect.h + 2); |
|
815 |
ny:= t |
|
816 |
end; |
|
817 |
Gear.Timer:= 640; |
|
143 | 818 |
Gear.doStep:= doStepTeamHealthSorterWork; |
819 |
currsorter:= Gear |
|
49 | 820 |
end; |
821 |
||
79 | 822 |
//////////////////////////////////////////////////////////////////////////////// |
823 |
procedure doStepShover(Gear: PGear); |
|
824 |
var HHGear: PGear; |
|
825 |
begin |
|
826 |
HHGear:= PHedgehog(Gear.Hedgehog)^.Gear; |
|
827 |
HHGear.State:= HHGear.State or gstNoDamage; |
|
828 |
AmmoShove(Gear, 30, 115); |
|
829 |
HHGear.State:= HHGear.State and not gstNoDamage; |
|
830 |
DeleteGear(Gear) |
|
831 |
end; |
|
832 |
||
833 |
//////////////////////////////////////////////////////////////////////////////// |
|
834 |
procedure doStepFlame(Gear: PGear); |
|
835 |
begin |
|
836 |
AllInactive:= false; |
|
837 |
if not TestCollisionYwithGear(Gear, 1) then |
|
838 |
begin |
|
839 |
Gear.dX:= Gear.dX + cWindSpeed; |
|
840 |
Gear.dY:= Gear.dY + cGravity; |
|
841 |
if abs(Gear.dX) > 0.12 then Gear.dX:= Gear.dX * 0.5; |
|
842 |
if Gear.dY > 0.12 then Gear.dY:= Gear.dY * 0.995; |
|
843 |
Gear.X:= Gear.X + Gear.dX; |
|
844 |
Gear.Y:= Gear.Y + Gear.dY; |
|
845 |
if Gear.Y > 1023 then |
|
846 |
begin |
|
847 |
DeleteGear(Gear); |
|
848 |
exit |
|
849 |
end |
|
850 |
end else begin |
|
851 |
if Gear.Timer > 0 then dec(Gear.Timer) |
|
852 |
else begin |
|
853 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 2, 0); |
|
854 |
dec(Gear.Health); |
|
855 |
Gear.Timer:= 1250 - Gear.Angle * 12 |
|
856 |
end |
|
857 |
end; |
|
858 |
||
859 |
if (((GameTicks div 8) mod 64) = Gear.Angle) then |
|
860 |
AmmoFlameWork(Gear); |
|
861 |
||
82 | 862 |
if Gear.Health = 0 then |
79 | 863 |
DeleteGear(Gear) |
864 |
end; |
|
82 | 865 |
|
866 |
//////////////////////////////////////////////////////////////////////////////// |
|
867 |
procedure doStepFirePunchWork(Gear: PGear); |
|
868 |
var HHGear: PGear; |
|
869 |
begin |
|
870 |
AllInactive:= false; |
|
871 |
if ((Gear.Message and gm_Destroy) <> 0) then |
|
872 |
begin |
|
873 |
DeleteGear(Gear); |
|
874 |
AfterAttack; |
|
875 |
exit |
|
876 |
end; |
|
877 |
||
878 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
879 |
if round(HHGear.Y) <= Gear.Tag - 2 then |
|
880 |
begin |
|
881 |
Gear.Tag:= round(HHGear.Y); |
|
882 |
DrawTunnel(HHGear.X - cHHRadius, HHGear.Y - 1, 0.5, 0.0, cHHRadius * 4, 2); |
|
883 |
HHGear.State:= HHGear.State or gstNoDamage; |
|
884 |
Gear.Y:= HHGear.Y; |
|
885 |
AmmoShove(Gear, 30, 40); |
|
886 |
HHGear.State:= HHGear.State and not gstNoDamage |
|
887 |
end; |
|
888 |
||
889 |
HHGear.dY:= HHGear.dY + cGravity; |
|
890 |
if HHGear.dY >= 0 then |
|
891 |
begin |
|
892 |
HHGear.State:= HHGear.State or gstFalling; |
|
893 |
DeleteGear(Gear); |
|
894 |
AfterAttack; |
|
895 |
exit |
|
896 |
end; |
|
897 |
HHGear.Y:= HHGear.Y + HHGear.dY |
|
898 |
end; |
|
899 |
||
900 |
procedure doStepFirePunch(Gear: PGear); |
|
901 |
var HHGear: PGear; |
|
902 |
begin |
|
903 |
AllInactive:= false; |
|
904 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
905 |
HHGear.X:= round(HHGear.X) - 0.5; |
|
108 | 906 |
HHGear.dX:= 0.0000001 * hwSign(HHGear.dX); |
82 | 907 |
HHGear.dY:= -0.30; |
908 |
||
909 |
Gear.X:= HHGear.X; |
|
108 | 910 |
Gear.dX:= hwSign(HHGear.dX)* 0.45; |
82 | 911 |
Gear.dY:= -0.9; |
912 |
Gear.doStep:= doStepFirePunchWork; |
|
913 |
DrawTunnel(HHGear.X - cHHRadius, HHGear.Y + 1, 0.5, 0.0, cHHRadius * 4, 5); |
|
914 |
end; |
|
915 |
||
263 | 916 |
//////////////////////////////////////////////////////////////////////////////// |
917 |
||
211 | 918 |
procedure doStepParachute(Gear: PGear); |
919 |
var HHGear: PGear; |
|
920 |
begin |
|
921 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
212 | 922 |
HHGear.State:= HHGear.State and not gstAttacking; |
82 | 923 |
|
212 | 924 |
if TestCollisionYwithGear(HHGear, 1) |
925 |
or ((HHGear.State and gstHHDriven) = 0) |
|
926 |
or CheckGearDrowning(HHGear) then |
|
211 | 927 |
begin |
928 |
with HHGear^ do |
|
929 |
begin |
|
930 |
Message:= 0; |
|
931 |
dx:= 0.0000001 * hwSign(dX); |
|
932 |
dY:= 0; |
|
933 |
State:= State and not (gstAttacking or gstAttacked); |
|
934 |
State:= State or gstFalling; |
|
935 |
end; |
|
936 |
DeleteGear(Gear); |
|
937 |
OnUsedAmmo(PHedgehog(HHGear.Hedgehog)^.Ammo); |
|
938 |
ApplyAmmoChanges(PHedgehog(HHGear.Hedgehog)^); |
|
939 |
exit |
|
940 |
end; |
|
941 |
||
942 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then |
|
943 |
HHGear.X:= HHGear.X + cWindSpeed * 200; |
|
944 |
||
945 |
if (Gear.Message and gm_Left) <> 0 then HHGear.X:= HHGear.X - cMaxWindSpeed * 40 |
|
946 |
else if (Gear.Message and gm_Right) <> 0 then HHGear.X:= HHGear.X + cMaxWindSpeed * 40; |
|
947 |
if (Gear.Message and gm_Up) <> 0 then HHGear.Y:= HHGear.Y - cGravity * 40 |
|
948 |
else if (Gear.Message and gm_Down) <> 0 then HHGear.Y:= HHGear.Y + cGravity * 40; |
|
949 |
||
950 |
HHGear.Y:= HHGear.Y + cGravity * 100; |
|
263 | 951 |
end; |
211 | 952 |
|
263 | 953 |
//////////////////////////////////////////////////////////////////////////////// |
285 | 954 |
const cAirPlaneSpeed = 1.4; |
263 | 955 |
cBombsDistance = 30; |
956 |
cBombsSpeed = 0.1; |
|
957 |
||
958 |
procedure doStepAirAttackWork(Gear: PGear); |
|
959 |
begin |
|
960 |
AllInactive:= false; |
|
961 |
Gear.X:= Gear.X + cAirPlaneSpeed; |
|
962 |
if (Gear.Health > 0)and(Gear.X >= Gear.dX)and(Gear.X < Gear.dX + cAirPlaneSpeed) then |
|
963 |
begin |
|
964 |
dec(Gear.Health); |
|
285 | 965 |
case Gear.State of |
966 |
0: AddGear(round(Gear.X), round(Gear.Y), gtAirBomb, 0, cBombsSpeed, 0.0); |
|
967 |
1: AddGear(round(Gear.X), round(Gear.Y), gtMine, 0, cBombsSpeed, 0.0); |
|
968 |
end; |
|
263 | 969 |
Gear.dX:= Gear.dX + cBombsDistance |
970 |
end; |
|
283 | 971 |
if Gear.X > 3072 then DeleteGear(Gear) |
263 | 972 |
end; |
973 |
||
974 |
procedure doStepAirAttack(Gear: PGear); |
|
975 |
begin |
|
976 |
AllInactive:= false; |
|
283 | 977 |
Gear.X:= -1024; |
263 | 978 |
Gear.Y:= -128; |
979 |
Gear.dX:= TargetPoint.X - |
|
980 |
cBombsDistance * 5 / 2 - |
|
981 |
cBombsSpeed * sqrt(2 * (TargetPoint.Y - Gear.Y) / cGravity); |
|
982 |
Gear.Health:= 6; |
|
983 |
Gear.doStep:= doStepAirAttackWork |
|
984 |
end; |
|
985 |
||
986 |
//////////////////////////////////////////////////////////////////////////////// |
|
987 |
||
988 |
procedure doStepAirBomb(Gear: PGear); |
|
989 |
begin |
|
990 |
AllInactive:= false; |
|
991 |
doStepFallingGear(Gear); |
|
992 |
if (Gear.State and gstCollision) <> 0 then |
|
993 |
begin |
|
285 | 994 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound); |
263 | 995 |
DeleteGear(Gear); |
996 |
exit |
|
997 |
end; |
|
998 |
if (GameTicks and $3F) = 0 then |
|
999 |
AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0) |
|
211 | 1000 |
end; |
1001 |
||
1002 |