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