author  unc0rr 
Sat, 31 Jan 2009 11:58:09 +0000  
changeset 1781  28f674367d68 
parent 1776  dd5648e250e4 
child 1784  dfe9bafb4590 
permissions  rwrr 
4  1 
(* 
1066  2 
* Hedgewars, a free turn based strategy game 
1689  3 
* Copyright (c) 20042009 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; 

1669  28 
PlaySound(sndSplash, false, nil) 
1133  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 

1669  46 
PlaySound(sndOw4, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) 
1123  47 
else 
1669  48 
PlaySound(sndOw1, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); 
1123  49 

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

51 
inc(Gear^.Damage, dmg); 

1505  52 
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, dmg, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color); 
1123  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; 

1263  128 

4  129 
doStepFallingGear(Gear); 
1263  130 

351  131 
dec(Gear^.Timer); 
132 
if Gear^.Timer = 0 then 

1133  133 
begin 
134 
case Gear^.Kind of 

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

1603  136 
gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 40, EXPLAutoSound); 
1133  137 
gtClusterBomb: begin 
138 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); 

139 
for i:= 0 to 4 do 

140 
begin 

141 
dX:= rndSign(GetRandom * _0_1); 

142 
dY:= (GetRandom  _3) * _0_08; 

1261  143 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); 
144 
end 

145 
end; 

146 
gtWatermelon: begin 

147 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); 

148 
for i:= 0 to 5 do 

149 
begin 

150 
dX:= rndSign(GetRandom * _0_1); 

1496  151 
dY:= (GetRandom  _1_5) * _0_3; 
1262  152 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMelonPiece, 0, dX, dY, 75)^.DirAngle:= i * 60; 
1133  153 
end 
1263  154 
end; 
1555  155 
gtHellishBomb: begin 
156 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 90, EXPLAutoSound); 

157 
for i:= 0 to 127 do 

158 
begin 

159 
dX:= AngleCos(i * 16) * _0_5 * (GetRandom + _1); 

160 
dY:= AngleSin(i * 16) * _0_5 * (GetRandom + _1); 

161 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); 

162 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); 

163 
end 

164 
end; 

1133  165 
end; 
166 
DeleteGear(Gear); 

167 
exit 

168 
end; 

1263  169 

4  170 
CalcRotationDirAngle(Gear); 
1263  171 

172 
if Gear^.Kind = gtHellishBomb then 

1279  173 
begin 
1669  174 
if Gear^.Timer = 3000 then PlaySound(sndHellish, false, nil); 
1279  175 

1263  176 
if (GameTicks and $3F) = 0 then 
177 
if (Gear^.State and gstCollision) = 0 then 

178 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0); 

1279  179 
end; 
1263  180 

1158  181 
if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then 
182 
if (hwAbs(Gear^.dX) > _0_1) or 

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

1669  184 
PlaySound(sndGrenadeImpact, false, nil) 
4  185 
end; 
186 

1279  187 
procedure doStepWatermelon(Gear: PGear); 
188 
begin 

189 
AllInactive:= false; 

1669  190 
PlaySound(sndMelon, false, nil); 
1279  191 
Gear^.doStep:= @doStepBomb 
192 
end; 

193 

78  194 
procedure doStepCluster(Gear: PGear); 
195 
begin 

196 
AllInactive:= false; 

197 
doStepFallingGear(Gear); 

351  198 
if (Gear^.State and gstCollision) <> 0 then 
1133  199 
begin 
1261  200 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Timer, EXPLAutoSound); 
1133  201 
DeleteGear(Gear); 
202 
exit 

203 
end; 

1262  204 

205 
if Gear^.Kind = gtMelonPiece then 

206 
CalcRotationDirAngle(Gear) 

207 
else 

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

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

78  210 
end; 
211 

4  212 
//////////////////////////////////////////////////////////////////////////////// 
213 
procedure doStepGrenade(Gear: PGear); 

214 
begin 

215 
AllInactive:= false; 

351  216 
Gear^.dX:= Gear^.dX + cWindSpeed; 
4  217 
doStepFallingGear(Gear); 
351  218 
if (Gear^.State and gstCollision) <> 0 then 
1133  219 
begin 
220 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 

221 
DeleteGear(Gear); 

222 
exit 

223 
end; 

4  224 
if (GameTicks and $3F) = 0 then 
1133  225 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) 
4  226 
end; 
227 

228 
//////////////////////////////////////////////////////////////////////////////// 

95  229 
procedure doStepHealthTagWork(Gear: PGear); 
4  230 
begin 
522  231 
if Gear^.Kind = gtHealthTag then 
1505  232 
AllInactive:= false; 
233 

351  234 
dec(Gear^.Timer); 
522  235 
Gear^.Y:= Gear^.Y + Gear^.dY; 
1505  236 

351  237 
if Gear^.Timer = 0 then 
1133  238 
begin 
239 
if Gear^.Kind = gtHealthTag then 

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

241 
DeleteGear(Gear) 

242 
end 

4  243 
end; 
244 

263  245 
procedure doStepHealthTagWorkUnderWater(Gear: PGear); 
246 
begin 

1505  247 
AllInactive:= false; 
1495  248 

351  249 
Gear^.Y:= Gear^.Y  _0_08; 
1495  250 

498  251 
if hwRound(Gear^.Y) < cWaterLine + 10 then 
1505  252 
DeleteGear(Gear) 
263  253 
end; 
254 

95  255 
procedure doStepHealthTag(Gear: PGear); 
256 
var s: shortstring; 

257 
begin 

1505  258 
AllInactive:= false; 
259 
Gear^.dY:= _0_08; 

