author  unc0rr 
Mon, 28 Jul 2008 13:53:50 +0000  
changeset 1133  5d5a912d6fc2 
parent 1132  b4c0698fbb6b 
child 1142  2c522c1ded31 
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); 
351  148 
if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then PlaySound(sndGrenadeImpact, false) 
4  149 
end; 
150 

78  151 
procedure doStepCluster(Gear: PGear); 
152 
begin 

153 
AllInactive:= false; 

154 
doStepFallingGear(Gear); 

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

158 
DeleteGear(Gear); 

159 
exit 

160 
end; 

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

4  165 
//////////////////////////////////////////////////////////////////////////////// 
166 
procedure doStepGrenade(Gear: PGear); 

167 
begin 

168 
AllInactive:= false; 

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

174 
DeleteGear(Gear); 

175 
exit 

176 
end; 

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

181 
//////////////////////////////////////////////////////////////////////////////// 

95  182 
procedure doStepHealthTagWork(Gear: PGear); 
4  183 
begin 
522  184 
if Gear^.Kind = gtHealthTag then 
185 
AllInactive:= false; 

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

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

192 
DeleteGear(Gear) 

193 
end 

4  194 
end; 
195 

263  196 
procedure doStepHealthTagWorkUnderWater(Gear: PGear); 
197 
begin 

198 
AllInactive:= false; 

351  199 
Gear^.Y:= Gear^.Y  _0_08; 
498  200 
if hwRound(Gear^.Y) < cWaterLine + 10 then 
263  201 
DeleteGear(Gear) 
202 
end; 

203 

95  204 
procedure doStepHealthTag(Gear: PGear); 
205 
var s: shortstring; 

522  206 
font: THWFont; 
95  207 
begin 
522  208 
if Gear^.Kind = gtHealthTag then 
209 
begin 

813  210 
AllInactive:= false; 
522  211 
font:= fnt16; 
212 
Gear^.dY:= _0_08 

213 
end else 

214 
begin 

215 
font:= fntSmall; 

216 
Gear^.dY:= _0_02 

217 
end; 

218 

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

4  226 
//////////////////////////////////////////////////////////////////////////////// 
227 
procedure doStepGrave(Gear: PGear); 

228 
begin 

229 
AllInactive:= false; 

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

4  232 

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

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

248 
//////////////////////////////////////////////////////////////////////////////// 

249 
procedure doStepUFOWork(Gear: PGear); 

351  250 
var t: hwFloat; 
374  251 
y: LongInt; 
4  252 
begin 
253 
AllInactive:= false; 

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

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

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

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

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

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

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

374  262 

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

264 
begin 

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

266 
if y + Gear^.Radius < cWaterLine then 

498  267 
AddGear(hwRound(Gear^.X), y, gtSmokeTrace, 0, _0, _0, 0); 
374  268 
end; 
269 

4  270 
CheckCollision(Gear); 
351  271 
dec(Gear^.Timer); 
272 
if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then 

4  273 
begin 
560  274 
StopSound(sndUFO); 
351  275 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 
4  276 
DeleteGear(Gear); 
277 
end; 

278 
end; 

279 

280 
procedure doStepUFO(Gear: PGear); 

281 
begin 

282 
AllInactive:= false; 

351  283 
Gear^.X:= Gear^.X + Gear^.dX; 
284 
Gear^.Y:= Gear^.Y + Gear^.dY; 

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

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

292 
end; 

351  293 
dec(Gear^.Timer); 
294 
if Gear^.Timer = 0 then 

4  295 
begin 
560  296 
PlaySound(sndUFO, true); 
351  297 
Gear^.Timer:= 5000; 
298 
Gear^.doStep:= @doStepUFOWork 

4  299 
end; 
300 
end; 

301 

302 
//////////////////////////////////////////////////////////////////////////////// 

876  303 
procedure doStepShotIdle(Gear: PGear); 
304 
begin 

305 
AllInactive:= false; 

306 
inc(Gear^.Timer); 

307 
if Gear^.Timer > 75 then 

308 
begin 

309 
DeleteGear(Gear); 

310 
AfterAttack 

311 
end 

312 
end; 

313 

4  314 
procedure doStepShotgunShot(Gear: PGear); 
315 
var i: LongWord; 

316 
begin 

317 
AllInactive:= false; 

876  318 

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

320 
begin 

321 
dec(Gear^.Timer); 

322 
if Gear^.Timer = 0 then 

323 
begin 

