author  unc0rr 
Tue, 28 Oct 2008 18:42:21 +0000  
changeset 1433  4af291d5d79c 
parent 1417  210cb6b1b275 
child 1435  d4b32ee3caa6 
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); 

1262  150 
dY:= (GetRandom  _2) * _0_2; 
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 

235 
AllInactive:= false; 

351  236 
Gear^.Y:= Gear^.Y  _0_08; 
498  237 
if hwRound(Gear^.Y) < cWaterLine + 10 then 
263  238 
DeleteGear(Gear) 
239 
end; 

240 

95  241 
procedure doStepHealthTag(Gear: PGear); 
242 
var s: shortstring; 

522  243 
font: THWFont; 
95  244 
begin 
522  245 
if Gear^.Kind = gtHealthTag then 
246 
begin 

813  247 
AllInactive:= false; 
522  248 
font:= fnt16; 
249 
Gear^.dY:= _0_08 

250 
end else 

251 
begin 

252 
font:= fntSmall; 

253 
Gear^.dY:= _0_02 

254 
end; 

255 

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

4  263 
//////////////////////////////////////////////////////////////////////////////// 
264 
procedure doStepGrave(Gear: PGear); 

265 
begin 

266 
AllInactive:= false; 

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

4  269 

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

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

285 
//////////////////////////////////////////////////////////////////////////////// 

286 
procedure doStepUFOWork(Gear: PGear); 

351  287 
var t: hwFloat; 
374  288 
y: LongInt; 
4  289 
begin 
290 
AllInactive:= false; 

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

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

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

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

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

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

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

374  299 

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

301 
begin 

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

303 
if y + Gear^.Radius < cWaterLine then 

498  304 
AddGear(hwRound(Gear^.X), y, gtSmokeTrace, 0, _0, _0, 0); 
374  305 
end; 
306 

4  307 
CheckCollision(Gear); 
351  308 
dec(Gear^.Timer); 
309 
if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then 

4  310 
begin 
560  311 
StopSound(sndUFO); 
351  312 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); 
4  313 
DeleteGear(Gear); 
314 
end; 

315 
end; 

316 

317 
procedure doStepUFO(Gear: PGear); 

318 
begin 

319 
AllInactive:= false; 

351  320 
Gear^.X:= Gear^.X + Gear^.dX; 
321 
Gear^.Y:= Gear^.Y + Gear^.dY; 

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

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

329 
end; 

351  330 
dec(Gear^.Timer); 
331 
if Gear^.Timer = 0 then 

4  332 
begin 
560  333 
PlaySound(sndUFO, true); 
351  334 
Gear^.Timer:= 5000; 
335 
Gear^.doStep:= @doStepUFOWork 

4  336 
end; 
337 
end; 

338 

339 
//////////////////////////////////////////////////////////////////////////////// 

876  340 
procedure doStepShotIdle(Gear: PGear); 
341 
begin 

342 
AllInactive:= false; 

343 
inc(Gear^.Timer); 

344 
if Gear^.Timer > 75 then 

345 
begin 

346 
DeleteGear(Gear); 

347 
AfterAttack 

348 
end 

349 
end; 

350 

4  351 
procedure doStepShotgunShot(Gear: PGear); 
352 
var i: LongWord; 

353 
begin 

354 
AllInactive:= false; 

876  355 

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

357 
begin 

358 
dec(Gear^.Timer); 

359 
if Gear^.Timer = 0 then 

360 
begin 

361 
PlaySound(sndShotgunFire, false); 

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

363 
end; 

364 
exit 

365 
end 

366 
else inc(Gear^.Timer); 

367 

4  368 
i:= 200; 
369 
repeat 

351  370 
Gear^.X:= Gear^.X + Gear^.dX; 
371 
Gear^.Y:= Gear^.Y + Gear^.dY; 

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

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

377 
ShotgunShot(Gear); 

378 
Gear^.doStep:= @doStepShotIdle; 

379 
exit 

380 
end; 

4  381 
dec(i) 
382 
until i = 0; 

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

