author  unc0rr 
Tue, 12 Aug 2008 19:41:16 +0000  
changeset 1200  b92323ccce45 
parent 1158  d03d12ef8971 
child 1206  d852883fcefe 
permissions  rwrr 
4  1 
(* 
1066  2 
* Hedgewars, a free turn based strategy game 
883  3 
* Copyright (c) 20042008 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 021111307, 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 
1133  24 
begin 
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)) 
1133  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 
1123  44 
begin 
45 
if _0_6 < Gear^.dY then 

1132  46 
PlaySound(sndOw4, false) 
1123  47 
else 
1132  48 
PlaySound(sndOw1, false); 
1123  49 

50 
dmg:= 1 + hwRound((hwAbs(Gear^.dY)  _0_4) * 70); 

51 
inc(Gear^.Damage, dmg); 

52 
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, dmg, Gear); 

53 
end 

4  54 
end; 
55 

56 
//////////////////////////////////////////////////////////////////////////////// 

57 
//////////////////////////////////////////////////////////////////////////////// 

58 
procedure CalcRotationDirAngle(Gear: PGear); 

776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset

59 
var dAngle: real; 
4  60 
begin 
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset

61 
dAngle:= (hwAbs(Gear^.dX) + hwAbs(Gear^.dY)).QWordValue / $80000000; 
1133  62 
if not Gear^.dX.isNegative then 
63 
Gear^.DirAngle:= Gear^.DirAngle + dAngle 

64 
else 

65 
Gear^.DirAngle:= Gear^.DirAngle  dAngle; 

66 

776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset

67 
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

68 
else if 360 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle  360 
4  69 
end; 
70 

71 
//////////////////////////////////////////////////////////////////////////////// 

72 
procedure doStepDrowningGear(Gear: PGear); 

73 
begin 

74 
AllInactive:= false; 

351  75 
Gear^.Y:= Gear^.Y + cDrownSpeed; 
76 
if hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear) 

4  77 
end; 
78 

79 
//////////////////////////////////////////////////////////////////////////////// 

80 
procedure doStepFallingGear(Gear: PGear); 

542  81 
var isFalling: boolean; 
4  82 
begin 
503  83 
Gear^.State:= Gear^.State and not gstCollision; 
84 

85 
if Gear^.dY.isNegative then 

1133  86 
begin 
87 
isFalling:= true; 

88 
if TestCollisionYwithGear(Gear, 1) then 

89 
begin 

90 
Gear^.dX:= Gear^.dX * Gear^.Friction; 

91 
Gear^.dY:=  Gear^.dY * Gear^.Elasticity; 

92 
Gear^.State:= Gear^.State or gstCollision 

93 
end 

94 
end else 

95 
if TestCollisionYwithGear(Gear, 1) then 

96 
begin 

97 
isFalling:= false; 

98 
Gear^.dX:= Gear^.dX * Gear^.Friction; 

99 
Gear^.dY:=  Gear^.dY * Gear^.Elasticity; 

100 
Gear^.State:= Gear^.State or gstCollision 

101 
end else isFalling:= true; 

503  102 

351  103 
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then 
1133  104 
begin 
105 
Gear^.dX:=  Gear^.dX * Gear^.Elasticity; 

106 
Gear^.dY:= Gear^.dY * Gear^.Elasticity; 

107 
Gear^.State:= Gear^.State or gstCollision 

108 
end; 

503  109 

542  110 
if isFalling then Gear^.dY:= Gear^.dY + cGravity; 
503  111 

351  112 
Gear^.X:= Gear^.X + Gear^.dX; 
113 
Gear^.Y:= Gear^.Y + Gear^.dY; 

4  114 
CheckGearDrowning(Gear); 
503  115 
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and 
1133  116 
(not isFalling) then 
117 
Gear^.State:= Gear^.State and not gstMoving 

118 
else 

119 
Gear^.State:= Gear^.State or gstMoving 

4  120 
end; 
121 

122 
//////////////////////////////////////////////////////////////////////////////// 

123 
procedure doStepBomb(Gear: PGear); 

371  124 
var i: LongInt; 
919  125 
dX, dY: hwFloat; 
4  126 
begin 
127 
AllInactive:= false; 

128 
doStepFallingGear(Gear); 

351  129 
dec(Gear^.Timer); 
130 
if Gear^.Timer = 0 then 

1133  131 
begin 
132 
case Gear^.Kind of 

133 
gtAmmo_Bomb: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 

134 
gtClusterBomb: begin 

135 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); 

136 
for i:= 0 to 4 do 

137 
begin 

138 
dX:= rndSign(GetRandom * _0_1); 

139 
dY:= (GetRandom  _3) * _0_08; 

140 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 0); 

141 
end 

142 
end 

143 
end; 

144 
DeleteGear(Gear); 

145 
exit 

146 
end; 

4  147 
CalcRotationDirAngle(Gear); 
1158  148 
if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then 
149 
if (hwAbs(Gear^.dX) > _0_1) or 

150 
(hwAbs(Gear^.dY) > _0_1) then 

151 
PlaySound(sndGrenadeImpact, false) 

4  152 
end; 
153 

78  154 
procedure doStepCluster(Gear: PGear); 
155 
begin 

156 
AllInactive:= false; 

157 
doStepFallingGear(Gear); 

351  158 
if (Gear^.State and gstCollision) <> 0 then 
1133  159 
begin 
160 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound); 

161 
DeleteGear(Gear); 

162 
exit 

163 
end; 

78  164 
if (GameTicks and $1F) = 0 then 
1133  165 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) 
78  166 
end; 
167 

4  168 
//////////////////////////////////////////////////////////////////////////////// 
169 
procedure doStepGrenade(Gear: PGear); 

170 
begin 

171 
AllInactive:= false; 

351  172 
Gear^.dX:= Gear^.dX + cWindSpeed; 
4  173 
doStepFallingGear(Gear); 
351  174 
if (Gear^.State and gstCollision) <> 0 then 
1133  175 
begin 
176 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 

177 
DeleteGear(Gear); 

178 
exit 

179 
end; 

4  180 
if (GameTicks and $3F) = 0 then 
1133  181 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) 
4  182 
end; 
183 

184 
//////////////////////////////////////////////////////////////////////////////// 

95  185 
procedure doStepHealthTagWork(Gear: PGear); 
4  186 
begin 
522  187 
if Gear^.Kind = gtHealthTag then 
188 
AllInactive:= false; 

351  189 
dec(Gear^.Timer); 
522  190 
Gear^.Y:= Gear^.Y + Gear^.dY; 
351  191 
if Gear^.Timer = 0 then 
1133  192 
begin 
193 
if Gear^.Kind = gtHealthTag then 

194 
PHedgehog(Gear^.Hedgehog)^.Gear^.Active:= true; // to let current hh die 

195 
DeleteGear(Gear) 

196 
end 

4  197 
end; 
198 

263  199 
procedure doStepHealthTagWorkUnderWater(Gear: PGear); 
200 
begin 

201 
AllInactive:= false; 

351  202 
Gear^.Y:= Gear^.Y  _0_08; 
498  203 
if hwRound(Gear^.Y) < cWaterLine + 10 then 
263  204 
DeleteGear(Gear) 
205 
end; 