324 
PlaySound(sndShotgunFire, false); 

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

326 
end; 

327 
exit 

328 
end 

329 
else inc(Gear^.Timer); 

330 

4  331 
i:= 200; 
332 
repeat 

351  333 
Gear^.X:= Gear^.X + Gear^.dX; 
334 
Gear^.Y:= Gear^.Y + Gear^.dY; 

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

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

340 
ShotgunShot(Gear); 

341 
Gear^.doStep:= @doStepShotIdle; 

342 
exit 

343 
end; 

4  344 
dec(i) 
345 
until i = 0; 

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

350 
//////////////////////////////////////////////////////////////////////////////// 

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

876  356 
inc(Gear^.Timer); 
37  357 
i:= 80; 
351  358 
oX:= Gear^.X; 
359 
oY:= Gear^.Y; 

37  360 
repeat 
351  361 
Gear^.X:= Gear^.X + Gear^.dX; 
362 
Gear^.Y:= Gear^.Y + Gear^.dY; 

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

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

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

37  371 
begin 
351  372 
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82  i, 1); 
373 
dec(Gear^.Health, Gear^.Damage); 

374 
Gear^.Damage:= 0 

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

559  380 
procedure doStepDEagleShot(Gear: PGear); 
381 
begin 

382 
PlaySound(sndGun, false); 

383 
Gear^.doStep:= @doStepDEagleShotWork 

384 
end; 

385 

37  386 
//////////////////////////////////////////////////////////////////////////////// 
4  387 
procedure doStepActionTimer(Gear: PGear); 
388 
begin 

351  389 
dec(Gear^.Timer); 
390 
case Gear^.Kind of 

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

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

83  402 
end 
403 
end; 

404 
gtATFinishGame: begin 

405 
AllInactive:= false; 

351  406 
if Gear^.Timer = 0 then 
113  407 
begin 
408 
SendIPC('N'); 

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

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

417 
//////////////////////////////////////////////////////////////////////////////// 

418 
procedure doStepPickHammerWork(Gear: PGear); 

371  419 
var i, ei: LongInt; 
4  420 
HHGear: PGear; 
421 
begin 

70  422 
AllInactive:= false; 
351  423 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
424 
dec(Gear^.Timer); 

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

4  426 
begin 
282  427 
StopSound(sndPickhammer); 
4  428 
DeleteGear(Gear); 
429 
AfterAttack; 

430 
exit 

431 
end; 

845  432 

422  433 
if (Gear^.Timer mod 33) = 0 then 
434 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y) + 6, 6, EXPLDontDraw); 

435 

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

4  437 
begin 
371  438 
i:= hwRound(Gear^.X)  Gear^.Radius  LongInt(GetRandom(2)); 
439 
ei:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); 

4  440 
while i <= ei do 
441 
begin 

422  442 
DrawExplosion(i, hwRound(Gear^.Y) + 3, 3); 
4  443 
inc(i, 1) 
444 
end; 

351  445 
Gear^.X:= Gear^.X + Gear^.dX; 
446 
Gear^.Y:= Gear^.Y + _1_9; 

42  447 
SetAllHHToActive; 
4  448 
end; 
449 
if TestCollisionYwithGear(Gear, 1) then 

450 
begin 

498  451 
Gear^.dY:= _0; 
351  452 
SetLittle(HHGear^.dX); 
498  453 
HHGear^.dY:= _0; 
4  454 
end else 
455 
begin 

351  456 
Gear^.dY:= Gear^.dY + cGravity; 
457 
Gear^.Y:= Gear^.Y + Gear^.dY; 

498  458 
if Gear^.Y > _1024 then Gear^.Timer:= 1 
4  459 
end; 
460 

351  461 
Gear^.X:= Gear^.X + HHGear^.dX; 
462 
HHGear^.X:= Gear^.X; 

498  463 
HHGear^.Y:= Gear^.Y  int2hwFloat(cHHRadius); 
4  464 

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

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

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

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

498  470 
else Gear^.dX:= _0; 
4  471 
end; 
472 

473 
procedure doStepPickHammer(Gear: PGear); 

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

476 
HHGear: PGear; 
4  477 
begin 
478 
i:= 0; 

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

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

480 

498  481 
y:= hwRound(Gear^.Y)  cHHRadius * 2; 
351  482 
while y < hwRound(Gear^.Y) do 
4  483 
begin 
371  484 
ar[i].Left := hwRound(Gear^.X)  Gear^.Radius  LongInt(GetRandom(2)); 
485 
ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); 