522  260 

351  261 
str(Gear^.State, s); 
1505  262 
Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, fnt16); 
263 

264 
if hwRound(Gear^.Y) < cWaterLine then 

265 
Gear^.doStep:= @doStepHealthTagWork 

266 
else 

267 
Gear^.doStep:= @doStepHealthTagWorkUnderWater; 

268 

762  269 
Gear^.Y:= Gear^.Y  int2hwFloat(Gear^.Tex^.h) 
95  270 
end; 
271 

4  272 
//////////////////////////////////////////////////////////////////////////////// 
273 
procedure doStepGrave(Gear: PGear); 

274 
begin 

275 
AllInactive:= false; 

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

4  278 

351  279 
if not Gear^.dY.isNegative then 
68  280 
if TestCollisionY(Gear, 1) then 
4  281 
begin 
351  282 
Gear^.dY:=  Gear^.dY * Gear^.Elasticity; 
283 
if Gear^.dY >  _1div1024 then 

4  284 
begin 
351  285 
Gear^.Active:= false; 
4  286 
exit 
1669  287 
end else if Gear^.dY <  _0_03 then PlaySound(sndGraveImpact, false, nil) 
4  288 
end; 
1505  289 

351  290 
Gear^.Y:= Gear^.Y + Gear^.dY; 
4  291 
CheckGearDrowning(Gear); 
351  292 
Gear^.dY:= Gear^.dY + cGravity 
4  293 
end; 
294 

295 
//////////////////////////////////////////////////////////////////////////////// 

296 
procedure doStepUFOWork(Gear: PGear); 

351  297 
var t: hwFloat; 
374  298 
y: LongInt; 
4  299 
begin 
300 
AllInactive:= false; 

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

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

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

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

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

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

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

374  309 

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

311 
begin 

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

313 
if y + Gear^.Radius < cWaterLine then 

498  314 
AddGear(hwRound(Gear^.X), y, gtSmokeTrace, 0, _0, _0, 0); 
374  315 
end; 
316 

4  317 
CheckCollision(Gear); 
351  318 
dec(Gear^.Timer); 
319 
if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then 

4  320 
begin 
560  321 
StopSound(sndUFO); 
351  322 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 
4  323 
DeleteGear(Gear); 
324 
end; 

325 
end; 

326 

327 
procedure doStepUFO(Gear: PGear); 

328 
begin 

329 
AllInactive:= false; 

351  330 
Gear^.X:= Gear^.X + Gear^.dX; 
331 
Gear^.Y:= Gear^.Y + Gear^.dY; 

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

4  333 
CheckCollision(Gear); 
351  334 
if (Gear^.State and gstCollision) <> 0 then 
4  335 
begin 
351  336 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 
4  337 
DeleteGear(Gear); 
338 
exit 

339 
end; 

351  340 
dec(Gear^.Timer); 
341 
if Gear^.Timer = 0 then 

4  342 
begin 
1669  343 
PlaySound(sndUFO, true, nil); 
351  344 
Gear^.Timer:= 5000; 
345 
Gear^.doStep:= @doStepUFOWork 

4  346 
end; 
347 
end; 

348 

349 
//////////////////////////////////////////////////////////////////////////////// 

876  350 
procedure doStepShotIdle(Gear: PGear); 
351 
begin 

352 
AllInactive:= false; 

353 
inc(Gear^.Timer); 

354 
if Gear^.Timer > 75 then 

355 
begin 

356 
DeleteGear(Gear); 

357 
AfterAttack 

358 
end 

359 
end; 

360 

4  361 
procedure doStepShotgunShot(Gear: PGear); 
362 
var i: LongWord; 

363 
begin 

364 
AllInactive:= false; 

876  365 

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

367 
begin 

368 
dec(Gear^.Timer); 

369 
if Gear^.Timer = 0 then 

370 
begin 

1669  371 
PlaySound(sndShotgunFire, false, nil); 
876  372 
Gear^.State:= Gear^.State or gstAnimation 
373 
end; 

374 
exit 

375 
end 

376 
else inc(Gear^.Timer); 

377 

4  378 
i:= 200; 
379 
repeat 

351  380 
Gear^.X:= Gear^.X + Gear^.dX; 
381 
Gear^.Y:= Gear^.Y + Gear^.dY; 

4  382 
CheckCollision(Gear); 
351  383 
if (Gear^.State and gstCollision) <> 0 then 
876  384 
begin 
385 
Gear^.X:= Gear^.X + Gear^.dX * 8; 

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

387 
ShotgunShot(Gear); 

388 
Gear^.doStep:= @doStepShotIdle; 

389 
exit 

390 
end; 

4  391 
dec(i) 
392 
until i = 0; 

1760  393 
if (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then 
876  394 
Gear^.doStep:= @doStepShotIdle 
4  395 
end; 
396 

397 
//////////////////////////////////////////////////////////////////////////////// 

559  398 
procedure doStepDEagleShotWork(Gear: PGear); 
38  399 
var i, x, y: LongWord; 
351  400 
oX, oY: hwFloat; 
38  401 
begin 
402 
AllInactive:= false; 

876  403 
inc(Gear^.Timer); 
37  404 
i:= 80; 
351  405 
oX:= Gear^.X; 
406 
oY:= Gear^.Y; 

37  407 
repeat 
351  408 
Gear^.X:= Gear^.X + Gear^.dX; 
409 
Gear^.Y:= Gear^.Y + Gear^.dY; 

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

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

1753  412 
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) 
351  413 
and (Land[y, x] <> 0) then inc(Gear^.Damage); 
519  414 
if Gear^.Damage > 5 then AmmoShove(Gear, 7, 20); 
38  415 
dec(i) 
351  416 
until (i = 0) or (Gear^.Damage > Gear^.Health); 
417 
if Gear^.Damage > 0 then 

