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