author  unc0rr 
Thu, 26 Mar 2009 13:59:27 +0000  
changeset 1918  975d5061712f 
parent 1915  c357f5b55320 
child 1919  390d3f685a80 
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; 

1918  22 
var skipSpeed, skipAngle, skipDecay: hwFloat; 
4  23 
begin 
1918  24 
// probably needs tweaking. might need to be in a case statement based upon gear type 
25 
//(not Gear^.dY.isNegative) and this should not be necessary 

498  26 
if cWaterLine < hwRound(Gear^.Y) + Gear^.Radius then 
1918  27 
begin 
28 
skipSpeed:= _0_25; // was 0.36  couldn't manage baseball bat. Tiy's build is 0.36... 

29 
skipAngle:= _1 + _0_9; // these should perhaps also be constants, once work out what proper values are 

30 
skipDecay:= _0_87; // this could perhaps be a tiny bit higher. 

31 
if ((Gear^.dX*Gear^.dX+Gear^.dY*Gear^.dY) > skipSpeed) and 

32 
(hwAbs(Gear^.dX/Gear^.dY) > skipAngle) then 

33 
begin 

34 
Gear^.dY.isNegative:= true; 

35 
Gear^.dY:=Gear^.dY*skipDecay; 

36 
Gear^.dX:=Gear^.dX*skipDecay; 

37 
CheckGearDrowning:= false 

38 
end 

39 
else 

40 
begin 

41 
CheckGearDrowning:= true; 

42 
Gear^.State:= gstDrowning; 

43 
Gear^.doStep:= @doStepDrowningGear; 

44 
end; 

45 
PlaySound(sndSplash, false, nil) 

46 
end 

47 
else 

1133  48 
CheckGearDrowning:= false 
4  49 
end; 
50 

51 
procedure CheckCollision(Gear: PGear); 

52 
begin 

351  53 
if TestCollisionXwithGear(Gear, hwSign(Gear^.X)) or TestCollisionYwithGear(Gear, hwSign(Gear^.Y)) 
1133  54 
then Gear^.State:= Gear^.State or gstCollision 
55 
else Gear^.State:= Gear^.State and not gstCollision 

4  56 
end; 
57 

58 
procedure CheckHHDamage(Gear: PGear); 

522  59 
var dmg: Longword; 
4  60 
begin 
1849  61 
if(Gear^.Invulnerable) then exit; 
522  62 
if _0_4 < Gear^.dY then 
1123  63 
begin 
64 
if _0_6 < Gear^.dY then 

1669  65 
PlaySound(sndOw4, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) 
1123  66 
else 
1669  67 
PlaySound(sndOw1, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); 
1123  68 

1861  69 
dmg:= modifyDamage(1 + hwRound((hwAbs(Gear^.dY)  _0_4) * 70)); 
1123  70 
inc(Gear^.Damage, dmg); 
1505  71 
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, dmg, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color); 
1123  72 
end 
4  73 
end; 
74 

75 
//////////////////////////////////////////////////////////////////////////////// 

76 
//////////////////////////////////////////////////////////////////////////////// 

77 
procedure CalcRotationDirAngle(Gear: PGear); 

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

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

80 
dAngle:= (hwAbs(Gear^.dX) + hwAbs(Gear^.dY)).QWordValue / $80000000; 
1133  81 
if not Gear^.dX.isNegative then 
82 
Gear^.DirAngle:= Gear^.DirAngle + dAngle 

83 
else 

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

85 

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

86 
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

87 
else if 360 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle  360 
4  88 
end; 
89 

90 
//////////////////////////////////////////////////////////////////////////////// 

91 
procedure doStepDrowningGear(Gear: PGear); 

92 
begin 

93 
AllInactive:= false; 

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

4  96 
end; 
97 

98 
//////////////////////////////////////////////////////////////////////////////// 

99 
procedure doStepFallingGear(Gear: PGear); 

542  100 
var isFalling: boolean; 
4  101 
begin 
503  102 
Gear^.State:= Gear^.State and not gstCollision; 
103 

104 
if Gear^.dY.isNegative then 

1133  105 
begin 
106 
isFalling:= true; 

107 
if TestCollisionYwithGear(Gear, 1) then 

108 
begin 

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

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

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

112 
end 

113 
end else 

114 
if TestCollisionYwithGear(Gear, 1) then 

115 
begin 

116 
isFalling:= false; 

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

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

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

120 
end else isFalling:= true; 

503  121 

351  122 
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then 
1133  123 
begin 
124 
Gear^.dX:=  Gear^.dX * Gear^.Elasticity; 

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

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

127 
end; 

503  128 

542  129 
if isFalling then Gear^.dY:= Gear^.dY + cGravity; 
503  130 

351  131 
Gear^.X:= Gear^.X + Gear^.dX; 
132 
Gear^.Y:= Gear^.Y + Gear^.dY; 

4  133 
CheckGearDrowning(Gear); 
503  134 
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and 
1133  135 
(not isFalling) then 
136 
Gear^.State:= Gear^.State and not gstMoving 

137 
else 

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

4  139 
end; 
140 

141 
//////////////////////////////////////////////////////////////////////////////// 

142 
procedure doStepBomb(Gear: PGear); 