387 
//////////////////////////////////////////////////////////////////////////////// 

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

876  393 
inc(Gear^.Timer); 
37  394 
i:= 80; 
351  395 
oX:= Gear^.X; 
396 
oY:= Gear^.Y; 

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

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

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

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

37  408 
begin 
351  409 
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82  i, 1); 
410 
dec(Gear^.Health, Gear^.Damage); 

411 
Gear^.Damage:= 0 

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

559  417 
procedure doStepDEagleShot(Gear: PGear); 
418 
begin 

419 
PlaySound(sndGun, false); 

420 
Gear^.doStep:= @doStepDEagleShotWork 

421 
end; 

422 

37  423 
//////////////////////////////////////////////////////////////////////////////// 
4  424 
procedure doStepActionTimer(Gear: PGear); 
425 
begin 

351  426 
dec(Gear^.Timer); 
427 
case Gear^.Kind of 

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

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

83  439 
end 
440 
end; 

441 
gtATFinishGame: begin 

442 
AllInactive:= false; 

351  443 
if Gear^.Timer = 0 then 
113  444 
begin 
445 
SendIPC('N'); 

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

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

454 
//////////////////////////////////////////////////////////////////////////////// 

455 
procedure doStepPickHammerWork(Gear: PGear); 

371  456 
var i, ei: LongInt; 
4  457 
HHGear: PGear; 
458 
begin 

70  459 
AllInactive:= false; 
351  460 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
461 
dec(Gear^.Timer); 

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

1200  463 
begin 
464 
StopSound(sndPickhammer); 

465 
DeleteGear(Gear); 

466 
AfterAttack; 

467 
exit 

468 
end; 

845  469 

422  470 
if (Gear^.Timer mod 33) = 0 then 
1200  471 
begin 
472 
HHGear^.State:= HHGear^.State or gstNoDamage; 

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

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

475 
end; 

422  476 

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

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

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

481 
while i <= ei do 

482 
begin 

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

484 
inc(i, 1) 

485 
end; 

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

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

488 
SetAllHHToActive; 

489 
end; 

4  490 
if TestCollisionYwithGear(Gear, 1) then 
1200  491 
begin 
492 
Gear^.dY:= _0; 

493 
SetLittle(HHGear^.dX); 

494 
HHGear^.dY:= _0; 

495 
end else 

496 
begin 

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

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

1417  499 
if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer:= 1 
1200  500 
end; 
4  501 

351  502 
Gear^.X:= Gear^.X + HHGear^.dX; 
503 
HHGear^.X:= Gear^.X; 

498  504 
HHGear^.Y:= Gear^.Y  int2hwFloat(cHHRadius); 
4  505 

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

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

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

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

498  511 
else Gear^.dX:= _0; 
4  512 
end; 
513 

514 
procedure doStepPickHammer(Gear: PGear); 

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

517 
HHGear: PGear; 
4  518 
begin 
519 
i:= 0; 

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

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

521 

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

4  527 
inc(y, 2); 
528 
inc(i) 

529 
end; 

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

530 

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

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

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

534 

282  535 
PlaySound(sndPickhammer, true); 
4  536 
doStepPickHammerWork(Gear); 
351  537 
Gear^.doStep:= @doStepPickHammerWork 
4  538 
end; 
539 

540 
//////////////////////////////////////////////////////////////////////////////// 

371  541 
var BTPrevAngle, BTSteps: LongInt; 
302  542 

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

543 
procedure doStepBlowTorchWork(Gear: PGear); 
302  544 
var HHGear: PGear; 
305  545 
b: boolean; 
302  546 
begin 
547 
AllInactive:= false; 

351  548 
dec(Gear^.Timer); 
549 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 

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

550 

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

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

552 

305  553 
b:= false; 
554 

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

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

357  568 

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

302  570 
HedgehogStep(HHGear); 
357  571 
HHGear^.State:= HHGear^.State or gstAttacking; 
305  572 

573 
inc(BTSteps); 