4  486 
inc(y, 2); 
487 
inc(i) 

488 
end; 

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

489 

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

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

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

493 

282  494 
PlaySound(sndPickhammer, true); 
4  495 
doStepPickHammerWork(Gear); 
351  496 
Gear^.doStep:= @doStepPickHammerWork 
4  497 
end; 
498 

499 
//////////////////////////////////////////////////////////////////////////////// 

371  500 
var BTPrevAngle, BTSteps: LongInt; 
302  501 

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

502 
procedure doStepBlowTorchWork(Gear: PGear); 
302  503 
var HHGear: PGear; 
305  504 
b: boolean; 
302  505 
begin 
506 
AllInactive:= false; 

351  507 
dec(Gear^.Timer); 
508 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 

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

509 

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

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

511 

305  512 
b:= false; 
513 

371  514 
if abs(LongInt(HHGear^.Angle)  BTPrevAngle) > 7 then 
305  515 
begin 
498  516 
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX); 
355  517 
Gear^.dY:= AngleCos(HHGear^.Angle) * (  _0_5); 
351  518 
BTPrevAngle:= HHGear^.Angle; 
358  519 
b:= true 
305  520 
end; 
521 

351  522 
if Gear^.Timer mod cHHStepTicks = 0 then 
302  523 
begin 
305  524 
b:= true; 
498  525 
if Gear^.dX.isNegative then HHGear^.Message:= (HHGear^.Message or gm_Left) and not gm_Right 
526 
else HHGear^.Message:= (HHGear^.Message or gm_Right) and not gm_Left; 

357  527 

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

302  529 
HedgehogStep(HHGear); 
357  530 
HHGear^.State:= HHGear^.State or gstAttacking; 
305  531 

532 
inc(BTSteps); 

511  533 
if BTSteps = 7 then 
305  534 
begin 
535 
BTSteps:= 0; 

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

351  538 
HHGear^.State:= HHGear^.State or gstNoDamage; 
511  539 
AmmoShove(Gear, 2, 14); 
351  540 
HHGear^.State:= HHGear^.State and not gstNoDamage 
305  541 
end; 
542 

542  543 
if (HHGear^.State and gstMoving) <> 0 then Gear^.Timer:= 0 
302  544 
end; 
305  545 

546 
if b then 

498  547 
DrawTunnel(HHGear^.X  Gear^.dX * cHHRadius, HHGear^.Y  _4  Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, 
351  548 
Gear^.dX, Gear^.dY, 
306  549 
cHHRadius * 5, cHHRadius * 2 + 6); 
305  550 

351  551 
if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) then 
302  552 
begin 
351  553 
HHGear^.Message:= 0; 
302  554 
DeleteGear(Gear); 
555 
AfterAttack 

556 
end 

557 
end; 

558 

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

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

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

561 
begin 
371  562 
BTPrevAngle:= High(LongInt); 
305  563 
BTSteps:= 0; 
351  564 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
565 
HHGear^.Message:= 0; 

566 
Gear^.doStep:= @doStepBlowTorchWork 

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

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

568 

302  569 
//////////////////////////////////////////////////////////////////////////////// 
570 

4  571 
procedure doStepRopeWork(Gear: PGear); 
70  572 
const flCheck: boolean = false; 
4  573 
var HHGear: PGear; 
789  574 
len, cs, cc, tx, ty, nx, ny: hwFloat; 
108  575 
lx, ly: LongInt; 
4  576 

577 
procedure DeleteMe; 

578 
begin 

579 
with HHGear^ do 

580 
begin 

581 
Message:= Message and not gm_Attack; 

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

584 
DeleteGear(Gear) 
4  585 
end; 
586 

587 
begin 

351  588 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
108  589 

351  590 
if ((HHGear^.State and gstHHDriven) = 0) 
80  591 
or (CheckGearDrowning(HHGear)) then 
4  592 
begin 
593 
DeleteMe; 

594 
exit 

595 
end; 

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

596 

351  597 
Gear^.dX:= HHGear^.X  Gear^.X; 
598 
Gear^.dY:= HHGear^.Y  Gear^.Y; 

4  599 

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

4  602 

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

351  605 
cs:= Gear^.dY + HHGear^.dY; 
606 
cc:= Gear^.dX + HHGear^.dX; 

498  607 
len:= _1 / Distance(cc, cs); 
789  608 
cc:= cc * len; // rope vector plus hedgehog direction vector normalized 
108  609 
cs:= cs * len; 
4  610 

