author  unc0rr 
Mon, 12 Jan 2009 18:50:49 +0000  
changeset 1652  2f15a299ffc6 
parent 1643  434e28245dc0 
child 1669  b709e061577e 
permissions  rwrr 
4  1 
(* 
1066  2 
* Hedgewars, a free turn based strategy game 
883  3 
* Copyright (c) 20042008 Andrey Korotaev <unC0Rr@gmail.com> 
4  4 
* 
183  5 
* This program is free software; you can redistribute it and/or modify 
6 
* it under the terms of the GNU General Public License as published by 

7 
* the Free Software Foundation; version 2 of the License 

4  8 
* 
183  9 
* This program is distributed in the hope that it will be useful, 
10 
* but WITHOUT ANY WARRANTY; without even the implied warranty of 

11 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

12 
* GNU General Public License for more details. 

4  13 
* 
183  14 
* You should have received a copy of the GNU General Public License 
15 
* along with this program; if not, write to the Free Software 

16 
* Foundation, Inc., 59 Temple Place  Suite 330, Boston, MA 021111307, USA 

4  17 
*) 
18 

19 
procedure doStepDrowningGear(Gear: PGear); forward; 

20 

21 
function CheckGearDrowning(Gear: PGear): boolean; 

22 
begin 

498  23 
if cWaterLine < hwRound(Gear^.Y) + Gear^.Radius then 
1133  24 
begin 
25 
CheckGearDrowning:= true; 

26 
Gear^.State:= gstDrowning; 

27 
Gear^.doStep:= @doStepDrowningGear; 

28 
PlaySound(sndSplash, false) 

29 
end else 

30 
CheckGearDrowning:= false 

4  31 
end; 
32 

33 
procedure CheckCollision(Gear: PGear); 

34 
begin 

351  35 
if TestCollisionXwithGear(Gear, hwSign(Gear^.X)) or TestCollisionYwithGear(Gear, hwSign(Gear^.Y)) 
1133  36 
then Gear^.State:= Gear^.State or gstCollision 
37 
else Gear^.State:= Gear^.State and not gstCollision 

4  38 
end; 
39 

40 
procedure CheckHHDamage(Gear: PGear); 

522  41 
var dmg: Longword; 
4  42 
begin 
522  43 
if _0_4 < Gear^.dY then 
1123  44 
begin 
45 
if _0_6 < Gear^.dY then 

1132  46 
PlaySound(sndOw4, false) 
1123  47 
else 
1132  48 
PlaySound(sndOw1, false); 
1123  49 

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

51 
inc(Gear^.Damage, dmg); 

1505  52 
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, dmg, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color); 
1123  53 
end 
4  54 
end; 
55 

56 
//////////////////////////////////////////////////////////////////////////////// 

57 
//////////////////////////////////////////////////////////////////////////////// 

58 
procedure CalcRotationDirAngle(Gear: PGear); 

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

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

61 
dAngle:= (hwAbs(Gear^.dX) + hwAbs(Gear^.dY)).QWordValue / $80000000; 
1133  62 
if not Gear^.dX.isNegative then 
63 
Gear^.DirAngle:= Gear^.DirAngle + dAngle 

64 
else 

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

66 

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

67 
if Gear^.DirAngle < 0 then Gear^.DirAngle:= Gear^.DirAngle + 360 
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset

68 
else if 360 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle  360 
4  69 
end; 
70 

71 
//////////////////////////////////////////////////////////////////////////////// 

72 
procedure doStepDrowningGear(Gear: PGear); 

73 
begin 

74 
AllInactive:= false; 

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

4  77 
end; 
78 

79 
//////////////////////////////////////////////////////////////////////////////// 

80 
procedure doStepFallingGear(Gear: PGear); 

542  81 
var isFalling: boolean; 
4  82 
begin 
503  83 
Gear^.State:= Gear^.State and not gstCollision; 
84 

85 
if Gear^.dY.isNegative then 

1133  86 
begin 
87 
isFalling:= true; 

88 
if TestCollisionYwithGear(Gear, 1) then 

89 
begin 

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

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

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

93 
end 

94 
end else 

95 
if TestCollisionYwithGear(Gear, 1) then 

96 
begin 

97 
isFalling:= false; 

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

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

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

101 
end else isFalling:= true; 

503  102 

351  103 
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then 
1133  104 
begin 
105 
Gear^.dX:=  Gear^.dX * Gear^.Elasticity; 

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

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