371  143 
var i: LongInt; 
919  144 
dX, dY: hwFloat; 
4  145 
begin 
146 
AllInactive:= false; 

1263  147 

4  148 
doStepFallingGear(Gear); 
1263  149 

351  150 
dec(Gear^.Timer); 
151 
if Gear^.Timer = 0 then 

1133  152 
begin 
153 
case Gear^.Kind of 

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

1603  155 
gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 40, EXPLAutoSound); 
1133  156 
gtClusterBomb: begin 
157 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); 

158 
for i:= 0 to 4 do 

159 
begin 

160 
dX:= rndSign(GetRandom * _0_1); 

161 
dY:= (GetRandom  _3) * _0_08; 

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

164 
end; 

165 
gtWatermelon: begin 

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

167 
for i:= 0 to 5 do 

168 
begin 

169 
dX:= rndSign(GetRandom * _0_1); 

1496  170 
dY:= (GetRandom  _1_5) * _0_3; 
1262  171 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMelonPiece, 0, dX, dY, 75)^.DirAngle:= i * 60; 
1133  172 
end 
1263  173 
end; 
1555  174 
gtHellishBomb: begin 
175 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 90, EXPLAutoSound); 

176 
for i:= 0 to 127 do 

177 
begin 

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

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

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

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

182 
end 

183 
end; 

1133  184 
end; 
185 
DeleteGear(Gear); 

186 
exit 

187 
end; 

1263  188 

4  189 
CalcRotationDirAngle(Gear); 
1263  190 

191 
if Gear^.Kind = gtHellishBomb then 

1279  192 
begin 
1669  193 
if Gear^.Timer = 3000 then PlaySound(sndHellish, false, nil); 
1279  194 

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

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

1279  198 
end; 
1263  199 

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

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

1669  203 
PlaySound(sndGrenadeImpact, false, nil) 
4  204 
end; 
205 

1279  206 
procedure doStepWatermelon(Gear: PGear); 
207 
begin 

208 
AllInactive:= false; 

1669  209 
PlaySound(sndMelon, false, nil); 
1279  210 
Gear^.doStep:= @doStepBomb 
211 
end; 

212 

78  213 
procedure doStepCluster(Gear: PGear); 
214 
begin 

215 
AllInactive:= false; 

216 
doStepFallingGear(Gear); 

351  217 
if (Gear^.State and gstCollision) <> 0 then 
1133  218 
begin 
1261  219 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Timer, EXPLAutoSound); 
1133  220 
DeleteGear(Gear); 
221 
exit 

222 
end; 

1262  223 

224 
if Gear^.Kind = gtMelonPiece then 

225 
CalcRotationDirAngle(Gear) 

226 
else 

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

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

78  229 
end; 
230 

4  231 
//////////////////////////////////////////////////////////////////////////////// 
232 
procedure doStepGrenade(Gear: PGear); 

233 
begin 

234 
AllInactive:= false; 

351  235 
Gear^.dX:= Gear^.dX + cWindSpeed; 
4  236 
doStepFallingGear(Gear); 
351  237 
if (Gear^.State and gstCollision) <> 0 then 
1133  238 
begin 
239 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 

240 
DeleteGear(Gear); 

241 
exit 

242 
end; 

4  243 
if (GameTicks and $3F) = 0 then 
1133  244 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) 
4  245 
end; 
246 

247 
//////////////////////////////////////////////////////////////////////////////// 

95  248 
procedure doStepHealthTagWork(Gear: PGear); 
4  249 
begin 
522  250 
if Gear^.Kind = gtHealthTag then 
1505  251 
AllInactive:= false; 
252 

351  253 
dec(Gear^.Timer); 
522  254 
Gear^.Y:= Gear^.Y + Gear^.dY; 
1505  255 

351  256 
if Gear^.Timer = 0 then 
1133  257 
begin 
258 
if Gear^.Kind = gtHealthTag then 

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

260 
DeleteGear(Gear) 

261 
end 

4  262 
end; 
263 

263  264 
procedure doStepHealthTagWorkUnderWater(Gear: PGear); 
265 
begin 

1505  266 
AllInactive:= false; 
1495  267 

351  268 
Gear^.Y:= Gear^.Y  _0_08; 
1495  269 

498  270 
if hwRound(Gear^.Y) < cWaterLine + 10 then 
1505  271 
DeleteGear(Gear) 
263  272 
end; 
273 

95  274 
procedure doStepHealthTag(Gear: PGear); 
275 
var s: shortstring; 

276 
begin 

1505  277 
AllInactive:= false; 
278 
Gear^.dY:= _0_08; 

522  279 

351  280 
str(Gear^.State, s); 
1505  281 
Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, fnt16); 
282 

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

284 
Gear^.doStep:= @doStepHealthTagWork 

285 
else 

286 
Gear^.doStep:= @doStepHealthTagWorkUnderWater; 

287 

762  288 
Gear^.Y:= Gear^.Y  int2hwFloat(Gear^.Tex^.h) 
95  289 
end; 
290 

4  291 
//////////////////////////////////////////////////////////////////////////////// 
292 
procedure doStepGrave(Gear: PGear); 

293 
begin 

294 
AllInactive:= false; 

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

4  297 