206 

95  207 
procedure doStepHealthTag(Gear: PGear); 
208 
var s: shortstring; 

522  209 
font: THWFont; 
95  210 
begin 
522  211 
if Gear^.Kind = gtHealthTag then 
212 
begin 

813  213 
AllInactive:= false; 
522  214 
font:= fnt16; 
215 
Gear^.dY:= _0_08 

216 
end else 

217 
begin 

218 
font:= fntSmall; 

219 
Gear^.dY:= _0_02 

220 
end; 

221 

351  222 
str(Gear^.State, s); 
762  223 
Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, font); 
498  224 
if hwRound(Gear^.Y) < cWaterLine then Gear^.doStep:= @doStepHealthTagWork 
522  225 
else Gear^.doStep:= @doStepHealthTagWorkUnderWater; 
762  226 
Gear^.Y:= Gear^.Y  int2hwFloat(Gear^.Tex^.h) 
95  227 
end; 
228 

4  229 
//////////////////////////////////////////////////////////////////////////////// 
230 
procedure doStepGrave(Gear: PGear); 

231 
begin 

232 
AllInactive:= false; 

498  233 
if Gear^.dY.isNegative then 
234 
if TestCollisionY(Gear, 1) then Gear^.dY:= _0; 

4  235 

351  236 
if not Gear^.dY.isNegative then 
68  237 
if TestCollisionY(Gear, 1) then 
4  238 
begin 
351  239 
Gear^.dY:=  Gear^.dY * Gear^.Elasticity; 
240 
if Gear^.dY >  _1div1024 then 

4  241 
begin 
351  242 
Gear^.Active:= false; 
4  243 
exit 
351  244 
end else if Gear^.dY <  _0_03 then PlaySound(sndGraveImpact, false) 
4  245 
end; 
351  246 
Gear^.Y:= Gear^.Y + Gear^.dY; 
4  247 
CheckGearDrowning(Gear); 
351  248 
Gear^.dY:= Gear^.dY + cGravity 
4  249 
end; 
250 

251 
//////////////////////////////////////////////////////////////////////////////// 

252 
procedure doStepUFOWork(Gear: PGear); 

351  253 
var t: hwFloat; 
374  254 
y: LongInt; 
4  255 
begin 
256 
AllInactive:= false; 

351  257 
t:= Distance(Gear^.dX, Gear^.dY); 
258 
Gear^.dX:= Gear^.Elasticity * (Gear^.dX + _0_000004 * (TargetPoint.X  hwRound(Gear^.X))); 

259 
Gear^.dY:= Gear^.Elasticity * (Gear^.dY + _0_000004 * (TargetPoint.Y  hwRound(Gear^.Y))); 

260 
t:= t / Distance(Gear^.dX, Gear^.dY); 

261 
Gear^.dX:= Gear^.dX * t; 

262 
Gear^.dY:= Gear^.dY * t; 

263 
Gear^.X:= Gear^.X + Gear^.dX; 

264 
Gear^.Y:= Gear^.Y + Gear^.dY; 

374  265 

266 
if (GameTicks and $3F) = 0 then 

267 
begin 

268 
y:= hwRound(Gear^.Y); 

269 
if y + Gear^.Radius < cWaterLine then 

498  270 
AddGear(hwRound(Gear^.X), y, gtSmokeTrace, 0, _0, _0, 0); 
374  271 
end; 
272 

4  273 
CheckCollision(Gear); 
351  274 
dec(Gear^.Timer); 
275 
if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then 

4  276 
begin 
560  277 
StopSound(sndUFO); 
351  278 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 
4  279 
DeleteGear(Gear); 
280 
end; 

281 
end; 

282 

283 
procedure doStepUFO(Gear: PGear); 

284 
begin 

285 
AllInactive:= false; 

351  286 
Gear^.X:= Gear^.X + Gear^.dX; 
287 
Gear^.Y:= Gear^.Y + Gear^.dY; 

288 
Gear^.dY:= Gear^.dY + cGravity; 

4  289 
CheckCollision(Gear); 
351  290 
if (Gear^.State and gstCollision) <> 0 then 
4  291 
begin 
351  292 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 
4  293 
DeleteGear(Gear); 
294 
exit 

295 
end; 

351  296 
dec(Gear^.Timer); 
297 
if Gear^.Timer = 0 then 

4  298 
begin 
560  299 
PlaySound(sndUFO, true); 
351  300 
Gear^.Timer:= 5000; 
301 
Gear^.doStep:= @doStepUFOWork 

4  302 
end; 
303 
end; 

304 

305 
//////////////////////////////////////////////////////////////////////////////// 

876  306 
procedure doStepShotIdle(Gear: PGear); 
307 
begin 

308 
AllInactive:= false; 

309 
inc(Gear^.Timer); 

310 
if Gear^.Timer > 75 then 

311 
begin 

312 
DeleteGear(Gear); 

313 
AfterAttack 

314 
end 

315 
end; 

316 

4  317 
procedure doStepShotgunShot(Gear: PGear); 
318 
var i: LongWord; 

319 
begin 

320 
AllInactive:= false; 

876  321 

322 
if ((Gear^.State and gstAnimation) = 0) then 

323 
begin 

324 
dec(Gear^.Timer); 

325 
if Gear^.Timer = 0 then 

326 
begin 

327 
PlaySound(sndShotgunFire, false); 

328 
Gear^.State:= Gear^.State or gstAnimation 

329 
end; 

330 
exit 

331 
end 

332 
else inc(Gear^.Timer); 

333 

4  334 
i:= 200; 
335 
repeat 

351  336 
Gear^.X:= Gear^.X + Gear^.dX; 
337 
Gear^.Y:= Gear^.Y + Gear^.dY; 

4  338 
CheckCollision(Gear); 
351  339 
if (Gear^.State and gstCollision) <> 0 then 
876  340 
begin 
341 
Gear^.X:= Gear^.X + Gear^.dX * 8; 

342 
Gear^.Y:= Gear^.Y + Gear^.dY * 8; 

343 
ShotgunShot(Gear); 

344 
Gear^.doStep:= @doStepShotIdle; 

345 
exit 

346 
end; 

4  347 
dec(i) 
348 
until i = 0; 

498  349 
if (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then 
876  350 
Gear^.doStep:= @doStepShotIdle 
4  351 
end; 
352 

353 
//////////////////////////////////////////////////////////////////////////////// 

559  354 
procedure doStepDEagleShotWork(Gear: PGear); 
38  355 
var i, x, y: LongWord; 
351  356 
oX, oY: hwFloat; 
38  357 
begin 
358 
AllInactive:= false; 

876  359 
inc(Gear^.Timer); 
37  360 
i:= 80; 
351  361 
oX:= Gear^.X; 
362 
oY:= Gear^.Y; 

37  363 
repeat 
351  364 
Gear^.X:= Gear^.X + Gear^.dX; 
365 
Gear^.Y:= Gear^.Y + Gear^.dY; 

366 
x:= hwRound(Gear^.X); 

367 
y:= hwRound(Gear^.Y); 

38  368 
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0) 
351  369 
and (Land[y, x] <> 0) then inc(Gear^.Damage); 
519  370 
if Gear^.Damage > 5 then AmmoShove(Gear, 7, 20); 
38  371 
dec(i) 
351  372 
until (i = 0) or (Gear^.Damage > Gear^.Health); 
373 
if Gear^.Damage > 0 then 