108 
end; 

503  109 

542  110 
if isFalling then Gear^.dY:= Gear^.dY + cGravity; 
503  111 

351  112 
Gear^.X:= Gear^.X + Gear^.dX; 
113 
Gear^.Y:= Gear^.Y + Gear^.dY; 

4  114 
CheckGearDrowning(Gear); 
503  115 
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and 
1133  116 
(not isFalling) then 
117 
Gear^.State:= Gear^.State and not gstMoving 

118 
else 

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

4  120 
end; 
121 

122 
//////////////////////////////////////////////////////////////////////////////// 

123 
procedure doStepBomb(Gear: PGear); 

371  124 
var i: LongInt; 
919  125 
dX, dY: hwFloat; 
4  126 
begin 
127 
AllInactive:= false; 

1263  128 

4  129 
doStepFallingGear(Gear); 
1263  130 

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

1133  133 
begin 
134 
case Gear^.Kind of 

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

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

139 
for i:= 0 to 4 do 

140 
begin 

141 
dX:= rndSign(GetRandom * _0_1); 

142 
dY:= (GetRandom  _3) * _0_08; 

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

145 
end; 

146 
gtWatermelon: begin 

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

148 
for i:= 0 to 5 do 

149 
begin 

150 
dX:= rndSign(GetRandom * _0_1); 

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

157 
for i:= 0 to 127 do 

158 
begin 

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

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

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

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

163 
end 

164 
end; 

1133  165 
end; 
166 
DeleteGear(Gear); 

167 
exit 

168 
end; 

1263  169 

4  170 
CalcRotationDirAngle(Gear); 
1263  171 

172 
if Gear^.Kind = gtHellishBomb then 

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

175 

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

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

1279  179 
end; 
1263  180 

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

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

184 
PlaySound(sndGrenadeImpact, false) 

4  185 
end; 
186 

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

189 
AllInactive:= false; 

190 
PlaySound(sndMelon, false); 

191 
Gear^.doStep:= @doStepBomb 

192 
end; 

193 

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

196 
AllInactive:= false; 

197 
doStepFallingGear(Gear); 

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

203 
end; 

1262  204 

205 
if Gear^.Kind = gtMelonPiece then 

206 
CalcRotationDirAngle(Gear) 

207 
else 

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

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

78  210 
end; 
211 

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

214 
begin 

215 
AllInactive:= false; 

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

221 
DeleteGear(Gear); 

222 
exit 

223 
end; 

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

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

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

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

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

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

241 
DeleteGear(Gear) 

242 
end 

4  243 
end; 
244 

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

1505  247 
AllInactive:= false; 
1495  248 

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

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

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

257 
begin 

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

522  260 

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

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

265 
Gear^.doStep:= @doStepHealthTagWork 

266 
else 

267 
Gear^.doStep:= @doStepHealthTagWorkUnderWater; 

268 

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

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

274 
begin 

275 
AllInactive:= false; 

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

4  278 

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

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

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

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

296 
procedure doStepUFOWork(Gear: PGear); 

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

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

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

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

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

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

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

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

374  309 

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

311 
begin 

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

313 
if y + Gear^.Radius < cWaterLine then 

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

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

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

325 
end; 

326 

327 
procedure doStepUFO(Gear: PGear); 

328 
begin 

329 
AllInactive:= false; 

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

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

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

339 
end; 

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

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

4  346 
end; 
347 
end; 

348 

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

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

352 
AllInactive:= false; 

353 
inc(Gear^.Timer); 

354 
if Gear^.Timer > 75 then 

355 
begin 

356 
DeleteGear(Gear); 

357 
AfterAttack 

358 
end 

359 
end; 

360 

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

363 
begin 

364 
AllInactive:= false; 

876  365 

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

367 
begin 

368 
dec(Gear^.Timer); 

369 
if Gear^.Timer = 0 then 

370 
begin 

371 
PlaySound(sndShotgunFire, false); 

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

373 
end; 

374 
exit 

375 
end 

376 
else inc(Gear^.Timer); 

377 

4  378 
i:= 200; 
379 
repeat 

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

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

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

387 
ShotgunShot(Gear); 

388 
Gear^.doStep:= @doStepShotIdle; 

389 
exit 

390 
end; 

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

