author  unc0rr 
Thu, 20 Nov 2008 15:48:50 +0000  
changeset 1504  1603a796f42a 
parent 1501  a0e56fdf10cd 
child 1505  3a96e93572cb 
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); 

52 
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, dmg, Gear); 

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); 

136 
gtClusterBomb: begin 

137 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); 

138 
for i:= 0 to 4 do 

139 
begin 

140 
dX:= rndSign(GetRandom * _0_1); 

141 
dY:= (GetRandom  _3) * _0_08; 

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

144 
end; 

145 
gtWatermelon: begin 

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

147 
for i:= 0 to 5 do 

148 
begin 

149 
dX:= rndSign(GetRandom * _0_1); 

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

1133  155 
end; 
156 
DeleteGear(Gear); 

157 
exit 

158 
end; 

1263  159 

4  160 
CalcRotationDirAngle(Gear); 
1263  161 

162 
if Gear^.Kind = gtHellishBomb then 

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

165 

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

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

1279  169 
end; 
1263  170 

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

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

174 
PlaySound(sndGrenadeImpact, false) 

4  175 
end; 
176 

1279  177 
procedure doStepWatermelon(Gear: PGear); 
178 
begin 

179 
AllInactive:= false; 

180 
PlaySound(sndMelon, false); 

181 
Gear^.doStep:= @doStepBomb 

182 
end; 

183 

78  184 
procedure doStepCluster(Gear: PGear); 
185 
begin 

186 
AllInactive:= false; 

187 
doStepFallingGear(Gear); 

351  188 
if (Gear^.State and gstCollision) <> 0 then 
1133  189 
begin 
1261  190 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Timer, EXPLAutoSound); 
1133  191 
DeleteGear(Gear); 
192 
exit 

193 
end; 

1262  194 

195 
if Gear^.Kind = gtMelonPiece then 

196 
CalcRotationDirAngle(Gear) 

197 
else 

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

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

78  200 
end; 
201 

4  202 
//////////////////////////////////////////////////////////////////////////////// 
203 
procedure doStepGrenade(Gear: PGear); 

204 
begin 

205 
AllInactive:= false; 

351  206 
Gear^.dX:= Gear^.dX + cWindSpeed; 
4  207 
doStepFallingGear(Gear); 
351  208 
if (Gear^.State and gstCollision) <> 0 then 
1133  209 
begin 
210 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 

211 
DeleteGear(Gear); 

212 
exit 

213 
end; 

4  214 
if (GameTicks and $3F) = 0 then 
1133  215 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) 
4  216 
end; 
217 

218 
//////////////////////////////////////////////////////////////////////////////// 

95  219 
procedure doStepHealthTagWork(Gear: PGear); 
4  220 
begin 
522  221 
if Gear^.Kind = gtHealthTag then 
222 
AllInactive:= false; 

351  223 
dec(Gear^.Timer); 
522  224 
Gear^.Y:= Gear^.Y + Gear^.dY; 
351  225 
if Gear^.Timer = 0 then 
1133  226 
begin 
227 
if Gear^.Kind = gtHealthTag then 

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

229 
DeleteGear(Gear) 

230 
end 

4  231 
end; 
232 

263  233 
procedure doStepHealthTagWorkUnderWater(Gear: PGear); 
234 
begin 

1495  235 
if Gear^.Kind = gtHealthTag then 
236 
AllInactive:= false; 

237 

351  238 
Gear^.Y:= Gear^.Y  _0_08; 
1495  239 

498  240 
if hwRound(Gear^.Y) < cWaterLine + 10 then 
263  241 
DeleteGear(Gear) 
242 
end; 

243 

95  244 
procedure doStepHealthTag(Gear: PGear); 
245 
var s: shortstring; 

522  246 
font: THWFont; 
95  247 
begin 
522  248 
if Gear^.Kind = gtHealthTag then 
249 
begin 

813  250 
AllInactive:= false; 
522  251 
font:= fnt16; 
252 
Gear^.dY:= _0_08 

253 
end else 

254 
begin 

255 
font:= fntSmall; 

256 
Gear^.dY:= _0_02 

257 
end; 

258 

351  259 
str(Gear^.State, s); 
762  260 
Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, font); 
498  261 
if hwRound(Gear^.Y) < cWaterLine then Gear^.doStep:= @doStepHealthTagWork 
522  262 
else Gear^.doStep:= @doStepHealthTagWorkUnderWater; 
762  263 
Gear^.Y:= Gear^.Y  int2hwFloat(Gear^.Tex^.h) 
95  264 
end; 
265 

4  266 
//////////////////////////////////////////////////////////////////////////////// 
267 
procedure doStepGrave(Gear: PGear); 

268 
begin 

269 
AllInactive:= false; 

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

4  272 

351  273 
if not Gear^.dY.isNegative then 
68  274 
if TestCollisionY(Gear, 1) then 
4  275 
begin 
351  276 
Gear^.dY:=  Gear^.dY * Gear^.Elasticity; 
277 
if Gear^.dY >  _1div1024 then 