511  574 
if BTSteps = 7 then 
305  575 
begin 
576 
BTSteps:= 0; 

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

351  579 
HHGear^.State:= HHGear^.State or gstNoDamage; 
511  580 
AmmoShove(Gear, 2, 14); 
351  581 
HHGear^.State:= HHGear^.State and not gstNoDamage 
305  582 
end; 
583 

542  584 
if (HHGear^.State and gstMoving) <> 0 then Gear^.Timer:= 0 
302  585 
end; 
305  586 

587 
if b then 

498  588 
DrawTunnel(HHGear^.X  Gear^.dX * cHHRadius, HHGear^.Y  _4  Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, 
351  589 
Gear^.dX, Gear^.dY, 
306  590 
cHHRadius * 5, cHHRadius * 2 + 6); 
305  591 

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

597 
end 

598 
end; 

599 

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

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

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

602 
begin 
371  603 
BTPrevAngle:= High(LongInt); 
305  604 
BTSteps:= 0; 
351  605 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
606 
HHGear^.Message:= 0; 

607 
Gear^.doStep:= @doStepBlowTorchWork 

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

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

609 

302  610 
//////////////////////////////////////////////////////////////////////////////// 
611 

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

618 
procedure DeleteMe; 

619 
begin 

620 
with HHGear^ do 

621 
begin 

622 
Message:= Message and not gm_Attack; 

542  623 
State:= State or gstMoving; 
4  624 
end; 
929
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

625 
DeleteGear(Gear) 
4  626 
end; 
627 

628 
begin 

351  629 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
108  630 

351  631 
if ((HHGear^.State and gstHHDriven) = 0) 
80  632 
or (CheckGearDrowning(HHGear)) then 
4  633 
begin 
634 
DeleteMe; 

635 
exit 

636 
end; 

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

637 

351  638 
Gear^.dX:= HHGear^.X  Gear^.X; 
639 
Gear^.dY:= HHGear^.Y  Gear^.Y; 

4  640 

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

4  643 

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

351  646 
cs:= Gear^.dY + HHGear^.dY; 
647 
cc:= Gear^.dX + HHGear^.dX; 

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

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

789  654 

4  655 
flCheck:= not flCheck; 
656 
if flCheck then // check whether rope needs dividing 

657 
begin 

498  658 
len:= Gear^.Elasticity  _20; 
659 
while len > _5 do 

4  660 
begin 
661 
tx:= cc*len; 

662 
ty:= cs*len; 

789  663 
lx:= hwRound(Gear^.X + tx + nx); 
664 
ly:= hwRound(Gear^.Y + ty + ny); 

652  665 
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0) and (Land[ly, lx] <> 0) then 
4  666 
begin 
667 
with RopePoints.ar[RopePoints.Count] do 

668 
begin 

351  669 
X:= Gear^.X; 
670 
Y:= Gear^.Y; 

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

671 
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); 
351  672 
b:= (cc * HHGear^.dY) > (cs * HHGear^.dX); 
4  673 
dLen:= len 
674 
end; 

351  675 
Gear^.X:= Gear^.X + tx; 
676 
Gear^.Y:= Gear^.Y + ty; 

4  677 
inc(RopePoints.Count); 
789  678 
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); 
351  679 
Gear^.Elasticity:= Gear^.Elasticity  len; 
680 
Gear^.Friction:= Gear^.Friction  len; 

4  681 
break 
682 
end; 

1361  683 
len:= len  _0_5 
4  684 
end; 
685 
end else 

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

687 
begin 

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

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

351  690 
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx  Gear^.X) * (ty  HHGear^.Y) > (tx  HHGear^.X) * (ty  Gear^.Y)) then 
4  691 
begin 
692 
dec(RopePoints.Count); 

351  693 
Gear^.X:=RopePoints.ar[RopePoints.Count].X; 
694 
Gear^.Y:=RopePoints.ar[RopePoints.Count].Y; 

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

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

4  697 
end 
698 
end; 

699 