498  393 
if (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then 
876  394 
Gear^.doStep:= @doStepShotIdle 
4  395 
end; 
396 

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

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

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

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

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

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

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

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

421 
Gear^.Damage:= 0 

37  422 
end; 
498  423 
if (Gear^.Health <= 0) or (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then 
876  424 
Gear^.doStep:= @doStepShotIdle 
37  425 
end; 
426 

559  427 
procedure doStepDEagleShot(Gear: PGear); 
428 
begin 

429 
PlaySound(sndGun, false); 

430 
Gear^.doStep:= @doStepDEagleShotWork 

431 
end; 

432 

37  433 
//////////////////////////////////////////////////////////////////////////////// 
4  434 
procedure doStepActionTimer(Gear: PGear); 
435 
begin 

351  436 
dec(Gear^.Timer); 
437 
case Gear^.Kind of 

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

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

83  449 
end 
450 
end; 

451 
gtATFinishGame: begin 

452 
AllInactive:= false; 

351  453 
if Gear^.Timer = 0 then 
113  454 
begin 
455 
SendIPC('N'); 

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

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

464 
//////////////////////////////////////////////////////////////////////////////// 

465 
procedure doStepPickHammerWork(Gear: PGear); 

371  466 
var i, ei: LongInt; 
4  467 
HHGear: PGear; 
468 
begin 

70  469 
AllInactive:= false; 
351  470 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
471 
dec(Gear^.Timer); 

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

1200  473 
begin 
474 
StopSound(sndPickhammer); 

475 
DeleteGear(Gear); 

476 
AfterAttack; 

477 
exit 

478 
end; 

845  479 

422  480 
if (Gear^.Timer mod 33) = 0 then 
1200  481 
begin 
482 
HHGear^.State:= HHGear^.State or gstNoDamage; 

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

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

485 
end; 

422  486 

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

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

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

491 
while i <= ei do 

492 
begin 

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

494 
inc(i, 1) 

495 
end; 

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

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

498 
SetAllHHToActive; 

499 
end; 

4  500 
if TestCollisionYwithGear(Gear, 1) then 
1200  501 
begin 
502 
Gear^.dY:= _0; 

503 
SetLittle(HHGear^.dX); 

504 
HHGear^.dY:= _0; 

505 
end else 

506 
begin 

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

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

1417  509 
if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer:= 1 
1200  510 
end; 
4  511 

351  512 
Gear^.X:= Gear^.X + HHGear^.dX; 
513 
HHGear^.X:= Gear^.X; 

498  514 
HHGear^.Y:= Gear^.Y  int2hwFloat(cHHRadius); 
4  515 

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

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

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

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

498  521 
else Gear^.dX:= _0; 
4  522 
end; 
523 

524 
procedure doStepPickHammer(Gear: PGear); 

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

527 
HHGear: PGear; 
4  528 
begin 
529 
i:= 0; 

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

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

531 

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

4  537 
inc(y, 2); 
538 
inc(i) 

539 
end; 

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

540 

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

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

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

544 

282  545 
PlaySound(sndPickhammer, true); 
4  546 
doStepPickHammerWork(Gear); 
351  547 
Gear^.doStep:= @doStepPickHammerWork 
4  548 
end; 
549 

550 
//////////////////////////////////////////////////////////////////////////////// 

371  551 
var BTPrevAngle, BTSteps: LongInt; 
302  552 

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

553 
procedure doStepBlowTorchWork(Gear: PGear); 
302  554 
var HHGear: PGear; 
1528  555 
b: boolean; 
556 
prevX: LongInt; 

302  557 
begin 
558 
AllInactive:= false; 

351  559 
dec(Gear^.Timer); 
560 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 

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

561 

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

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

563 

305  564 
b:= false; 
565 

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

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

570 
BTPrevAngle:= HHGear^.Angle; 

571 
b:= true 

572 
end; 

573 

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

575 
begin 

576 
doStepHedgehogMoving(HHGear); 

577 
if (HHGear^.Damage > 0) then Gear^.Timer:= 0 

578 
end; 

305  579 

351  580 
if Gear^.Timer mod cHHStepTicks = 0 then 
1528  581 
begin 
582 
b:= true; 

583 
if Gear^.dX.isNegative then 

1547  584 
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Left 
1528  585 
else 
1547  586 
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Right; 
305  587 

1528  588 
if ((HHGear^.State and gstMoving) = 0) then 
589 
begin 

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

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

592 

593 
HedgehogStep(HHGear); 

594 

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

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

597 
end; 

305  598 

1528  599 
inc(BTSteps); 
600 
if BTSteps = 7 then 

601 
begin 

602 
BTSteps:= 0; 

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

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

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

1643  606 
AmmoShove(Gear, 2, 15); 
1528  607 
HHGear^.State:= HHGear^.State and not gstNoDamage 
608 
end; 

609 
end; 

305  610 

611 
if b then 

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

351  616 
if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) then 
1528  617 
begin 
618 
HHGear^.Message:= 0; 

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

620 
DeleteGear(Gear); 

621 
AfterAttack 

622 
end 

302  623 
end; 
624 

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

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

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

627 
begin 
371  628 
BTPrevAngle:= High(LongInt); 
305  629 
BTSteps:= 0; 
351  630 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
631 
HHGear^.Message:= 0; 

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

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

635 

302  636 
//////////////////////////////////////////////////////////////////////////////// 
637 

4  638 
procedure doStepRopeWork(Gear: PGear); 
639 
var HHGear: PGear; 

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

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

643 
haveDivided: boolean; 
4  644 

1504  645 
procedure DeleteMe; 
646 
begin 

647 
with HHGear^ do 

648 
begin 

649 
Message:= Message and not gm_Attack; 

650 
State:= State or gstMoving; 

651 
end; 

652 
DeleteGear(Gear) 

653 
end; 

4  654 

655 
begin 

351  656 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
108  657 

351  658 
if ((HHGear^.State and gstHHDriven) = 0) 
1504  659 
or (CheckGearDrowning(HHGear)) then 
660 
begin 

661 
DeleteMe; 

662 
exit 

663 
end; 

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

664 

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

4  667 

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

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

672 

673 
mdX:= ropeDx + HHGear^.dX; 

674 
mdY:= ropeDy + HHGear^.dY; 

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

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

677 
mdY:= mdY * len; 

678 

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

680 
Gear^.dY:= mdY; 

681 

682 
///// 

683 
tx:= HHGear^.X; 

684 
ty:= HHGear^.Y; 

4  685 

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

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

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

690 

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

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

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

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

695 

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

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

698 

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

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

701 
//// 

702 

1554  703 

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

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

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

706 
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

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

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

709 

1652  710 
len:= Gear^.Elasticity  _0_3x70; 
711 
while len > _0_3 do 

1504  712 
begin 
1652  713 
lx:= hwRound(Gear^.X + mdX * len); 
714 
ly:= hwRound(Gear^.Y + mdY * len); 

1504  715 
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0) and (Land[ly, lx] <> 0) then 
716 
begin 