37  418 
begin 
351  419 
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82  i, 1); 
420 
dec(Gear^.Health, Gear^.Damage); 

421 
Gear^.Damage:= 0 

37  422 
end; 
1760  423 

424 
if (Gear^.Health <= 0) 

425 
or (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) 

426 
or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then 

876  427 
Gear^.doStep:= @doStepShotIdle 
37  428 
end; 
429 

559  430 
procedure doStepDEagleShot(Gear: PGear); 
431 
begin 

1669  432 
PlaySound(sndGun, false, nil); 
559  433 
Gear^.doStep:= @doStepDEagleShotWork 
434 
end; 

435 

37  436 
//////////////////////////////////////////////////////////////////////////////// 
4  437 
procedure doStepActionTimer(Gear: PGear); 
438 
begin 

351  439 
dec(Gear^.Timer); 
440 
case Gear^.Kind of 

83  441 
gtATStartGame: begin 
4  442 
AllInactive:= false; 
351  443 
if Gear^.Timer = 0 then 
83  444 
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); 
4  445 
end; 
83  446 
gtATSmoothWindCh: begin 
351  447 
if Gear^.Timer = 0 then 
6  448 
begin 
351  449 
if WindBarWidth < Gear^.Tag then inc(WindBarWidth) 
450 
else if WindBarWidth > Gear^.Tag then dec(WindBarWidth); 

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

83  452 
end 
453 
end; 

454 
gtATFinishGame: begin 

455 
AllInactive:= false; 

351  456 
if Gear^.Timer = 0 then 
113  457 
begin 
458 
SendIPC('N'); 

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

459 
SendIPC('q'); 
83  460 
GameState:= gsExit 
113  461 
end 
6  462 
end; 
4  463 
end; 
351  464 
if Gear^.Timer = 0 then DeleteGear(Gear) 
4  465 
end; 
466 

467 
//////////////////////////////////////////////////////////////////////////////// 

468 
procedure doStepPickHammerWork(Gear: PGear); 

371  469 
var i, ei: LongInt; 
4  470 
HHGear: PGear; 
471 
begin 

70  472 
AllInactive:= false; 
351  473 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
474 
dec(Gear^.Timer); 

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

1200  476 
begin 
477 
StopSound(sndPickhammer); 

478 
DeleteGear(Gear); 

479 
AfterAttack; 

480 
exit 

481 
end; 

845  482 

422  483 
if (Gear^.Timer mod 33) = 0 then 
1200  484 
begin 
485 
HHGear^.State:= HHGear^.State or gstNoDamage; 

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

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

488 
end; 

422  489 

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

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

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

494 
while i <= ei do 

495 
begin 

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

497 
inc(i, 1) 

498 
end; 

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

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

501 
SetAllHHToActive; 

502 
end; 

4  503 
if TestCollisionYwithGear(Gear, 1) then 
1200  504 
begin 
505 
Gear^.dY:= _0; 

506 
SetLittle(HHGear^.dX); 

507 
HHGear^.dY:= _0; 

508 
end else 

509 
begin 

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

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

1417  512 
if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer:= 1 
1200  513 
end; 
4  514 

351  515 
Gear^.X:= Gear^.X + HHGear^.dX; 
516 
HHGear^.X:= Gear^.X; 

498  517 
HHGear^.Y:= Gear^.Y  int2hwFloat(cHHRadius); 
4  518 

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

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

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

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

498  524 
else Gear^.dX:= _0; 
4  525 
end; 
526 

527 
procedure doStepPickHammer(Gear: PGear); 

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

530 
HHGear: PGear; 
4  531 
begin 
532 
i:= 0; 

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

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

534 

498  535 
y:= hwRound(Gear^.Y)  cHHRadius * 2; 
351  536 
while y < hwRound(Gear^.Y) do 
4  537 
begin 
371  538 
ar[i].Left := hwRound(Gear^.X)  Gear^.Radius  LongInt(GetRandom(2)); 
539 
ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); 

4  540 
inc(y, 2); 
541 
inc(i) 

542 
end; 

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

543 

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

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

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

547 

1669  548 
PlaySound(sndPickhammer, true, nil); 
4  549 
doStepPickHammerWork(Gear); 
351  550 
Gear^.doStep:= @doStepPickHammerWork 
4  551 
end; 
552 

553 
//////////////////////////////////////////////////////////////////////////////// 

371  554 
var BTPrevAngle, BTSteps: LongInt; 
302  555 

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

556 
procedure doStepBlowTorchWork(Gear: PGear); 
302  557 
var HHGear: PGear; 
1528  558 
b: boolean; 
559 
prevX: LongInt; 

302  560 
begin 
561 
AllInactive:= false; 

351  562 
dec(Gear^.Timer); 
563 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 

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

564 

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

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

566 

305  567 
b:= false; 
568 

371  569 
if abs(LongInt(HHGear^.Angle)  BTPrevAngle) > 7 then 
1528  570 
begin 
571 
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX); 

572 
Gear^.dY:= AngleCos(HHGear^.Angle) * (  _0_5); 

573 
BTPrevAngle:= HHGear^.Angle; 

574 
b:= true 

575 
end; 

576 

577 
if ((HHGear^.State and gstMoving) <> 0) then 

578 
begin 

579 
doStepHedgehogMoving(HHGear); 