351  298 
if not Gear^.dY.isNegative then 
68  299 
if TestCollisionY(Gear, 1) then 
4  300 
begin 
351  301 
Gear^.dY:=  Gear^.dY * Gear^.Elasticity; 
302 
if Gear^.dY >  _1div1024 then 

4  303 
begin 
351  304 
Gear^.Active:= false; 
4  305 
exit 
1669  306 
end else if Gear^.dY <  _0_03 then PlaySound(sndGraveImpact, false, nil) 
4  307 
end; 
1505  308 

351  309 
Gear^.Y:= Gear^.Y + Gear^.dY; 
4  310 
CheckGearDrowning(Gear); 
351  311 
Gear^.dY:= Gear^.dY + cGravity 
4  312 
end; 
313 

314 
//////////////////////////////////////////////////////////////////////////////// 

315 
procedure doStepUFOWork(Gear: PGear); 

351  316 
var t: hwFloat; 
374  317 
y: LongInt; 
4  318 
begin 
319 
AllInactive:= false; 

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

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

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

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

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

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

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

374  328 

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

330 
begin 

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

332 
if y + Gear^.Radius < cWaterLine then 

498  333 
AddGear(hwRound(Gear^.X), y, gtSmokeTrace, 0, _0, _0, 0); 
374  334 
end; 
335 

4  336 
CheckCollision(Gear); 
351  337 
dec(Gear^.Timer); 
338 
if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then 

4  339 
begin 
560  340 
StopSound(sndUFO); 
351  341 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 
4  342 
DeleteGear(Gear); 
343 
end; 

344 
end; 

345 

346 
procedure doStepUFO(Gear: PGear); 

347 
begin 

348 
AllInactive:= false; 

351  349 
Gear^.X:= Gear^.X + Gear^.dX; 
350 
Gear^.Y:= Gear^.Y + Gear^.dY; 

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

4  352 
CheckCollision(Gear); 
351  353 
if (Gear^.State and gstCollision) <> 0 then 
4  354 
begin 
351  355 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 
4  356 
DeleteGear(Gear); 
357 
exit 

358 
end; 

351  359 
dec(Gear^.Timer); 
360 
if Gear^.Timer = 0 then 

4  361 
begin 
1669  362 
PlaySound(sndUFO, true, nil); 
351  363 
Gear^.Timer:= 5000; 
364 
Gear^.doStep:= @doStepUFOWork 

4  365 
end; 
366 
end; 

367 

368 
//////////////////////////////////////////////////////////////////////////////// 

876  369 
procedure doStepShotIdle(Gear: PGear); 
370 
begin 

371 
AllInactive:= false; 

372 
inc(Gear^.Timer); 

373 
if Gear^.Timer > 75 then 

374 
begin 

375 
DeleteGear(Gear); 

376 
AfterAttack 

377 
end 

378 
end; 

379 

4  380 
procedure doStepShotgunShot(Gear: PGear); 
381 
var i: LongWord; 

382 
begin 

383 
AllInactive:= false; 

876  384 

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

386 
begin 

387 
dec(Gear^.Timer); 

388 
if Gear^.Timer = 0 then 

389 
begin 

1669  390 
PlaySound(sndShotgunFire, false, nil); 
876  391 
Gear^.State:= Gear^.State or gstAnimation 
392 
end; 

393 
exit 

394 
end 

395 
else inc(Gear^.Timer); 

396 

4  397 
i:= 200; 
398 
repeat 

351  399 
Gear^.X:= Gear^.X + Gear^.dX; 
400 
Gear^.Y:= Gear^.Y + Gear^.dY; 

4  401 
CheckCollision(Gear); 
351  402 
if (Gear^.State and gstCollision) <> 0 then 
876  403 
begin 
404 
Gear^.X:= Gear^.X + Gear^.dX * 8; 

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

406 
ShotgunShot(Gear); 

407 
Gear^.doStep:= @doStepShotIdle; 

408 
exit 

409 
end; 

4  410 
dec(i) 
411 
until i = 0; 

1760  412 
if (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then 
876  413 
Gear^.doStep:= @doStepShotIdle 
4  414 
end; 
415 

416 
//////////////////////////////////////////////////////////////////////////////// 

559  417 
procedure doStepDEagleShotWork(Gear: PGear); 
38  418 
var i, x, y: LongWord; 
351  419 
oX, oY: hwFloat; 
38  420 
begin 
421 
AllInactive:= false; 

876  422 
inc(Gear^.Timer); 
37  423 
i:= 80; 
351  424 
oX:= Gear^.X; 
425 
oY:= Gear^.Y; 

37  426 
repeat 
351  427 
Gear^.X:= Gear^.X + Gear^.dX; 
428 
Gear^.Y:= Gear^.Y + Gear^.dY; 

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

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

1753  431 
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) 
351  432 
and (Land[y, x] <> 0) then inc(Gear^.Damage); 
519  433 
if Gear^.Damage > 5 then AmmoShove(Gear, 7, 20); 
38  434 
dec(i) 
351  435 
until (i = 0) or (Gear^.Damage > Gear^.Health); 
436 
if Gear^.Damage > 0 then 

37  437 
begin 
351  438 
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82  i, 1); 
439 
dec(Gear^.Health, Gear^.Damage); 

440 
Gear^.Damage:= 0 

37  441 
end; 
1760  442 

443 
if (Gear^.Health <= 0) 

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

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