717 
with RopePoints.ar[RopePoints.Count] do 

718 
begin 

719 
X:= Gear^.X; 

720 
Y:= Gear^.Y; 

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

721 
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); 
1652  722 
b:= (nx * HHGear^.dY) > (ny * HHGear^.dX); 
1504  723 
dLen:= len 
724 
end; 

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

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

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

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

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

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

731 
haveDivided:= true; 
1504  732 
break 
733 
end; 

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

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

736 

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

737 
if not haveDivided then 
1504  738 
if RopePoints.Count > 0 then // check whether the last dividing point could be removed 
739 
begin 

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

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

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

743 
begin 

744 
dec(RopePoints.Count); 

1652  745 
Gear^.X:= RopePoints.ar[RopePoints.Count].X; 
746 
Gear^.Y:= RopePoints.ar[RopePoints.Count].Y; 

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

749 
end 

750 
end; 

4  751 

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

752 
haveCollision:= false; 
351  753 
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

754 
begin 
1504  755 
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

756 
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

757 
end; 
351  758 
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

759 
begin 
1504  760 
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

761 
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

762 
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

763 

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

764 
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

765 
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

766 
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

767 
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

768 
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

769 
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

770 
end; 
4  771 

789  772 
len:= Distance(HHGear^.dX, HHGear^.dY); 
940  773 
if len > _0_8 then 
1504  774 
begin 
775 
len:= _0_8 / len; 

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

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

778 
end; 

789  779 

351  780 
if (Gear^.Message and gm_Attack) <> 0 then 
1504  781 
if (Gear^.State and gsttmpFlag) <> 0 then 
782 
DeleteMe 

783 
else 

784 
else 

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

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

4  787 
end; 
788 

789 