1736  580 
if (HHGear^.State and gstHHDriven) = 0 then Gear^.Timer:= 0 
1528  581 
end; 
305  582 

351  583 
if Gear^.Timer mod cHHStepTicks = 0 then 
1528  584 
begin 
585 
b:= true; 

586 
if Gear^.dX.isNegative then 

1547  587 
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Left 
1528  588 
else 
1547  589 
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Right; 
305  590 

1528  591 
if ((HHGear^.State and gstMoving) = 0) then 
592 
begin 

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

594 
prevX:= hwRound(HHGear^.X); 

595 

596 
HedgehogStep(HHGear); 

597 

598 
if (prevX = hwRound(HHGear^.X)) then HHGear^.X:= HHGear^.X + SignAs(_1, HHGear^.dX); 

599 
HHGear^.State:= HHGear^.State or gstAttacking 

600 
end; 

305  601 

1528  602 
inc(BTSteps); 
603 
if BTSteps = 7 then 

604 
begin 

605 
BTSteps:= 0; 

606 
Gear^.X:= HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); 

607 
Gear^.Y:= HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); 

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

1643  609 
AmmoShove(Gear, 2, 15); 
1528  610 
HHGear^.State:= HHGear^.State and not gstNoDamage 
611 
end; 

612 
end; 

305  613 

614 
if b then 

498  615 
DrawTunnel(HHGear^.X  Gear^.dX * cHHRadius, HHGear^.Y  _4  Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, 
351  616 
Gear^.dX, Gear^.dY, 
1501  617 
cHHRadius * 5, cHHRadius * 2 + 7); 
305  618 

351  619 
if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) then 
1528  620 
begin 
621 
HHGear^.Message:= 0; 

622 
HHGear^.State:= HHGear^.State and (not gstNotKickable); 

623 
DeleteGear(Gear); 

624 
AfterAttack 

625 
end 

302  626 
end; 
627 

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

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

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

630 
begin 
371  631 
BTPrevAngle:= High(LongInt); 
305  632 
BTSteps:= 0; 
351  633 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
634 
HHGear^.Message:= 0; 

1528  635 
HHGear^.State:= HHGear^.State or gstNotKickable; 
351  636 
Gear^.doStep:= @doStepBlowTorchWork 
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset

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

638 

302  639 
//////////////////////////////////////////////////////////////////////////////// 
640 

1781  641 
procedure doStepRope(Gear: PGear); forward; 
642 

643 
procedure doStepRopeAfterAttack(Gear: PGear); 

644 
var HHGear: PGear; 

645 
begin 

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

647 
if ((HHGear^.State and gstHHDriven) = 0) 

648 
or (CheckGearDrowning(HHGear)) 

649 
or TestCollisionYwithGear(HHGear, 1) then 

650 
begin 

651 
DeleteGear(Gear); 

652 
exit 

653 
end; 

654 

655 
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); 

656 
if HHGear^.dY.isNegative and TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= _0; 

657 
HHGear^.X:= HHGear^.X + HHGear^.dX; 

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

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

660 

661 
if (Gear^.Message and gm_Attack) <> 0 then 

662 
begin 

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

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

665 
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX); 

666 
Gear^.dY:= AngleCos(HHGear^.Angle); 

667 
Gear^.Friction:= _450; 

668 
Gear^.Elasticity:= _0; 

669 
Gear^.State:= Gear^.State and not gsttmpflag; 

670 
Gear^.doStep:= @doStepRope 

671 
end 

672 
end; 

673 

4  674 
procedure doStepRopeWork(Gear: PGear); 
675 
var HHGear: PGear; 

1669  676 
len, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY: hwFloat; 
1504  677 
lx, ly: LongInt; 
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset

678 
haveCollision, 
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset

679 
haveDivided: boolean; 
4  680 

1504  681 
procedure DeleteMe; 
682 
begin 

683 
with HHGear^ do 

684 
begin 

685 
Message:= Message and not gm_Attack; 

686 
State:= State or gstMoving; 

687 
end; 

688 
DeleteGear(Gear) 

689 
end; 

4  690 

1781  691 
procedure WaitCollision; 
692 
begin 

693 
with HHGear^ do 

694 
begin 

695 
Message:= Message and not gm_Attack; 

696 
State:= State or gstMoving; 

697 
end; 

698 
RopePoints.Count:= 0; 

699 
Gear^.Elasticity:= _0; 

700 
Gear^.doStep:= @doStepRopeAfterAttack 

701 
end; 

702 

4  703 
begin 
351  704 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
108  705 

351  706 
if ((HHGear^.State and gstHHDriven) = 0) 
1504  707 
or (CheckGearDrowning(HHGear)) then 
708 
begin 

709 
DeleteMe; 

710 
exit 

711 
end; 

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

712 

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

4  715 

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

1652  718 
ropeDx:= HHGear^.X  Gear^.X; // vector between hedgehog and rope attaching point 
719 
ropeDy:= HHGear^.Y  Gear^.Y; 

720 

721 
mdX:= ropeDx + HHGear^.dX; 

722 
mdY:= ropeDy + HHGear^.dY; 

723 
len:= _1 / Distance(mdX, mdY); 

724 
mdX:= mdX * len; // rope vector plus hedgehog direction vector normalized 

725 
mdY:= mdY * len; 

726 

727 
Gear^.dX:= mdX; // for visual purposes only 

728 
Gear^.dY:= mdY; 

729 

730 
///// 

731 
tx:= HHGear^.X; 

732 
ty:= HHGear^.Y; 

4  733 