4  278 
begin 
351  279 
Gear^.Active:= false; 
4  280 
exit 
351  281 
end else if Gear^.dY <  _0_03 then PlaySound(sndGraveImpact, false) 
4  282 
end; 
351  283 
Gear^.Y:= Gear^.Y + Gear^.dY; 
4  284 
CheckGearDrowning(Gear); 
351  285 
Gear^.dY:= Gear^.dY + cGravity 
4  286 
end; 
287 

288 
//////////////////////////////////////////////////////////////////////////////// 

289 
procedure doStepUFOWork(Gear: PGear); 

351  290 
var t: hwFloat; 
374  291 
y: LongInt; 
4  292 
begin 
293 
AllInactive:= false; 

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

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

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

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

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

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

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

374  302 

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

304 
begin 

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

306 
if y + Gear^.Radius < cWaterLine then 

498  307 
AddGear(hwRound(Gear^.X), y, gtSmokeTrace, 0, _0, _0, 0); 
374  308 
end; 
309 

4  310 
CheckCollision(Gear); 
351  311 
dec(Gear^.Timer); 
312 
if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then 

4  313 
begin 
560  314 
StopSound(sndUFO); 
351  315 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 
4  316 
DeleteGear(Gear); 
317 
end; 

318 
end; 

319 

320 
procedure doStepUFO(Gear: PGear); 

321 
begin 

322 
AllInactive:= false; 

351  323 
Gear^.X:= Gear^.X + Gear^.dX; 
324 
Gear^.Y:= Gear^.Y + Gear^.dY; 

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

4  326 
CheckCollision(Gear); 
351  327 
if (Gear^.State and gstCollision) <> 0 then 
4  328 
begin 
351  329 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 
4  330 
DeleteGear(Gear); 
331 
exit 

332 
end; 

351  333 
dec(Gear^.Timer); 
334 
if Gear^.Timer = 0 then 

4  335 
begin 
560  336 
PlaySound(sndUFO, true); 
351  337 
Gear^.Timer:= 5000; 
338 
Gear^.doStep:= @doStepUFOWork 

4  339 
end; 
340 
end; 

341 

342 
//////////////////////////////////////////////////////////////////////////////// 

876  343 
procedure doStepShotIdle(Gear: PGear); 
344 
begin 

345 
AllInactive:= false; 

346 
inc(Gear^.Timer); 

347 
if Gear^.Timer > 75 then 

348 
begin 

349 
DeleteGear(Gear); 

350 
AfterAttack 

351 
end 

352 
end; 

353 

4  354 
procedure doStepShotgunShot(Gear: PGear); 
355 
var i: LongWord; 

356 
begin 

357 
AllInactive:= false; 

876  358 

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

360 
begin 

361 
dec(Gear^.Timer); 

362 
if Gear^.Timer = 0 then 

363 
begin 

364 
PlaySound(sndShotgunFire, false); 

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

366 
end; 

367 
exit 

368 
end 

369 
else inc(Gear^.Timer); 

370 

4  371 
i:= 200; 
372 
repeat 

351  373 
Gear^.X:= Gear^.X + Gear^.dX; 
374 
Gear^.Y:= Gear^.Y + Gear^.dY; 

4  375 
CheckCollision(Gear); 
351  376 
if (Gear^.State and gstCollision) <> 0 then 
876  377 
begin 
378 
Gear^.X:= Gear^.X + Gear^.dX * 8; 

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

380 
ShotgunShot(Gear); 

381 
Gear^.doStep:= @doStepShotIdle; 

382 
exit 

383 
end; 

4  384 
dec(i) 
385 
until i = 0; 

498  386 
if (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then 
876  387 
Gear^.doStep:= @doStepShotIdle 
4  388 
end; 
389 

390 
//////////////////////////////////////////////////////////////////////////////// 

559  391 
procedure doStepDEagleShotWork(Gear: PGear); 
38  392 
var i, x, y: LongWord; 
351  393 
oX, oY: hwFloat; 
38  394 
begin 
395 
AllInactive:= false; 

876  396 
inc(Gear^.Timer); 
37  397 
i:= 80; 
351  398 
oX:= Gear^.X; 
399 
oY:= Gear^.Y; 

37  400 
repeat 
351  401 
Gear^.X:= Gear^.X + Gear^.dX; 
402 
Gear^.Y:= Gear^.Y + Gear^.dY; 

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

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

38  405 
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0) 
351  406 
and (Land[y, x] <> 0) then inc(Gear^.Damage); 
519  407 
if Gear^.Damage > 5 then AmmoShove(Gear, 7, 20); 
38  408 
dec(i) 
351  409 
until (i = 0) or (Gear^.Damage > Gear^.Health); 
410 
if Gear^.Damage > 0 then 

37  411 
begin 
351  412 
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82  i, 1); 
413 
dec(Gear^.Health, Gear^.Damage); 

414 
Gear^.Damage:= 0 

