author | unc0rr |
Wed, 20 Sep 2006 18:24:13 +0000 | |
changeset 155 | 401f4ea24715 |
parent 146 | 458f4f58c1b6 |
child 161 | d8870bbf960e |
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 |
* |
5 |
* Distributed under the terms of the BSD-modified licence: |
|
6 |
* |
|
7 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
8 |
* of this software and associated documentation files (the "Software"), to deal |
|
9 |
* with the Software without restriction, including without limitation the |
|
10 |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
|
11 |
* sell copies of the Software, and to permit persons to whom the Software is |
|
12 |
* furnished to do so, subject to the following conditions: |
|
13 |
* |
|
14 |
* 1. Redistributions of source code must retain the above copyright notice, |
|
15 |
* this list of conditions and the following disclaimer. |
|
16 |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
|
17 |
* this list of conditions and the following disclaimer in the documentation |
|
18 |
* and/or other materials provided with the distribution. |
|
19 |
* 3. The name of the author may not be used to endorse or promote products |
|
20 |
* derived from this software without specific prior written permission. |
|
21 |
* |
|
22 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
|
23 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
24 |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
|
25 |
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
26 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
27 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
|
28 |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|
29 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
|
30 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|
31 |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
32 |
*) |
|
33 |
||
34 |
procedure doStepDrowningGear(Gear: PGear); forward; |
|
35 |
||
36 |
function CheckGearDrowning(Gear: PGear): boolean; |
|
37 |
begin |
|
53 | 38 |
Result:= Gear.Y + Gear.Radius >= cWaterLine; |
4 | 39 |
if Result then |
40 |
begin |
|
41 |
Gear.State:= gstDrowning; |
|
42 |
Gear.doStep:= doStepDrowningGear; |
|
43 |
PlaySound(sndSplash) |
|
44 |
end |
|
45 |
end; |
|
46 |
||
47 |
procedure CheckCollision(Gear: PGear); |
|
48 |
begin |
|
108 | 49 |
if TestCollisionXwithGear(Gear, hwSign(Gear.X)) or TestCollisionYwithGear(Gear, hwSign(Gear.Y)) |
4 | 50 |
then Gear.State:= Gear.State or gstCollision |
51 |
else Gear.State:= Gear.State and not gstCollision |
|
52 |
end; |
|
53 |
||
54 |
procedure CheckHHDamage(Gear: PGear); |
|
55 |
begin |
|
71 | 56 |
if Gear.dY > 0.40 then Gear.Damage:= Gear.Damage + 1 + round(70 * (abs(Gear.dY) - 0.40)); |
4 | 57 |
end; |
58 |
||
59 |
//////////////////////////////////////////////////////////////////////////////// |
|
60 |
//////////////////////////////////////////////////////////////////////////////// |
|
61 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
107 | 62 |
var dAngle: Double; |
4 | 63 |
begin |
64 |
dAngle:= (abs(Gear.dX) + abs(Gear.dY))*0.1; |
|
65 |
if Gear.dX >= 0 then Gear.DirAngle:= Gear.DirAngle + dAngle |
|
66 |
else Gear.DirAngle:= Gear.DirAngle - dAngle; |
|
67 |
if Gear.DirAngle < 0 then Gear.DirAngle:= Gear.DirAngle + 16 |
|
68 |
else if Gear.DirAngle >= 16 then Gear.DirAngle:= Gear.DirAngle - 16 |
|
69 |
end; |
|
70 |
||
71 |
//////////////////////////////////////////////////////////////////////////////// |
|
72 |
procedure doStepDrowningGear(Gear: PGear); |
|
73 |
begin |
|
74 |
AllInactive:= false; |
|
75 |
Gear.Y:= Gear.Y + cDrownSpeed; |
|
75 | 76 |
if round(Gear.Y) > Gear.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear) |
4 | 77 |
end; |
78 |
||
79 |
//////////////////////////////////////////////////////////////////////////////// |
|
80 |
procedure doStepFallingGear(Gear: PGear); |
|
81 |
var b: boolean; |
|
82 |
begin |
|
108 | 83 |
if TestCollisionYwithGear(Gear, hwSign(Gear.dY)) then |
4 | 84 |
begin |
85 |
Gear.dX:= Gear.dX * Gear.Friction; |
|
86 |
Gear.dY:= - Gear.dY * Gear.Elasticity; |
|
87 |
b:= false |
|
88 |
end else b:= true; |
|
108 | 89 |
if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then |
4 | 90 |
begin |
91 |
Gear.dX:= - Gear.dX * Gear.Elasticity; |
|
92 |
// Gear.dY:= Gear.dY; |
|
93 |
b:= false |
|
94 |
end; |
|
95 |
if b then |
|
96 |
begin |
|
97 |
Gear.dY:= Gear.dY + cGravity; |
|
98 |
Gear.State:= Gear.State and not gstCollision |
|
99 |
end else |
|
100 |
begin |
|
101 |
if sqr(Gear.dX) + sqr(Gear.dY) < 0.00001 then |
|
102 |
if (Gear.Timer = 0) then Gear.Active:= false |
|
103 |
else begin |
|
104 |
Gear.dX:= 0; |
|
105 |
Gear.dY:= 0 |
|
106 |
end; |
|
107 |
Gear.State:= Gear.State or gstCollision |
|
108 |
end; |
|
109 |
Gear.X:= Gear.X + Gear.dX; |
|
110 |
Gear.Y:= Gear.Y + Gear.dY; |
|
111 |
CheckGearDrowning(Gear); |
|
112 |
if (sqr(Gear.dX) + sqr(Gear.dY) < 0.003) then Gear.State:= Gear.State and not gstMoving |
|
113 |
else Gear.State:= Gear.State or gstMoving |
|
114 |
end; |
|
115 |
||
116 |
//////////////////////////////////////////////////////////////////////////////// |
|
117 |
procedure doStepCloud(Gear: PGear); |
|
118 |
begin |
|
119 |
Gear.X:= Gear.X + cWindSpeed * 200 + Gear.dX; |
|
74 | 120 |
if Gear.Y > -160 then Gear.dY:= Gear.dY - 0.00002 |
121 |
else Gear.dY:= Gear.dY + 0.00002; |
|
122 |
Gear.Y:= Gear.Y + Gear.dY; |
|
123 |
if Gear.X < -cScreenWidth - 256 then Gear.X:= cScreenWidth + 2048 else |
|
4 | 124 |
if Gear.X > cScreenWidth + 2048 then Gear.X:= -cScreenWidth - 256 |
125 |
end; |
|
126 |
||
127 |
//////////////////////////////////////////////////////////////////////////////// |
|
128 |
procedure doStepBomb(Gear: PGear); |
|
78 | 129 |
var i: integer; |
4 | 130 |
begin |
131 |
AllInactive:= false; |
|
132 |
doStepFallingGear(Gear); |
|
133 |
dec(Gear.Timer); |
|
134 |
if Gear.Timer = 0 then |
|
135 |
begin |
|
78 | 136 |
case Gear.Kind of |
137 |
gtAmmo_Bomb: doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound); |
|
138 |
gtClusterBomb: begin |
|
139 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 30, EXPLAutoSound); |
|
140 |
for i:= 0 to 4 do |
|
79 | 141 |
AddGear(round(Gear.X), round(Gear.Y), gtCluster, 0, (getrandom - 0.5)*0.2, (getrandom - 3) * 0.08); |
78 | 142 |
end |
143 |
end; |
|
4 | 144 |
DeleteGear(Gear); |
145 |
exit |
|
146 |
end; |
|
147 |
CalcRotationDirAngle(Gear); |
|
148 |
if (Gear.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then PlaySound(sndGrenadeImpact) |
|
149 |
end; |
|
150 |
||
78 | 151 |
procedure doStepCluster(Gear: PGear); |
152 |
begin |
|
153 |
AllInactive:= false; |
|
154 |
doStepFallingGear(Gear); |
|
155 |
if (Gear.State and gstCollision) <> 0 then |
|
156 |
begin |
|
157 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 20, EXPLAutoSound); |
|
158 |
DeleteGear(Gear); |
|
159 |
exit |
|
160 |
end; |
|
161 |
if (GameTicks and $1F) = 0 then |
|
162 |
AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0) |
|
163 |
end; |
|
164 |
||
4 | 165 |
//////////////////////////////////////////////////////////////////////////////// |
166 |
procedure doStepGrenade(Gear: PGear); |
|
167 |
begin |
|
168 |
AllInactive:= false; |
|
169 |
Gear.dX:= Gear.dX + cWindSpeed; |
|
170 |
doStepFallingGear(Gear); |
|
171 |
if (Gear.State and gstCollision) <> 0 then |
|
172 |
begin |
|
173 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound); |
|
174 |
DeleteGear(Gear); |
|
175 |
exit |
|
176 |
end; |
|
177 |
if (GameTicks and $3F) = 0 then |
|
178 |
AddGear(round(Gear.X), round(Gear.Y), gtSmokeTrace, 0) |
|
179 |
end; |
|
180 |
||
181 |
//////////////////////////////////////////////////////////////////////////////// |
|
95 | 182 |
procedure doStepHealthTagWork(Gear: PGear); |
4 | 183 |
begin |
184 |
AllInactive:= false; |
|
185 |
dec(Gear.Timer); |
|
186 |
Gear.Y:= Gear.Y - 0.07; |
|
187 |
if Gear.Timer = 0 then |
|
188 |
begin |
|
189 |
PHedgehog(Gear.Hedgehog).Gear.Active:= true; |
|
190 |
DeleteGear(Gear) |
|
191 |
end |
|
192 |
end; |
|
193 |
||
95 | 194 |
procedure doStepHealthTag(Gear: PGear); |
195 |
var s: shortstring; |
|
196 |
begin |
|
197 |
AllInactive:= false; |
|
198 |
str(Gear.State, s); |
|
199 |
Gear.Surf:= RenderString(s, PHedgehog(Gear.Hedgehog).Team.Color, fnt16); |
|
200 |
Gear.doStep:= doStepHealthTagWork |
|
201 |
end; |
|
202 |
||
4 | 203 |
//////////////////////////////////////////////////////////////////////////////// |
204 |
procedure doStepGrave(Gear: PGear); |
|
205 |
begin |
|
206 |
AllInactive:= false; |
|
207 |
if Gear.dY < 0 then |
|
68 | 208 |
if TestCollisionY(Gear, -1) then Gear.dY:= 0; |
4 | 209 |
|
210 |
if Gear.dY >=0 then |
|
68 | 211 |
if TestCollisionY(Gear, 1) then |
4 | 212 |
begin |
213 |
Gear.dY:= - Gear.dY * Gear.Elasticity; |
|
214 |
if Gear.dY > - 0.001 then |
|
215 |
begin |
|
216 |
Gear.Active:= false; |
|
217 |
exit |
|
218 |
end else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact) |
|
219 |
end; |
|
220 |
Gear.Y:= Gear.Y + Gear.dY; |
|
221 |
CheckGearDrowning(Gear); |
|
222 |
Gear.dY:= Gear.dY + cGravity |
|
223 |
end; |
|
224 |
||
225 |
//////////////////////////////////////////////////////////////////////////////// |
|
226 |
procedure doStepUFOWork(Gear: PGear); |
|
107 | 227 |
var t: Double; |
4 | 228 |
begin |
229 |
AllInactive:= false; |
|
230 |
t:= sqrt(sqr(Gear.dX) + sqr(Gear.dY)); |
|
231 |
Gear.dX:= Gear.Elasticity * (Gear.dX + 0.000004 * (TargetPoint.X - trunc(Gear.X))); |
|
232 |
Gear.dY:= Gear.Elasticity * (Gear.dY + 0.000004 * (TargetPoint.Y - trunc(Gear.Y))); |
|
233 |
t:= t / (sqrt(sqr(Gear.dX) + sqr(Gear.dY))); |
|
234 |
Gear.dX:= Gear.dX * t; |
|
235 |
Gear.dY:= Gear.dY * t; |
|
236 |
Gear.X:= Gear.X + Gear.dX; |
|
237 |
Gear.Y:= Gear.Y + Gear.dY; |
|
238 |
CheckCollision(Gear); |
|
239 |
dec(Gear.Timer); |
|
240 |
if ((Gear.State and gstCollision) <> 0) or (Gear.Timer = 0) then |
|
241 |
begin |
|
242 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound); |
|
243 |
DeleteGear(Gear); |
|
244 |
end; |
|
245 |
end; |
|
246 |
||
247 |
procedure doStepUFO(Gear: PGear); |
|
248 |
begin |
|
249 |
AllInactive:= false; |
|
250 |
Gear.X:= Gear.X + Gear.dX; |
|
251 |
Gear.Y:= Gear.Y + Gear.dY; |
|
252 |
Gear.dY:= Gear.dY + cGravity; |
|
253 |
CheckCollision(Gear); |
|
254 |
if (Gear.State and gstCollision) <> 0 then |
|
255 |
begin |
|
256 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound); |
|
257 |
DeleteGear(Gear); |
|
258 |
exit |
|
259 |
end; |
|
260 |
dec(Gear.Timer); |
|
261 |
if Gear.Timer = 0 then |
|
262 |
begin |
|
263 |
Gear.Timer:= 5000; |
|
264 |
Gear.doStep:= doStepUFOWork |
|
265 |
end; |
|
266 |
end; |
|
267 |
||
268 |
//////////////////////////////////////////////////////////////////////////////// |
|
269 |
procedure doStepShotgunShot(Gear: PGear); |
|
270 |
var i: LongWord; |
|
271 |
begin |
|
272 |
AllInactive:= false; |
|
273 |
if Gear.Timer > 0 then |
|
274 |
begin |
|
275 |
dec(Gear.Timer); |
|
95 | 276 |
if Gear.Timer = 0 then PlaySound(sndShotgunFire); |
4 | 277 |
exit |
278 |
end; |
|
279 |
i:= 200; |
|
280 |
repeat |
|
281 |
Gear.X:= Gear.X + Gear.dX; |
|
282 |
Gear.Y:= Gear.Y + Gear.dY; |
|
283 |
CheckCollision(Gear); |
|
284 |
if (Gear.State and gstCollision) <> 0 then |
|
285 |
begin |
|
75 | 286 |
AmmoShove(Gear, 25, 25); |
42 | 287 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 25, EXPLNoDamage or EXPLDoNotTouchHH); |
4 | 288 |
DeleteGear(Gear); |
75 | 289 |
AfterAttack; |
4 | 290 |
exit |
291 |
end; |
|
292 |
dec(i) |
|
293 |
until i = 0; |
|
294 |
if (Gear.X < 0) or (Gear.Y < 0) or (Gear.X > 2048) or (Gear.Y > 1024) then |
|
95 | 295 |
begin |
296 |
DeleteGear(Gear); |
|
297 |
AfterAttack |
|
298 |
end |
|
4 | 299 |
end; |
300 |
||
301 |
//////////////////////////////////////////////////////////////////////////////// |
|
38 | 302 |
procedure doStepDEagleShot(Gear: PGear); |
303 |
var i, x, y: LongWord; |
|
107 | 304 |
oX, oY: Double; |
38 | 305 |
begin |
306 |
AllInactive:= false; |
|
37 | 307 |
i:= 80; |
38 | 308 |
oX:= Gear.X; |
309 |
oY:= Gear.Y; |
|
37 | 310 |
repeat |
38 | 311 |
Gear.X:= Gear.X + Gear.dX; |
312 |
Gear.Y:= Gear.Y + Gear.dY; |
|
313 |
x:= round(Gear.X); |
|
314 |
y:= round(Gear.Y); |
|
315 |
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0) |
|
316 |
and (Land[y, x] <> 0) then inc(Gear.Damage); |
|
75 | 317 |
AmmoShove(Gear, 7, 20); |
38 | 318 |
dec(i) |
319 |
until (i = 0) or (Gear.Damage > Gear.Health); |
|
320 |
if Gear.Damage > 0 then |
|
37 | 321 |
begin |
38 | 322 |
DrawTunnel(oX, oY, Gear.dX, Gear.dY, 82 - i, 1); |
323 |
dec(Gear.Health, Gear.Damage); |
|
324 |
Gear.Damage:= 0 |
|
37 | 325 |
end; |
38 | 326 |
if (Gear.Health <= 0) or (Gear.X < 0) or (Gear.Y < 0) or (Gear.X > 2048) or (Gear.Y > 1024) then |
37 | 327 |
DeleteGear(Gear) |
328 |
end; |
|
329 |
||
330 |
//////////////////////////////////////////////////////////////////////////////// |
|
4 | 331 |
procedure doStepActionTimer(Gear: PGear); |
332 |
begin |
|
83 | 333 |
dec(Gear.Timer); |
334 |
case Gear.Kind of |
|
335 |
gtATStartGame: begin |
|
4 | 336 |
AllInactive:= false; |
83 | 337 |
if Gear.Timer = 0 then |
338 |
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); |
|
4 | 339 |
end; |
83 | 340 |
gtATSmoothWindCh: begin |
6 | 341 |
if Gear.Timer = 0 then |
342 |
begin |
|
343 |
if WindBarWidth < Gear.Tag then inc(WindBarWidth) |
|
83 | 344 |
else if WindBarWidth > Gear.Tag then dec(WindBarWidth); |
345 |
if WindBarWidth <> Gear.Tag then Gear.Timer:= 10; |
|
346 |
end |
|
347 |
end; |
|
348 |
gtATFinishGame: begin |
|
349 |
AllInactive:= false; |
|
350 |
if Gear.Timer = 0 then |
|
113 | 351 |
begin |
352 |
SendIPC('N'); |
|
83 | 353 |
GameState:= gsExit |
113 | 354 |
end |
6 | 355 |
end; |
4 | 356 |
end; |
83 | 357 |
if Gear.Timer = 0 then DeleteGear(Gear) |
4 | 358 |
end; |
359 |
||
360 |
//////////////////////////////////////////////////////////////////////////////// |
|
361 |
procedure doStepPickHammerWork(Gear: PGear); |
|
362 |
var i, ei: integer; |
|
363 |
HHGear: PGear; |
|
364 |
begin |
|
70 | 365 |
AllInactive:= false; |
4 | 366 |
dec(Gear.Timer); |
367 |
if (Gear.Timer = 0)or((Gear.Message and gm_Destroy) <> 0) then |
|
368 |
begin |
|
369 |
DeleteGear(Gear); |
|
370 |
AfterAttack; |
|
371 |
exit |
|
372 |
end; |
|
373 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
374 |
if (Gear.Timer and $3F) = 0 then |
|
375 |
begin |
|
53 | 376 |
i:= round(Gear.X) - Gear.Radius - GetRandom(2); |
377 |
ei:= round(Gear.X) + Gear.Radius + GetRandom(2); |
|
4 | 378 |
while i <= ei do |
379 |
begin |
|
380 |
doMakeExplosion(i, round(Gear.Y) + 3, 3, 0); |
|
381 |
inc(i, 1) |
|
382 |
end; |
|
383 |
Gear.X:= Gear.X + Gear.dX; |
|
42 | 384 |
Gear.Y:= Gear.Y + 1.9; |
385 |
SetAllHHToActive; |
|
4 | 386 |
end; |
387 |
if TestCollisionYwithGear(Gear, 1) then |
|
388 |
begin |
|
389 |
Gear.dY:= 0; |
|
108 | 390 |
HHGear.dX:= 0.0000001 * hwSign(PGear(Gear.Hedgehog).dX); |
4 | 391 |
HHGear.dY:= 0; |
392 |
end else |
|
393 |
begin |
|
394 |
Gear.dY:= Gear.dY + cGravity; |
|
395 |
Gear.Y:= Gear.Y + Gear.dY; |
|
396 |
if Gear.Y > 1024 then Gear.Timer:= 1 |
|
397 |
end; |
|
398 |
||
399 |
Gear.X:= Gear.X + HHGear.dX; |
|
400 |
HHGear.X:= Gear.X; |
|
53 | 401 |
HHGear.Y:= Gear.Y - cHHRadius; |
4 | 402 |
|
403 |
if (Gear.Message and gm_Attack) <> 0 then |
|
404 |
if (Gear.State and gsttmpFlag) <> 0 then Gear.Timer:= 1 else else |
|
405 |
if (Gear.State and gsttmpFlag) = 0 then Gear.State:= Gear.State or gsttmpFlag; |
|
406 |
if ((Gear.Message and gm_Left) <> 0) then Gear.dX:= -0.3 else |
|
407 |
if ((Gear.Message and gm_Right) <> 0) then Gear.dX:= 0.3 |
|
408 |
else Gear.dX:= 0; |
|
409 |
end; |
|
410 |
||
411 |
procedure doStepPickHammer(Gear: PGear); |
|
412 |
var i, y: integer; |
|
413 |
ar: TRangeArray; |
|
414 |
begin |
|
415 |
i:= 0; |
|
53 | 416 |
y:= round(Gear.Y) - cHHRadius*2; |
4 | 417 |
while y < round(Gear.Y) do |
418 |
begin |
|
53 | 419 |
ar[i].Left := round(Gear.X) - Gear.Radius - GetRandom(2); |
420 |
ar[i].Right:= round(Gear.X) + Gear.Radius + GetRandom(2); |
|
4 | 421 |
inc(y, 2); |
422 |
inc(i) |
|
423 |
end; |
|
53 | 424 |
DrawHLinesExplosions(@ar, 3, round(Gear.Y) - cHHRadius*2, 2, Pred(i)); |
4 | 425 |
Gear.dY:= PHedgehog(Gear.Hedgehog).Gear.dY; |
426 |
doStepPickHammerWork(Gear); |
|
427 |
Gear.doStep:= doStepPickHammerWork |
|
428 |
end; |
|
429 |
||
430 |
//////////////////////////////////////////////////////////////////////////////// |
|
431 |
procedure doStepRopeWork(Gear: PGear); |
|
70 | 432 |
const flCheck: boolean = false; |
4 | 433 |
var HHGear: PGear; |
107 | 434 |
len, cs, cc, tx, ty: Double; |
108 | 435 |
lx, ly: LongInt; |
4 | 436 |
|
437 |
procedure DeleteMe; |
|
438 |
begin |
|
439 |
with HHGear^ do |
|
440 |
begin |
|
441 |
Message:= Message and not gm_Attack; |
|
442 |
State:= State or gstFalling; |
|
443 |
end; |
|
444 |
DeleteGear(Gear); |
|
113 | 445 |
OnUsedAmmo(PHedgehog(HHGear.Hedgehog)^.Ammo); |
446 |
ApplyAmmoChanges(PHedgehog(HHGear.Hedgehog)^) |
|
4 | 447 |
end; |
448 |
||
449 |
begin |
|
450 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
108 | 451 |
|
80 | 452 |
if ((HHGear.State and gstHHDriven) = 0) |
453 |
or (CheckGearDrowning(HHGear)) then |
|
4 | 454 |
begin |
455 |
DeleteMe; |
|
456 |
exit |
|
457 |
end; |
|
458 |
Gear.dX:= HHGear.X - Gear.X; |
|
459 |
Gear.dY:= HHGear.Y - Gear.Y; |
|
460 |
||
461 |
if (Gear.Message and gm_Left <> 0) then HHGear.dX:= HHGear.dX - 0.0002 else |
|
462 |
if (Gear.Message and gm_Right <> 0) then HHGear.dX:= HHGear.dX + 0.0002; |
|
463 |
||
464 |
if not TestCollisionYwithGear(HHGear, 1) then HHGear.dY:= HHGear.dY + cGravity; |
|
465 |
||
108 | 466 |
cs:= Gear.dY + HHGear.dY; |
467 |
cc:= Gear.dX + HHGear.dX; |
|
468 |
len:= 1 / sqrt(sqr(cc)+sqr(cs)); |
|
469 |
cc:= cc * len; |
|
470 |
cs:= cs * len; |
|
4 | 471 |
|
472 |
flCheck:= not flCheck; |
|
473 |
if flCheck then // check whether rope needs dividing |
|
474 |
begin |
|
475 |
len:= Gear.Elasticity - 20; |
|
476 |
while len > 5 do |
|
477 |
begin |
|
478 |
tx:= cc*len; |
|
479 |
ty:= cs*len; |
|
108 | 480 |
lx:= round(Gear.X + tx) + hwSign(HHGear.dX); |
481 |
ly:= round(Gear.Y + ty) + hwSign(HHGear.dY); |
|
4 | 482 |
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0)and (Land[ly, lx] <> 0) then |
483 |
begin |
|
484 |
with RopePoints.ar[RopePoints.Count] do |
|
485 |
begin |
|
486 |
X:= Gear.X; |
|
487 |
Y:= Gear.Y; |
|
488 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle32(Gear.dY, Gear.dX); |
|
489 |
b:= (cc * HHGear.dY) > (cs * HHGear.dX); |
|
490 |
dLen:= len |
|
491 |
end; |
|
492 |
Gear.X:= Gear.X + tx; |
|
493 |
Gear.Y:= Gear.Y + ty; |
|
494 |
inc(RopePoints.Count); |
|
495 |
Gear.Elasticity:= Gear.Elasticity - len; |
|
496 |
Gear.Friction:= Gear.Friction - len; |
|
497 |
break |
|
498 |
end; |
|
499 |
len:= len - 3 |
|
500 |
end; |
|
501 |
end else |
|
502 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
|
503 |
begin |
|
504 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
505 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
506 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear.X) * (ty - HHGear.Y) > (tx - HHGear.X) * (ty - Gear.Y)) then |
|
507 |
begin |
|
508 |
dec(RopePoints.Count); |
|
509 |
Gear.X:=RopePoints.ar[RopePoints.Count].X; |
|
510 |
Gear.Y:=RopePoints.ar[RopePoints.Count].Y; |
|
511 |
Gear.Elasticity:= Gear.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
|
512 |
Gear.Friction:= Gear.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
513 |
end |
|
514 |
end; |
|
515 |
||
516 |
Gear.dX:= HHGear.X - Gear.X; |
|
517 |
Gear.dY:= HHGear.Y - Gear.Y; |
|
108 | 518 |
|
519 |
cs:= Gear.dY + HHGear.dY; |
|
520 |
cc:= Gear.dX + HHGear.dX; |
|
521 |
len:= 1 / sqrt(sqr(cc)+sqr(cs)); |
|
522 |
cc:= cc * len; |
|
523 |
cs:= cs * len; |
|
4 | 524 |
|
525 |
HHGear.dX:= HHGear.X; |
|
526 |
HHGear.dY:= HHGear.Y; |
|
527 |
||
528 |
if ((Gear.Message and gm_Down) <> 0) and (Gear.Elasticity < Gear.Friction) 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 |
if ((Gear.Message and gm_Up) <> 0) and (Gear.Elasticity > 30) then |
|
108 | 533 |
if not (TestCollisionXwithGear(HHGear, -hwSign(Gear.dX)) |
534 |
or TestCollisionYwithGear(HHGear, -hwSign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity - 0.3; |
|
4 | 535 |
|
536 |
HHGear.X:= Gear.X + cc*Gear.Elasticity; |
|
537 |
HHGear.Y:= Gear.Y + cs*Gear.Elasticity; |
|
538 |
||
539 |
HHGear.dX:= HHGear.X - HHGear.dX; |
|
540 |
HHGear.dY:= HHGear.Y - HHGear.dY; |
|
541 |
||
108 | 542 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then |
75 | 543 |
HHGear.dX:= -0.6 * HHGear.dX; |
108 | 544 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear.dY)) then |
75 | 545 |
HHGear.dY:= -0.6 * HHGear.dY; |
4 | 546 |
|
547 |
if (Gear.Message and gm_Attack) <> 0 then |
|
548 |
if (Gear.State and gsttmpFlag) <> 0 then DeleteMe else |
|
549 |
else if (Gear.State and gsttmpFlag) = 0 then Gear.State:= Gear.State or gsttmpFlag; |
|
550 |
end; |
|
551 |
||
552 |
||
553 |
procedure doStepRopeAttach(Gear: PGear); |
|
554 |
var HHGear: PGear; |
|
107 | 555 |
tx, ty, tt: Double; |
4 | 556 |
begin |
113 | 557 |
Gear.X:= Gear.X - Gear.dX; |
558 |
Gear.Y:= Gear.Y - Gear.dY; |
|
4 | 559 |
Gear.Elasticity:= Gear.Elasticity + 1.0; |
560 |
HHGear:= PHedgehog(Gear.Hedgehog)^.Gear; |
|
561 |
if (HHGear.State and gstFalling) <> 0 then |
|
68 | 562 |
if TestCollisionYwithGear(HHGear, 1) then |
4 | 563 |
begin |
564 |
HHGear.dY:= 0; |
|
565 |
CheckHHDamage(HHGear); |
|
566 |
HHGear.State:= HHGear.State and not (gstFalling or gstHHJumping); |
|
567 |
end else |
|
568 |
begin |
|
108 | 569 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then HHGear.dX:= 0.0000001 * hwSign(HHGear.dX); |
4 | 570 |
HHGear.X:= HHGear.X + HHGear.dX; |
571 |
HHGear.Y:= HHGear.Y + HHGear.dY; |
|
572 |
Gear.X:= Gear.X + HHGear.dX; |
|
573 |
Gear.Y:= Gear.Y + HHGear.dY; |
|
574 |
HHGear.dY:= HHGear.dY + cGravity; |
|
575 |
tt:= Gear.Elasticity; |
|
576 |
tx:= 0; |
|
577 |
ty:= 0; |
|
578 |
while tt > 20 do |
|
579 |
begin |
|
108 | 580 |
if TestCollisionXwithXYShift(Gear, round(tx), round(ty), hwSign(Gear.dX)) |
581 |
or TestCollisionYwithXYShift(Gear, round(tx), round(ty), hwSign(Gear.dY)) then |
|
4 | 582 |
begin |
583 |
Gear.X:= Gear.X + tx; |
|
584 |
Gear.Y:= Gear.Y + ty; |
|
585 |
Gear.Elasticity:= tt; |
|
586 |
Gear.doStep:= doStepRopeWork; |
|
587 |
with HHGear^ do State:= State and not gstAttacking; |
|
588 |
tt:= 0 |
|
589 |
end; |
|
113 | 590 |
tx:= tx + Gear.dX - Gear.dX; |
591 |
ty:= ty + Gear.dY - Gear.dY; |
|
4 | 592 |
tt:= tt - 2.0; |
593 |
end; |
|
594 |
end; |
|
595 |
CheckCollision(Gear); |
|
596 |
if (Gear.State and gstCollision) <> 0 then |
|
597 |
begin |
|
598 |
Gear.doStep:= doStepRopeWork; |
|
599 |
with HHGear^ do State:= State and not gstAttacking; |
|
600 |
if Gear.Elasticity < 10 then |
|
601 |
Gear.Elasticity:= 10000; |
|
602 |
end; |
|
603 |
||
604 |
if (Gear.Elasticity >= Gear.Friction) or ((Gear.Message and gm_Attack) = 0) then |
|
605 |
begin |
|
606 |
with PHedgehog(Gear.Hedgehog).Gear^ do |
|
607 |
begin |
|
608 |
State:= State and not gstAttacking; |
|
609 |
Message:= Message and not gm_Attack |
|
610 |
end; |
|
611 |
DeleteGear(Gear) |
|
612 |
end |
|
613 |
end; |
|
614 |
||
615 |
procedure doStepRope(Gear: PGear); |
|
616 |
begin |
|
113 | 617 |
Gear.dX:= - Gear.dX; |
618 |
Gear.dY:= - Gear.dY; |
|
4 | 619 |
Gear.doStep:= doStepRopeAttach |
620 |
end; |
|
621 |
||
622 |
//////////////////////////////////////////////////////////////////////////////// |
|
623 |
procedure doStepSmokeTrace(Gear: PGear); |
|
624 |
begin |
|
625 |
inc(Gear.Timer); |
|
626 |
if Gear.Timer > 64 then |
|
627 |
begin |
|
628 |
Gear.Timer:= 0; |
|
9 | 629 |
dec(Gear.State) |
4 | 630 |
end; |
631 |
Gear.dX:= Gear.dX + cWindSpeed; |
|
632 |
Gear.X:= Gear.X + Gear.dX; |
|
9 | 633 |
if Gear.State = 0 then DeleteGear(Gear) |
4 | 634 |
end; |
9 | 635 |
|
636 |
//////////////////////////////////////////////////////////////////////////////// |
|
637 |
procedure doStepExplosion(Gear: PGear); |
|
638 |
begin |
|
639 |
inc(Gear.Timer); |
|
640 |
if Gear.Timer > 75 then |
|
641 |
begin |
|
642 |
inc(Gear.State); |
|
643 |
Gear.Timer:= 0; |
|
644 |
if Gear.State > 5 then DeleteGear(Gear) |
|
645 |
end; |
|
646 |
end; |
|
10 | 647 |
|
648 |
//////////////////////////////////////////////////////////////////////////////// |
|
649 |
procedure doStepMine(Gear: PGear); |
|
650 |
begin |
|
39 | 651 |
if (Gear.dX <> 0) or (Gear.dY <> 0) then |
10 | 652 |
begin |
53 | 653 |
if Gear.CollIndex < High(Longword) then DeleteCI(Gear); |
10 | 654 |
doStepFallingGear(Gear); |
13 | 655 |
if Gear.Active = false then |
656 |
begin |
|
53 | 657 |
if Gear.CollIndex = High(Longword) then AddGearCI(Gear); |
13 | 658 |
Gear.dX:= 0; |
659 |
Gear.dY:= 0 |
|
660 |
end; |
|
661 |
CalcRotationDirAngle(Gear); |
|
10 | 662 |
AllInactive:= false |
663 |
end; |
|
39 | 664 |
|
10 | 665 |
if ((Gear.State and gsttmpFlag) <> 0) then |
666 |
if ((Gear.State and gstAttacking) = 0) then |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
667 |
begin |
39 | 668 |
if ((GameTicks and $F) = 0) then |
15 | 669 |
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
|
670 |
end else // gstAttacking <> 0 |
10 | 671 |
begin |
672 |
AllInactive:= false; |
|
37 | 673 |
if (Gear.Timer and $FF) = 0 then PlaySound(sndMineTick); |
10 | 674 |
if Gear.Timer = 0 then |
675 |
begin |
|
13 | 676 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 50, EXPLAutoSound); |
10 | 677 |
DeleteGear(Gear) |
678 |
end; |
|
13 | 679 |
dec(Gear.Timer); |
680 |
end else // gsttmpFlag = 0 |
|
681 |
if TurnTimeLeft = 0 then Gear.State:= Gear.State or gsttmpFlag; |
|
10 | 682 |
end; |
57 | 683 |
|
39 | 684 |
//////////////////////////////////////////////////////////////////////////////// |
685 |
procedure doStepDynamite(Gear: PGear); |
|
686 |
begin |
|
43 | 687 |
doStepFallingGear(Gear); |
688 |
AllInactive:= false; |
|
689 |
if Gear.Timer mod 166 = 0 then inc(Gear.Tag); |
|
690 |
if Gear.Timer = 0 then |
|
39 | 691 |
begin |
46 | 692 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 75, EXPLAutoSound); |
43 | 693 |
DeleteGear(Gear); |
694 |
exit |
|
39 | 695 |
end; |
43 | 696 |
dec(Gear.Timer); |
39 | 697 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
698 |
|
15 | 699 |
//////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
700 |
procedure doStepCase(Gear: PGear); |
89 | 701 |
var i, x, y: integer; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
702 |
begin |
15 | 703 |
if (Gear.Message and gm_Destroy) > 0 then |
704 |
begin |
|
705 |
DeleteGear(Gear); |
|
706 |
exit |
|
707 |
end; |
|
708 |
||
79 | 709 |
if Gear.Damage > 0 then |
710 |
begin |
|
89 | 711 |
x:= round(Gear.X); |
712 |
y:= round(Gear.Y); |
|
79 | 713 |
DeleteGear(Gear); |
89 | 714 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
79 | 715 |
for i:= 0 to 63 do |
89 | 716 |
AddGear(x, y, gtFlame, 0); |
79 | 717 |
exit |
718 |
end; |
|
719 |
||
53 | 720 |
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
|
721 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
722 |
AllInactive:= false; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
723 |
Gear.dY:= Gear.dY + cGravity; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
724 |
Gear.Y:= Gear.Y + Gear.dY; |
53 | 725 |
if (Gear.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0 else |
726 |
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
|
727 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
728 |
Gear.dY:= - Gear.dY * Gear.Elasticity; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
729 |
if Gear.dY > - 0.001 then Gear.dY:= 0 |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
730 |
else if Gear.dY < - 0.03 then PlaySound(sndGraveImpact); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
731 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
732 |
CheckGearDrowning(Gear); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
733 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
734 |
|
53 | 735 |
if (Gear.CollIndex = High(Longword)) and (Gear.dY = 0) then AddGearCI(Gear) |
736 |
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
|
737 |
end; |
49 | 738 |
|
739 |
//////////////////////////////////////////////////////////////////////////////// |
|
740 |
var thexchar: array[0..5] of record |
|
741 |
oy, ny: integer; |
|
742 |
team: PTeam; |
|
743 |
end; |
|
744 |
thexchcnt: Longword; |
|
143 | 745 |
currsorter: PGear; |
49 | 746 |
|
747 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
748 |
var i: integer; |
|
749 |
begin |
|
750 |
AllInactive:= false; |
|
751 |
dec(Gear.Timer); |
|
752 |
if (Gear.Timer and 15) = 0 then |
|
753 |
for i:= 0 to Pred(thexchcnt) do |
|
754 |
with thexchar[i] do |
|
755 |
{$WARNINGS OFF} |
|
756 |
team.DrawHealthY:= ny + (oy - ny) * Gear.Timer div 640; |
|
757 |
{$WARNINGS ON} |
|
143 | 758 |
if (Gear.Timer = 0) or (currsorter <> Gear) then |
759 |
begin |
|
760 |
if currsorter = Gear then currsorter:= nil; |
|
49 | 761 |
DeleteGear(Gear) |
143 | 762 |
end |
49 | 763 |
end; |
764 |
||
765 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
766 |
var team: PTeam; |
|
767 |
i, t: Longword; |
|
768 |
begin |
|
769 |
AllInactive:= false; |
|
770 |
team:= TeamsList; |
|
771 |
i:= 0; |
|
772 |
while team <> nil do |
|
773 |
begin |
|
774 |
thexchar[i].oy:= team.DrawHealthY; |
|
775 |
thexchar[i].team:= team; |
|
776 |
inc(i); |
|
777 |
team:= team.Next |
|
778 |
end; |
|
779 |
thexchcnt:= i; |
|
780 |
for i:= 1 to thexchcnt do |
|
781 |
for t:= 0 to thexchcnt - 2 do |
|
146 | 782 |
if thexchar[t].team.TeamHealthBarWidth > thexchar[Succ(t)].team.TeamHealthBarWidth then |
49 | 783 |
begin |
784 |
thexchar[5]:= thexchar[t]; |
|
785 |
thexchar[t]:= thexchar[Succ(t)]; |
|
786 |
thexchar[Succ(t)]:= thexchar[5] |
|
787 |
end; |
|
788 |
t:= cScreenHeight - 4; |
|
789 |
for i:= 0 to Pred(thexchcnt) do |
|
790 |
with thexchar[i] do |
|
791 |
begin |
|
792 |
dec(t, team.HealthRect.h + 2); |
|
793 |
ny:= t |
|
794 |
end; |
|
795 |
Gear.Timer:= 640; |
|
143 | 796 |
Gear.doStep:= doStepTeamHealthSorterWork; |
797 |
currsorter:= Gear |
|
49 | 798 |
end; |
799 |
||
79 | 800 |
//////////////////////////////////////////////////////////////////////////////// |
801 |
procedure doStepShover(Gear: PGear); |
|
802 |
var HHGear: PGear; |
|
803 |
begin |
|
804 |
HHGear:= PHedgehog(Gear.Hedgehog)^.Gear; |
|
805 |
HHGear.State:= HHGear.State or gstNoDamage; |
|
806 |
AmmoShove(Gear, 30, 115); |
|
807 |
HHGear.State:= HHGear.State and not gstNoDamage; |
|
808 |
DeleteGear(Gear) |
|
809 |
end; |
|
810 |
||
811 |
//////////////////////////////////////////////////////////////////////////////// |
|
812 |
procedure doStepFlame(Gear: PGear); |
|
813 |
begin |
|
814 |
AllInactive:= false; |
|
815 |
if not TestCollisionYwithGear(Gear, 1) then |
|
816 |
begin |
|
817 |
Gear.dX:= Gear.dX + cWindSpeed; |
|
818 |
Gear.dY:= Gear.dY + cGravity; |
|
819 |
if abs(Gear.dX) > 0.12 then Gear.dX:= Gear.dX * 0.5; |
|
820 |
if Gear.dY > 0.12 then Gear.dY:= Gear.dY * 0.995; |
|
821 |
Gear.X:= Gear.X + Gear.dX; |
|
822 |
Gear.Y:= Gear.Y + Gear.dY; |
|
823 |
if Gear.Y > 1023 then |
|
824 |
begin |
|
825 |
DeleteGear(Gear); |
|
826 |
exit |
|
827 |
end |
|
828 |
end else begin |
|
829 |
if Gear.Timer > 0 then dec(Gear.Timer) |
|
830 |
else begin |
|
831 |
doMakeExplosion(round(Gear.X), round(Gear.Y), 2, 0); |
|
832 |
dec(Gear.Health); |
|
833 |
Gear.Timer:= 1250 - Gear.Angle * 12 |
|
834 |
end |
|
835 |
end; |
|
836 |
||
837 |
if (((GameTicks div 8) mod 64) = Gear.Angle) then |
|
838 |
AmmoFlameWork(Gear); |
|
839 |
||
82 | 840 |
if Gear.Health = 0 then |
79 | 841 |
DeleteGear(Gear) |
842 |
end; |
|
82 | 843 |
|
844 |
//////////////////////////////////////////////////////////////////////////////// |
|
845 |
procedure doStepFirePunchWork(Gear: PGear); |
|
846 |
var HHGear: PGear; |
|
847 |
begin |
|
848 |
AllInactive:= false; |
|
849 |
if ((Gear.Message and gm_Destroy) <> 0) then |
|
850 |
begin |
|
851 |
DeleteGear(Gear); |
|
852 |
AfterAttack; |
|
853 |
exit |
|
854 |
end; |
|
855 |
||
856 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
857 |
if round(HHGear.Y) <= Gear.Tag - 2 then |
|
858 |
begin |
|
859 |
Gear.Tag:= round(HHGear.Y); |
|
860 |
DrawTunnel(HHGear.X - cHHRadius, HHGear.Y - 1, 0.5, 0.0, cHHRadius * 4, 2); |
|
861 |
HHGear.State:= HHGear.State or gstNoDamage; |
|
862 |
Gear.Y:= HHGear.Y; |
|
863 |
AmmoShove(Gear, 30, 40); |
|
864 |
HHGear.State:= HHGear.State and not gstNoDamage |
|
865 |
end; |
|
866 |
||
867 |
HHGear.dY:= HHGear.dY + cGravity; |
|
868 |
if HHGear.dY >= 0 then |
|
869 |
begin |
|
870 |
HHGear.State:= HHGear.State or gstFalling; |
|
871 |
DeleteGear(Gear); |
|
872 |
AfterAttack; |
|
873 |
exit |
|
874 |
end; |
|
875 |
HHGear.Y:= HHGear.Y + HHGear.dY |
|
876 |
end; |
|
877 |
||
878 |
procedure doStepFirePunch(Gear: PGear); |
|
879 |
var HHGear: PGear; |
|
880 |
begin |
|
881 |
AllInactive:= false; |
|
882 |
HHGear:= PHedgehog(Gear.Hedgehog).Gear; |
|
883 |
HHGear.X:= round(HHGear.X) - 0.5; |
|
108 | 884 |
HHGear.dX:= 0.0000001 * hwSign(HHGear.dX); |
82 | 885 |
HHGear.dY:= -0.30; |
886 |
||
887 |
Gear.X:= HHGear.X; |
|
108 | 888 |
Gear.dX:= hwSign(HHGear.dX)* 0.45; |
82 | 889 |
Gear.dY:= -0.9; |
890 |
Gear.doStep:= doStepFirePunchWork; |
|
891 |
DrawTunnel(HHGear.X - cHHRadius, HHGear.Y + 1, 0.5, 0.0, cHHRadius * 4, 5); |
|
892 |
end; |
|
893 |
||
894 |