author  nemo 
Fri, 15 May 2009 12:56:32 +0000  
changeset 2059  b25eed7f9183 
parent 2058  5c2b52755141 
child 2060  3e9e5e1be6f5 
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; 

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)); 
2017  70 
ApplyDamage(Gear, dmg); 
1123  71 
end 
4  72 
end; 
73 

74 
//////////////////////////////////////////////////////////////////////////////// 

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

76 
procedure CalcRotationDirAngle(Gear: PGear); 

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

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

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

82 
else 

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

84 

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

85 
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

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

89 
//////////////////////////////////////////////////////////////////////////////// 

90 
procedure doStepDrowningGear(Gear: PGear); 

91 
begin 

92 
AllInactive:= false; 

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

4  95 
end; 
96 

97 
//////////////////////////////////////////////////////////////////////////////// 

98 
procedure doStepFallingGear(Gear: PGear); 

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

103 
if Gear^.dY.isNegative then 

1133  104 
begin 
105 
isFalling:= true; 

106 
if TestCollisionYwithGear(Gear, 1) then 

107 
begin 

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

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

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

111 
end 

112 
end else 

113 
if TestCollisionYwithGear(Gear, 1) then 

114 
begin 

115 
isFalling:= false; 

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

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

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

119 
end else isFalling:= true; 

503  120 

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

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

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

126 
end; 

503  127 

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

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

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

136 
else 

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

4  138 
end; 
139 

140 
//////////////////////////////////////////////////////////////////////////////// 

141 
procedure doStepBomb(Gear: PGear); 

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

1263  146 

4  147 
doStepFallingGear(Gear); 
1263  148 

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

1133  151 
begin 
152 
case Gear^.Kind of 

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

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

157 
for i:= 0 to 4 do 

158 
begin 

159 
dX:= rndSign(GetRandom * _0_1); 

160 
dY:= (GetRandom  _3) * _0_08; 

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

163 
end; 

164 
gtWatermelon: begin 

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

166 
for i:= 0 to 5 do 

167 
begin 

168 
dX:= rndSign(GetRandom * _0_1); 

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

175 
for i:= 0 to 127 do 

176 
begin 

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

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

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

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

181 
end 

182 
end; 

1133  183 
end; 
184 
DeleteGear(Gear); 

185 
exit 

186 
end; 

1263  187 

4  188 
CalcRotationDirAngle(Gear); 
1263  189 

190 
if Gear^.Kind = gtHellishBomb then 

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

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

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

1279  197 
end; 
1263  198 

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

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

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

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

207 
AllInactive:= false; 

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

211 

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

214 
AllInactive:= false; 

215 
doStepFallingGear(Gear); 

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

221 
end; 

1262  222 

223 
if Gear^.Kind = gtMelonPiece then 

224 
CalcRotationDirAngle(Gear) 

225 
else 

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

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

78  228 
end; 
229 

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

232 
begin 

233 
AllInactive:= false; 

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

239 
DeleteGear(Gear); 

240 
exit 

241 
end; 

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

246 
//////////////////////////////////////////////////////////////////////////////// 

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

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

351  255 
if Gear^.Timer = 0 then 
1133  256 
begin 
2017  257 
if (Gear^.Kind = gtHealthTag) and (PHedgehog(Gear^.Hedgehog)^.Gear <> nil) then 
1133  258 
PHedgehog(Gear^.Hedgehog)^.Gear^.Active:= true; // to let current hh die 
259 
DeleteGear(Gear) 

260 
end 

4  261 
end; 
262 

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

1505  265 
AllInactive:= false; 
1495  266 

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

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

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

275 
begin 

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

522  278 

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

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

283 
Gear^.doStep:= @doStepHealthTagWork 

284 
else 

285 
Gear^.doStep:= @doStepHealthTagWorkUnderWater; 

286 

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

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

292 
begin 

293 
AllInactive:= false; 

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

4  296 

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

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

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

313 
//////////////////////////////////////////////////////////////////////////////// 