37  415 
end; 
498  416 
if (Gear^.Health <= 0) or (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then 
876  417 
Gear^.doStep:= @doStepShotIdle 
37  418 
end; 
419 

559  420 
procedure doStepDEagleShot(Gear: PGear); 
421 
begin 

422 
PlaySound(sndGun, false); 

423 
Gear^.doStep:= @doStepDEagleShotWork 

424 
end; 

425 

37  426 
//////////////////////////////////////////////////////////////////////////////// 
4  427 
procedure doStepActionTimer(Gear: PGear); 
428 
begin 

351  429 
dec(Gear^.Timer); 
430 
case Gear^.Kind of 

83  431 
gtATStartGame: begin 
4  432 
AllInactive:= false; 
351  433 
if Gear^.Timer = 0 then 
83  434 
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); 
4  435 
end; 
83  436 
gtATSmoothWindCh: begin 
351  437 
if Gear^.Timer = 0 then 
6  438 
begin 
351  439 
if WindBarWidth < Gear^.Tag then inc(WindBarWidth) 
440 
else if WindBarWidth > Gear^.Tag then dec(WindBarWidth); 

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

83  442 
end 
443 
end; 

444 
gtATFinishGame: begin 

445 
AllInactive:= false; 

351  446 
if Gear^.Timer = 0 then 
113  447 
begin 
448 
SendIPC('N'); 

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

449 
SendIPC('q'); 
83  450 
GameState:= gsExit 
113  451 
end 
6  452 
end; 
4  453 
end; 
351  454 
if Gear^.Timer = 0 then DeleteGear(Gear) 
4  455 
end; 
456 

457 
//////////////////////////////////////////////////////////////////////////////// 

458 
procedure doStepPickHammerWork(Gear: PGear); 

371  459 
var i, ei: LongInt; 
4  460 
HHGear: PGear; 
461 
begin 

70  462 
AllInactive:= false; 
351  463 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
464 
dec(Gear^.Timer); 

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

1200  466 
begin 
467 
StopSound(sndPickhammer); 

468 
DeleteGear(Gear); 

469 
AfterAttack; 

470 
exit 

471 
end; 

845  472 

422  473 
if (Gear^.Timer mod 33) = 0 then 
1200  474 
begin 
475 
HHGear^.State:= HHGear^.State or gstNoDamage; 

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

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

478 
end; 

422  479 

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

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

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

484 
while i <= ei do 

485 
begin 

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

487 
inc(i, 1) 

488 
end; 

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

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

491 
SetAllHHToActive; 

492 
end; 

4  493 
if TestCollisionYwithGear(Gear, 1) then 
1200  494 
begin 
495 
Gear^.dY:= _0; 

496 
SetLittle(HHGear^.dX); 

497 
HHGear^.dY:= _0; 

498 
end else 

499 
begin 

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

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

1417  502 
if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer:= 1 
1200  503 
end; 
4  504 

351  505 
Gear^.X:= Gear^.X + HHGear^.dX; 
506 
HHGear^.X:= Gear^.X; 

498  507 
HHGear^.Y:= Gear^.Y  int2hwFloat(cHHRadius); 
4  508 

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

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

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

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

498  514 
else Gear^.dX:= _0; 
4  515 
end; 
516 

517 
procedure doStepPickHammer(Gear: PGear); 

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

520 
HHGear: PGear; 
4  521 
begin 
522 
i:= 0; 

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

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

524 

498  525 
y:= hwRound(Gear^.Y)  cHHRadius * 2; 
351  526 
while y < hwRound(Gear^.Y) do 
4  527 
begin 
371  528 
ar[i].Left := hwRound(Gear^.X)  Gear^.Radius  LongInt(GetRandom(2)); 
529 
ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); 

4  530 
inc(y, 2); 
531 
inc(i) 

532 
end; 

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

533 

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

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

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

537 

282  538 
PlaySound(sndPickhammer, true); 
4  539 
doStepPickHammerWork(Gear); 
351  540 
Gear^.doStep:= @doStepPickHammerWork 
4  541 
end; 
542 

543 
//////////////////////////////////////////////////////////////////////////////// 

371  544 
var BTPrevAngle, BTSteps: LongInt; 
302  545 

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

546 
procedure doStepBlowTorchWork(Gear: PGear); 
302  547 
var HHGear: PGear; 
305  548 
b: boolean; 
302  549 
begin 
550 
AllInactive:= false; 

351  551 
dec(Gear^.Timer); 
552 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 

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

553 

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

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

555 

305  556 
b:= false; 
557 

371  558 
if abs(LongInt(HHGear^.Angle)  BTPrevAngle) > 7 then 
305  559 
begin 
498  560 
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX); 
355  561 
Gear^.dY:= AngleCos(HHGear^.Angle) * (  _0_5); 
351  562 
BTPrevAngle:= HHGear^.Angle; 
358  563 
b:= true 
305  564 
end; 
565 

351  566 
if Gear^.Timer mod cHHStepTicks = 0 then 
302  567 
begin 
305  568 
b:= true; 
498  569 
if Gear^.dX.isNegative then HHGear^.Message:= (HHGear^.Message or gm_Left) and not gm_Right 
570 
else HHGear^.Message:= (HHGear^.Message or gm_Right) and not gm_Left; 