351  700 
Gear^.dX:= HHGear^.X  Gear^.X; 
701 
Gear^.dY:= HHGear^.Y  Gear^.Y; 

108  702 

351  703 
cs:= Gear^.dY + HHGear^.dY; 
704 
cc:= Gear^.dX + HHGear^.dX; 

498  705 
len:= _1 / Distance(cc, cs); 
108  706 
cc:= cc * len; 
707 
cs:= cs * len; 

4  708 

351  709 
HHGear^.dX:= HHGear^.X; 
710 
HHGear^.dY:= HHGear^.Y; 

4  711 

351  712 
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then 
713 
if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) 

714 
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity + _0_3; 

4  715 

498  716 
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then 
351  717 
if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) 
718 
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity  _0_3; 

4  719 

351  720 
HHGear^.X:= Gear^.X + cc*Gear^.Elasticity; 
721 
HHGear^.Y:= Gear^.Y + cs*Gear^.Elasticity; 

4  722 

351  723 
HHGear^.dX:= HHGear^.X  HHGear^.dX; 
724 
HHGear^.dY:= HHGear^.Y  HHGear^.dY; 

4  725 

351  726 
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then 
727 
HHGear^.dX:= _0_6 * HHGear^.dX; 

728 
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then 

729 
HHGear^.dY:= _0_6 * HHGear^.dY; 

4  730 

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

737 
end; 

738 

351  739 
if (Gear^.Message and gm_Attack) <> 0 then 
740 
if (Gear^.State and gsttmpFlag) <> 0 then DeleteMe else 

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

4  742 
end; 
743 

744 

745 
procedure doStepRopeAttach(Gear: PGear); 

746 
var HHGear: PGear; 

351  747 
tx, ty, tt: hwFloat; 
4  748 
begin 
351  749 
Gear^.X:= Gear^.X  Gear^.dX; 
750 
Gear^.Y:= Gear^.Y  Gear^.dY; 

498  751 
Gear^.Elasticity:= Gear^.Elasticity + _1; 
351  752 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
517  753 
DeleteCI(HHGear); 
542  754 
if (HHGear^.State and gstMoving) <> 0 then 
1433  755 
if TestCollisionYwithGear(HHGear, 1) then 
756 
begin 

757 
CheckHHDamage(HHGear); 

758 
HHGear^.dY:= _0; 

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

760 
end else 

761 
begin 

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

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

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

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

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

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

768 
tt:= Gear^.Elasticity; 

769 
tx:= _0; 

770 
ty:= _0; 

771 
while tt > _20 do 

772 
begin 

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

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

775 
begin 

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

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

778 
Gear^.Elasticity:= tt; 

779 
Gear^.doStep:= @doStepRopeWork; 

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

781 
tt:= _0 

782 
end; 

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

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

785 
tt:= tt  _2; 

786 
end; 

787 
end; 

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

788 

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

790 

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

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

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

794 
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

795 

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

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

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

798 

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

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

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

801 
end; 
4  802 

351  803 
if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then 
1433  804 
begin 
805 
with PHedgehog(Gear^.Hedgehog)^.Gear^ do 

806 
begin 

807 
State:= State and not gstAttacking; 

808 
Message:= Message and not gm_Attack 

809 
end; 

810 
DeleteGear(Gear) 

811 
end 

4  812 
end; 
813 

814 
procedure doStepRope(Gear: PGear); 

815 
begin 

351  816 
Gear^.dX:=  Gear^.dX; 
817 
Gear^.dY:=  Gear^.dY; 

818 
Gear^.doStep:= @doStepRopeAttach 

4  819 
end; 
820 

821 
//////////////////////////////////////////////////////////////////////////////// 

822 
procedure doStepSmokeTrace(Gear: PGear); 

823 
begin 

351  824 
inc(Gear^.Timer); 
825 
if Gear^.Timer > 64 then 

1133  826 
begin 
827 
Gear^.Timer:= 0; 

828 
dec(Gear^.State) 

829 
end; 

