author | unc0rr |
Sun, 27 Jul 2008 13:32:15 +0000 | |
changeset 1107 | ee873ada9e86 |
parent 1106 | f868b7307003 |
child 1108 | c77267d982ee |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
883 | 3 |
* Copyright (c) 2004-2008 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 |
|
498 | 23 |
if cWaterLine < hwRound(Gear^.Y) + Gear^.Radius then |
4 | 24 |
begin |
351 | 25 |
CheckGearDrowning:= true; |
26 |
Gear^.State:= gstDrowning; |
|
27 |
Gear^.doStep:= @doStepDrowningGear; |
|
28 |
PlaySound(sndSplash, false) |
|
29 |
end else |
|
30 |
CheckGearDrowning:= false |
|
4 | 31 |
end; |
32 |
||
33 |
procedure CheckCollision(Gear: PGear); |
|
34 |
begin |
|
351 | 35 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.X)) or TestCollisionYwithGear(Gear, hwSign(Gear^.Y)) |
36 |
then Gear^.State:= Gear^.State or gstCollision |
|
37 |
else Gear^.State:= Gear^.State and not gstCollision |
|
4 | 38 |
end; |
39 |
||
40 |
procedure CheckHHDamage(Gear: PGear); |
|
522 | 41 |
var dmg: Longword; |
4 | 42 |
begin |
522 | 43 |
if _0_4 < Gear^.dY then |
44 |
begin |
|
45 |
dmg:= 1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70); |
|
46 |
inc(Gear^.Damage, dmg); |
|
47 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, dmg, Gear); |
|
48 |
end |
|
4 | 49 |
end; |
50 |
||
51 |
//////////////////////////////////////////////////////////////////////////////// |
|
52 |
//////////////////////////////////////////////////////////////////////////////// |
|
53 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
54 |
var dAngle: real; |
4 | 55 |
begin |
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
56 |
dAngle:= (hwAbs(Gear^.dX) + hwAbs(Gear^.dY)).QWordValue / $80000000; |
351 | 57 |
if not Gear^.dX.isNegative then Gear^.DirAngle:= Gear^.DirAngle + dAngle |
58 |
else Gear^.DirAngle:= Gear^.DirAngle - dAngle; |
|
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
59 |
if Gear^.DirAngle < 0 then Gear^.DirAngle:= Gear^.DirAngle + 360 |
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
60 |
else if 360 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle - 360 |
4 | 61 |
end; |
62 |
||
63 |
//////////////////////////////////////////////////////////////////////////////// |
|
64 |
procedure doStepDrowningGear(Gear: PGear); |
|
65 |
begin |
|
66 |
AllInactive:= false; |
|
351 | 67 |
Gear^.Y:= Gear^.Y + cDrownSpeed; |
68 |
if hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear) |
|
4 | 69 |
end; |
70 |
||
71 |
//////////////////////////////////////////////////////////////////////////////// |
|
72 |
procedure doStepFallingGear(Gear: PGear); |
|
542 | 73 |
var isFalling: boolean; |
4 | 74 |
begin |
503 | 75 |
Gear^.State:= Gear^.State and not gstCollision; |
76 |
||
77 |
if Gear^.dY.isNegative then |
|
4 | 78 |
begin |
542 | 79 |
isFalling:= true; |
503 | 80 |
if TestCollisionYwithGear(Gear, -1) then |
81 |
begin |
|
82 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
83 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
84 |
Gear^.State:= Gear^.State or gstCollision |
|
85 |
end |
|
86 |
end else |
|
87 |
if TestCollisionYwithGear(Gear, 1) then |
|
88 |
begin |
|
542 | 89 |
isFalling:= false; |
503 | 90 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
91 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
92 |
Gear^.State:= Gear^.State or gstCollision |
|
542 | 93 |
end else isFalling:= true; |
503 | 94 |
|
351 | 95 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
4 | 96 |
begin |
351 | 97 |
Gear^.dX:= - Gear^.dX * Gear^.Elasticity; |
924 | 98 |
Gear^.dY:= Gear^.dY * Gear^.Elasticity; |
351 | 99 |
Gear^.State:= Gear^.State or gstCollision |
4 | 100 |
end; |
503 | 101 |
|
542 | 102 |
if isFalling then Gear^.dY:= Gear^.dY + cGravity; |
503 | 103 |
|
351 | 104 |
Gear^.X:= Gear^.X + Gear^.dX; |
105 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
4 | 106 |
CheckGearDrowning(Gear); |
503 | 107 |
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and |
542 | 108 |
(not isFalling) then Gear^.State:= Gear^.State and not gstMoving |
109 |
else Gear^.State:= Gear^.State or gstMoving |
|
4 | 110 |
end; |
111 |
||
112 |
//////////////////////////////////////////////////////////////////////////////// |
|
113 |
procedure doStepBomb(Gear: PGear); |
|
371 | 114 |
var i: LongInt; |
919 | 115 |
dX, dY: hwFloat; |
4 | 116 |
begin |
117 |
AllInactive:= false; |
|
118 |
doStepFallingGear(Gear); |
|
351 | 119 |
dec(Gear^.Timer); |
120 |
if Gear^.Timer = 0 then |
|
4 | 121 |
begin |
351 | 122 |
case Gear^.Kind of |
123 |
gtAmmo_Bomb: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
78 | 124 |
gtClusterBomb: begin |
915 | 125 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
78 | 126 |
for i:= 0 to 4 do |
919 | 127 |
begin |
128 |
dX:= rndSign(GetRandom * _0_1); |
|
129 |
dY:= (GetRandom - _3) * _0_08; |
|
130 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 0); |
|
131 |
end |
|
78 | 132 |
end |
133 |
end; |
|
4 | 134 |
DeleteGear(Gear); |
135 |
exit |
|
136 |
end; |
|
137 |
CalcRotationDirAngle(Gear); |
|
351 | 138 |
if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then PlaySound(sndGrenadeImpact, false) |
4 | 139 |
end; |
140 |
||
78 | 141 |
procedure doStepCluster(Gear: PGear); |
142 |
begin |
|
143 |
AllInactive:= false; |
|
144 |
doStepFallingGear(Gear); |
|
351 | 145 |
if (Gear^.State and gstCollision) <> 0 then |
78 | 146 |
begin |
915 | 147 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound); |
78 | 148 |
DeleteGear(Gear); |
149 |
exit |
|
150 |
end; |
|
151 |
if (GameTicks and $1F) = 0 then |
|
498 | 152 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
78 | 153 |
end; |
154 |
||
4 | 155 |
//////////////////////////////////////////////////////////////////////////////// |
156 |
procedure doStepGrenade(Gear: PGear); |
|
157 |
begin |
|
158 |
AllInactive:= false; |
|
351 | 159 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
4 | 160 |
doStepFallingGear(Gear); |
351 | 161 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 162 |
begin |
351 | 163 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
4 | 164 |
DeleteGear(Gear); |
165 |
exit |
|
166 |
end; |
|
167 |
if (GameTicks and $3F) = 0 then |
|
498 | 168 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
4 | 169 |
end; |
170 |
||
171 |
//////////////////////////////////////////////////////////////////////////////// |
|
95 | 172 |
procedure doStepHealthTagWork(Gear: PGear); |
4 | 173 |
begin |
522 | 174 |
if Gear^.Kind = gtHealthTag then |
175 |
AllInactive:= false; |
|
351 | 176 |
dec(Gear^.Timer); |
522 | 177 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
351 | 178 |
if Gear^.Timer = 0 then |
4 | 179 |
begin |
522 | 180 |
if Gear^.Kind = gtHealthTag then |
181 |
PHedgehog(Gear^.Hedgehog)^.Gear^.Active:= true; // to let current hh die |
|
4 | 182 |
DeleteGear(Gear) |
183 |
end |
|
184 |
end; |
|
185 |
||
263 | 186 |
procedure doStepHealthTagWorkUnderWater(Gear: PGear); |
187 |
begin |
|
188 |
AllInactive:= false; |
|
351 | 189 |
Gear^.Y:= Gear^.Y - _0_08; |
498 | 190 |
if hwRound(Gear^.Y) < cWaterLine + 10 then |
263 | 191 |
DeleteGear(Gear) |
192 |
end; |
|
193 |
||
95 | 194 |
procedure doStepHealthTag(Gear: PGear); |
195 |
var s: shortstring; |
|
522 | 196 |
font: THWFont; |
95 | 197 |
begin |
522 | 198 |
if Gear^.Kind = gtHealthTag then |
199 |
begin |
|
813 | 200 |
AllInactive:= false; |
522 | 201 |
font:= fnt16; |
202 |
Gear^.dY:= -_0_08 |
|
203 |
end else |
|
204 |
begin |
|
205 |
font:= fntSmall; |
|
206 |
Gear^.dY:= -_0_02 |
|
207 |
end; |
|
208 |
||
351 | 209 |
str(Gear^.State, s); |
762 | 210 |
Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, font); |
498 | 211 |
if hwRound(Gear^.Y) < cWaterLine then Gear^.doStep:= @doStepHealthTagWork |
522 | 212 |
else Gear^.doStep:= @doStepHealthTagWorkUnderWater; |
762 | 213 |
Gear^.Y:= Gear^.Y - int2hwFloat(Gear^.Tex^.h) |
95 | 214 |
end; |
215 |
||
4 | 216 |
//////////////////////////////////////////////////////////////////////////////// |
217 |
procedure doStepGrave(Gear: PGear); |
|
218 |
begin |
|
219 |
AllInactive:= false; |
|
498 | 220 |
if Gear^.dY.isNegative then |
221 |
if TestCollisionY(Gear, -1) then Gear^.dY:= _0; |
|
4 | 222 |
|
351 | 223 |
if not Gear^.dY.isNegative then |
68 | 224 |
if TestCollisionY(Gear, 1) then |
4 | 225 |
begin |
351 | 226 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
227 |
if Gear^.dY > - _1div1024 then |
|
4 | 228 |
begin |
351 | 229 |
Gear^.Active:= false; |
4 | 230 |
exit |
351 | 231 |
end else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false) |
4 | 232 |
end; |
351 | 233 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
4 | 234 |
CheckGearDrowning(Gear); |
351 | 235 |
Gear^.dY:= Gear^.dY + cGravity |
4 | 236 |
end; |
237 |
||
238 |
//////////////////////////////////////////////////////////////////////////////// |
|
239 |
procedure doStepUFOWork(Gear: PGear); |
|
351 | 240 |
var t: hwFloat; |
374 | 241 |
y: LongInt; |
4 | 242 |
begin |
243 |
AllInactive:= false; |
|
351 | 244 |
t:= Distance(Gear^.dX, Gear^.dY); |
245 |
Gear^.dX:= Gear^.Elasticity * (Gear^.dX + _0_000004 * (TargetPoint.X - hwRound(Gear^.X))); |
|
246 |
Gear^.dY:= Gear^.Elasticity * (Gear^.dY + _0_000004 * (TargetPoint.Y - hwRound(Gear^.Y))); |
|
247 |
t:= t / Distance(Gear^.dX, Gear^.dY); |
|
248 |
Gear^.dX:= Gear^.dX * t; |
|
249 |
Gear^.dY:= Gear^.dY * t; |
|
250 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
251 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
374 | 252 |
|
253 |
if (GameTicks and $3F) = 0 then |
|
254 |
begin |
|
255 |
y:= hwRound(Gear^.Y); |
|
256 |
if y + Gear^.Radius < cWaterLine then |
|
498 | 257 |
AddGear(hwRound(Gear^.X), y, gtSmokeTrace, 0, _0, _0, 0); |
374 | 258 |
end; |
259 |
||
4 | 260 |
CheckCollision(Gear); |
351 | 261 |
dec(Gear^.Timer); |
262 |
if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then |
|
4 | 263 |
begin |
560 | 264 |
StopSound(sndUFO); |
351 | 265 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
4 | 266 |
DeleteGear(Gear); |
267 |
end; |
|
268 |
end; |
|
269 |
||
270 |
procedure doStepUFO(Gear: PGear); |
|
271 |
begin |
|
272 |
AllInactive:= false; |
|
351 | 273 |
Gear^.X:= Gear^.X + Gear^.dX; |
274 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
275 |
Gear^.dY:= Gear^.dY + cGravity; |
|
4 | 276 |
CheckCollision(Gear); |
351 | 277 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 278 |
begin |
351 | 279 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
4 | 280 |
DeleteGear(Gear); |
281 |
exit |
|
282 |
end; |
|
351 | 283 |
dec(Gear^.Timer); |
284 |
if Gear^.Timer = 0 then |
|
4 | 285 |
begin |
560 | 286 |
PlaySound(sndUFO, true); |
351 | 287 |
Gear^.Timer:= 5000; |
288 |
Gear^.doStep:= @doStepUFOWork |
|
4 | 289 |
end; |
290 |
end; |
|
291 |
||
292 |
//////////////////////////////////////////////////////////////////////////////// |
|
876 | 293 |
procedure doStepShotIdle(Gear: PGear); |
294 |
begin |
|
295 |
AllInactive:= false; |
|
296 |
inc(Gear^.Timer); |
|
297 |
if Gear^.Timer > 75 then |
|
298 |
begin |
|
299 |
DeleteGear(Gear); |
|
300 |
AfterAttack |
|
301 |
end |
|
302 |
end; |
|
303 |
||
4 | 304 |
procedure doStepShotgunShot(Gear: PGear); |
305 |
var i: LongWord; |
|
306 |
begin |
|
307 |
AllInactive:= false; |
|
876 | 308 |
|
309 |
if ((Gear^.State and gstAnimation) = 0) then |
|
310 |
begin |
|
311 |
dec(Gear^.Timer); |
|
312 |
if Gear^.Timer = 0 then |
|
313 |
begin |
|
314 |
PlaySound(sndShotgunFire, false); |
|
315 |
Gear^.State:= Gear^.State or gstAnimation |
|
316 |
end; |
|
317 |
exit |
|
318 |
end |
|
319 |
else inc(Gear^.Timer); |
|
320 |
||
4 | 321 |
i:= 200; |
322 |
repeat |
|
351 | 323 |
Gear^.X:= Gear^.X + Gear^.dX; |
324 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
4 | 325 |
CheckCollision(Gear); |
351 | 326 |
if (Gear^.State and gstCollision) <> 0 then |
876 | 327 |
begin |
328 |
Gear^.X:= Gear^.X + Gear^.dX * 8; |
|
329 |
Gear^.Y:= Gear^.Y + Gear^.dY * 8; |
|
330 |
ShotgunShot(Gear); |
|
331 |
Gear^.doStep:= @doStepShotIdle; |
|
332 |
exit |
|
333 |
end; |
|
4 | 334 |
dec(i) |
335 |
until i = 0; |
|
498 | 336 |
if (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then |
876 | 337 |
Gear^.doStep:= @doStepShotIdle |
4 | 338 |
end; |
339 |
||
340 |
//////////////////////////////////////////////////////////////////////////////// |
|
559 | 341 |
procedure doStepDEagleShotWork(Gear: PGear); |
38 | 342 |
var i, x, y: LongWord; |
351 | 343 |
oX, oY: hwFloat; |
38 | 344 |
begin |
345 |
AllInactive:= false; |
|
876 | 346 |
inc(Gear^.Timer); |
37 | 347 |
i:= 80; |
351 | 348 |
oX:= Gear^.X; |
349 |
oY:= Gear^.Y; |
|
37 | 350 |
repeat |
351 | 351 |
Gear^.X:= Gear^.X + Gear^.dX; |
352 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
353 |
x:= hwRound(Gear^.X); |
|
354 |
y:= hwRound(Gear^.Y); |
|
38 | 355 |
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0) |
351 | 356 |
and (Land[y, x] <> 0) then inc(Gear^.Damage); |
519 | 357 |
if Gear^.Damage > 5 then AmmoShove(Gear, 7, 20); |
38 | 358 |
dec(i) |
351 | 359 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
360 |
if Gear^.Damage > 0 then |
|
37 | 361 |
begin |
351 | 362 |
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82 - i, 1); |
363 |
dec(Gear^.Health, Gear^.Damage); |
|
364 |
Gear^.Damage:= 0 |
|
37 | 365 |
end; |
498 | 366 |
if (Gear^.Health <= 0) or (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then |
876 | 367 |
Gear^.doStep:= @doStepShotIdle |
37 | 368 |
end; |
369 |
||
559 | 370 |
procedure doStepDEagleShot(Gear: PGear); |
371 |
begin |
|
372 |
PlaySound(sndGun, false); |
|
373 |
Gear^.doStep:= @doStepDEagleShotWork |
|
374 |
end; |
|
375 |
||
37 | 376 |
//////////////////////////////////////////////////////////////////////////////// |
4 | 377 |
procedure doStepActionTimer(Gear: PGear); |
378 |
begin |
|
351 | 379 |
dec(Gear^.Timer); |
380 |
case Gear^.Kind of |
|
83 | 381 |
gtATStartGame: begin |
4 | 382 |
AllInactive:= false; |
351 | 383 |
if Gear^.Timer = 0 then |
83 | 384 |
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); |
4 | 385 |
end; |
83 | 386 |
gtATSmoothWindCh: begin |
351 | 387 |
if Gear^.Timer = 0 then |
6 | 388 |
begin |
351 | 389 |
if WindBarWidth < Gear^.Tag then inc(WindBarWidth) |
390 |
else if WindBarWidth > Gear^.Tag then dec(WindBarWidth); |
|
391 |
if WindBarWidth <> Gear^.Tag then Gear^.Timer:= 10; |
|
83 | 392 |
end |
393 |
end; |
|
394 |
gtATFinishGame: begin |
|
395 |
AllInactive:= false; |
|
351 | 396 |
if Gear^.Timer = 0 then |
113 | 397 |
begin |
398 |
SendIPC('N'); |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
399 |
SendIPC('q'); |
83 | 400 |
GameState:= gsExit |
113 | 401 |
end |
6 | 402 |
end; |
4 | 403 |
end; |
351 | 404 |
if Gear^.Timer = 0 then DeleteGear(Gear) |
4 | 405 |
end; |
406 |
||
407 |
//////////////////////////////////////////////////////////////////////////////// |
|
408 |
procedure doStepPickHammerWork(Gear: PGear); |
|
371 | 409 |
var i, ei: LongInt; |
4 | 410 |
HHGear: PGear; |
411 |
begin |
|
70 | 412 |
AllInactive:= false; |
351 | 413 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
414 |
dec(Gear^.Timer); |
|
415 |
if (Gear^.Timer = 0)or((Gear^.Message and gm_Destroy) <> 0)or((HHGear^.State and gstHHDriven) = 0) then |
|
4 | 416 |
begin |
282 | 417 |
StopSound(sndPickhammer); |
4 | 418 |
DeleteGear(Gear); |
419 |
AfterAttack; |
|
420 |
exit |
|
421 |
end; |
|
845 | 422 |
|
422 | 423 |
if (Gear^.Timer mod 33) = 0 then |
424 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y) + 6, 6, EXPLDontDraw); |
|
425 |
||
426 |
if (Gear^.Timer mod 47) = 0 then |
|
4 | 427 |
begin |
371 | 428 |
i:= hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
429 |
ei:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
4 | 430 |
while i <= ei do |
431 |
begin |
|
422 | 432 |
DrawExplosion(i, hwRound(Gear^.Y) + 3, 3); |
4 | 433 |
inc(i, 1) |
434 |
end; |
|
351 | 435 |
Gear^.X:= Gear^.X + Gear^.dX; |
436 |
Gear^.Y:= Gear^.Y + _1_9; |
|
42 | 437 |
SetAllHHToActive; |
4 | 438 |
end; |
439 |
if TestCollisionYwithGear(Gear, 1) then |
|
440 |
begin |
|
498 | 441 |
Gear^.dY:= _0; |
351 | 442 |
SetLittle(HHGear^.dX); |
498 | 443 |
HHGear^.dY:= _0; |
4 | 444 |
end else |
445 |
begin |
|
351 | 446 |
Gear^.dY:= Gear^.dY + cGravity; |
447 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 448 |
if Gear^.Y > _1024 then Gear^.Timer:= 1 |
4 | 449 |
end; |
450 |
||
351 | 451 |
Gear^.X:= Gear^.X + HHGear^.dX; |
452 |
HHGear^.X:= Gear^.X; |
|
498 | 453 |
HHGear^.Y:= Gear^.Y - int2hwFloat(cHHRadius); |
4 | 454 |
|
351 | 455 |
if (Gear^.Message and gm_Attack) <> 0 then |
456 |
if (Gear^.State and gsttmpFlag) <> 0 then Gear^.Timer:= 1 else else |
|
457 |
if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
458 |
if ((Gear^.Message and gm_Left) <> 0) then Gear^.dX:= - _0_3 else |
|
459 |
if ((Gear^.Message and gm_Right) <> 0) then Gear^.dX:= _0_3 |
|
498 | 460 |
else Gear^.dX:= _0; |
4 | 461 |
end; |
462 |
||
463 |
procedure doStepPickHammer(Gear: PGear); |
|
371 | 464 |
var i, y: LongInt; |
4 | 465 |
ar: TRangeArray; |
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
466 |
HHGear: PGear; |
4 | 467 |
begin |
468 |
i:= 0; |
|
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
469 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
470 |
|
498 | 471 |
y:= hwRound(Gear^.Y) - cHHRadius * 2; |
351 | 472 |
while y < hwRound(Gear^.Y) do |
4 | 473 |
begin |
371 | 474 |
ar[i].Left := hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
475 |
ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
4 | 476 |
inc(y, 2); |
477 |
inc(i) |
|
478 |
end; |
|
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
479 |
|
498 | 480 |
DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius * 2, 2, Pred(i)); |
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
481 |
Gear^.dY:= HHGear^.dY; |
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
482 |
DeleteCI(HHGear); |
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
483 |
|
282 | 484 |
PlaySound(sndPickhammer, true); |
4 | 485 |
doStepPickHammerWork(Gear); |
351 | 486 |
Gear^.doStep:= @doStepPickHammerWork |
4 | 487 |
end; |
488 |
||
489 |
//////////////////////////////////////////////////////////////////////////////// |
|
371 | 490 |
var BTPrevAngle, BTSteps: LongInt; |
302 | 491 |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
492 |
procedure doStepBlowTorchWork(Gear: PGear); |
302 | 493 |
var HHGear: PGear; |
305 | 494 |
b: boolean; |
302 | 495 |
begin |
496 |
AllInactive:= false; |
|
351 | 497 |
dec(Gear^.Timer); |
498 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
499 |
|
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
500 |
HedgehogChAngle(HHGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
501 |
|
305 | 502 |
b:= false; |
503 |
||
371 | 504 |
if abs(LongInt(HHGear^.Angle) - BTPrevAngle) > 7 then |
305 | 505 |
begin |
498 | 506 |
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX); |
355 | 507 |
Gear^.dY:= AngleCos(HHGear^.Angle) * ( - _0_5); |
351 | 508 |
BTPrevAngle:= HHGear^.Angle; |
358 | 509 |
b:= true |
305 | 510 |
end; |
511 |
||
351 | 512 |
if Gear^.Timer mod cHHStepTicks = 0 then |
302 | 513 |
begin |
305 | 514 |
b:= true; |
498 | 515 |
if Gear^.dX.isNegative then HHGear^.Message:= (HHGear^.Message or gm_Left) and not gm_Right |
516 |
else HHGear^.Message:= (HHGear^.Message or gm_Right) and not gm_Left; |
|
357 | 517 |
|
518 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
302 | 519 |
HedgehogStep(HHGear); |
357 | 520 |
HHGear^.State:= HHGear^.State or gstAttacking; |
305 | 521 |
|
522 |
inc(BTSteps); |
|
511 | 523 |
if BTSteps = 7 then |
305 | 524 |
begin |
525 |
BTSteps:= 0; |
|
511 | 526 |
Gear^.X:= HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); |
527 |
Gear^.Y:= HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); |
|
351 | 528 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
511 | 529 |
AmmoShove(Gear, 2, 14); |
351 | 530 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
305 | 531 |
end; |
532 |
||
542 | 533 |
if (HHGear^.State and gstMoving) <> 0 then Gear^.Timer:= 0 |
302 | 534 |
end; |
305 | 535 |
|
536 |
if b then |
|
498 | 537 |
DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - _4 - Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, |
351 | 538 |
Gear^.dX, Gear^.dY, |
306 | 539 |
cHHRadius * 5, cHHRadius * 2 + 6); |
305 | 540 |
|
351 | 541 |
if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) then |
302 | 542 |
begin |
351 | 543 |
HHGear^.Message:= 0; |
302 | 544 |
DeleteGear(Gear); |
545 |
AfterAttack |
|
546 |
end |
|
547 |
end; |
|
548 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
549 |
procedure doStepBlowTorch(Gear: PGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
550 |
var HHGear: PGear; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
551 |
begin |
371 | 552 |
BTPrevAngle:= High(LongInt); |
305 | 553 |
BTSteps:= 0; |
351 | 554 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
555 |
HHGear^.Message:= 0; |
|
556 |
Gear^.doStep:= @doStepBlowTorchWork |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
557 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
558 |
|
302 | 559 |
//////////////////////////////////////////////////////////////////////////////// |
560 |
||
4 | 561 |
procedure doStepRopeWork(Gear: PGear); |
70 | 562 |
const flCheck: boolean = false; |
4 | 563 |
var HHGear: PGear; |
789 | 564 |
len, cs, cc, tx, ty, nx, ny: hwFloat; |
108 | 565 |
lx, ly: LongInt; |
4 | 566 |
|
567 |
procedure DeleteMe; |
|
568 |
begin |
|
569 |
with HHGear^ do |
|
570 |
begin |
|
571 |
Message:= Message and not gm_Attack; |
|
542 | 572 |
State:= State or gstMoving; |
4 | 573 |
end; |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
574 |
DeleteGear(Gear) |
4 | 575 |
end; |
576 |
||
577 |
begin |
|
351 | 578 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
108 | 579 |
|
351 | 580 |
if ((HHGear^.State and gstHHDriven) = 0) |
80 | 581 |
or (CheckGearDrowning(HHGear)) then |
4 | 582 |
begin |
583 |
DeleteMe; |
|
584 |
exit |
|
585 |
end; |
|
928
b9064b48b001
Some preparation work for attacking from rope, parachute and etc.
unc0rr
parents:
925
diff
changeset
|
586 |
|
351 | 587 |
Gear^.dX:= HHGear^.X - Gear^.X; |
588 |
Gear^.dY:= HHGear^.Y - Gear^.Y; |
|
4 | 589 |
|
351 | 590 |
if (Gear^.Message and gm_Left <> 0) then HHGear^.dX:= HHGear^.dX - _0_0002 else |
591 |
if (Gear^.Message and gm_Right <> 0) then HHGear^.dX:= HHGear^.dX + _0_0002; |
|
4 | 592 |
|
351 | 593 |
if not TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= HHGear^.dY + cGravity; |
4 | 594 |
|
351 | 595 |
cs:= Gear^.dY + HHGear^.dY; |
596 |
cc:= Gear^.dX + HHGear^.dX; |
|
498 | 597 |
len:= _1 / Distance(cc, cs); |
789 | 598 |
cc:= cc * len; // rope vector plus hedgehog direction vector normalized |
108 | 599 |
cs:= cs * len; |
4 | 600 |
|
940 | 601 |
nx:= hwAbs(cs) * hwSign(HHGear^.dX) * 5; // hedgehog direction normalized with length 3 |
602 |
ny:= hwAbs(cc) * hwSign(HHGear^.dY) * 5; |
|
789 | 603 |
|
4 | 604 |
flCheck:= not flCheck; |
605 |
if flCheck then // check whether rope needs dividing |
|
606 |
begin |
|
498 | 607 |
len:= Gear^.Elasticity - _20; |
608 |
while len > _5 do |
|
4 | 609 |
begin |
610 |
tx:= cc*len; |
|
611 |
ty:= cs*len; |
|
789 | 612 |
lx:= hwRound(Gear^.X + tx + nx); |
613 |
ly:= hwRound(Gear^.Y + ty + ny); |
|
652 | 614 |
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0) and (Land[ly, lx] <> 0) then |
4 | 615 |
begin |
616 |
with RopePoints.ar[RopePoints.Count] do |
|
617 |
begin |
|
351 | 618 |
X:= Gear^.X; |
619 |
Y:= Gear^.Y; |
|
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
620 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); |
351 | 621 |
b:= (cc * HHGear^.dY) > (cs * HHGear^.dX); |
4 | 622 |
dLen:= len |
623 |
end; |
|
351 | 624 |
Gear^.X:= Gear^.X + tx; |
625 |
Gear^.Y:= Gear^.Y + ty; |
|
4 | 626 |
inc(RopePoints.Count); |
789 | 627 |
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); |
351 | 628 |
Gear^.Elasticity:= Gear^.Elasticity - len; |
629 |
Gear^.Friction:= Gear^.Friction - len; |
|
4 | 630 |
break |
631 |
end; |
|
789 | 632 |
len:= len - _2 |
4 | 633 |
end; |
634 |
end else |
|
635 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
|
636 |
begin |
|
637 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
638 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
351 | 639 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then |
4 | 640 |
begin |
641 |
dec(RopePoints.Count); |
|
351 | 642 |
Gear^.X:=RopePoints.ar[RopePoints.Count].X; |
643 |
Gear^.Y:=RopePoints.ar[RopePoints.Count].Y; |
|
644 |
Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
|
645 |
Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
4 | 646 |
end |
647 |
end; |
|
648 |
||
351 | 649 |
Gear^.dX:= HHGear^.X - Gear^.X; |
650 |
Gear^.dY:= HHGear^.Y - Gear^.Y; |
|
108 | 651 |
|
351 | 652 |
cs:= Gear^.dY + HHGear^.dY; |
653 |
cc:= Gear^.dX + HHGear^.dX; |
|
498 | 654 |
len:= _1 / Distance(cc, cs); |
108 | 655 |
cc:= cc * len; |
656 |
cs:= cs * len; |
|
4 | 657 |
|
351 | 658 |
HHGear^.dX:= HHGear^.X; |
659 |
HHGear^.dY:= HHGear^.Y; |
|
4 | 660 |
|
351 | 661 |
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then |
662 |
if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
|
663 |
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity + _0_3; |
|
4 | 664 |
|
498 | 665 |
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then |
351 | 666 |
if not (TestCollisionXwithGear(HHGear, -hwSign(Gear^.dX)) |
667 |
or TestCollisionYwithGear(HHGear, -hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity - _0_3; |
|
4 | 668 |
|
351 | 669 |
HHGear^.X:= Gear^.X + cc*Gear^.Elasticity; |
670 |
HHGear^.Y:= Gear^.Y + cs*Gear^.Elasticity; |
|
4 | 671 |
|
351 | 672 |
HHGear^.dX:= HHGear^.X - HHGear^.dX; |
673 |
HHGear^.dY:= HHGear^.Y - HHGear^.dY; |
|
4 | 674 |
|
351 | 675 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
676 |
HHGear^.dX:= -_0_6 * HHGear^.dX; |
|
677 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then |
|
678 |
HHGear^.dY:= -_0_6 * HHGear^.dY; |
|
4 | 679 |
|
789 | 680 |
len:= Distance(HHGear^.dX, HHGear^.dY); |
940 | 681 |
if len > _0_8 then |
789 | 682 |
begin |
940 | 683 |
len:= _0_8 / len; |
789 | 684 |
HHGear^.dX:= HHGear^.dX * len; |
685 |
HHGear^.dY:= HHGear^.dY * len; |
|
686 |
end; |
|
687 |
||
351 | 688 |
if (Gear^.Message and gm_Attack) <> 0 then |
689 |
if (Gear^.State and gsttmpFlag) <> 0 then DeleteMe else |
|
690 |
else if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
4 | 691 |
end; |
692 |
||
693 |
||
694 |
procedure doStepRopeAttach(Gear: PGear); |
|
695 |
var HHGear: PGear; |
|
351 | 696 |
tx, ty, tt: hwFloat; |
4 | 697 |
begin |
351 | 698 |
Gear^.X:= Gear^.X - Gear^.dX; |
699 |
Gear^.Y:= Gear^.Y - Gear^.dY; |
|
498 | 700 |
Gear^.Elasticity:= Gear^.Elasticity + _1; |
351 | 701 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
517 | 702 |
DeleteCI(HHGear); |
542 | 703 |
if (HHGear^.State and gstMoving) <> 0 then |
68 | 704 |
if TestCollisionYwithGear(HHGear, 1) then |
4 | 705 |
begin |
820
a26537586400
Fix fall without damage trick, which could be performed with not attached rope
unc0rr
parents:
819
diff
changeset
|
706 |
CheckHHDamage(HHGear); |
498 | 707 |
HHGear^.dY:= _0; |
542 | 708 |
HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); |
4 | 709 |
end else |
710 |
begin |
|
351 | 711 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
712 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
713 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
714 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
715 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
716 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
717 |
tt:= Gear^.Elasticity; |
|
498 | 718 |
tx:= _0; |
719 |
ty:= _0; |
|
720 |
while tt > _20 do |
|
4 | 721 |
begin |
517 | 722 |
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) |
723 |
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then |
|
4 | 724 |
begin |
351 | 725 |
Gear^.X:= Gear^.X + tx; |
726 |
Gear^.Y:= Gear^.Y + ty; |
|
727 |
Gear^.Elasticity:= tt; |
|
728 |
Gear^.doStep:= @doStepRopeWork; |
|
4 | 729 |
with HHGear^ do State:= State and not gstAttacking; |
498 | 730 |
tt:= _0 |
4 | 731 |
end; |
517 | 732 |
tx:= tx + Gear^.dX + Gear^.dX; |
733 |
ty:= ty + Gear^.dY + Gear^.dY; |
|
498 | 734 |
tt:= tt - _2; |
4 | 735 |
end; |
736 |
end; |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
737 |
|
4 | 738 |
CheckCollision(Gear); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
739 |
|
351 | 740 |
if (Gear^.State and gstCollision) <> 0 then |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
741 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
742 |
Gear^.doStep:= @doStepRopeWork; |
974
fc16141a0128
Prevent wrong aim direction when using rope after high jump
unc0rr
parents:
963
diff
changeset
|
743 |
with HHGear^ do State:= State and not (gstAttacking or gstHHHJump); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
744 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
745 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
746 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
747 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
748 |
if Gear^.Elasticity < _10 then |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
749 |
Gear^.Elasticity:= _10000; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
750 |
end; |
4 | 751 |
|
351 | 752 |
if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then |
4 | 753 |
begin |
351 | 754 |
with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
4 | 755 |
begin |
756 |
State:= State and not gstAttacking; |
|
757 |
Message:= Message and not gm_Attack |
|
758 |
end; |
|
759 |
DeleteGear(Gear) |
|
760 |
end |
|
761 |
end; |
|
762 |
||
763 |
procedure doStepRope(Gear: PGear); |
|
764 |
begin |
|
351 | 765 |
Gear^.dX:= - Gear^.dX; |
766 |
Gear^.dY:= - Gear^.dY; |
|
767 |
Gear^.doStep:= @doStepRopeAttach |
|
4 | 768 |
end; |
769 |
||
770 |
//////////////////////////////////////////////////////////////////////////////// |
|
771 |
procedure doStepSmokeTrace(Gear: PGear); |
|
772 |
begin |
|
351 | 773 |
inc(Gear^.Timer); |
774 |
if Gear^.Timer > 64 then |
|
4 | 775 |
begin |
351 | 776 |
Gear^.Timer:= 0; |
777 |
dec(Gear^.State) |
|
4 | 778 |
end; |
351 | 779 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
780 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
781 |
if Gear^.State = 0 then DeleteGear(Gear) |
|
4 | 782 |
end; |
9 | 783 |
|
784 |
//////////////////////////////////////////////////////////////////////////////// |
|
1045 | 785 |
procedure doStepExplosionWork(Gear: PGear); |
9 | 786 |
begin |
351 | 787 |
inc(Gear^.Timer); |
788 |
if Gear^.Timer > 75 then |
|
9 | 789 |
begin |
351 | 790 |
inc(Gear^.State); |
791 |
Gear^.Timer:= 0; |
|
792 |
if Gear^.State > 5 then DeleteGear(Gear) |
|
9 | 793 |
end; |
794 |
end; |
|
10 | 795 |
|
1045 | 796 |
procedure doStepExplosion(Gear: PGear); |
797 |
var i: LongWord; |
|
798 |
begin |
|
1047 | 799 |
for i:= 0 to 31 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFire); |
800 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart); |
|
801 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart2); |
|
1045 | 802 |
Gear^.doStep:= @doStepExplosionWork |
803 |
end; |
|
804 |
||
10 | 805 |
//////////////////////////////////////////////////////////////////////////////// |
806 |
procedure doStepMine(Gear: PGear); |
|
807 |
begin |
|
542 | 808 |
if (Gear^.State and gstMoving) <> 0 then |
914 | 809 |
begin |
810 |
DeleteCI(Gear); |
|
811 |
doStepFallingGear(Gear); |
|
812 |
if (Gear^.State and gstMoving) = 0 then |
|
813 |
begin |
|
814 |
AddGearCI(Gear); |
|
815 |
Gear^.dX:= _0; |
|
816 |
Gear^.dY:= _0 |
|
817 |
end; |
|
818 |
CalcRotationDirAngle(Gear); |
|
819 |
AllInactive:= false |
|
820 |
end else |
|
821 |
if ((GameTicks and $3F) = 25) then |
|
822 |
doStepFallingGear(Gear); |
|
351 | 823 |
|
824 |
if ((Gear^.State and gsttmpFlag) <> 0) then |
|
825 |
if ((Gear^.State and gstAttacking) = 0) then |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
826 |
begin |
914 | 827 |
if ((GameTicks and $1F) = 0) then |
351 | 828 |
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
|
829 |
end else // gstAttacking <> 0 |
10 | 830 |
begin |
831 |
AllInactive:= false; |
|
351 | 832 |
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false); |
833 |
if Gear^.Timer = 0 then |
|
10 | 834 |
begin |
351 | 835 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
521 | 836 |
DeleteGear(Gear); |
837 |
exit |
|
10 | 838 |
end; |
351 | 839 |
dec(Gear^.Timer); |
13 | 840 |
end else // gsttmpFlag = 0 |
351 | 841 |
if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
10 | 842 |
end; |
57 | 843 |
|
39 | 844 |
//////////////////////////////////////////////////////////////////////////////// |
845 |
procedure doStepDynamite(Gear: PGear); |
|
846 |
begin |
|
43 | 847 |
doStepFallingGear(Gear); |
848 |
AllInactive:= false; |
|
351 | 849 |
if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); |
850 |
if Gear^.Timer = 0 then |
|
39 | 851 |
begin |
351 | 852 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
43 | 853 |
DeleteGear(Gear); |
854 |
exit |
|
39 | 855 |
end; |
351 | 856 |
dec(Gear^.Timer); |
39 | 857 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
858 |
|
351 | 859 |
/////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
860 |
procedure doStepCase(Gear: PGear); |
371 | 861 |
var i, x, y: LongInt; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
862 |
begin |
351 | 863 |
if (Gear^.Message and gm_Destroy) > 0 then |
15 | 864 |
begin |
865 |
DeleteGear(Gear); |
|
435 | 866 |
FreeActionsList; |
913 | 867 |
SetAllToActive; // something (hh, mine, etc...) could be on top of the case |
602 | 868 |
with CurrentHedgehog^ do |
441 | 869 |
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
15 | 870 |
exit |
871 |
end; |
|
872 |
||
351 | 873 |
if Gear^.Damage > 0 then |
79 | 874 |
begin |
351 | 875 |
x:= hwRound(Gear^.X); |
876 |
y:= hwRound(Gear^.Y); |
|
79 | 877 |
DeleteGear(Gear); |
590 | 878 |
if Gear^.Kind = gtCase then |
879 |
begin |
|
880 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
|
881 |
for i:= 0 to 63 do |
|
882 |
AddGear(x, y, gtFlame, 0, _0, _0, 0); |
|
883 |
end; |
|
79 | 884 |
exit |
885 |
end; |
|
886 |
||
351 | 887 |
if (Gear^.dY.QWordValue <> 0) or (not TestCollisionYwithGear(Gear, 1)) then |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
888 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
889 |
AllInactive:= false; |
351 | 890 |
Gear^.dY:= Gear^.dY + cGravity; |
891 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 892 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else |
439 | 893 |
if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
894 |
begin |
351 | 895 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
498 | 896 |
if Gear^.dY > - _0_001 then Gear^.dY:= _0 |
351 | 897 |
else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false); |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
898 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
899 |
CheckGearDrowning(Gear); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
900 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
901 |
|
511 | 902 |
if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
903 |
else if (Gear^.dY.QWordValue <> 0) then DeleteCI(Gear) |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
904 |
end; |
49 | 905 |
|
906 |
//////////////////////////////////////////////////////////////////////////////// |
|
557 | 907 |
const cSorterWorkTime = 640; |
908 |
var thexchar: array[0..cMaxTeams] of |
|
909 |
record |
|
910 |
dy, ny, dw: LongInt; |
|
49 | 911 |
team: PTeam; |
557 | 912 |
SortFactor: QWord; |
49 | 913 |
end; |
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
914 |
currsorter: PGear = nil; |
49 | 915 |
|
916 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
371 | 917 |
var i: LongInt; |
49 | 918 |
begin |
919 |
AllInactive:= false; |
|
351 | 920 |
dec(Gear^.Timer); |
921 |
if (Gear^.Timer and 15) = 0 then |
|
557 | 922 |
for i:= 0 to Pred(TeamsCount) do |
49 | 923 |
with thexchar[i] do |
557 | 924 |
begin |
49 | 925 |
{$WARNINGS OFF} |
557 | 926 |
team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; |
927 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; |
|
49 | 928 |
{$WARNINGS ON} |
557 | 929 |
end; |
351 | 930 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
143 | 931 |
begin |
932 |
if currsorter = Gear then currsorter:= nil; |
|
49 | 933 |
DeleteGear(Gear) |
143 | 934 |
end |
49 | 935 |
end; |
936 |
||
937 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
547 | 938 |
var i, t: Longword; |
557 | 939 |
b: boolean; |
49 | 940 |
begin |
941 |
AllInactive:= false; |
|
557 | 942 |
|
547 | 943 |
for t:= 0 to Pred(TeamsCount) do |
557 | 944 |
with thexchar[t] do |
49 | 945 |
begin |
557 | 946 |
dy:= TeamsArray[t]^.DrawHealthY; |
947 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
948 |
team:= TeamsArray[t]; |
|
949 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
950 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
951 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
49 | 952 |
end; |
547 | 953 |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
954 |
if TeamsCount > 1 then |
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
955 |
repeat |
557 | 956 |
b:= true; |
957 |
for t:= 0 to TeamsCount - 2 do |
|
958 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
49 | 959 |
begin |
557 | 960 |
thexchar[cMaxTeams]:= thexchar[t]; |
49 | 961 |
thexchar[t]:= thexchar[Succ(t)]; |
557 | 962 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
963 |
b:= false |
|
964 |
end |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
965 |
until b; |
557 | 966 |
|
49 | 967 |
t:= cScreenHeight - 4; |
557 | 968 |
for i:= 0 to Pred(TeamsCount) do |
49 | 969 |
with thexchar[i] do |
970 |
begin |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
971 |
dec(t, team^.HealthTex^.h + 2); |
557 | 972 |
ny:= t; |
973 |
dy:= dy - ny |
|
49 | 974 |
end; |
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
975 |
|
557 | 976 |
Gear^.Timer:= cSorterWorkTime; |
351 | 977 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
143 | 978 |
currsorter:= Gear |
49 | 979 |
end; |
980 |
||
79 | 981 |
//////////////////////////////////////////////////////////////////////////////// |
854 | 982 |
procedure doStepIdle(Gear: PGear); |
983 |
begin |
|
984 |
AllInactive:= false; |
|
925 | 985 |
dec(Gear^.Timer); |
854 | 986 |
if Gear^.Timer = 0 then |
987 |
begin |
|
988 |
DeleteGear(Gear); |
|
989 |
AfterAttack |
|
990 |
end |
|
991 |
end; |
|
992 |
||
79 | 993 |
procedure doStepShover(Gear: PGear); |
994 |
var HHGear: PGear; |
|
995 |
begin |
|
351 | 996 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
997 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
998 |
DeleteCI(HHGear); |
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
999 |
|
79 | 1000 |
AmmoShove(Gear, 30, 115); |
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1001 |
|
351 | 1002 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
854 | 1003 |
Gear^.Timer:= 250; |
1004 |
Gear^.doStep:= @doStepIdle |
|
79 | 1005 |
end; |
1006 |
||
1007 |
//////////////////////////////////////////////////////////////////////////////// |
|
925 | 1008 |
procedure doStepWhip(Gear: PGear); |
1009 |
var HHGear: PGear; |
|
1010 |
i: LongInt; |
|
1011 |
begin |
|
1012 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1013 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1014 |
DeleteCI(HHGear); |
925 | 1015 |
|
1016 |
for i:= 0 to 3 do |
|
1017 |
begin |
|
1018 |
AmmoShove(Gear, 30, 25); |
|
1019 |
Gear^.X:= Gear^.X + Gear^.dX * 5 |
|
1020 |
end; |
|
1021 |
||
1022 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
|
1023 |
Gear^.Timer:= 250; |
|
1024 |
Gear^.doStep:= @doStepIdle |
|
1025 |
end; |
|
1026 |
||
1027 |
//////////////////////////////////////////////////////////////////////////////// |
|
79 | 1028 |
procedure doStepFlame(Gear: PGear); |
1029 |
begin |
|
1030 |
AllInactive:= false; |
|
1031 |
if not TestCollisionYwithGear(Gear, 1) then |
|
1032 |
begin |
|
351 | 1033 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
1034 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1035 |
if hwAbs(Gear^.dX) > _0_1 then Gear^.dX:= Gear^.dX * _0_5; |
|
1036 |
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; |
|
1037 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1038 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 1039 |
if not (Gear^.Y < _1024) then |
79 | 1040 |
begin |
1041 |
DeleteGear(Gear); |
|
1042 |
exit |
|
1043 |
end |
|
1044 |
end else begin |
|
351 | 1045 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
79 | 1046 |
else begin |
506 | 1047 |
// doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 2, 0); |
351 | 1048 |
dec(Gear^.Health); |
1049 |
Gear^.Timer:= 1250 - Gear^.Angle * 12 |
|
79 | 1050 |
end |
1051 |
end; |
|
1052 |
||
351 | 1053 |
if (((GameTicks div 8) mod 64) = Gear^.Angle) then |
79 | 1054 |
AmmoFlameWork(Gear); |
1055 |
||
351 | 1056 |
if Gear^.Health = 0 then |
79 | 1057 |
DeleteGear(Gear) |
1058 |
end; |
|
82 | 1059 |
|
1060 |
//////////////////////////////////////////////////////////////////////////////// |
|
1061 |
procedure doStepFirePunchWork(Gear: PGear); |
|
1062 |
var HHGear: PGear; |
|
1063 |
begin |
|
1064 |
AllInactive:= false; |
|
351 | 1065 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
82 | 1066 |
begin |
1067 |
DeleteGear(Gear); |
|
1068 |
AfterAttack; |
|
1069 |
exit |
|
1070 |
end; |
|
1071 |
||
351 | 1072 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1073 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
82 | 1074 |
begin |
351 | 1075 |
Gear^.Tag:= hwRound(HHGear^.Y); |
498 | 1076 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
351 | 1077 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
1078 |
Gear^.Y:= HHGear^.Y; |
|
82 | 1079 |
AmmoShove(Gear, 30, 40); |
351 | 1080 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
82 | 1081 |
end; |
351 | 1082 |
|
1083 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1084 |
if not (HHGear^.dY.isNegative) then |
|
82 | 1085 |
begin |
542 | 1086 |
HHGear^.State:= HHGear^.State or gstMoving; |
82 | 1087 |
DeleteGear(Gear); |
1088 |
AfterAttack; |
|
1089 |
exit |
|
1090 |
end; |
|
351 | 1091 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1092 |
end; |
1093 |
||
1094 |
procedure doStepFirePunch(Gear: PGear); |
|
1095 |
var HHGear: PGear; |
|
1096 |
begin |
|
1097 |
AllInactive:= false; |
|
351 | 1098 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1099 |
DeleteCI(HHGear); |
498 | 1100 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1101 |
HHGear^.dX:= SignAs(cLittle, Gear^.dX); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1102 |
|
351 | 1103 |
HHGear^.dY:= - _0_3; |
82 | 1104 |
|
351 | 1105 |
Gear^.X:= HHGear^.X; |
979
edb8f208c1d9
Fix firepunch direction when attacking from high jump
unc0rr
parents:
974
diff
changeset
|
1106 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
351 | 1107 |
Gear^.dY:= - _0_9; |
1108 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1109 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
82 | 1110 |
end; |
1111 |
||
263 | 1112 |
//////////////////////////////////////////////////////////////////////////////// |
1113 |
||
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1114 |
procedure doStepParachuteWork(Gear: PGear); |
211 | 1115 |
var HHGear: PGear; |
1116 |
begin |
|
351 | 1117 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
82 | 1118 |
|
516 | 1119 |
inc(Gear^.Timer); |
1120 |
||
212 | 1121 |
if TestCollisionYwithGear(HHGear, 1) |
351 | 1122 |
or ((HHGear^.State and gstHHDriven) = 0) |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1123 |
or CheckGearDrowning(HHGear) |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1124 |
or ((Gear^.Message and gm_Attack) <> 0) then |
211 | 1125 |
begin |
1126 |
with HHGear^ do |
|
1127 |
begin |
|
1128 |
Message:= 0; |
|
568 | 1129 |
SetLittle(dX); |
498 | 1130 |
dY:= _0; |
542 | 1131 |
State:= State or gstMoving; |
211 | 1132 |
end; |
1133 |
DeleteGear(Gear); |
|
1134 |
exit |
|
1135 |
end; |
|
1136 |
||
351 | 1137 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1138 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
|
211 | 1139 |
|
351 | 1140 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1141 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1142 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1143 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1144 |
|
351 | 1145 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1146 |
Gear^.X:= HHGear^.X; |
1147 |
Gear^.Y:= HHGear^.Y |
|
263 | 1148 |
end; |
211 | 1149 |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1150 |
procedure doStepParachute(Gear: PGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1151 |
var HHGear: PGear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1152 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1153 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1154 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1155 |
DeleteCI(HHGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1156 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1157 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1158 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1159 |
|
931 | 1160 |
HHGear^.State:= HHGear^.State and not (gstAttacking or gstAttacked or gstMoving); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1161 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1162 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1163 |
Gear^.doStep:= @doStepParachuteWork; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1164 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1165 |
Gear^.Message:= HHGear^.Message; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1166 |
doStepParachuteWork(Gear) |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1167 |
end; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1168 |
|
263 | 1169 |
//////////////////////////////////////////////////////////////////////////////// |
1170 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1171 |
begin |
|
1172 |
AllInactive:= false; |
|
498 | 1173 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1174 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
263 | 1175 |
begin |
351 | 1176 |
dec(Gear^.Health); |
1177 |
case Gear^.State of |
|
498 | 1178 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
1179 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
285 | 1180 |
end; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1181 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
263 | 1182 |
end; |
498 | 1183 |
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1184 |
end; |
1185 |
||
1186 |
procedure doStepAirAttack(Gear: PGear); |
|
1187 |
begin |
|
1188 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1189 |
|
408 | 1190 |
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 |
1191 |
else Gear^.Tag:= -1; |
|
498 | 1192 |
Gear^.X:= _1024 - _2048 * Gear^.Tag; |
1193 |
Gear^.Y:= -_128; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1194 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1195 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1196 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
498 | 1197 |
Gear^.dX:= Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(TargetPoint.Y) - Gear^.Y) * 2 / cGravity) * Gear^.Tag; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1198 |
|
351 | 1199 |
Gear^.Health:= 6; |
801 | 1200 |
Gear^.doStep:= @doStepAirAttackWork; |
1201 |
PlaySound(sndIncoming, false) |
|
263 | 1202 |
end; |
1203 |
||
1204 |
//////////////////////////////////////////////////////////////////////////////// |
|
1205 |
||
1206 |
procedure doStepAirBomb(Gear: PGear); |
|
1207 |
begin |
|
1208 |
AllInactive:= false; |
|
1209 |
doStepFallingGear(Gear); |
|
351 | 1210 |
if (Gear^.State and gstCollision) <> 0 then |
263 | 1211 |
begin |
351 | 1212 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
263 | 1213 |
DeleteGear(Gear); |
1214 |
exit |
|
1215 |
end; |
|
1216 |
if (GameTicks and $3F) = 0 then |
|
498 | 1217 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1218 |
end; |
409 | 1219 |
|
1220 |
//////////////////////////////////////////////////////////////////////////////// |
|
1221 |
||
1222 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1223 |
var HHGear: PGear; |
409 | 1224 |
begin |
1225 |
AllInactive:= false; |
|
415 | 1226 |
|
1227 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1228 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1229 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1230 |
sprAmGirder, Gear^.State, true) then |
409 | 1231 |
begin |
415 | 1232 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
1233 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1234 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1235 |
DeleteGear(Gear); |
|
1236 |
isCursorVisible:= true |
|
409 | 1237 |
end |
415 | 1238 |
else begin |
1239 |
DeleteGear(Gear); |
|
1240 |
AfterAttack |
|
1241 |
end; |
|
1242 |
TargetPoint.X:= NoPointX |
|
409 | 1243 |
end; |
520 | 1244 |
|
1245 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1246 |
procedure doStepTeleportAfter(Gear: PGear); |
912 | 1247 |
var HHGear: PGear; |
1248 |
begin |
|
1249 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1250 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases |
|
1251 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1252 |
if TestCollisionYwithGear(HHGear, 1) |
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1253 |
or CheckGearDrowning(HHGear) then |
912 | 1254 |
begin |
1255 |
DeleteGear(Gear); |
|
1256 |
AfterAttack |
|
1257 |
end |
|
1258 |
end; |
|
1259 |
||
1260 |
procedure doStepTeleportAnim(Gear: PGear); |
|
525 | 1261 |
begin |
853 | 1262 |
inc(Gear^.Timer); |
1263 |
if Gear^.Timer = 65 then |
|
1264 |
begin |
|
1265 |
Gear^.Timer:= 0; |
|
1266 |
inc(Gear^.Pos); |
|
1267 |
if Gear^.Pos = 11 then |
|
912 | 1268 |
Gear^.doStep:= @doStepTeleportAfter |
853 | 1269 |
end |
525 | 1270 |
end; |
520 | 1271 |
|
1272 |
procedure doStepTeleport(Gear: PGear); |
|
1273 |
var HHGear: PGear; |
|
1274 |
begin |
|
1275 |
AllInactive:= false; |
|
1276 |
||
1277 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1278 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1279 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1280 |
sprHHTelepMask, 0, false) then |
|
853 | 1281 |
begin |
1282 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1283 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1284 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1285 |
DeleteGear(Gear); |
|
1286 |
isCursorVisible:= true |
|
1287 |
end |
|
1288 |
else begin |
|
1289 |
DeleteCI(HHGear); |
|
1290 |
SetAllHHToActive; |
|
912 | 1291 |
Gear^.doStep:= @doStepTeleportAnim; |
853 | 1292 |
Gear^.X:= HHGear^.X; |
1293 |
Gear^.Y:= HHGear^.Y; |
|
1294 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1295 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1296 |
HHGear^.State:= HHGear^.State or gstMoving |
|
1297 |
end; |
|
520 | 1298 |
TargetPoint.X:= NoPointX |
1299 |
end; |
|
534 | 1300 |
|
1301 |
//////////////////////////////////////////////////////////////////////////////// |
|
1302 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1303 |
var HHGear: PGear; |
|
1304 |
Msg, State: Longword; |
|
1305 |
begin |
|
1306 |
AllInactive:= false; |
|
1307 |
||
540 | 1308 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
534 | 1309 |
begin |
1310 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1311 |
Msg:= Gear^.Message and not gm_Switch; |
|
1312 |
DeleteGear(Gear); |
|
538 | 1313 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
1314 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1315 |
|
602 | 1316 |
HHGear:= CurrentHedgehog^.Gear; |
538 | 1317 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
534 | 1318 |
HHGear^.Message:= Msg; |
1319 |
exit |
|
1320 |
end; |
|
1321 |
||
1322 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1323 |
begin |
|
602 | 1324 |
HHGear:= CurrentHedgehog^.Gear; |
534 | 1325 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
809 | 1326 |
Gear^.Message:= Gear^.Message and not gm_Switch; |
534 | 1327 |
State:= HHGear^.State; |
1328 |
HHGear^.State:= 0; |
|
1329 |
HHGear^.Active:= false; |
|
1330 |
HHGear^.Z:= cHHZ; |
|
1331 |
RemoveGearFromList(HHGear); |
|
1332 |
InsertGearToList(HHGear); |
|
1333 |
||
1334 |
repeat |
|
551 | 1335 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
652 | 1336 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
1337 |
||
1338 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
|
534 | 1339 |
|
602 | 1340 |
HHGear:= CurrentHedgehog^.Gear; |
534 | 1341 |
HHGear^.State:= State; |
1342 |
HHGear^.Active:= true; |
|
1343 |
FollowGear:= HHGear; |
|
1344 |
HHGear^.Z:= cCurrHHZ; |
|
1345 |
RemoveGearFromList(HHGear); |
|
1346 |
InsertGearToList(HHGear); |
|
1347 |
Gear^.X:= HHGear^.X; |
|
1348 |
Gear^.Y:= HHGear^.Y |
|
1349 |
end; |
|
1350 |
end; |
|
1351 |
||
1352 |
procedure doStepSwitcher(Gear: PGear); |
|
1353 |
var HHGear: PGear; |
|
1354 |
begin |
|
1355 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1356 |
||
1357 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1358 |
with HHGear^ do |
|
1359 |
begin |
|
1360 |
State:= State and not gstAttacking; |
|
1361 |
Message:= Message and not gm_Attack |
|
1362 |
end |
|
1363 |
end; |
|
924 | 1364 |
|
1365 |
//////////////////////////////////////////////////////////////////////////////// |
|
1366 |
procedure doStepMortar(Gear: PGear); |
|
1367 |
var dX, dY: hwFloat; |
|
1368 |
i: LongInt; |
|
963 | 1369 |
dxn, dyn: boolean; |
924 | 1370 |
begin |
1371 |
AllInactive:= false; |
|
963 | 1372 |
dxn:= Gear^.dX.isNegative; |
1373 |
dyn:= Gear^.dY.isNegative; |
|
1374 |
||
924 | 1375 |
doStepFallingGear(Gear); |
1376 |
if (Gear^.State and gstCollision) <> 0 then |
|
1377 |
begin |
|
1378 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
963 | 1379 |
|
1380 |
Gear^.dX.isNegative:= not dxn; |
|
1381 |
Gear^.dY.isNegative:= not dyn; |
|
924 | 1382 |
for i:= 0 to 4 do |
1383 |
begin |
|
963 | 1384 |
dX:= Gear^.dX + (GetRandom - _0_5) * _0_03; |
1385 |
dY:= Gear^.dY + (GetRandom - _0_5) * _0_03; |
|
924 | 1386 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 0); |
1387 |
end; |
|
1388 |
||
1389 |
DeleteGear(Gear); |
|
1390 |
exit |
|
1391 |
end; |
|
963 | 1392 |
|
924 | 1393 |
if (GameTicks and $3F) = 0 then |
1394 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
1395 |
end; |
|
984 | 1396 |
|
1397 |
//////////////////////////////////////////////////////////////////////////////// |
|
1398 |
procedure doStepKamikazeWork(Gear: PGear); |
|
1399 |
const upd: Longword = 0; |
|
987 | 1400 |
var i: LongWord; |
984 | 1401 |
HHGear: PGear; |
1402 |
begin |
|
1403 |
AllInactive:= false; |
|
1404 |
||
1405 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1406 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1407 |
DeleteCI(HHGear); |
|
1408 |
||
1409 |
i:= 2; |
|
1410 |
repeat |
|
1411 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
1412 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
1413 |
HHGear^.X:= Gear^.X; |
|
1414 |
HHGear^.Y:= Gear^.Y; |
|
1415 |
||
1416 |
inc(Gear^.Damage, 2); |
|
1417 |
||
1418 |
if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
|
1419 |
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); |
|
1420 |
||
1421 |
dec(i) |
|
1422 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
|
1423 |
||
1424 |
inc(upd); |
|
1425 |
if upd > 3 then |
|
1426 |
begin |
|
987 | 1427 |
if Gear^.Health < 1500 then Gear^.Pos:= 2; |
1428 |
||
984 | 1429 |
AmmoShove(Gear, 30, 40); |
1430 |
||
1431 |
DrawTunnel(HHGear^.X - HHGear^.dX * 10, |
|
1432 |
HHGear^.Y - _3 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 5, |
|
1433 |
HHGear^.dX, |
|
1434 |
HHGear^.dY, |
|
1435 |
20 + cHHRadius * 2, |
|
1436 |
cHHRadius * 2 + 4); |
|
1437 |
||
1438 |
upd:= 0 |
|
1439 |
end; |
|
1440 |
||
1441 |
if Gear^.Health < Gear^.Damage then |
|
1442 |
begin |
|
1443 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1444 |
AfterAttack; |
|
1445 |
DeleteGear(Gear); |
|
1446 |
DeleteGear(HHGear); |
|
1447 |
end else |
|
1448 |
begin |
|
1449 |
dec(Gear^.Health, Gear^.Damage); |
|
1450 |
Gear^.Damage:= 0 |
|
1451 |
end |
|
1452 |
end; |
|
1453 |
||
987 | 1454 |
procedure doStepKamikazeIdle(Gear: PGear); |
1455 |
begin |
|
1456 |
AllInactive:= false; |
|
1457 |
dec(Gear^.Timer); |
|
1458 |
if Gear^.Timer = 0 then |
|
1459 |
begin |
|
1460 |
Gear^.Pos:= 1; |
|
992 | 1461 |
PlaySound(sndKamikaze, false); |
987 | 1462 |
Gear^.doStep:= @doStepKamikazeWork |
1463 |
end |
|
1464 |
end; |
|
1465 |
||
984 | 1466 |
procedure doStepKamikaze(Gear: PGear); |
1467 |
var HHGear: PGear; |
|
1468 |
begin |
|
1469 |
AllInactive:= false; |
|
1470 |
||
1471 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1472 |
||
1473 |
HHGear^.dX:= Gear^.dX; |
|
1474 |
HHGear^.dY:= Gear^.dY; |
|
1475 |
||
1476 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
|
1477 |
Gear^.dY:= - _0_9; |
|
1478 |
||
987 | 1479 |
Gear^.Timer:= 550; |
1480 |
||
1481 |
Gear^.doStep:= @doStepKamikazeIdle |
|
984 | 1482 |
end; |
1483 |
||
1103 | 1484 |
//////////////////////////////////////////////////////////////////////////////// |
1485 |
const cakeh = 27; |
|
1486 |
var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; end; |
|
1487 |
CakeI: Longword; |
|
1488 |
||
1089 | 1489 |
procedure doStepCakeWork(Gear: PGear); |
1490 |
const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0)); |
|
1491 |
var xx, yy, xxn, yyn: LongInt; |
|
1492 |
da: LongInt; |
|
1103 | 1493 |
tdx, tdy: hwFloat; |
1089 | 1494 |
|
1495 |
procedure PrevAngle; |
|
1496 |
begin |
|
1497 |
Gear^.Angle:= (Gear^.Angle + 4 - dA) mod 4 |
|
1498 |
end; |
|
1499 |
||
1500 |
procedure NextAngle; |
|
1501 |
begin |
|
1502 |
Gear^.Angle:= (Gear^.Angle + 4 + dA) mod 4 |
|
1503 |
end; |
|
1504 |
||
1088 | 1505 |
begin |
1089 | 1506 |
inc(Gear^.Tag); |
1507 |
if Gear^.Tag < 5 then exit; |
|
1508 |
||
1509 |
dA:= hwSign(Gear^.dX); |
|
1510 |
xx:= dirs[Gear^.Angle].x; |
|
1511 |
yy:= dirs[Gear^.Angle].y; |
|
1512 |
xxn:= dirs[(Gear^.Angle + 4 + dA) mod 4].x; |
|
1513 |
yyn:= dirs[(Gear^.Angle + 4 + dA) mod 4].y; |
|
1514 |
||
1515 |
||
1516 |
if (xx = 0) then |
|
1517 |
if TestCollisionYwithGear(Gear, yy) then |
|
1518 |
PrevAngle |
|
1519 |
else begin |
|
1520 |
Gear^.Tag:= 0; |
|
1521 |
Gear^.Y:= Gear^.Y + int2hwFloat(yy); |
|
1522 |
if not TestCollisionXwithGear(Gear, xxn) then NextAngle |
|
1523 |
end; |
|
1524 |
||
1525 |
if (yy = 0) then |
|
1526 |
if TestCollisionXwithGear(Gear, xx) then |
|
1527 |
PrevAngle |
|
1528 |
else begin |
|
1529 |
Gear^.Tag:= 0; |
|
1530 |
Gear^.X:= Gear^.X + int2hwFloat(xx); |
|
1531 |
if not TestCollisionYwithGear(Gear, yyn) then NextAngle |
|
1532 |
end; |
|
1533 |
||
1103 | 1534 |
if Gear^.Tag = 0 then |
1535 |
begin |
|
1536 |
CakeI:= (CakeI + 1) mod cakeh; |
|
1537 |
tdx:= CakePoints[CakeI].x - Gear^.X; |
|
1538 |
tdy:= - CakePoints[CakeI].y + Gear^.Y; |
|
1539 |
CakePoints[CakeI].x:= Gear^.X; |
|
1540 |
CakePoints[CakeI].y:= Gear^.Y; |
|
1541 |
Gear^.DirAngle:= DxDy2Angle(tdx, tdy); |
|
1542 |
end; |
|
1543 |
||
1089 | 1544 |
dec(Gear^.Health); |
1090 | 1545 |
if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then |
1089 | 1546 |
begin |
1547 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
|
1548 |
AfterAttack; |
|
1549 |
DeleteGear(Gear) |
|
1550 |
end |
|
1088 | 1551 |
end; |
1089 | 1552 |
|
1103 | 1553 |
procedure doStepCakeUp(Gear: PGear); |
1554 |
var i: Longword; |
|
1555 |
begin |
|
1556 |
AllInactive:= false; |
|
1557 |
||
1558 |
begin |
|
1559 |
for i:= 0 to Pred(cakeh) do |
|
1560 |
begin |
|
1561 |
CakePoints[i].x:= Gear^.X; |
|
1562 |
CakePoints[i].y:= Gear^.Y |
|
1563 |
end; |
|
1564 |
CakeI:= 0; |
|
1565 |
Gear^.doStep:= @doStepCakeWork |
|
1566 |
end |
|
1567 |
end; |
|
1568 |
||
1089 | 1569 |
procedure doStepCakeFall(Gear: PGear); |
1570 |
begin |
|
1571 |
AllInactive:= false; |
|
1572 |
||
1573 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1574 |
if TestCollisionYwithGear(Gear, 1) then |
|
1103 | 1575 |
Gear^.doStep:= @doStepCakeUp |
1089 | 1576 |
else |
1577 |
begin |
|
1578 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1579 |
if CheckGearDrowning(Gear) then AfterAttack |
|
1580 |
end |
|
1581 |
end; |
|
1582 |
||
1583 |
procedure doStepCake(Gear: PGear); |
|
1584 |
var HHGear: PGear; |
|
1585 |
begin |
|
1586 |
AllInactive:= false; |
|
1587 |
||
1588 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1103 | 1589 |
HHGear^.Message:= HHGear^.Message and (not gm_Attack); |
1089 | 1590 |
DeleteCI(HHGear); |
1591 |
||
1106 | 1592 |
FollowGear:= Gear; |
1593 |
||
1089 | 1594 |
Gear^.doStep:= @doStepCakeFall |
1595 |
end; |
|
1596 |