357  571 

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

302  573 
HedgehogStep(HHGear); 
357  574 
HHGear^.State:= HHGear^.State or gstAttacking; 
305  575 

576 
inc(BTSteps); 

511  577 
if BTSteps = 7 then 
305  578 
begin 
579 
BTSteps:= 0; 

511  580 
Gear^.X:= HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); 
581 
Gear^.Y:= HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); 

351  582 
HHGear^.State:= HHGear^.State or gstNoDamage; 
1501  583 
AmmoShove(Gear, 2, 10); 
351  584 
HHGear^.State:= HHGear^.State and not gstNoDamage 
305  585 
end; 
586 

542  587 
if (HHGear^.State and gstMoving) <> 0 then Gear^.Timer:= 0 
302  588 
end; 
305  589 

590 
if b then 

498  591 
DrawTunnel(HHGear^.X  Gear^.dX * cHHRadius, HHGear^.Y  _4  Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, 
351  592 
Gear^.dX, Gear^.dY, 
1501  593 
cHHRadius * 5, cHHRadius * 2 + 7); 
305  594 

351  595 
if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) then 
302  596 
begin 
351  597 
HHGear^.Message:= 0; 
302  598 
DeleteGear(Gear); 
599 
AfterAttack 

600 
end 

601 
end; 

602 

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

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

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

605 
begin 
371  606 
BTPrevAngle:= High(LongInt); 
305  607 
BTSteps:= 0; 
351  608 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
609 
HHGear^.Message:= 0; 

610 
Gear^.doStep:= @doStepBlowTorchWork 

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

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

612 

302  613 
//////////////////////////////////////////////////////////////////////////////// 
614 

4  615 
procedure doStepRopeWork(Gear: PGear); 
70  616 
const flCheck: boolean = false; 
4  617 
var HHGear: PGear; 
1504  618 
len, cs, cc, tx, ty, nx, ny: hwFloat; 
619 
lx, ly: LongInt; 

4  620 

1504  621 
procedure DeleteMe; 
622 
begin 

623 
with HHGear^ do 

624 
begin 

625 
Message:= Message and not gm_Attack; 

626 
State:= State or gstMoving; 

627 
end; 

628 
DeleteGear(Gear) 

629 
end; 

4  630 

631 
begin 

351  632 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
108  633 

351  634 
if ((HHGear^.State and gstHHDriven) = 0) 
1504  635 
or (CheckGearDrowning(HHGear)) then 
636 
begin 

637 
DeleteMe; 

638 
exit 

639 
end; 

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

640 

351  641 
Gear^.dX:= HHGear^.X  Gear^.X; 
642 
Gear^.dY:= HHGear^.Y  Gear^.Y; 

4  643 

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

4  646 

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

351  649 
cs:= Gear^.dY + HHGear^.dY; 
650 
cc:= Gear^.dX + HHGear^.dX; 

498  651 
len:= _1 / Distance(cc, cs); 
789  652 
cc:= cc * len; // rope vector plus hedgehog direction vector normalized 
108  653 
cs:= cs * len; 
4  654 

1361  655 
nx:= SignAs(cs, HHGear^.dX) * 7; // hedgehog direction normalized with length 7 
656 
ny:= SignAs(cc, HHGear^.dY) * 7; 

789  657 

4  658 
flCheck:= not flCheck; 
659 
if flCheck then // check whether rope needs dividing 

1504  660 
begin 
661 
len:= Gear^.Elasticity  _20; 

662 
while len > _5 do 

663 
begin 

664 
tx:= cc*len; 

665 
ty:= cs*len; 

666 
lx:= hwRound(Gear^.X + tx + nx); 

667 
ly:= hwRound(Gear^.Y + ty + ny); 

668 
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0) and (Land[ly, lx] <> 0) then 

669 
begin 

670 
with RopePoints.ar[RopePoints.Count] do 

671 
begin 

672 
X:= Gear^.X; 

673 
Y:= Gear^.Y; 

674 
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); 

675 
b:= (cc * HHGear^.dY) > (cs * HHGear^.dX); 

676 
dLen:= len 

677 
end; 

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

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

680 
inc(RopePoints.Count); 

681 
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); 

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

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

684 
break 

685 
end; 

686 
len:= len  _0_5 

687 
end; 

688 
end else 

689 
if RopePoints.Count > 0 then // check whether the last dividing point could be removed 

690 
begin 

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

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

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

694 
begin 

695 
dec(RopePoints.Count); 

696 
Gear^.X:=RopePoints.ar[RopePoints.Count].X; 

697 
Gear^.Y:=RopePoints.ar[RopePoints.Count].Y; 

698 
Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; 

699 
Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen 

700 
end 

701 
end; 

4  702 

351  703 
Gear^.dX:= HHGear^.X  Gear^.X; 
704 
Gear^.dY:= HHGear^.Y  Gear^.Y; 

108  705 

351  706 
cs:= Gear^.dY + HHGear^.dY; 
707 
cc:= Gear^.dX + HHGear^.dX; 