1652  734 
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then 
735 
if not (TestCollisionXwithGear(HHGear, hwSign(ropeDx)) 

736 
or TestCollisionYwithGear(HHGear, hwSign(ropeDy))) then 

737 
Gear^.Elasticity:= Gear^.Elasticity + _0_3; 

738 

739 
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then 

740 
if not (TestCollisionXwithGear(HHGear, hwSign(ropeDx)) 

741 
or TestCollisionYwithGear(HHGear, hwSign(ropeDy))) then 

742 
Gear^.Elasticity:= Gear^.Elasticity  _0_3; 

743 

744 
HHGear^.X:= Gear^.X + mdX * Gear^.Elasticity; 

745 
HHGear^.Y:= Gear^.Y + mdY * Gear^.Elasticity; 

746 

747 
HHGear^.dX:= HHGear^.X  tx; 

748 
HHGear^.dY:= HHGear^.Y  ty; 

749 
//// 

750 

1554  751 

1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset

752 
haveDivided:= false; 
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset

753 
// check whether rope needs dividing 
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset

754 
len:= _1 / Distance(ropeDx, ropeDy); // old rope pos 
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset

755 
nx:= ropeDx * len; 
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset

756 
ny:= ropeDy * len; 
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset

757 

1652  758 
len:= Gear^.Elasticity  _0_3x70; 
759 
while len > _0_3 do 

1504  760 
begin 
1652  761 
lx:= hwRound(Gear^.X + mdX * len); 
762 
ly:= hwRound(Gear^.Y + mdY * len); 

1753  763 
if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (Land[ly, lx] <> 0) then 
1504  764 
begin 
765 
with RopePoints.ar[RopePoints.Count] do 

766 
begin 

767 
X:= Gear^.X; 

768 
Y:= Gear^.Y; 

1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset

769 
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); 
1652  770 
b:= (nx * HHGear^.dY) > (ny * HHGear^.dX); 
1504  771 
dLen:= len 
772 
end; 

1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset

773 
Gear^.X:= Gear^.X + nx * len; 
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset

774 
Gear^.Y:= Gear^.Y + ny * len; 
1504  775 
inc(RopePoints.Count); 
776 
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); 

777 
Gear^.Elasticity:= Gear^.Elasticity  len; 

778 
Gear^.Friction:= Gear^.Friction  len; 

1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset

779 
haveDivided:= true; 
1504  780 
break 
781 
end; 

1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset

782 
len:= len  _0_3 // should be the same as increase step 
1504  783 
end; 
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset

784 

77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset

785 
if not haveDivided then 
1504  786 
if RopePoints.Count > 0 then // check whether the last dividing point could be removed 
787 
begin 

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

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

790 
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx  Gear^.X) * (ty  HHGear^.Y) > (tx  HHGear^.X) * (ty  Gear^.Y)) then 

791 
begin 

792 
dec(RopePoints.Count); 

1652  793 
Gear^.X:= RopePoints.ar[RopePoints.Count].X; 
794 
Gear^.Y:= RopePoints.ar[RopePoints.Count].Y; 

1504  795 
Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; 
796 
Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen 

797 
end 

798 
end; 

4  799 

1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset

800 
haveCollision:= false; 
351  801 
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then 
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset

802 
begin 
1504  803 
HHGear^.dX:= _0_6 * HHGear^.dX; 
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset

804 
haveCollision:= true 
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset

805 
end; 
351  806 
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then 
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset

807 
begin 
1504  808 
HHGear^.dY:= _0_6 * HHGear^.dY; 
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset

809 
haveCollision:= true 
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset

810 
end; 
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset

811 

1579
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset

812 
if haveCollision 
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset

813 
and (Gear^.Message and (gm_Left or gm_Right) <> 0) 
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset

814 
and (Gear^.Message and (gm_Up or gm_Down) <> 0) then 
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset

815 
begin 
1579
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset

816 
HHGear^.dX:= SignAs(hwAbs(HHGear^.dX) + _0_2, HHGear^.dX); 
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset

817 
HHGear^.dY:= SignAs(hwAbs(HHGear^.dY) + _0_2, HHGear^.dY) 
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset

818 
end; 
4  819 

789  820 
len:= Distance(HHGear^.dX, HHGear^.dY); 
940  821 
if len > _0_8 then 
1504  822 
begin 
823 
len:= _0_8 / len; 

824 
HHGear^.dX:= HHGear^.dX * len; 

825 
HHGear^.dY:= HHGear^.dY * len; 

826 
end; 

789  827 

351  828 
if (Gear^.Message and gm_Attack) <> 0 then 
1504  829 
if (Gear^.State and gsttmpFlag) <> 0 then 
1781  830 
WaitCollision 
1504  831 
else 
832 
else 

833 
if (Gear^.State and gsttmpFlag) = 0 then 

834 
Gear^.State:= Gear^.State or gsttmpFlag; 

4  835 
end; 
836 

837 
procedure doStepRopeAttach(Gear: PGear); 

838 
var HHGear: PGear; 

1781  839 
tx, ty, tt: hwFloat; 
840 

841 
procedure RemoveFromAmmo; 

842 
begin 

843 
if (Gear^.State and gstAttacked) = 0 then 

844 
begin 

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

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

847 
Gear^.State:= Gear^.State or gstAttacked 

848 
end 

849 
end; 

850 

4  851 
begin 
351  852 
Gear^.X:= Gear^.X  Gear^.dX; 
853 
Gear^.Y:= Gear^.Y  Gear^.dY; 