876  446 
Gear^.doStep:= @doStepShotIdle 
37  447 
end; 
448 

559  449 
procedure doStepDEagleShot(Gear: PGear); 
450 
begin 

1669  451 
PlaySound(sndGun, false, nil); 
559  452 
Gear^.doStep:= @doStepDEagleShotWork 
453 
end; 

454 

37  455 
//////////////////////////////////////////////////////////////////////////////// 
4  456 
procedure doStepActionTimer(Gear: PGear); 
457 
begin 

351  458 
dec(Gear^.Timer); 
459 
case Gear^.Kind of 

83  460 
gtATStartGame: begin 
4  461 
AllInactive:= false; 
351  462 
if Gear^.Timer = 0 then 
83  463 
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); 
4  464 
end; 
83  465 
gtATSmoothWindCh: begin 
351  466 
if Gear^.Timer = 0 then 
6  467 
begin 
351  468 
if WindBarWidth < Gear^.Tag then inc(WindBarWidth) 
469 
else if WindBarWidth > Gear^.Tag then dec(WindBarWidth); 

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

83  471 
end 
472 
end; 

473 
gtATFinishGame: begin 

474 
AllInactive:= false; 

351  475 
if Gear^.Timer = 0 then 
113  476 
begin 
477 
SendIPC('N'); 

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

478 
SendIPC('q'); 
83  479 
GameState:= gsExit 
113  480 
end 
6  481 
end; 
4  482 
end; 
351  483 
if Gear^.Timer = 0 then DeleteGear(Gear) 
4  484 
end; 
485 

486 
//////////////////////////////////////////////////////////////////////////////// 

487 
procedure doStepPickHammerWork(Gear: PGear); 

371  488 
var i, ei: LongInt; 
4  489 
HHGear: PGear; 
490 
begin 

70  491 
AllInactive:= false; 
351  492 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
493 
dec(Gear^.Timer); 

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

1200  495 
begin 
496 
StopSound(sndPickhammer); 

497 
DeleteGear(Gear); 

498 
AfterAttack; 

499 
exit 

500 
end; 

845  501 

422  502 
if (Gear^.Timer mod 33) = 0 then 
1200  503 
begin 
504 
HHGear^.State:= HHGear^.State or gstNoDamage; 

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

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

507 
end; 

422  508 

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

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

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

513 
while i <= ei do 

514 
begin 

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

516 
inc(i, 1) 

517 
end; 

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

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

520 
SetAllHHToActive; 

521 
end; 

4  522 
if TestCollisionYwithGear(Gear, 1) then 
1200  523 
begin 
524 
Gear^.dY:= _0; 

525 
SetLittle(HHGear^.dX); 

526 
HHGear^.dY:= _0; 

527 
end else 

528 
begin 

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

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

1417  531 
if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer:= 1 
1200  532 
end; 
4  533 

351  534 
Gear^.X:= Gear^.X + HHGear^.dX; 
535 
HHGear^.X:= Gear^.X; 

498  536 
HHGear^.Y:= Gear^.Y  int2hwFloat(cHHRadius); 
4  537 

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

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

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

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

498  543 
else Gear^.dX:= _0; 
4  544 
end; 
545 

546 
procedure doStepPickHammer(Gear: PGear); 

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

549 
HHGear: PGear; 
4  550 
begin 
551 
i:= 0; 

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

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

553 

498  554 
y:= hwRound(Gear^.Y)  cHHRadius * 2; 
351  555 
while y < hwRound(Gear^.Y) do 
4  556 
begin 
371  557 
ar[i].Left := hwRound(Gear^.X)  Gear^.Radius  LongInt(GetRandom(2)); 
558 
ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); 

4  559 
inc(y, 2); 
560 
inc(i) 

561 
end; 

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

562 

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

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

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

566 

1669  567 
PlaySound(sndPickhammer, true, nil); 
4  568 
doStepPickHammerWork(Gear); 
351  569 
Gear^.doStep:= @doStepPickHammerWork 
4  570 
end; 
571 

572 
//////////////////////////////////////////////////////////////////////////////// 

371  573 
var BTPrevAngle, BTSteps: LongInt; 
302  574 

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

575 
procedure doStepBlowTorchWork(Gear: PGear); 
302  576 
var HHGear: PGear; 
1528  577 
b: boolean; 
578 
prevX: LongInt; 

302  579 
begin 
580 
AllInactive:= false; 

351  581 
dec(Gear^.Timer); 
582 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 

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

583 

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

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

585 

305  586 
b:= false; 
587 

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

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

592 
BTPrevAngle:= HHGear^.Angle; 

593 
b:= true 

594 
end; 

595 

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

597 
begin 

598 
doStepHedgehogMoving(HHGear); 

1736  599 
if (HHGear^.State and gstHHDriven) = 0 then Gear^.Timer:= 0 
1528  600 
end; 
305  601 

351  602 
if Gear^.Timer mod cHHStepTicks = 0 then 
1528  603 
begin 
604 
b:= true; 

605 
if Gear^.dX.isNegative then 

1547  606 
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Left 
1528  607 
else 
1547  608 
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Right; 
305  609 

1528  610 
if ((HHGear^.State and gstMoving) = 0) then 
611 
begin 

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

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

614 

615 
HedgehogStep(HHGear); 