498  708 
len:= _1 / Distance(cc, cs); 
108  709 
cc:= cc * len; 
710 
cs:= cs * len; 

4  711 

351  712 
HHGear^.dX:= HHGear^.X; 
713 
HHGear^.dY:= HHGear^.Y; 

4  714 

351  715 
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then 
1504  716 
if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) 
717 
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity + _0_3; 

4  718 

498  719 
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then 
1504  720 
if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) 
721 
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity  _0_3; 

4  722 

351  723 
HHGear^.X:= Gear^.X + cc*Gear^.Elasticity; 
724 
HHGear^.Y:= Gear^.Y + cs*Gear^.Elasticity; 

4  725 

351  726 
HHGear^.dX:= HHGear^.X  HHGear^.dX; 
727 
HHGear^.dY:= HHGear^.Y  HHGear^.dY; 

4  728 

351  729 
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then 
1504  730 
HHGear^.dX:= _0_6 * HHGear^.dX; 
351  731 
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then 
1504  732 
HHGear^.dY:= _0_6 * HHGear^.dY; 
4  733 

789  734 
len:= Distance(HHGear^.dX, HHGear^.dY); 
940  735 
if len > _0_8 then 
1504  736 
begin 
737 
len:= _0_8 / len; 

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

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

740 
end; 

789  741 

351  742 
if (Gear^.Message and gm_Attack) <> 0 then 
1504  743 
if (Gear^.State and gsttmpFlag) <> 0 then 
744 
DeleteMe 

745 
else 

746 
else 

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

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

4  749 
end; 
750 

751 

752 
procedure doStepRopeAttach(Gear: PGear); 

753 
var HHGear: PGear; 

351  754 
tx, ty, tt: hwFloat; 
4  755 
begin 
351  756 
Gear^.X:= Gear^.X  Gear^.dX; 
757 
Gear^.Y:= Gear^.Y  Gear^.dY; 

498  758 
Gear^.Elasticity:= Gear^.Elasticity + _1; 
351  759 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
517  760 
DeleteCI(HHGear); 
542  761 
if (HHGear^.State and gstMoving) <> 0 then 
1433  762 
if TestCollisionYwithGear(HHGear, 1) then 
763 
begin 

764 
CheckHHDamage(HHGear); 

765 
HHGear^.dY:= _0; 

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

767 
end else 

768 
begin 

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

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

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

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

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

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

775 
tt:= Gear^.Elasticity; 

776 
tx:= _0; 

777 
ty:= _0; 

778 
while tt > _20 do 

779 
begin 

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

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

782 
begin 

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

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

785 
Gear^.Elasticity:= tt; 

786 
Gear^.doStep:= @doStepRopeWork; 

787 
with HHGear^ do State:= State and not gstAttacking; 

788 
tt:= _0 

789 
end; 

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

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

792 
tt:= tt  _2; 

793 
end; 

794 
end; 

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

795 

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

797 

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

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

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

801 
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

802 

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

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

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

805 

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

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

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

808 
end; 
4  809 

351  810 
if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then 
1433  811 
begin 
812 
with PHedgehog(Gear^.Hedgehog)^.Gear^ do 

813 
begin 

814 
State:= State and not gstAttacking; 

815 
Message:= Message and not gm_Attack 

816 
end; 

817 
DeleteGear(Gear) 

818 
end 

4  819 
end; 
820 

821 
procedure doStepRope(Gear: PGear); 

822 
begin 

351  823 
Gear^.dX:=  Gear^.dX; 
824 
Gear^.dY:=  Gear^.dY; 

825 
Gear^.doStep:= @doStepRopeAttach 

4  826 
end; 
827 

828 
//////////////////////////////////////////////////////////////////////////////// 

829 
procedure doStepSmokeTrace(Gear: PGear); 

830 
begin 

351  831 
inc(Gear^.Timer); 
832 
if Gear^.Timer > 64 then 

1133  833 
begin 
834 
Gear^.Timer:= 0; 

835 
dec(Gear^.State) 

836 
end; 

351  837 
Gear^.dX:= Gear^.dX + cWindSpeed; 
838 
Gear^.X:= Gear^.X + Gear^.dX; 

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

4  840 
end; 
9  841 

842 
//////////////////////////////////////////////////////////////////////////////// 

1045  843 
procedure doStepExplosionWork(Gear: PGear); 
9  844 
begin 
351  845 
inc(Gear^.Timer); 
846 
if Gear^.Timer > 75 then 

1133  847 
begin 
848 
inc(Gear^.State); 

849 
Gear^.Timer:= 0; 

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

851 
end; 

9  852 
end; 
10  853 

1045  854 
procedure doStepExplosion(Gear: PGear); 
855 
var i: LongWord; 

856 
begin 

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

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

1045  860 
Gear^.doStep:= @doStepExplosionWork 
861 
end; 

862 

10  863 
//////////////////////////////////////////////////////////////////////////////// 
864 
procedure doStepMine(Gear: PGear); 

865 
begin 

542  866 
if (Gear^.State and gstMoving) <> 0 then 
914  867 
begin 
868 
DeleteCI(Gear); 