940  611 
nx:= hwAbs(cs) * hwSign(HHGear^.dX) * 5; // hedgehog direction normalized with length 3 
612 
ny:= hwAbs(cc) * hwSign(HHGear^.dY) * 5; 

789  613 

4  614 
flCheck:= not flCheck; 
615 
if flCheck then // check whether rope needs dividing 

616 
begin 

498  617 
len:= Gear^.Elasticity  _20; 
618 
while len > _5 do 

4  619 
begin 
620 
tx:= cc*len; 

621 
ty:= cs*len; 

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

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

627 
begin 

351  628 
X:= Gear^.X; 
629 
Y:= Gear^.Y; 

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

630 
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); 
351  631 
b:= (cc * HHGear^.dY) > (cs * HHGear^.dX); 
4  632 
dLen:= len 
633 
end; 

351  634 
Gear^.X:= Gear^.X + tx; 
635 
Gear^.Y:= Gear^.Y + ty; 

4  636 
inc(RopePoints.Count); 
789  637 
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); 
351  638 
Gear^.Elasticity:= Gear^.Elasticity  len; 
639 
Gear^.Friction:= Gear^.Friction  len; 

4  640 
break 
641 
end; 

789  642 
len:= len  _2 
4  643 
end; 
644 
end else 

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

646 
begin 

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

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

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

351  652 
Gear^.X:=RopePoints.ar[RopePoints.Count].X; 
653 
Gear^.Y:=RopePoints.ar[RopePoints.Count].Y; 

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

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

4  656 
end 
657 
end; 

658 

351  659 
Gear^.dX:= HHGear^.X  Gear^.X; 
660 
Gear^.dY:= HHGear^.Y  Gear^.Y; 

108  661 

351  662 
cs:= Gear^.dY + HHGear^.dY; 
663 
cc:= Gear^.dX + HHGear^.dX; 

498  664 
len:= _1 / Distance(cc, cs); 
108  665 
cc:= cc * len; 
666 
cs:= cs * len; 

4  667 

351  668 
HHGear^.dX:= HHGear^.X; 
669 
HHGear^.dY:= HHGear^.Y; 

4  670 

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

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

4  674 

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

4  678 

351  679 
HHGear^.X:= Gear^.X + cc*Gear^.Elasticity; 
680 
HHGear^.Y:= Gear^.Y + cs*Gear^.Elasticity; 

4  681 

351  682 
HHGear^.dX:= HHGear^.X  HHGear^.dX; 
683 
HHGear^.dY:= HHGear^.Y  HHGear^.dY; 

4  684 

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

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

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

4  689 

789  690 
len:= Distance(HHGear^.dX, HHGear^.dY); 
940  691 
if len > _0_8 then 
789  692 
begin 
940  693 
len:= _0_8 / len; 
789  694 
HHGear^.dX:= HHGear^.dX * len; 
695 
HHGear^.dY:= HHGear^.dY * len; 

696 
end; 

697 

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

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

4  701 
end; 
702 

703 

704 
procedure doStepRopeAttach(Gear: PGear); 

705 
var HHGear: PGear; 

351  706 
tx, ty, tt: hwFloat; 
4  707 
begin 
351  708 
Gear^.X:= Gear^.X  Gear^.dX; 
709 
Gear^.Y:= Gear^.Y  Gear^.dY; 

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

716 
CheckHHDamage(HHGear); 
498  717 
HHGear^.dY:= _0; 
542  718 
HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); 
4  719 
end else 
720 
begin 

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

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

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

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

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

727 
tt:= Gear^.Elasticity; 

498  728 
tx:= _0; 
729 
ty:= _0; 

730 
while tt > _20 do 

4  731 
begin 
517  732 
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), hwSign(Gear^.dX)) 
733 
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), hwSign(Gear^.dY)) then 

4  734 
begin 
351  735 
Gear^.X:= Gear^.X + tx; 
736 
Gear^.Y:= Gear^.Y + ty; 

737 
Gear^.Elasticity:= tt; 

738 
Gear^.doStep:= @doStepRopeWork; 

4  739 
with HHGear^ do State:= State and not gstAttacking; 
498  740 
tt:= _0 
4  741 
end; 
517  742 
tx:= tx + Gear^.dX + Gear^.dX; 
743 
ty:= ty + Gear^.dY + Gear^.dY; 

498  744 
tt:= tt  _2; 
4  745 
end; 
746 
end; 

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

