author  nemo 
Tue, 25 Aug 2009 20:54:11 +0000  
changeset 2331  e4941a7986d6 
parent 2329  1cfb7d184ee1 
child 2339  f1bbcca1ae07 
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. 

1919  31 
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > skipSpeed) and 
1920  32 
(hwAbs(Gear^.dX) > skipAngle * hwAbs(Gear^.dY)) then 
1918  33 
begin 
34 
Gear^.dY.isNegative:= true; 

1919  35 
Gear^.dY:= Gear^.dY * skipDecay; 
36 
Gear^.dX:= Gear^.dX * skipDecay; 

1918  37 
CheckGearDrowning:= false 
38 
end 

39 
else 

40 
begin 

41 
CheckGearDrowning:= true; 

42 
Gear^.State:= gstDrowning; 

43 
Gear^.doStep:= @doStepDrowningGear; 

2142  44 
if Gear^.Kind = gtHedgehog then AddCaption(Format(GetEventString(eidDrowned), PHedgehog(Gear^.Hedgehog)^.Name), $FFFFFF, capgrpMessage); 
1918  45 
end; 
46 
PlaySound(sndSplash, false, nil) 

47 
end 

48 
else 

1133  49 
CheckGearDrowning:= false 
4  50 
end; 
51 

52 
procedure CheckCollision(Gear: PGear); 

53 
begin 

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

4  57 
end; 
58 

59 
procedure CheckHHDamage(Gear: PGear); 

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

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

1861  70 
dmg:= modifyDamage(1 + hwRound((hwAbs(Gear^.dY)  _0_4) * 70)); 
2017  71 
ApplyDamage(Gear, dmg); 
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; 
2228  95 
Gear^.X:= Gear^.X + Gear^.dX * cDrownSpeed; 
2143
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
2142
diff
changeset

96 
if hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear); 
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
2142
diff
changeset

97 
// Create some bubbles (0.5% might be better but causes too few bubbles sometimes) 
2225  98 
if (GameTicks and $1F) = 0 then 
99 
if (Gear^.Kind = gtHedgehog) and (Random(4) = 0) then 

100 
AddVisualGear(hwRound(Gear^.X)  Gear^.Radius, hwRound(Gear^.Y)  Gear^.Radius, vgtBubble) 

101 
else if Random(12) = 0 then 

102 
AddVisualGear(hwRound(Gear^.X)  Gear^.Radius, hwRound(Gear^.Y)  Gear^.Radius, vgtBubble) 

4  103 
end; 
104 

105 
//////////////////////////////////////////////////////////////////////////////// 

106 
procedure doStepFallingGear(Gear: PGear); 

542  107 
var isFalling: boolean; 
4  108 
begin 
503  109 
Gear^.State:= Gear^.State and not gstCollision; 
110 

111 
if Gear^.dY.isNegative then 

1133  112 
begin 
113 
isFalling:= true; 

114 
if TestCollisionYwithGear(Gear, 1) then 

115 
begin 

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

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

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

119 
end 

120 
end else 

121 
if TestCollisionYwithGear(Gear, 1) then 

122 
begin 

123 
isFalling:= false; 

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

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

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

127 
end else isFalling:= true; 

503  128 

351  129 
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then 
1133  130 
begin 
131 
Gear^.dX:=  Gear^.dX * Gear^.Elasticity; 

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

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

134 
end; 

503  135 

542  136 
if isFalling then Gear^.dY:= Gear^.dY + cGravity; 
503  137 

351  138 
Gear^.X:= Gear^.X + Gear^.dX; 
139 
Gear^.Y:= Gear^.Y + Gear^.dY; 

4  140 
CheckGearDrowning(Gear); 
503  141 
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and 
1133  142 
(not isFalling) then 
143 
Gear^.State:= Gear^.State and not gstMoving 

144 
else 

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

4  146 
end; 
147 

148 
//////////////////////////////////////////////////////////////////////////////// 

149 
procedure doStepBomb(Gear: PGear); 

371  150 
var i: LongInt; 
919  151 
dX, dY: hwFloat; 
4  152 
begin 
153 
AllInactive:= false; 

1263  154 

4  155 
doStepFallingGear(Gear); 
1263  156 

351  157 
dec(Gear^.Timer); 
158 
if Gear^.Timer = 0 then 

1133  159 
begin 
160 
case Gear^.Kind of 

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

1603  162 
gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 40, EXPLAutoSound); 
1133  163 
gtClusterBomb: begin 
164 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); 

165 
for i:= 0 to 4 do 

166 
begin 

167 
dX:= rndSign(GetRandom * _0_1); 

168 
dY:= (GetRandom  _3) * _0_08; 

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

171 
end; 

172 
gtWatermelon: begin 

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

174 
for i:= 0 to 5 do 

175 
begin 

176 
dX:= rndSign(GetRandom * _0_1); 

1496  177 
dY:= (GetRandom  _1_5) * _0_3; 
1262  178 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMelonPiece, 0, dX, dY, 75)^.DirAngle:= i * 60; 
1133  179 
end 
1263  180 
end; 
1555  181 
gtHellishBomb: begin 
182 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 90, EXPLAutoSound); 

183 
for i:= 0 to 127 do 

184 
begin 

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

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

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

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

189 
end 

190 
end; 

1133  191 
end; 
192 
DeleteGear(Gear); 

193 
exit 

194 
end; 

1263  195 

4  196 
CalcRotationDirAngle(Gear); 
1263  197 

198 
if Gear^.Kind = gtHellishBomb then 

1279  199 
begin 
1669  200 
if Gear^.Timer = 3000 then PlaySound(sndHellish, false, nil); 
1279  201 

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

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

1279  205 
end; 
1263  206 

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

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

1669  210 
PlaySound(sndGrenadeImpact, false, nil) 
4  211 
end; 
212 

1279  213 
procedure doStepWatermelon(Gear: PGear); 
214 
begin 

215 
AllInactive:= false; 

1669  216 
PlaySound(sndMelon, false, nil); 
1279  217 
Gear^.doStep:= @doStepBomb 
218 
end; 

219 

78  220 
procedure doStepCluster(Gear: PGear); 
221 
begin 

222 
AllInactive:= false; 