314 
procedure doStepUFOWork(Gear: PGear); 

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

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

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

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

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

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

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

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

374  327 

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

329 
begin 

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

331 
if y + Gear^.Radius < cWaterLine then 

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

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

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

343 
end; 

344 

345 
procedure doStepUFO(Gear: PGear); 

346 
begin 

347 
AllInactive:= false; 

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

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

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

357 
end; 

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

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

4  364 
end; 
365 
end; 

366 

367 
//////////////////////////////////////////////////////////////////////////////// 

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

370 
AllInactive:= false; 

371 
inc(Gear^.Timer); 

372 
if Gear^.Timer > 75 then 

373 
begin 

374 
DeleteGear(Gear); 

375 
AfterAttack 

376 
end 

377 
end; 

378 

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

381 
begin 

382 
AllInactive:= false; 

876  383 

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

385 
begin 

386 
dec(Gear^.Timer); 

387 
if Gear^.Timer = 0 then 

388 
begin 

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

392 
exit 

393 
end 

394 
else inc(Gear^.Timer); 

395 

4  396 
i:= 200; 
397 
repeat 

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

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

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

405 
ShotgunShot(Gear); 

406 
Gear^.doStep:= @doStepShotIdle; 

407 
exit 

408 
end; 

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

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

415 
//////////////////////////////////////////////////////////////////////////////// 

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

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

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

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

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

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

1753  430 
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) 
351  431 
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

432 
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

433 
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

434 
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

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

436 
AmmoShove(Gear, Gear^.Timer, 20); 
38  437 
dec(i) 
351  438 
until (i = 0) or (Gear^.Damage > Gear^.Health); 
439 
if Gear^.Damage > 0 then 

37  440 
begin 
351  441 
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82  i, 1); 
442 
dec(Gear^.Health, Gear^.Damage); 

443 
Gear^.Damage:= 0 

37  444 
end; 
1760  445 

446 
if (Gear^.Health <= 0) 

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

448 
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

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

450 
if (GameFlags and gfLaserSight) = 0 then cLaserSighting:= false; 
2033  451 
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

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

454 
end; 
37  455 
end; 
456 

559  457 
procedure doStepDEagleShot(Gear: PGear); 
458 
begin 

1669  459 
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

460 
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

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

462 

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

463 
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

464 
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

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

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

467 
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

468 
HHGear^.State:= HHGear^.State or gstNotKickable; 
2033  469 
HedgehogChAngle(HHGear); 
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

470 
if not cLaserSighting then // game doesn't have default laser sight. turn it on and give them a chance to aim 
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset

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

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

473 
HHGear^.Message:= 0; 
2052  474 
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

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

476 

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

477 
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

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

479 
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

480 
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

481 
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

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

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

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

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

486 
if (GameTicks mod 32) = 0 then 
2052  487 
if (GameTicks mod 4096) < 2048 then 
488 
begin 

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

490 
end 

491 
else 

492 
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

493 

2058  494 
if (TurnTimeLeft > 0) then 
495 
dec(TurnTimeLeft) 

496 
else 

497 
begin 

498 
DeleteGear(Gear); 

2059  499 
AfterAttack; 
500 
TurnTimeLeft:= 0 

2058  501 
end; 
559  502 
end; 
503 

37  504 
//////////////////////////////////////////////////////////////////////////////// 
4  505 
procedure doStepActionTimer(Gear: PGear); 
506 
begin 

351  507 
dec(Gear^.Timer); 
508 
case Gear^.Kind of 

83  509 
gtATStartGame: begin 
4  510 
AllInactive:= false; 
351  511 
if Gear^.Timer = 0 then 
83  512 
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); 
4  513 
end; 
83  514 
gtATSmoothWindCh: begin 
351  515 
if Gear^.Timer = 0 then 
6  516 
begin 
351  517 
if WindBarWidth < Gear^.Tag then inc(WindBarWidth) 
518 
else if WindBarWidth > Gear^.Tag then dec(WindBarWidth); 

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