747 

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

749 

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

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

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

753 
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

754 

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

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

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

757 

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

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

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

760 
end; 
4  761 

351  762 
if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then 
4  763 
begin 
351  764 
with PHedgehog(Gear^.Hedgehog)^.Gear^ do 
4  765 
begin 
766 
State:= State and not gstAttacking; 

767 
Message:= Message and not gm_Attack 

768 
end; 

769 
DeleteGear(Gear) 

770 
end 

771 
end; 

772 

773 
procedure doStepRope(Gear: PGear); 

774 
begin 

351  775 
Gear^.dX:=  Gear^.dX; 
776 
Gear^.dY:=  Gear^.dY; 

777 
Gear^.doStep:= @doStepRopeAttach 

4  778 
end; 
779 

780 
//////////////////////////////////////////////////////////////////////////////// 

781 
procedure doStepSmokeTrace(Gear: PGear); 

782 
begin 

351  783 
inc(Gear^.Timer); 
784 
if Gear^.Timer > 64 then 

1133  785 
begin 
786 
Gear^.Timer:= 0; 

787 
dec(Gear^.State) 

788 
end; 

351  789 
Gear^.dX:= Gear^.dX + cWindSpeed; 
790 
Gear^.X:= Gear^.X + Gear^.dX; 

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

4  792 
end; 
9  793 

794 
//////////////////////////////////////////////////////////////////////////////// 

1045  795 
procedure doStepExplosionWork(Gear: PGear); 
9  796 
begin 
351  797 
inc(Gear^.Timer); 
798 
if Gear^.Timer > 75 then 

1133  799 
begin 
800 
inc(Gear^.State); 

801 
Gear^.Timer:= 0; 

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

803 
end; 

9  804 
end; 
10  805 

1045  806 
procedure doStepExplosion(Gear: PGear); 
807 
var i: LongWord; 

808 
begin 

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

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

1045  812 
Gear^.doStep:= @doStepExplosionWork 
813 
end; 

814 

10  815 
//////////////////////////////////////////////////////////////////////////////// 
816 
procedure doStepMine(Gear: PGear); 

817 
begin 

542  818 
if (Gear^.State and gstMoving) <> 0 then 
914  819 
begin 
820 
DeleteCI(Gear); 

821 
doStepFallingGear(Gear); 

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

823 
begin 

824 
AddGearCI(Gear); 

825 
Gear^.dX:= _0; 

826 
Gear^.dY:= _0 

827 
end; 

828 
CalcRotationDirAngle(Gear); 

829 
AllInactive:= false 

830 
end else 

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

832 
doStepFallingGear(Gear); 

351  833 

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

1133  835 
if ((Gear^.State and gstAttacking) = 0) then 
836 
begin 

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

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

839 
end else // gstAttacking <> 0 

840 
begin 

841 
AllInactive:= false; 

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

843 
if Gear^.Timer = 0 then 

844 
begin 

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

846 
DeleteGear(Gear); 

847 
exit 

848 
end; 

849 
dec(Gear^.Timer); 

850 
end else // gsttmpFlag = 0 

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

10  852 
end; 
57  853 

39  854 
//////////////////////////////////////////////////////////////////////////////// 
855 
procedure doStepDynamite(Gear: PGear); 

856 
begin 

43  857 
doStepFallingGear(Gear); 
858 
AllInactive:= false; 

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

1133  861 
begin 
862 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); 

863 
DeleteGear(Gear); 

864 
exit 

865 
end; 

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

868 

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

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

872 
begin 
351  873 
if (Gear^.Message and gm_Destroy) > 0 then 
1133  874 
begin 
875 
DeleteGear(Gear); 

876 
FreeActionsList; 

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

878 
with CurrentHedgehog^ do 

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

880 
exit 

881 
end; 

15  882 

351  883 
if Gear^.Damage > 0 then 
1133  884 
begin 
885 
x:= hwRound(Gear^.X); 

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

887 
DeleteGear(Gear); 

888 
if Gear^.Kind = gtCase then 

889 
begin 

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

891 
for i:= 0 to 63 do 

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

893 
end; 

894 
exit 

895 
end; 

79  896 

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

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

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

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

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

904 
begin 

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

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

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

908 
end; 

909 
CheckGearDrowning(Gear); 

910 
end; 

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

911 

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

914 
end; 
49  915 

916 
//////////////////////////////////////////////////////////////////////////////// 

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