790 
procedure doStepRopeAttach(Gear: PGear); 

791 
var HHGear: PGear; 

351  792 
tx, ty, tt: hwFloat; 
4  793 
begin 
351  794 
Gear^.X:= Gear^.X  Gear^.dX; 
795 
Gear^.Y:= Gear^.Y  Gear^.dY; 

498  796 
Gear^.Elasticity:= Gear^.Elasticity + _1; 
351  797 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
517  798 
DeleteCI(HHGear); 
542  799 
if (HHGear^.State and gstMoving) <> 0 then 
1433  800 
if TestCollisionYwithGear(HHGear, 1) then 
801 
begin 

802 
CheckHHDamage(HHGear); 

803 
HHGear^.dY:= _0; 

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

805 
end else 

806 
begin 

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

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

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

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

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

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

813 
tt:= Gear^.Elasticity; 

814 
tx:= _0; 

815 
ty:= _0; 

816 
while tt > _20 do 

817 
begin 

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

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

820 
begin 

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

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

823 
Gear^.Elasticity:= tt; 

824 
Gear^.doStep:= @doStepRopeWork; 

1624
3cbf01d31e5c
 Fix bug when hedgehog was unable to drop some weapons from rope if it thrown rope in jump
unc0rr
parents:
1603
diff
changeset

825 
with HHGear^ do State:= State and not (gstAttacking or gstMoving); 
1433  826 
tt:= _0 
827 
end; 

828 
tx:= tx + Gear^.dX + Gear^.dX; 

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

830 
tt:= tt  _2; 

831 
end; 

832 
end; 

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

833 

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

835 

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

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

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

839 
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

840 

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

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

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

843 

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

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

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

846 
end; 
4  847 

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

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

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

850 
or (HHGear^.Damage > 0) then 
1433  851 
begin 
852 
with PHedgehog(Gear^.Hedgehog)^.Gear^ do 

853 
begin 

854 
State:= State and not gstAttacking; 

855 
Message:= Message and not gm_Attack 

856 
end; 

857 
DeleteGear(Gear) 

858 
end 

4  859 
end; 
860 

861 
procedure doStepRope(Gear: PGear); 

862 
begin 

351  863 
Gear^.dX:=  Gear^.dX; 
864 
Gear^.dY:=  Gear^.dY; 

865 
Gear^.doStep:= @doStepRopeAttach 

4  866 
end; 
867 

868 
//////////////////////////////////////////////////////////////////////////////// 

869 
procedure doStepSmokeTrace(Gear: PGear); 

870 
begin 

351  871 
inc(Gear^.Timer); 
872 
if Gear^.Timer > 64 then 

1133  873 
begin 
874 
Gear^.Timer:= 0; 

875 
dec(Gear^.State) 

876 
end; 

351  877 
Gear^.dX:= Gear^.dX + cWindSpeed; 
878 
Gear^.X:= Gear^.X + Gear^.dX; 

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

4  880 
end; 
9  881 

882 
//////////////////////////////////////////////////////////////////////////////// 

1045  883 
procedure doStepExplosionWork(Gear: PGear); 
9  884 
begin 
351  885 
inc(Gear^.Timer); 
886 
if Gear^.Timer > 75 then 

1133  887 
begin 
888 
inc(Gear^.State); 

889 
Gear^.Timer:= 0; 

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

891 
end; 

9  892 
end; 
10  893 

1045  894 
procedure doStepExplosion(Gear: PGear); 
895 
var i: LongWord; 

896 
begin 

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

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

1045  900 
Gear^.doStep:= @doStepExplosionWork 
901 
end; 

902 

10  903 
//////////////////////////////////////////////////////////////////////////////// 
904 
procedure doStepMine(Gear: PGear); 

905 
begin 

542  906 
if (Gear^.State and gstMoving) <> 0 then 
914  907 
begin 
908 
DeleteCI(Gear); 

909 
doStepFallingGear(Gear); 

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

911 
begin 

912 
AddGearCI(Gear); 

913 
Gear^.dX:= _0; 

914 
Gear^.dY:= _0 

915 
end; 

916 
CalcRotationDirAngle(Gear); 

917 
AllInactive:= false 

918 
end else 

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

920 
doStepFallingGear(Gear); 

351  921 

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

1133  923 
if ((Gear^.State and gstAttacking) = 0) then 
924 
begin 

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

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

927 
end else // gstAttacking <> 0 