37  374 
begin 
351  375 
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82  i, 1); 
376 
dec(Gear^.Health, Gear^.Damage); 

377 
Gear^.Damage:= 0 

37  378 
end; 
498  379 
if (Gear^.Health <= 0) or (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then 
876  380 
Gear^.doStep:= @doStepShotIdle 
37  381 
end; 
382 

559  383 
procedure doStepDEagleShot(Gear: PGear); 
384 
begin 

385 
PlaySound(sndGun, false); 

386 
Gear^.doStep:= @doStepDEagleShotWork 

387 
end; 

388 

37  389 
//////////////////////////////////////////////////////////////////////////////// 
4  390 
procedure doStepActionTimer(Gear: PGear); 
391 
begin 

351  392 
dec(Gear^.Timer); 
393 
case Gear^.Kind of 

83  394 
gtATStartGame: begin 
4  395 
AllInactive:= false; 
351  396 
if Gear^.Timer = 0 then 
83  397 
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); 
4  398 
end; 
83  399 
gtATSmoothWindCh: begin 
351  400 
if Gear^.Timer = 0 then 
6  401 
begin 
351  402 
if WindBarWidth < Gear^.Tag then inc(WindBarWidth) 
403 
else if WindBarWidth > Gear^.Tag then dec(WindBarWidth); 

404 
if WindBarWidth <> Gear^.Tag then Gear^.Timer:= 10; 

83  405 
end 
406 
end; 

407 
gtATFinishGame: begin 

408 
AllInactive:= false; 

351  409 
if Gear^.Timer = 0 then 
113  410 
begin 
411 
SendIPC('N'); 

324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset

412 
SendIPC('q'); 
83  413 
GameState:= gsExit 
113  414 
end 
6  415 
end; 
4  416 
end; 
351  417 
if Gear^.Timer = 0 then DeleteGear(Gear) 
4  418 
end; 
419 

420 
//////////////////////////////////////////////////////////////////////////////// 

421 
procedure doStepPickHammerWork(Gear: PGear); 

371  422 
var i, ei: LongInt; 
4  423 
HHGear: PGear; 
424 
begin 

70  425 
AllInactive:= false; 
351  426 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
427 
dec(Gear^.Timer); 

428 
if (Gear^.Timer = 0)or((Gear^.Message and gm_Destroy) <> 0)or((HHGear^.State and gstHHDriven) = 0) then 

1200  429 
begin 
430 
StopSound(sndPickhammer); 

431 
DeleteGear(Gear); 

432 
AfterAttack; 

433 
exit 

434 
end; 

845  435 

422  436 
if (Gear^.Timer mod 33) = 0 then 
1200  437 
begin 
438 
HHGear^.State:= HHGear^.State or gstNoDamage; 

439 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y) + 7, 6, EXPLDontDraw); 

440 
HHGear^.State:= HHGear^.State and not gstNoDamage 

441 
end; 

422  442 

443 
if (Gear^.Timer mod 47) = 0 then 

1200  444 
begin 
445 
i:= hwRound(Gear^.X)  Gear^.Radius  LongInt(GetRandom(2)); 

446 
ei:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); 

447 
while i <= ei do 

448 
begin 

449 
DrawExplosion(i, hwRound(Gear^.Y) + 3, 3); 

450 
inc(i, 1) 

451 
end; 

452 
Gear^.X:= Gear^.X + Gear^.dX; 

453 
Gear^.Y:= Gear^.Y + _1_9; 

454 
SetAllHHToActive; 

455 
end; 

4  456 
if TestCollisionYwithGear(Gear, 1) then 
1200  457 
begin 
458 
Gear^.dY:= _0; 

459 
SetLittle(HHGear^.dX); 

460 
HHGear^.dY:= _0; 

461 
end else 

462 
begin 

463 
Gear^.dY:= Gear^.dY + cGravity; 

464 
Gear^.Y:= Gear^.Y + Gear^.dY; 

465 
if Gear^.Y > _1024 then Gear^.Timer:= 1 

466 
end; 

4  467 

351  468 
Gear^.X:= Gear^.X + HHGear^.dX; 
469 
HHGear^.X:= Gear^.X; 

498  470 
HHGear^.Y:= Gear^.Y  int2hwFloat(cHHRadius); 
4  471 

351  472 
if (Gear^.Message and gm_Attack) <> 0 then 
473 
if (Gear^.State and gsttmpFlag) <> 0 then Gear^.Timer:= 1 else else 

474 
if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; 

475 
if ((Gear^.Message and gm_Left) <> 0) then Gear^.dX:=  _0_3 else 

476 
if ((Gear^.Message and gm_Right) <> 0) then Gear^.dX:= _0_3 

498  477 
else Gear^.dX:= _0; 
4  478 
end; 
479 

480 
procedure doStepPickHammer(Gear: PGear); 

371  481 
var i, y: LongInt; 
4  482 
ar: TRangeArray; 
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset

483 
HHGear: PGear; 
4  484 
begin 
485 
i:= 0; 

911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset

486 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset

487 

498  488 
y:= hwRound(Gear^.Y)  cHHRadius * 2; 
351  489 
while y < hwRound(Gear^.Y) do 
4  490 
begin 
371  491 
ar[i].Left := hwRound(Gear^.X)  Gear^.Radius  LongInt(GetRandom(2)); 
492 
ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); 

4  493 
inc(y, 2); 
494 
inc(i) 

495 
end; 

911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset

496 

498  497 
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

498 
Gear^.dY:= HHGear^.dY; 
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset

499 
DeleteCI(HHGear); 
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset

500 

282  501 
PlaySound(sndPickhammer, true); 
4  502 
doStepPickHammerWork(Gear); 
351  503 
Gear^.doStep:= @doStepPickHammerWork 
4  504 
end; 
505 

506 
//////////////////////////////////////////////////////////////////////////////// 

371  507 
var BTPrevAngle, BTSteps: LongInt; 
302  508 

303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset

509 
procedure doStepBlowTorchWork(Gear: PGear); 
302  510 
var HHGear: PGear; 
305  511 
b: boolean; 
302  512 
begin 
513 
AllInactive:= false; 

351  514 
dec(Gear^.Timer); 
515 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 

303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset

516 

1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset

517 
HedgehogChAngle(HHGear); 
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset

518 

305  519 
b:= false; 
520 

371  521 
if abs(LongInt(HHGear^.Angle)  BTPrevAngle) > 7 then 
305  522 
begin 
498  523 
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX); 
355  524 
Gear^.dY:= AngleCos(HHGear^.Angle) * (  _0_5); 
351  525 
BTPrevAngle:= HHGear^.Angle; 
358  526 
b:= true 
305  527 
end; 
528 

351  529 
if Gear^.Timer mod cHHStepTicks = 0 then 
302  530 
begin 
305  531 
b:= true; 
498  532 
if Gear^.dX.isNegative then HHGear^.Message:= (HHGear^.Message or gm_Left) and not gm_Right 
533 
else HHGear^.Message:= (HHGear^.Message or gm_Right) and not gm_Left; 

