author | unc0rr |
Thu, 22 May 2008 17:25:12 +0000 | |
changeset 944 | 9299c0ebfdbc |
parent 940 | 769adb0ad082 |
child 945 | 4ead9cde4e14 |
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; |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
574 |
DeleteGear(Gear) |
4 | 575 |
end; |
576 |
||
577 |
begin |
|
351 | 578 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
108 | 579 |
|
351 | 580 |
if ((HHGear^.State and gstHHDriven) = 0) |
80 | 581 |
or (CheckGearDrowning(HHGear)) then |
4 | 582 |
begin |
583 |
DeleteMe; |
|
584 |
exit |
|
585 |
end; |
|
928
b9064b48b001
Some preparation work for attacking from rope, parachute and etc.
unc0rr
parents:
925
diff
changeset
|
586 |
|
351 | 587 |
Gear^.dX:= HHGear^.X - Gear^.X; |
588 |
Gear^.dY:= HHGear^.Y - Gear^.Y; |
|
4 | 589 |
|
351 | 590 |
if (Gear^.Message and gm_Left <> 0) then HHGear^.dX:= HHGear^.dX - _0_0002 else |
591 |
if (Gear^.Message and gm_Right <> 0) then HHGear^.dX:= HHGear^.dX + _0_0002; |
|
4 | 592 |
|
351 | 593 |
if not TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= HHGear^.dY + cGravity; |
4 | 594 |
|
351 | 595 |
cs:= Gear^.dY + HHGear^.dY; |
596 |
cc:= Gear^.dX + HHGear^.dX; |
|
498 | 597 |
len:= _1 / Distance(cc, cs); |
789 | 598 |
cc:= cc * len; // rope vector plus hedgehog direction vector normalized |
108 | 599 |
cs:= cs * len; |
4 | 600 |
|
940 | 601 |
nx:= hwAbs(cs) * hwSign(HHGear^.dX) * 5; // hedgehog direction normalized with length 3 |
602 |
ny:= hwAbs(cc) * hwSign(HHGear^.dY) * 5; |
|
789 | 603 |
|
4 | 604 |
flCheck:= not flCheck; |
605 |
if flCheck then // check whether rope needs dividing |
|
606 |
begin |
|
498 | 607 |
len:= Gear^.Elasticity - _20; |
608 |
while len > _5 do |
|
4 | 609 |
begin |
610 |
tx:= cc*len; |
|
611 |
ty:= cs*len; |
|
789 | 612 |
lx:= hwRound(Gear^.X + tx + nx); |
613 |
ly:= hwRound(Gear^.Y + ty + ny); |
|
652 | 614 |
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0) and (Land[ly, lx] <> 0) then |
4 | 615 |
begin |
616 |
with RopePoints.ar[RopePoints.Count] do |
|
617 |
begin |
|
351 | 618 |
X:= Gear^.X; |
619 |
Y:= Gear^.Y; |
|
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
620 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); |
351 | 621 |
b:= (cc * HHGear^.dY) > (cs * HHGear^.dX); |
4 | 622 |
dLen:= len |
623 |
end; |
|
351 | 624 |
Gear^.X:= Gear^.X + tx; |
625 |
Gear^.Y:= Gear^.Y + ty; |
|
4 | 626 |
inc(RopePoints.Count); |
789 | 627 |
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); |
351 | 628 |
Gear^.Elasticity:= Gear^.Elasticity - len; |
629 |
Gear^.Friction:= Gear^.Friction - len; |
|
4 | 630 |
break |
631 |
end; |
|
789 | 632 |
len:= len - _2 |
4 | 633 |
end; |
634 |
end else |
|
635 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
|
636 |
begin |
|
637 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
638 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
351 | 639 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then |
4 | 640 |
begin |
641 |
dec(RopePoints.Count); |
|
351 | 642 |
Gear^.X:=RopePoints.ar[RopePoints.Count].X; |
643 |
Gear^.Y:=RopePoints.ar[RopePoints.Count].Y; |
|
644 |
Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
|
645 |
Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
4 | 646 |
end |
647 |
end; |
|
648 |
||
351 | 649 |
Gear^.dX:= HHGear^.X - Gear^.X; |
650 |
Gear^.dY:= HHGear^.Y - Gear^.Y; |
|
108 | 651 |
|
351 | 652 |
cs:= Gear^.dY + HHGear^.dY; |
653 |
cc:= Gear^.dX + HHGear^.dX; |
|
498 | 654 |
len:= _1 / Distance(cc, cs); |
108 | 655 |
cc:= cc * len; |
656 |
cs:= cs * len; |
|
4 | 657 |
|
351 | 658 |
HHGear^.dX:= HHGear^.X; |
659 |
HHGear^.dY:= HHGear^.Y; |
|
4 | 660 |
|
351 | 661 |
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then |
662 |
if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
|
663 |
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity + _0_3; |
|
4 | 664 |
|
498 | 665 |
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then |
351 | 666 |
if not (TestCollisionXwithGear(HHGear, -hwSign(Gear^.dX)) |
667 |
or TestCollisionYwithGear(HHGear, -hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity - _0_3; |
|
4 | 668 |
|
351 | 669 |
HHGear^.X:= Gear^.X + cc*Gear^.Elasticity; |
670 |
HHGear^.Y:= Gear^.Y + cs*Gear^.Elasticity; |
|
4 | 671 |
|
351 | 672 |
HHGear^.dX:= HHGear^.X - HHGear^.dX; |
673 |
HHGear^.dY:= HHGear^.Y - HHGear^.dY; |
|
4 | 674 |
|
351 | 675 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
676 |
HHGear^.dX:= -_0_6 * HHGear^.dX; |
|
677 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then |
|
678 |
HHGear^.dY:= -_0_6 * HHGear^.dY; |
|
4 | 679 |
|
789 | 680 |
len:= Distance(HHGear^.dX, HHGear^.dY); |
940 | 681 |
if len > _0_8 then |
789 | 682 |
begin |
940 | 683 |
len:= _0_8 / len; |
789 | 684 |
HHGear^.dX:= HHGear^.dX * len; |
685 |
HHGear^.dY:= HHGear^.dY * len; |
|
686 |
end; |
|
687 |
||
351 | 688 |
if (Gear^.Message and gm_Attack) <> 0 then |
689 |
if (Gear^.State and gsttmpFlag) <> 0 then DeleteMe else |
|
690 |
else if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
4 | 691 |
end; |
692 |
||
693 |
||
694 |
procedure doStepRopeAttach(Gear: PGear); |
|
695 |
var HHGear: PGear; |
|
351 | 696 |
tx, ty, tt: hwFloat; |
4 | 697 |
begin |
351 | 698 |
Gear^.X:= Gear^.X - Gear^.dX; |
699 |
Gear^.Y:= Gear^.Y - Gear^.dY; |
|
498 | 700 |
Gear^.Elasticity:= Gear^.Elasticity + _1; |
351 | 701 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
517 | 702 |
DeleteCI(HHGear); |
542 | 703 |
if (HHGear^.State and gstMoving) <> 0 then |
68 | 704 |
if TestCollisionYwithGear(HHGear, 1) then |
4 | 705 |
begin |
820
a26537586400
Fix fall without damage trick, which could be performed with not attached rope
unc0rr
parents:
819
diff
changeset
|
706 |
CheckHHDamage(HHGear); |
498 | 707 |
HHGear^.dY:= _0; |
542 | 708 |
HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); |
4 | 709 |
end else |
710 |
begin |
|
351 | 711 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
712 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
713 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
714 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
715 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
716 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
717 |
tt:= Gear^.Elasticity; |
|
498 | 718 |
tx:= _0; |
719 |
ty:= _0; |
|
720 |
while tt > _20 do |
|
4 | 721 |
begin |
517 | 722 |
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) |
723 |
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then |
|
4 | 724 |
begin |
351 | 725 |
Gear^.X:= Gear^.X + tx; |
726 |
Gear^.Y:= Gear^.Y + ty; |
|
727 |
Gear^.Elasticity:= tt; |
|
728 |
Gear^.doStep:= @doStepRopeWork; |
|
4 | 729 |
with HHGear^ do State:= State and not gstAttacking; |
498 | 730 |
tt:= _0 |
4 | 731 |
end; |
517 | 732 |
tx:= tx + Gear^.dX + Gear^.dX; |
733 |
ty:= ty + Gear^.dY + Gear^.dY; |
|
498 | 734 |
tt:= tt - _2; |
4 | 735 |
end; |
736 |
end; |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
737 |
|
4 | 738 |
CheckCollision(Gear); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
739 |
|
351 | 740 |
if (Gear^.State and gstCollision) <> 0 then |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
741 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
742 |
Gear^.doStep:= @doStepRopeWork; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
743 |
with HHGear^ do State:= State and not gstAttacking; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
744 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
745 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
746 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
747 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
748 |
if Gear^.Elasticity < _10 then |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
749 |
Gear^.Elasticity:= _10000; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
750 |
end; |
4 | 751 |
|
351 | 752 |
if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then |
4 | 753 |
begin |
351 | 754 |
with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
4 | 755 |
begin |
756 |
State:= State and not gstAttacking; |
|
757 |
Message:= Message and not gm_Attack |
|
758 |
end; |
|
759 |
DeleteGear(Gear) |
|
760 |
end |
|
761 |
end; |
|
762 |
||
763 |
procedure doStepRope(Gear: PGear); |
|
764 |
begin |
|
351 | 765 |
Gear^.dX:= - Gear^.dX; |
766 |
Gear^.dY:= - Gear^.dY; |
|
767 |
Gear^.doStep:= @doStepRopeAttach |
|
4 | 768 |
end; |
769 |
||
770 |
//////////////////////////////////////////////////////////////////////////////// |
|
771 |
procedure doStepSmokeTrace(Gear: PGear); |
|
772 |
begin |
|
351 | 773 |
inc(Gear^.Timer); |
774 |
if Gear^.Timer > 64 then |
|
4 | 775 |
begin |
351 | 776 |
Gear^.Timer:= 0; |
777 |
dec(Gear^.State) |
|
4 | 778 |
end; |
351 | 779 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
780 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
781 |
if Gear^.State = 0 then DeleteGear(Gear) |
|
4 | 782 |
end; |
9 | 783 |
|
784 |
//////////////////////////////////////////////////////////////////////////////// |
|
785 |
procedure doStepExplosion(Gear: PGear); |
|
786 |
begin |
|
351 | 787 |
inc(Gear^.Timer); |
788 |
if Gear^.Timer > 75 then |
|
9 | 789 |
begin |
351 | 790 |
inc(Gear^.State); |
791 |
Gear^.Timer:= 0; |
|
792 |
if Gear^.State > 5 then DeleteGear(Gear) |
|
9 | 793 |
end; |
794 |
end; |
|
10 | 795 |
|
796 |
//////////////////////////////////////////////////////////////////////////////// |
|
797 |
procedure doStepMine(Gear: PGear); |
|
798 |
begin |
|
542 | 799 |
if (Gear^.State and gstMoving) <> 0 then |
914 | 800 |
begin |
801 |
DeleteCI(Gear); |
|
802 |
doStepFallingGear(Gear); |
|
803 |
if (Gear^.State and gstMoving) = 0 then |
|
804 |
begin |
|
805 |
AddGearCI(Gear); |
|
806 |
Gear^.dX:= _0; |
|
807 |
Gear^.dY:= _0 |
|
808 |
end; |
|
809 |
CalcRotationDirAngle(Gear); |
|
810 |
AllInactive:= false |
|
811 |
end else |
|
812 |
if ((GameTicks and $3F) = 25) then |
|
813 |
doStepFallingGear(Gear); |
|
351 | 814 |
|
815 |
if ((Gear^.State and gsttmpFlag) <> 0) then |
|
816 |
if ((Gear^.State and gstAttacking) = 0) then |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
817 |
begin |
914 | 818 |
if ((GameTicks and $1F) = 0) then |
351 | 819 |
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
|
820 |
end else // gstAttacking <> 0 |
10 | 821 |
begin |
822 |
AllInactive:= false; |
|
351 | 823 |
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false); |
824 |
if Gear^.Timer = 0 then |
|
10 | 825 |
begin |
351 | 826 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
521 | 827 |
DeleteGear(Gear); |
828 |
exit |
|
10 | 829 |
end; |
351 | 830 |
dec(Gear^.Timer); |
13 | 831 |
end else // gsttmpFlag = 0 |
351 | 832 |
if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
10 | 833 |
end; |
57 | 834 |
|
39 | 835 |
//////////////////////////////////////////////////////////////////////////////// |
836 |
procedure doStepDynamite(Gear: PGear); |
|
837 |
begin |
|
43 | 838 |
doStepFallingGear(Gear); |
839 |
AllInactive:= false; |
|
351 | 840 |
if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); |
841 |
if Gear^.Timer = 0 then |
|
39 | 842 |
begin |
351 | 843 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
43 | 844 |
DeleteGear(Gear); |
845 |
exit |
|
39 | 846 |
end; |
351 | 847 |
dec(Gear^.Timer); |
39 | 848 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
849 |
|
351 | 850 |
/////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
851 |
procedure doStepCase(Gear: PGear); |
371 | 852 |
var i, x, y: LongInt; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
853 |
begin |
351 | 854 |
if (Gear^.Message and gm_Destroy) > 0 then |
15 | 855 |
begin |
856 |
DeleteGear(Gear); |
|
435 | 857 |
FreeActionsList; |
913 | 858 |
SetAllToActive; // something (hh, mine, etc...) could be on top of the case |
602 | 859 |
with CurrentHedgehog^ do |
441 | 860 |
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
15 | 861 |
exit |
862 |
end; |
|
863 |
||
351 | 864 |
if Gear^.Damage > 0 then |
79 | 865 |
begin |
351 | 866 |
x:= hwRound(Gear^.X); |
867 |
y:= hwRound(Gear^.Y); |
|
79 | 868 |
DeleteGear(Gear); |
590 | 869 |
if Gear^.Kind = gtCase then |
870 |
begin |
|
871 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
|
872 |
for i:= 0 to 63 do |
|
873 |
AddGear(x, y, gtFlame, 0, _0, _0, 0); |
|
874 |
end; |
|
79 | 875 |
exit |
876 |
end; |
|
877 |
||
351 | 878 |
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
|
879 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
880 |
AllInactive:= false; |
351 | 881 |
Gear^.dY:= Gear^.dY + cGravity; |
882 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 883 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else |
439 | 884 |
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
|
885 |
begin |
351 | 886 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
498 | 887 |
if Gear^.dY > - _0_001 then Gear^.dY:= _0 |
351 | 888 |
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
|
889 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
890 |
CheckGearDrowning(Gear); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
891 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
892 |
|
511 | 893 |
if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
894 |
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
|
895 |
end; |
49 | 896 |
|
897 |
//////////////////////////////////////////////////////////////////////////////// |
|
557 | 898 |
const cSorterWorkTime = 640; |
899 |
var thexchar: array[0..cMaxTeams] of |
|
900 |
record |
|
901 |
dy, ny, dw: LongInt; |
|
49 | 902 |
team: PTeam; |
557 | 903 |
SortFactor: QWord; |
49 | 904 |
end; |
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
905 |
currsorter: PGear = nil; |
49 | 906 |
|
907 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
371 | 908 |
var i: LongInt; |
49 | 909 |
begin |
910 |
AllInactive:= false; |
|
351 | 911 |
dec(Gear^.Timer); |
912 |
if (Gear^.Timer and 15) = 0 then |
|
557 | 913 |
for i:= 0 to Pred(TeamsCount) do |
49 | 914 |
with thexchar[i] do |
557 | 915 |
begin |
49 | 916 |
{$WARNINGS OFF} |
557 | 917 |
team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; |
918 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; |
|
49 | 919 |
{$WARNINGS ON} |
557 | 920 |
end; |
351 | 921 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
143 | 922 |
begin |
923 |
if currsorter = Gear then currsorter:= nil; |
|
49 | 924 |
DeleteGear(Gear) |
143 | 925 |
end |
49 | 926 |
end; |
927 |
||
928 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
547 | 929 |
var i, t: Longword; |
557 | 930 |
b: boolean; |
49 | 931 |
begin |
932 |
AllInactive:= false; |
|
557 | 933 |
|
547 | 934 |
for t:= 0 to Pred(TeamsCount) do |
557 | 935 |
with thexchar[t] do |
49 | 936 |
begin |
557 | 937 |
dy:= TeamsArray[t]^.DrawHealthY; |
938 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
939 |
team:= TeamsArray[t]; |
|
940 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
941 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
942 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
49 | 943 |
end; |
547 | 944 |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
945 |
if TeamsCount > 1 then |
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
946 |
repeat |
557 | 947 |
b:= true; |
948 |
for t:= 0 to TeamsCount - 2 do |
|
949 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
49 | 950 |
begin |
557 | 951 |
thexchar[cMaxTeams]:= thexchar[t]; |
49 | 952 |
thexchar[t]:= thexchar[Succ(t)]; |
557 | 953 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
954 |
b:= false |
|
955 |
end |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
956 |
until b; |
557 | 957 |
|
49 | 958 |
t:= cScreenHeight - 4; |
557 | 959 |
for i:= 0 to Pred(TeamsCount) do |
49 | 960 |
with thexchar[i] do |
961 |
begin |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
962 |
dec(t, team^.HealthTex^.h + 2); |
557 | 963 |
ny:= t; |
964 |
dy:= dy - ny |
|
49 | 965 |
end; |
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
966 |
|
557 | 967 |
Gear^.Timer:= cSorterWorkTime; |
351 | 968 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
143 | 969 |
currsorter:= Gear |
49 | 970 |
end; |
971 |
||
79 | 972 |
//////////////////////////////////////////////////////////////////////////////// |
854 | 973 |
procedure doStepIdle(Gear: PGear); |
974 |
begin |
|
975 |
AllInactive:= false; |
|
925 | 976 |
dec(Gear^.Timer); |
854 | 977 |
if Gear^.Timer = 0 then |
978 |
begin |
|
979 |
DeleteGear(Gear); |
|
980 |
AfterAttack |
|
981 |
end |
|
982 |
end; |
|
983 |
||
79 | 984 |
procedure doStepShover(Gear: PGear); |
985 |
var HHGear: PGear; |
|
986 |
begin |
|
351 | 987 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
988 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
79 | 989 |
AmmoShove(Gear, 30, 115); |
351 | 990 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
854 | 991 |
Gear^.Timer:= 250; |
992 |
Gear^.doStep:= @doStepIdle |
|
79 | 993 |
end; |
994 |
||
995 |
//////////////////////////////////////////////////////////////////////////////// |
|
925 | 996 |
procedure doStepWhip(Gear: PGear); |
997 |
var HHGear: PGear; |
|
998 |
i: LongInt; |
|
999 |
begin |
|
1000 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1001 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1002 |
||
1003 |
for i:= 0 to 3 do |
|
1004 |
begin |
|
1005 |
AmmoShove(Gear, 30, 25); |
|
1006 |
Gear^.X:= Gear^.X + Gear^.dX * 5 |
|
1007 |
end; |
|
1008 |
||
1009 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
|
1010 |
Gear^.Timer:= 250; |
|
1011 |
Gear^.doStep:= @doStepIdle |
|
1012 |
end; |
|
1013 |
||
1014 |
//////////////////////////////////////////////////////////////////////////////// |
|
79 | 1015 |
procedure doStepFlame(Gear: PGear); |
1016 |
begin |
|
1017 |
AllInactive:= false; |
|
1018 |
if not TestCollisionYwithGear(Gear, 1) then |
|
1019 |
begin |
|
351 | 1020 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
1021 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1022 |
if hwAbs(Gear^.dX) > _0_1 then Gear^.dX:= Gear^.dX * _0_5; |
|
1023 |
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; |
|
1024 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1025 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 1026 |
if not (Gear^.Y < _1024) then |
79 | 1027 |
begin |
1028 |
DeleteGear(Gear); |
|
1029 |
exit |
|
1030 |
end |
|
1031 |
end else begin |
|
351 | 1032 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
79 | 1033 |
else begin |
506 | 1034 |
// doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 2, 0); |
351 | 1035 |
dec(Gear^.Health); |
1036 |
Gear^.Timer:= 1250 - Gear^.Angle * 12 |
|
79 | 1037 |
end |
1038 |
end; |
|
1039 |
||
351 | 1040 |
if (((GameTicks div 8) mod 64) = Gear^.Angle) then |
79 | 1041 |
AmmoFlameWork(Gear); |
1042 |
||
351 | 1043 |
if Gear^.Health = 0 then |
79 | 1044 |
DeleteGear(Gear) |
1045 |
end; |
|
82 | 1046 |
|
1047 |
//////////////////////////////////////////////////////////////////////////////// |
|
1048 |
procedure doStepFirePunchWork(Gear: PGear); |
|
1049 |
var HHGear: PGear; |
|
1050 |
begin |
|
1051 |
AllInactive:= false; |
|
351 | 1052 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
82 | 1053 |
begin |
1054 |
DeleteGear(Gear); |
|
1055 |
AfterAttack; |
|
1056 |
exit |
|
1057 |
end; |
|
1058 |
||
351 | 1059 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1060 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
82 | 1061 |
begin |
351 | 1062 |
Gear^.Tag:= hwRound(HHGear^.Y); |
498 | 1063 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
351 | 1064 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
1065 |
Gear^.Y:= HHGear^.Y; |
|
82 | 1066 |
AmmoShove(Gear, 30, 40); |
351 | 1067 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
82 | 1068 |
end; |
351 | 1069 |
|
1070 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1071 |
if not (HHGear^.dY.isNegative) then |
|
82 | 1072 |
begin |
542 | 1073 |
HHGear^.State:= HHGear^.State or gstMoving; |
82 | 1074 |
DeleteGear(Gear); |
1075 |
AfterAttack; |
|
1076 |
exit |
|
1077 |
end; |
|
351 | 1078 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1079 |
end; |
1080 |
||
1081 |
procedure doStepFirePunch(Gear: PGear); |
|
1082 |
var HHGear: PGear; |
|
1083 |
begin |
|
1084 |
AllInactive:= false; |
|
351 | 1085 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1086 |
DeleteCI(HHGear); |
498 | 1087 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
351 | 1088 |
SetLittle(HHGear^.dX); |
1089 |
HHGear^.dY:= - _0_3; |
|
82 | 1090 |
|
351 | 1091 |
Gear^.X:= HHGear^.X; |
498 | 1092 |
Gear^.dX:= SignAs(_0_45, HHGear^.dX); |
351 | 1093 |
Gear^.dY:= - _0_9; |
1094 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1095 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
82 | 1096 |
end; |
1097 |
||
263 | 1098 |
//////////////////////////////////////////////////////////////////////////////// |
1099 |
||
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1100 |
procedure doStepParachuteWork(Gear: PGear); |
211 | 1101 |
var HHGear: PGear; |
1102 |
begin |
|
351 | 1103 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
82 | 1104 |
|
516 | 1105 |
inc(Gear^.Timer); |
1106 |
||
212 | 1107 |
if TestCollisionYwithGear(HHGear, 1) |
351 | 1108 |
or ((HHGear^.State and gstHHDriven) = 0) |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1109 |
or CheckGearDrowning(HHGear) |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1110 |
or ((Gear^.Message and gm_Attack) <> 0) then |
211 | 1111 |
begin |
1112 |
with HHGear^ do |
|
1113 |
begin |
|
1114 |
Message:= 0; |
|
568 | 1115 |
SetLittle(dX); |
498 | 1116 |
dY:= _0; |
542 | 1117 |
State:= State or gstMoving; |
211 | 1118 |
end; |
1119 |
DeleteGear(Gear); |
|
1120 |
exit |
|
1121 |
end; |
|
1122 |
||
351 | 1123 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1124 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
|
211 | 1125 |
|
351 | 1126 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1127 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1128 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1129 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1130 |
|
351 | 1131 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1132 |
Gear^.X:= HHGear^.X; |
1133 |
Gear^.Y:= HHGear^.Y |
|
263 | 1134 |
end; |
211 | 1135 |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1136 |
procedure doStepParachute(Gear: PGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1137 |
var HHGear: PGear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1138 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1139 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1140 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1141 |
DeleteCI(HHGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1142 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1143 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1144 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1145 |
|
931 | 1146 |
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
|
1147 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1148 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1149 |
Gear^.doStep:= @doStepParachuteWork; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1150 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1151 |
Gear^.Message:= HHGear^.Message; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1152 |
doStepParachuteWork(Gear) |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1153 |
end; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1154 |
|
263 | 1155 |
//////////////////////////////////////////////////////////////////////////////// |
1156 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1157 |
begin |
|
1158 |
AllInactive:= false; |
|
498 | 1159 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1160 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
263 | 1161 |
begin |
351 | 1162 |
dec(Gear^.Health); |
1163 |
case Gear^.State of |
|
498 | 1164 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
1165 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
285 | 1166 |
end; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1167 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
263 | 1168 |
end; |
498 | 1169 |
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1170 |
end; |
1171 |
||
1172 |
procedure doStepAirAttack(Gear: PGear); |
|
1173 |
begin |
|
1174 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1175 |
|
408 | 1176 |
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 |
1177 |
else Gear^.Tag:= -1; |
|
498 | 1178 |
Gear^.X:= _1024 - _2048 * Gear^.Tag; |
1179 |
Gear^.Y:= -_128; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1180 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1181 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1182 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
498 | 1183 |
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
|
1184 |
|
351 | 1185 |
Gear^.Health:= 6; |
801 | 1186 |
Gear^.doStep:= @doStepAirAttackWork; |
1187 |
PlaySound(sndIncoming, false) |
|
263 | 1188 |
end; |
1189 |
||
1190 |
//////////////////////////////////////////////////////////////////////////////// |
|
1191 |
||
1192 |
procedure doStepAirBomb(Gear: PGear); |
|
1193 |
begin |
|
1194 |
AllInactive:= false; |
|
1195 |
doStepFallingGear(Gear); |
|
351 | 1196 |
if (Gear^.State and gstCollision) <> 0 then |
263 | 1197 |
begin |
351 | 1198 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
263 | 1199 |
DeleteGear(Gear); |
1200 |
exit |
|
1201 |
end; |
|
1202 |
if (GameTicks and $3F) = 0 then |
|
498 | 1203 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1204 |
end; |
409 | 1205 |
|
1206 |
//////////////////////////////////////////////////////////////////////////////// |
|
1207 |
||
1208 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1209 |
var HHGear: PGear; |
409 | 1210 |
begin |
1211 |
AllInactive:= false; |
|
415 | 1212 |
|
1213 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1214 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1215 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1216 |
sprAmGirder, Gear^.State, true) then |
409 | 1217 |
begin |
415 | 1218 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
1219 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1220 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1221 |
DeleteGear(Gear); |
|
1222 |
isCursorVisible:= true |
|
409 | 1223 |
end |
415 | 1224 |
else begin |
1225 |
DeleteGear(Gear); |
|
1226 |
AfterAttack |
|
1227 |
end; |
|
1228 |
TargetPoint.X:= NoPointX |
|
409 | 1229 |
end; |
520 | 1230 |
|
1231 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1232 |
procedure doStepTeleportAfter(Gear: PGear); |
912 | 1233 |
var HHGear: PGear; |
1234 |
begin |
|
1235 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1236 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases |
|
1237 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1238 |
if TestCollisionYwithGear(HHGear, 1) then |
|
1239 |
begin |
|
1240 |
DeleteGear(Gear); |
|
1241 |
AfterAttack |
|
1242 |
end |
|
1243 |
end; |
|
1244 |
||
1245 |
procedure doStepTeleportAnim(Gear: PGear); |
|
525 | 1246 |
begin |
853 | 1247 |
inc(Gear^.Timer); |
1248 |
if Gear^.Timer = 65 then |
|
1249 |
begin |
|
1250 |
Gear^.Timer:= 0; |
|
1251 |
inc(Gear^.Pos); |
|
1252 |
if Gear^.Pos = 11 then |
|
912 | 1253 |
Gear^.doStep:= @doStepTeleportAfter |
853 | 1254 |
end |
525 | 1255 |
end; |
520 | 1256 |
|
1257 |
procedure doStepTeleport(Gear: PGear); |
|
1258 |
var HHGear: PGear; |
|
1259 |
begin |
|
1260 |
AllInactive:= false; |
|
1261 |
||
1262 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1263 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1264 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1265 |
sprHHTelepMask, 0, false) then |
|
853 | 1266 |
begin |
1267 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1268 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1269 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1270 |
DeleteGear(Gear); |
|
1271 |
isCursorVisible:= true |
|
1272 |
end |
|
1273 |
else begin |
|
1274 |
DeleteCI(HHGear); |
|
1275 |
SetAllHHToActive; |
|
912 | 1276 |
Gear^.doStep:= @doStepTeleportAnim; |
853 | 1277 |
Gear^.X:= HHGear^.X; |
1278 |
Gear^.Y:= HHGear^.Y; |
|
1279 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1280 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1281 |
HHGear^.State:= HHGear^.State or gstMoving |
|
1282 |
end; |
|
520 | 1283 |
TargetPoint.X:= NoPointX |
1284 |
end; |
|
534 | 1285 |
|
1286 |
//////////////////////////////////////////////////////////////////////////////// |
|
1287 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1288 |
var HHGear: PGear; |
|
1289 |
Msg, State: Longword; |
|
1290 |
begin |
|
1291 |
AllInactive:= false; |
|
1292 |
||
540 | 1293 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
534 | 1294 |
begin |
1295 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1296 |
Msg:= Gear^.Message and not gm_Switch; |
|
1297 |
DeleteGear(Gear); |
|
538 | 1298 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
1299 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1300 |
|
602 | 1301 |
HHGear:= CurrentHedgehog^.Gear; |
538 | 1302 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
534 | 1303 |
HHGear^.Message:= Msg; |
1304 |
exit |
|
1305 |
end; |
|
1306 |
||
1307 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1308 |
begin |
|
602 | 1309 |
HHGear:= CurrentHedgehog^.Gear; |
534 | 1310 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
809 | 1311 |
Gear^.Message:= Gear^.Message and not gm_Switch; |
534 | 1312 |
State:= HHGear^.State; |
1313 |
HHGear^.State:= 0; |
|
1314 |
HHGear^.Active:= false; |
|
1315 |
HHGear^.Z:= cHHZ; |
|
1316 |
RemoveGearFromList(HHGear); |
|
1317 |
InsertGearToList(HHGear); |
|
1318 |
||
1319 |
repeat |
|
551 | 1320 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
652 | 1321 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
1322 |
||
1323 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
|
534 | 1324 |
|
602 | 1325 |
HHGear:= CurrentHedgehog^.Gear; |
534 | 1326 |
HHGear^.State:= State; |
1327 |
HHGear^.Active:= true; |
|
1328 |
FollowGear:= HHGear; |
|
1329 |
HHGear^.Z:= cCurrHHZ; |
|
1330 |
RemoveGearFromList(HHGear); |
|
1331 |
InsertGearToList(HHGear); |
|
1332 |
Gear^.X:= HHGear^.X; |
|
1333 |
Gear^.Y:= HHGear^.Y |
|
1334 |
end; |
|
1335 |
end; |
|
1336 |
||
1337 |
procedure doStepSwitcher(Gear: PGear); |
|
1338 |
var HHGear: PGear; |
|
1339 |
begin |
|
1340 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1341 |
||
1342 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1343 |
with HHGear^ do |
|
1344 |
begin |
|
1345 |
State:= State and not gstAttacking; |
|
1346 |
Message:= Message and not gm_Attack |
|
1347 |
end |
|
1348 |
end; |
|
924 | 1349 |
|
1350 |
//////////////////////////////////////////////////////////////////////////////// |
|
1351 |
procedure doStepMortar(Gear: PGear); |
|
1352 |
var dX, dY: hwFloat; |
|
1353 |
i: LongInt; |
|
1354 |
begin |
|
1355 |
AllInactive:= false; |
|
1356 |
doStepFallingGear(Gear); |
|
1357 |
if (Gear^.State and gstCollision) <> 0 then |
|
1358 |
begin |
|
1359 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
1360 |
||
1361 |
for i:= 0 to 4 do |
|
1362 |
begin |
|
1363 |
dX:= - Gear^.dX + (GetRandom - _0_5) * _0_03; |
|
1364 |
dY:= - Gear^.dY + (GetRandom - _0_5) * _0_03; |
|
1365 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 0); |
|
1366 |
end; |
|
1367 |
||
1368 |
DeleteGear(Gear); |
|
1369 |
exit |
|
1370 |
end; |
|
1371 |
if (GameTicks and $3F) = 0 then |
|
1372 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
1373 |
end; |