83  520 
end 
521 
end; 

522 
gtATFinishGame: begin 

523 
AllInactive:= false; 

351  524 
if Gear^.Timer = 0 then 
113  525 
begin 
526 
SendIPC('N'); 

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

527 
SendIPC('q'); 
83  528 
GameState:= gsExit 
113  529 
end 
6  530 
end; 
4  531 
end; 
351  532 
if Gear^.Timer = 0 then DeleteGear(Gear) 
4  533 
end; 
534 

535 
//////////////////////////////////////////////////////////////////////////////// 

536 
procedure doStepPickHammerWork(Gear: PGear); 

371  537 
var i, ei: LongInt; 
4  538 
HHGear: PGear; 
539 
begin 

70  540 
AllInactive:= false; 
351  541 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
542 
dec(Gear^.Timer); 

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

1200  544 
begin 
545 
StopSound(sndPickhammer); 

546 
DeleteGear(Gear); 

547 
AfterAttack; 

548 
exit 

549 
end; 

845  550 

422  551 
if (Gear^.Timer mod 33) = 0 then 
1200  552 
begin 
553 
HHGear^.State:= HHGear^.State or gstNoDamage; 

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

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

556 
end; 

422  557 

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

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

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

562 
while i <= ei do 

563 
begin 

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

565 
inc(i, 1) 

566 
end; 

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

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

569 
SetAllHHToActive; 

570 
end; 

4  571 
if TestCollisionYwithGear(Gear, 1) then 
1200  572 
begin 
573 
Gear^.dY:= _0; 

574 
SetLittle(HHGear^.dX); 

575 
HHGear^.dY:= _0; 

576 
end else 

577 
begin 

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

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

1417  580 
if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer:= 1 
1200  581 
end; 
4  582 

351  583 
Gear^.X:= Gear^.X + HHGear^.dX; 
584 
HHGear^.X:= Gear^.X; 

498  585 
HHGear^.Y:= Gear^.Y  int2hwFloat(cHHRadius); 
4  586 

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

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

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

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

498  592 
else Gear^.dX:= _0; 
4  593 
end; 
594 

595 
procedure doStepPickHammer(Gear: PGear); 

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

598 
HHGear: PGear; 
4  599 
begin 
600 
i:= 0; 

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

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

602 

498  603 
y:= hwRound(Gear^.Y)  cHHRadius * 2; 
351  604 
while y < hwRound(Gear^.Y) do 
4  605 
begin 
371  606 
ar[i].Left := hwRound(Gear^.X)  Gear^.Radius  LongInt(GetRandom(2)); 
607 
ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); 

4  608 
inc(y, 2); 
609 
inc(i) 

610 
end; 

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

611 

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

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

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

615 

1669  616 
PlaySound(sndPickhammer, true, nil); 
4  617 
doStepPickHammerWork(Gear); 
351  618 
Gear^.doStep:= @doStepPickHammerWork 
4  619 
end; 
620 

621 
//////////////////////////////////////////////////////////////////////////////// 

371  622 
var BTPrevAngle, BTSteps: LongInt; 
302  623 

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

624 
procedure doStepBlowTorchWork(Gear: PGear); 
302  625 
var HHGear: PGear; 
1528  626 
b: boolean; 
627 
prevX: LongInt; 

302  628 
begin 
629 
AllInactive:= false; 

351  630 
dec(Gear^.Timer); 
631 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 

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

632 

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

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

634 

305  635 
b:= false; 
636 

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

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

641 
BTPrevAngle:= HHGear^.Angle; 

642 
b:= true 

643 
end; 

644 

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

646 
begin 

647 
doStepHedgehogMoving(HHGear); 

1736  648 
if (HHGear^.State and gstHHDriven) = 0 then Gear^.Timer:= 0 
1528  649 
end; 
305  650 

351  651 
if Gear^.Timer mod cHHStepTicks = 0 then 
1528  652 
begin 
653 
b:= true; 

