author | unc0rr |
Wed, 18 Jun 2008 21:53:54 +0000 | |
changeset 1015 | 6f4a1890c60d |
parent 1014 | 3c7d4e7ccdff |
child 1024 | a6942122c31d |
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; |
974
fc16141a0128
Prevent wrong aim direction when using rope after high jump
unc0rr
parents:
963
diff
changeset
|
743 |
with HHGear^ do State:= State and not (gstAttacking or gstHHHJump); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
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; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
989 |
DeleteCI(HHGear); |
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
990 |
|
79 | 991 |
AmmoShove(Gear, 30, 115); |
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
992 |
|
351 | 993 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
854 | 994 |
Gear^.Timer:= 250; |
995 |
Gear^.doStep:= @doStepIdle |
|
79 | 996 |
end; |
997 |
||
998 |
//////////////////////////////////////////////////////////////////////////////// |
|
925 | 999 |
procedure doStepWhip(Gear: PGear); |
1000 |
var HHGear: PGear; |
|
1001 |
i: LongInt; |
|
1002 |
begin |
|
1003 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1004 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1005 |
DeleteCI(HHGear); |
925 | 1006 |
|
1007 |
for i:= 0 to 3 do |
|
1008 |
begin |
|
1009 |
AmmoShove(Gear, 30, 25); |
|
1010 |
Gear^.X:= Gear^.X + Gear^.dX * 5 |
|
1011 |
end; |
|
1012 |
||
1013 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
|
1014 |
Gear^.Timer:= 250; |
|
1015 |
Gear^.doStep:= @doStepIdle |
|
1016 |
end; |
|
1017 |
||
1018 |
//////////////////////////////////////////////////////////////////////////////// |
|
79 | 1019 |
procedure doStepFlame(Gear: PGear); |
1020 |
begin |
|
1021 |
AllInactive:= false; |
|
1022 |
if not TestCollisionYwithGear(Gear, 1) then |
|
1023 |
begin |
|
351 | 1024 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
1025 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1026 |
if hwAbs(Gear^.dX) > _0_1 then Gear^.dX:= Gear^.dX * _0_5; |
|
1027 |
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; |
|
1028 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1029 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 1030 |
if not (Gear^.Y < _1024) then |
79 | 1031 |
begin |
1032 |
DeleteGear(Gear); |
|
1033 |
exit |
|
1034 |
end |
|
1035 |
end else begin |
|
351 | 1036 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
79 | 1037 |
else begin |
506 | 1038 |
// doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 2, 0); |
351 | 1039 |
dec(Gear^.Health); |
1040 |
Gear^.Timer:= 1250 - Gear^.Angle * 12 |
|
79 | 1041 |
end |
1042 |
end; |
|
1043 |
||
351 | 1044 |
if (((GameTicks div 8) mod 64) = Gear^.Angle) then |
79 | 1045 |
AmmoFlameWork(Gear); |
1046 |
||
351 | 1047 |
if Gear^.Health = 0 then |
79 | 1048 |
DeleteGear(Gear) |
1049 |
end; |
|
82 | 1050 |
|
1051 |
//////////////////////////////////////////////////////////////////////////////// |
|
1052 |
procedure doStepFirePunchWork(Gear: PGear); |
|
1053 |
var HHGear: PGear; |
|
1054 |
begin |
|
1055 |
AllInactive:= false; |
|
351 | 1056 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
82 | 1057 |
begin |
1058 |
DeleteGear(Gear); |
|
1059 |
AfterAttack; |
|
1060 |
exit |
|
1061 |
end; |
|
1062 |
||
351 | 1063 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1064 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
82 | 1065 |
begin |
351 | 1066 |
Gear^.Tag:= hwRound(HHGear^.Y); |
498 | 1067 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
351 | 1068 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
1069 |
Gear^.Y:= HHGear^.Y; |
|
82 | 1070 |
AmmoShove(Gear, 30, 40); |
351 | 1071 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
82 | 1072 |
end; |
351 | 1073 |
|
1074 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1075 |
if not (HHGear^.dY.isNegative) then |
|
82 | 1076 |
begin |
542 | 1077 |
HHGear^.State:= HHGear^.State or gstMoving; |
82 | 1078 |
DeleteGear(Gear); |
1079 |
AfterAttack; |
|
1080 |
exit |
|
1081 |
end; |
|
351 | 1082 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1083 |
end; |
1084 |
||
1085 |
procedure doStepFirePunch(Gear: PGear); |
|
1086 |
var HHGear: PGear; |
|
1087 |
begin |
|
1088 |
AllInactive:= false; |
|
351 | 1089 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1090 |
DeleteCI(HHGear); |
498 | 1091 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1092 |
HHGear^.dX:= SignAs(cLittle, Gear^.dX); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1093 |
|
351 | 1094 |
HHGear^.dY:= - _0_3; |
82 | 1095 |
|
351 | 1096 |
Gear^.X:= HHGear^.X; |
979
edb8f208c1d9
Fix firepunch direction when attacking from high jump
unc0rr
parents:
974
diff
changeset
|
1097 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
351 | 1098 |
Gear^.dY:= - _0_9; |
1099 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1100 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
82 | 1101 |
end; |
1102 |
||
263 | 1103 |
//////////////////////////////////////////////////////////////////////////////// |
1104 |
||
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1105 |
procedure doStepParachuteWork(Gear: PGear); |
211 | 1106 |
var HHGear: PGear; |
1107 |
begin |
|
351 | 1108 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
82 | 1109 |
|
516 | 1110 |
inc(Gear^.Timer); |
1111 |
||
212 | 1112 |
if TestCollisionYwithGear(HHGear, 1) |
351 | 1113 |
or ((HHGear^.State and gstHHDriven) = 0) |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1114 |
or CheckGearDrowning(HHGear) |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1115 |
or ((Gear^.Message and gm_Attack) <> 0) then |
211 | 1116 |
begin |
1117 |
with HHGear^ do |
|
1118 |
begin |
|
1119 |
Message:= 0; |
|
568 | 1120 |
SetLittle(dX); |
498 | 1121 |
dY:= _0; |
542 | 1122 |
State:= State or gstMoving; |
211 | 1123 |
end; |
1124 |
DeleteGear(Gear); |
|
1125 |
exit |
|
1126 |
end; |
|
1127 |
||
351 | 1128 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1129 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
|
211 | 1130 |
|
351 | 1131 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1132 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1133 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1134 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1135 |
|
351 | 1136 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1137 |
Gear^.X:= HHGear^.X; |
1138 |
Gear^.Y:= HHGear^.Y |
|
263 | 1139 |
end; |
211 | 1140 |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1141 |
procedure doStepParachute(Gear: PGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1142 |
var HHGear: PGear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1143 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1144 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1145 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1146 |
DeleteCI(HHGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1147 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1148 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1149 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1150 |
|
931 | 1151 |
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
|
1152 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1153 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1154 |
Gear^.doStep:= @doStepParachuteWork; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1155 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1156 |
Gear^.Message:= HHGear^.Message; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1157 |
doStepParachuteWork(Gear) |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1158 |
end; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1159 |
|
263 | 1160 |
//////////////////////////////////////////////////////////////////////////////// |
1161 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1162 |
begin |
|
1163 |
AllInactive:= false; |
|
498 | 1164 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1165 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
263 | 1166 |
begin |
351 | 1167 |
dec(Gear^.Health); |
1168 |
case Gear^.State of |
|
498 | 1169 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
1170 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
285 | 1171 |
end; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1172 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
263 | 1173 |
end; |
498 | 1174 |
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1175 |
end; |
1176 |
||
1177 |
procedure doStepAirAttack(Gear: PGear); |
|
1178 |
begin |
|
1179 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1180 |
|
408 | 1181 |
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 |
1182 |
else Gear^.Tag:= -1; |
|
498 | 1183 |
Gear^.X:= _1024 - _2048 * Gear^.Tag; |
1184 |
Gear^.Y:= -_128; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1185 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1186 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1187 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
498 | 1188 |
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
|
1189 |
|
351 | 1190 |
Gear^.Health:= 6; |
801 | 1191 |
Gear^.doStep:= @doStepAirAttackWork; |
1192 |
PlaySound(sndIncoming, false) |
|
263 | 1193 |
end; |
1194 |
||
1195 |
//////////////////////////////////////////////////////////////////////////////// |
|
1196 |
||
1197 |
procedure doStepAirBomb(Gear: PGear); |
|
1198 |
begin |
|
1199 |
AllInactive:= false; |
|
1200 |
doStepFallingGear(Gear); |
|
351 | 1201 |
if (Gear^.State and gstCollision) <> 0 then |
263 | 1202 |
begin |
351 | 1203 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
263 | 1204 |
DeleteGear(Gear); |
1205 |
exit |
|
1206 |
end; |
|
1207 |
if (GameTicks and $3F) = 0 then |
|
498 | 1208 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1209 |
end; |
409 | 1210 |
|
1211 |
//////////////////////////////////////////////////////////////////////////////// |
|
1212 |
||
1213 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1214 |
var HHGear: PGear; |
409 | 1215 |
begin |
1216 |
AllInactive:= false; |
|
415 | 1217 |
|
1218 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1219 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1220 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1221 |
sprAmGirder, Gear^.State, true) then |
409 | 1222 |
begin |
415 | 1223 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
1224 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1225 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1226 |
DeleteGear(Gear); |
|
1227 |
isCursorVisible:= true |
|
409 | 1228 |
end |
415 | 1229 |
else begin |
1230 |
DeleteGear(Gear); |
|
1231 |
AfterAttack |
|
1232 |
end; |
|
1233 |
TargetPoint.X:= NoPointX |
|
409 | 1234 |
end; |
520 | 1235 |
|
1236 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1237 |
procedure doStepTeleportAfter(Gear: PGear); |
912 | 1238 |
var HHGear: PGear; |
1239 |
begin |
|
1240 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1241 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases |
|
1242 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1243 |
if TestCollisionYwithGear(HHGear, 1) |
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1244 |
or CheckGearDrowning(HHGear) then |
912 | 1245 |
begin |
1246 |
DeleteGear(Gear); |
|
1247 |
AfterAttack |
|
1248 |
end |
|
1249 |
end; |
|
1250 |
||
1251 |
procedure doStepTeleportAnim(Gear: PGear); |
|
525 | 1252 |
begin |
853 | 1253 |
inc(Gear^.Timer); |
1254 |
if Gear^.Timer = 65 then |
|
1255 |
begin |
|
1256 |
Gear^.Timer:= 0; |
|
1257 |
inc(Gear^.Pos); |
|
1258 |
if Gear^.Pos = 11 then |
|
912 | 1259 |
Gear^.doStep:= @doStepTeleportAfter |
853 | 1260 |
end |
525 | 1261 |
end; |
520 | 1262 |
|
1263 |
procedure doStepTeleport(Gear: PGear); |
|
1264 |
var HHGear: PGear; |
|
1265 |
begin |
|
1266 |
AllInactive:= false; |
|
1267 |
||
1268 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1269 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1270 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1271 |
sprHHTelepMask, 0, false) then |
|
853 | 1272 |
begin |
1273 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1274 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1275 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1276 |
DeleteGear(Gear); |
|
1277 |
isCursorVisible:= true |
|
1278 |
end |
|
1279 |
else begin |
|
1280 |
DeleteCI(HHGear); |
|
1281 |
SetAllHHToActive; |
|
912 | 1282 |
Gear^.doStep:= @doStepTeleportAnim; |
853 | 1283 |
Gear^.X:= HHGear^.X; |
1284 |
Gear^.Y:= HHGear^.Y; |
|
1285 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1286 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1287 |
HHGear^.State:= HHGear^.State or gstMoving |
|
1288 |
end; |
|
520 | 1289 |
TargetPoint.X:= NoPointX |
1290 |
end; |
|
534 | 1291 |
|
1292 |
//////////////////////////////////////////////////////////////////////////////// |
|
1293 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1294 |
var HHGear: PGear; |
|
1295 |
Msg, State: Longword; |
|
1296 |
begin |
|
1297 |
AllInactive:= false; |
|
1298 |
||
540 | 1299 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
534 | 1300 |
begin |
1301 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1302 |
Msg:= Gear^.Message and not gm_Switch; |
|
1303 |
DeleteGear(Gear); |
|
538 | 1304 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
1305 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1306 |
|
602 | 1307 |
HHGear:= CurrentHedgehog^.Gear; |
538 | 1308 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
534 | 1309 |
HHGear^.Message:= Msg; |
1310 |
exit |
|
1311 |
end; |
|
1312 |
||
1313 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1314 |
begin |
|
602 | 1315 |
HHGear:= CurrentHedgehog^.Gear; |
534 | 1316 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
809 | 1317 |
Gear^.Message:= Gear^.Message and not gm_Switch; |
534 | 1318 |
State:= HHGear^.State; |
1319 |
HHGear^.State:= 0; |
|
1320 |
HHGear^.Active:= false; |
|
1321 |
HHGear^.Z:= cHHZ; |
|
1322 |
RemoveGearFromList(HHGear); |
|
1323 |
InsertGearToList(HHGear); |
|
1324 |
||
1325 |
repeat |
|
551 | 1326 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
652 | 1327 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
1328 |
||
1329 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
|
534 | 1330 |
|
602 | 1331 |
HHGear:= CurrentHedgehog^.Gear; |
534 | 1332 |
HHGear^.State:= State; |
1333 |
HHGear^.Active:= true; |
|
1334 |
FollowGear:= HHGear; |
|
1335 |
HHGear^.Z:= cCurrHHZ; |
|
1336 |
RemoveGearFromList(HHGear); |
|
1337 |
InsertGearToList(HHGear); |
|
1338 |
Gear^.X:= HHGear^.X; |
|
1339 |
Gear^.Y:= HHGear^.Y |
|
1340 |
end; |
|
1341 |
end; |
|
1342 |
||
1343 |
procedure doStepSwitcher(Gear: PGear); |
|
1344 |
var HHGear: PGear; |
|
1345 |
begin |
|
1346 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1347 |
||
1348 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1349 |
with HHGear^ do |
|
1350 |
begin |
|
1351 |
State:= State and not gstAttacking; |
|
1352 |
Message:= Message and not gm_Attack |
|
1353 |
end |
|
1354 |
end; |
|
924 | 1355 |
|
1356 |
//////////////////////////////////////////////////////////////////////////////// |
|
1357 |
procedure doStepMortar(Gear: PGear); |
|
1358 |
var dX, dY: hwFloat; |
|
1359 |
i: LongInt; |
|
963 | 1360 |
dxn, dyn: boolean; |
924 | 1361 |
begin |
1362 |
AllInactive:= false; |
|
963 | 1363 |
dxn:= Gear^.dX.isNegative; |
1364 |
dyn:= Gear^.dY.isNegative; |
|
1365 |
||
924 | 1366 |
doStepFallingGear(Gear); |
1367 |
if (Gear^.State and gstCollision) <> 0 then |
|
1368 |
begin |
|
1369 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
963 | 1370 |
|
1371 |
Gear^.dX.isNegative:= not dxn; |
|
1372 |
Gear^.dY.isNegative:= not dyn; |
|
924 | 1373 |
for i:= 0 to 4 do |
1374 |
begin |
|
963 | 1375 |
dX:= Gear^.dX + (GetRandom - _0_5) * _0_03; |
1376 |
dY:= Gear^.dY + (GetRandom - _0_5) * _0_03; |
|
924 | 1377 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 0); |
1378 |
end; |
|
1379 |
||
1380 |
DeleteGear(Gear); |
|
1381 |
exit |
|
1382 |
end; |
|
963 | 1383 |
|
924 | 1384 |
if (GameTicks and $3F) = 0 then |
1385 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
1386 |
end; |
|
984 | 1387 |
|
1388 |
//////////////////////////////////////////////////////////////////////////////// |
|
1389 |
procedure doStepKamikazeWork(Gear: PGear); |
|
1390 |
const upd: Longword = 0; |
|
987 | 1391 |
var i: LongWord; |
984 | 1392 |
HHGear: PGear; |
1393 |
begin |
|
1394 |
AllInactive:= false; |
|
1395 |
||
1396 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1397 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1398 |
DeleteCI(HHGear); |
|
1399 |
||
1400 |
i:= 2; |
|
1401 |
repeat |
|
1402 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
1403 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
1404 |
HHGear^.X:= Gear^.X; |
|
1405 |
HHGear^.Y:= Gear^.Y; |
|
1406 |
||
1407 |
inc(Gear^.Damage, 2); |
|
1408 |
||
1409 |
if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
|
1410 |
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); |
|
1411 |
||
1412 |
dec(i) |
|
1413 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
|
1414 |
addfilelog(inttostr(Gear^.Damage)); |
|
1415 |
||
1416 |
inc(upd); |
|
1417 |
if upd > 3 then |
|
1418 |
begin |
|
987 | 1419 |
if Gear^.Health < 1500 then Gear^.Pos:= 2; |
1420 |
||
984 | 1421 |
AmmoShove(Gear, 30, 40); |
1422 |
||
1423 |
DrawTunnel(HHGear^.X - HHGear^.dX * 10, |
|
1424 |
HHGear^.Y - _3 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 5, |
|
1425 |
HHGear^.dX, |
|
1426 |
HHGear^.dY, |
|
1427 |
20 + cHHRadius * 2, |
|
1428 |
cHHRadius * 2 + 4); |
|
1429 |
||
1430 |
upd:= 0 |
|
1431 |
end; |
|
1432 |
||
1433 |
if Gear^.Health < Gear^.Damage then |
|
1434 |
begin |
|
1435 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1436 |
AfterAttack; |
|
1437 |
DeleteGear(Gear); |
|
1438 |
DeleteGear(HHGear); |
|
1439 |
end else |
|
1440 |
begin |
|
1441 |
dec(Gear^.Health, Gear^.Damage); |
|
1442 |
Gear^.Damage:= 0 |
|
1443 |
end |
|
1444 |
end; |
|
1445 |
||
987 | 1446 |
procedure doStepKamikazeIdle(Gear: PGear); |
1447 |
begin |
|
1448 |
AllInactive:= false; |
|
1449 |
dec(Gear^.Timer); |
|
1450 |
if Gear^.Timer = 0 then |
|
1451 |
begin |
|
1452 |
Gear^.Pos:= 1; |
|
992 | 1453 |
PlaySound(sndKamikaze, false); |
987 | 1454 |
Gear^.doStep:= @doStepKamikazeWork |
1455 |
end |
|
1456 |
end; |
|
1457 |
||
984 | 1458 |
procedure doStepKamikaze(Gear: PGear); |
1459 |
var HHGear: PGear; |
|
1460 |
begin |
|
1461 |
AllInactive:= false; |
|
1462 |
||
1463 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1464 |
||
1465 |
HHGear^.dX:= Gear^.dX; |
|
1466 |
HHGear^.dY:= Gear^.dY; |
|
1467 |
||
1468 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
|
1469 |
Gear^.dY:= - _0_9; |
|
1470 |
||
987 | 1471 |
Gear^.Timer:= 550; |
1472 |
||
1473 |
Gear^.doStep:= @doStepKamikazeIdle |
|
984 | 1474 |
end; |
1475 |