author | unc0rr |
Tue, 28 Nov 2006 17:14:39 +0000 | |
changeset 282 | b1e3387389b6 |
parent 263 | 36379e6abcdd |
child 283 | 28d105f378f1 |
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; |
|
219 | 385 |
HHGear.dX:= 0.0000001 * hwSign(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 |
//////////////////////////////////////////////////////////////////////////////// |
|
427 |
procedure doStepRopeWork(Gear: PGear); |
|
70 | 428 |
const flCheck: boolean = false; |
4 | 429 |
var HHGear: PGear; |
107 | 430 |
len, cs, cc, tx, ty: Double; |
108 | 431 |
lx, ly: LongInt; |
4 | 432 |
|
433 |
procedure DeleteMe; |
|
434 |
begin |
|
435 |
with HHGear^ do |
|
436 |
begin |
|
437 |
Message:= Message and not gm_Attack; |
|
438 |
State:= State or gstFalling; |
|
439 |
end; |
|
440 |
DeleteGear(Gear); |
|
113 | 441 |
OnUsedAmmo(PHedgehog(HHGear.Hedgehog)^.Ammo); |
442 |
ApplyAmmoChanges(PHedgehog(HHGear.Hedgehog)^) |
|
4 | 443 |
end; |
444 |
||
445 |
begin |
|
446 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
108 | 447 |
|
80 | 448 |
if ((HHGear.State and gstHHDriven) = 0) |
449 |
or (CheckGearDrowning(HHGear)) then |
|
4 | 450 |
begin |
451 |
DeleteMe; |
|
452 |
exit |
|
453 |
end; |
|
454 |
Gear.dX:= HHGear.X - Gear.X; |
|
455 |
Gear.dY:= HHGear.Y - Gear.Y; |
|
456 |
||
457 |
if (Gear.Message and gm_Left <> 0) then HHGear.dX:= HHGear.dX - 0.0002 else |
|
458 |
if (Gear.Message and gm_Right <> 0) then HHGear.dX:= HHGear.dX + 0.0002; |
|
459 |
||
460 |
if not TestCollisionYwithGear(HHGear, 1) then HHGear.dY:= HHGear.dY + cGravity; |
|
461 |
||
108 | 462 |
cs:= Gear.dY + HHGear.dY; |
463 |
cc:= Gear.dX + HHGear.dX; |
|
464 |
len:= 1 / sqrt(sqr(cc)+sqr(cs)); |
|
465 |
cc:= cc * len; |
|
466 |
cs:= cs * len; |
|
4 | 467 |
|
468 |
flCheck:= not flCheck; |
|
469 |
if flCheck then // check whether rope needs dividing |
|
470 |
begin |
|
471 |
len:= Gear.Elasticity - 20; |
|
472 |
while len > 5 do |
|
473 |
begin |
|
474 |
tx:= cc*len; |
|
475 |
ty:= cs*len; |
|
108 | 476 |
lx:= round(Gear.X + tx) + hwSign(HHGear.dX); |
477 |
ly:= round(Gear.Y + ty) + hwSign(HHGear.dY); |
|
4 | 478 |
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0)and (Land[ly, lx] <> 0) then |
479 |
begin |
|
480 |
with RopePoints.ar[RopePoints.Count] do |
|
481 |
begin |
|
482 |
X:= Gear.X; |
|
483 |
Y:= Gear.Y; |
|
484 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle32(Gear.dY, Gear.dX); |
|
485 |
b:= (cc * HHGear.dY) > (cs * HHGear.dX); |
|
486 |
dLen:= len |
|
487 |
end; |
|
488 |
Gear.X:= Gear.X + tx; |
|
489 |
Gear.Y:= Gear.Y + ty; |
|
490 |
inc(RopePoints.Count); |
|
491 |
Gear.Elasticity:= Gear.Elasticity - len; |
|
492 |
Gear.Friction:= Gear.Friction - len; |
|
493 |
break |
|
494 |
end; |
|
495 |
len:= len - 3 |
|
496 |
end; |
|
497 |
end else |
|
498 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
|
499 |
begin |
|
500 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
501 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
502 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear.X) * (ty - HHGear.Y) > (tx - HHGear.X) * (ty - Gear.Y)) then |
|
503 |
begin |
|
504 |
dec(RopePoints.Count); |
|
505 |
Gear.X:=RopePoints.ar[RopePoints.Count].X; |
|
506 |
Gear.Y:=RopePoints.ar[RopePoints.Count].Y; |
|
507 |
Gear.Elasticity:= Gear.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
|
508 |
Gear.Friction:= Gear.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
509 |
end |
|
510 |
end; |
|
511 |
||
512 |
Gear.dX:= HHGear.X - Gear.X; |
|
513 |
Gear.dY:= HHGear.Y - Gear.Y; |
|
108 | 514 |
|
515 |
cs:= Gear.dY + HHGear.dY; |
|
516 |
cc:= Gear.dX + HHGear.dX; |
|
517 |
len:= 1 / sqrt(sqr(cc)+sqr(cs)); |
|
518 |
cc:= cc * len; |
|
519 |
cs:= cs * len; |
|
4 | 520 |
|
521 |
HHGear.dX:= HHGear.X; |
|
522 |
HHGear.dY:= HHGear.Y; |
|
523 |
||
524 |
if ((Gear.Message and gm_Down) <> 0) and (Gear.Elasticity < Gear.Friction) then |
|
108 | 525 |
if not (TestCollisionXwithGear(HHGear, hwSign(Gear.dX)) |
526 |
or TestCollisionYwithGear(HHGear, hwSign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity + 0.3; |
|
4 | 527 |
|
528 |
if ((Gear.Message and gm_Up) <> 0) and (Gear.Elasticity > 30) then |
|
108 | 529 |
if not (TestCollisionXwithGear(HHGear, -hwSign(Gear.dX)) |
530 |
or TestCollisionYwithGear(HHGear, -hwSign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity - 0.3; |
|
4 | 531 |
|
532 |
HHGear.X:= Gear.X + cc*Gear.Elasticity; |
|
533 |
HHGear.Y:= Gear.Y + cs*Gear.Elasticity; |
|
534 |
||
535 |
HHGear.dX:= HHGear.X - HHGear.dX; |
|
536 |
HHGear.dY:= HHGear.Y - HHGear.dY; |
|
537 |
||
108 | 538 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then |
75 | 539 |
HHGear.dX:= -0.6 * HHGear.dX; |
108 | 540 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear.dY)) then |
75 | 541 |
HHGear.dY:= -0.6 * HHGear.dY; |
4 | 542 |
|
543 |
if (Gear.Message and gm_Attack) <> 0 then |
|
544 |
if (Gear.State and gsttmpFlag) <> 0 then DeleteMe else |
|
545 |
else if (Gear.State and gsttmpFlag) = 0 then Gear.State:= Gear.State or gsttmpFlag; |
|
546 |
end; |
|
547 |
||
548 |
||
549 |
procedure doStepRopeAttach(Gear: PGear); |
|
550 |
var HHGear: PGear; |
|
107 | 551 |
tx, ty, tt: Double; |
4 | 552 |
begin |
113 | 553 |
Gear.X:= Gear.X - Gear.dX; |
554 |
Gear.Y:= Gear.Y - Gear.dY; |
|
4 | 555 |
Gear.Elasticity:= Gear.Elasticity + 1.0; |
556 |
HHGear:= PHedgehog(Gear.Hedgehog)^.Gear; |
|
557 |
if (HHGear.State and gstFalling) <> 0 then |
|
68 | 558 |
if TestCollisionYwithGear(HHGear, 1) then |
4 | 559 |
begin |
560 |
HHGear.dY:= 0; |
|
561 |
CheckHHDamage(HHGear); |
|
562 |
HHGear.State:= HHGear.State and not (gstFalling or gstHHJumping); |
|
563 |
end else |
|
564 |
begin |
|
108 | 565 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then HHGear.dX:= 0.0000001 * hwSign(HHGear.dX); |
4 | 566 |
HHGear.X:= HHGear.X + HHGear.dX; |
567 |
HHGear.Y:= HHGear.Y + HHGear.dY; |
|
568 |
Gear.X:= Gear.X + HHGear.dX; |
|
569 |
Gear.Y:= Gear.Y + HHGear.dY; |
|
570 |
HHGear.dY:= HHGear.dY + cGravity; |
|
571 |
tt:= Gear.Elasticity; |
|
572 |
tx:= 0; |
|
573 |
ty:= 0; |
|
574 |
while tt > 20 do |
|
575 |
begin |
|
108 | 576 |
if TestCollisionXwithXYShift(Gear, round(tx), round(ty), hwSign(Gear.dX)) |
577 |
or TestCollisionYwithXYShift(Gear, round(tx), round(ty), hwSign(Gear.dY)) then |
|
4 | 578 |
begin |
579 |
Gear.X:= Gear.X + tx; |
|
580 |
Gear.Y:= Gear.Y + ty; |
|
581 |
Gear.Elasticity:= tt; |
|
582 |
Gear.doStep:= doStepRopeWork; |
|
583 |
with HHGear^ do State:= State and not gstAttacking; |
|
584 |
tt:= 0 |
|
585 |
end; |
|
113 | 586 |
tx:= tx + Gear.dX - Gear.dX; |
587 |
ty:= ty + Gear.dY - Gear.dY; |
|
4 | 588 |
tt:= tt - 2.0; |
589 |
end; |
|
590 |
end; |
|
591 |
CheckCollision(Gear); |
|
592 |
if (Gear.State and gstCollision) <> 0 then |
|
593 |
begin |
|
594 |
Gear.doStep:= doStepRopeWork; |
|
595 |
with HHGear^ do State:= State and not gstAttacking; |
|
596 |
if Gear.Elasticity < 10 then |
|
597 |
Gear.Elasticity:= 10000; |
|
598 |
end; |
|
599 |
||
600 |
if (Gear.Elasticity >= Gear.Friction) or ((Gear.Message and gm_Attack) = 0) then |
|
601 |
begin |
|
602 |
with PHedgehog(Gear.Hedgehog).Gear^ do |
|
603 |
begin |
|
604 |
State:= State and not gstAttacking; |
|
605 |
Message:= Message and not gm_Attack |
|
606 |
end; |
|
607 |
DeleteGear(Gear) |
|
608 |
end |
|
609 |
end; |
|
610 |
||
611 |
procedure doStepRope(Gear: PGear); |
|
612 |
begin |
|
113 | 613 |
Gear.dX:= - Gear.dX; |
614 |
Gear.dY:= - Gear.dY; |
|
4 | 615 |
Gear.doStep:= doStepRopeAttach |
616 |
end; |
|
617 |
||
618 |
//////////////////////////////////////////////////////////////////////////////// |
|
619 |
procedure doStepSmokeTrace(Gear: PGear); |
|
620 |
begin |
|
621 |
inc(Gear.Timer); |
|
622 |
if Gear.Timer > 64 then |
|
623 |
begin |
|
624 |
Gear.Timer:= 0; |
|
9 | 625 |
dec(Gear.State) |
4 | 626 |
end; |
627 |
Gear.dX:= Gear.dX + cWindSpeed; |
|
628 |
Gear.X:= Gear.X + Gear.dX; |
|
9 | 629 |
if Gear.State = 0 then DeleteGear(Gear) |
4 | 630 |
end; |
9 | 631 |
|
632 |
//////////////////////////////////////////////////////////////////////////////// |
|
633 |
procedure doStepExplosion(Gear: PGear); |
|
634 |
begin |
|
635 |
inc(Gear.Timer); |
|
636 |
if Gear.Timer > 75 then |
|
637 |
begin |
|
638 |
inc(Gear.State); |
|
639 |
Gear.Timer:= 0; |
|
640 |
if Gear.State > 5 then DeleteGear(Gear) |
|
641 |
end; |
|
642 |
end; |
|
10 | 643 |
|
644 |
//////////////////////////////////////////////////////////////////////////////// |
|
645 |
procedure doStepMine(Gear: PGear); |
|
646 |
begin |
|
39 | 647 |
if (Gear.dX <> 0) or (Gear.dY <> 0) then |
10 | 648 |
begin |
53 | 649 |
if Gear.CollIndex < High(Longword) then DeleteCI(Gear); |
10 | 650 |
doStepFallingGear(Gear); |
13 | 651 |
if Gear.Active = false then |
652 |
begin |
|
53 | 653 |
if Gear.CollIndex = High(Longword) then AddGearCI(Gear); |
13 | 654 |
Gear.dX:= 0; |
655 |
Gear.dY:= 0 |
|
656 |
end; |
|
657 |
CalcRotationDirAngle(Gear); |
|
10 | 658 |
AllInactive:= false |
659 |
end; |
|
39 | 660 |
|
10 | 661 |
if ((Gear.State and gsttmpFlag) <> 0) then |
662 |
if ((Gear.State and gstAttacking) = 0) then |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
663 |
begin |
39 | 664 |
if ((GameTicks and $F) = 0) then |
15 | 665 |
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
|
666 |
end else // gstAttacking <> 0 |
10 | 667 |
begin |
668 |
AllInactive:= false; |
|
37 | 669 |
if (Gear.Timer and $FF) = 0 then PlaySound(sndMineTick); |
10 | 670 |
if Gear.Timer = 0 then |
671 |
begin |
|
13 | 672 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound); |
10 | 673 |
DeleteGear(Gear) |
674 |
end; |
|
13 | 675 |
dec(Gear.Timer); |
676 |
end else // gsttmpFlag = 0 |
|
677 |
if TurnTimeLeft = 0 then Gear.State:= Gear.State or gsttmpFlag; |
|
10 | 678 |
end; |
57 | 679 |
|
39 | 680 |
//////////////////////////////////////////////////////////////////////////////// |
681 |
procedure doStepDynamite(Gear: PGear); |
|
682 |
begin |
|
43 | 683 |
doStepFallingGear(Gear); |
684 |
AllInactive:= false; |
|
685 |
if Gear.Timer mod 166 = 0 then inc(Gear.Tag); |
|
686 |
if Gear.Timer = 0 then |
|
39 | 687 |
begin |
46 | 688 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 75, EXPLAutoSound); |
43 | 689 |
DeleteGear(Gear); |
690 |
exit |
|
39 | 691 |
end; |
43 | 692 |
dec(Gear.Timer); |
39 | 693 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
694 |
|
15 | 695 |
//////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
696 |
procedure doStepCase(Gear: PGear); |
89 | 697 |
var i, x, y: integer; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
698 |
begin |
15 | 699 |
if (Gear.Message and gm_Destroy) > 0 then |
700 |
begin |
|
701 |
DeleteGear(Gear); |
|
702 |
exit |
|
703 |
end; |
|
704 |
||
79 | 705 |
if Gear.Damage > 0 then |
706 |
begin |
|
89 | 707 |
x:= round(Gear.X); |
708 |
y:= round(Gear.Y); |
|
79 | 709 |
DeleteGear(Gear); |
89 | 710 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
79 | 711 |
for i:= 0 to 63 do |
89 | 712 |
AddGear(x, y, gtFlame, 0); |
79 | 713 |
exit |
714 |
end; |
|
715 |
||
53 | 716 |
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
|
717 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
718 |
AllInactive:= false; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
719 |
Gear.dY:= Gear.dY + cGravity; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
720 |
Gear.Y:= Gear.Y + Gear.dY; |
53 | 721 |
if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0 else |
722 |
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
|
723 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
724 |
Gear.dY:= - Gear.dY * Gear.Elasticity; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
725 |
if Gear.dY > - 0.001 then Gear.dY:= 0 |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
726 |
else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
727 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
728 |
CheckGearDrowning(Gear); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
729 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
730 |
|
53 | 731 |
if (Gear.CollIndex = High(Longword)) and (Gear.dY = 0) then AddGearCI(Gear) |
732 |
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
|
733 |
end; |
49 | 734 |
|
735 |
//////////////////////////////////////////////////////////////////////////////// |
|
736 |
var thexchar: array[0..5] of record |
|
737 |
oy, ny: integer; |
|
738 |
team: PTeam; |
|
739 |
end; |
|
740 |
thexchcnt: Longword; |
|
143 | 741 |
currsorter: PGear; |
49 | 742 |
|
743 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
744 |
var i: integer; |
|
745 |
begin |
|
746 |
AllInactive:= false; |
|
747 |
dec(Gear.Timer); |
|
748 |
if (Gear.Timer and 15) = 0 then |
|
749 |
for i:= 0 to Pred(thexchcnt) do |
|
750 |
with thexchar[i] do |
|
751 |
{$WARNINGS OFF} |
|
752 |
team.DrawHealthY:= ny + (oy - ny) * Gear.Timer div 640; |
|
753 |
{$WARNINGS ON} |
|
143 | 754 |
if (Gear.Timer = 0) or (currsorter <> Gear) then |
755 |
begin |
|
756 |
if currsorter = Gear then currsorter:= nil; |
|
49 | 757 |
DeleteGear(Gear) |
143 | 758 |
end |
49 | 759 |
end; |
760 |
||
761 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
762 |
var team: PTeam; |
|
763 |
i, t: Longword; |
|
764 |
begin |
|
765 |
AllInactive:= false; |
|
766 |
team:= TeamsList; |
|
767 |
i:= 0; |
|
768 |
while team <> nil do |
|
769 |
begin |
|
770 |
thexchar[i].oy:= team.DrawHealthY; |
|
771 |
thexchar[i].team:= team; |
|
772 |
inc(i); |
|
773 |
team:= team.Next |
|
774 |
end; |
|
775 |
thexchcnt:= i; |
|
776 |
for i:= 1 to thexchcnt do |
|
777 |
for t:= 0 to thexchcnt - 2 do |
|
146 | 778 |
if thexchar[t].team.TeamHealthBarWidth > thexchar[Succ(t)].team.TeamHealthBarWidth then |
49 | 779 |
begin |
780 |
thexchar[5]:= thexchar[t]; |
|
781 |
thexchar[t]:= thexchar[Succ(t)]; |
|
782 |
thexchar[Succ(t)]:= thexchar[5] |
|
783 |
end; |
|
784 |
t:= cScreenHeight - 4; |
|
785 |
for i:= 0 to Pred(thexchcnt) do |
|
786 |
with thexchar[i] do |
|
787 |
begin |
|
788 |
dec(t, team.HealthRect.h + 2); |
|
789 |
ny:= t |
|
790 |
end; |
|
791 |
Gear.Timer:= 640; |
|
143 | 792 |
Gear.doStep:= doStepTeamHealthSorterWork; |
793 |
currsorter:= Gear |
|
49 | 794 |
end; |
795 |
||
79 | 796 |
//////////////////////////////////////////////////////////////////////////////// |
797 |
procedure doStepShover(Gear: PGear); |
|
798 |
var HHGear: PGear; |
|
799 |
begin |
|
800 |
HHGear:= PHedgehog(Gear.Hedgehog)^.Gear; |
|
801 |
HHGear.State:= HHGear.State or gstNoDamage; |
|
802 |
AmmoShove(Gear, 30, 115); |
|
803 |
HHGear.State:= HHGear.State and not gstNoDamage; |
|
804 |
DeleteGear(Gear) |
|
805 |
end; |
|
806 |
||
807 |
//////////////////////////////////////////////////////////////////////////////// |
|
808 |
procedure doStepFlame(Gear: PGear); |
|
809 |
begin |
|
810 |
AllInactive:= false; |
|
811 |
if not TestCollisionYwithGear(Gear, 1) then |
|
812 |
begin |
|
813 |
Gear.dX:= Gear.dX + cWindSpeed; |
|
814 |
Gear.dY:= Gear.dY + cGravity; |
|
815 |
if abs(Gear.dX) > 0.12 then Gear.dX:= Gear.dX * 0.5; |
|
816 |
if Gear.dY > 0.12 then Gear.dY:= Gear.dY * 0.995; |
|
817 |
Gear.X:= Gear.X + Gear.dX; |
|
818 |
Gear.Y:= Gear.Y + Gear.dY; |
|
819 |
if Gear.Y > 1023 then |
|
820 |
begin |
|
821 |
DeleteGear(Gear); |
|
822 |
exit |
|
823 |
end |
|
824 |
end else begin |
|
825 |
if Gear.Timer > 0 then dec(Gear.Timer) |
|
826 |
else begin |
|
827 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 2, 0); |
|
828 |
dec(Gear.Health); |
|
829 |
Gear.Timer:= 1250 - Gear.Angle * 12 |
|
830 |
end |
|
831 |
end; |
|
832 |
||
833 |
if (((GameTicks div 8) mod 64) = Gear.Angle) then |
|
834 |
AmmoFlameWork(Gear); |
|
835 |
||
82 | 836 |
if Gear.Health = 0 then |
79 | 837 |
DeleteGear(Gear) |
838 |
end; |
|
82 | 839 |
|
840 |
//////////////////////////////////////////////////////////////////////////////// |
|
841 |
procedure doStepFirePunchWork(Gear: PGear); |
|
842 |
var HHGear: PGear; |
|
843 |
begin |
|
844 |
AllInactive:= false; |
|
845 |
if ((Gear.Message and gm_Destroy) <> 0) then |
|
846 |
begin |
|
847 |
DeleteGear(Gear); |
|
848 |
AfterAttack; |
|
849 |
exit |
|
850 |
end; |
|
851 |
||
852 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
853 |
if round(HHGear.Y) <= Gear.Tag - 2 then |
|
854 |
begin |
|
855 |
Gear.Tag:= round(HHGear.Y); |
|
856 |
DrawTunnel(HHGear.X - cHHRadius, HHGear.Y - 1, 0.5, 0.0, cHHRadius * 4, 2); |
|
857 |
HHGear.State:= HHGear.State or gstNoDamage; |
|
858 |
Gear.Y:= HHGear.Y; |
|
859 |
AmmoShove(Gear, 30, 40); |
|
860 |
HHGear.State:= HHGear.State and not gstNoDamage |
|
861 |
end; |
|
862 |
||
863 |
HHGear.dY:= HHGear.dY + cGravity; |
|
864 |
if HHGear.dY >= 0 then |
|
865 |
begin |
|
866 |
HHGear.State:= HHGear.State or gstFalling; |
|
867 |
DeleteGear(Gear); |
|
868 |
AfterAttack; |
|
869 |
exit |
|
870 |
end; |
|
871 |
HHGear.Y:= HHGear.Y + HHGear.dY |
|
872 |
end; |
|
873 |
||
874 |
procedure doStepFirePunch(Gear: PGear); |
|
875 |
var HHGear: PGear; |
|
876 |
begin |
|
877 |
AllInactive:= false; |
|
878 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
879 |
HHGear.X:= round(HHGear.X) - 0.5; |
|
108 | 880 |
HHGear.dX:= 0.0000001 * hwSign(HHGear.dX); |
82 | 881 |
HHGear.dY:= -0.30; |
882 |
||
883 |
Gear.X:= HHGear.X; |
|
108 | 884 |
Gear.dX:= hwSign(HHGear.dX)* 0.45; |
82 | 885 |
Gear.dY:= -0.9; |
886 |
Gear.doStep:= doStepFirePunchWork; |
|
887 |
DrawTunnel(HHGear.X - cHHRadius, HHGear.Y + 1, 0.5, 0.0, cHHRadius * 4, 5); |
|
888 |
end; |
|
889 |
||
263 | 890 |
//////////////////////////////////////////////////////////////////////////////// |
891 |
||
211 | 892 |
procedure doStepParachute(Gear: PGear); |
893 |
var HHGear: PGear; |
|
894 |
begin |
|
895 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
212 | 896 |
HHGear.State:= HHGear.State and not gstAttacking; |
82 | 897 |
|
212 | 898 |
if TestCollisionYwithGear(HHGear, 1) |
899 |
or ((HHGear.State and gstHHDriven) = 0) |
|
900 |
or CheckGearDrowning(HHGear) then |
|
211 | 901 |
begin |
902 |
with HHGear^ do |
|
903 |
begin |
|
904 |
Message:= 0; |
|
905 |
dx:= 0.0000001 * hwSign(dX); |
|
906 |
dY:= 0; |
|
907 |
State:= State and not (gstAttacking or gstAttacked); |
|
908 |
State:= State or gstFalling; |
|
909 |
end; |
|
910 |
DeleteGear(Gear); |
|
911 |
OnUsedAmmo(PHedgehog(HHGear.Hedgehog)^.Ammo); |
|
912 |
ApplyAmmoChanges(PHedgehog(HHGear.Hedgehog)^); |
|
913 |
exit |
|
914 |
end; |
|
915 |
||
916 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then |
|
917 |
HHGear.X:= HHGear.X + cWindSpeed * 200; |
|
918 |
||
919 |
if (Gear.Message and gm_Left) <> 0 then HHGear.X:= HHGear.X - cMaxWindSpeed * 40 |
|
920 |
else if (Gear.Message and gm_Right) <> 0 then HHGear.X:= HHGear.X + cMaxWindSpeed * 40; |
|
921 |
if (Gear.Message and gm_Up) <> 0 then HHGear.Y:= HHGear.Y - cGravity * 40 |
|
922 |
else if (Gear.Message and gm_Down) <> 0 then HHGear.Y:= HHGear.Y + cGravity * 40; |
|
923 |
||
924 |
HHGear.Y:= HHGear.Y + cGravity * 100; |
|
263 | 925 |
end; |
211 | 926 |
|
263 | 927 |
//////////////////////////////////////////////////////////////////////////////// |
928 |
const cAirPlaneSpeed = 0.8; |
|
929 |
cBombsDistance = 30; |
|
930 |
cBombsSpeed = 0.1; |
|
931 |
||
932 |
procedure doStepAirAttackWork(Gear: PGear); |
|
933 |
begin |
|
934 |
AllInactive:= false; |
|
935 |
Gear.X:= Gear.X + cAirPlaneSpeed; |
|
936 |
if (Gear.Health > 0)and(Gear.X >= Gear.dX)and(Gear.X < Gear.dX + cAirPlaneSpeed) then |
|
937 |
begin |
|
938 |
dec(Gear.Health); |
|
939 |
AddGear(round(Gear.X), round(Gear.Y), gtAirBomb, 0, cBombsSpeed, 0.0); |
|
940 |
Gear.dX:= Gear.dX + cBombsDistance |
|
941 |
end; |
|
942 |
if Gear.X > 2560 then DeleteGear(Gear) |
|
943 |
end; |
|
944 |
||
945 |
procedure doStepAirAttack(Gear: PGear); |
|
946 |
begin |
|
947 |
AllInactive:= false; |
|
948 |
Gear.X:= -512; |
|
949 |
Gear.Y:= -128; |
|
950 |
Gear.dX:= TargetPoint.X - |
|
951 |
cBombsDistance * 5 / 2 - |
|
952 |
cBombsSpeed * sqrt(2 * (TargetPoint.Y - Gear.Y) / cGravity); |
|
953 |
Gear.Health:= 6; |
|
954 |
Gear.doStep:= doStepAirAttackWork |
|
955 |
end; |
|
956 |
||
957 |
//////////////////////////////////////////////////////////////////////////////// |
|
958 |
||
959 |
procedure doStepAirBomb(Gear: PGear); |
|
960 |
begin |
|
961 |
AllInactive:= false; |
|
962 |
doStepFallingGear(Gear); |
|
963 |
if (Gear.State and gstCollision) <> 0 then |
|
964 |
begin |
|
965 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 35, EXPLAutoSound); |
|
966 |
DeleteGear(Gear); |
|
967 |
exit |
|
968 |
end; |
|
969 |
if (GameTicks and $3F) = 0 then |
|
970 |
AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0) |
|
211 | 971 |
end; |
972 |
||
973 |