869 
doStepFallingGear(Gear); 

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

871 
begin 

872 
AddGearCI(Gear); 

873 
Gear^.dX:= _0; 

874 
Gear^.dY:= _0 

875 
end; 

876 
CalcRotationDirAngle(Gear); 

877 
AllInactive:= false 

878 
end else 

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

880 
doStepFallingGear(Gear); 

351  881 

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

1133  883 
if ((Gear^.State and gstAttacking) = 0) then 
884 
begin 

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

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

887 
end else // gstAttacking <> 0 

888 
begin 

889 
AllInactive:= false; 

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

891 
if Gear^.Timer = 0 then 

892 
begin 

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

894 
DeleteGear(Gear); 

895 
exit 

896 
end; 

897 
dec(Gear^.Timer); 

898 
end else // gsttmpFlag = 0 

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

10  900 
end; 
57  901 

39  902 
//////////////////////////////////////////////////////////////////////////////// 
903 
procedure doStepDynamite(Gear: PGear); 

904 
begin 

43  905 
doStepFallingGear(Gear); 
906 
AllInactive:= false; 

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

1133  909 
begin 
910 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); 

911 
DeleteGear(Gear); 

912 
exit 

913 
end; 

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

916 

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

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

921 
begin 
351  922 
if (Gear^.Message and gm_Destroy) > 0 then 
1133  923 
begin 
924 
DeleteGear(Gear); 

925 
FreeActionsList; 

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

927 
with CurrentHedgehog^ do 

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

929 
exit 

930 
end; 

15  931 

351  932 
if Gear^.Damage > 0 then 
1133  933 
begin 
934 
x:= hwRound(Gear^.X); 

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

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

938 

939 
if k = gtCase then 

1133  940 
begin 
941 
doMakeExplosion(x, y, 25, EXPLAutoSound); 

942 
for i:= 0 to 63 do 

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

944 
end; 

945 
exit 

946 
end; 

79  947 

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

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

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

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

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

955 
begin 

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

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

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

959 
end; 

960 
CheckGearDrowning(Gear); 

961 
end; 

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

962 

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

965 
end; 
49  966 

967 
//////////////////////////////////////////////////////////////////////////////// 

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

1133  970 
record 
971 
dy, ny, dw: LongInt; 

972 
team: PTeam; 

973 
SortFactor: QWord; 

974 
end; 

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

975 
currsorter: PGear = nil; 
49  976 

977 
procedure doStepTeamHealthSorterWork(Gear: PGear); 

371  978 
var i: LongInt; 
49  979 
begin 
980 
AllInactive:= false; 

351  981 
dec(Gear^.Timer); 
982 
if (Gear^.Timer and 15) = 0 then 

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

985 
begin 

986 
{$WARNINGS OFF} 

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

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

989 
{$WARNINGS ON} 

990 
end; 

991 

351  992 
if (Gear^.Timer = 0) or (currsorter <> Gear) then 
1133  993 
begin 
994 
if currsorter = Gear then currsorter:= nil; 

995 
DeleteGear(Gear) 

996 
end 

49  997 
end; 
998 

999 
procedure doStepTeamHealthSorter(Gear: PGear); 

1133  1000 
var i: Longword; 
1001 
b: boolean; 

1002 
t: LongInt; 

49  1003 
begin 
1004 
AllInactive:= false; 

557  1005 

547  1006 
for t:= 0 to Pred(TeamsCount) do 
1133  1007 
with thexchar[t] do 
1008 
begin 

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

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

1011 
team:= TeamsArray[t]; 

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

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

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

1015 
end; 

547  1016 

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

1017 
if TeamsCount > 1 then 
1133  1018 
repeat 
1019 
b:= true; 

1020 
for t:= 0 to TeamsCount  2 do 

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

1022 
begin 

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

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

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

1026 
b:= false 

1027 
end 

1028 
until b; 

557  1029 

1120  1030 
t:=  4; 
557  1031 
for i:= 0 to Pred(TeamsCount) do 
1133  1032 
with thexchar[i] do 
1033 
begin 

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

1035 
ny:= t; 

1036 
dy:= dy  ny 

1037 
end; 

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

1038 

557  1039 
Gear^.Timer:= cSorterWorkTime; 
351  1040 
Gear^.doStep:= @doStepTeamHealthSorterWork; 
143  1041 
currsorter:= Gear 
49  1042 
end; 
1043 

79  1044 
//////////////////////////////////////////////////////////////////////////////// 
854  1045 
procedure doStepIdle(Gear: PGear); 
1046 
begin 

1047 
AllInactive:= false; 

925  1048 
dec(Gear^.Timer); 
854  1049 
if Gear^.Timer = 0 then 
1050 
begin 

1051 
DeleteGear(Gear); 

1052 
AfterAttack 

1053 
end 

1054 
end; 

1055 

79  1056 
procedure doStepShover(Gear: PGear); 
1057 
var HHGear: PGear; 

1058 
begin 