223 
doStepFallingGear(Gear); 

351  224 
if (Gear^.State and gstCollision) <> 0 then 
1133  225 
begin 
1261  226 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Timer, EXPLAutoSound); 
1133  227 
DeleteGear(Gear); 
228 
exit 

229 
end; 

1262  230 

231 
if Gear^.Kind = gtMelonPiece then 

232 
CalcRotationDirAngle(Gear) 

233 
else 

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

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

78  236 
end; 
237 

4  238 
//////////////////////////////////////////////////////////////////////////////// 
239 
procedure doStepGrenade(Gear: PGear); 

240 
begin 

241 
AllInactive:= false; 

351  242 
Gear^.dX:= Gear^.dX + cWindSpeed; 
4  243 
doStepFallingGear(Gear); 
351  244 
if (Gear^.State and gstCollision) <> 0 then 
1133  245 
begin 
246 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 

247 
DeleteGear(Gear); 

248 
exit 

249 
end; 

4  250 
if (GameTicks and $3F) = 0 then 
1133  251 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) 
4  252 
end; 
253 

254 
//////////////////////////////////////////////////////////////////////////////// 

95  255 
procedure doStepHealthTagWork(Gear: PGear); 
4  256 
begin 
522  257 
if Gear^.Kind = gtHealthTag then 
1505  258 
AllInactive:= false; 
259 

351  260 
dec(Gear^.Timer); 
522  261 
Gear^.Y:= Gear^.Y + Gear^.dY; 
1505  262 

351  263 
if Gear^.Timer = 0 then 
1133  264 
begin 
2017  265 
if (Gear^.Kind = gtHealthTag) and (PHedgehog(Gear^.Hedgehog)^.Gear <> nil) then 
1133  266 
PHedgehog(Gear^.Hedgehog)^.Gear^.Active:= true; // to let current hh die 
267 
DeleteGear(Gear) 

268 
end 

4  269 
end; 
270 

263  271 
procedure doStepHealthTagWorkUnderWater(Gear: PGear); 
272 
begin 

1505  273 
AllInactive:= false; 
1495  274 

351  275 
Gear^.Y:= Gear^.Y  _0_08; 
1495  276 

498  277 
if hwRound(Gear^.Y) < cWaterLine + 10 then 
1505  278 
DeleteGear(Gear) 
263  279 
end; 
280 

95  281 
procedure doStepHealthTag(Gear: PGear); 
282 
var s: shortstring; 

283 
begin 

1505  284 
AllInactive:= false; 
285 
Gear^.dY:= _0_08; 

522  286 

351  287 
str(Gear^.State, s); 
1505  288 
Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, fnt16); 
289 

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

291 
Gear^.doStep:= @doStepHealthTagWork 

292 
else 

293 
Gear^.doStep:= @doStepHealthTagWorkUnderWater; 

294 

762  295 
Gear^.Y:= Gear^.Y  int2hwFloat(Gear^.Tex^.h) 
95  296 
end; 
297 

4  298 
//////////////////////////////////////////////////////////////////////////////// 
299 
procedure doStepGrave(Gear: PGear); 

300 
begin 

301 
AllInactive:= false; 

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

4  304 

351  305 
if not Gear^.dY.isNegative then 
68  306 
if TestCollisionY(Gear, 1) then 
4  307 
begin 
351  308 
Gear^.dY:=  Gear^.dY * Gear^.Elasticity; 
309 
if Gear^.dY >  _1div1024 then 

4  310 
begin 
351  311 
Gear^.Active:= false; 
4  312 
exit 
1669  313 
end else if Gear^.dY <  _0_03 then PlaySound(sndGraveImpact, false, nil) 
4  314 
end; 
1505  315 

351  316 
Gear^.Y:= Gear^.Y + Gear^.dY; 
4  317 
CheckGearDrowning(Gear); 
351  318 
Gear^.dY:= Gear^.dY + cGravity 
4  319 
end; 
320 

321 
//////////////////////////////////////////////////////////////////////////////// 

322 
procedure doStepUFOWork(Gear: PGear); 

351  323 
var t: hwFloat; 
374  324 
y: LongInt; 
4  325 
begin 
326 
AllInactive:= false; 

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

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

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

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

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

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

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

374  335 

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

337 
begin 

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

339 
if y + Gear^.Radius < cWaterLine then 

498  340 
AddGear(hwRound(Gear^.X), y, gtSmokeTrace, 0, _0, _0, 0); 
374  341 
end; 
342 

4  343 
CheckCollision(Gear); 
351  344 
dec(Gear^.Timer); 
345 
if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then 

4  346 
begin 
560  347 
StopSound(sndUFO); 
351  348 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 
4  349 
DeleteGear(Gear); 
350 
end; 

351 
end; 

352 

353 
procedure doStepUFO(Gear: PGear); 

354 
begin 

355 
AllInactive:= false; 

351  356 
Gear^.X:= Gear^.X + Gear^.dX; 
357 
Gear^.Y:= Gear^.Y + Gear^.dY; 

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

4  359 
CheckCollision(Gear); 
351  360 
if (Gear^.State and gstCollision) <> 0 then 
4  361 
begin 
351  362 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 
4  363 
DeleteGear(Gear); 
364 
exit 

365 
end; 

351  366 
dec(Gear^.Timer); 
367 
if Gear^.Timer = 0 then 

4  368 
begin 
1669  369 
PlaySound(sndUFO, true, nil); 
351  370 
Gear^.Timer:= 5000; 
371 
Gear^.doStep:= @doStepUFOWork 

4  372 
end; 
373 
end; 

374 

375 
//////////////////////////////////////////////////////////////////////////////// 

876  376 
procedure doStepShotIdle(Gear: PGear); 
377 
begin 

378 
AllInactive:= false; 

379 
inc(Gear^.Timer); 

380 
if Gear^.Timer > 75 then 

381 
begin 

382 
DeleteGear(Gear); 

383 
AfterAttack 

384 
end 

385 
end; 

386 

4  387 
procedure doStepShotgunShot(Gear: PGear); 
388 
var i: LongWord; 

389 
begin 

390 
AllInactive:= false; 

876  391 

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

393 
begin 