498  854 
Gear^.Elasticity:= Gear^.Elasticity + _1; 
351  855 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
517  856 
DeleteCI(HHGear); 
542  857 
if (HHGear^.State and gstMoving) <> 0 then 
1433  858 
if TestCollisionYwithGear(HHGear, 1) then 
859 
begin 

860 
CheckHHDamage(HHGear); 

861 
HHGear^.dY:= _0; 

862 
HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); 

863 
end else 

864 
begin 

865 
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); 

866 
HHGear^.X:= HHGear^.X + HHGear^.dX; 

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

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

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

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

871 
tt:= Gear^.Elasticity; 

872 
tx:= _0; 

873 
ty:= _0; 

874 
while tt > _20 do 

875 
begin 

876 
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), hwSign(Gear^.dX)) 

877 
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), hwSign(Gear^.dY)) then 

878 
begin 

879 
Gear^.X:= Gear^.X + tx; 

880 
Gear^.Y:= Gear^.Y + ty; 

881 
Gear^.Elasticity:= tt; 

882 
Gear^.doStep:= @doStepRopeWork; 

1752
769986d39202
Fix accidental rope removinf from ammo in some cases
unc0rr
parents:
1736
diff
changeset

883 
with HHGear^ do State:= State and not (gstAttacking or gstMoving or gstHHHJump); 
1781  884 

885 
RemoveFromAmmo; 

886 

1752
769986d39202
Fix accidental rope removinf from ammo in some cases
unc0rr
parents:
1736
diff
changeset

887 
tt:= _0; 
769986d39202
Fix accidental rope removinf from ammo in some cases
unc0rr
parents:
1736
diff
changeset

888 
exit 
1433  889 
end; 
890 
tx:= tx + Gear^.dX + Gear^.dX; 

891 
ty:= ty + Gear^.dY + Gear^.dY; 

892 
tt:= tt  _2; 

893 
end; 

894 
end; 

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

895 

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

897 

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

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

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

901 
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

902 

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

904 

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

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

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

907 
end; 
4  908 

1634
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset

909 
if (Gear^.Elasticity > Gear^.Friction) 
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset

910 
or ((Gear^.Message and gm_Attack) = 0) 
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset

911 
or (HHGear^.Damage > 0) then 
1433  912 
begin 
913 
with PHedgehog(Gear^.Hedgehog)^.Gear^ do 

914 
begin 

915 
State:= State and not gstAttacking; 

916 
Message:= Message and not gm_Attack 

917 
end; 

918 
DeleteGear(Gear) 

919 
end 

4  920 
end; 
921 

922 
procedure doStepRope(Gear: PGear); 

923 
begin 

351  924 
Gear^.dX:=  Gear^.dX; 
925 
Gear^.dY:=  Gear^.dY; 

926 
Gear^.doStep:= @doStepRopeAttach 

4  927 
end; 
928 

929 
//////////////////////////////////////////////////////////////////////////////// 

930 
procedure doStepSmokeTrace(Gear: PGear); 

931 
begin 

351  932 
inc(Gear^.Timer); 
933 
if Gear^.Timer > 64 then 

1133  934 
begin 
935 
Gear^.Timer:= 0; 

936 
dec(Gear^.State) 

937 
end; 

351  938 
Gear^.dX:= Gear^.dX + cWindSpeed; 
939 
Gear^.X:= Gear^.X + Gear^.dX; 

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

4  941 
end; 
9  942 

943 
//////////////////////////////////////////////////////////////////////////////// 

1045  944 
procedure doStepExplosionWork(Gear: PGear); 
9  945 
begin 
351  946 
inc(Gear^.Timer); 
947 
if Gear^.Timer > 75 then 

1133  948 
begin 
949 
inc(Gear^.State); 

950 
Gear^.Timer:= 0; 

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

952 
end; 

9  953 
end; 
10  954 

1045  955 
procedure doStepExplosion(Gear: PGear); 
956 
var i: LongWord; 

957 
begin 

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

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

1045  961 
Gear^.doStep:= @doStepExplosionWork 
962 
end; 

963 

10  964 
//////////////////////////////////////////////////////////////////////////////// 
965 
procedure doStepMine(Gear: PGear); 

966 
begin 

542  967 
if (Gear^.State and gstMoving) <> 0 then 
914  968 
begin 
969 
DeleteCI(Gear); 

970 
doStepFallingGear(Gear); 

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

972 
begin 

973 
AddGearCI(Gear); 

974 
Gear^.dX:= _0; 

975 
Gear^.dY:= _0 

976 
end; 

977 
CalcRotationDirAngle(Gear); 

978 
AllInactive:= false 

979 
end else 

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

981 
doStepFallingGear(Gear); 

351  982 

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

1133  984 
if ((Gear^.State and gstAttacking) = 0) then 
985 
begin 

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

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

988 
end else // gstAttacking <> 0 

989 
begin 

990 
AllInactive:= false; 

1669  991 
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false, nil); 
1133  992 
if Gear^.Timer = 0 then 
993 
begin 

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

995 
DeleteGear(Gear); 

996 
exit 

997 
end; 

998 
dec(Gear^.Timer); 

999 
end else // gsttmpFlag = 0 

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

10  1001 
end; 
57  1002 

39  1003 
//////////////////////////////////////////////////////////////////////////////// 
1004 
procedure doStepDynamite(Gear: PGear); 

1005 
begin 

43  1006 
doStepFallingGear(Gear); 
1007 
AllInactive:= false; 

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

1133  1010 
begin 
1011 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); 

1012 
DeleteGear(Gear); 

1013 
exit 

1014 
end; 

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

1017 

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

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

1022 
begin 
351  1023 
if (Gear^.Message and gm_Destroy) > 0 then 
1133  1024 
begin 
1025 
DeleteGear(Gear); 

