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