394 
dec(Gear^.Timer); 

395 
if Gear^.Timer = 0 then 

396 
begin 

1669  397 
PlaySound(sndShotgunFire, false, nil); 
876  398 
Gear^.State:= Gear^.State or gstAnimation 
399 
end; 

400 
exit 

401 
end 

402 
else inc(Gear^.Timer); 

403 

4  404 
i:= 200; 
405 
repeat 

351  406 
Gear^.X:= Gear^.X + Gear^.dX; 
407 
Gear^.Y:= Gear^.Y + Gear^.dY; 

4  408 
CheckCollision(Gear); 
351  409 
if (Gear^.State and gstCollision) <> 0 then 
876  410 
begin 
411 
Gear^.X:= Gear^.X + Gear^.dX * 8; 

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

413 
ShotgunShot(Gear); 

414 
Gear^.doStep:= @doStepShotIdle; 

415 
exit 

416 
end; 

4  417 
dec(i) 
418 
until i = 0; 

1760  419 
if (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then 
876  420 
Gear^.doStep:= @doStepShotIdle 
4  421 
end; 
422 

423 
//////////////////////////////////////////////////////////////////////////////// 

2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

424 
procedure doStepBulletWork(Gear: PGear); 
38  425 
var i, x, y: LongWord; 
351  426 
oX, oY: hwFloat; 
38  427 
begin 
428 
AllInactive:= false; 

876  429 
inc(Gear^.Timer); 
37  430 
i:= 80; 
351  431 
oX:= Gear^.X; 
432 
oY:= Gear^.Y; 

37  433 
repeat 
351  434 
Gear^.X:= Gear^.X + Gear^.dX; 
435 
Gear^.Y:= Gear^.Y + Gear^.dY; 

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

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

1753  438 
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) 
351  439 
and (Land[y, x] <> 0) then inc(Gear^.Damage); 
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

440 
if Gear^.Damage > 5 then 
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

441 
if Gear^.Ammo^.AmmoType = amDEagle then 
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

442 
AmmoShove(Gear, 7, 20) 
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

443 
else 
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

444 
AmmoShove(Gear, Gear^.Timer, 20); 
38  445 
dec(i) 
351  446 
until (i = 0) or (Gear^.Damage > Gear^.Health); 
447 
if Gear^.Damage > 0 then 

37  448 
begin 
351  449 
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82  i, 1); 
450 
dec(Gear^.Health, Gear^.Damage); 

451 
Gear^.Damage:= 0 

37  452 
end; 
1760  453 

454 
if (Gear^.Health <= 0) 

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

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

2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

457 
begin 
2087  458 
if (Gear^.Kind = gtSniperRifleShot) and ((GameFlags and gfLaserSight) = 0) then cLaserSighting:= false; 
2033  459 
if (Gear^.Ammo^.NumPerTurn <= CurrentHedgehog^.AttacksNum) and 
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

460 
((GameFlags and gfArtillery) = 0) then cArtillery:= false; 
876  461 
Gear^.doStep:= @doStepShotIdle 
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

462 
end; 
37  463 
end; 
464 

559  465 
procedure doStepDEagleShot(Gear: PGear); 
466 
begin 

1669  467 
PlaySound(sndGun, false, nil); 
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

468 
Gear^.doStep:= @doStepBulletWork 
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

469 
end; 
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

470 

41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

471 
procedure doStepSniperRifleShot(Gear: PGear); 
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

472 
var HHGear: PGear; 
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

473 
begin 
2024
2985f3bd18b7
Disable long jump in artillery mode, make snipre rifle single shot
nemo
parents:
2023
diff
changeset

474 
cArtillery:= true; 
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

475 
HHGear:=PHedgehog(Gear^.Hedgehog)^.Gear; 
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

476 
HHGear^.State:= HHGear^.State or gstNotKickable; 
2033  477 
HedgehogChAngle(HHGear); 
2220  478 
if not cLaserSighting then // game does not have default laser sight. turn it on and give them a chance to aim 
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

479 
begin 
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

480 
cLaserSighting:= true; 
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

481 
HHGear^.Message:= 0; 
2052  482 
if(HHGear^.Angle  32 >= 0) then dec(HHGear^.Angle,32) 
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

483 
end; 
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

484 

b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

485 
if (HHGear^.Message and gm_Attack) <> 0 then 
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

486 
begin 
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

487 
Gear^.State:= Gear^.State or gstAnimation; 
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

488 
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _0_5; 
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

489 
Gear^.dY:= AngleCos(HHGear^.Angle) * _0_5; 
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

490 
PlaySound(sndGun, false, nil); 
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

491 
Gear^.doStep:= @doStepBulletWork; 
2024
2985f3bd18b7
Disable long jump in artillery mode, make snipre rifle single shot
nemo
parents:
2023
diff
changeset

492 
end 
2985f3bd18b7
Disable long jump in artillery mode, make snipre rifle single shot
nemo
parents:
2023
diff
changeset

493 
else 
2031
b6f3e56fb100
david_ac's game scheme options for mine delay/quantity, tweaks to sniper rifle
nemo
parents:
2029
diff
changeset

494 
if (GameTicks mod 32) = 0 then 
2052  495 
if (GameTicks mod 4096) < 2048 then 
496 
begin 

497 
if(HHGear^.Angle + 1 <= cMaxAngle) then inc(HHGear^.Angle) 

498 
end 

499 
else 

500 
if(HHGear^.Angle  1 >= 0) then dec(HHGear^.Angle); 

2024
2985f3bd18b7
Disable long jump in artillery mode, make snipre rifle single shot
nemo
parents:
2023
diff
changeset

501 

2058  502 
if (TurnTimeLeft > 0) then 
503 
dec(TurnTimeLeft) 

504 
else 

505 
begin 

2139
5a083e71a71d
Properly decrement sniper rifle if timed out. Try to get camera position straight for once.
nemo
parents:
2090
diff
changeset

506 
PHedgehog(Gear^.Hedgehog)^.AttacksNum:= Gear^.Ammo^.NumPerTurn+1; 
2058  507 
DeleteGear(Gear); 
2059  508 
AfterAttack; 
509 
TurnTimeLeft:= 0 

2058  510 
end; 
559  511 
end; 
512 

