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