1133  919 
record 
920 
dy, ny, dw: LongInt; 

921 
team: PTeam; 

922 
SortFactor: QWord; 

923 
end; 

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

924 
currsorter: PGear = nil; 
49  925 

926 
procedure doStepTeamHealthSorterWork(Gear: PGear); 

371  927 
var i: LongInt; 
49  928 
begin 
929 
AllInactive:= false; 

351  930 
dec(Gear^.Timer); 
931 
if (Gear^.Timer and 15) = 0 then 

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

934 
begin 

935 
{$WARNINGS OFF} 

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

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

938 
{$WARNINGS ON} 

939 
end; 

940 

351  941 
if (Gear^.Timer = 0) or (currsorter <> Gear) then 
1133  942 
begin 
943 
if currsorter = Gear then currsorter:= nil; 

944 
DeleteGear(Gear) 

945 
end 

49  946 
end; 
947 

948 
procedure doStepTeamHealthSorter(Gear: PGear); 

1133  949 
var i: Longword; 
950 
b: boolean; 

951 
t: LongInt; 

49  952 
begin 
953 
AllInactive:= false; 

557  954 

547  955 
for t:= 0 to Pred(TeamsCount) do 
1133  956 
with thexchar[t] do 
957 
begin 

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

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

960 
team:= TeamsArray[t]; 

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

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

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

964 
end; 

547  965 

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

966 
if TeamsCount > 1 then 
1133  967 
repeat 
968 
b:= true; 

969 
for t:= 0 to TeamsCount  2 do 

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

971 
begin 

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

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

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

975 
b:= false 

976 
end 

977 
until b; 

557  978 

1120  979 
t:=  4; 
557  980 
for i:= 0 to Pred(TeamsCount) do 
1133  981 
with thexchar[i] do 
982 
begin 

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

984 
ny:= t; 

985 
dy:= dy  ny 

986 
end; 

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

987 

557  988 
Gear^.Timer:= cSorterWorkTime; 
351  989 
Gear^.doStep:= @doStepTeamHealthSorterWork; 
143  990 
currsorter:= Gear 
49  991 
end; 
992 

79  993 
//////////////////////////////////////////////////////////////////////////////// 
854  994 
procedure doStepIdle(Gear: PGear); 
995 
begin 

996 
AllInactive:= false; 

925  997 
dec(Gear^.Timer); 
854  998 
if Gear^.Timer = 0 then 
999 
begin 

1000 
DeleteGear(Gear); 

1001 
AfterAttack 

1002 
end 

1003 
end; 

1004 

79  1005 
procedure doStepShover(Gear: PGear); 
1006 
var HHGear: PGear; 

1007 
begin 

351  1008 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
1009 
HHGear^.State:= HHGear^.State or gstNoDamage; 

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

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

1011 

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

1013 

351  1014 
HHGear^.State:= HHGear^.State and not gstNoDamage; 
854  1015 
Gear^.Timer:= 250; 
1016 
Gear^.doStep:= @doStepIdle 

79  1017 
end; 
1018 

1019 
//////////////////////////////////////////////////////////////////////////////// 

925  1020 
procedure doStepWhip(Gear: PGear); 
1021 
var HHGear: PGear; 

1022 
i: LongInt; 

1023 
begin 

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

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

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

1026 
DeleteCI(HHGear); 
925  1027 

1028 
for i:= 0 to 3 do 

1029 
begin 

1030 
AmmoShove(Gear, 30, 25); 

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

1032 
end; 

1033 

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

1035 
Gear^.Timer:= 250; 

1036 
Gear^.doStep:= @doStepIdle 

1037 
end; 

1038 

1039 
//////////////////////////////////////////////////////////////////////////////// 

79  1040 
procedure doStepFlame(Gear: PGear); 
1041 
begin 

1042 
AllInactive:= false; 

1043 
if not TestCollisionYwithGear(Gear, 1) then 

1133  1044 
begin 
1045 
Gear^.dX:= Gear^.dX + cWindSpeed; 

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

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

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

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

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

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

1052 
begin 

1053 
DeleteGear(Gear); 

1054 
exit 

1055 
end 

1056 
end else begin 

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

1058 
else begin 

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

1060 
dec(Gear^.Health); 

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

1062 
end 

1063 
end; 

79  1064 

351  1065 
if (((GameTicks div 8) mod 64) = Gear^.Angle) then 
1133  1066 
AmmoFlameWork(Gear); 
79  1067 