37  513 
//////////////////////////////////////////////////////////////////////////////// 
4  514 
procedure doStepActionTimer(Gear: PGear); 
515 
begin 

351  516 
dec(Gear^.Timer); 
517 
case Gear^.Kind of 

83  518 
gtATStartGame: begin 
4  519 
AllInactive:= false; 
351  520 
if Gear^.Timer = 0 then 
83  521 
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); 
4  522 
end; 
83  523 
gtATSmoothWindCh: begin 
351  524 
if Gear^.Timer = 0 then 
6  525 
begin 
351  526 
if WindBarWidth < Gear^.Tag then inc(WindBarWidth) 
527 
else if WindBarWidth > Gear^.Tag then dec(WindBarWidth); 

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

83  529 
end 
530 
end; 

531 
gtATFinishGame: begin 

532 
AllInactive:= false; 

351  533 
if Gear^.Timer = 0 then 
113  534 
begin 
535 
SendIPC('N'); 

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

536 
SendIPC('q'); 
83  537 
GameState:= gsExit 
113  538 
end 
6  539 
end; 
4  540 
end; 
351  541 
if Gear^.Timer = 0 then DeleteGear(Gear) 
4  542 
end; 
543 

544 
//////////////////////////////////////////////////////////////////////////////// 

545 
procedure doStepPickHammerWork(Gear: PGear); 

371  546 
var i, ei: LongInt; 
4  547 
HHGear: PGear; 
548 
begin 

70  549 
AllInactive:= false; 
351  550 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
551 
dec(Gear^.Timer); 

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

1200  553 
begin 
554 
StopSound(sndPickhammer); 

555 
DeleteGear(Gear); 

556 
AfterAttack; 

557 
exit 

558 
end; 

845  559 

422  560 
if (Gear^.Timer mod 33) = 0 then 
1200  561 
begin 
562 
HHGear^.State:= HHGear^.State or gstNoDamage; 

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

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

565 
end; 

422  566 

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

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

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

571 
while i <= ei do 

572 
begin 

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

574 
inc(i, 1) 

575 
end; 

2331
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2329
diff
changeset

576 

e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2329
diff
changeset

577 
if CheckLandValue(hwRound(Gear^.X + Gear^.dX + SignAs(_6,Gear^.dX)), hwRound(Gear^.Y + _1_9), COLOR_INDESTRUCTIBLE) then 
2090
4edb0d49a42d
prevent unc0rr from getting clever with jackhammer too. bring blowtorch into line with the other  should be more fun anyway
nemo
parents:
2089
diff
changeset

578 
begin 
4edb0d49a42d
prevent unc0rr from getting clever with jackhammer too. bring blowtorch into line with the other  should be more fun anyway
nemo
parents:
2089
diff
changeset

579 
Gear^.X:= Gear^.X + Gear^.dX; 
4edb0d49a42d
prevent unc0rr from getting clever with jackhammer too. bring blowtorch into line with the other  should be more fun anyway
nemo
parents:
2089
diff
changeset

580 
Gear^.Y:= Gear^.Y + _1_9; 
4edb0d49a42d
prevent unc0rr from getting clever with jackhammer too. bring blowtorch into line with the other  should be more fun anyway
nemo
parents:
2089
diff
changeset

581 
end; 
1200  582 
SetAllHHToActive; 
583 
end; 

4  584 
if TestCollisionYwithGear(Gear, 1) then 
1200  585 
begin 
586 
Gear^.dY:= _0; 

587 
SetLittle(HHGear^.dX); 

588 
HHGear^.dY:= _0; 

589 
end else 

590 
begin 

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

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

1417  593 
if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer:= 1 
1200  594 
end; 
4  595 

351  596 
Gear^.X:= Gear^.X + HHGear^.dX; 
597 
HHGear^.X:= Gear^.X; 

498  598 
HHGear^.Y:= Gear^.Y  int2hwFloat(cHHRadius); 
4  599 

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

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

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

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

498  605 
else Gear^.dX:= _0; 
4  606 
end; 
607 

608 
procedure doStepPickHammer(Gear: PGear); 

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

611 
HHGear: PGear; 
4  612 
begin 
613 
i:= 0; 

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

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

615 

498  616 
y:= hwRound(Gear^.Y)  cHHRadius * 2; 
351  617 
while y < hwRound(Gear^.Y) do 
4  618 
begin 
371  619 
ar[i].Left := hwRound(Gear^.X)  Gear^.Radius  LongInt(GetRandom(2)); 
620 
ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); 

4  621 
inc(y, 2); 
622 
inc(i) 

623 
end; 

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

624 

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

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

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

628 

1669  629 
PlaySound(sndPickhammer, true, nil); 
4  630 
doStepPickHammerWork(Gear); 
351  631 
Gear^.doStep:= @doStepPickHammerWork 
4  632 
end; 
633 

634 
//////////////////////////////////////////////////////////////////////////////// 

371  635 
var BTPrevAngle, BTSteps: LongInt; 
302  636 

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

637 
procedure doStepBlowTorchWork(Gear: PGear); 
302  638 
var HHGear: PGear; 
1528  639 
b: boolean; 
640 
prevX: LongInt; 

302  641 
begin 
642 
AllInactive:= false; 

351  643 
dec(Gear^.Timer); 
644 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 

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

645 

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

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

647 

305  648 
b:= false; 
649 

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

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

654 
BTPrevAngle:= HHGear^.Angle; 

655 
b:= true 

656 
end; 

657 

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

659 
begin 

660 
doStepHedgehogMoving(HHGear); 

1736  661 
if (HHGear^.State and gstHHDriven) = 0 then Gear^.Timer:= 0 
1528  662 
end; 
305  663 

351  664 
if Gear^.Timer mod cHHStepTicks = 0 then 
1528  665 
begin 
666 
b:= true; 

667 
if Gear^.dX.isNegative then 

1547  668 
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Left 
1528  669 
else 
1547  670 
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Right; 
305  671 

1528  672 
if ((HHGear^.State and gstMoving) = 0) then 
673 
begin 

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

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

2090
4edb0d49a42d
prevent unc0rr from getting clever with jackhammer too. bring blowtorch into line with the other  should be more fun anyway
nemo
parents:
2089
diff
changeset