351  1059 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
1060 
HHGear^.State:= HHGear^.State or gstNoDamage; 

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

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

1062 

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

1064 

351  1065 
HHGear^.State:= HHGear^.State and not gstNoDamage; 
854  1066 
Gear^.Timer:= 250; 
1067 
Gear^.doStep:= @doStepIdle 

79  1068 
end; 
1069 

1070 
//////////////////////////////////////////////////////////////////////////////// 

925  1071 
procedure doStepWhip(Gear: PGear); 
1072 
var HHGear: PGear; 

1073 
i: LongInt; 

1074 
begin 

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

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

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

1077 
DeleteCI(HHGear); 
925  1078 

1079 
for i:= 0 to 3 do 

1080 
begin 

1081 
AmmoShove(Gear, 30, 25); 

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

1083 
end; 

1084 

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

1086 
Gear^.Timer:= 250; 

1087 
Gear^.doStep:= @doStepIdle 

1088 
end; 

1089 

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

79  1091 
procedure doStepFlame(Gear: PGear); 
1433  1092 
var cWindFactor: hwFloat; 
79  1093 
begin 
1094 
AllInactive:= false; 

1433  1095 

79  1096 
if not TestCollisionYwithGear(Gear, 1) then 
1133  1097 
begin 
1433  1098 
cWindFactor:= cWindSpeed * 270; 
1099 

1100 
if hwAbs(Gear^.dX  cWindFactor) > _0_01 then 

1437  1101 
Gear^.dX:= (Gear^.dX  cWindFactor) * _0_995 + cWindFactor; 
1297  1102 

1133  1103 
Gear^.dY:= Gear^.dY + cGravity; 
1104 
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; 

1297  1105 

1133  1106 
Gear^.X:= Gear^.X + Gear^.dX; 
1107 
Gear^.Y:= Gear^.Y + Gear^.dY; 

1297  1108 

1417  1109 
if not (hwRound(Gear^.Y) < cWaterLine) then 
1133  1110 
begin 
1111 
DeleteGear(Gear); 

1112 
exit 

1113 
end 

1114 
end else begin 

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

1116 
else begin 

1297  1117 
Gear^.Radius:= 5; 
1118 
AmmoShove(Gear, 3, 100); 

1119 
Gear^.Radius:= 1; 

1120 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 4, EXPLNoDamage); 

1133  1121 
dec(Gear^.Health); 
1297  1122 
Gear^.Timer:= 1250  Gear^.Tag * 12 
1133  1123 
end 
1124 
end; 

79  1125 

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

79  1128 

351  1129 
if Gear^.Health = 0 then 
1133  1130 
DeleteGear(Gear) 
79  1131 
end; 
82  1132 

1133 
//////////////////////////////////////////////////////////////////////////////// 

1134 
procedure doStepFirePunchWork(Gear: PGear); 

1135 
var HHGear: PGear; 

1136 
begin 

1137 
AllInactive:= false; 

351  1138 
if ((Gear^.Message and gm_Destroy) <> 0) then 
1133  1139 
begin 
1140 
DeleteGear(Gear); 

1141 
AfterAttack; 

1142 
exit 

1143 
end; 

82  1144 

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

1133  1147 
begin 
1148 
Gear^.Tag:= hwRound(HHGear^.Y); 

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

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

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

1152 
AmmoShove(Gear, 30, 40); 

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

1154 
end; 

351  1155 

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

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

1133  1158 
begin 
1159 
HHGear^.State:= HHGear^.State or gstMoving; 

1160 
DeleteGear(Gear); 

1161 
AfterAttack; 

1162 
exit 

1163 
end; 

351  1164 
HHGear^.Y:= HHGear^.Y + HHGear^.dY 
82  1165 
end; 
1166 

1167 
procedure doStepFirePunch(Gear: PGear); 

1168 
var HHGear: PGear; 

1169 
begin 

1170 
AllInactive:= false; 

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

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

1175 

351  1176 
HHGear^.dY:=  _0_3; 
82  1177 

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

1179 
Gear^.dX:= SignAs(_0_45, Gear^.dX); 
351  1180 
Gear^.dY:=  _0_9; 
1181 
Gear^.doStep:= @doStepFirePunchWork; 

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

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

82  1185 
end; 
1186 

263  1187 
//////////////////////////////////////////////////////////////////////////////// 
1188 

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

1189 
procedure doStepParachuteWork(Gear: PGear); 
211  1190 
var HHGear: PGear; 
1191 
begin 

351  1192 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
82  1193 

516  1194 
inc(Gear^.Timer); 
1195 

212  1196 
if TestCollisionYwithGear(HHGear, 1) 
1133  1197 
or ((HHGear^.State and gstHHDriven) = 0) 
1198 
or CheckGearDrowning(HHGear) 

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

1200 
begin 

1201 
with HHGear^ do 

1202 
begin 

1203 
Message:= 0; 

1204 
SetLittle(dX); 

1205 
dY:= _0; 

1206 
State:= State or gstMoving; 

1207 
end; 

1208 
DeleteGear(Gear); 

1209 
exit 

1210 
end; 