357  534 

535 
HHGear^.State:= HHGear^.State and not gstAttacking; 

302  536 
HedgehogStep(HHGear); 
357  537 
HHGear^.State:= HHGear^.State or gstAttacking; 
305  538 

539 
inc(BTSteps); 

511  540 
if BTSteps = 7 then 
305  541 
begin 
542 
BTSteps:= 0; 

511  543 
Gear^.X:= HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); 
544 
Gear^.Y:= HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); 

351  545 
HHGear^.State:= HHGear^.State or gstNoDamage; 
511  546 
AmmoShove(Gear, 2, 14); 
351  547 
HHGear^.State:= HHGear^.State and not gstNoDamage 
305  548 
end; 
549 

542  550 
if (HHGear^.State and gstMoving) <> 0 then Gear^.Timer:= 0 
302  551 
end; 
305  552 

553 
if b then 

498  554 
DrawTunnel(HHGear^.X  Gear^.dX * cHHRadius, HHGear^.Y  _4  Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, 
351  555 
Gear^.dX, Gear^.dY, 
306  556 
cHHRadius * 5, cHHRadius * 2 + 6); 
305  557 

351  558 
if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) then 
302  559 
begin 
351  560 
HHGear^.Message:= 0; 
302  561 
DeleteGear(Gear); 
562 
AfterAttack 

563 
end 

564 
end; 

565 

303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset

566 
procedure doStepBlowTorch(Gear: PGear); 
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset

567 
var HHGear: PGear; 
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset

568 
begin 
371  569 
BTPrevAngle:= High(LongInt); 
305  570 
BTSteps:= 0; 
351  571 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
572 
HHGear^.Message:= 0; 

573 
Gear^.doStep:= @doStepBlowTorchWork 

303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset

574 
end; 
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset

575 

302  576 
//////////////////////////////////////////////////////////////////////////////// 
577 

4  578 
procedure doStepRopeWork(Gear: PGear); 
70  579 
const flCheck: boolean = false; 
4  580 
var HHGear: PGear; 
789  581 
len, cs, cc, tx, ty, nx, ny: hwFloat; 
108  582 
lx, ly: LongInt; 
4  583 

584 
procedure DeleteMe; 

585 
begin 

586 
with HHGear^ do 

587 
begin 

588 
Message:= Message and not gm_Attack; 

542  589 
State:= State or gstMoving; 
4  590 
end; 
929
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

591 
DeleteGear(Gear) 
4  592 
end; 
593 

594 
begin 

351  595 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
108  596 

351  597 
if ((HHGear^.State and gstHHDriven) = 0) 
80  598 
or (CheckGearDrowning(HHGear)) then 
4  599 
begin 
600 
DeleteMe; 

601 
exit 

602 
end; 

928
b9064b48b001
Some preparation work for attacking from rope, parachute and etc.
unc0rr
parents:
925
diff
changeset

603 

351  604 
Gear^.dX:= HHGear^.X  Gear^.X; 
605 
Gear^.dY:= HHGear^.Y  Gear^.Y; 

4  606 

351  607 
if (Gear^.Message and gm_Left <> 0) then HHGear^.dX:= HHGear^.dX  _0_0002 else 
608 
if (Gear^.Message and gm_Right <> 0) then HHGear^.dX:= HHGear^.dX + _0_0002; 

4  609 

351  610 
if not TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= HHGear^.dY + cGravity; 
4  611 

351  612 
cs:= Gear^.dY + HHGear^.dY; 
613 
cc:= Gear^.dX + HHGear^.dX; 

498  614 
len:= _1 / Distance(cc, cs); 
789  615 
cc:= cc * len; // rope vector plus hedgehog direction vector normalized 
108  616 
cs:= cs * len; 
4  617 

1142
2c522c1ded31
Last try to get rope not to get stuck in the ground
unc0rr
parents:
1133
diff
changeset

618 
nx:= hwAbs(cs) * hwSign(HHGear^.dX) * 7; // hedgehog direction normalized with length 7 
2c522c1ded31
Last try to get rope not to get stuck in the ground
unc0rr
parents:
1133
diff
changeset

619 
ny:= hwAbs(cc) * hwSign(HHGear^.dY) * 7; 
789  620 

4  621 
flCheck:= not flCheck; 
622 
if flCheck then // check whether rope needs dividing 

623 
begin 

498  624 
len:= Gear^.Elasticity  _20; 
625 
while len > _5 do 

4  626 
begin 
627 
tx:= cc*len; 

628 
ty:= cs*len; 

789  629 
lx:= hwRound(Gear^.X + tx + nx); 
630 
ly:= hwRound(Gear^.Y + ty + ny); 

652  631 
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0) and (Land[ly, lx] <> 0) then 
4  632 
begin 
633 
with RopePoints.ar[RopePoints.Count] do 

634 
begin 

351  635 
X:= Gear^.X; 
636 
Y:= Gear^.Y; 

776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset

637 
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); 
351  638 
b:= (cc * HHGear^.dY) > (cs * HHGear^.dX); 
4  639 
dLen:= len 
640 
end; 

351  641 
Gear^.X:= Gear^.X + tx; 
642 
Gear^.Y:= Gear^.Y + ty; 

4  643 
inc(RopePoints.Count); 
789  644 
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); 
351  645 
Gear^.Elasticity:= Gear^.Elasticity  len; 
646 
Gear^.Friction:= Gear^.Friction  len; 

4  647 
break 
648 
end; 

789  649 
len:= len  _2 
4  650 
end; 
651 
end else 

652 
if RopePoints.Count > 0 then // check whether the last dividing point could be removed 

653 
begin 

654 
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; 

655 
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; 

351  656 
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx  Gear^.X) * (ty  HHGear^.Y) > (tx  HHGear^.X) * (ty  Gear^.Y)) then 
4  657 
begin 
658 
dec(RopePoints.Count); 

351  659 
Gear^.X:=RopePoints.ar[RopePoints.Count].X; 
660 
Gear^.Y:=RopePoints.ar[RopePoints.Count].Y; 

661 
Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; 

662 
Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen 

4  663 
end 
664 
end; 

665 

351  666 
Gear^.dX:= HHGear^.X  Gear^.X; 
667 
Gear^.dY:= HHGear^.Y  Gear^.Y; 

108  668 

351  669 
cs:= Gear^.dY + HHGear^.dY; 
670 
cc:= Gear^.dX + HHGear^.dX; 

498  671 
len:= _1 / Distance(cc, cs); 
108  672 
cc:= cc * len; 
673 
cs:= cs * len; 

4  674 

351  675 
HHGear^.dX:= HHGear^.X; 
676 
HHGear^.dY:= HHGear^.Y; 

4  677 

351  678 
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then 
679 
if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) 

680 
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity + _0_3; 

4  681 

498  682 
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then 
351  683 
if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) 
684 
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity  _0_3; 

4  685 

351  686 
HHGear^.X:= Gear^.X + cc*Gear^.Elasticity; 
687 
HHGear^.Y:= Gear^.Y + cs*Gear^.Elasticity; 

4  688 

