author | unc0rr |
Tue, 21 Nov 2006 16:54:58 +0000 | |
changeset 257 | 7be02e84fc68 |
parent 219 | 73a2bf84d0e6 |
child 263 | 36379e6abcdd |
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 |
|
174 |
PHedgehog(Gear.Hedgehog).Gear.Active:= true; |
|
175 |
DeleteGear(Gear) |
|
176 |
end |
|
177 |
end; |
|
178 |
||
95 | 179 |
procedure doStepHealthTag(Gear: PGear); |
180 |
var s: shortstring; |
|
181 |
begin |
|
182 |
AllInactive:= false; |
|
183 |
str(Gear.State, s); |
|
184 |
Gear.Surf:= RenderString(s, PHedgehog(Gear.Hedgehog).Team.Color, fnt16); |
|
185 |
Gear.doStep:= doStepHealthTagWork |
|
186 |
end; |
|
187 |
||
4 | 188 |
//////////////////////////////////////////////////////////////////////////////// |
189 |
procedure doStepGrave(Gear: PGear); |
|
190 |
begin |
|
191 |
AllInactive:= false; |
|
192 |
if Gear.dY < 0 then |
|
68 | 193 |
if TestCollisionY(Gear, -1) then Gear.dY:= 0; |
4 | 194 |
|
195 |
if Gear.dY >=0 then |
|
68 | 196 |
if TestCollisionY(Gear, 1) then |
4 | 197 |
begin |
198 |
Gear.dY:= - Gear.dY * Gear.Elasticity; |
|
199 |
if Gear.dY > - 0.001 then |
|
200 |
begin |
|
201 |
Gear.Active:= false; |
|
202 |
exit |
|
203 |
end else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact) |
|
204 |
end; |
|
205 |
Gear.Y:= Gear.Y + Gear.dY; |
|
206 |
CheckGearDrowning(Gear); |
|
207 |
Gear.dY:= Gear.dY + cGravity |
|
208 |
end; |
|
209 |
||
210 |
//////////////////////////////////////////////////////////////////////////////// |
|
211 |
procedure doStepUFOWork(Gear: PGear); |
|
107 | 212 |
var t: Double; |
4 | 213 |
begin |
214 |
AllInactive:= false; |
|
215 |
t:= sqrt(sqr(Gear.dX) + sqr(Gear.dY)); |
|
216 |
Gear.dX:= Gear.Elasticity * (Gear.dX + 0.000004 * (TargetPoint.X - trunc(Gear.X))); |
|
217 |
Gear.dY:= Gear.Elasticity * (Gear.dY + 0.000004 * (TargetPoint.Y - trunc(Gear.Y))); |
|
218 |
t:= t / (sqrt(sqr(Gear.dX) + sqr(Gear.dY))); |
|
219 |
Gear.dX:= Gear.dX * t; |
|
220 |
Gear.dY:= Gear.dY * t; |
|
221 |
Gear.X:= Gear.X + Gear.dX; |
|
222 |
Gear.Y:= Gear.Y + Gear.dY; |
|
223 |
CheckCollision(Gear); |
|
224 |
dec(Gear.Timer); |
|
225 |
if ((Gear.State and gstCollision) <> 0) or (Gear.Timer = 0) then |
|
226 |
begin |
|
227 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound); |
|
228 |
DeleteGear(Gear); |
|
229 |
end; |
|
230 |
end; |
|
231 |
||
232 |
procedure doStepUFO(Gear: PGear); |
|
233 |
begin |
|
234 |
AllInactive:= false; |
|
235 |
Gear.X:= Gear.X + Gear.dX; |
|
236 |
Gear.Y:= Gear.Y + Gear.dY; |
|
237 |
Gear.dY:= Gear.dY + cGravity; |
|
238 |
CheckCollision(Gear); |
|
239 |
if (Gear.State and gstCollision) <> 0 then |
|
240 |
begin |
|
241 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound); |
|
242 |
DeleteGear(Gear); |
|
243 |
exit |
|
244 |
end; |
|
245 |
dec(Gear.Timer); |
|
246 |
if Gear.Timer = 0 then |
|
247 |
begin |
|
248 |
Gear.Timer:= 5000; |
|
249 |
Gear.doStep:= doStepUFOWork |
|
250 |
end; |
|
251 |
end; |
|
252 |
||
253 |
//////////////////////////////////////////////////////////////////////////////// |
|
254 |
procedure doStepShotgunShot(Gear: PGear); |
|
255 |
var i: LongWord; |
|
256 |
begin |
|
257 |
AllInactive:= false; |
|
258 |
if Gear.Timer > 0 then |
|
259 |
begin |
|
260 |
dec(Gear.Timer); |
|
95 | 261 |
if Gear.Timer = 0 then PlaySound(sndShotgunFire); |
4 | 262 |
exit |
263 |
end; |
|
264 |
i:= 200; |
|
265 |
repeat |
|
266 |
Gear.X:= Gear.X + Gear.dX; |
|
267 |
Gear.Y:= Gear.Y + Gear.dY; |
|
268 |
CheckCollision(Gear); |
|
269 |
if (Gear.State and gstCollision) <> 0 then |
|
270 |
begin |
|
75 | 271 |
AmmoShove(Gear, 25, 25); |
42 | 272 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 25, EXPLNoDamage or EXPLDoNotTouchHH); |
4 | 273 |
DeleteGear(Gear); |
75 | 274 |
AfterAttack; |
4 | 275 |
exit |
276 |
end; |
|
277 |
dec(i) |
|
278 |
until i = 0; |
|
279 |
if (Gear.X < 0) or (Gear.Y < 0) or (Gear.X > 2048) or (Gear.Y > 1024) then |
|
95 | 280 |
begin |
281 |
DeleteGear(Gear); |
|
282 |
AfterAttack |
|
283 |
end |
|
4 | 284 |
end; |
285 |
||
286 |
//////////////////////////////////////////////////////////////////////////////// |
|
38 | 287 |
procedure doStepDEagleShot(Gear: PGear); |
288 |
var i, x, y: LongWord; |
|
107 | 289 |
oX, oY: Double; |
38 | 290 |
begin |
291 |
AllInactive:= false; |
|
37 | 292 |
i:= 80; |
38 | 293 |
oX:= Gear.X; |
294 |
oY:= Gear.Y; |
|
37 | 295 |
repeat |
38 | 296 |
Gear.X:= Gear.X + Gear.dX; |
297 |
Gear.Y:= Gear.Y + Gear.dY; |
|
298 |
x:= round(Gear.X); |
|
299 |
y:= round(Gear.Y); |
|
300 |
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0) |
|
301 |
and (Land[y, x] <> 0) then inc(Gear.Damage); |
|
75 | 302 |
AmmoShove(Gear, 7, 20); |
38 | 303 |
dec(i) |
304 |
until (i = 0) or (Gear.Damage > Gear.Health); |
|
305 |
if Gear.Damage > 0 then |
|
37 | 306 |
begin |
38 | 307 |
DrawTunnel(oX, oY, Gear.dX, Gear.dY, 82 - i, 1); |
308 |
dec(Gear.Health, Gear.Damage); |
|
309 |
Gear.Damage:= 0 |
|
37 | 310 |
end; |
38 | 311 |
if (Gear.Health <= 0) or (Gear.X < 0) or (Gear.Y < 0) or (Gear.X > 2048) or (Gear.Y > 1024) then |
37 | 312 |
DeleteGear(Gear) |
313 |
end; |
|
314 |
||
315 |
//////////////////////////////////////////////////////////////////////////////// |
|
4 | 316 |
procedure doStepActionTimer(Gear: PGear); |
317 |
begin |
|
83 | 318 |
dec(Gear.Timer); |
319 |
case Gear.Kind of |
|
320 |
gtATStartGame: begin |
|
4 | 321 |
AllInactive:= false; |
83 | 322 |
if Gear.Timer = 0 then |
323 |
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); |
|
4 | 324 |
end; |
83 | 325 |
gtATSmoothWindCh: begin |
6 | 326 |
if Gear.Timer = 0 then |
327 |
begin |
|
328 |
if WindBarWidth < Gear.Tag then inc(WindBarWidth) |
|
83 | 329 |
else if WindBarWidth > Gear.Tag then dec(WindBarWidth); |
330 |
if WindBarWidth <> Gear.Tag then Gear.Timer:= 10; |
|
331 |
end |
|
332 |
end; |
|
333 |
gtATFinishGame: begin |
|
334 |
AllInactive:= false; |
|
335 |
if Gear.Timer = 0 then |
|
113 | 336 |
begin |
337 |
SendIPC('N'); |
|
83 | 338 |
GameState:= gsExit |
113 | 339 |
end |
6 | 340 |
end; |
4 | 341 |
end; |
83 | 342 |
if Gear.Timer = 0 then DeleteGear(Gear) |
4 | 343 |
end; |
344 |
||
345 |
//////////////////////////////////////////////////////////////////////////////// |
|
346 |
procedure doStepPickHammerWork(Gear: PGear); |
|
347 |
var i, ei: integer; |
|
348 |
HHGear: PGear; |
|
349 |
begin |
|
70 | 350 |
AllInactive:= false; |
161 | 351 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
4 | 352 |
dec(Gear.Timer); |
161 | 353 |
if (Gear.Timer = 0)or((Gear.Message and gm_Destroy) <> 0)or((HHGear.State and gstHHDriven) = 0) then |
4 | 354 |
begin |
355 |
DeleteGear(Gear); |
|
356 |
AfterAttack; |
|
357 |
exit |
|
358 |
end; |
|
359 |
if (Gear.Timer and $3F) = 0 then |
|
360 |
begin |
|
53 | 361 |
i:= round(Gear.X) - Gear.Radius - GetRandom(2); |
362 |
ei:= round(Gear.X) + Gear.Radius + GetRandom(2); |
|
4 | 363 |
while i <= ei do |
364 |
begin |
|
365 |
doMakeExplosion(i, round(Gear.Y) + 3, 3, 0); |
|
366 |
inc(i, 1) |
|
367 |
end; |
|
368 |
Gear.X:= Gear.X + Gear.dX; |
|
42 | 369 |
Gear.Y:= Gear.Y + 1.9; |
370 |
SetAllHHToActive; |
|
4 | 371 |
end; |
372 |
if TestCollisionYwithGear(Gear, 1) then |
|
373 |
begin |
|
374 |
Gear.dY:= 0; |
|
219 | 375 |
HHGear.dX:= 0.0000001 * hwSign(HHGear.dX); |
4 | 376 |
HHGear.dY:= 0; |
377 |
end else |
|
378 |
begin |
|
379 |
Gear.dY:= Gear.dY + cGravity; |
|
380 |
Gear.Y:= Gear.Y + Gear.dY; |
|
381 |
if Gear.Y > 1024 then Gear.Timer:= 1 |
|
382 |
end; |
|
383 |
||
384 |
Gear.X:= Gear.X + HHGear.dX; |
|
385 |
HHGear.X:= Gear.X; |
|
53 | 386 |
HHGear.Y:= Gear.Y - cHHRadius; |
4 | 387 |
|
388 |
if (Gear.Message and gm_Attack) <> 0 then |
|
389 |
if (Gear.State and gsttmpFlag) <> 0 then Gear.Timer:= 1 else else |
|
390 |
if (Gear.State and gsttmpFlag) = 0 then Gear.State:= Gear.State or gsttmpFlag; |
|
391 |
if ((Gear.Message and gm_Left) <> 0) then Gear.dX:= -0.3 else |
|
392 |
if ((Gear.Message and gm_Right) <> 0) then Gear.dX:= 0.3 |
|
393 |
else Gear.dX:= 0; |
|
394 |
end; |
|
395 |
||
396 |
procedure doStepPickHammer(Gear: PGear); |
|
397 |
var i, y: integer; |
|
398 |
ar: TRangeArray; |
|
399 |
begin |
|
400 |
i:= 0; |
|
53 | 401 |
y:= round(Gear.Y) - cHHRadius*2; |
4 | 402 |
while y < round(Gear.Y) do |
403 |
begin |
|
53 | 404 |
ar[i].Left := round(Gear.X) - Gear.Radius - GetRandom(2); |
405 |
ar[i].Right:= round(Gear.X) + Gear.Radius + GetRandom(2); |
|
4 | 406 |
inc(y, 2); |
407 |
inc(i) |
|
408 |
end; |
|
53 | 409 |
DrawHLinesExplosions(@ar, 3, round(Gear.Y) - cHHRadius*2, 2, Pred(i)); |
4 | 410 |
Gear.dY:= PHedgehog(Gear.Hedgehog).Gear.dY; |
411 |
doStepPickHammerWork(Gear); |
|
412 |
Gear.doStep:= doStepPickHammerWork |
|
413 |
end; |
|
414 |
||
415 |
//////////////////////////////////////////////////////////////////////////////// |
|
416 |
procedure doStepRopeWork(Gear: PGear); |
|
70 | 417 |
const flCheck: boolean = false; |
4 | 418 |
var HHGear: PGear; |
107 | 419 |
len, cs, cc, tx, ty: Double; |
108 | 420 |
lx, ly: LongInt; |
4 | 421 |
|
422 |
procedure DeleteMe; |
|
423 |
begin |
|
424 |
with HHGear^ do |
|
425 |
begin |
|
426 |
Message:= Message and not gm_Attack; |
|
427 |
State:= State or gstFalling; |
|
428 |
end; |
|
429 |
DeleteGear(Gear); |
|
113 | 430 |
OnUsedAmmo(PHedgehog(HHGear.Hedgehog)^.Ammo); |
431 |
ApplyAmmoChanges(PHedgehog(HHGear.Hedgehog)^) |
|
4 | 432 |
end; |
433 |
||
434 |
begin |
|
435 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
108 | 436 |
|
80 | 437 |
if ((HHGear.State and gstHHDriven) = 0) |
438 |
or (CheckGearDrowning(HHGear)) then |
|
4 | 439 |
begin |
440 |
DeleteMe; |
|
441 |
exit |
|
442 |
end; |
|
443 |
Gear.dX:= HHGear.X - Gear.X; |
|
444 |
Gear.dY:= HHGear.Y - Gear.Y; |
|
445 |
||
446 |
if (Gear.Message and gm_Left <> 0) then HHGear.dX:= HHGear.dX - 0.0002 else |
|
447 |
if (Gear.Message and gm_Right <> 0) then HHGear.dX:= HHGear.dX + 0.0002; |
|
448 |
||
449 |
if not TestCollisionYwithGear(HHGear, 1) then HHGear.dY:= HHGear.dY + cGravity; |
|
450 |
||
108 | 451 |
cs:= Gear.dY + HHGear.dY; |
452 |
cc:= Gear.dX + HHGear.dX; |
|
453 |
len:= 1 / sqrt(sqr(cc)+sqr(cs)); |
|
454 |
cc:= cc * len; |
|
455 |
cs:= cs * len; |
|
4 | 456 |
|
457 |
flCheck:= not flCheck; |
|
458 |
if flCheck then // check whether rope needs dividing |
|
459 |
begin |
|
460 |
len:= Gear.Elasticity - 20; |
|
461 |
while len > 5 do |
|
462 |
begin |
|
463 |
tx:= cc*len; |
|
464 |
ty:= cs*len; |
|
108 | 465 |
lx:= round(Gear.X + tx) + hwSign(HHGear.dX); |
466 |
ly:= round(Gear.Y + ty) + hwSign(HHGear.dY); |
|
4 | 467 |
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0)and (Land[ly, lx] <> 0) then |
468 |
begin |
|
469 |
with RopePoints.ar[RopePoints.Count] do |
|
470 |
begin |
|
471 |
X:= Gear.X; |
|
472 |
Y:= Gear.Y; |
|
473 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle32(Gear.dY, Gear.dX); |
|
474 |
b:= (cc * HHGear.dY) > (cs * HHGear.dX); |
|
475 |
dLen:= len |
|
476 |
end; |
|
477 |
Gear.X:= Gear.X + tx; |
|
478 |
Gear.Y:= Gear.Y + ty; |
|
479 |
inc(RopePoints.Count); |
|
480 |
Gear.Elasticity:= Gear.Elasticity - len; |
|
481 |
Gear.Friction:= Gear.Friction - len; |
|
482 |
break |
|
483 |
end; |
|
484 |
len:= len - 3 |
|
485 |
end; |
|
486 |
end else |
|
487 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
|
488 |
begin |
|
489 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
490 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
491 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear.X) * (ty - HHGear.Y) > (tx - HHGear.X) * (ty - Gear.Y)) then |
|
492 |
begin |
|
493 |
dec(RopePoints.Count); |
|
494 |
Gear.X:=RopePoints.ar[RopePoints.Count].X; |
|
495 |
Gear.Y:=RopePoints.ar[RopePoints.Count].Y; |
|
496 |
Gear.Elasticity:= Gear.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
|
497 |
Gear.Friction:= Gear.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
498 |
end |
|
499 |
end; |
|
500 |
||
501 |
Gear.dX:= HHGear.X - Gear.X; |
|
502 |
Gear.dY:= HHGear.Y - Gear.Y; |
|
108 | 503 |
|
504 |
cs:= Gear.dY + HHGear.dY; |
|
505 |
cc:= Gear.dX + HHGear.dX; |
|
506 |
len:= 1 / sqrt(sqr(cc)+sqr(cs)); |
|
507 |
cc:= cc * len; |
|
508 |
cs:= cs * len; |
|
4 | 509 |
|
510 |
HHGear.dX:= HHGear.X; |
|
511 |
HHGear.dY:= HHGear.Y; |
|
512 |
||
513 |
if ((Gear.Message and gm_Down) <> 0) and (Gear.Elasticity < Gear.Friction) then |
|
108 | 514 |
if not (TestCollisionXwithGear(HHGear, hwSign(Gear.dX)) |
515 |
or TestCollisionYwithGear(HHGear, hwSign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity + 0.3; |
|
4 | 516 |
|
517 |
if ((Gear.Message and gm_Up) <> 0) and (Gear.Elasticity > 30) then |
|
108 | 518 |
if not (TestCollisionXwithGear(HHGear, -hwSign(Gear.dX)) |
519 |
or TestCollisionYwithGear(HHGear, -hwSign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity - 0.3; |
|
4 | 520 |
|
521 |
HHGear.X:= Gear.X + cc*Gear.Elasticity; |
|
522 |
HHGear.Y:= Gear.Y + cs*Gear.Elasticity; |
|
523 |
||
524 |
HHGear.dX:= HHGear.X - HHGear.dX; |
|
525 |
HHGear.dY:= HHGear.Y - HHGear.dY; |
|
526 |
||
108 | 527 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then |
75 | 528 |
HHGear.dX:= -0.6 * HHGear.dX; |
108 | 529 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear.dY)) then |
75 | 530 |
HHGear.dY:= -0.6 * HHGear.dY; |
4 | 531 |
|
532 |
if (Gear.Message and gm_Attack) <> 0 then |
|
533 |
if (Gear.State and gsttmpFlag) <> 0 then DeleteMe else |
|
534 |
else if (Gear.State and gsttmpFlag) = 0 then Gear.State:= Gear.State or gsttmpFlag; |
|
535 |
end; |
|
536 |
||
537 |
||
538 |
procedure doStepRopeAttach(Gear: PGear); |
|
539 |
var HHGear: PGear; |
|
107 | 540 |
tx, ty, tt: Double; |
4 | 541 |
begin |
113 | 542 |
Gear.X:= Gear.X - Gear.dX; |
543 |
Gear.Y:= Gear.Y - Gear.dY; |
|
4 | 544 |
Gear.Elasticity:= Gear.Elasticity + 1.0; |
545 |
HHGear:= PHedgehog(Gear.Hedgehog)^.Gear; |
|
546 |
if (HHGear.State and gstFalling) <> 0 then |
|
68 | 547 |
if TestCollisionYwithGear(HHGear, 1) then |
4 | 548 |
begin |
549 |
HHGear.dY:= 0; |
|
550 |
CheckHHDamage(HHGear); |
|
551 |
HHGear.State:= HHGear.State and not (gstFalling or gstHHJumping); |
|
552 |
end else |
|
553 |
begin |
|
108 | 554 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then HHGear.dX:= 0.0000001 * hwSign(HHGear.dX); |
4 | 555 |
HHGear.X:= HHGear.X + HHGear.dX; |
556 |
HHGear.Y:= HHGear.Y + HHGear.dY; |
|
557 |
Gear.X:= Gear.X + HHGear.dX; |
|
558 |
Gear.Y:= Gear.Y + HHGear.dY; |
|
559 |
HHGear.dY:= HHGear.dY + cGravity; |
|
560 |
tt:= Gear.Elasticity; |
|
561 |
tx:= 0; |
|
562 |
ty:= 0; |
|
563 |
while tt > 20 do |
|
564 |
begin |
|
108 | 565 |
if TestCollisionXwithXYShift(Gear, round(tx), round(ty), hwSign(Gear.dX)) |
566 |
or TestCollisionYwithXYShift(Gear, round(tx), round(ty), hwSign(Gear.dY)) then |
|
4 | 567 |
begin |
568 |
Gear.X:= Gear.X + tx; |
|
569 |
Gear.Y:= Gear.Y + ty; |
|
570 |
Gear.Elasticity:= tt; |
|
571 |
Gear.doStep:= doStepRopeWork; |
|
572 |
with HHGear^ do State:= State and not gstAttacking; |
|
573 |
tt:= 0 |
|
574 |
end; |
|
113 | 575 |
tx:= tx + Gear.dX - Gear.dX; |
576 |
ty:= ty + Gear.dY - Gear.dY; |
|
4 | 577 |
tt:= tt - 2.0; |
578 |
end; |
|
579 |
end; |
|
580 |
CheckCollision(Gear); |
|
581 |
if (Gear.State and gstCollision) <> 0 then |
|
582 |
begin |
|
583 |
Gear.doStep:= doStepRopeWork; |
|
584 |
with HHGear^ do State:= State and not gstAttacking; |
|
585 |
if Gear.Elasticity < 10 then |
|
586 |
Gear.Elasticity:= 10000; |
|
587 |
end; |
|
588 |
||
589 |
if (Gear.Elasticity >= Gear.Friction) or ((Gear.Message and gm_Attack) = 0) then |
|
590 |
begin |
|
591 |
with PHedgehog(Gear.Hedgehog).Gear^ do |
|
592 |
begin |
|
593 |
State:= State and not gstAttacking; |
|
594 |
Message:= Message and not gm_Attack |
|
595 |
end; |
|
596 |
DeleteGear(Gear) |
|
597 |
end |
|
598 |
end; |
|
599 |
||
600 |
procedure doStepRope(Gear: PGear); |
|
601 |
begin |
|
113 | 602 |
Gear.dX:= - Gear.dX; |
603 |
Gear.dY:= - Gear.dY; |
|
4 | 604 |
Gear.doStep:= doStepRopeAttach |
605 |
end; |
|
606 |
||
607 |
//////////////////////////////////////////////////////////////////////////////// |
|
608 |
procedure doStepSmokeTrace(Gear: PGear); |
|
609 |
begin |
|
610 |
inc(Gear.Timer); |
|
611 |
if Gear.Timer > 64 then |
|
612 |
begin |
|
613 |
Gear.Timer:= 0; |
|
9 | 614 |
dec(Gear.State) |
4 | 615 |
end; |
616 |
Gear.dX:= Gear.dX + cWindSpeed; |
|
617 |
Gear.X:= Gear.X + Gear.dX; |
|
9 | 618 |
if Gear.State = 0 then DeleteGear(Gear) |
4 | 619 |
end; |
9 | 620 |
|
621 |
//////////////////////////////////////////////////////////////////////////////// |
|
622 |
procedure doStepExplosion(Gear: PGear); |
|
623 |
begin |
|
624 |
inc(Gear.Timer); |
|
625 |
if Gear.Timer > 75 then |
|
626 |
begin |
|
627 |
inc(Gear.State); |
|
628 |
Gear.Timer:= 0; |
|
629 |
if Gear.State > 5 then DeleteGear(Gear) |
|
630 |
end; |
|
631 |
end; |
|
10 | 632 |
|
633 |
//////////////////////////////////////////////////////////////////////////////// |
|
634 |
procedure doStepMine(Gear: PGear); |
|
635 |
begin |
|
39 | 636 |
if (Gear.dX <> 0) or (Gear.dY <> 0) then |
10 | 637 |
begin |
53 | 638 |
if Gear.CollIndex < High(Longword) then DeleteCI(Gear); |
10 | 639 |
doStepFallingGear(Gear); |
13 | 640 |
if Gear.Active = false then |
641 |
begin |
|
53 | 642 |
if Gear.CollIndex = High(Longword) then AddGearCI(Gear); |
13 | 643 |
Gear.dX:= 0; |
644 |
Gear.dY:= 0 |
|
645 |
end; |
|
646 |
CalcRotationDirAngle(Gear); |
|
10 | 647 |
AllInactive:= false |
648 |
end; |
|
39 | 649 |
|
10 | 650 |
if ((Gear.State and gsttmpFlag) <> 0) then |
651 |
if ((Gear.State and gstAttacking) = 0) then |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
652 |
begin |
39 | 653 |
if ((GameTicks and $F) = 0) then |
15 | 654 |
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
|
655 |
end else // gstAttacking <> 0 |
10 | 656 |
begin |
657 |
AllInactive:= false; |
|
37 | 658 |
if (Gear.Timer and $FF) = 0 then PlaySound(sndMineTick); |
10 | 659 |
if Gear.Timer = 0 then |
660 |
begin |
|
13 | 661 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound); |
10 | 662 |
DeleteGear(Gear) |
663 |
end; |
|
13 | 664 |
dec(Gear.Timer); |
665 |
end else // gsttmpFlag = 0 |
|
666 |
if TurnTimeLeft = 0 then Gear.State:= Gear.State or gsttmpFlag; |
|
10 | 667 |
end; |
57 | 668 |
|
39 | 669 |
//////////////////////////////////////////////////////////////////////////////// |
670 |
procedure doStepDynamite(Gear: PGear); |
|
671 |
begin |
|
43 | 672 |
doStepFallingGear(Gear); |
673 |
AllInactive:= false; |
|
674 |
if Gear.Timer mod 166 = 0 then inc(Gear.Tag); |
|
675 |
if Gear.Timer = 0 then |
|
39 | 676 |
begin |
46 | 677 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 75, EXPLAutoSound); |
43 | 678 |
DeleteGear(Gear); |
679 |
exit |
|
39 | 680 |
end; |
43 | 681 |
dec(Gear.Timer); |
39 | 682 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
683 |
|
15 | 684 |
//////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
685 |
procedure doStepCase(Gear: PGear); |
89 | 686 |
var i, x, y: integer; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
687 |
begin |
15 | 688 |
if (Gear.Message and gm_Destroy) > 0 then |
689 |
begin |
|
690 |
DeleteGear(Gear); |
|
691 |
exit |
|
692 |
end; |
|
693 |
||
79 | 694 |
if Gear.Damage > 0 then |
695 |
begin |
|
89 | 696 |
x:= round(Gear.X); |
697 |
y:= round(Gear.Y); |
|
79 | 698 |
DeleteGear(Gear); |
89 | 699 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
79 | 700 |
for i:= 0 to 63 do |
89 | 701 |
AddGear(x, y, gtFlame, 0); |
79 | 702 |
exit |
703 |
end; |
|
704 |
||
53 | 705 |
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
|
706 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
707 |
AllInactive:= false; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
708 |
Gear.dY:= Gear.dY + cGravity; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
709 |
Gear.Y:= Gear.Y + Gear.dY; |
53 | 710 |
if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0 else |
711 |
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
|
712 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
713 |
Gear.dY:= - Gear.dY * Gear.Elasticity; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
714 |
if Gear.dY > - 0.001 then Gear.dY:= 0 |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
715 |
else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
716 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
717 |
CheckGearDrowning(Gear); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
718 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
719 |
|
53 | 720 |
if (Gear.CollIndex = High(Longword)) and (Gear.dY = 0) then AddGearCI(Gear) |
721 |
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
|
722 |
end; |
49 | 723 |
|
724 |
//////////////////////////////////////////////////////////////////////////////// |
|
725 |
var thexchar: array[0..5] of record |
|
726 |
oy, ny: integer; |
|
727 |
team: PTeam; |
|
728 |
end; |
|
729 |
thexchcnt: Longword; |
|
143 | 730 |
currsorter: PGear; |
49 | 731 |
|
732 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
733 |
var i: integer; |
|
734 |
begin |
|
735 |
AllInactive:= false; |
|
736 |
dec(Gear.Timer); |
|
737 |
if (Gear.Timer and 15) = 0 then |
|
738 |
for i:= 0 to Pred(thexchcnt) do |
|
739 |
with thexchar[i] do |
|
740 |
{$WARNINGS OFF} |
|
741 |
team.DrawHealthY:= ny + (oy - ny) * Gear.Timer div 640; |
|
742 |
{$WARNINGS ON} |
|
143 | 743 |
if (Gear.Timer = 0) or (currsorter <> Gear) then |
744 |
begin |
|
745 |
if currsorter = Gear then currsorter:= nil; |
|
49 | 746 |
DeleteGear(Gear) |
143 | 747 |
end |
49 | 748 |
end; |
749 |
||
750 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
751 |
var team: PTeam; |
|
752 |
i, t: Longword; |
|
753 |
begin |
|
754 |
AllInactive:= false; |
|
755 |
team:= TeamsList; |
|
756 |
i:= 0; |
|
757 |
while team <> nil do |
|
758 |
begin |
|
759 |
thexchar[i].oy:= team.DrawHealthY; |
|
760 |
thexchar[i].team:= team; |
|
761 |
inc(i); |
|
762 |
team:= team.Next |
|
763 |
end; |
|
764 |
thexchcnt:= i; |
|
765 |
for i:= 1 to thexchcnt do |
|
766 |
for t:= 0 to thexchcnt - 2 do |
|
146 | 767 |
if thexchar[t].team.TeamHealthBarWidth > thexchar[Succ(t)].team.TeamHealthBarWidth then |
49 | 768 |
begin |
769 |
thexchar[5]:= thexchar[t]; |
|
770 |
thexchar[t]:= thexchar[Succ(t)]; |
|
771 |
thexchar[Succ(t)]:= thexchar[5] |
|
772 |
end; |
|
773 |
t:= cScreenHeight - 4; |
|
774 |
for i:= 0 to Pred(thexchcnt) do |
|
775 |
with thexchar[i] do |
|
776 |
begin |
|
777 |
dec(t, team.HealthRect.h + 2); |
|
778 |
ny:= t |
|
779 |
end; |
|
780 |
Gear.Timer:= 640; |
|
143 | 781 |
Gear.doStep:= doStepTeamHealthSorterWork; |
782 |
currsorter:= Gear |
|
49 | 783 |
end; |
784 |
||
79 | 785 |
//////////////////////////////////////////////////////////////////////////////// |
786 |
procedure doStepShover(Gear: PGear); |
|
787 |
var HHGear: PGear; |
|
788 |
begin |
|
789 |
HHGear:= PHedgehog(Gear.Hedgehog)^.Gear; |
|
790 |
HHGear.State:= HHGear.State or gstNoDamage; |
|
791 |
AmmoShove(Gear, 30, 115); |
|
792 |
HHGear.State:= HHGear.State and not gstNoDamage; |
|
793 |
DeleteGear(Gear) |
|
794 |
end; |
|
795 |
||
796 |
//////////////////////////////////////////////////////////////////////////////// |
|
797 |
procedure doStepFlame(Gear: PGear); |
|
798 |
begin |
|
799 |
AllInactive:= false; |
|
800 |
if not TestCollisionYwithGear(Gear, 1) then |
|
801 |
begin |
|
802 |
Gear.dX:= Gear.dX + cWindSpeed; |
|
803 |
Gear.dY:= Gear.dY + cGravity; |
|
804 |
if abs(Gear.dX) > 0.12 then Gear.dX:= Gear.dX * 0.5; |
|
805 |
if Gear.dY > 0.12 then Gear.dY:= Gear.dY * 0.995; |
|
806 |
Gear.X:= Gear.X + Gear.dX; |
|
807 |
Gear.Y:= Gear.Y + Gear.dY; |
|
808 |
if Gear.Y > 1023 then |
|
809 |
begin |
|
810 |
DeleteGear(Gear); |
|
811 |
exit |
|
812 |
end |
|
813 |
end else begin |
|
814 |
if Gear.Timer > 0 then dec(Gear.Timer) |
|
815 |
else begin |
|
816 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 2, 0); |
|
817 |
dec(Gear.Health); |
|
818 |
Gear.Timer:= 1250 - Gear.Angle * 12 |
|
819 |
end |
|
820 |
end; |
|
821 |
||
822 |
if (((GameTicks div 8) mod 64) = Gear.Angle) then |
|
823 |
AmmoFlameWork(Gear); |
|
824 |
||
82 | 825 |
if Gear.Health = 0 then |
79 | 826 |
DeleteGear(Gear) |
827 |
end; |
|
82 | 828 |
|
829 |
//////////////////////////////////////////////////////////////////////////////// |
|
830 |
procedure doStepFirePunchWork(Gear: PGear); |
|
831 |
var HHGear: PGear; |
|
832 |
begin |
|
833 |
AllInactive:= false; |
|
834 |
if ((Gear.Message and gm_Destroy) <> 0) then |
|
835 |
begin |
|
836 |
DeleteGear(Gear); |
|
837 |
AfterAttack; |
|
838 |
exit |
|
839 |
end; |
|
840 |
||
841 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
842 |
if round(HHGear.Y) <= Gear.Tag - 2 then |
|
843 |
begin |
|
844 |
Gear.Tag:= round(HHGear.Y); |
|
845 |
DrawTunnel(HHGear.X - cHHRadius, HHGear.Y - 1, 0.5, 0.0, cHHRadius * 4, 2); |
|
846 |
HHGear.State:= HHGear.State or gstNoDamage; |
|
847 |
Gear.Y:= HHGear.Y; |
|
848 |
AmmoShove(Gear, 30, 40); |
|
849 |
HHGear.State:= HHGear.State and not gstNoDamage |
|
850 |
end; |
|
851 |
||
852 |
HHGear.dY:= HHGear.dY + cGravity; |
|
853 |
if HHGear.dY >= 0 then |
|
854 |
begin |
|
855 |
HHGear.State:= HHGear.State or gstFalling; |
|
856 |
DeleteGear(Gear); |
|
857 |
AfterAttack; |
|
858 |
exit |
|
859 |
end; |
|
860 |
HHGear.Y:= HHGear.Y + HHGear.dY |
|
861 |
end; |
|
862 |
||
863 |
procedure doStepFirePunch(Gear: PGear); |
|
864 |
var HHGear: PGear; |
|
865 |
begin |
|
866 |
AllInactive:= false; |
|
867 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
868 |
HHGear.X:= round(HHGear.X) - 0.5; |
|
108 | 869 |
HHGear.dX:= 0.0000001 * hwSign(HHGear.dX); |
82 | 870 |
HHGear.dY:= -0.30; |
871 |
||
872 |
Gear.X:= HHGear.X; |
|
108 | 873 |
Gear.dX:= hwSign(HHGear.dX)* 0.45; |
82 | 874 |
Gear.dY:= -0.9; |
875 |
Gear.doStep:= doStepFirePunchWork; |
|
876 |
DrawTunnel(HHGear.X - cHHRadius, HHGear.Y + 1, 0.5, 0.0, cHHRadius * 4, 5); |
|
877 |
end; |
|
878 |
||
211 | 879 |
procedure doStepParachute(Gear: PGear); |
880 |
var HHGear: PGear; |
|
881 |
begin |
|
882 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
212 | 883 |
HHGear.State:= HHGear.State and not gstAttacking; |
82 | 884 |
|
212 | 885 |
if TestCollisionYwithGear(HHGear, 1) |
886 |
or ((HHGear.State and gstHHDriven) = 0) |
|
887 |
or CheckGearDrowning(HHGear) then |
|
211 | 888 |
begin |
889 |
with HHGear^ do |
|
890 |
begin |
|
891 |
Message:= 0; |
|
892 |
dx:= 0.0000001 * hwSign(dX); |
|
893 |
dY:= 0; |
|
894 |
State:= State and not (gstAttacking or gstAttacked); |
|
895 |
State:= State or gstFalling; |
|
896 |
end; |
|
897 |
DeleteGear(Gear); |
|
898 |
OnUsedAmmo(PHedgehog(HHGear.Hedgehog)^.Ammo); |
|
899 |
ApplyAmmoChanges(PHedgehog(HHGear.Hedgehog)^); |
|
900 |
exit |
|
901 |
end; |
|
902 |
||
903 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then |
|
904 |
HHGear.X:= HHGear.X + cWindSpeed * 200; |
|
905 |
||
906 |
if (Gear.Message and gm_Left) <> 0 then HHGear.X:= HHGear.X - cMaxWindSpeed * 40 |
|
907 |
else if (Gear.Message and gm_Right) <> 0 then HHGear.X:= HHGear.X + cMaxWindSpeed * 40; |
|
908 |
if (Gear.Message and gm_Up) <> 0 then HHGear.Y:= HHGear.Y - cGravity * 40 |
|
909 |
else if (Gear.Message and gm_Down) <> 0 then HHGear.Y:= HHGear.Y + cGravity * 40; |
|
910 |
||
911 |
HHGear.Y:= HHGear.Y + cGravity * 100; |
|
912 |
||
913 |
end; |
|
914 |
||
915 |