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