author | unc0rr |
Sun, 27 Jul 2008 20:03:07 +0000 | |
changeset 1123 | ed713652afae |
parent 1120 | eb5a9f86f9c6 |
child 1124 | 1636a3c7c061 |
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; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1179 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
263 | 1180 |
begin |
351 | 1181 |
dec(Gear^.Health); |
1182 |
case Gear^.State of |
|
498 | 1183 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
1184 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
285 | 1185 |
end; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1186 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
263 | 1187 |
end; |
498 | 1188 |
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1189 |
end; |
1190 |
||
1191 |
procedure doStepAirAttack(Gear: PGear); |
|
1192 |
begin |
|
1193 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1194 |
|
408 | 1195 |
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 |
1196 |
else Gear^.Tag:= -1; |
|
498 | 1197 |
Gear^.X:= _1024 - _2048 * Gear^.Tag; |
1198 |
Gear^.Y:= -_128; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1199 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1200 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1201 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
498 | 1202 |
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
|
1203 |
|
351 | 1204 |
Gear^.Health:= 6; |
801 | 1205 |
Gear^.doStep:= @doStepAirAttackWork; |
1206 |
PlaySound(sndIncoming, false) |
|
263 | 1207 |
end; |
1208 |
||
1209 |
//////////////////////////////////////////////////////////////////////////////// |
|
1210 |
||
1211 |
procedure doStepAirBomb(Gear: PGear); |
|
1212 |
begin |
|
1213 |
AllInactive:= false; |
|
1214 |
doStepFallingGear(Gear); |
|
351 | 1215 |
if (Gear^.State and gstCollision) <> 0 then |
263 | 1216 |
begin |
351 | 1217 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
263 | 1218 |
DeleteGear(Gear); |
1219 |
exit |
|
1220 |
end; |
|
1221 |
if (GameTicks and $3F) = 0 then |
|
498 | 1222 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1223 |
end; |
409 | 1224 |
|
1225 |
//////////////////////////////////////////////////////////////////////////////// |
|
1226 |
||
1227 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1228 |
var HHGear: PGear; |
409 | 1229 |
begin |
1230 |
AllInactive:= false; |
|
415 | 1231 |
|
1232 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1233 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1234 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1235 |
sprAmGirder, Gear^.State, true) then |
409 | 1236 |
begin |
415 | 1237 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
1238 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1239 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1240 |
DeleteGear(Gear); |
|
1241 |
isCursorVisible:= true |
|
409 | 1242 |
end |
415 | 1243 |
else begin |
1244 |
DeleteGear(Gear); |
|
1245 |
AfterAttack |
|
1246 |
end; |
|
1247 |
TargetPoint.X:= NoPointX |
|
409 | 1248 |
end; |
520 | 1249 |
|
1250 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1251 |
procedure doStepTeleportAfter(Gear: PGear); |
912 | 1252 |
var HHGear: PGear; |
1253 |
begin |
|
1254 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1255 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases |
|
1256 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1257 |
if TestCollisionYwithGear(HHGear, 1) |
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1258 |
or CheckGearDrowning(HHGear) then |
912 | 1259 |
begin |
1260 |
DeleteGear(Gear); |
|
1261 |
AfterAttack |
|
1262 |
end |
|
1263 |
end; |
|
1264 |
||
1265 |
procedure doStepTeleportAnim(Gear: PGear); |
|
525 | 1266 |
begin |
853 | 1267 |
inc(Gear^.Timer); |
1268 |
if Gear^.Timer = 65 then |
|
1269 |
begin |
|
1270 |
Gear^.Timer:= 0; |
|
1271 |
inc(Gear^.Pos); |
|
1272 |
if Gear^.Pos = 11 then |
|
912 | 1273 |
Gear^.doStep:= @doStepTeleportAfter |
853 | 1274 |
end |
525 | 1275 |
end; |
520 | 1276 |
|
1277 |
procedure doStepTeleport(Gear: PGear); |
|
1278 |
var HHGear: PGear; |
|
1279 |
begin |
|
1280 |
AllInactive:= false; |
|
1281 |
||
1282 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1283 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1284 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1285 |
sprHHTelepMask, 0, false) then |
|
853 | 1286 |
begin |
1287 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1288 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1289 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1290 |
DeleteGear(Gear); |
|
1291 |
isCursorVisible:= true |
|
1292 |
end |
|
1293 |
else begin |
|
1294 |
DeleteCI(HHGear); |
|
1295 |
SetAllHHToActive; |
|
912 | 1296 |
Gear^.doStep:= @doStepTeleportAnim; |
853 | 1297 |
Gear^.X:= HHGear^.X; |
1298 |
Gear^.Y:= HHGear^.Y; |
|
1299 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1300 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1301 |
HHGear^.State:= HHGear^.State or gstMoving |
|
1302 |
end; |
|
520 | 1303 |
TargetPoint.X:= NoPointX |
1304 |
end; |
|
534 | 1305 |
|
1306 |
//////////////////////////////////////////////////////////////////////////////// |
|
1307 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1308 |
var HHGear: PGear; |
|
1309 |
Msg, State: Longword; |
|
1310 |
begin |
|
1311 |
AllInactive:= false; |
|
1312 |
||
540 | 1313 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
534 | 1314 |
begin |
1315 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1316 |
Msg:= Gear^.Message and not gm_Switch; |
|
1317 |
DeleteGear(Gear); |
|
538 | 1318 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
1319 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1320 |
|
602 | 1321 |
HHGear:= CurrentHedgehog^.Gear; |
538 | 1322 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
534 | 1323 |
HHGear^.Message:= Msg; |
1324 |
exit |
|
1325 |
end; |
|
1326 |
||
1327 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1328 |
begin |
|
602 | 1329 |
HHGear:= CurrentHedgehog^.Gear; |
534 | 1330 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
809 | 1331 |
Gear^.Message:= Gear^.Message and not gm_Switch; |
534 | 1332 |
State:= HHGear^.State; |
1333 |
HHGear^.State:= 0; |
|
1334 |
HHGear^.Active:= false; |
|
1335 |
HHGear^.Z:= cHHZ; |
|
1336 |
RemoveGearFromList(HHGear); |
|
1337 |
InsertGearToList(HHGear); |
|
1338 |
||
1339 |
repeat |
|
551 | 1340 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
652 | 1341 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
1342 |
||
1343 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
|
534 | 1344 |
|
602 | 1345 |
HHGear:= CurrentHedgehog^.Gear; |
534 | 1346 |
HHGear^.State:= State; |
1347 |
HHGear^.Active:= true; |
|
1348 |
FollowGear:= HHGear; |
|
1349 |
HHGear^.Z:= cCurrHHZ; |
|
1350 |
RemoveGearFromList(HHGear); |
|
1351 |
InsertGearToList(HHGear); |
|
1352 |
Gear^.X:= HHGear^.X; |
|
1353 |
Gear^.Y:= HHGear^.Y |
|
1354 |
end; |
|
1355 |
end; |
|
1356 |
||
1357 |
procedure doStepSwitcher(Gear: PGear); |
|
1358 |
var HHGear: PGear; |
|
1359 |
begin |
|
1360 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1361 |
||
1362 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1363 |
with HHGear^ do |
|
1364 |
begin |
|
1365 |
State:= State and not gstAttacking; |
|
1366 |
Message:= Message and not gm_Attack |
|
1367 |
end |
|
1368 |
end; |
|
924 | 1369 |
|
1370 |
//////////////////////////////////////////////////////////////////////////////// |
|
1371 |
procedure doStepMortar(Gear: PGear); |
|
1372 |
var dX, dY: hwFloat; |
|
1373 |
i: LongInt; |
|
963 | 1374 |
dxn, dyn: boolean; |
924 | 1375 |
begin |
1376 |
AllInactive:= false; |
|
963 | 1377 |
dxn:= Gear^.dX.isNegative; |
1378 |
dyn:= Gear^.dY.isNegative; |
|
1379 |
||
924 | 1380 |
doStepFallingGear(Gear); |
1381 |
if (Gear^.State and gstCollision) <> 0 then |
|
1382 |
begin |
|
1383 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
963 | 1384 |
|
1385 |
Gear^.dX.isNegative:= not dxn; |
|
1386 |
Gear^.dY.isNegative:= not dyn; |
|
924 | 1387 |
for i:= 0 to 4 do |
1388 |
begin |
|
963 | 1389 |
dX:= Gear^.dX + (GetRandom - _0_5) * _0_03; |
1390 |
dY:= Gear^.dY + (GetRandom - _0_5) * _0_03; |
|
924 | 1391 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 0); |
1392 |
end; |
|
1393 |
||
1394 |
DeleteGear(Gear); |
|
1395 |
exit |
|
1396 |
end; |
|
963 | 1397 |
|
924 | 1398 |
if (GameTicks and $3F) = 0 then |
1399 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
1400 |
end; |
|
984 | 1401 |
|
1402 |
//////////////////////////////////////////////////////////////////////////////// |
|
1403 |
procedure doStepKamikazeWork(Gear: PGear); |
|
1404 |
const upd: Longword = 0; |
|
987 | 1405 |
var i: LongWord; |
984 | 1406 |
HHGear: PGear; |
1407 |
begin |
|
1408 |
AllInactive:= false; |
|
1409 |
||
1410 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1411 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1412 |
DeleteCI(HHGear); |
|
1413 |
||
1414 |
i:= 2; |
|
1415 |
repeat |
|
1416 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
1417 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
1418 |
HHGear^.X:= Gear^.X; |
|
1419 |
HHGear^.Y:= Gear^.Y; |
|
1420 |
||
1421 |
inc(Gear^.Damage, 2); |
|
1422 |
||
1423 |
if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
|
1424 |
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); |
|
1425 |
||
1426 |
dec(i) |
|
1427 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
|
1428 |
||
1429 |
inc(upd); |
|
1430 |
if upd > 3 then |
|
1431 |
begin |
|
987 | 1432 |
if Gear^.Health < 1500 then Gear^.Pos:= 2; |
1433 |
||
984 | 1434 |
AmmoShove(Gear, 30, 40); |
1435 |
||
1436 |
DrawTunnel(HHGear^.X - HHGear^.dX * 10, |
|
1437 |
HHGear^.Y - _3 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 5, |
|
1438 |
HHGear^.dX, |
|
1439 |
HHGear^.dY, |
|
1440 |
20 + cHHRadius * 2, |
|
1441 |
cHHRadius * 2 + 4); |
|
1442 |
||
1443 |
upd:= 0 |
|
1444 |
end; |
|
1445 |
||
1446 |
if Gear^.Health < Gear^.Damage then |
|
1447 |
begin |
|
1448 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1449 |
AfterAttack; |
|
1450 |
DeleteGear(Gear); |
|
1451 |
DeleteGear(HHGear); |
|
1452 |
end else |
|
1453 |
begin |
|
1454 |
dec(Gear^.Health, Gear^.Damage); |
|
1455 |
Gear^.Damage:= 0 |
|
1456 |
end |
|
1457 |
end; |
|
1458 |
||
987 | 1459 |
procedure doStepKamikazeIdle(Gear: PGear); |
1460 |
begin |
|
1461 |
AllInactive:= false; |
|
1462 |
dec(Gear^.Timer); |
|
1463 |
if Gear^.Timer = 0 then |
|
1464 |
begin |
|
1465 |
Gear^.Pos:= 1; |
|
992 | 1466 |
PlaySound(sndKamikaze, false); |
987 | 1467 |
Gear^.doStep:= @doStepKamikazeWork |
1468 |
end |
|
1469 |
end; |
|
1470 |
||
984 | 1471 |
procedure doStepKamikaze(Gear: PGear); |
1472 |
var HHGear: PGear; |
|
1473 |
begin |
|
1474 |
AllInactive:= false; |
|
1475 |
||
1476 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1477 |
||
1478 |
HHGear^.dX:= Gear^.dX; |
|
1479 |
HHGear^.dY:= Gear^.dY; |
|
1480 |
||
1481 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
|
1482 |
Gear^.dY:= - _0_9; |
|
1483 |
||
987 | 1484 |
Gear^.Timer:= 550; |
1485 |
||
1486 |
Gear^.doStep:= @doStepKamikazeIdle |
|
984 | 1487 |
end; |
1488 |
||
1103 | 1489 |
//////////////////////////////////////////////////////////////////////////////// |
1490 |
const cakeh = 27; |
|
1110 | 1491 |
cakeDmg = 75; |
1103 | 1492 |
var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; end; |
1493 |
CakeI: Longword; |
|
1494 |
||
1110 | 1495 |
procedure doStepCakeExpl(Gear: PGear); |
1496 |
begin |
|
1497 |
inc(Gear^.Tag); |
|
1498 |
if Gear^.Tag < 2250 then exit; |
|
1499 |
||
1500 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, EXPLAutoSound); |
|
1501 |
AfterAttack; |
|
1502 |
DeleteGear(Gear) |
|
1503 |
end; |
|
1504 |
||
1109 | 1505 |
procedure doStepCakeDown(Gear: PGear); |
1506 |
var i: Longword; |
|
1110 | 1507 |
gi: PGear; |
1508 |
dmg: LongInt; |
|
1109 | 1509 |
begin |
1510 |
AllInactive:= false; |
|
1511 |
||
1512 |
inc(Gear^.Tag); |
|
1513 |
if Gear^.Tag < 100 then exit; |
|
1514 |
Gear^.Tag:= 0; |
|
1515 |
||
1516 |
if Gear^.Pos = 0 then |
|
1517 |
begin |
|
1110 | 1518 |
gi:= GearsList; |
1519 |
while gi <> nil do |
|
1520 |
begin |
|
1521 |
dmg:= cakeDmg * 2 - hwRound(Distance(gi^.X - Gear^.X, gi^.Y - Gear^.Y)); |
|
1522 |
if (dmg > 1) and (gi^.Kind = gtHedgehog) then |
|
1523 |
gi^.State:= gi^.State or gstWinner; |
|
1524 |
gi:= gi^.NextGear |
|
1525 |
end; |
|
1526 |
Gear^.doStep:= @doStepCakeExpl; |
|
1111 | 1527 |
PlaySound(sndCake, false) |
1109 | 1528 |
end else dec(Gear^.Pos) |
1529 |
end; |
|
1530 |
||
1531 |
||
1089 | 1532 |
procedure doStepCakeWork(Gear: PGear); |
1533 |
const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0)); |
|
1534 |
var xx, yy, xxn, yyn: LongInt; |
|
1535 |
da: LongInt; |
|
1103 | 1536 |
tdx, tdy: hwFloat; |
1089 | 1537 |
|
1538 |
procedure PrevAngle; |
|
1539 |
begin |
|
1540 |
Gear^.Angle:= (Gear^.Angle + 4 - dA) mod 4 |
|
1541 |
end; |
|
1542 |
||
1543 |
procedure NextAngle; |
|
1544 |
begin |
|
1545 |
Gear^.Angle:= (Gear^.Angle + 4 + dA) mod 4 |
|
1546 |
end; |
|
1547 |
||
1088 | 1548 |
begin |
1089 | 1549 |
inc(Gear^.Tag); |
1108 | 1550 |
if Gear^.Tag < 7 then exit; |
1089 | 1551 |
|
1552 |
dA:= hwSign(Gear^.dX); |
|
1553 |
xx:= dirs[Gear^.Angle].x; |
|
1554 |
yy:= dirs[Gear^.Angle].y; |
|
1555 |
xxn:= dirs[(Gear^.Angle + 4 + dA) mod 4].x; |
|
1556 |
yyn:= dirs[(Gear^.Angle + 4 + dA) mod 4].y; |
|
1557 |
||
1558 |
||
1559 |
if (xx = 0) then |
|
1560 |
if TestCollisionYwithGear(Gear, yy) then |
|
1561 |
PrevAngle |
|
1562 |
else begin |
|
1563 |
Gear^.Tag:= 0; |
|
1564 |
Gear^.Y:= Gear^.Y + int2hwFloat(yy); |
|
1565 |
if not TestCollisionXwithGear(Gear, xxn) then NextAngle |
|
1566 |
end; |
|
1567 |
||
1568 |
if (yy = 0) then |
|
1569 |
if TestCollisionXwithGear(Gear, xx) then |
|
1570 |
PrevAngle |
|
1571 |
else begin |
|
1572 |
Gear^.Tag:= 0; |
|
1573 |
Gear^.X:= Gear^.X + int2hwFloat(xx); |
|
1574 |
if not TestCollisionYwithGear(Gear, yyn) then NextAngle |
|
1575 |
end; |
|
1576 |
||
1103 | 1577 |
if Gear^.Tag = 0 then |
1578 |
begin |
|
1579 |
CakeI:= (CakeI + 1) mod cakeh; |
|
1580 |
tdx:= CakePoints[CakeI].x - Gear^.X; |
|
1581 |
tdy:= - CakePoints[CakeI].y + Gear^.Y; |
|
1582 |
CakePoints[CakeI].x:= Gear^.X; |
|
1583 |
CakePoints[CakeI].y:= Gear^.Y; |
|
1584 |
Gear^.DirAngle:= DxDy2Angle(tdx, tdy); |
|
1585 |
end; |
|
1586 |
||
1089 | 1587 |
dec(Gear^.Health); |
1090 | 1588 |
if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then |
1089 | 1589 |
begin |
1109 | 1590 |
FollowGear:= Gear; |
1591 |
Gear^.doStep:= @doStepCakeDown |
|
1089 | 1592 |
end |
1088 | 1593 |
end; |
1089 | 1594 |
|
1103 | 1595 |
procedure doStepCakeUp(Gear: PGear); |
1596 |
var i: Longword; |
|
1597 |
begin |
|
1598 |
AllInactive:= false; |
|
1599 |
||
1108 | 1600 |
inc(Gear^.Tag); |
1109 | 1601 |
if Gear^.Tag < 100 then exit; |
1108 | 1602 |
Gear^.Tag:= 0; |
1603 |
||
1109 | 1604 |
if Gear^.Pos = 6 then |
1103 | 1605 |
begin |
1606 |
for i:= 0 to Pred(cakeh) do |
|
1607 |
begin |
|
1608 |
CakePoints[i].x:= Gear^.X; |
|
1609 |
CakePoints[i].y:= Gear^.Y |
|
1610 |
end; |
|
1611 |
CakeI:= 0; |
|
1612 |
Gear^.doStep:= @doStepCakeWork |
|
1109 | 1613 |
end else inc(Gear^.Pos) |
1103 | 1614 |
end; |
1615 |
||
1089 | 1616 |
procedure doStepCakeFall(Gear: PGear); |
1617 |
begin |
|
1618 |
AllInactive:= false; |
|
1619 |
||
1620 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1621 |
if TestCollisionYwithGear(Gear, 1) then |
|
1103 | 1622 |
Gear^.doStep:= @doStepCakeUp |
1089 | 1623 |
else |
1624 |
begin |
|
1625 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1626 |
if CheckGearDrowning(Gear) then AfterAttack |
|
1627 |
end |
|
1628 |
end; |
|
1629 |
||
1630 |
procedure doStepCake(Gear: PGear); |
|
1631 |
var HHGear: PGear; |
|
1632 |
begin |
|
1633 |
AllInactive:= false; |
|
1634 |
||
1635 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1103 | 1636 |
HHGear^.Message:= HHGear^.Message and (not gm_Attack); |
1089 | 1637 |
DeleteCI(HHGear); |
1638 |
||
1106 | 1639 |
FollowGear:= Gear; |
1640 |
||
1089 | 1641 |
Gear^.doStep:= @doStepCakeFall |
1642 |
end; |
|
1643 |