676 

4edb0d49a42d
prevent unc0rr from getting clever with jackhammer too. bring blowtorch into line with the other  should be more fun anyway
nemo
parents:
2089
diff
changeset

677 
// why the call to HedgehogStep then a further increment of X? 
2331
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2329
diff
changeset

678 
if (prevX = hwRound(HHGear^.X)) and 
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2329
diff
changeset

679 
CheckLandValue(hwRound(HHGear^.X + SignAs(_6, HHGear^.dX)), hwRound(HHGear^.Y), COLOR_INDESTRUCTIBLE) then HedgehogStep(HHGear); 
1528  680 

2331
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2329
diff
changeset

681 
if (prevX = hwRound(HHGear^.X)) and 
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2329
diff
changeset

682 
CheckLandValue(hwRound(HHGear^.X + SignAs(_6, HHGear^.dX)), hwRound(HHGear^.Y), COLOR_INDESTRUCTIBLE) then HHGear^.X:= HHGear^.X + SignAs(_1, HHGear^.dX); 
1528  683 
HHGear^.State:= HHGear^.State or gstAttacking 
684 
end; 

305  685 

1528  686 
inc(BTSteps); 
687 
if BTSteps = 7 then 

688 
begin 

689 
BTSteps:= 0; 

2331
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2329
diff
changeset

690 
if CheckLandValue(hwRound(HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC) + SignAs(_6,Gear^.dX)), hwRound(HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC)), COLOR_INDESTRUCTIBLE) then 
2090
4edb0d49a42d
prevent unc0rr from getting clever with jackhammer too. bring blowtorch into line with the other  should be more fun anyway
nemo
parents:
2089
diff
changeset

691 
begin 
2331
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2329
diff
changeset

692 
Gear^.X:= HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); 
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2329
diff
changeset

693 
Gear^.Y:= HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); 
2090
4edb0d49a42d
prevent unc0rr from getting clever with jackhammer too. bring blowtorch into line with the other  should be more fun anyway
nemo
parents:
2089
diff
changeset

694 
end; 
1528  695 
HHGear^.State:= HHGear^.State or gstNoDamage; 
1643  696 
AmmoShove(Gear, 2, 15); 
1528  697 
HHGear^.State:= HHGear^.State and not gstNoDamage 
698 
end; 

699 
end; 

305  700 

701 
if b then 

498  702 
DrawTunnel(HHGear^.X  Gear^.dX * cHHRadius, HHGear^.Y  _4  Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, 
351  703 
Gear^.dX, Gear^.dY, 
1501  704 
cHHRadius * 5, cHHRadius * 2 + 7); 
305  705 

2090
4edb0d49a42d
prevent unc0rr from getting clever with jackhammer too. bring blowtorch into line with the other  should be more fun anyway
nemo
parents:
2089
diff
changeset

706 
if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) then 
1528  707 
begin 
708 
HHGear^.Message:= 0; 

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

710 
DeleteGear(Gear); 

711 
AfterAttack 

712 
end 

302  713 
end; 
714 

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

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

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

717 
begin 
371  718 
BTPrevAngle:= High(LongInt); 
305  719 
BTSteps:= 0; 
351  720 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
721 
HHGear^.Message:= 0; 

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

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

725 

302  726 
//////////////////////////////////////////////////////////////////////////////// 
727 

1781  728 
procedure doStepRope(Gear: PGear); forward; 
729 

730 
procedure doStepRopeAfterAttack(Gear: PGear); 

731 
var HHGear: PGear; 

732 
begin 

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

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

735 
or (CheckGearDrowning(HHGear)) 

736 
or TestCollisionYwithGear(HHGear, 1) then 

737 
begin 

738 
DeleteGear(Gear); 

2060
3e9e5e1be6f5
fix crash in parachute/rope if drowning with active girder/teleport
nemo
parents:
2059
diff
changeset

739 
isCursorVisible:= false; 
1781  740 
exit 
741 
end; 

742 

1785  743 
HedgehogChAngle(HHGear); 
744 

2283  745 
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); 
2029  746 

1781  747 
if HHGear^.dY.isNegative and TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= _0; 
748 
HHGear^.X:= HHGear^.X + HHGear^.dX; 

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

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

751 

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

753 
begin 

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

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

1964  756 

757 
ApplyAngleBounds(PHedgehog(Gear^.Hedgehog)^, amRope); 

758 

1781  759 
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX); 
760 
Gear^.dY:= AngleCos(HHGear^.Angle); 

761 
Gear^.Friction:= _450; 

762 
Gear^.Elasticity:= _0; 

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

764 
Gear^.doStep:= @doStepRope 

765 
end 

766 
end; 

767 

4  768 
procedure doStepRopeWork(Gear: PGear); 
769 
var HHGear: PGear; 

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

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

773 
haveDivided: boolean; 
4  774 

1504  775 
procedure DeleteMe; 
776 
begin 

777 
with HHGear^ do 

778 
begin 

779 
Message:= Message and not gm_Attack; 

2025
692308790912
Adjust routines impacted by DrawRotatedF modification, clear gstHHHJump in rope to avoid crosshair/hat drawing bug.
nemo
parents:
2024
diff
changeset

780 
State:= (State or gstMoving) and not gstWinner; 
1504  781 
end; 
782 
DeleteGear(Gear) 

783 
end; 

4  784 

1781  785 
procedure WaitCollision; 
786 
begin 

787 
with HHGear^ do 

788 
begin 

789 
Message:= Message and not gm_Attack; 

790 
State:= State or gstMoving; 

791 
end; 

792 
RopePoints.Count:= 0; 

793 
Gear^.Elasticity:= _0; 

794 
Gear^.doStep:= @doStepRopeAfterAttack 

795 
end; 

796 

4  797 
begin 
351  798 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
108  799 

351  800 
if ((HHGear^.State and gstHHDriven) = 0) 
1504  801 
or (CheckGearDrowning(HHGear)) then 
802 
begin 

803 
DeleteMe; 

804 
exit 

805 
end; 

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

806 

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

4  809 

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

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

814 

815 
mdX:= ropeDx + HHGear^.dX; 