928 
begin 

929 
AllInactive:= false; 

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

931 
if Gear^.Timer = 0 then 

932 
begin 

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

934 
DeleteGear(Gear); 

935 
exit 

936 
end; 

937 
dec(Gear^.Timer); 

938 
end else // gsttmpFlag = 0 

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

10  940 
end; 
57  941 

39  942 
//////////////////////////////////////////////////////////////////////////////// 
943 
procedure doStepDynamite(Gear: PGear); 

944 
begin 

43  945 
doStepFallingGear(Gear); 
946 
AllInactive:= false; 

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

1133  949 
begin 
950 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); 

951 
DeleteGear(Gear); 

952 
exit 

953 
end; 

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

956 

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

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

961 
begin 
351  962 
if (Gear^.Message and gm_Destroy) > 0 then 
1133  963 
begin 
964 
DeleteGear(Gear); 

965 
FreeActionsList; 

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

967 
with CurrentHedgehog^ do 

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

969 
exit 

970 
end; 

15  971 

351  972 
if Gear^.Damage > 0 then 
1133  973 
begin 
974 
x:= hwRound(Gear^.X); 

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

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

978 

979 
if k = gtCase then 

1133  980 
begin 
981 
doMakeExplosion(x, y, 25, EXPLAutoSound); 

982 
for i:= 0 to 63 do 

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

984 
end; 

985 
exit 

986 
end; 

79  987 

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

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

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

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

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

995 
begin 

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

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

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

999 
end; 

1000 
CheckGearDrowning(Gear); 

1001 
end; 

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

1002 

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

1005 
end; 
49  1006 

1007 
//////////////////////////////////////////////////////////////////////////////// 

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

1133  1010 
record 
1011 
dy, ny, dw: LongInt; 

1012 
team: PTeam; 

1013 
SortFactor: QWord; 

1014 
end; 

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

1015 
currsorter: PGear = nil; 
49  1016 

1017 
procedure doStepTeamHealthSorterWork(Gear: PGear); 

371  1018 
var i: LongInt; 
49  1019 
begin 
1020 
AllInactive:= false; 

351  1021 
dec(Gear^.Timer); 
1022 
if (Gear^.Timer and 15) = 0 then 

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

1025 
begin 

1026 
{$WARNINGS OFF} 

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

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

1029 
{$WARNINGS ON} 

1030 
end; 

1031 

351  1032 
if (Gear^.Timer = 0) or (currsorter <> Gear) then 
1133  1033 
begin 
1034 
if currsorter = Gear then currsorter:= nil; 

1035 
DeleteGear(Gear) 

1036 
end 

49  1037 
end; 
1038 

1039 
procedure doStepTeamHealthSorter(Gear: PGear); 

1133  1040 
var i: Longword; 
1041 
b: boolean; 

1042 
t: LongInt; 

49  1043 
begin 
1044 
AllInactive:= false; 

557  1045 

547  1046 
for t:= 0 to Pred(TeamsCount) do 
1133  1047 
with thexchar[t] do 
1048 
begin 

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

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

1051 
team:= TeamsArray[t]; 

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

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

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

1055 
end; 

547  1056 

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

1057 
if TeamsCount > 1 then 
1133  1058 
repeat 
1059 
b:= true; 

1060 
for t:= 0 to TeamsCount  2 do 

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

1062 
begin 

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

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

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

1066 
b:= false 

1067 
end 

1068 
until b; 

557  1069 

1120  1070 
t:=  4; 
557  1071 
for i:= 0 to Pred(TeamsCount) do 
1133  1072 
with thexchar[i] do 
1073 
begin 

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

1075 
ny:= t; 

1076 
dy:= dy  ny 

1077 
end; 

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

1078 

557  1079 
Gear^.Timer:= cSorterWorkTime; 
351  1080 
Gear^.doStep:= @doStepTeamHealthSorterWork; 
143  1081 
currsorter:= Gear 
49  1082 
end; 
1083 

79  1084 
//////////////////////////////////////////////////////////////////////////////// 
854  1085 
procedure doStepIdle(Gear: PGear); 
1086 
begin 

1087 
AllInactive:= false; 

925  1088 
dec(Gear^.Timer); 
854  1089 
if Gear^.Timer = 0 then 
1090 
begin 

1091 
DeleteGear(Gear); 

1092 
AfterAttack 

1093 
end 