351  830 
Gear^.dX:= Gear^.dX + cWindSpeed; 
831 
Gear^.X:= Gear^.X + Gear^.dX; 

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

4  833 
end; 
9  834 

835 
//////////////////////////////////////////////////////////////////////////////// 

1045  836 
procedure doStepExplosionWork(Gear: PGear); 
9  837 
begin 
351  838 
inc(Gear^.Timer); 
839 
if Gear^.Timer > 75 then 

1133  840 
begin 
841 
inc(Gear^.State); 

842 
Gear^.Timer:= 0; 

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

844 
end; 

9  845 
end; 
10  846 

1045  847 
procedure doStepExplosion(Gear: PGear); 
848 
var i: LongWord; 

849 
begin 

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

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

1045  853 
Gear^.doStep:= @doStepExplosionWork 
854 
end; 

855 

10  856 
//////////////////////////////////////////////////////////////////////////////// 
857 
procedure doStepMine(Gear: PGear); 

858 
begin 

542  859 
if (Gear^.State and gstMoving) <> 0 then 
914  860 
begin 
861 
DeleteCI(Gear); 

862 
doStepFallingGear(Gear); 

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

864 
begin 

865 
AddGearCI(Gear); 

866 
Gear^.dX:= _0; 

867 
Gear^.dY:= _0 

868 
end; 

869 
CalcRotationDirAngle(Gear); 

870 
AllInactive:= false 

871 
end else 

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

873 
doStepFallingGear(Gear); 

351  874 

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

1133  876 
if ((Gear^.State and gstAttacking) = 0) then 
877 
begin 

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

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

880 
end else // gstAttacking <> 0 

881 
begin 

882 
AllInactive:= false; 

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

884 
if Gear^.Timer = 0 then 

885 
begin 

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

887 
DeleteGear(Gear); 

888 
exit 

889 
end; 

890 
dec(Gear^.Timer); 

891 
end else // gsttmpFlag = 0 

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

10  893 
end; 
57  894 

39  895 
//////////////////////////////////////////////////////////////////////////////// 
896 
procedure doStepDynamite(Gear: PGear); 

897 
begin 

43  898 
doStepFallingGear(Gear); 
899 
AllInactive:= false; 

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

1133  902 
begin 
903 
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); 

904 
DeleteGear(Gear); 

905 
exit 

906 
end; 

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

909 

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

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

913 
begin 
351  914 
if (Gear^.Message and gm_Destroy) > 0 then 
1133  915 
begin 
916 
DeleteGear(Gear); 

917 
FreeActionsList; 

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

919 
with CurrentHedgehog^ do 

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

921 
exit 

922 
end; 

15  923 

351  924 
if Gear^.Damage > 0 then 
1133  925 
begin 
926 
x:= hwRound(Gear^.X); 

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

928 
DeleteGear(Gear); 

929 
if Gear^.Kind = gtCase then 

930 
begin 

931 
doMakeExplosion(x, y, 25, EXPLAutoSound); 

932 
for i:= 0 to 63 do 

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

934 
end; 

935 
exit 

936 
end; 

79  937 

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

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

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

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

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

945 
begin 

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

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

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

949 
end; 

950 
CheckGearDrowning(Gear); 

951 
end; 

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

952 

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

955 
end; 
49  956 

957 
//////////////////////////////////////////////////////////////////////////////// 

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

1133  960 
record 
961 
dy, ny, dw: LongInt; 

962 
team: PTeam; 

963 
SortFactor: QWord; 

964 
end; 

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

965 
currsorter: PGear = nil; 
49  966 

967 
procedure doStepTeamHealthSorterWork(Gear: PGear); 

371  968 
var i: LongInt; 
49  969 
begin 
970 
AllInactive:= false; 

351  971 
dec(Gear^.Timer); 
972 
if (Gear^.Timer and 15) = 0 then 

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

975 
begin 

976 
{$WARNINGS OFF} 

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

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

979 
{$WARNINGS ON} 

980 
end; 

981 