654 
if Gear^.dX.isNegative then 

1547  655 
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Left 
1528  656 
else 
1547  657 
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Right; 
305  658 

1528  659 
if ((HHGear^.State and gstMoving) = 0) then 
660 
begin 

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

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

663 

664 
HedgehogStep(HHGear); 

665 

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

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

668 
end; 

305  669 

1528  670 
inc(BTSteps); 
671 
if BTSteps = 7 then 

672 
begin 

673 
BTSteps:= 0; 

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

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

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

1643  677 
AmmoShove(Gear, 2, 15); 
1528  678 
HHGear^.State:= HHGear^.State and not gstNoDamage 
679 
end; 

680 
end; 

305  681 

682 
if b then 

498  683 
DrawTunnel(HHGear^.X  Gear^.dX * cHHRadius, HHGear^.Y  _4  Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, 
351  684 
Gear^.dX, Gear^.dY, 
1501  685 
cHHRadius * 5, cHHRadius * 2 + 7); 
305  686 

1784  687 
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  688 
begin 
689 
HHGear^.Message:= 0; 

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

691 
DeleteGear(Gear); 

692 
AfterAttack 

693 
end 

302  694 
end; 
695 

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

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

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

698 
begin 
371  699 
BTPrevAngle:= High(LongInt); 
305  700 
BTSteps:= 0; 
351  701 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
702 
HHGear^.Message:= 0; 

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

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

706 

302  707 
//////////////////////////////////////////////////////////////////////////////// 
708 

1781  709 
procedure doStepRope(Gear: PGear); forward; 
710 

711 
procedure doStepRopeAfterAttack(Gear: PGear); 

712 
var HHGear: PGear; 

713 
begin 

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

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

716 
or (CheckGearDrowning(HHGear)) 

717 
or TestCollisionYwithGear(HHGear, 1) then 

718 
begin 

719 
DeleteGear(Gear); 

720 
exit 

721 
end; 

722 

1785  723 
HedgehogChAngle(HHGear); 
724 

2029  725 
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then 
726 
begin 

727 
{$IFDEF DEBUGFILE}if HHGear^.dX.QWordValue > 1 then AddFileLog('Stopping hedgehog after rope attack due to wall collision');{$ENDIF} 

728 
SetLittle(HHGear^.dX); 

729 
end; 

730 

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

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

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

735 

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

737 
begin 

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

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

1964  740 

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

742 

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

745 
Gear^.Friction:= _450; 

746 
Gear^.Elasticity:= _0; 

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

748 
Gear^.doStep:= @doStepRope 

749 
end 

750 
end; 

751 

4  752 
procedure doStepRopeWork(Gear: PGear); 
753 
var HHGear: PGear; 

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

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

757 
haveDivided: boolean; 
4  758 

1504  759 
procedure DeleteMe; 
760 
begin 

761 
with HHGear^ do 

762 
begin 

763 
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

764 
State:= (State or gstMoving) and not gstWinner; 
1504  765 
end; 
766 
DeleteGear(Gear) 

767 
end; 

4  768 

1781  769 
procedure WaitCollision; 
770 
begin 

771 
with HHGear^ do 

772 
begin 

773 
Message:= Message and not gm_Attack; 

774 
State:= State or gstMoving; 

775 
end; 

776 
RopePoints.Count:= 0; 

777 
Gear^.Elasticity:= _0; 

778 
Gear^.doStep:= @doStepRopeAfterAttack 

779 
end; 

780 

4  781 
begin 
351  782 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
108  783 

351  784 
if ((HHGear^.State and gstHHDriven) = 0) 
1504  785 
or (CheckGearDrowning(HHGear)) then 
786 
begin 

787 
DeleteMe; 

788 
exit 

789 
end; 

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

790 

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

4  793 

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

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

798 

799 
mdX:= ropeDx + HHGear^.dX; 

800 
mdY:= ropeDy + HHGear^.dY; 

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

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