1094 
end; 

1095 

79  1096 
procedure doStepShover(Gear: PGear); 
1097 
var HHGear: PGear; 

1098 
begin 

351  1099 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
1100 
HHGear^.State:= HHGear^.State or gstNoDamage; 

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

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

1102 

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

1104 

351  1105 
HHGear^.State:= HHGear^.State and not gstNoDamage; 
854  1106 
Gear^.Timer:= 250; 
1107 
Gear^.doStep:= @doStepIdle 

79  1108 
end; 
1109 

1110 
//////////////////////////////////////////////////////////////////////////////// 

925  1111 
procedure doStepWhip(Gear: PGear); 
1112 
var HHGear: PGear; 

1113 
i: LongInt; 

1114 
begin 

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

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

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

1117 
DeleteCI(HHGear); 
925  1118 

1119 
for i:= 0 to 3 do 

1120 
begin 

1121 
AmmoShove(Gear, 30, 25); 

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

1123 
end; 

1124 

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

1126 
Gear^.Timer:= 250; 

1127 
Gear^.doStep:= @doStepIdle 

1128 
end; 

1129 

1130 
//////////////////////////////////////////////////////////////////////////////// 

79  1131 
procedure doStepFlame(Gear: PGear); 
1132 
begin 

1133 
AllInactive:= false; 

1433  1134 

79  1135 
if not TestCollisionYwithGear(Gear, 1) then 
1133  1136 
begin 
1586  1137 
if hwAbs(Gear^.dX) > _0_01 then 
1138 
Gear^.dX:= Gear^.dX * _0_995; 

1297  1139 

1133  1140 
Gear^.dY:= Gear^.dY + cGravity; 
1586  1141 
if hwAbs(Gear^.dY) > _0_08 then Gear^.dY:= Gear^.dY * _0_995; 
1297  1142 

1586  1143 
Gear^.X:= Gear^.X + Gear^.dX + cWindSpeed * 270; 
1133  1144 
Gear^.Y:= Gear^.Y + Gear^.dY; 
1297  1145 

1417  1146 
if not (hwRound(Gear^.Y) < cWaterLine) then 
1133  1147 
begin 
1148 
DeleteGear(Gear); 

1149 
exit 

1150 
end 

1151 
end else begin 

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

1153 
else begin 

1586  1154 
Gear^.Radius:= 9; 
1155 
AmmoShove(Gear, 4, 100); 

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

1133  1158 
dec(Gear^.Health); 
1586  1159 
Gear^.Timer:= 450  Gear^.Tag * 8 
1133  1160 
end 
1161 
end; 

79  1162 

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

79  1165 

351  1166 
if Gear^.Health = 0 then 
1133  1167 
DeleteGear(Gear) 
79  1168 
end; 
82  1169 

1170 
//////////////////////////////////////////////////////////////////////////////// 

1171 
procedure doStepFirePunchWork(Gear: PGear); 

1172 
var HHGear: PGear; 

1173 
begin 

1174 
AllInactive:= false; 

351  1175 
if ((Gear^.Message and gm_Destroy) <> 0) then 
1133  1176 
begin 
1177 
DeleteGear(Gear); 

1178 
AfterAttack; 

1179 
exit 

1180 
end; 

82  1181 

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

1133  1184 
begin 
1185 
Gear^.Tag:= hwRound(HHGear^.Y); 

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

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

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

1189 
AmmoShove(Gear, 30, 40); 

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

1191 
end; 

351  1192 

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

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

1133  1195 
begin 
1196 
HHGear^.State:= HHGear^.State or gstMoving; 

1197 
DeleteGear(Gear); 

1198 
AfterAttack; 

1199 
exit 

1200 
end; 

351  1201 
HHGear^.Y:= HHGear^.Y + HHGear^.dY 
82  1202 
end; 
1203 

1204 
procedure doStepFirePunch(Gear: PGear); 

1205 
var HHGear: PGear; 

1206 
begin 

1207 
AllInactive:= false; 

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

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

1212 

351  1213 
HHGear^.dY:=  _0_3; 
82  1214 

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

1216 
Gear^.dX:= SignAs(_0_45, Gear^.dX); 
351  1217 
Gear^.dY:=  _0_9; 
1218 
Gear^.doStep:= @doStepFirePunchWork; 

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

1221 
PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false) 

82  1222 
end; 
1223 