1026 
FreeActionsList; 

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

1028 
with CurrentHedgehog^ do 

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

1030 
exit 

1031 
end; 

15  1032 

351  1033 
if Gear^.Damage > 0 then 
1133  1034 
begin 
1035 
x:= hwRound(Gear^.X); 

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

1436  1037 
k:= Gear^.Kind; 
1038 
DeleteGear(Gear); // < delete gear! 

1039 

1040 
if k = gtCase then 

1133  1041 
begin 
1042 
doMakeExplosion(x, y, 25, EXPLAutoSound); 

1043 
for i:= 0 to 63 do 

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

1045 
end; 

1046 
exit 

1047 
end; 

79  1048 

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

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

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

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

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

1056 
begin 

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

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

1669  1059 
else if Gear^.dY <  _0_03 then PlaySound(sndGraveImpact, false, nil); 
1133  1060 
end; 
1061 
CheckGearDrowning(Gear); 

1062 
end; 

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

1063 

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

1066 
end; 
49  1067 

1068 
//////////////////////////////////////////////////////////////////////////////// 

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

1133  1071 
record 
1072 
dy, ny, dw: LongInt; 

1073 
team: PTeam; 

1074 
SortFactor: QWord; 

1075 
end; 

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

1076 
currsorter: PGear = nil; 
49  1077 

1078 
procedure doStepTeamHealthSorterWork(Gear: PGear); 

371  1079 
var i: LongInt; 
49  1080 
begin 
1081 
AllInactive:= false; 

351  1082 
dec(Gear^.Timer); 
1083 
if (Gear^.Timer and 15) = 0 then 

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

1086 
begin 

1087 
{$WARNINGS OFF} 

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

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

1090 
{$WARNINGS ON} 

1091 
end; 

1092 

351  1093 
if (Gear^.Timer = 0) or (currsorter <> Gear) then 
1133  1094 
begin 
1095 
if currsorter = Gear then currsorter:= nil; 

1096 
DeleteGear(Gear) 

1097 
end 

49  1098 
end; 
1099 

1100 
procedure doStepTeamHealthSorter(Gear: PGear); 

1133  1101 
var i: Longword; 
1102 
b: boolean; 

1103 
t: LongInt; 

49  1104 
begin 
1105 
AllInactive:= false; 

557  1106 

547  1107 
for t:= 0 to Pred(TeamsCount) do 
1133  1108 
with thexchar[t] do 
1109 
begin 

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

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

1112 
team:= TeamsArray[t]; 

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

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

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

1116 
end; 

547  1117 

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

1118 
if TeamsCount > 1 then 
1133  1119 
repeat 
1120 
b:= true; 

1121 
for t:= 0 to TeamsCount  2 do 

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

1123 
begin 

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

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

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

1127 
b:= false 

1128 
end 

1129 
until b; 

557  1130 

1120  1131 
t:=  4; 
557  1132 
for i:= 0 to Pred(TeamsCount) do 
1133  1133 
with thexchar[i] do 
1134 
begin 

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

1136 
ny:= t; 

1137 
dy:= dy  ny 

1138 
end; 

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

1139 

557  1140 
Gear^.Timer:= cSorterWorkTime; 
351  1141 
Gear^.doStep:= @doStepTeamHealthSorterWork; 
143  1142 
currsorter:= Gear 
49  1143 
end; 
1144 

79  1145 
//////////////////////////////////////////////////////////////////////////////// 
854  1146 
procedure doStepIdle(Gear: PGear); 
1147 
begin 

1148 
AllInactive:= false; 

925  1149 
dec(Gear^.Timer); 
854  1150 
if Gear^.Timer = 0 then 
1151 
begin 

1152 
DeleteGear(Gear); 

1153 
AfterAttack 

1154 
end 

1155 
end; 

1156 

79  1157 
procedure doStepShover(Gear: PGear); 
1158 
var HHGear: PGear; 

1159 
begin 

351  1160 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
1161 
HHGear^.State:= HHGear^.State or gstNoDamage; 

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

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

1163 

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

1165 

351  1166 
HHGear^.State:= HHGear^.State and not gstNoDamage; 
854  1167 
Gear^.Timer:= 250; 
1168 
Gear^.doStep:= @doStepIdle 

79  1169 
end; 
1170 

1171 
//////////////////////////////////////////////////////////////////////////////// 

925  1172 
procedure doStepWhip(Gear: PGear); 
1173 
var HHGear: PGear; 

1174 
i: LongInt; 

1175 
begin 

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

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

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

1178 
DeleteCI(HHGear); 
925  1179 

1180 
for i:= 0 to 3 do 

1181 
begin 

1182 
AmmoShove(Gear, 30, 25); 

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

1184 
end; 

1185 

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

1187 
Gear^.Timer:= 250; 

1188 
Gear^.doStep:= @doStepIdle 

1189 
end; 

1190 

1191 
//////////////////////////////////////////////////////////////////////////////// 

79  1192 
procedure doStepFlame(Gear: PGear); 
1193 
begin 

1194 
AllInactive:= false; 

1433  1195 

79  1196 
if not TestCollisionYwithGear(Gear, 1) then 
1133  1197 
begin 
1586  1198 
if hwAbs(Gear^.dX) > _0_01 then 
1199 
Gear^.dX:= Gear^.dX * _0_995; 

1297  1200 

1133  1201 
Gear^.dY:= Gear^.dY + cGravity; 
1586  1202 
if hwAbs(Gear^.dY) > _0_08 then Gear^.dY:= Gear^.dY * _0_995; 
1297  1203 

