author | unc0rr |
Fri, 07 Mar 2008 13:16:11 +0000 | |
changeset 798 | 02753868d459 |
parent 789 | 3d976d2579eb |
child 801 | 0323e5c7ee54 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
393 | 3 |
* Copyright (c) 2004-2007 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 02111-1307, 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 |
4 | 24 |
begin |
351 | 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)) |
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 |
44 |
begin |
|
45 |
dmg:= 1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70); |
|
46 |
inc(Gear^.Damage, dmg); |
|
47 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, dmg, Gear); |
|
48 |
end |
|
4 | 49 |
end; |
50 |
||
51 |
//////////////////////////////////////////////////////////////////////////////// |
|
52 |
//////////////////////////////////////////////////////////////////////////////// |
|
53 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
54 |
var dAngle: real; |
4 | 55 |
begin |
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
56 |
dAngle:= (hwAbs(Gear^.dX) + hwAbs(Gear^.dY)).QWordValue / $80000000; |
351 | 57 |
if not Gear^.dX.isNegative then Gear^.DirAngle:= Gear^.DirAngle + dAngle |
58 |
else Gear^.DirAngle:= Gear^.DirAngle - dAngle; |
|
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
59 |
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
|
60 |
else if 360 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle - 360 |
4 | 61 |
end; |
62 |
||
63 |
//////////////////////////////////////////////////////////////////////////////// |
|
64 |
procedure doStepDrowningGear(Gear: PGear); |
|
65 |
begin |
|
66 |
AllInactive:= false; |
|
351 | 67 |
Gear^.Y:= Gear^.Y + cDrownSpeed; |
68 |
if hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear) |
|
4 | 69 |
end; |
70 |
||
71 |
//////////////////////////////////////////////////////////////////////////////// |
|
72 |
procedure doStepFallingGear(Gear: PGear); |
|
542 | 73 |
var isFalling: boolean; |
4 | 74 |
begin |
503 | 75 |
Gear^.State:= Gear^.State and not gstCollision; |
76 |
||
77 |
if Gear^.dY.isNegative then |
|
4 | 78 |
begin |
542 | 79 |
isFalling:= true; |
503 | 80 |
if TestCollisionYwithGear(Gear, -1) then |
81 |
begin |
|
82 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
83 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
84 |
Gear^.State:= Gear^.State or gstCollision |
|
85 |
end |
|
86 |
end else |
|
87 |
if TestCollisionYwithGear(Gear, 1) then |
|
88 |
begin |
|
542 | 89 |
isFalling:= false; |
503 | 90 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
91 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
92 |
Gear^.State:= Gear^.State or gstCollision |
|
542 | 93 |
end else isFalling:= true; |
503 | 94 |
|
351 | 95 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
4 | 96 |
begin |
351 | 97 |
Gear^.dX:= - Gear^.dX * Gear^.Elasticity; |
98 |
Gear^.State:= Gear^.State or gstCollision |
|
4 | 99 |
end; |
503 | 100 |
|
542 | 101 |
if isFalling then Gear^.dY:= Gear^.dY + cGravity; |
503 | 102 |
|
351 | 103 |
Gear^.X:= Gear^.X + Gear^.dX; |
104 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
4 | 105 |
CheckGearDrowning(Gear); |
503 | 106 |
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and |
542 | 107 |
(not isFalling) then Gear^.State:= Gear^.State and not gstMoving |
108 |
else Gear^.State:= Gear^.State or gstMoving |
|
4 | 109 |
end; |
110 |
||
111 |
//////////////////////////////////////////////////////////////////////////////// |
|
112 |
procedure doStepCloud(Gear: PGear); |
|
113 |
begin |
|
351 | 114 |
Gear^.X:= Gear^.X + cWindSpeed * 200 + Gear^.dX; |
498 | 115 |
if hwRound(Gear^.Y) > -160 then Gear^.dY:= Gear^.dY - _1div50000 |
116 |
else Gear^.dY:= Gear^.dY + _1div50000; |
|
351 | 117 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
498 | 118 |
if hwRound(Gear^.X) < -cScreenWidth - 256 then Gear^.X:= int2hwFloat(cScreenWidth + 2048) else |
119 |
if hwRound(Gear^.X) > cScreenWidth + 2048 then Gear^.X:= int2hwFloat(-cScreenWidth - 256) |
|
4 | 120 |
end; |
121 |
||
122 |
//////////////////////////////////////////////////////////////////////////////// |
|
123 |
procedure doStepBomb(Gear: PGear); |
|
371 | 124 |
var i: LongInt; |
4 | 125 |
begin |
126 |
AllInactive:= false; |
|
127 |
doStepFallingGear(Gear); |
|
351 | 128 |
dec(Gear^.Timer); |
129 |
if Gear^.Timer = 0 then |
|
4 | 130 |
begin |
351 | 131 |
case Gear^.Kind of |
132 |
gtAmmo_Bomb: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
78 | 133 |
gtClusterBomb: begin |
351 | 134 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
78 | 135 |
for i:= 0 to 4 do |
498 | 136 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, (getrandom - _0_5) * _0_2, (getrandom - _3) * _0_08, 0); |
78 | 137 |
end |
138 |
end; |
|
4 | 139 |
DeleteGear(Gear); |
140 |
exit |
|
141 |
end; |
|
142 |
CalcRotationDirAngle(Gear); |
|
351 | 143 |
if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then PlaySound(sndGrenadeImpact, false) |
4 | 144 |
end; |
145 |
||
78 | 146 |
procedure doStepCluster(Gear: PGear); |
147 |
begin |
|
148 |
AllInactive:= false; |
|
149 |
doStepFallingGear(Gear); |
|
351 | 150 |
if (Gear^.State and gstCollision) <> 0 then |
78 | 151 |
begin |
351 | 152 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
78 | 153 |
DeleteGear(Gear); |
154 |
exit |
|
155 |
end; |
|
156 |
if (GameTicks and $1F) = 0 then |
|
498 | 157 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
78 | 158 |
end; |
159 |
||
4 | 160 |
//////////////////////////////////////////////////////////////////////////////// |
161 |
procedure doStepGrenade(Gear: PGear); |
|
162 |
begin |
|
163 |
AllInactive:= false; |
|
351 | 164 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
4 | 165 |
doStepFallingGear(Gear); |
351 | 166 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 167 |
begin |
351 | 168 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
4 | 169 |
DeleteGear(Gear); |
170 |
exit |
|
171 |
end; |
|
172 |
if (GameTicks and $3F) = 0 then |
|
498 | 173 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
4 | 174 |
end; |
175 |
||
176 |
//////////////////////////////////////////////////////////////////////////////// |
|
95 | 177 |
procedure doStepHealthTagWork(Gear: PGear); |
4 | 178 |
begin |
522 | 179 |
if Gear^.Kind = gtHealthTag then |
180 |
AllInactive:= false; |
|
351 | 181 |
dec(Gear^.Timer); |
522 | 182 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
351 | 183 |
if Gear^.Timer = 0 then |
4 | 184 |
begin |
522 | 185 |
if Gear^.Kind = gtHealthTag then |
186 |
PHedgehog(Gear^.Hedgehog)^.Gear^.Active:= true; // to let current hh die |
|
4 | 187 |
DeleteGear(Gear) |
188 |
end |
|
189 |
end; |
|
190 |
||
263 | 191 |
procedure doStepHealthTagWorkUnderWater(Gear: PGear); |
192 |
begin |
|
193 |
AllInactive:= false; |
|
351 | 194 |
Gear^.Y:= Gear^.Y - _0_08; |
498 | 195 |
if hwRound(Gear^.Y) < cWaterLine + 10 then |
263 | 196 |
DeleteGear(Gear) |
197 |
end; |
|
198 |
||
95 | 199 |
procedure doStepHealthTag(Gear: PGear); |
200 |
var s: shortstring; |
|
522 | 201 |
font: THWFont; |
95 | 202 |
begin |
203 |
AllInactive:= false; |
|
522 | 204 |
if Gear^.Kind = gtHealthTag then |
205 |
begin |
|
206 |
font:= fnt16; |
|
207 |
Gear^.dY:= -_0_08 |
|
208 |
end else |
|
209 |
begin |
|
210 |
font:= fntSmall; |
|
211 |
Gear^.dY:= -_0_02 |
|
212 |
end; |
|
213 |
||
351 | 214 |
str(Gear^.State, s); |
762 | 215 |
Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, font); |
498 | 216 |
if hwRound(Gear^.Y) < cWaterLine then Gear^.doStep:= @doStepHealthTagWork |
522 | 217 |
else Gear^.doStep:= @doStepHealthTagWorkUnderWater; |
762 | 218 |
Gear^.Y:= Gear^.Y - int2hwFloat(Gear^.Tex^.h) |
95 | 219 |
end; |
220 |
||
4 | 221 |
//////////////////////////////////////////////////////////////////////////////// |
222 |
procedure doStepGrave(Gear: PGear); |
|
223 |
begin |
|
224 |
AllInactive:= false; |
|
498 | 225 |
if Gear^.dY.isNegative then |
226 |
if TestCollisionY(Gear, -1) then Gear^.dY:= _0; |
|
4 | 227 |
|
351 | 228 |
if not Gear^.dY.isNegative then |
68 | 229 |
if TestCollisionY(Gear, 1) then |
4 | 230 |
begin |
351 | 231 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
232 |
if Gear^.dY > - _1div1024 then |
|
4 | 233 |
begin |
351 | 234 |
Gear^.Active:= false; |
4 | 235 |
exit |
351 | 236 |
end else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false) |
4 | 237 |
end; |
351 | 238 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
4 | 239 |
CheckGearDrowning(Gear); |
351 | 240 |
Gear^.dY:= Gear^.dY + cGravity |
4 | 241 |
end; |
242 |
||
243 |
//////////////////////////////////////////////////////////////////////////////// |
|
244 |
procedure doStepUFOWork(Gear: PGear); |
|
351 | 245 |
var t: hwFloat; |
374 | 246 |
y: LongInt; |
4 | 247 |
begin |
248 |
AllInactive:= false; |
|
351 | 249 |
t:= Distance(Gear^.dX, Gear^.dY); |
250 |
Gear^.dX:= Gear^.Elasticity * (Gear^.dX + _0_000004 * (TargetPoint.X - hwRound(Gear^.X))); |
|
251 |
Gear^.dY:= Gear^.Elasticity * (Gear^.dY + _0_000004 * (TargetPoint.Y - hwRound(Gear^.Y))); |
|
252 |
t:= t / Distance(Gear^.dX, Gear^.dY); |
|
253 |
Gear^.dX:= Gear^.dX * t; |
|
254 |
Gear^.dY:= Gear^.dY * t; |
|
255 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
256 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
374 | 257 |
|
258 |
if (GameTicks and $3F) = 0 then |
|
259 |
begin |
|
260 |
y:= hwRound(Gear^.Y); |
|
261 |
if y + Gear^.Radius < cWaterLine then |
|
498 | 262 |
AddGear(hwRound(Gear^.X), y, gtSmokeTrace, 0, _0, _0, 0); |
374 | 263 |
end; |
264 |
||
4 | 265 |
CheckCollision(Gear); |
351 | 266 |
dec(Gear^.Timer); |
267 |
if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then |
|
4 | 268 |
begin |
560 | 269 |
StopSound(sndUFO); |
351 | 270 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
4 | 271 |
DeleteGear(Gear); |
272 |
end; |
|
273 |
end; |
|
274 |
||
275 |
procedure doStepUFO(Gear: PGear); |
|
276 |
begin |
|
277 |
AllInactive:= false; |
|
351 | 278 |
Gear^.X:= Gear^.X + Gear^.dX; |
279 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
280 |
Gear^.dY:= Gear^.dY + cGravity; |
|
4 | 281 |
CheckCollision(Gear); |
351 | 282 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 283 |
begin |
351 | 284 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
4 | 285 |
DeleteGear(Gear); |
286 |
exit |
|
287 |
end; |
|
351 | 288 |
dec(Gear^.Timer); |
289 |
if Gear^.Timer = 0 then |
|
4 | 290 |
begin |
560 | 291 |
PlaySound(sndUFO, true); |
351 | 292 |
Gear^.Timer:= 5000; |
293 |
Gear^.doStep:= @doStepUFOWork |
|
4 | 294 |
end; |
295 |
end; |
|
296 |
||
297 |
//////////////////////////////////////////////////////////////////////////////// |
|
298 |
procedure doStepShotgunShot(Gear: PGear); |
|
299 |
var i: LongWord; |
|
300 |
begin |
|
301 |
AllInactive:= false; |
|
351 | 302 |
if Gear^.Timer > 0 then |
4 | 303 |
begin |
351 | 304 |
dec(Gear^.Timer); |
305 |
if Gear^.Timer = 0 then PlaySound(sndShotgunFire, false); |
|
4 | 306 |
exit |
307 |
end; |
|
308 |
i:= 200; |
|
309 |
repeat |
|
351 | 310 |
Gear^.X:= Gear^.X + Gear^.dX; |
311 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
4 | 312 |
CheckCollision(Gear); |
351 | 313 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 314 |
begin |
506 | 315 |
Gear^.X:= Gear^.X + Gear^.dX * 8; |
316 |
Gear^.Y:= Gear^.Y + Gear^.dY * 8; |
|
317 |
ShotgunShot(Gear); |
|
4 | 318 |
DeleteGear(Gear); |
75 | 319 |
AfterAttack; |
4 | 320 |
exit |
321 |
end; |
|
322 |
dec(i) |
|
323 |
until i = 0; |
|
498 | 324 |
if (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then |
95 | 325 |
begin |
326 |
DeleteGear(Gear); |
|
327 |
AfterAttack |
|
328 |
end |
|
4 | 329 |
end; |
330 |
||
331 |
//////////////////////////////////////////////////////////////////////////////// |
|
559 | 332 |
procedure doStepDEagleShotWork(Gear: PGear); |
38 | 333 |
var i, x, y: LongWord; |
351 | 334 |
oX, oY: hwFloat; |
38 | 335 |
begin |
336 |
AllInactive:= false; |
|
37 | 337 |
i:= 80; |
351 | 338 |
oX:= Gear^.X; |
339 |
oY:= Gear^.Y; |
|
37 | 340 |
repeat |
351 | 341 |
Gear^.X:= Gear^.X + Gear^.dX; |
342 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
343 |
x:= hwRound(Gear^.X); |
|
344 |
y:= hwRound(Gear^.Y); |
|
38 | 345 |
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0) |
351 | 346 |
and (Land[y, x] <> 0) then inc(Gear^.Damage); |
519 | 347 |
if Gear^.Damage > 5 then AmmoShove(Gear, 7, 20); |
38 | 348 |
dec(i) |
351 | 349 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
350 |
if Gear^.Damage > 0 then |
|
37 | 351 |
begin |
351 | 352 |
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82 - i, 1); |
353 |
dec(Gear^.Health, Gear^.Damage); |
|
354 |
Gear^.Damage:= 0 |
|
37 | 355 |
end; |
498 | 356 |
if (Gear^.Health <= 0) or (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then |
37 | 357 |
DeleteGear(Gear) |
358 |
end; |
|
359 |
||
559 | 360 |
procedure doStepDEagleShot(Gear: PGear); |
361 |
begin |
|
362 |
PlaySound(sndGun, false); |
|
363 |
Gear^.doStep:= @doStepDEagleShotWork |
|
364 |
end; |
|
365 |
||
37 | 366 |
//////////////////////////////////////////////////////////////////////////////// |
4 | 367 |
procedure doStepActionTimer(Gear: PGear); |
368 |
begin |
|
351 | 369 |
dec(Gear^.Timer); |
370 |
case Gear^.Kind of |
|
83 | 371 |
gtATStartGame: begin |
4 | 372 |
AllInactive:= false; |
351 | 373 |
if Gear^.Timer = 0 then |
83 | 374 |
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); |
4 | 375 |
end; |
83 | 376 |
gtATSmoothWindCh: begin |
351 | 377 |
if Gear^.Timer = 0 then |
6 | 378 |
begin |
351 | 379 |
if WindBarWidth < Gear^.Tag then inc(WindBarWidth) |
380 |
else if WindBarWidth > Gear^.Tag then dec(WindBarWidth); |
|
381 |
if WindBarWidth <> Gear^.Tag then Gear^.Timer:= 10; |
|
83 | 382 |
end |
383 |
end; |
|
384 |
gtATFinishGame: begin |
|
385 |
AllInactive:= false; |
|
351 | 386 |
if Gear^.Timer = 0 then |
113 | 387 |
begin |
388 |
SendIPC('N'); |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
389 |
SendIPC('q'); |
83 | 390 |
GameState:= gsExit |
113 | 391 |
end |
6 | 392 |
end; |
4 | 393 |
end; |
351 | 394 |
if Gear^.Timer = 0 then DeleteGear(Gear) |
4 | 395 |
end; |
396 |
||
397 |
//////////////////////////////////////////////////////////////////////////////// |
|
398 |
procedure doStepPickHammerWork(Gear: PGear); |
|
371 | 399 |
var i, ei: LongInt; |
4 | 400 |
HHGear: PGear; |
401 |
begin |
|
70 | 402 |
AllInactive:= false; |
351 | 403 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
404 |
dec(Gear^.Timer); |
|
405 |
if (Gear^.Timer = 0)or((Gear^.Message and gm_Destroy) <> 0)or((HHGear^.State and gstHHDriven) = 0) then |
|
4 | 406 |
begin |
282 | 407 |
StopSound(sndPickhammer); |
4 | 408 |
DeleteGear(Gear); |
409 |
AfterAttack; |
|
410 |
exit |
|
411 |
end; |
|
422 | 412 |
|
413 |
if (Gear^.Timer mod 33) = 0 then |
|
414 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y) + 6, 6, EXPLDontDraw); |
|
415 |
||
416 |
if (Gear^.Timer mod 47) = 0 then |
|
4 | 417 |
begin |
371 | 418 |
i:= hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
419 |
ei:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
4 | 420 |
while i <= ei do |
421 |
begin |
|
422 | 422 |
DrawExplosion(i, hwRound(Gear^.Y) + 3, 3); |
4 | 423 |
inc(i, 1) |
424 |
end; |
|
351 | 425 |
Gear^.X:= Gear^.X + Gear^.dX; |
426 |
Gear^.Y:= Gear^.Y + _1_9; |
|
42 | 427 |
SetAllHHToActive; |
4 | 428 |
end; |
429 |
if TestCollisionYwithGear(Gear, 1) then |
|
430 |
begin |
|
498 | 431 |
Gear^.dY:= _0; |
351 | 432 |
SetLittle(HHGear^.dX); |
498 | 433 |
HHGear^.dY:= _0; |
4 | 434 |
end else |
435 |
begin |
|
351 | 436 |
Gear^.dY:= Gear^.dY + cGravity; |
437 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 438 |
if Gear^.Y > _1024 then Gear^.Timer:= 1 |
4 | 439 |
end; |
440 |
||
351 | 441 |
Gear^.X:= Gear^.X + HHGear^.dX; |
442 |
HHGear^.X:= Gear^.X; |
|
498 | 443 |
HHGear^.Y:= Gear^.Y - int2hwFloat(cHHRadius); |
4 | 444 |
|
351 | 445 |
if (Gear^.Message and gm_Attack) <> 0 then |
446 |
if (Gear^.State and gsttmpFlag) <> 0 then Gear^.Timer:= 1 else else |
|
447 |
if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
448 |
if ((Gear^.Message and gm_Left) <> 0) then Gear^.dX:= - _0_3 else |
|
449 |
if ((Gear^.Message and gm_Right) <> 0) then Gear^.dX:= _0_3 |
|
498 | 450 |
else Gear^.dX:= _0; |
4 | 451 |
end; |
452 |
||
453 |
procedure doStepPickHammer(Gear: PGear); |
|
371 | 454 |
var i, y: LongInt; |
4 | 455 |
ar: TRangeArray; |
456 |
begin |
|
457 |
i:= 0; |
|
498 | 458 |
y:= hwRound(Gear^.Y) - cHHRadius * 2; |
351 | 459 |
while y < hwRound(Gear^.Y) do |
4 | 460 |
begin |
371 | 461 |
ar[i].Left := hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
462 |
ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
4 | 463 |
inc(y, 2); |
464 |
inc(i) |
|
465 |
end; |
|
498 | 466 |
DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius * 2, 2, Pred(i)); |
351 | 467 |
Gear^.dY:= PHedgehog(Gear^.Hedgehog)^.Gear^.dY; |
282 | 468 |
PlaySound(sndPickhammer, true); |
4 | 469 |
doStepPickHammerWork(Gear); |
351 | 470 |
Gear^.doStep:= @doStepPickHammerWork |
4 | 471 |
end; |
472 |
||
473 |
//////////////////////////////////////////////////////////////////////////////// |
|
371 | 474 |
var BTPrevAngle, BTSteps: LongInt; |
302 | 475 |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
476 |
procedure doStepBlowTorchWork(Gear: PGear); |
302 | 477 |
var HHGear: PGear; |
305 | 478 |
b: boolean; |
302 | 479 |
begin |
480 |
AllInactive:= false; |
|
351 | 481 |
dec(Gear^.Timer); |
482 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
483 |
|
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
484 |
HedgehogChAngle(HHGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
485 |
|
305 | 486 |
b:= false; |
487 |
||
371 | 488 |
if abs(LongInt(HHGear^.Angle) - BTPrevAngle) > 7 then |
305 | 489 |
begin |
498 | 490 |
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX); |
355 | 491 |
Gear^.dY:= AngleCos(HHGear^.Angle) * ( - _0_5); |
351 | 492 |
BTPrevAngle:= HHGear^.Angle; |
358 | 493 |
b:= true |
305 | 494 |
end; |
495 |
||
351 | 496 |
if Gear^.Timer mod cHHStepTicks = 0 then |
302 | 497 |
begin |
305 | 498 |
b:= true; |
498 | 499 |
if Gear^.dX.isNegative then HHGear^.Message:= (HHGear^.Message or gm_Left) and not gm_Right |
500 |
else HHGear^.Message:= (HHGear^.Message or gm_Right) and not gm_Left; |
|
357 | 501 |
|
502 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
302 | 503 |
HedgehogStep(HHGear); |
357 | 504 |
HHGear^.State:= HHGear^.State or gstAttacking; |
305 | 505 |
|
506 |
inc(BTSteps); |
|
511 | 507 |
if BTSteps = 7 then |
305 | 508 |
begin |
509 |
BTSteps:= 0; |
|
511 | 510 |
Gear^.X:= HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); |
511 |
Gear^.Y:= HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); |
|
351 | 512 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
511 | 513 |
AmmoShove(Gear, 2, 14); |
351 | 514 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
305 | 515 |
end; |
516 |
||
542 | 517 |
if (HHGear^.State and gstMoving) <> 0 then Gear^.Timer:= 0 |
302 | 518 |
end; |
305 | 519 |
|
520 |
if b then |
|
498 | 521 |
DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - _4 - Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, |
351 | 522 |
Gear^.dX, Gear^.dY, |
306 | 523 |
cHHRadius * 5, cHHRadius * 2 + 6); |
305 | 524 |
|
351 | 525 |
if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) then |
302 | 526 |
begin |
351 | 527 |
HHGear^.Message:= 0; |
302 | 528 |
DeleteGear(Gear); |
529 |
AfterAttack |
|
530 |
end |
|
531 |
end; |
|
532 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
533 |
procedure doStepBlowTorch(Gear: PGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
534 |
var HHGear: PGear; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
535 |
begin |
371 | 536 |
BTPrevAngle:= High(LongInt); |
305 | 537 |
BTSteps:= 0; |
351 | 538 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
539 |
HHGear^.Message:= 0; |
|
540 |
Gear^.doStep:= @doStepBlowTorchWork |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
541 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
542 |
|
302 | 543 |
//////////////////////////////////////////////////////////////////////////////// |
544 |
||
4 | 545 |
procedure doStepRopeWork(Gear: PGear); |
70 | 546 |
const flCheck: boolean = false; |
4 | 547 |
var HHGear: PGear; |
789 | 548 |
len, cs, cc, tx, ty, nx, ny: hwFloat; |
108 | 549 |
lx, ly: LongInt; |
4 | 550 |
|
551 |
procedure DeleteMe; |
|
552 |
begin |
|
553 |
with HHGear^ do |
|
554 |
begin |
|
555 |
Message:= Message and not gm_Attack; |
|
542 | 556 |
State:= State or gstMoving; |
4 | 557 |
end; |
558 |
DeleteGear(Gear); |
|
534 | 559 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
351 | 560 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) |
4 | 561 |
end; |
562 |
||
563 |
begin |
|
351 | 564 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
108 | 565 |
|
351 | 566 |
if ((HHGear^.State and gstHHDriven) = 0) |
80 | 567 |
or (CheckGearDrowning(HHGear)) then |
4 | 568 |
begin |
569 |
DeleteMe; |
|
570 |
exit |
|
571 |
end; |
|
351 | 572 |
Gear^.dX:= HHGear^.X - Gear^.X; |
573 |
Gear^.dY:= HHGear^.Y - Gear^.Y; |
|
4 | 574 |
|
351 | 575 |
if (Gear^.Message and gm_Left <> 0) then HHGear^.dX:= HHGear^.dX - _0_0002 else |
576 |
if (Gear^.Message and gm_Right <> 0) then HHGear^.dX:= HHGear^.dX + _0_0002; |
|
4 | 577 |
|
351 | 578 |
if not TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= HHGear^.dY + cGravity; |
4 | 579 |
|
351 | 580 |
cs:= Gear^.dY + HHGear^.dY; |
581 |
cc:= Gear^.dX + HHGear^.dX; |
|
498 | 582 |
len:= _1 / Distance(cc, cs); |
789 | 583 |
cc:= cc * len; // rope vector plus hedgehog direction vector normalized |
108 | 584 |
cs:= cs * len; |
4 | 585 |
|
789 | 586 |
nx:= hwAbs(cs) * hwSign(HHGear^.dX) * 3; // hedgehog direction normalized with length 3 |
587 |
ny:= hwAbs(cc) * hwSign(HHGear^.dY) * 3; |
|
588 |
||
4 | 589 |
flCheck:= not flCheck; |
590 |
if flCheck then // check whether rope needs dividing |
|
591 |
begin |
|
498 | 592 |
len:= Gear^.Elasticity - _20; |
593 |
while len > _5 do |
|
4 | 594 |
begin |
595 |
tx:= cc*len; |
|
596 |
ty:= cs*len; |
|
789 | 597 |
lx:= hwRound(Gear^.X + tx + nx); |
598 |
ly:= hwRound(Gear^.Y + ty + ny); |
|
652 | 599 |
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0) and (Land[ly, lx] <> 0) then |
4 | 600 |
begin |
601 |
with RopePoints.ar[RopePoints.Count] do |
|
602 |
begin |
|
351 | 603 |
X:= Gear^.X; |
604 |
Y:= Gear^.Y; |
|
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
605 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); |
351 | 606 |
b:= (cc * HHGear^.dY) > (cs * HHGear^.dX); |
4 | 607 |
dLen:= len |
608 |
end; |
|
351 | 609 |
Gear^.X:= Gear^.X + tx; |
610 |
Gear^.Y:= Gear^.Y + ty; |
|
4 | 611 |
inc(RopePoints.Count); |
789 | 612 |
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); |
351 | 613 |
Gear^.Elasticity:= Gear^.Elasticity - len; |
614 |
Gear^.Friction:= Gear^.Friction - len; |
|
4 | 615 |
break |
616 |
end; |
|
789 | 617 |
len:= len - _2 |
4 | 618 |
end; |
619 |
end else |
|
620 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
|
621 |
begin |
|
622 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
623 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
351 | 624 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then |
4 | 625 |
begin |
626 |
dec(RopePoints.Count); |
|
351 | 627 |
Gear^.X:=RopePoints.ar[RopePoints.Count].X; |
628 |
Gear^.Y:=RopePoints.ar[RopePoints.Count].Y; |
|
629 |
Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
|
630 |
Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
4 | 631 |
end |
632 |
end; |
|
633 |
||
351 | 634 |
Gear^.dX:= HHGear^.X - Gear^.X; |
635 |
Gear^.dY:= HHGear^.Y - Gear^.Y; |
|
108 | 636 |
|
351 | 637 |
cs:= Gear^.dY + HHGear^.dY; |
638 |
cc:= Gear^.dX + HHGear^.dX; |
|
498 | 639 |
len:= _1 / Distance(cc, cs); |
108 | 640 |
cc:= cc * len; |
641 |
cs:= cs * len; |
|
4 | 642 |
|
351 | 643 |
HHGear^.dX:= HHGear^.X; |
644 |
HHGear^.dY:= HHGear^.Y; |
|
4 | 645 |
|
351 | 646 |
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then |
647 |
if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
|
648 |
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity + _0_3; |
|
4 | 649 |
|
498 | 650 |
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then |
351 | 651 |
if not (TestCollisionXwithGear(HHGear, -hwSign(Gear^.dX)) |
652 |
or TestCollisionYwithGear(HHGear, -hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity - _0_3; |
|
4 | 653 |
|
351 | 654 |
HHGear^.X:= Gear^.X + cc*Gear^.Elasticity; |
655 |
HHGear^.Y:= Gear^.Y + cs*Gear^.Elasticity; |
|
4 | 656 |
|
351 | 657 |
HHGear^.dX:= HHGear^.X - HHGear^.dX; |
658 |
HHGear^.dY:= HHGear^.Y - HHGear^.dY; |
|
4 | 659 |
|
351 | 660 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
661 |
HHGear^.dX:= -_0_6 * HHGear^.dX; |
|
662 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then |
|
663 |
HHGear^.dY:= -_0_6 * HHGear^.dY; |
|
4 | 664 |
|
789 | 665 |
len:= Distance(HHGear^.dX, HHGear^.dY); |
666 |
if len > _0_5 then |
|
667 |
begin |
|
668 |
len:= _0_5 / len; |
|
669 |
HHGear^.dX:= HHGear^.dX * len; |
|
670 |
HHGear^.dY:= HHGear^.dY * len; |
|
671 |
end; |
|
672 |
||
351 | 673 |
if (Gear^.Message and gm_Attack) <> 0 then |
674 |
if (Gear^.State and gsttmpFlag) <> 0 then DeleteMe else |
|
675 |
else if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
4 | 676 |
end; |
677 |
||
678 |
||
679 |
procedure doStepRopeAttach(Gear: PGear); |
|
680 |
var HHGear: PGear; |
|
351 | 681 |
tx, ty, tt: hwFloat; |
4 | 682 |
begin |
351 | 683 |
Gear^.X:= Gear^.X - Gear^.dX; |
684 |
Gear^.Y:= Gear^.Y - Gear^.dY; |
|
498 | 685 |
Gear^.Elasticity:= Gear^.Elasticity + _1; |
351 | 686 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
517 | 687 |
DeleteCI(HHGear); |
542 | 688 |
if (HHGear^.State and gstMoving) <> 0 then |
68 | 689 |
if TestCollisionYwithGear(HHGear, 1) then |
4 | 690 |
begin |
498 | 691 |
HHGear^.dY:= _0; |
4 | 692 |
CheckHHDamage(HHGear); |
542 | 693 |
HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); |
4 | 694 |
end else |
695 |
begin |
|
351 | 696 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
697 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
698 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
699 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
700 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
701 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
702 |
tt:= Gear^.Elasticity; |
|
498 | 703 |
tx:= _0; |
704 |
ty:= _0; |
|
705 |
while tt > _20 do |
|
4 | 706 |
begin |
517 | 707 |
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) |
708 |
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then |
|
4 | 709 |
begin |
351 | 710 |
Gear^.X:= Gear^.X + tx; |
711 |
Gear^.Y:= Gear^.Y + ty; |
|
712 |
Gear^.Elasticity:= tt; |
|
713 |
Gear^.doStep:= @doStepRopeWork; |
|
4 | 714 |
with HHGear^ do State:= State and not gstAttacking; |
498 | 715 |
tt:= _0 |
4 | 716 |
end; |
517 | 717 |
tx:= tx + Gear^.dX + Gear^.dX; |
718 |
ty:= ty + Gear^.dY + Gear^.dY; |
|
498 | 719 |
tt:= tt - _2; |
4 | 720 |
end; |
721 |
end; |
|
722 |
CheckCollision(Gear); |
|
351 | 723 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 724 |
begin |
351 | 725 |
Gear^.doStep:= @doStepRopeWork; |
4 | 726 |
with HHGear^ do State:= State and not gstAttacking; |
498 | 727 |
if Gear^.Elasticity < _10 then |
728 |
Gear^.Elasticity:= _10000; |
|
4 | 729 |
end; |
730 |
||
351 | 731 |
if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then |
4 | 732 |
begin |
351 | 733 |
with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
4 | 734 |
begin |
735 |
State:= State and not gstAttacking; |
|
736 |
Message:= Message and not gm_Attack |
|
737 |
end; |
|
738 |
DeleteGear(Gear) |
|
739 |
end |
|
740 |
end; |
|
741 |
||
742 |
procedure doStepRope(Gear: PGear); |
|
743 |
begin |
|
351 | 744 |
Gear^.dX:= - Gear^.dX; |
745 |
Gear^.dY:= - Gear^.dY; |
|
746 |
Gear^.doStep:= @doStepRopeAttach |
|
4 | 747 |
end; |
748 |
||
749 |
//////////////////////////////////////////////////////////////////////////////// |
|
750 |
procedure doStepSmokeTrace(Gear: PGear); |
|
751 |
begin |
|
351 | 752 |
inc(Gear^.Timer); |
753 |
if Gear^.Timer > 64 then |
|
4 | 754 |
begin |
351 | 755 |
Gear^.Timer:= 0; |
756 |
dec(Gear^.State) |
|
4 | 757 |
end; |
351 | 758 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
759 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
760 |
if Gear^.State = 0 then DeleteGear(Gear) |
|
4 | 761 |
end; |
9 | 762 |
|
763 |
//////////////////////////////////////////////////////////////////////////////// |
|
764 |
procedure doStepExplosion(Gear: PGear); |
|
765 |
begin |
|
351 | 766 |
inc(Gear^.Timer); |
767 |
if Gear^.Timer > 75 then |
|
9 | 768 |
begin |
351 | 769 |
inc(Gear^.State); |
770 |
Gear^.Timer:= 0; |
|
771 |
if Gear^.State > 5 then DeleteGear(Gear) |
|
9 | 772 |
end; |
773 |
end; |
|
10 | 774 |
|
775 |
//////////////////////////////////////////////////////////////////////////////// |
|
776 |
procedure doStepMine(Gear: PGear); |
|
777 |
begin |
|
542 | 778 |
if (Gear^.State and gstMoving) <> 0 then |
10 | 779 |
begin |
503 | 780 |
DeleteCI(Gear); |
10 | 781 |
doStepFallingGear(Gear); |
542 | 782 |
if (Gear^.State and gstMoving) = 0 then |
13 | 783 |
begin |
503 | 784 |
AddGearCI(Gear); |
498 | 785 |
Gear^.dX:= _0; |
786 |
Gear^.dY:= _0 |
|
13 | 787 |
end; |
788 |
CalcRotationDirAngle(Gear); |
|
10 | 789 |
AllInactive:= false |
790 |
end; |
|
351 | 791 |
|
792 |
if ((Gear^.State and gsttmpFlag) <> 0) then |
|
793 |
if ((Gear^.State and gstAttacking) = 0) then |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
794 |
begin |
39 | 795 |
if ((GameTicks and $F) = 0) then |
351 | 796 |
if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
797 |
end else // gstAttacking <> 0 |
10 | 798 |
begin |
799 |
AllInactive:= false; |
|
351 | 800 |
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false); |
801 |
if Gear^.Timer = 0 then |
|
10 | 802 |
begin |
351 | 803 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
521 | 804 |
DeleteGear(Gear); |
805 |
exit |
|
10 | 806 |
end; |
351 | 807 |
dec(Gear^.Timer); |
13 | 808 |
end else // gsttmpFlag = 0 |
351 | 809 |
if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
10 | 810 |
end; |
57 | 811 |
|
39 | 812 |
//////////////////////////////////////////////////////////////////////////////// |
813 |
procedure doStepDynamite(Gear: PGear); |
|
814 |
begin |
|
43 | 815 |
doStepFallingGear(Gear); |
816 |
AllInactive:= false; |
|
351 | 817 |
if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); |
818 |
if Gear^.Timer = 0 then |
|
39 | 819 |
begin |
351 | 820 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
43 | 821 |
DeleteGear(Gear); |
822 |
exit |
|
39 | 823 |
end; |
351 | 824 |
dec(Gear^.Timer); |
39 | 825 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
826 |
|
351 | 827 |
/////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
828 |
procedure doStepCase(Gear: PGear); |
371 | 829 |
var i, x, y: LongInt; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
830 |
begin |
351 | 831 |
if (Gear^.Message and gm_Destroy) > 0 then |
15 | 832 |
begin |
833 |
DeleteGear(Gear); |
|
435 | 834 |
FreeActionsList; |
602 | 835 |
with CurrentHedgehog^ do |
441 | 836 |
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
15 | 837 |
exit |
838 |
end; |
|
839 |
||
351 | 840 |
if Gear^.Damage > 0 then |
79 | 841 |
begin |
351 | 842 |
x:= hwRound(Gear^.X); |
843 |
y:= hwRound(Gear^.Y); |
|
79 | 844 |
DeleteGear(Gear); |
590 | 845 |
if Gear^.Kind = gtCase then |
846 |
begin |
|
847 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
|
848 |
for i:= 0 to 63 do |
|
849 |
AddGear(x, y, gtFlame, 0, _0, _0, 0); |
|
850 |
end; |
|
79 | 851 |
exit |
852 |
end; |
|
853 |
||
351 | 854 |
if (Gear^.dY.QWordValue <> 0) or (not TestCollisionYwithGear(Gear, 1)) then |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
855 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
856 |
AllInactive:= false; |
351 | 857 |
Gear^.dY:= Gear^.dY + cGravity; |
858 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 859 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else |
439 | 860 |
if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
861 |
begin |
351 | 862 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
498 | 863 |
if Gear^.dY > - _0_001 then Gear^.dY:= _0 |
351 | 864 |
else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false); |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
865 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
866 |
CheckGearDrowning(Gear); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
867 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
868 |
|
511 | 869 |
if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
870 |
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
|
871 |
end; |
49 | 872 |
|
873 |
//////////////////////////////////////////////////////////////////////////////// |
|
557 | 874 |
const cSorterWorkTime = 640; |
875 |
var thexchar: array[0..cMaxTeams] of |
|
876 |
record |
|
877 |
dy, ny, dw: LongInt; |
|
49 | 878 |
team: PTeam; |
557 | 879 |
SortFactor: QWord; |
49 | 880 |
end; |
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
881 |
currsorter: PGear = nil; |
49 | 882 |
|
883 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
371 | 884 |
var i: LongInt; |
49 | 885 |
begin |
886 |
AllInactive:= false; |
|
351 | 887 |
dec(Gear^.Timer); |
888 |
if (Gear^.Timer and 15) = 0 then |
|
557 | 889 |
for i:= 0 to Pred(TeamsCount) do |
49 | 890 |
with thexchar[i] do |
557 | 891 |
begin |
49 | 892 |
{$WARNINGS OFF} |
557 | 893 |
team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; |
894 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; |
|
49 | 895 |
{$WARNINGS ON} |
557 | 896 |
end; |
351 | 897 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
143 | 898 |
begin |
899 |
if currsorter = Gear then currsorter:= nil; |
|
49 | 900 |
DeleteGear(Gear) |
143 | 901 |
end |
49 | 902 |
end; |
903 |
||
904 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
547 | 905 |
var i, t: Longword; |
557 | 906 |
b: boolean; |
49 | 907 |
begin |
908 |
AllInactive:= false; |
|
557 | 909 |
|
547 | 910 |
for t:= 0 to Pred(TeamsCount) do |
557 | 911 |
with thexchar[t] do |
49 | 912 |
begin |
557 | 913 |
dy:= TeamsArray[t]^.DrawHealthY; |
914 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
915 |
team:= TeamsArray[t]; |
|
916 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
917 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
918 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
49 | 919 |
end; |
547 | 920 |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
921 |
if TeamsCount > 1 then |
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
922 |
repeat |
557 | 923 |
b:= true; |
924 |
for t:= 0 to TeamsCount - 2 do |
|
925 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
49 | 926 |
begin |
557 | 927 |
thexchar[cMaxTeams]:= thexchar[t]; |
49 | 928 |
thexchar[t]:= thexchar[Succ(t)]; |
557 | 929 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
930 |
b:= false |
|
931 |
end |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
932 |
until b; |
557 | 933 |
|
49 | 934 |
t:= cScreenHeight - 4; |
557 | 935 |
for i:= 0 to Pred(TeamsCount) do |
49 | 936 |
with thexchar[i] do |
937 |
begin |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
938 |
dec(t, team^.HealthTex^.h + 2); |
557 | 939 |
ny:= t; |
940 |
dy:= dy - ny |
|
49 | 941 |
end; |
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
942 |
|
557 | 943 |
Gear^.Timer:= cSorterWorkTime; |
351 | 944 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
143 | 945 |
currsorter:= Gear |
49 | 946 |
end; |
947 |
||
79 | 948 |
//////////////////////////////////////////////////////////////////////////////// |
949 |
procedure doStepShover(Gear: PGear); |
|
950 |
var HHGear: PGear; |
|
951 |
begin |
|
351 | 952 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
953 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
79 | 954 |
AmmoShove(Gear, 30, 115); |
351 | 955 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
79 | 956 |
DeleteGear(Gear) |
957 |
end; |
|
958 |
||
959 |
//////////////////////////////////////////////////////////////////////////////// |
|
960 |
procedure doStepFlame(Gear: PGear); |
|
961 |
begin |
|
962 |
AllInactive:= false; |
|
963 |
if not TestCollisionYwithGear(Gear, 1) then |
|
964 |
begin |
|
351 | 965 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
966 |
Gear^.dY:= Gear^.dY + cGravity; |
|
967 |
if hwAbs(Gear^.dX) > _0_1 then Gear^.dX:= Gear^.dX * _0_5; |
|
968 |
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; |
|
969 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
970 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 971 |
if not (Gear^.Y < _1024) then |
79 | 972 |
begin |
973 |
DeleteGear(Gear); |
|
974 |
exit |
|
975 |
end |
|
976 |
end else begin |
|
351 | 977 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
79 | 978 |
else begin |
506 | 979 |
// doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 2, 0); |
351 | 980 |
dec(Gear^.Health); |
981 |
Gear^.Timer:= 1250 - Gear^.Angle * 12 |
|
79 | 982 |
end |
983 |
end; |
|
984 |
||
351 | 985 |
if (((GameTicks div 8) mod 64) = Gear^.Angle) then |
79 | 986 |
AmmoFlameWork(Gear); |
987 |
||
351 | 988 |
if Gear^.Health = 0 then |
79 | 989 |
DeleteGear(Gear) |
990 |
end; |
|
82 | 991 |
|
992 |
//////////////////////////////////////////////////////////////////////////////// |
|
993 |
procedure doStepFirePunchWork(Gear: PGear); |
|
994 |
var HHGear: PGear; |
|
995 |
begin |
|
996 |
AllInactive:= false; |
|
351 | 997 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
82 | 998 |
begin |
999 |
DeleteGear(Gear); |
|
1000 |
AfterAttack; |
|
1001 |
exit |
|
1002 |
end; |
|
1003 |
||
351 | 1004 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1005 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
82 | 1006 |
begin |
351 | 1007 |
Gear^.Tag:= hwRound(HHGear^.Y); |
498 | 1008 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
351 | 1009 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
1010 |
Gear^.Y:= HHGear^.Y; |
|
82 | 1011 |
AmmoShove(Gear, 30, 40); |
351 | 1012 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
82 | 1013 |
end; |
351 | 1014 |
|
1015 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1016 |
if not (HHGear^.dY.isNegative) then |
|
82 | 1017 |
begin |
542 | 1018 |
HHGear^.State:= HHGear^.State or gstMoving; |
82 | 1019 |
DeleteGear(Gear); |
1020 |
AfterAttack; |
|
1021 |
exit |
|
1022 |
end; |
|
351 | 1023 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1024 |
end; |
1025 |
||
1026 |
procedure doStepFirePunch(Gear: PGear); |
|
1027 |
var HHGear: PGear; |
|
1028 |
begin |
|
1029 |
AllInactive:= false; |
|
351 | 1030 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1031 |
DeleteCI(HHGear); |
498 | 1032 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
351 | 1033 |
SetLittle(HHGear^.dX); |
1034 |
HHGear^.dY:= - _0_3; |
|
82 | 1035 |
|
351 | 1036 |
Gear^.X:= HHGear^.X; |
498 | 1037 |
Gear^.dX:= SignAs(_0_45, HHGear^.dX); |
351 | 1038 |
Gear^.dY:= - _0_9; |
1039 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1040 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
82 | 1041 |
end; |
1042 |
||
263 | 1043 |
//////////////////////////////////////////////////////////////////////////////// |
1044 |
||
211 | 1045 |
procedure doStepParachute(Gear: PGear); |
1046 |
var HHGear: PGear; |
|
1047 |
begin |
|
351 | 1048 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1049 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
517 | 1050 |
DeleteCI(HHGear); |
82 | 1051 |
|
516 | 1052 |
inc(Gear^.Timer); |
1053 |
||
212 | 1054 |
if TestCollisionYwithGear(HHGear, 1) |
351 | 1055 |
or ((HHGear^.State and gstHHDriven) = 0) |
212 | 1056 |
or CheckGearDrowning(HHGear) then |
211 | 1057 |
begin |
1058 |
with HHGear^ do |
|
1059 |
begin |
|
1060 |
Message:= 0; |
|
568 | 1061 |
SetLittle(dX); |
498 | 1062 |
dY:= _0; |
211 | 1063 |
State:= State and not (gstAttacking or gstAttacked); |
542 | 1064 |
State:= State or gstMoving; |
211 | 1065 |
end; |
1066 |
DeleteGear(Gear); |
|
516 | 1067 |
if Gear^.Timer > 10 then |
1068 |
begin |
|
534 | 1069 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
516 | 1070 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) |
1071 |
end; |
|
211 | 1072 |
exit |
1073 |
end; |
|
1074 |
||
351 | 1075 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1076 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
|
211 | 1077 |
|
351 | 1078 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1079 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1080 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1081 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1082 |
|
351 | 1083 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1084 |
Gear^.X:= HHGear^.X; |
1085 |
Gear^.Y:= HHGear^.Y |
|
263 | 1086 |
end; |
211 | 1087 |
|
263 | 1088 |
//////////////////////////////////////////////////////////////////////////////// |
1089 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1090 |
begin |
|
1091 |
AllInactive:= false; |
|
498 | 1092 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1093 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
263 | 1094 |
begin |
351 | 1095 |
dec(Gear^.Health); |
1096 |
case Gear^.State of |
|
498 | 1097 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
1098 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
285 | 1099 |
end; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1100 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
263 | 1101 |
end; |
498 | 1102 |
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1103 |
end; |
1104 |
||
1105 |
procedure doStepAirAttack(Gear: PGear); |
|
1106 |
begin |
|
1107 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1108 |
|
408 | 1109 |
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 |
1110 |
else Gear^.Tag:= -1; |
|
498 | 1111 |
Gear^.X:= _1024 - _2048 * Gear^.Tag; |
1112 |
Gear^.Y:= -_128; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1113 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1114 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1115 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
498 | 1116 |
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
|
1117 |
addfilelog('attack: x = '+floattostr(gear^.dx)); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1118 |
|
351 | 1119 |
Gear^.Health:= 6; |
1120 |
Gear^.doStep:= @doStepAirAttackWork |
|
263 | 1121 |
end; |
1122 |
||
1123 |
//////////////////////////////////////////////////////////////////////////////// |
|
1124 |
||
1125 |
procedure doStepAirBomb(Gear: PGear); |
|
1126 |
begin |
|
1127 |
AllInactive:= false; |
|
1128 |
doStepFallingGear(Gear); |
|
351 | 1129 |
if (Gear^.State and gstCollision) <> 0 then |
263 | 1130 |
begin |
351 | 1131 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
263 | 1132 |
DeleteGear(Gear); |
1133 |
exit |
|
1134 |
end; |
|
1135 |
if (GameTicks and $3F) = 0 then |
|
498 | 1136 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1137 |
end; |
409 | 1138 |
|
1139 |
//////////////////////////////////////////////////////////////////////////////// |
|
1140 |
||
1141 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1142 |
var HHGear: PGear; |
409 | 1143 |
begin |
1144 |
AllInactive:= false; |
|
415 | 1145 |
|
1146 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1147 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1148 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1149 |
sprAmGirder, Gear^.State, true) then |
409 | 1150 |
begin |
415 | 1151 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
1152 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1153 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1154 |
DeleteGear(Gear); |
|
1155 |
isCursorVisible:= true |
|
409 | 1156 |
end |
415 | 1157 |
else begin |
1158 |
DeleteGear(Gear); |
|
1159 |
AfterAttack |
|
1160 |
end; |
|
1161 |
TargetPoint.X:= NoPointX |
|
409 | 1162 |
end; |
520 | 1163 |
|
1164 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1165 |
procedure doStepTeleportAfter(Gear: PGear); |
798 | 1166 |
//var HHGear: PGear; |
525 | 1167 |
begin |
798 | 1168 |
//HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1169 |
//HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
1170 |
//HHGear^.dY:= HHGear^.dY + cGravity; |
|
1171 |
//if TestCollisionYwithGear(HHGear, 1) then |
|
1172 |
// begin |
|
525 | 1173 |
DeleteGear(Gear); |
1174 |
AfterAttack |
|
798 | 1175 |
// end |
525 | 1176 |
end; |
520 | 1177 |
|
1178 |
procedure doStepTeleport(Gear: PGear); |
|
1179 |
var HHGear: PGear; |
|
1180 |
begin |
|
1181 |
AllInactive:= false; |
|
1182 |
||
1183 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1184 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1185 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1186 |
sprHHTelepMask, 0, false) then |
|
1187 |
begin |
|
1188 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1189 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1190 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1191 |
DeleteGear(Gear); |
|
1192 |
isCursorVisible:= true |
|
1193 |
end |
|
1194 |
else begin |
|
1195 |
DeleteCI(HHGear); |
|
525 | 1196 |
Gear^.doStep:= @doStepTeleportAfter; |
520 | 1197 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
1198 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
542 | 1199 |
HHGear^.State:= HHGear^.State or gstMoving |
520 | 1200 |
end; |
1201 |
TargetPoint.X:= NoPointX |
|
1202 |
end; |
|
534 | 1203 |
|
1204 |
//////////////////////////////////////////////////////////////////////////////// |
|
1205 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1206 |
var HHGear: PGear; |
|
1207 |
Msg, State: Longword; |
|
1208 |
begin |
|
1209 |
AllInactive:= false; |
|
1210 |
||
540 | 1211 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
534 | 1212 |
begin |
1213 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1214 |
Msg:= Gear^.Message and not gm_Switch; |
|
1215 |
DeleteGear(Gear); |
|
538 | 1216 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
1217 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1218 |
|
602 | 1219 |
HHGear:= CurrentHedgehog^.Gear; |
538 | 1220 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
534 | 1221 |
HHGear^.Message:= Msg; |
1222 |
exit |
|
1223 |
end; |
|
1224 |
||
1225 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1226 |
begin |
|
602 | 1227 |
HHGear:= CurrentHedgehog^.Gear; |
534 | 1228 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
1229 |
State:= HHGear^.State; |
|
1230 |
HHGear^.State:= 0; |
|
1231 |
HHGear^.Active:= false; |
|
1232 |
HHGear^.Z:= cHHZ; |
|
1233 |
RemoveGearFromList(HHGear); |
|
1234 |
InsertGearToList(HHGear); |
|
1235 |
||
1236 |
repeat |
|
551 | 1237 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
652 | 1238 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
1239 |
||
1240 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
|
534 | 1241 |
|
602 | 1242 |
HHGear:= CurrentHedgehog^.Gear; |
534 | 1243 |
HHGear^.State:= State; |
1244 |
HHGear^.Active:= true; |
|
1245 |
FollowGear:= HHGear; |
|
1246 |
HHGear^.Z:= cCurrHHZ; |
|
1247 |
RemoveGearFromList(HHGear); |
|
1248 |
InsertGearToList(HHGear); |
|
1249 |
Gear^.X:= HHGear^.X; |
|
1250 |
Gear^.Y:= HHGear^.Y |
|
1251 |
end; |
|
1252 |
end; |
|
1253 |
||
1254 |
procedure doStepSwitcher(Gear: PGear); |
|
1255 |
var HHGear: PGear; |
|
1256 |
begin |
|
1257 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1258 |
||
1259 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1260 |
with HHGear^ do |
|
1261 |
begin |
|
1262 |
State:= State and not gstAttacking; |
|
1263 |
Message:= Message and not gm_Attack |
|
1264 |
end |
|
1265 |
end; |