351  982 
if (Gear^.Timer = 0) or (currsorter <> Gear) then 
1133  983 
begin 
984 
if currsorter = Gear then currsorter:= nil; 

985 
DeleteGear(Gear) 

986 
end 

49  987 
end; 
988 

989 
procedure doStepTeamHealthSorter(Gear: PGear); 

1133  990 
var i: Longword; 
991 
b: boolean; 

992 
t: LongInt; 

49  993 
begin 
994 
AllInactive:= false; 

557  995 

547  996 
for t:= 0 to Pred(TeamsCount) do 
1133  997 
with thexchar[t] do 
998 
begin 

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

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

1001 
team:= TeamsArray[t]; 

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

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

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

1005 
end; 

547  1006 

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

1007 
if TeamsCount > 1 then 
1133  1008 
repeat 
1009 
b:= true; 

1010 
for t:= 0 to TeamsCount  2 do 

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

1012 
begin 

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

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

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

1016 
b:= false 

1017 
end 

1018 
until b; 

557  1019 

1120  1020 
t:=  4; 
557  1021 
for i:= 0 to Pred(TeamsCount) do 
1133  1022 
with thexchar[i] do 
1023 
begin 

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

1025 
ny:= t; 

1026 
dy:= dy  ny 

1027 
end; 

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

1028 

557  1029 
Gear^.Timer:= cSorterWorkTime; 
351  1030 
Gear^.doStep:= @doStepTeamHealthSorterWork; 
143  1031 
currsorter:= Gear 
49  1032 
end; 
1033 

79  1034 
//////////////////////////////////////////////////////////////////////////////// 
854  1035 
procedure doStepIdle(Gear: PGear); 
1036 
begin 

1037 
AllInactive:= false; 

925  1038 
dec(Gear^.Timer); 
854  1039 
if Gear^.Timer = 0 then 
1040 
begin 

1041 
DeleteGear(Gear); 

1042 
AfterAttack 

1043 
end 

1044 
end; 

1045 

79  1046 
procedure doStepShover(Gear: PGear); 
1047 
var HHGear: PGear; 

1048 
begin 

351  1049 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
1050 
HHGear^.State:= HHGear^.State or gstNoDamage; 

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

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

1052 

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

1054 

351  1055 
HHGear^.State:= HHGear^.State and not gstNoDamage; 
854  1056 
Gear^.Timer:= 250; 
1057 
Gear^.doStep:= @doStepIdle 

79  1058 
end; 
1059 

1060 
//////////////////////////////////////////////////////////////////////////////// 

925  1061 
procedure doStepWhip(Gear: PGear); 
1062 
var HHGear: PGear; 

1063 
i: LongInt; 

1064 
begin 

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

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

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

1067 
DeleteCI(HHGear); 
925  1068 

1069 
for i:= 0 to 3 do 

1070 
begin 

1071 
AmmoShove(Gear, 30, 25); 

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

1073 
end; 

1074 

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

1076 
Gear^.Timer:= 250; 

1077 
Gear^.doStep:= @doStepIdle 

1078 
end; 

1079 

1080 
//////////////////////////////////////////////////////////////////////////////// 

79  1081 
procedure doStepFlame(Gear: PGear); 
1433  1082 
var cWindFactor: hwFloat; 
79  1083 
begin 
1084 
AllInactive:= false; 

1433  1085 

79  1086 
if not TestCollisionYwithGear(Gear, 1) then 
1133  1087 
begin 
1433  1088 
cWindFactor:= cWindSpeed * 270; 
1089 

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

1091 
Gear^.dX:= (Gear^.dX  cWindFactor) * _0_998 + cWindFactor; 

1297  1092 

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

1297  1095 

1133  1096 
Gear^.X:= Gear^.X + Gear^.dX; 
1097 
Gear^.Y:= Gear^.Y + Gear^.dY; 

1297  1098 

1417  1099 
if not (hwRound(Gear^.Y) < cWaterLine) then 
1133  1100 
begin 
1101 
DeleteGear(Gear); 

1102 
exit 

1103 
end 

