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