616 

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

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

619 
end; 

305  620 

1528  621 
inc(BTSteps); 
622 
if BTSteps = 7 then 

623 
begin 

624 
BTSteps:= 0; 

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

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

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

1643  628 
AmmoShove(Gear, 2, 15); 
1528  629 
HHGear^.State:= HHGear^.State and not gstNoDamage 
630 
end; 

631 
end; 

305  632 

633 
if b then 

498  634 
DrawTunnel(HHGear^.X  Gear^.dX * cHHRadius, HHGear^.Y  _4  Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, 
351  635 
Gear^.dX, Gear^.dY, 
1501  636 
cHHRadius * 5, cHHRadius * 2 + 7); 
305  637 

1784  638 
if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) or (Land[hwRound(HHGear^.Y), hwRound(HHGear^.X + Gear^.dX * 32)] = COLOR_INDESTRUCTIBLE) then 
1528  639 
begin 
640 
HHGear^.Message:= 0; 

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

642 
DeleteGear(Gear); 

643 
AfterAttack 

644 
end 

302  645 
end; 
646 

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

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

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

649 
begin 
371  650 
BTPrevAngle:= High(LongInt); 
305  651 
BTSteps:= 0; 
351  652 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
653 
HHGear^.Message:= 0; 

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

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

657 

302  658 
//////////////////////////////////////////////////////////////////////////////// 
659 

1781  660 
procedure doStepRope(Gear: PGear); forward; 
661 

662 
procedure doStepRopeAfterAttack(Gear: PGear); 

663 
var HHGear: PGear; 

664 
begin 

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

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

667 
or (CheckGearDrowning(HHGear)) 

668 
or TestCollisionYwithGear(HHGear, 1) then 

669 
begin 

670 
DeleteGear(Gear); 

671 
exit 

672 
end; 

673 

1785  674 
HedgehogChAngle(HHGear); 
675 

1781  676 
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); 
677 
if HHGear^.dY.isNegative and TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= _0; 

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

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

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

681 

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

683 
begin 

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

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

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

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

688 
Gear^.Friction:= _450; 

689 
Gear^.Elasticity:= _0; 

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

691 
Gear^.doStep:= @doStepRope 

692 
end 

693 
end; 

694 

4  695 
procedure doStepRopeWork(Gear: PGear); 
696 
var HHGear: PGear; 

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

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

700 
haveDivided: boolean; 
4  701 

1504  702 
procedure DeleteMe; 
703 
begin 

704 
with HHGear^ do 

705 
begin 

706 
Message:= Message and not gm_Attack; 

707 
State:= State or gstMoving; 

1892  708 
State:= State and not gstWinner; 
1504  709 
end; 
710 
DeleteGear(Gear) 

711 
end; 

4  712 

1781  713 
procedure WaitCollision; 
714 
begin 

715 
with HHGear^ do 

716 
begin 

717 
Message:= Message and not gm_Attack; 

718 
State:= State or gstMoving; 

719 
end; 

720 
RopePoints.Count:= 0; 

721 
Gear^.Elasticity:= _0; 

722 
Gear^.doStep:= @doStepRopeAfterAttack 

723 
end; 

724 

4  725 
begin 
351  726 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
108  727 

351  728 
if ((HHGear^.State and gstHHDriven) = 0) 
1504  729 
or (CheckGearDrowning(HHGear)) then 
730 
begin 

731 
DeleteMe; 

732 
exit 

733 
end; 

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

734 

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

4  737 

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

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

742 

743 
mdX:= ropeDx + HHGear^.dX; 

744 
mdY:= ropeDy + HHGear^.dY; 

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

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

747 
mdY:= mdY * len; 

748 

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

750 
Gear^.dY:= mdY; 

751 

752 
///// 

753 
tx:= HHGear^.X; 

754 
ty:= HHGear^.Y; 

4  755 

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

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

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

760 

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

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

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

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

765 

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

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

768 

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

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

771 
//// 

772 

1554  773 

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

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

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

776 
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

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

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

779 

1652  780 
len:= Gear^.Elasticity  _0_3x70; 
781 
while len > _0_3 do 

1504  782 
begin 
1652  783 
lx:= hwRound(Gear^.X + mdX * len); 
784 
ly:= hwRound(Gear^.Y + mdY * len); 

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

788 
begin 

789 
X:= Gear^.X; 

790 
Y:= Gear^.Y; 

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

791 
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); 
1652  792 
b:= (nx * HHGear^.dY) > (ny * HHGear^.dX); 
1504  793 
dLen:= len 
794 
end; 

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

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

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

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

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

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

801 
haveDivided:= true; 
1504  802 
break 
803 
end; 

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

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

806 

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

807 
if not haveDivided then 
1504  808 
if RopePoints.Count > 0 then // check whether the last dividing point could be removed 
809 
begin 

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

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

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

813 
begin 

814 
dec(RopePoints.Count); 

1652  815 
Gear^.X:= RopePoints.ar[RopePoints.Count].X; 
816 
Gear^.Y:= RopePoints.ar[RopePoints.Count].Y; 

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

819 
end 

820 
end; 

4  821 

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

822 
haveCollision:= false; 
351  823 
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

824 
begin 
1504  825 
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

826 
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

827 
end; 
351  828 
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