1104 
end else begin 

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

1106 
else begin 

1297  1107 
Gear^.Radius:= 5; 
1108 
AmmoShove(Gear, 3, 100); 

1109 
Gear^.Radius:= 1; 

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

1133  1111 
dec(Gear^.Health); 
1297  1112 
Gear^.Timer:= 1250  Gear^.Tag * 12 
1133  1113 
end 
1114 
end; 

79  1115 

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

79  1118 

351  1119 
if Gear^.Health = 0 then 
1133  1120 
DeleteGear(Gear) 
79  1121 
end; 
82  1122 

1123 
//////////////////////////////////////////////////////////////////////////////// 

1124 
procedure doStepFirePunchWork(Gear: PGear); 

1125 
var HHGear: PGear; 

1126 
begin 

1127 
AllInactive:= false; 

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

1131 
AfterAttack; 

1132 
exit 

1133 
end; 

82  1134 

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

1133  1137 
begin 
1138 
Gear^.Tag:= hwRound(HHGear^.Y); 

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

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

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

1142 
AmmoShove(Gear, 30, 40); 

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

1144 
end; 

351  1145 

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

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

1133  1148 
begin 
1149 
HHGear^.State:= HHGear^.State or gstMoving; 

1150 
DeleteGear(Gear); 

1151 
AfterAttack; 

1152 
exit 

1153 
end; 

351  1154 
HHGear^.Y:= HHGear^.Y + HHGear^.dY 
82  1155 
end; 
1156 

1157 
procedure doStepFirePunch(Gear: PGear); 

1158 
var HHGear: PGear; 

1159 
begin 

1160 
AllInactive:= false; 

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

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

1165 

351  1166 
HHGear^.dY:=  _0_3; 
82  1167 

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

1169 
Gear^.dX:= SignAs(_0_45, Gear^.dX); 
351  1170 
Gear^.dY:=  _0_9; 
1171 
Gear^.doStep:= @doStepFirePunchWork; 

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

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

82  1175 
end; 
1176 

263  1177 
//////////////////////////////////////////////////////////////////////////////// 
1178 

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

1179 
procedure doStepParachuteWork(Gear: PGear); 
211  1180 
var HHGear: PGear; 
1181 
begin 

351  1182 
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; 
82  1183 

516  1184 
inc(Gear^.Timer); 
1185 

212  1186 
if TestCollisionYwithGear(HHGear, 1) 
1133  1187 
or ((HHGear^.State and gstHHDriven) = 0) 
1188 
or CheckGearDrowning(HHGear) 

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

1190 
begin 

1191 
with HHGear^ do 

1192 
begin 

1193 
Message:= 0; 

1194 
SetLittle(dX); 

1195 
dY:= _0; 

1196 
State:= State or gstMoving; 

1197 
end; 

1198 
DeleteGear(Gear); 

1199 
exit 

1200 
end; 

211  1201 

351  1202 
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then 
1133  1203 
HHGear^.X:= HHGear^.X + cWindSpeed * 200; 
211  1204 

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

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

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

211  1209 

351  1210 
HHGear^.Y:= HHGear^.Y + cGravity * 100; 
568  1211 
Gear^.X:= HHGear^.X; 
1212 
Gear^.Y:= HHGear^.Y 

263  1213 
end; 
211  1214 

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

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

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

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

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

1219 

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

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

1221 

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

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

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

1224 

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

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

1227 

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

1228 
Gear^.doStep:= @doStepParachuteWork; 
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 
Gear^.Message:= HHGear^.Message; 
9456e1e77369
 Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset

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

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

1233 

263  1234 
//////////////////////////////////////////////////////////////////////////////// 
1235 
procedure doStepAirAttackWork(Gear: PGear); 

1236 
begin 

1237 
AllInactive:= false; 

498  1238 
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; 
1124  1239 

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

1240 
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then 
1124  1241 
begin 
1242 
dec(Gear^.Health); 

1243 
case Gear^.State of 

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

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

1246 
end; 

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

1248 
end; 