211  1211 

351  1212 
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then 
1133  1213 
HHGear^.X:= HHGear^.X + cWindSpeed * 200; 
211  1214 

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

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

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

211  1219 

351  1220 
HHGear^.Y:= HHGear^.Y + cGravity * 100; 
568  1221 
Gear^.X:= HHGear^.X; 
1222 
Gear^.Y:= HHGear^.Y 

263  1223 
end; 
211  1224 

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

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

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

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

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

1229 

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

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

1231 

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

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

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

1234 

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

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

1237 

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

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

1239 

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

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

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

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

1243 

263  1244 
//////////////////////////////////////////////////////////////////////////////// 
1245 
procedure doStepAirAttackWork(Gear: PGear); 

1246 
begin 

1247 
AllInactive:= false; 

498  1248 
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; 
1124  1249 

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

1250 
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then 
1124  1251 
begin 
1252 
dec(Gear^.Health); 

1253 
case Gear^.State of 

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

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

1256 
end; 

1257 
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) 

1258 
end; 

1259 

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

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

1262 

498  1263 
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < 1024) then DeleteGear(Gear) 
263  1264 
end; 
1265 

1266 
procedure doStepAirAttack(Gear: PGear); 

1267 
begin 

1268 
AllInactive:= false; 

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

1269 

408  1270 
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 
1271 
else Gear^.Tag:= 1; 

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

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

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

1276 
if int2hwFloat(TargetPoint.Y)  Gear^.Y > _0 then 
1133  1277 
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

1278 

351  1279 
Gear^.Health:= 6; 
801  1280 
Gear^.doStep:= @doStepAirAttackWork; 
1281 
PlaySound(sndIncoming, false) 

263  1282 
end; 
1283 

1284 
//////////////////////////////////////////////////////////////////////////////// 

1285 

1286 
procedure doStepAirBomb(Gear: PGear); 

1287 
begin 

1288 
AllInactive:= false; 

1289 
doStepFallingGear(Gear); 

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

1293 
DeleteGear(Gear); 

1294 
exit 

1295 
end; 

263  1296 
if (GameTicks and $3F) = 0 then 
1133  1297 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) 
211  1298 
end; 
409  1299 

1300 
//////////////////////////////////////////////////////////////////////////////// 

1301 

1302 
procedure doStepGirder(Gear: PGear); 

415  1303 
var HHGear: PGear; 
409  1304 
begin 
1305 
AllInactive:= false; 

415  1306 

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

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

520  1310 
sprAmGirder, Gear^.State, true) then 
1133  1311 
begin 
1312 
HHGear^.Message:= HHGear^.Message and not gm_Attack; 

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

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

1315 
DeleteGear(Gear); 

1316 
isCursorVisible:= true 

1317 
end 

1318 
else begin 

1319 
DeleteGear(Gear); 

1320 
AfterAttack 

1321 
end; 

415  1322 
TargetPoint.X:= NoPointX 
409  1323 
end; 
520  1324 

1325 
//////////////////////////////////////////////////////////////////////////////// 

525  1326 
procedure doStepTeleportAfter(Gear: PGear); 
912  1327 
var HHGear: PGear; 
1328 
begin 

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

1330 
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases 

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

945
4ead9cde4e14
 Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset

1332 
if TestCollisionYwithGear(HHGear, 1) 
1133  1333 
or CheckGearDrowning(HHGear) then 
1334 
begin 

1335 
DeleteGear(Gear); 

1336 
AfterAttack 

1337 
end 

912  1338 
end; 
1339 

1340 
procedure doStepTeleportAnim(Gear: PGear); 

525  1341 
begin 
853  1342 
inc(Gear^.Timer); 
1343 
if Gear^.Timer = 65 then 

1344 
begin 

1345 
Gear^.Timer:= 0; 

1346 
inc(Gear^.Pos); 

1347 
if Gear^.Pos = 11 then 

912  1348 
Gear^.doStep:= @doStepTeleportAfter 
853  1349 
end 
525  1350 
end; 
520  1351 

1352 
procedure doStepTeleport(Gear: PGear); 

1353 
var HHGear: PGear; 

1354 
begin 

1355 
AllInactive:= false; 

1356 

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

1358 
if not TryPlaceOnLand(TargetPoint.X  SpritesData[sprHHTelepMask].Width div 2, 

1359 
TargetPoint.Y  SpritesData[sprHHTelepMask].Height div 2, 

1360 
sprHHTelepMask, 0, false) then 

853  1361 
begin 
1362 
HHGear^.Message:= HHGear^.Message and not gm_Attack; 

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

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

1365 
DeleteGear(Gear); 

1366 
isCursorVisible:= true 

1367 
end 

1368 
else begin 

1369 
DeleteCI(HHGear); 

1370 
SetAllHHToActive; 

912  1371 
Gear^.doStep:= @doStepTeleportAnim; 
853  1372 
Gear^.X:= HHGear^.X; 
1373 
Gear^.Y:= HHGear^.Y; 

1374 
HHGear^.X:= int2hwFloat(TargetPoint.X); 