351  689 
HHGear^.dX:= HHGear^.X  HHGear^.dX; 
690 
HHGear^.dY:= HHGear^.Y  HHGear^.dY; 

4  691 

351  692 
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then 
693 
HHGear^.dX:= _0_6 * HHGear^.dX; 

694 
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then 

695 
HHGear^.dY:= _0_6 * HHGear^.dY; 

4  696 

789  697 
len:= Distance(HHGear^.dX, HHGear^.dY); 
940  698 
if len > _0_8 then 
789  699 
begin 
940  700 
len:= _0_8 / len; 
789  701 
HHGear^.dX:= HHGear^.dX * len; 
702 
HHGear^.dY:= HHGear^.dY * len; 

703 
end; 

704 

351  705 
if (Gear^.Message and gm_Attack) <> 0 then 
706 
if (Gear^.State and gsttmpFlag) <> 0 then DeleteMe else 

707 
else if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; 

4  708 
end; 
709 

710 

711 
procedure doStepRopeAttach(Gear: PGear); 

712 
var HHGear: PGear; 

351  713 
tx, ty, tt: hwFloat; 
4  714 
begin 
351  715 
Gear^.X:= Gear^.X  Gear^.dX; 
716 
Gear^.Y:= Gear^.Y  Gear^.dY; 

498  717 
Gear^.Elasticity:= Gear^.Elasticity + _1; 
351  718 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
517  719 
DeleteCI(HHGear); 
542  720 
if (HHGear^.State and gstMoving) <> 0 then 
68  721 
if TestCollisionYwithGear(HHGear, 1) then 
4  722 
begin 
820
a26537586400
Fix fall without damage trick, which could be performed with not attached rope
unc0rr
parents:
819
diff
changeset

723 
CheckHHDamage(HHGear); 
498  724 
HHGear^.dY:= _0; 
542  725 
HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); 
4  726 
end else 
727 
begin 

351  728 
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); 
729 
HHGear^.X:= HHGear^.X + HHGear^.dX; 

730 
HHGear^.Y:= HHGear^.Y + HHGear^.dY; 

731 
Gear^.X:= Gear^.X + HHGear^.dX; 

732 
Gear^.Y:= Gear^.Y + HHGear^.dY; 

733 
HHGear^.dY:= HHGear^.dY + cGravity; 

734 
tt:= Gear^.Elasticity; 

498  735 
tx:= _0; 
736 
ty:= _0; 

737 
while tt > _20 do 

4  738 
begin 
517  739 
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), hwSign(Gear^.dX)) 
740 
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), hwSign(Gear^.dY)) then 

4  741 
begin 
351  742 
Gear^.X:= Gear^.X + tx; 
743 
Gear^.Y:= Gear^.Y + ty; 

744 
Gear^.Elasticity:= tt; 

745 
Gear^.doStep:= @doStepRopeWork; 

4  746 
with HHGear^ do State:= State and not gstAttacking; 
498  747 
tt:= _0 
4  748 
end; 
517  749 
tx:= tx + Gear^.dX + Gear^.dX; 
750 
ty:= ty + Gear^.dY + Gear^.dY; 

498  751 
tt:= tt  _2; 
4  752 
end; 
753 
end; 

929
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

754 

4  755 
CheckCollision(Gear); 
929
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

756 

351  757 
if (Gear^.State and gstCollision) <> 0 then 
929
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

758 
begin 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

759 
Gear^.doStep:= @doStepRopeWork; 
974
fc16141a0128
Prevent wrong aim direction when using rope after high jump
unc0rr
parents:
963
diff
changeset

760 
with HHGear^ do State:= State and not (gstAttacking or gstHHHJump); 
929
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

761 

9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

762 
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

763 
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

764 

9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

765 
if Gear^.Elasticity < _10 then 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

766 
Gear^.Elasticity:= _10000; 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

767 
end; 
4  768 

351  769 
if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then 
4  770 
begin 
351  771 
with PHedgehog(Gear^.Hedgehog)^.Gear^ do 
4  772 
begin 
773 
State:= State and not gstAttacking; 

774 
Message:= Message and not gm_Attack 

775 
end; 

776 
DeleteGear(Gear) 

777 
end 

778 
end; 

779 

780 
procedure doStepRope(Gear: PGear); 

781 
begin 

351  782 
Gear^.dX:=  Gear^.dX; 
783 
Gear^.dY:=  Gear^.dY; 

784 
Gear^.doStep:= @doStepRopeAttach 

4  785 
end; 
786 

787 
//////////////////////////////////////////////////////////////////////////////// 

788 
procedure doStepSmokeTrace(Gear: PGear); 

789 
begin 

351  790 
inc(Gear^.Timer); 
791 
if Gear^.Timer > 64 then 

1133  792 
begin 
793 
Gear^.Timer:= 0; 

794 
dec(Gear^.State) 

795 
end; 

351  796 
Gear^.dX:= Gear^.dX + cWindSpeed; 
797 
Gear^.X:= Gear^.X + Gear^.dX; 

798 
if Gear^.State = 0 then DeleteGear(Gear) 

4  799 
end; 
9  800 

801 
//////////////////////////////////////////////////////////////////////////////// 

1045  802 
procedure doStepExplosionWork(Gear: PGear); 
9  803 
begin 
351  804 
inc(Gear^.Timer); 
805 
if Gear^.Timer > 75 then 

1133  806 
begin 
807 
inc(Gear^.State); 

808 
Gear^.Timer:= 0; 

809 
if Gear^.State > 5 then DeleteGear(Gear) 

810 
end; 

9  811 
end; 
10  812 

1045  813 
procedure doStepExplosion(Gear: PGear); 
814 
var i: LongWord; 

815 
begin 

1047  816 
for i:= 0 to 31 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFire); 
817 
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart); 

818 
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart2); 

1045  819 
Gear^.doStep:= @doStepExplosionWork 
820 
end; 

821 

10  822 
//////////////////////////////////////////////////////////////////////////////// 
823 
procedure doStepMine(Gear: PGear); 

824 
begin 

542  825 
if (Gear^.State and gstMoving) <> 0 then 
914  826 
begin 
827 
DeleteCI(Gear); 

828 
doStepFallingGear(Gear); 

829 
if (Gear^.State and gstMoving) = 0 then 

830 
begin 

831 
AddGearCI(Gear); 

832 
Gear^.dX:= _0; 

833 
Gear^.dY:= _0 

834 
end; 

835 
CalcRotationDirAngle(Gear); 

836 
AllInactive:= false 

837 
end else 

838 
if ((GameTicks and $3F) = 25) then 

839 
doStepFallingGear(Gear); 

351  840 

841 
if ((Gear^.State and gsttmpFlag) <> 0) then 

1133  842 
if ((Gear^.State and gstAttacking) = 0) then 
843 
begin 

844 
if ((GameTicks and $1F) = 0) then 

845 
if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking 

846 
end else // gstAttacking <> 0 

847 
begin 

848 
AllInactive:= false; 

849 
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false); 

850 
if Gear^.Timer = 0 then 

851 
begin 

852 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 

853 
DeleteGear(Gear); 

854 
exit 

855 
end; 

856 
dec(Gear^.Timer); 