803 
mdY:= mdY * len; 

804 

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

806 
Gear^.dY:= mdY; 

807 

808 
///// 

809 
tx:= HHGear^.X; 

810 
ty:= HHGear^.Y; 

4  811 

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

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

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

816 

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

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

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

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

821 

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

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

824 

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

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

827 
//// 

828 

1554  829 

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

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

832 
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

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

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

835 

1652  836 
len:= Gear^.Elasticity  _0_3x70; 
837 
while len > _0_3 do 

1504  838 
begin 
1652  839 
lx:= hwRound(Gear^.X + mdX * len); 
840 
ly:= hwRound(Gear^.Y + mdY * len); 

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

844 
begin 

845 
X:= Gear^.X; 

846 
Y:= Gear^.Y; 

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

847 
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); 
1652  848 
b:= (nx * HHGear^.dY) > (ny * HHGear^.dX); 
1504  849 
dLen:= len 
850 
end; 

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

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

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

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

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

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

857 
haveDivided:= true; 
1504  858 
break 
859 
end; 

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

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

862 

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

863 
if not haveDivided then 
1504  864 
if RopePoints.Count > 0 then // check whether the last dividing point could be removed 
865 
begin 

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

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

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

869 
begin 

870 
dec(RopePoints.Count); 

1652  871 
Gear^.X:= RopePoints.ar[RopePoints.Count].X; 
872 
Gear^.Y:= RopePoints.ar[RopePoints.Count].Y; 

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

875 
end 

876 
end; 

4  877 

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

878 
haveCollision:= false; 
351  879 
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

880 
begin 
1504  881 
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

882 
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

883 
end; 
351  884 
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

885 
begin 
1504  886 
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

887 
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

888 
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

889 

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

890 
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

891 
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

892 
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

893 
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

894 
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

895 
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

896 
end; 
4  897 

789  898 
len:= Distance(HHGear^.dX, HHGear^.dY); 
940  899 
if len > _0_8 then 
1504  900 
begin 
901 
len:= _0_8 / len; 

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

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

904 
end; 

789  905 

351  906 
if (Gear^.Message and gm_Attack) <> 0 then 
1504  907 
if (Gear^.State and gsttmpFlag) <> 0 then 
1922  908 
with PHedgehog(Gear^.Hedgehog)^ do 
1964  909 
if Ammo^[CurSlot, CurAmmo].AmmoType <> amParachute then 
1922  910 
WaitCollision 
911 
else 

912 
DeleteMe 

1504  913 
else 
914 
else 

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

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

4  917 
end; 
918 

919 
procedure doStepRopeAttach(Gear: PGear); 

920 
var HHGear: PGear; 

1781  921 
tx, ty, tt: hwFloat; 
922 

923 
procedure RemoveFromAmmo; 

924 
begin 

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

926 
begin 

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

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

1964  929 
end; 
930 
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) 

1781  931 
end; 
932 

4  933 
begin 
351  934 
Gear^.X:= Gear^.X  Gear^.dX; 
935 
Gear^.Y:= Gear^.Y  Gear^.dY; 

498  936 
Gear^.Elasticity:= Gear^.Elasticity + _1; 
351  937 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
517  938 
DeleteCI(HHGear); 
542  939 
if (HHGear^.State and gstMoving) <> 0 then 
1433  940 
if TestCollisionYwithGear(HHGear, 1) then 
941 
begin 

942 
CheckHHDamage(HHGear); 

943 
HHGear^.dY:= _0; 

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

944 
HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping or gstHHHJump); 
1433  945 
end else 
946 
begin 

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

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

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

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

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

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

953 
tt:= Gear^.Elasticity; 

954 
tx:= _0; 

955 
ty:= _0; 

956 
while tt > _20 do 

957 
begin 

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

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

960 
begin 

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

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

963 
Gear^.Elasticity:= tt; 

964 
Gear^.doStep:= @doStepRopeWork; 

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

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