351  1068 
if Gear^.Health = 0 then 
1133  1069 
DeleteGear(Gear) 
79  1070 
end; 
82  1071 

1072 
//////////////////////////////////////////////////////////////////////////////// 

1073 
procedure doStepFirePunchWork(Gear: PGear); 

1074 
var HHGear: PGear; 

1075 
begin 

1076 
AllInactive:= false; 

351  1077 
if ((Gear^.Message and gm_Destroy) <> 0) then 
1133  1078 
begin 
1079 
DeleteGear(Gear); 

1080 
AfterAttack; 

1081 
exit 

1082 
end; 

82  1083 

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

1133  1086 
begin 
1087 
Gear^.Tag:= hwRound(HHGear^.Y); 

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

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

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

1091 
AmmoShove(Gear, 30, 40); 

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

1093 
end; 

351  1094 

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

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

1133  1097 
begin 
1098 
HHGear^.State:= HHGear^.State or gstMoving; 

1099 
DeleteGear(Gear); 

1100 
AfterAttack; 

1101 
exit 

1102 
end; 

351  1103 
HHGear^.Y:= HHGear^.Y + HHGear^.dY 
82  1104 
end; 
1105 

1106 
procedure doStepFirePunch(Gear: PGear); 

1107 
var HHGear: PGear; 

1108 
begin 

1109 
AllInactive:= false; 

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

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

1114 

351  1115 
HHGear^.dY:=  _0_3; 
82  1116 

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

1118 
Gear^.dX:= SignAs(_0_45, Gear^.dX); 
351  1119 
Gear^.dY:=  _0_9; 
1120 
Gear^.doStep:= @doStepFirePunchWork; 

498  1121 
DrawTunnel(HHGear^.X  int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); 
82  1122 
end; 
1123 

263  1124 
//////////////////////////////////////////////////////////////////////////////// 
1125 

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

1126 
procedure doStepParachuteWork(Gear: PGear); 
211  1127 
var HHGear: PGear; 
1128 
begin 

351  1129 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
82  1130 

516  1131 
inc(Gear^.Timer); 
1132 

212  1133 
if TestCollisionYwithGear(HHGear, 1) 
1133  1134 
or ((HHGear^.State and gstHHDriven) = 0) 
1135 
or CheckGearDrowning(HHGear) 

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

1137 
begin 

1138 
with HHGear^ do 

1139 
begin 

1140 
Message:= 0; 

1141 
SetLittle(dX); 

1142 
dY:= _0; 

1143 
State:= State or gstMoving; 

1144 
end; 

1145 
DeleteGear(Gear); 

1146 
exit 

1147 
end; 

211  1148 

351  1149 
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then 
1133  1150 
HHGear^.X:= HHGear^.X + cWindSpeed * 200; 
211  1151 

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

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

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

211  1156 

351  1157 
HHGear^.Y:= HHGear^.Y + cGravity * 100; 
568  1158 
Gear^.X:= HHGear^.X; 
1159 
Gear^.Y:= HHGear^.Y 

263  1160 
end; 
211  1161 

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

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

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

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

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

1166 

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

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

1168 

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

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

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

1171 

931  1172 
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

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

1174 

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

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

1176 

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

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

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

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

1180 

263  1181 
//////////////////////////////////////////////////////////////////////////////// 
1182 
procedure doStepAirAttackWork(Gear: PGear); 

1183 
begin 

1184 
AllInactive:= false; 

498  1185 
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; 
1124  1186 

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

1187 
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then 
1124  1188 
begin 
1189 
dec(Gear^.Health); 

1190 
case Gear^.State of 

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

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

1193 
end; 

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

1195 
end; 

1196 

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

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

1199 

498  1200 
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < 1024) then DeleteGear(Gear) 
263  1201 
end; 
1202 

1203 
procedure doStepAirAttack(Gear: PGear); 

1204 
begin 

1205 
AllInactive:= false; 

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

1206 

408  1207 
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 
1208 
else Gear^.Tag:= 1; 

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

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

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

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

1215 

351  1216 
Gear^.Health:= 6; 
801  1217 
Gear^.doStep:= @doStepAirAttackWork; 
1218 
PlaySound(sndIncoming, false) 

263  1219 
end; 
1220 

1221 
//////////////////////////////////////////////////////////////////////////////// 

1222 

1223 
procedure doStepAirBomb(Gear: PGear); 

1224 
begin 

1225 
AllInactive:= false; 

1226 
doStepFallingGear(Gear); 

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