263  1224 
//////////////////////////////////////////////////////////////////////////////// 
1225 

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

1226 
procedure doStepParachuteWork(Gear: PGear); 
211  1227 
var HHGear: PGear; 
1228 
begin 

351  1229 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
82  1230 

516  1231 
inc(Gear^.Timer); 
1232 

212  1233 
if TestCollisionYwithGear(HHGear, 1) 
1133  1234 
or ((HHGear^.State and gstHHDriven) = 0) 
1235 
or CheckGearDrowning(HHGear) 

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

1237 
begin 

1238 
with HHGear^ do 

1239 
begin 

1240 
Message:= 0; 

1241 
SetLittle(dX); 

1242 
dY:= _0; 

1243 
State:= State or gstMoving; 

1244 
end; 

1245 
DeleteGear(Gear); 

1246 
exit 

1247 
end; 

211  1248 

351  1249 
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then 
1133  1250 
HHGear^.X:= HHGear^.X + cWindSpeed * 200; 
211  1251 

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

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

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

211  1256 

351  1257 
HHGear^.Y:= HHGear^.Y + cGravity * 100; 
568  1258 
Gear^.X:= HHGear^.X; 
1259 
Gear^.Y:= HHGear^.Y 

263  1260 
end; 
211  1261 

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

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

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

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

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

1266 

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

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

1268 

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

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

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

1271 

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

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

1274 

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

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

1276 

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

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

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

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

1280 

263  1281 
//////////////////////////////////////////////////////////////////////////////// 
1282 
procedure doStepAirAttackWork(Gear: PGear); 

1507  1283 
var i: Longint; 
263  1284 
begin 
1285 
AllInactive:= false; 

498  1286 
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; 
1124  1287 

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

1288 
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then 
1124  1289 
begin 
1290 
dec(Gear^.Health); 

1291 
case Gear^.State of 

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

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

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

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

1298 
end; 

1299 

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

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

1302 

498  1303 
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < 1024) then DeleteGear(Gear) 
263  1304 
end; 
1305 

1306 
procedure doStepAirAttack(Gear: PGear); 

1307 
begin 

1308 
AllInactive:= false; 

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

1309 

1507  1310 
if Gear^.X.QWordValue = 0 then 
1311 
Gear^.Tag:= 1 

1312 
else 

1313 
Gear^.Tag:= 1; 

1314 

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

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

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

1319 
if int2hwFloat(TargetPoint.Y)  Gear^.Y > _0 then 
1133  1320 
Gear^.dX:= Gear^.dX  cBombsSpeed * hwSqrt((int2hwFloat(TargetPoint.Y)  Gear^.Y) * 2 / cGravity) * Gear^.Tag; 
543
465e2ec8f05f
 Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset

1321 

351  1322 
Gear^.Health:= 6; 
801  1323 
Gear^.doStep:= @doStepAirAttackWork; 
1324 
PlaySound(sndIncoming, false) 

263  1325 
end; 
1326 

1327 
//////////////////////////////////////////////////////////////////////////////// 

1328 

1329 
procedure doStepAirBomb(Gear: PGear); 

1330 
begin 

1331 
AllInactive:= false; 

1332 
doStepFallingGear(Gear); 

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

1336 
DeleteGear(Gear); 

1337 
exit 

1338 
end; 

263  1339 
if (GameTicks and $3F) = 0 then 
1133  1340 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) 
211  1341 
end; 
409  1342 

1343 
//////////////////////////////////////////////////////////////////////////////// 

1344 

1345 
procedure doStepGirder(Gear: PGear); 

415  1346 
var HHGear: PGear; 
409  1347 
begin 
1348 
AllInactive:= false; 

415  1349 

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

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

520  1353 
sprAmGirder, Gear^.State, true) then 
1133  1354 
begin 
1355 
HHGear^.Message:= HHGear^.Message and not gm_Attack; 

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

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

1358 
DeleteGear(Gear); 

1359 
isCursorVisible:= true 

1360 
end 

1361 
else begin 

1362 
DeleteGear(Gear); 

1363 
AfterAttack 

1364 
end; 

415  1365 
TargetPoint.X:= NoPointX 
409  1366 
end; 
520  1367 

1368 
//////////////////////////////////////////////////////////////////////////////// 

525  1369 
procedure doStepTeleportAfter(Gear: PGear); 
912  1370 
var HHGear: PGear; 
1371 
begin 

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