967 
RemoveFromAmmo; 

968 

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

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

970 
exit 
1433  971 
end; 
972 
tx:= tx + Gear^.dX + Gear^.dX; 

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

974 
tt:= tt  _2; 

975 
end; 

976 
end; 

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

977 

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

979 

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

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

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

983 
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

984 

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

986 

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

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

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

989 
end; 
4  990 

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

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

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

993 
or (HHGear^.Damage > 0) then 
1433  994 
begin 
995 
with PHedgehog(Gear^.Hedgehog)^.Gear^ do 

996 
begin 

997 
State:= State and not gstAttacking; 

998 
Message:= Message and not gm_Attack 

999 
end; 

1000 
DeleteGear(Gear) 

1001 
end 

4  1002 
end; 
1003 

1004 
procedure doStepRope(Gear: PGear); 

1005 
begin 

351  1006 
Gear^.dX:=  Gear^.dX; 
1007 
Gear^.dY:=  Gear^.dY; 

1008 
Gear^.doStep:= @doStepRopeAttach 

4  1009 
end; 
1010 

1011 
//////////////////////////////////////////////////////////////////////////////// 

1012 
procedure doStepSmokeTrace(Gear: PGear); 

1013 
begin 

351  1014 
inc(Gear^.Timer); 
1015 
if Gear^.Timer > 64 then 

1133  1016 
begin 
1017 
Gear^.Timer:= 0; 

1018 
dec(Gear^.State) 

1019 
end; 

351  1020 
Gear^.dX:= Gear^.dX + cWindSpeed; 
1021 
Gear^.X:= Gear^.X + Gear^.dX; 

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

4  1023 
end; 
9  1024 

1025 
//////////////////////////////////////////////////////////////////////////////// 

1045  1026 
procedure doStepExplosionWork(Gear: PGear); 
9  1027 
begin 
351  1028 
inc(Gear^.Timer); 
1029 
if Gear^.Timer > 75 then 

1133  1030 
begin 
1031 
inc(Gear^.State); 

1032 
Gear^.Timer:= 0; 

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

1034 
end; 

9  1035 
end; 
10  1036 

1045  1037 
procedure doStepExplosion(Gear: PGear); 
1038 
var i: LongWord; 

1039 
begin 

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

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

1045  1043 
Gear^.doStep:= @doStepExplosionWork 
1044 
end; 

1045 

10  1046 
//////////////////////////////////////////////////////////////////////////////// 
1047 
procedure doStepMine(Gear: PGear); 

1048 
begin 

542  1049 
if (Gear^.State and gstMoving) <> 0 then 
914  1050 
begin 
1051 
DeleteCI(Gear); 

1052 
doStepFallingGear(Gear); 

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

1054 
begin 

1055 
AddGearCI(Gear); 

1056 
Gear^.dX:= _0; 

1057 
Gear^.dY:= _0 

1058 
end; 

1059 
CalcRotationDirAngle(Gear); 

1060 
AllInactive:= false 

1061 
end else 

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

1063 
doStepFallingGear(Gear); 

351  1064 

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

1133  1066 
if ((Gear^.State and gstAttacking) = 0) then 
1067 
begin 

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

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

1070 
end else // gstAttacking <> 0 

1071 
begin 

1072 
AllInactive:= false; 

1669  1073 
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false, nil); 
1133  1074 
if Gear^.Timer = 0 then 
1075 
begin 

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

1077 
DeleteGear(Gear); 

1078 
exit 

1079 
end; 

1080 
dec(Gear^.Timer); 

1081 
end else // gsttmpFlag = 0 

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

10  1083 
end; 
57  1084 

39  1085 
//////////////////////////////////////////////////////////////////////////////// 
1086 
procedure doStepDynamite(Gear: PGear); 

1087 
begin 

43  1088 
doStepFallingGear(Gear); 
1089 
AllInactive:= false; 

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

1133  1092 
begin 
1093 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); 

1094 
DeleteGear(Gear); 