1249 

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

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

1252 

498  1253 
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < 1024) then DeleteGear(Gear) 
263  1254 
end; 
1255 

1256 
procedure doStepAirAttack(Gear: PGear); 

1257 
begin 

1258 
AllInactive:= false; 

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

1259 

408  1260 
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 
1261 
else Gear^.Tag:= 1; 

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

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

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

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

1268 

351  1269 
Gear^.Health:= 6; 
801  1270 
Gear^.doStep:= @doStepAirAttackWork; 
1271 
PlaySound(sndIncoming, false) 

263  1272 
end; 
1273 

1274 
//////////////////////////////////////////////////////////////////////////////// 

1275 

1276 
procedure doStepAirBomb(Gear: PGear); 

1277 
begin 

1278 
AllInactive:= false; 

1279 
doStepFallingGear(Gear); 

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

1283 
DeleteGear(Gear); 

1284 
exit 

1285 
end; 

263  1286 
if (GameTicks and $3F) = 0 then 
1133  1287 
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) 
211  1288 
end; 
409  1289 

1290 
//////////////////////////////////////////////////////////////////////////////// 

1291 

1292 
procedure doStepGirder(Gear: PGear); 

415  1293 
var HHGear: PGear; 
409  1294 
begin 
1295 
AllInactive:= false; 

415  1296 

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

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

520  1300 
sprAmGirder, Gear^.State, true) then 
1133  1301 
begin 
1302 
HHGear^.Message:= HHGear^.Message and not gm_Attack; 

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

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

1305 
DeleteGear(Gear); 

1306 
isCursorVisible:= true 

1307 
end 

1308 
else begin 

1309 
DeleteGear(Gear); 

1310 
AfterAttack 

1311 
end; 

415  1312 
TargetPoint.X:= NoPointX 
409  1313 
end; 
520  1314 

1315 
//////////////////////////////////////////////////////////////////////////////// 

525  1316 
procedure doStepTeleportAfter(Gear: PGear); 
912  1317 
var HHGear: PGear; 
1318 
begin 

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

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

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

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

1322 
if TestCollisionYwithGear(HHGear, 1) 
1133  1323 
or CheckGearDrowning(HHGear) then 
1324 
begin 

1325 
DeleteGear(Gear); 

1326 
AfterAttack 

1327 
end 

912  1328 
end; 
1329 

1330 
procedure doStepTeleportAnim(Gear: PGear); 

525  1331 
begin 
853  1332 
inc(Gear^.Timer); 
1333 
if Gear^.Timer = 65 then 

1334 
begin 

1335 
Gear^.Timer:= 0; 

1336 
inc(Gear^.Pos); 

1337 
if Gear^.Pos = 11 then 

912  1338 
Gear^.doStep:= @doStepTeleportAfter 
853  1339 
end 
525  1340 
end; 
520  1341 

1342 
procedure doStepTeleport(Gear: PGear); 

1343 
var HHGear: PGear; 

1344 
begin 

1345 
AllInactive:= false; 

1346 

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

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

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

1350 
sprHHTelepMask, 0, false) then 

853  1351 
begin 
1352 
HHGear^.Message:= HHGear^.Message and not gm_Attack; 

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

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

1355 
DeleteGear(Gear); 

1356 
isCursorVisible:= true 

1357 
end 

1358 
else begin 

1359 
DeleteCI(HHGear); 

1360 
SetAllHHToActive; 

912  1361 
Gear^.doStep:= @doStepTeleportAnim; 
853  1362 
Gear^.X:= HHGear^.X; 
1363 
Gear^.Y:= HHGear^.Y; 

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

1365 
HHGear^.Y:= int2hwFloat(TargetPoint.Y); 

1366 
HHGear^.State:= HHGear^.State or gstMoving 

1367 
end; 

520  1368 
TargetPoint.X:= NoPointX 
1369 
end; 

534  1370 

1371 
//////////////////////////////////////////////////////////////////////////////// 

92fb2b0d5117
 Fix some bugs
unc 