829 
begin 
1504  830 
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

831 
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

832 
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

833 

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

834 
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

835 
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

836 
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

837 
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

838 
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

839 
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

840 
end; 
4  841 

789  842 
len:= Distance(HHGear^.dX, HHGear^.dY); 
940  843 
if len > _0_8 then 
1504  844 
begin 
845 
len:= _0_8 / len; 

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

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

848 
end; 

789  849 

351  850 
if (Gear^.Message and gm_Attack) <> 0 then 
1504  851 
if (Gear^.State and gsttmpFlag) <> 0 then 
1781  852 
WaitCollision 
1504  853 
else 
854 
else 

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

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

4  857 
end; 
858 

859 
procedure doStepRopeAttach(Gear: PGear); 

860 
var HHGear: PGear; 

1781  861 
tx, ty, tt: hwFloat; 
862 

863 
procedure RemoveFromAmmo; 

864 
begin 

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

866 
begin 

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

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

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

870 
end 

871 
end; 

872 

4  873 
begin 
351  874 
Gear^.X:= Gear^.X  Gear^.dX; 
875 
Gear^.Y:= Gear^.Y  Gear^.dY; 

498  876 
Gear^.Elasticity:= Gear^.Elasticity + _1; 
351  877 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
517  878 
DeleteCI(HHGear); 
542  879 
if (HHGear^.State and gstMoving) <> 0 then 
1433  880 
if TestCollisionYwithGear(HHGear, 1) then 
881 
begin 

882 
CheckHHDamage(HHGear); 

883 
HHGear^.dY:= _0; 

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

885 
end else 

886 
begin 

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

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

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

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

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

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

893 
tt:= Gear^.Elasticity; 

894 
tx:= _0; 

895 
ty:= _0; 

896 
while tt > _20 do 

897 
begin 

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

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

900 
begin 

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

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

903 
Gear^.Elasticity:= tt; 

904 
Gear^.doStep:= @doStepRopeWork; 

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

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

907 
RemoveFromAmmo; 

908 

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

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

910 
exit 
1433  911 
end; 
912 
tx:= tx + Gear^.dX + Gear^.dX; 

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

914 
tt:= tt  _2; 

915 
end; 

916 
end; 

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

917 

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

919 

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

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

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

923 
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

924 

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

926 

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

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

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

929 
end; 
4  930 

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

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

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

933 
or (HHGear^.Damage > 0) then 
1433  934 
begin 
935 
with PHedgehog(Gear^.Hedgehog)^.Gear^ do 

936 
begin 

937 
State:= State and not gstAttacking; 

938 
Message:= Message and not gm_Attack 

939 
end; 

940 
DeleteGear(Gear) 

941 
end 

4  942 
end; 
943 

944 
procedure doStepRope(Gear: PGear); 

945 
begin 

351  946 
Gear^.dX:=  Gear^.dX; 
947 
Gear^.dY:=  Gear^.dY; 

948 
Gear^.doStep:= @doStepRopeAttach 

4  949 
end; 
950 

951 
//////////////////////////////////////////////////////////////////////////////// 

952 
procedure doStepSmokeTrace(Gear: PGear); 

953 
begin 

351  954 
inc(Gear^.Timer); 
955 
if Gear^.Timer > 64 then 

1133  956 
begin 
957 
Gear^.Timer:= 0; 

958 
dec(Gear^.State) 

959 
end; 

351  960 
Gear^.dX:= Gear^.dX + cWindSpeed; 
961 
Gear^.X:= Gear^.X + Gear^.dX; 

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

4  963 
end; 
9  964 

965 
//////////////////////////////////////////////////////////////////////////////// 

1045  966 
procedure doStepExplosionWork(Gear: PGear); 
9  967 
begin 
351  968 
inc(Gear^.Timer); 
969 
if Gear^.Timer > 75 then 

1133  970 
begin 
971 
inc(Gear^.State); 

972 
Gear^.Timer:= 0; 

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

974 
end; 

9  975 
end; 
10  976 

1045  977 
procedure doStepExplosion(Gear: PGear); 
978 
var i: LongWord; 

979 
begin 

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

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

1045  983 
Gear^.doStep:= @doStepExplosionWork 
984 
end; 

985 

10  986 
//////////////////////////////////////////////////////////////////////////////// 
987 
procedure doStepMine(Gear: PGear); 

988 
begin 

542  989 
if (Gear^.State and gstMoving) <> 0 then 
914  990 
begin 
991 
DeleteCI(Gear); 

992 
doStepFallingGear(Gear); 

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

994 
begin 

995 
AddGearCI(Gear); 

996 
Gear^.dX:= _0; 

997 
Gear^.dY:= _0 

998 
end; 

999 
CalcRotationDirAngle(Gear); 

1000 
AllInactive:= false 

1001 
end else 

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

1003 
doStepFallingGear(Gear); 

351  1004 

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

1133  1006 
if ((Gear^.State and gstAttacking) = 0) then 
1007 
begin 

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

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

1010 
end else // gstAttacking <> 0 

1011 
begin 

1012 
AllInactive:= false; 

1669  1013 
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false, nil); 
1133  1014 
if Gear^.Timer = 0 then 
1015 
begin 

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

1017 
DeleteGear(Gear); 

1018 
exit 