816 
mdY:= ropeDy + HHGear^.dY; 

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

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

819 
mdY:= mdY * len; 

820 

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

822 
Gear^.dY:= mdY; 

823 

824 
///// 

825 
tx:= HHGear^.X; 

826 
ty:= HHGear^.Y; 

4  827 

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

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

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

832 

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

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

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

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

837 

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

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

840 

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

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

843 
//// 

844 

1554  845 

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

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

848 
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

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

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

851 

1652  852 
len:= Gear^.Elasticity  _0_3x70; 
853 
while len > _0_3 do 

1504  854 
begin 
1652  855 
lx:= hwRound(Gear^.X + mdX * len); 
856 
ly:= hwRound(Gear^.Y + mdY * len); 

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

860 
begin 

861 
X:= Gear^.X; 

862 
Y:= Gear^.Y; 

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

863 
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); 
1652  864 
b:= (nx * HHGear^.dY) > (ny * HHGear^.dX); 
1504  865 
dLen:= len 
866 
end; 

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

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

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

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

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

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

873 
haveDivided:= true; 
1504  874 
break 
875 
end; 

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

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

878 

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

879 
if not haveDivided then 
1504  880 
if RopePoints.Count > 0 then // check whether the last dividing point could be removed 
881 
begin 

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

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

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

885 
begin 

886 
dec(RopePoints.Count); 

1652  887 
Gear^.X:= RopePoints.ar[RopePoints.Count].X; 
888 
Gear^.Y:= RopePoints.ar[RopePoints.Count].Y; 

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

891 
end 

892 
end; 

4  893 

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

894 
haveCollision:= false; 
351  895 
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

896 
begin 
1504  897 
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

898 
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

899 
end; 
351  900 
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

901 
begin 
1504  902 
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

903 
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

904 
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

905 

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

906 
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

907 
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

908 
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

909 
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

910 
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

911 
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

912 
end; 
4  913 

789  914 
len:= Distance(HHGear^.dX, HHGear^.dY); 
940  915 
if len > _0_8 then 
1504  916 
begin 
917 
len:= _0_8 / len; 

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

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

920 
end; 

789  921 

351  922 
if (Gear^.Message and gm_Attack) <> 0 then 
1504  923 
if (Gear^.State and gsttmpFlag) <> 0 then 
1922  924 
with PHedgehog(Gear^.Hedgehog)^ do 
1964  925 
if Ammo^[CurSlot, CurAmmo].AmmoType <> amParachute then 
1922  926 
WaitCollision 
927 
else 

928 
DeleteMe 

1504  929 
else 
930 
else 

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

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

4  933 
end; 
934 

935 
procedure doStepRopeAttach(Gear: PGear); 

936 
var HHGear: PGear; 

1781  937 
tx, ty, tt: hwFloat; 
938 

939 
procedure RemoveFromAmmo; 

940 
begin 

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

942 
begin 

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

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

1964  945 
end; 
946 
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) 

1781  947 
end; 
948 

4  949 
begin 
351  950 
Gear^.X:= Gear^.X  Gear^.dX; 
951 
Gear^.Y:= Gear^.Y  Gear^.dY; 

498  952 
Gear^.Elasticity:= Gear^.Elasticity + _1; 
351  953 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
517  954 
DeleteCI(HHGear); 
542  955 
if (HHGear^.State and gstMoving) <> 0 then 
1433  956 
begin 
2282  957 
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); 
2329
1cfb7d184ee1
Fix bug with hedgehog getting into ground while throwing rope (http://hedgewars.org/node/1722)
unc0rr
parents:
2301
diff
changeset

958 
if HHGear^.dY.isNegative and TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= _0; 
1cfb7d184ee1
Fix bug with hedgehog getting into ground while throwing rope (http://hedgewars.org/node/1722)
unc0rr
parents:
2301
diff
changeset

959 

1433  960 
HHGear^.X:= HHGear^.X + HHGear^.dX; 
961 
Gear^.X:= Gear^.X + HHGear^.dX; 

2281
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

962 

3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

963 
if TestCollisionYwithGear(HHGear, 1) then 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

964 
begin 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

965 
CheckHHDamage(HHGear); 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

966 
HHGear^.dY:= _0; 
2282  967 
HHGear^.State:= HHGear^.State and not (gstHHJumping or gstHHHJump); 
2281
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

968 
end else 
1433  969 
begin 
2281
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

970 
HHGear^.Y:= HHGear^.Y + HHGear^.dY; 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

971 
Gear^.Y:= Gear^.Y + HHGear^.dY; 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

972 
HHGear^.dY:= HHGear^.dY + cGravity; 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

973 
tt:= Gear^.Elasticity; 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

974 
tx:= _0; 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

975 
ty:= _0; 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

976 
while tt > _20 do 
1433  977 
begin 
2281
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

978 
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), hwSign(Gear^.dX)) 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

979 
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), hwSign(Gear^.dY)) then 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

980 
begin 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

981 
Gear^.X:= Gear^.X + tx; 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

982 
Gear^.Y:= Gear^.Y + ty; 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

983 
Gear^.Elasticity:= tt; 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

984 
Gear^.doStep:= @doStepRopeWork; 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

985 
with HHGear^ do State:= State and not (gstAttacking or gstMoving or gstHHHJump); 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

986 

3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

987 
RemoveFromAmmo; 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

988 

3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

989 
tt:= _0; 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

990 
exit 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

991 
end; 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

992 
tx:= tx + Gear^.dX + Gear^.dX; 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

993 
ty:= ty + Gear^.dY + Gear^.dY; 
3217f0d8c420
Fix hedgehog stopping to slide when throwing rope (not tested)
unc0rr
parents:
2280
diff
changeset

994 
tt:= tt  _2; 
1433  995 
end; 
996 
end; 

997 
end; 

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

998 

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

1000 

351  1001 
if (Gear^.State and gstCollision) <> 0 then 
2068  1002 
if Gear^.Elasticity < _10 then 
1003 
Gear^.Elasticity:= _10000 

1004 
else 

1005 
begin 

1006 
Gear^.doStep:= @doStepRopeWork; 

1007 
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

1008 

2068  1009 
RemoveFromAmmo; 
1010 