1095 
exit 

1096 
end; 

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

1099 

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

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

1104 
begin 
351  1105 
if (Gear^.Message and gm_Destroy) > 0 then 
1133  1106 
begin 
1107 
DeleteGear(Gear); 

1108 
FreeActionsList; 

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

1110 
with CurrentHedgehog^ do 

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

1112 
exit 

1113 
end; 

15  1114 

351  1115 
if Gear^.Damage > 0 then 
1133  1116 
begin 
1117 
x:= hwRound(Gear^.X); 

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

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

1121 

1122 
if k = gtCase then 

1133  1123 
begin 
1124 
doMakeExplosion(x, y, 25, EXPLAutoSound); 

1125 
for i:= 0 to 63 do 

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

1127 
end; 

1128 
exit 

1129 
end; 

79  1130 

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

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

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

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

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

1138 
begin 

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

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

1669  1141 
else if Gear^.dY <  _0_03 then PlaySound(sndGraveImpact, false, nil); 
1133  1142 
end; 
1143 
CheckGearDrowning(Gear); 

1144 
end; 

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

1145 

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

1148 
end; 
49  1149 

1150 
//////////////////////////////////////////////////////////////////////////////// 

854  1151 
procedure doStepIdle(Gear: PGear); 
1152 
begin 

1153 
AllInactive:= false; 

925  1154 
dec(Gear^.Timer); 
854  1155 
if Gear^.Timer = 0 then 
1156 
begin 

1157 
DeleteGear(Gear); 

1158 
AfterAttack 

1159 
end 

1160 
end; 

1161 

79  1162 
procedure doStepShover(Gear: PGear); 
1163 
var HHGear: PGear; 

1164 
begin 

351  1165 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
1166 
HHGear^.State:= HHGear^.State or gstNoDamage; 

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

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

1168 

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

1170 

351  1171 
HHGear^.State:= HHGear^.State and not gstNoDamage; 
854  1172 
Gear^.Timer:= 250; 
1173 
Gear^.doStep:= @doStepIdle 

79  1174 
end; 
1175 

1176 
//////////////////////////////////////////////////////////////////////////////// 

925  1177 
procedure doStepWhip(Gear: PGear); 
1178 
var HHGear: PGear; 

1179 
i: LongInt; 

1180 
begin 

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

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

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

1183 
DeleteCI(HHGear); 
925  1184 

1185 
for i:= 0 to 3 do 

1186 
begin 

1187 
AmmoShove(Gear, 30, 25); 

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

1189 
end; 

1190 

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

1192 
Gear^.Timer:= 250; 

1193 
Gear^.doStep:= @doStepIdle 

1194 
end; 

1195 

1196 
//////////////////////////////////////////////////////////////////////////////// 

79  1197 
procedure doStepFlame(Gear: PGear); 
1198 
begin 

1199 
AllInactive:= false; 

1433  1200 

79  1201 
if not TestCollisionYwithGear(Gear, 1) then 
1133  1202 
begin 
1586  1203 
if hwAbs(Gear^.dX) > _0_01 then 
1204 
Gear^.dX:= Gear^.dX * _0_995; 

1297  1205 

1133  1206 
Gear^.dY:= Gear^.dY + cGravity; 
1830  1207 
if hwAbs(Gear^.dY) > _0_2 then Gear^.dY:= Gear^.dY * _0_995; 
1297  1208 

1830  1209 
Gear^.X:= Gear^.X + Gear^.dX + cWindSpeed * 640; 
1133  1210 
Gear^.Y:= Gear^.Y + Gear^.dY; 
1297  1211 

1417  1212 
if not (hwRound(Gear^.Y) < cWaterLine) then 
1133  1213 
begin 
1214 
DeleteGear(Gear); 

1215 
exit 

1216 
end 

1217 
end else begin 

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

1219 
else begin 

1586  1220 
Gear^.Radius:= 9; 
1221 
AmmoShove(Gear, 4, 100); 

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