1019 
end; 

1020 
dec(Gear^.Timer); 

1021 
end else // gsttmpFlag = 0 

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

10  1023 
end; 
57  1024 

39  1025 
//////////////////////////////////////////////////////////////////////////////// 
1026 
procedure doStepDynamite(Gear: PGear); 

1027 
begin 

43  1028 
doStepFallingGear(Gear); 
1029 
AllInactive:= false; 

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

1133  1032 
begin 
1033 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); 

1034 
DeleteGear(Gear); 

1035 
exit 

1036 
end; 

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

1039 

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

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

1044 
begin 
351  1045 
if (Gear^.Message and gm_Destroy) > 0 then 
1133  1046 
begin 
1047 
DeleteGear(Gear); 

1048 
FreeActionsList; 

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

1050 
with CurrentHedgehog^ do 

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

1052 
exit 

1053 
end; 

15  1054 

351  1055 
if Gear^.Damage > 0 then 
1133  1056 
begin 
1057 
x:= hwRound(Gear^.X); 

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

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

1061 

1062 
if k = gtCase then 

1133  1063 
begin 
1064 
doMakeExplosion(x, y, 25, EXPLAutoSound); 

1065 
for i:= 0 to 63 do 

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

1067 
end; 

1068 
exit 

1069 
end; 

79  1070 

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

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

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

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

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

1078 
begin 

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

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

1669  1081 
else if Gear^.dY <  _0_03 then PlaySound(sndGraveImpact, false, nil); 
1133  1082 
end; 
1083 
CheckGearDrowning(Gear); 

1084 
end; 

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

1085 

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

1088 
end; 
49  1089 

1090 
//////////////////////////////////////////////////////////////////////////////// 

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

1133  1093 
record 
1094 
dy, ny, dw: LongInt; 

1095 
team: PTeam; 

1096 
SortFactor: QWord; 

1097 
end; 

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

1098 
currsorter: PGear = nil; 
49  1099 

1100 
procedure doStepTeamHealthSorterWork(Gear: PGear); 

371  1101 
var i: LongInt; 
49  1102 
begin 
1103 
AllInactive:= false; 

351  1104 
dec(Gear^.Timer); 
1105 
if (Gear^.Timer and 15) = 0 then 

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

1108 
begin 

1109 
{$WARNINGS OFF} 

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

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

1112 
{$WARNINGS ON} 

1113 
end; 

1114 

351  1115 
if (Gear^.Timer = 0) or (currsorter <> Gear) then 
1133  1116 
begin 
1117 
if currsorter = Gear then currsorter:= nil; 

1118 
DeleteGear(Gear) 

1119 
end 

49  1120 
end; 
1121 

1122 
procedure doStepTeamHealthSorter(Gear: PGear); 

1133  1123 
var i: Longword; 
1124 
b: boolean; 

1125 
t: LongInt; 

49  1126 
begin 
1127 
AllInactive:= false; 

557  1128 

547  1129 
for t:= 0 to Pred(TeamsCount) do 
1133  1130 
with thexchar[t] do 
1131 
begin 

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

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

1134 
team:= TeamsArray[t]; 

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

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

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

1138 
end; 

547  1139 

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

1140 
if TeamsCount > 1 then 
1133  1141 
repeat 
1142 
b:= true; 

1143 
for t:= 0 to TeamsCount  2 do 

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

1145 
begin 

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

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

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

1149 
b:= false 

1150 
end 

1151 
until b; 

557  1152 

1120  1153 
t:=  4; 
557  1154 
for i:= 0 to Pred(TeamsCount) do 
1133  1155 
with thexchar[i] do 
1156 
begin 

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

1158 
ny:= t; 

1159 
dy:= dy  ny 

1160 
end; 

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

1161 

557  1162 
Gear^.Timer:= cSorterWorkTime; 
351  1163 
Gear^.doStep:= @doStepTeamHealthSorterWork; 
143  1164 
currsorter:= Gear 
49  1165 
end; 
1166 

79  1167 
//////////////////////////////////////////////////////////////////////////////// 
854  1168 
procedure doStepIdle(Gear: PGear); 
1169 
begin 

1170 
AllInactive:= false; 

925  1171 
dec(Gear^.Timer); 
854  1172 
if Gear^.Timer = 0 then 
1173 
begin 

1174 
DeleteGear(Gear); 

1175 
AfterAttack 

1176 
end 

1177 
end; 

1178 

79  1179 
procedure doStepShover(Gear: PGear); 
1180 
var HHGear: PGear; 

1181 
begin 

351  1182 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
1183 
HHGear^.State:= HHGear^.State or gstNoDamage; 

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

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

1185 

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

1187 

351  1188 
HHGear^.State:= HHGear^.State and not gstNoDamage; 
854  1189 
Gear^.Timer:= 250; 
1190 
Gear^.doStep:= @doStepIdle 

79  1191 
end; 
1192 

1193 
//////////////////////////////////////////////////////////////////////////////// 

925  1194 
procedure doStepWhip(Gear: PGear); 
1195 
var HHGear: PGear; 

1196 
i: LongInt; 

1197 
begin 

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

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

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

1200 
DeleteCI(HHGear); 
925  1201 

1202 
for i:= 0 to 3 do 

1203 
begin 