857 
end else // gsttmpFlag = 0 

858 
if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; 

10  859 
end; 
57  860 

39  861 
//////////////////////////////////////////////////////////////////////////////// 
862 
procedure doStepDynamite(Gear: PGear); 

863 
begin 

43  864 
doStepFallingGear(Gear); 
865 
AllInactive:= false; 

351  866 
if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); 
867 
if Gear^.Timer = 0 then 

1133  868 
begin 
869 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); 

870 
DeleteGear(Gear); 

871 
exit 

872 
end; 

351  873 
dec(Gear^.Timer); 
39  874 
end; 
14
81f125629b25
 Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset

875 

351  876 
/////////////////////////////////////////////////////////////////////////////// 
14
81f125629b25
 Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset

877 
procedure doStepCase(Gear: PGear); 
371  878 
var i, x, y: LongInt; 
14
81f125629b25
 Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset

879 
begin 
351  880 
if (Gear^.Message and gm_Destroy) > 0 then 
1133  881 
begin 
882 
DeleteGear(Gear); 

883 
FreeActionsList; 

884 
SetAllToActive; // something (hh, mine, etc...) could be on top of the case 

885 
with CurrentHedgehog^ do 

886 
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); 

887 
exit 

888 
end; 

15  889 

351  890 
if Gear^.Damage > 0 then 
1133  891 
begin 
892 
x:= hwRound(Gear^.X); 

893 
y:= hwRound(Gear^.Y); 

894 
DeleteGear(Gear); 

895 
if Gear^.Kind = gtCase then 

896 
begin 

897 
doMakeExplosion(x, y, 25, EXPLAutoSound); 

898 
for i:= 0 to 63 do 

899 
AddGear(x, y, gtFlame, 0, _0, _0, 0); 

900 
end; 

901 
exit 

902 
end; 

79  903 

351  904 
if (Gear^.dY.QWordValue <> 0) or (not TestCollisionYwithGear(Gear, 1)) then 
1133  905 
begin 
906 
AllInactive:= false; 

907 
Gear^.dY:= Gear^.dY + cGravity; 

908 
Gear^.Y:= Gear^.Y + Gear^.dY; 

909 
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then Gear^.dY:= _0 else 

910 
if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then 

911 
begin 

912 
Gear^.dY:=  Gear^.dY * Gear^.Elasticity; 

913 
if Gear^.dY >  _0_001 then Gear^.dY:= _0 

914 
else if Gear^.dY <  _0_03 then PlaySound(sndGraveImpact, false); 

915 
end; 

916 
CheckGearDrowning(Gear); 

917 
end; 

14
81f125629b25
 Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset

918 

511  919 
if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) 
1133  920 
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

921 
end; 
49  922 

923 
//////////////////////////////////////////////////////////////////////////////// 

557  924 
const cSorterWorkTime = 640; 
925 
var thexchar: array[0..cMaxTeams] of 

1133  926 
record 
927 
dy, ny, dw: LongInt; 

928 
team: PTeam; 

929 
SortFactor: QWord; 

930 
end; 

601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset

931 
currsorter: PGear = nil; 
49  932 

933 
procedure doStepTeamHealthSorterWork(Gear: PGear); 

371  934 
var i: LongInt; 
49  935 
begin 
936 
AllInactive:= false; 

351  937 
dec(Gear^.Timer); 
938 
if (Gear^.Timer and 15) = 0 then 

1133  939 
for i:= 0 to Pred(TeamsCount) do 
940 
with thexchar[i] do 

941 
begin 

942 
{$WARNINGS OFF} 

943 
team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; 

944 
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; 

945 
{$WARNINGS ON} 

946 
end; 

947 

351  948 
if (Gear^.Timer = 0) or (currsorter <> Gear) then 
1133  949 
begin 
950 
if currsorter = Gear then currsorter:= nil; 

951 
DeleteGear(Gear) 

952 
end 

49  953 
end; 
954 

955 
procedure doStepTeamHealthSorter(Gear: PGear); 

1133  956 
var i: Longword; 
957 
b: boolean; 

958 
t: LongInt; 

49  959 
begin 
960 
AllInactive:= false; 

557  961 

547  962 
for t:= 0 to Pred(TeamsCount) do 
1133  963 
with thexchar[t] do 
964 
begin 

965 
dy:= TeamsArray[t]^.DrawHealthY; 

966 
dw:= TeamsArray[t]^.TeamHealthBarWidth  TeamsArray[t]^.NewTeamHealthBarWidth; 

967 
team:= TeamsArray[t]; 

968 
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; 

969 
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; 

970 
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; 

971 
end; 

547  972 

601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset

973 
if TeamsCount > 1 then 
1133  974 
repeat 
975 
b:= true; 

976 
for t:= 0 to TeamsCount  2 do 

977 
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then 

978 
begin 

979 
thexchar[cMaxTeams]:= thexchar[t]; 

980 
thexchar[t]:= thexchar[Succ(t)]; 

981 
thexchar[Succ(t)]:= thexchar[cMaxTeams]; 

982 
b:= false 

983 
end 

984 
until b; 

557  985 

1120  986 
t:=  4; 
557  987 
for i:= 0 to Pred(TeamsCount) do 
1133  988 
with thexchar[i] do 
989 
begin 

990 
dec(t, team^.HealthTex^.h + 2); 

991 
ny:= t; 

992 
dy:= dy  ny 

993 
end; 

764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset

994 

557  995 
Gear^.Timer:= cSorterWorkTime; 
351  996 
Gear^.doStep:= @doStepTeamHealthSorterWork; 
143  997 
currsorter:= Gear 
49  998 
end; 
999 

79  1000 
//////////////////////////////////////////////////////////////////////////////// 
854  1001 
procedure doStepIdle(Gear: PGear); 
1002 
begin 

1003 
AllInactive:= false; 

925  1004 
dec(Gear^.Timer); 
854  1005 
if Gear^.Timer = 0 then 
1006 
begin 

1007 
DeleteGear(Gear); 

1008 
AfterAttack 

1009 
end 

1010 
end; 

1011 

79  1012 
procedure doStepShover(Gear: PGear); 
1013 
var HHGear: PGear; 

1014 
begin 

351  1015 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
1016 
HHGear^.State:= HHGear^.State or gstNoDamage; 

980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset

1017 
DeleteCI(HHGear); 
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset

1018 

79  1019 
AmmoShove(Gear, 30, 115); 
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset

1020 

351  1021 
HHGear^.State:= HHGear^.State and not gstNoDamage; 
854  1022 
Gear^.Timer:= 250; 
1023 
Gear^.doStep:= @doStepIdle 

79  1024 
end; 
1025 

1026 
//////////////////////////////////////////////////////////////////////////////// 

925  1027 
procedure doStepWhip(Gear: PGear); 
1028 
var HHGear: PGear; 

1029 
i: LongInt; 

1030 
begin 

1031 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 

1032 
HHGear^.State:= HHGear^.State or gstNoDamage; 

980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset

1033 
DeleteCI(HHGear); 
925  1034 

1035 
for i:= 0 to 3 do 

1036 
begin 

1037 
AmmoShove(Gear, 30, 25); 

1038 
Gear^.X:= Gear^.X + Gear^.dX * 5 

