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