1204 
AmmoShove(Gear, 30, 25); 

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

1206 
end; 

1207 

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

1209 
Gear^.Timer:= 250; 

1210 
Gear^.doStep:= @doStepIdle 

1211 
end; 

1212 

1213 
//////////////////////////////////////////////////////////////////////////////// 

79  1214 
procedure doStepFlame(Gear: PGear); 
1215 
begin 

1216 
AllInactive:= false; 

1433  1217 

79  1218 
if not TestCollisionYwithGear(Gear, 1) then 
1133  1219 
begin 
1586  1220 
if hwAbs(Gear^.dX) > _0_01 then 
1221 
Gear^.dX:= Gear^.dX * _0_995; 

1297  1222 

1133  1223 
Gear^.dY:= Gear^.dY + cGravity; 
1830  1224 
if hwAbs(Gear^.dY) > _0_2 then Gear^.dY:= Gear^.dY * _0_995; 
1297  1225 

1830  1226 
Gear^.X:= Gear^.X + Gear^.dX + cWindSpeed * 640; 
1133  1227 
Gear^.Y:= Gear^.Y + Gear^.dY; 
1297  1228 

1417  1229 
if not (hwRound(Gear^.Y) < cWaterLine) then 
1133  1230 
begin 
1231 
DeleteGear(Gear); 

1232 
exit 

1233 
end 

1234 
end else begin 

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

1236 
else begin 

1586  1237 
Gear^.Radius:= 9; 
1238 
AmmoShove(Gear, 4, 100); 

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

1133  1241 
dec(Gear^.Health); 
1586  1242 
Gear^.Timer:= 450  Gear^.Tag * 8 
1133  1243 
end 
1244 
end; 

79  1245 

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

79  1248 

351  1249 
if Gear^.Health = 0 then 
1133  1250 
DeleteGear(Gear) 
79  1251 
end; 
82  1252 

1253 
//////////////////////////////////////////////////////////////////////////////// 

1254 
procedure doStepFirePunchWork(Gear: PGear); 

1255 
var HHGear: PGear; 

1256 
begin 

1257 
AllInactive:= false; 

351  1258 
if ((Gear^.Message and gm_Destroy) <> 0) then 
1133  1259 
begin 
1260 
DeleteGear(Gear); 

1261 
AfterAttack; 

1262 
exit 

1263 
end; 

82  1264 

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

1133  1267 
begin 
1268 
Gear^.Tag:= hwRound(HHGear^.Y); 

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

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

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

1272 
AmmoShove(Gear, 30, 40); 

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

1274 
end; 

351  1275 

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

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

1133  1278 
begin 
1279 
HHGear^.State:= HHGear^.State or gstMoving; 

1280 
DeleteGear(Gear); 

1281 
AfterAttack; 

1282 
exit 

1283 
end; 

351  1284 
HHGear^.Y:= HHGear^.Y + HHGear^.dY 
82  1285 
end; 
1286 

1287 
procedure doStepFirePunch(Gear: PGear); 

1288 
var HHGear: PGear; 

1289 
begin 

1290 
AllInactive:= false; 

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

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

1295 

351  1296 
HHGear^.dY:=  _0_3; 
82  1297 

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

1299 
Gear^.dX:= SignAs(_0_45, Gear^.dX); 
351  1300 
Gear^.dY:=  _0_9; 
1301 
Gear^.doStep:= @doStepFirePunchWork; 

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

1669  1304 
PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false, PHedgehog(HHGear^.Hedgehog)^.Team^.voicepack) 
82  1305 
end; 
1306 

263  1307 
//////////////////////////////////////////////////////////////////////////////// 
1308 

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

1309 
procedure doStepParachuteWork(Gear: PGear); 
211  1310 
var HHGear: PGear; 
1311 
begin 

351  1312 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
82  1313 

516  1314 
inc(Gear^.Timer); 
1315 

212  1316 
if TestCollisionYwithGear(HHGear, 1) 
1133  1317 
or ((HHGear^.State and gstHHDriven) = 0) 
1318 
or CheckGearDrowning(HHGear) 

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

1320 
begin 

1321 
with HHGear^ do 

1322 
begin 

1323 
Message:= 0; 

1324 
SetLittle(dX); 

1325 
dY:= _0; 

1326 
State:= State or gstMoving; 

1327 
end; 

1328 
DeleteGear(Gear); 

1329 
exit 

1330 
end; 

211  1331 

351  1332 
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then 
1133  1333 
HHGear^.X:= HHGear^.X + cWindSpeed * 200; 
211  1334 

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

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

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

211  1339 

351  1340 
HHGear^.Y:= HHGear^.Y + cGravity * 100; 
568  1341 
Gear^.X:= HHGear^.X; 
1342 
Gear^.Y:= HHGear^.Y 

263  1343 
end; 
211  1344 

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

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

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

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

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

1349 

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

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

1351 

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

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

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

1354 

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

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

1357 

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

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

1359 

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

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

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

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

1363 

263  1364 
//////////////////////////////////////////////////////////////////////////////// 
1365 
procedure doStepAirAttackWork(Gear: PGear); 

1507  1366 
var i: Longint; 
263  1367 
begin 
1368 
AllInactive:= false; 

498  1369 
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; 
1124  1370 

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

1371 
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then 
1124