1039 
end; 

1040 

1041 
HHGear^.State:= HHGear^.State and not gstNoDamage; 

1042 
Gear^.Timer:= 250; 

1043 
Gear^.doStep:= @doStepIdle 

1044 
end; 

1045 

1046 
//////////////////////////////////////////////////////////////////////////////// 

79  1047 
procedure doStepFlame(Gear: PGear); 
1048 
begin 

1049 
AllInactive:= false; 

1050 
if not TestCollisionYwithGear(Gear, 1) then 

1133  1051 
begin 
1052 
Gear^.dX:= Gear^.dX + cWindSpeed; 

1053 
Gear^.dY:= Gear^.dY + cGravity; 

1054 
if hwAbs(Gear^.dX) > _0_1 then Gear^.dX:= Gear^.dX * _0_5; 

1055 
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; 

1056 
Gear^.X:= Gear^.X + Gear^.dX; 

1057 
Gear^.Y:= Gear^.Y + Gear^.dY; 

1058 
if not (Gear^.Y < _1024) then 

1059 
begin 

1060 
DeleteGear(Gear); 

1061 
exit 

1062 
end 

1063 
end else begin 

1064 
if Gear^.Timer > 0 then dec(Gear^.Timer) 

1065 
else begin 

1066 
// doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 2, 0); 

1067 
dec(Gear^.Health); 

1068 
Gear^.Timer:= 1250  Gear^.Angle * 12 

1069 
end 

1070 
end; 

79  1071 

351  1072 
if (((GameTicks div 8) mod 64) = Gear^.Angle) then 
1133  1073 
AmmoFlameWork(Gear); 
79  1074 

351  1075 
if Gear^.Health = 0 then 
1133  1076 
DeleteGear(Gear) 
79  1077 
end; 
82  1078 

1079 
//////////////////////////////////////////////////////////////////////////////// 

1080 
procedure doStepFirePunchWork(Gear: PGear); 

1081 
var HHGear: PGear; 

1082 
begin 

1083 
AllInactive:= false; 

351  1084 
if ((Gear^.Message and gm_Destroy) <> 0) then 
1133  1085 
begin 
1086 
DeleteGear(Gear); 

1087 
AfterAttack; 

1088 
exit 

1089 
end; 

82  1090 

351  1091 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
1092 
if hwRound(HHGear^.Y) <= Gear^.Tag  2 then 

1133  1093 
begin 
1094 
Gear^.Tag:= hwRound(HHGear^.Y); 

1095 
DrawTunnel(HHGear^.X  int2hwFloat(cHHRadius), HHGear^.Y  _1, _0_5, _0, cHHRadius * 4, 2); 

1096 
HHGear^.State:= HHGear^.State or gstNoDamage; 

1097 
Gear^.Y:= HHGear^.Y; 

1098 
AmmoShove(Gear, 30, 40); 

1099 
HHGear^.State:= HHGear^.State and not gstNoDamage 

1100 
end; 

351  1101 

1102 
HHGear^.dY:= HHGear^.dY + cGravity; 

1103 
if not (HHGear^.dY.isNegative) then 

1133  1104 
begin 
1105 
HHGear^.State:= HHGear^.State or gstMoving; 

1106 
DeleteGear(Gear); 

1107 
AfterAttack; 

1108 
exit 

1109 
end; 

351  1110 
HHGear^.Y:= HHGear^.Y + HHGear^.dY 
82  1111 
end; 
1112 

1113 
procedure doStepFirePunch(Gear: PGear); 

1114 
var HHGear: PGear; 

1115 
begin 

1116 
AllInactive:= false; 

351  1117 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
514  1118 
DeleteCI(HHGear); 
498  1119 
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X))  _0_5; 
1014
3c7d4e7ccdff
 Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset

1120 
HHGear^.dX:= SignAs(cLittle, Gear^.dX); 
3c7d4e7ccdff
 Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset

1121 

351  1122 
HHGear^.dY:=  _0_3; 
82  1123 

351  1124 
Gear^.X:= HHGear^.X; 
979
edb8f208c1d9
Fix firepunch direction when attacking from high jump
unc0rr
parents:
974
diff
changeset

1125 
Gear^.dX:= SignAs(_0_45, Gear^.dX); 
351  1126 
Gear^.dY:=  _0_9; 
1127 
Gear^.doStep:= @doStepFirePunchWork; 

498  1128 
DrawTunnel(HHGear^.X  int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); 
82  1129 
end; 
1130 

263  1131 
//////////////////////////////////////////////////////////////////////////////// 
1132 

929
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1133 
procedure doStepParachuteWork(Gear: PGear); 
211  1134 
var HHGear: PGear; 
1135 
begin 

351  1136 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
82  1137 

516  1138 
inc(Gear^.Timer); 
1139 

212  1140 
if TestCollisionYwithGear(HHGear, 1) 
1133  1141 
or ((HHGear^.State and gstHHDriven) = 0) 
1142 
or CheckGearDrowning(HHGear) 

1143 
or ((Gear^.Message and gm_Attack) <> 0) then 

1144 
begin 

1145 
with HHGear^ do 

1146 
begin 

1147 
Message:= 0; 

1148 
SetLittle(dX); 

1149 
dY:= _0; 

1150 
State:= State or gstMoving; 

1151 
end; 

1152 
DeleteGear(Gear); 

1153 
exit 

1154 
end; 

211  1155 

351  1156 
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then 
1133  1157 
HHGear^.X:= HHGear^.X + cWindSpeed * 200; 
211  1158 

351  1159 
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X  cMaxWindSpeed * 40 
1160 
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; 

1161 
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y  cGravity * 40 

1162 
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; 

211  1163 

351  1164 
HHGear^.Y:= HHGear^.Y + cGravity * 100; 
568  1165 
Gear^.X:= HHGear^.X; 
1166 
Gear^.Y:= HHGear^.Y 

263  1167 
end; 
211  1168 

929
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1169 
procedure doStepParachute(Gear: PGear); 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1170 
var HHGear: PGear; 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1171 
begin 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1172 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1173 

9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1174 
DeleteCI(HHGear); 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1175 

9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1176 
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1177 
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1178 

931  1179 
HHGear^.State:= HHGear^.State and not (gstAttacking or gstAttacked or gstMoving); 
929
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1180 
HHGear^.Message:= HHGear^.Message and not gm_Attack; 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1181 

9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1182 
Gear^.doStep:= @doStepParachuteWork; 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1183 

9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1184 
Gear^.Message:= HHGear^.Message; 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1185 
doStepParachuteWork(Gear) 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1186 
end; 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

1187 

263  1188 
//////////////////////////////////////////////////////////////////////////////// 
1189 
procedure doStepAirAttackWork(Gear: PGear); 

1190 
begin 

1191 
AllInactive:= false; 

498  1192 
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; 
1124  1193 

543
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

1194 
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then 
1124  1195 
begin 
1196 
dec(Gear^.Health); 

1197 
case Gear^.State of 

1198 
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); 

1199 
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); 

1200 
end; 

1201 
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) 

1202 
end; 

1203 

1204 
if (GameTicks and $3F) = 0 then 

1205 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); 

1206 