1230 
DeleteGear(Gear); 

1231 
exit 

1232 
end; 

263  1233 
if (GameTicks and $3F) = 0 then 
1133  1234 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) 
211  1235 
end; 
409  1236 

1237 
//////////////////////////////////////////////////////////////////////////////// 

1238 

1239 
procedure doStepGirder(Gear: PGear); 

415  1240 
var HHGear: PGear; 
409  1241 
begin 
1242 
AllInactive:= false; 

415  1243 

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

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

520  1247 
sprAmGirder, Gear^.State, true) then 
1133  1248 
begin 
1249 
HHGear^.Message:= HHGear^.Message and not gm_Attack; 

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

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

1252 
DeleteGear(Gear); 

1253 
isCursorVisible:= true 

1254 
end 

1255 
else begin 

1256 
DeleteGear(Gear); 

1257 
AfterAttack 

1258 
end; 

415  1259 
TargetPoint.X:= NoPointX 
409  1260 
end; 
520  1261 

1262 
//////////////////////////////////////////////////////////////////////////////// 

525  1263 
procedure doStepTeleportAfter(Gear: PGear); 
912  1264 
var HHGear: PGear; 
1265 
begin 

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

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

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

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

1269 
if TestCollisionYwithGear(HHGear, 1) 
1133  1270 
or CheckGearDrowning(HHGear) then 
1271 
begin 

1272 
DeleteGear(Gear); 

1273 
AfterAttack 

1274 
end 

912  1275 
end; 
1276 

1277 
procedure doStepTeleportAnim(Gear: PGear); 

525  1278 
begin 
853  1279 
inc(Gear^.Timer); 
1280 
if Gear^.Timer = 65 then 

1281 
begin 

1282 
Gear^.Timer:= 0; 

1283 
inc(Gear^.Pos); 

1284 
if Gear^.Pos = 11 then 

912  1285 
Gear^.doStep:= @doStepTeleportAfter 
853  1286 
end 
525  1287 
end; 
520  1288 

1289 
procedure doStepTeleport(Gear: PGear); 

1290 
var HHGear: PGear; 

1291 
begin 

1292 
AllInactive:= false; 

1293 

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

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

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

1297 
sprHHTelepMask, 0, false) then 

853  1298 
begin 
1299 
HHGear^.Message:= HHGear^.Message and not gm_Attack; 

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

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

1302 
DeleteGear(Gear); 

1303 
isCursorVisible:= true 

1304 
end 

1305 
else begin 

1306 
DeleteCI(HHGear); 

1307 
SetAllHHToActive; 

912  1308 
Gear^.doStep:= @doStepTeleportAnim; 
853  1309 
Gear^.X:= HHGear^.X; 
1310 
Gear^.Y:= HHGear^.Y; 

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

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

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

1314 
end; 

520  1315 
TargetPoint.X:= NoPointX 
1316 
end; 

534  1317 

1318 
//////////////////////////////////////////////////////////////////////////////// 

1319 
procedure doStepSwitcherWork(Gear: PGear); 

1320 
var HHGear: PGear; 

1321 
Msg, State: Longword; 

1322 
begin 

1323 
AllInactive:= false; 

1324 

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

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

1329 
DeleteGear(Gear); 

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

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

534  1332 

1133  1333 
HHGear:= CurrentHedgehog^.Gear; 
1334 
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); 

1335 
HHGear^.Message:= Msg; 

1336 
exit 

1337 
end; 

534  1338 

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

1133  1340 
begin 
1341 
HHGear:= CurrentHedgehog^.Gear; 

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

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

1344 
State:= HHGear^.State; 

1345 
HHGear^.State:= 0; 

1346 
HHGear^.Active:= false; 

1347 
HHGear^.Z:= cHHZ; 

1348 
RemoveGearFromList(HHGear); 

1349 
InsertGearToList(HHGear); 

534  1350 

1133  1351 
repeat 
1352 
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); 

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

652  1354 

1133  1355 
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; 
534  1356 

1133  1357 
HHGear:= CurrentHedgehog^.Gear; 
1358 
HHGear^.State:= State; 

1359 
HHGear^.Active:= true; 

1360 
FollowGear:= HHGear; 

1361 
HHGear^.Z:= cCurrHHZ; 

1362 
RemoveGearFromList(HHGear); 

1363 
InsertGearToList(HHGear); 

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

1365 
Gear^.Y:= HHGear^.Y 

1366 
end; 

534  1367 
end; 