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