1586  1204 
Gear^.X:= Gear^.X + Gear^.dX + cWindSpeed * 270; 
1133  1205 
Gear^.Y:= Gear^.Y + Gear^.dY; 
1297  1206 

1417  1207 
if not (hwRound(Gear^.Y) < cWaterLine) then 
1133  1208 
begin 
1209 
DeleteGear(Gear); 

1210 
exit 

1211 
end 

1212 
end else begin 

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

1214 
else begin 

1586  1215 
Gear^.Radius:= 9; 
1216 
AmmoShove(Gear, 4, 100); 

1297  1217 
Gear^.Radius:= 1; 
1218 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 4, EXPLNoDamage); 

1133  1219 
dec(Gear^.Health); 
1586  1220 
Gear^.Timer:= 450  Gear^.Tag * 8 
1133  1221 
end 
1222 
end; 

79  1223 

1295  1224 
//if (((GameTicks div 8) mod 64) = Gear^.Tag) then 
1225 
// AmmoFlameWork(Gear); 

79  1226 

351  1227 
if Gear^.Health = 0 then 
1133  1228 
DeleteGear(Gear) 
79  1229 
end; 
82  1230 

1231 
//////////////////////////////////////////////////////////////////////////////// 

1232 
procedure doStepFirePunchWork(Gear: PGear); 

1233 
var HHGear: PGear; 

1234 
begin 

1235 
AllInactive:= false; 

351  1236 
if ((Gear^.Message and gm_Destroy) <> 0) then 
1133  1237 
begin 
1238 
DeleteGear(Gear); 

1239 
AfterAttack; 

1240 
exit 

1241 
end; 

82  1242 

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

1133  1245 
begin 
1246 
Gear^.Tag:= hwRound(HHGear^.Y); 

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

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

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

1250 
AmmoShove(Gear, 30, 40); 

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

1252 
end; 

351  1253 

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

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

1133  1256 
begin 
1257 
HHGear^.State:= HHGear^.State or gstMoving; 

1258 
DeleteGear(Gear); 

1259 
AfterAttack; 

1260 
exit 

1261 
end; 

351  1262 
HHGear^.Y:= HHGear^.Y + HHGear^.dY 
82  1263 
end; 
1264 

1265 
procedure doStepFirePunch(Gear: PGear); 

1266 
var HHGear: PGear; 

1267 
begin 

1268 
AllInactive:= false; 

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

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

1273 

351  1274 
HHGear^.dY:=  _0_3; 
82  1275 

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

1277 
Gear^.dX:= SignAs(_0_45, Gear^.dX); 
351  1278 
Gear^.dY:=  _0_9; 
1279 
Gear^.doStep:= @doStepFirePunchWork; 

498  1280 
DrawTunnel(HHGear^.X  int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); 
1279  1281 

1669  1282 
PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false, PHedgehog(HHGear^.Hedgehog)^.Team^.voicepack) 
82  1283 
end; 
1284 

263  1285 
//////////////////////////////////////////////////////////////////////////////// 
1286 

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

1287 
procedure doStepParachuteWork(Gear: PGear); 
211  1288 
var HHGear: PGear; 
1289 
begin 

351  1290 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
82  1291 

516  1292 
inc(Gear^.Timer); 
1293 

212  1294 
if TestCollisionYwithGear(HHGear, 1) 
1133  1295 
or ((HHGear^.State and gstHHDriven) = 0) 
1296 
or CheckGearDrowning(HHGear) 

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

1298 
begin 

1299 
with HHGear^ do 

1300 
begin 

1301 
Message:= 0; 

1302 
SetLittle(dX); 

1303 
dY:= _0; 

1304 
State:= State or gstMoving; 

1305 
end; 

1306 
DeleteGear(Gear); 

1307 
exit 

1308 
end; 

211  1309 

351  1310 
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then 
1133  1311 
HHGear^.X:= HHGear^.X + cWindSpeed * 200; 
211  1312 

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

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

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

211  1317 

351  1318 
HHGear^.Y:= HHGear^.Y + cGravity * 100; 
568  1319 
Gear^.X:= HHGear^.X; 
1320 
Gear^.Y:= HHGear^.Y 

263  1321 
end; 
211  1322 

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

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

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

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

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

1327 

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

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

1329 

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

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

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

1332 

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

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

1335 

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

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

1337 

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

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

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

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

1341 

263  1342 
//////////////////////////////////////////////////////////////////////////////// 
1343 
procedure doStepAirAttackWork(Gear: PGear); 

1507  1344 
var i: Longint; 
263  1345 
begin 
1346 
AllInactive:= false; 

498  1347 
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; 
1124  1348 

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

1349 
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then 
1124  1350 
begin 
1351 
dec(Gear^.Health); 

1352 
case Gear^.State of 

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

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

1586  1355 
2: for i:= 19 to 19 do 
1356 
FollowGear:= AddGear(hwRound(Gear^.X) + i div 3, hwRound(Gear^.Y), gtFlame, 0, _0_001 * i, _0, 0); 

1124  1357 
end; 
1358 
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) 

1359 
end; 

1360 

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

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

1363 

1753  1364 
if (hwRound(Gear^.X) > (LAND_WIDTH+1024)) or (hwRound(Gear^.X) < 1024) then DeleteGear(Gear) 
263  1365 
end; 
1366 

1367 
procedure doStepAirAttack(Gear: PGear); 

1368 
begin 

1369 
AllInactive:= false; 

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

1370 

1507  1371 
if Gear^.X.QWordValue = 0 then 
1771 < 