1011 
exit 

1012 
end; 

4  1013 

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

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

1015 
or ((Gear^.Message and gm_Attack) = 0) 
2280  1016 
or ((HHGear^.State and gstHHDriven) = 0) 
1634
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset

1017 
or (HHGear^.Damage > 0) then 
1433  1018 
begin 
1019 
with PHedgehog(Gear^.Hedgehog)^.Gear^ do 

1020 
begin 

1021 
State:= State and not gstAttacking; 

1022 
Message:= Message and not gm_Attack 

1023 
end; 

1024 
DeleteGear(Gear) 

1025 
end 

4  1026 
end; 
1027 

1028 
procedure doStepRope(Gear: PGear); 

1029 
begin 

351  1030 
Gear^.dX:=  Gear^.dX; 
1031 
Gear^.dY:=  Gear^.dY; 

1032 
Gear^.doStep:= @doStepRopeAttach 

4  1033 
end; 
1034 

1035 
//////////////////////////////////////////////////////////////////////////////// 

1036 
procedure doStepSmokeTrace(Gear: PGear); 

1037 
begin 

351  1038 
inc(Gear^.Timer); 
1039 
if Gear^.Timer > 64 then 

1133  1040 
begin 
1041 
Gear^.Timer:= 0; 

1042 
dec(Gear^.State) 

1043 
end; 

351  1044 
Gear^.dX:= Gear^.dX + cWindSpeed; 
1045 
Gear^.X:= Gear^.X + Gear^.dX; 

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

4  1047 
end; 
9  1048 

1049 
//////////////////////////////////////////////////////////////////////////////// 

1045  1050 
procedure doStepExplosionWork(Gear: PGear); 
9  1051 
begin 
351  1052 
inc(Gear^.Timer); 
1053 
if Gear^.Timer > 75 then 

1133  1054 
begin 
1055 
inc(Gear^.State); 

1056 
Gear^.Timer:= 0; 

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

1058 
end; 

9  1059 
end; 
10  1060 

1045  1061 
procedure doStepExplosion(Gear: PGear); 
1062 
var i: LongWord; 

1063 
begin 

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

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

1045  1067 
Gear^.doStep:= @doStepExplosionWork 
1068 
end; 

1069 

10  1070 
//////////////////////////////////////////////////////////////////////////////// 
1071 
procedure doStepMine(Gear: PGear); 

1072 
begin 

542  1073 
if (Gear^.State and gstMoving) <> 0 then 
914  1074 
begin 
1075 
DeleteCI(Gear); 

1076 
doStepFallingGear(Gear); 

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

1078 
begin 

1079 
AddGearCI(Gear); 

1080 
Gear^.dX:= _0; 

1081 
Gear^.dY:= _0 

1082 
end; 

1083 
CalcRotationDirAngle(Gear); 

1084 
AllInactive:= false 

1085 
end else 

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

1087 
doStepFallingGear(Gear); 

351  1088 

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

1133  1090 
if ((Gear^.State and gstAttacking) = 0) then 
1091 
begin 

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

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

1094 
end else // gstAttacking <> 0 

1095 
begin 

1096 
AllInactive:= false; 

1669  1097 
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false, nil); 
1133  1098 
if Gear^.Timer = 0 then 
1099 
begin 

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

1101 
DeleteGear(Gear); 

1102 
exit 

1103 
end; 

1104 
dec(Gear^.Timer); 

1105 
end else // gsttmpFlag = 0 

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

10  1107 
end; 
57  1108 

39  1109 
//////////////////////////////////////////////////////////////////////////////// 
1110 
procedure doStepDynamite(Gear: PGear); 

1111 
begin 

43  1112 
doStepFallingGear(Gear); 
1113 
AllInactive:= false; 

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

1133  1116 
begin 
1117 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); 

1118 
DeleteGear(Gear); 

1119 
exit 

1120 
end; 

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

1123 

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

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

1128 
begin 
351  1129 
if (Gear^.Message and gm_Destroy) > 0 then 
1133  1130 
begin 
1131 
DeleteGear(Gear); 

1132 
FreeActionsList; 

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

1134 
with CurrentHedgehog^ do 

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

1136 
exit 

1137 
end; 

15  1138 

351  1139 
if Gear^.Damage > 0 then 
1133  1140 
begin 
1141 
x:= hwRound(Gear^.X); 

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

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

1145 

1146 
if k = gtCase then 

1133  1147 
begin 
1148 
doMakeExplosion(x, y, 25, EXPLAutoSound); 

1149 
for i:= 0 to 63 do 

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

1151 
end; 

1152 
exit 

1153 
end; 

79  1154 

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

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

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

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

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

1162 
begin 

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

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

1669  1165 
else if Gear^.dY <  _0_03 then PlaySound(sndGraveImpact, false, nil); 
1133  1166 
end; 
1167 
CheckGearDrowning(Gear); 

1168 
end; 

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

1169 

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

1172 
end; 
49  1173 

1174 
//////////////////////////////////////////////////////////////////////////////// 

854  1175 
procedure doStepIdle(Gear: PGear); 
1176 
begin 

1177 
AllInactive:= false; 

925  1178 
dec(Gear^.Timer); 
854  1179 
if Gear^.Timer = 0 then 
1180 
begin 

1181 
DeleteGear(Gear); 

1182 
AfterAttack 

1183 
end 

1184 
end; 

1185 

79  1186 
procedure doStepShover(Gear: PGear); 
1187 
var HHGear: PGear; 

1188 
begin 

351  1189 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
1190 
HHGear^.State:= HHGear^.State or gstNoDamage; 

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

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

1192 

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

1194 

351  1195 
HHGear^.State:= HHGear^.State and not gstNoDamage; 
854  1196 
Gear^.Timer:= 250; 
1197 
Gear^.doStep:= @doStepIdle 

79  1198 
end; 
1199 

1200 
//////////////////////////////////////////////////////////////////////////////// 

925  1201 
procedure doStepWhip(Gear: PGear); 
1202 
var HHGear: PGear; 

1203 
i: LongInt; 

1204 
begin 

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

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

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

1207 
DeleteCI(HHGear); 
925  1208 

1209 
for i:= 0 to 3 do 