1133  1224 
dec(Gear^.Health); 
1586  1225 
Gear^.Timer:= 450  Gear^.Tag * 8 
1133  1226 
end 
1227 
end; 

79  1228 

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

79  1231 

351  1232 
if Gear^.Health = 0 then 
1133  1233 
DeleteGear(Gear) 
79  1234 
end; 
82  1235 

1236 
//////////////////////////////////////////////////////////////////////////////// 

1237 
procedure doStepFirePunchWork(Gear: PGear); 

1238 
var HHGear: PGear; 

1239 
begin 

1240 
AllInactive:= false; 

351  1241 
if ((Gear^.Message and gm_Destroy) <> 0) then 
1133  1242 
begin 
1243 
DeleteGear(Gear); 

1244 
AfterAttack; 

1245 
exit 

1246 
end; 

82  1247 

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

1133  1250 
begin 
1251 
Gear^.Tag:= hwRound(HHGear^.Y); 

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

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

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

1255 
AmmoShove(Gear, 30, 40); 

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

1257 
end; 

351  1258 

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

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

1133  1261 
begin 
1262 
HHGear^.State:= HHGear^.State or gstMoving; 

1263 
DeleteGear(Gear); 

1264 
AfterAttack; 

1265 
exit 

1266 
end; 

351  1267 
HHGear^.Y:= HHGear^.Y + HHGear^.dY 
82  1268 
end; 
1269 

1270 
procedure doStepFirePunch(Gear: PGear); 

1271 
var HHGear: PGear; 

1272 
begin 

1273 
AllInactive:= false; 

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

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

1278 

351  1279 
HHGear^.dY:=  _0_3; 
82  1280 

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

1282 
Gear^.dX:= SignAs(_0_45, Gear^.dX); 
351  1283 
Gear^.dY:=  _0_9; 
1284 
Gear^.doStep:= @doStepFirePunchWork; 

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

1669  1287 
PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false, PHedgehog(HHGear^.Hedgehog)^.Team^.voicepack) 
82  1288 
end; 
1289 

263  1290 
//////////////////////////////////////////////////////////////////////////////// 
1291 

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

1292 
procedure doStepParachuteWork(Gear: PGear); 
211  1293 
var HHGear: PGear; 
1294 
begin 

351  1295 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
82  1296 

516  1297 
inc(Gear^.Timer); 
1298 

212  1299 
if TestCollisionYwithGear(HHGear, 1) 
1133  1300 
or ((HHGear^.State and gstHHDriven) = 0) 
1301 
or CheckGearDrowning(HHGear) 

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

1303 
begin 

1304 
with HHGear^ do 

1305 
begin 

1306 
Message:= 0; 

1307 
SetLittle(dX); 

1308 
dY:= _0; 

1309 
State:= State or gstMoving; 

1310 
end; 

1311 
DeleteGear(Gear); 

1312 
exit 

1313 
end; 

211  1314 

351  1315 
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then 
1133  1316 
HHGear^.X:= HHGear^.X + cWindSpeed * 200; 
211  1317 

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

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

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

211  1322 

351  1323 
HHGear^.Y:= HHGear^.Y + cGravity * 100; 
568  1324 
Gear^.X:= HHGear^.X; 
1325 
Gear^.Y:= HHGear^.Y 

263  1326 
end; 
211  1327 

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

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

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

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

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

1332 

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

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

1334 

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

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

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

1337 

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

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

1340 

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

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

1342 

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

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

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

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

1346 

263  1347 
//////////////////////////////////////////////////////////////////////////////// 
1348 
procedure doStepAirAttackWork(Gear: PGear); 

1507  1349 
var i: Longint; 
263  1350 
begin 
1351 
AllInactive:= false; 

498  1352 
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; 
1124  1353 

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

1354 
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then 
1124  1355 
begin 
1356 
dec(Gear^.Health); 

1357 
case Gear^.State of 

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

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

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

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

1364 
end; 

1365 

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