498  1207 
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < 1024) then DeleteGear(Gear) 
263  1208 
end; 
1209 

1210 
procedure doStepAirAttack(Gear: PGear); 

1211 
begin 

1212 
AllInactive:= false; 

543
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

1213 

408  1214 
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 
1215 
else Gear^.Tag:= 1; 

498  1216 
Gear^.X:= _1024  _2048 * Gear^.Tag; 
1124  1217 
Gear^.Y:= _300; 
543
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

1218 
Gear^.dX:= int2hwFloat(TargetPoint.X  5 * Gear^.Tag * 15); 
357  1219 

543
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

1220 
if int2hwFloat(TargetPoint.Y)  Gear^.Y > _0 then 
1133  1221 
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

1222 

351  1223 
Gear^.Health:= 6; 
801  1224 
Gear^.doStep:= @doStepAirAttackWork; 
1225 
PlaySound(sndIncoming, false) 

263  1226 
end; 
1227 

1228 
//////////////////////////////////////////////////////////////////////////////// 

1229 

1230 
procedure doStepAirBomb(Gear: PGear); 

1231 
begin 

1232 
AllInactive:= false; 

1233 
doStepFallingGear(Gear); 

351  1234 
if (Gear^.State and gstCollision) <> 0 then 
1133  1235 
begin 
1236 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); 

1237 
DeleteGear(Gear); 

1238 
exit 

1239 
end; 

263  1240 
if (GameTicks and $3F) = 0 then 
1133  1241 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) 
211  1242 
end; 
409  1243 

1244 
//////////////////////////////////////////////////////////////////////////////// 

1245 

1246 
procedure doStepGirder(Gear: PGear); 

415  1247 
var HHGear: PGear; 
409  1248 
begin 
1249 
AllInactive:= false; 

415  1250 

1251 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 

409  1252 
if not TryPlaceOnLand(TargetPoint.X  SpritesData[sprAmGirder].Width div 2, 
1253 
TargetPoint.Y  SpritesData[sprAmGirder].Height div 2, 

520  1254 
sprAmGirder, Gear^.State, true) then 
1133  1255 
begin 
1256 
HHGear^.Message:= HHGear^.Message and not gm_Attack; 

1257 
HHGear^.State:= HHGear^.State and not gstAttacking; 

1258 
HHGear^.State:= HHGear^.State or gstHHChooseTarget; 

1259 
DeleteGear(Gear); 

1260 
isCursorVisible:= true 

1261 
end 

1262 
else begin 

1263 
DeleteGear(Gear); 

1264 
AfterAttack 

1265 
end; 

415  1266 
TargetPoint.X:= NoPointX 
409  1267 
end; 
520  1268 

1269 
//////////////////////////////////////////////////////////////////////////////// 

525  1270 
procedure doStepTeleportAfter(Gear: PGear); 
912  1271 
var HHGear: PGear; 
1272 
begin 

1273 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 

1274 
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases 

1275 
HHGear^.dY:= HHGear^.dY + cGravity; 

945
4ead9cde4e14
 Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset

1276 
if TestCollisionYwithGear(HHGear, 1) 
1133  1277 
or CheckGearDrowning(HHGear) then 
1278 
begin 

1279 
DeleteGear(Gear); 

1280 
AfterAttack 

1281 
end 

912  1282 
end; 
1283 

1284 
procedure doStepTeleportAnim(Gear: PGear); 

525  1285 
begin 
853  1286 
inc(Gear^.Timer); 
1287 
if Gear^.Timer = 65 then 

1288 
begin 

1289 
Gear^.Timer:= 0; 

1290 
inc(Gear^.Pos); 

1291 
if Gear^.Pos = 11 then 

912  1292 
Gear^.doStep:= @doStepTeleportAfter 
853  1293 
end 
525  1294 
end; 
520  1295 

1296 
procedure doStepTeleport(Gear: PGear); 

1297 
var HHGear: PGear; 

1298 
begin 

1299 
AllInactive:= false; 

1300 

1301 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 

1302 
if not TryPlaceOnLand(TargetPoint.X  SpritesData[sprHHTelepMask].Width div 2, 

1303 
TargetPoint.Y  SpritesData[sprHHTelepMask].Height div 2, 

1304 
sprHHTelepMask, 0, false) then 

853  1305 
begin 
1306 
HHGear^.Message:= HHGear^.Message and not gm_Attack; 

1307 
HHGear^.State:= HHGear^.State and not gstAttacking; 

1308 
HHGear^.State:= HHGear^.State or gstHHChooseTarget; 

1309 
DeleteGear(Gear); 

1310 
isCursorVisible:= true 

1311 
end 

1312 
else begin 

1313 
DeleteCI(HHGear); 

1314 
SetAllHHToActive; 

912  1315 
Gear^.doStep:= @doStepTeleportAnim; 
853  1316 
Gear^.X:= HHGear^.X; 
1317 
Gear^.Y:= HHGear^.Y; 

1318 
HHGear^.X:= int2hwFloat(TargetPoint.X); 

1319 
HHGear^.Y:= int2hwFloat(TargetPoint.Y); 

1320 
HHGear^.State:= HHGear^.State or gstMoving 

1321 
end; 

520  1322 
TargetPoint.X:= NoPointX 
1323 
end; 

534  1324 

1325 
//////////////////////////////////////////////////////////////////////////////// 

1326 
procedure doStepSwitcherWork(Gear: PGear); 

1327 
var HHGear: PGear; 

1328 
Msg, State: Longword; 

1329 
begin 

1330 
AllInactive:= false; 

1331 

540  1332 
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then 
1133  1333 
begin 
1334 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 

1335 
Msg:= Gear^.Message and not gm_Switch; 

1336 
DeleteGear(Gear); 

1337 
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); 

1338 
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); 

534  1339 

1133  1340 
HHGear:= CurrentHedgehog^.Gear; 
1341 
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); 

1342 
HHGear^.Message:= Msg; 

1343 
exit 

1344 
end; 

534  1345 

1346 
if (Gear^.Message and gm_Switch) <> 0 then 

1133  1347 
begin 
1348 
HHGear:= CurrentHedgehog^.Gear; 

1349 
HHGear^.Message:= HHGear^.Message and not gm_Switch; 

1350 
Gear^.Message:= Gear^.Message and not gm_Switch; 

1351 
State:= HHGear^.State; 

1352 
HHGear^.State:= 0; 

1353 
HHGear^.Active:= false; 

1354 
HHGear^.Z:= cHHZ; 

1355 
RemoveGearFromList(HHGear); 

1356 
InsertGearToList(HHGear); 

534  1357 

1133  1358 
repeat 
1359 
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); 

1360 
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); 

652  1361 

1133  1362 
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; 
534  1363 

1133  1364 
HHGear:= CurrentHedgehog^.Gear; 
1365 
HHGear^.State:= State; 

1366 
HHGear^.Active:= true; 

1367 
FollowGear:= HHGear; 

1368 
HHGear^.Z:= cCurrHHZ; 

1369 
RemoveGearFromList(HHGear); 

1370 
InsertGearToList(HHGear); 

1371 
Gear^.X:= HHGear^.X; 

1372 
Gear^.Y:= HHGear^.Y 