1210 
begin 

1211 
AmmoShove(Gear, 30, 25); 

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

1213 
end; 

1214 

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

1216 
Gear^.Timer:= 250; 

1217 
Gear^.doStep:= @doStepIdle 

1218 
end; 

1219 

1220 
//////////////////////////////////////////////////////////////////////////////// 

79  1221 
procedure doStepFlame(Gear: PGear); 
2143
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
2142
diff
changeset

1222 
var i: Integer; 
79  1223 
begin 
1224 
AllInactive:= false; 

1433  1225 

79  1226 
if not TestCollisionYwithGear(Gear, 1) then 
1133  1227 
begin 
1586  1228 
if hwAbs(Gear^.dX) > _0_01 then 
1229 
Gear^.dX:= Gear^.dX * _0_995; 

1297  1230 

1133  1231 
Gear^.dY:= Gear^.dY + cGravity; 
1830  1232 
if hwAbs(Gear^.dY) > _0_2 then Gear^.dY:= Gear^.dY * _0_995; 
1297  1233 

1830  1234 
Gear^.X:= Gear^.X + Gear^.dX + cWindSpeed * 640; 
1133  1235 
Gear^.Y:= Gear^.Y + Gear^.dY; 
1297  1236 

2143
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
2142
diff
changeset

1237 
if (hwRound(Gear^.Y) > cWaterLine) then 
1133  1238 
begin 
2143
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
2142
diff
changeset

1239 
for i:= 0 to 3 do 
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
2142
diff
changeset

1240 
begin 
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
2142
diff
changeset

1241 
AddVisualGear(hwRound(Gear^.X)  16 + Random(32), hwRound(Gear^.Y)  16 + Random(16), vgtSteam); 
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
2142
diff
changeset

1242 
PlaySound(sndVaporize, false, nil); 
ad05f6b2d1c0
New baseball bat sound, steam when fire lands on water (needs new hiss sound), bubbles when hedgehog drowns, more messages on
nemo
parents:
2142
diff
changeset

1243 
end; 
1133  1244 
DeleteGear(Gear); 
1245 
exit 

1246 
end 

1247 
end else begin 

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

1249 
else begin 

1586  1250 
Gear^.Radius:= 9; 
1251 
AmmoShove(Gear, 4, 100); 

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

1133  1254 
dec(Gear^.Health); 
1586  1255 
Gear^.Timer:= 450  Gear^.Tag * 8 
1133  1256 
end 
1257 
end; 

79  1258 

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

79  1261 

351  1262 
if Gear^.Health = 0 then 
1133  1263 
DeleteGear(Gear) 
79  1264 
end; 
82  1265 

1266 
//////////////////////////////////////////////////////////////////////////////// 

1267 
procedure doStepFirePunchWork(Gear: PGear); 

1268 
var HHGear: PGear; 

1269 
begin 

1270 
AllInactive:= false; 

351  1271 
if ((Gear^.Message and gm_Destroy) <> 0) then 
1133  1272 
begin 
1273 
DeleteGear(Gear); 

1274 
AfterAttack; 

1275 
exit 

1276 
end; 

82  1277 

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

1133  1280 
begin 
1281 
Gear^.Tag:= hwRound(HHGear^.Y); 

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

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

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

1285 
AmmoShove(Gear, 30, 40); 

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

1287 
end; 

351  1288 

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

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

1133  1291 
begin 
1292 
HHGear^.State:= HHGear^.State or gstMoving; 

1293 
DeleteGear(Gear); 

1294 
AfterAttack; 

1295 
exit 

1296 
end; 

2089  1297 

2331
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2329
diff
changeset

1298 
if CheckLandValue(hwRound(HHGear^.X), hwRound(HHGear^.Y + HHGear^.dY + SignAs(_6,Gear^.dY)), COLOR_INDESTRUCTIBLE) then 
e4941a7986d6
Another try at keeping blowtorch/firepunch/jackhammer from going through indestructible stuff. Shame these routines don't use hedgehog movement
nemo
parents:
2329
diff
changeset

1299 
HHGear^.Y:= HHGear^.Y + HHGear^.dY 
82  1300 
end; 
1301 

1302 
procedure doStepFirePunch(Gear: PGear); 

1303 
var HHGear: PGear; 

1304 
begin 

1305 
AllInactive:= false; 

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

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

1310 

351  1311 
HHGear^.dY:=  _0_3; 
82  1312 

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

1314 
Gear^.dX:= SignAs(_0_45, Gear^.dX); 
351  1315 
Gear^.dY:=  _0_9; 
1316 
Gear^.doStep:= @doStepFirePunchWork; 

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

1669  1319 
PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false, PHedgehog(HHGear^.Hedgehog)^.Team^.voicepack) 
82  1320 
end; 
1321 

263  1322 
//////////////////////////////////////////////////////////////////////////////// 
1323 

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

1324 
procedure doStepParachuteWork(Gear: PGear); 
211  1325 
var HHGear: PGear; 
1326 
begin 

351  1327 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
82  1328 

516  1329 
inc(Gear^.Timer); 
1330 

212  1331 
if TestCollisionYwithGear(HHGear, 1) 
1133  1332 
or ((HHGear^.State and gstHHDriven) = 0) 
1333 
or CheckGearDrowning(HHGear) 

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

1335 
begin 

1336 
with HHGear^ do 

1337 
begin 

1338 
Message:= 0; 

1339 
SetLittle(dX); 

1340 
dY:= _0; 

1341 
State:= State or gstMoving; 

1342 
end; 

1343 
DeleteGear(Gear); 

2060
3e9e5e1be6f5
fix crash in parachute/rope if drowning with active girder/teleport
nemo
parents:
2059
diff
changeset

1344 
isCursorVisible:= false; 
1133  1345 
exit 
1346 
end; 

211  1347 

351  1348 
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then 
1133  1349 
HHGear^.X:= HHGear^.X + cWindSpeed * 200; 
211  1350 

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

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

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

211  1355 

351  1356 
HHGear^.Y:= HHGear^.Y + cGravity * 100; 
568  1357 
Gear^.X:= HHGear^.X; 
1358 
Gear^.Y:= HHGear^.Y 

263  1359 
end; 