author | displacer |
Thu, 16 Aug 2007 14:10:06 +0000 | |
changeset 571 | a6cea9fbbc59 |
parent 568 | d0690b7aa808 |
child 576 | 35a1af355ada |
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 |
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; |
351 | 548 |
len, cs, cc, tx, ty: 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); |
108 | 583 |
cc:= cc * len; |
584 |
cs:= cs * len; |
|
4 | 585 |
|
586 |
flCheck:= not flCheck; |
|
587 |
if flCheck then // check whether rope needs dividing |
|
588 |
begin |
|
498 | 589 |
len:= Gear^.Elasticity - _20; |
590 |
while len > _5 do |
|
4 | 591 |
begin |
592 |
tx:= cc*len; |
|
593 |
ty:= cs*len; |
|
351 | 594 |
lx:= hwRound(Gear^.X + tx) + hwSign(HHGear^.dX); |
595 |
ly:= hwRound(Gear^.Y + ty) + hwSign(HHGear^.dY); |
|
4 | 596 |
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0)and (Land[ly, lx] <> 0) then |
597 |
begin |
|
598 |
with RopePoints.ar[RopePoints.Count] do |
|
599 |
begin |
|
351 | 600 |
X:= Gear^.X; |
601 |
Y:= Gear^.Y; |
|
370
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
358
diff
changeset
|
602 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle32(Gear^.dY, Gear^.dX); |
351 | 603 |
b:= (cc * HHGear^.dY) > (cs * HHGear^.dX); |
4 | 604 |
dLen:= len |
605 |
end; |
|
351 | 606 |
Gear^.X:= Gear^.X + tx; |
607 |
Gear^.Y:= Gear^.Y + ty; |
|
4 | 608 |
inc(RopePoints.Count); |
351 | 609 |
Gear^.Elasticity:= Gear^.Elasticity - len; |
610 |
Gear^.Friction:= Gear^.Friction - len; |
|
4 | 611 |
break |
612 |
end; |
|
498 | 613 |
len:= len - _3 |
4 | 614 |
end; |
615 |
end else |
|
616 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
|
617 |
begin |
|
618 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
619 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
351 | 620 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then |
4 | 621 |
begin |
622 |
dec(RopePoints.Count); |
|
351 | 623 |
Gear^.X:=RopePoints.ar[RopePoints.Count].X; |
624 |
Gear^.Y:=RopePoints.ar[RopePoints.Count].Y; |
|
625 |
Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
|
626 |
Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
4 | 627 |
end |
628 |
end; |
|
629 |
||
351 | 630 |
Gear^.dX:= HHGear^.X - Gear^.X; |
631 |
Gear^.dY:= HHGear^.Y - Gear^.Y; |
|
108 | 632 |
|
351 | 633 |
cs:= Gear^.dY + HHGear^.dY; |
634 |
cc:= Gear^.dX + HHGear^.dX; |
|
498 | 635 |
len:= _1 / Distance(cc, cs); |
108 | 636 |
cc:= cc * len; |
637 |
cs:= cs * len; |
|
4 | 638 |
|
351 | 639 |
HHGear^.dX:= HHGear^.X; |
640 |
HHGear^.dY:= HHGear^.Y; |
|
4 | 641 |
|
351 | 642 |
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then |
643 |
if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
|
644 |
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity + _0_3; |
|
4 | 645 |
|
498 | 646 |
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then |
351 | 647 |
if not (TestCollisionXwithGear(HHGear, -hwSign(Gear^.dX)) |
648 |
or TestCollisionYwithGear(HHGear, -hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity - _0_3; |
|
4 | 649 |
|
351 | 650 |
HHGear^.X:= Gear^.X + cc*Gear^.Elasticity; |
651 |
HHGear^.Y:= Gear^.Y + cs*Gear^.Elasticity; |
|
4 | 652 |
|
351 | 653 |
HHGear^.dX:= HHGear^.X - HHGear^.dX; |
654 |
HHGear^.dY:= HHGear^.Y - HHGear^.dY; |
|
4 | 655 |
|
351 | 656 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
657 |
HHGear^.dX:= -_0_6 * HHGear^.dX; |
|
658 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then |
|
659 |
HHGear^.dY:= -_0_6 * HHGear^.dY; |
|
4 | 660 |
|
351 | 661 |
if (Gear^.Message and gm_Attack) <> 0 then |
662 |
if (Gear^.State and gsttmpFlag) <> 0 then DeleteMe else |
|
663 |
else if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
4 | 664 |
end; |
665 |
||
666 |
||
667 |
procedure doStepRopeAttach(Gear: PGear); |
|
668 |
var HHGear: PGear; |
|
351 | 669 |
tx, ty, tt: hwFloat; |
4 | 670 |
begin |
351 | 671 |
Gear^.X:= Gear^.X - Gear^.dX; |
672 |
Gear^.Y:= Gear^.Y - Gear^.dY; |
|
498 | 673 |
Gear^.Elasticity:= Gear^.Elasticity + _1; |
351 | 674 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
517 | 675 |
DeleteCI(HHGear); |
542 | 676 |
if (HHGear^.State and gstMoving) <> 0 then |
68 | 677 |
if TestCollisionYwithGear(HHGear, 1) then |
4 | 678 |
begin |
498 | 679 |
HHGear^.dY:= _0; |
4 | 680 |
CheckHHDamage(HHGear); |
542 | 681 |
HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); |
4 | 682 |
end else |
683 |
begin |
|
351 | 684 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
685 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
686 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
687 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
688 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
689 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
690 |
tt:= Gear^.Elasticity; |
|
498 | 691 |
tx:= _0; |
692 |
ty:= _0; |
|
693 |
while tt > _20 do |
|
4 | 694 |
begin |
517 | 695 |
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) |
696 |
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then |
|
4 | 697 |
begin |
351 | 698 |
Gear^.X:= Gear^.X + tx; |
699 |
Gear^.Y:= Gear^.Y + ty; |
|
700 |
Gear^.Elasticity:= tt; |
|
701 |
Gear^.doStep:= @doStepRopeWork; |
|
4 | 702 |
with HHGear^ do State:= State and not gstAttacking; |
498 | 703 |
tt:= _0 |
4 | 704 |
end; |
517 | 705 |
tx:= tx + Gear^.dX + Gear^.dX; |
706 |
ty:= ty + Gear^.dY + Gear^.dY; |
|
498 | 707 |
tt:= tt - _2; |
4 | 708 |
end; |
709 |
end; |
|
710 |
CheckCollision(Gear); |
|
351 | 711 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 712 |
begin |
351 | 713 |
Gear^.doStep:= @doStepRopeWork; |
4 | 714 |
with HHGear^ do State:= State and not gstAttacking; |
498 | 715 |
if Gear^.Elasticity < _10 then |
716 |
Gear^.Elasticity:= _10000; |
|
4 | 717 |
end; |
718 |
||
351 | 719 |
if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then |
4 | 720 |
begin |
351 | 721 |
with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
4 | 722 |
begin |
723 |
State:= State and not gstAttacking; |
|
724 |
Message:= Message and not gm_Attack |
|
725 |
end; |
|
726 |
DeleteGear(Gear) |
|
727 |
end |
|
728 |
end; |
|
729 |
||
730 |
procedure doStepRope(Gear: PGear); |
|
731 |
begin |
|
351 | 732 |
Gear^.dX:= - Gear^.dX; |
733 |
Gear^.dY:= - Gear^.dY; |
|
734 |
Gear^.doStep:= @doStepRopeAttach |
|
4 | 735 |
end; |
736 |
||
737 |
//////////////////////////////////////////////////////////////////////////////// |
|
738 |
procedure doStepSmokeTrace(Gear: PGear); |
|
739 |
begin |
|
351 | 740 |
inc(Gear^.Timer); |
741 |
if Gear^.Timer > 64 then |
|
4 | 742 |
begin |
351 | 743 |
Gear^.Timer:= 0; |
744 |
dec(Gear^.State) |
|
4 | 745 |
end; |
351 | 746 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
747 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
748 |
if Gear^.State = 0 then DeleteGear(Gear) |
|
4 | 749 |
end; |
9 | 750 |
|
751 |
//////////////////////////////////////////////////////////////////////////////// |
|
752 |
procedure doStepExplosion(Gear: PGear); |
|
753 |
begin |
|
351 | 754 |
inc(Gear^.Timer); |
755 |
if Gear^.Timer > 75 then |
|
9 | 756 |
begin |
351 | 757 |
inc(Gear^.State); |
758 |
Gear^.Timer:= 0; |
|
759 |
if Gear^.State > 5 then DeleteGear(Gear) |
|
9 | 760 |
end; |
761 |
end; |
|
10 | 762 |
|
763 |
//////////////////////////////////////////////////////////////////////////////// |
|
764 |
procedure doStepMine(Gear: PGear); |
|
765 |
begin |
|
542 | 766 |
if (Gear^.State and gstMoving) <> 0 then |
10 | 767 |
begin |
503 | 768 |
DeleteCI(Gear); |
10 | 769 |
doStepFallingGear(Gear); |
542 | 770 |
if (Gear^.State and gstMoving) = 0 then |
13 | 771 |
begin |
503 | 772 |
AddGearCI(Gear); |
498 | 773 |
Gear^.dX:= _0; |
774 |
Gear^.dY:= _0 |
|
13 | 775 |
end; |
776 |
CalcRotationDirAngle(Gear); |
|
10 | 777 |
AllInactive:= false |
778 |
end; |
|
351 | 779 |
|
780 |
if ((Gear^.State and gsttmpFlag) <> 0) then |
|
781 |
if ((Gear^.State and gstAttacking) = 0) then |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
782 |
begin |
39 | 783 |
if ((GameTicks and $F) = 0) then |
351 | 784 |
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
|
785 |
end else // gstAttacking <> 0 |
10 | 786 |
begin |
787 |
AllInactive:= false; |
|
351 | 788 |
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false); |
789 |
if Gear^.Timer = 0 then |
|
10 | 790 |
begin |
351 | 791 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
521 | 792 |
DeleteGear(Gear); |
793 |
exit |
|
10 | 794 |
end; |
351 | 795 |
dec(Gear^.Timer); |
13 | 796 |
end else // gsttmpFlag = 0 |
351 | 797 |
if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
10 | 798 |
end; |
57 | 799 |
|
39 | 800 |
//////////////////////////////////////////////////////////////////////////////// |
801 |
procedure doStepDynamite(Gear: PGear); |
|
802 |
begin |
|
43 | 803 |
doStepFallingGear(Gear); |
804 |
AllInactive:= false; |
|
351 | 805 |
if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); |
806 |
if Gear^.Timer = 0 then |
|
39 | 807 |
begin |
351 | 808 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
43 | 809 |
DeleteGear(Gear); |
810 |
exit |
|
39 | 811 |
end; |
351 | 812 |
dec(Gear^.Timer); |
39 | 813 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
814 |
|
351 | 815 |
/////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
816 |
procedure doStepCase(Gear: PGear); |
371 | 817 |
var i, x, y: LongInt; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
818 |
begin |
351 | 819 |
if (Gear^.Message and gm_Destroy) > 0 then |
15 | 820 |
begin |
821 |
DeleteGear(Gear); |
|
435 | 822 |
FreeActionsList; |
441 | 823 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do |
824 |
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
|
15 | 825 |
exit |
826 |
end; |
|
827 |
||
351 | 828 |
if Gear^.Damage > 0 then |
79 | 829 |
begin |
351 | 830 |
x:= hwRound(Gear^.X); |
831 |
y:= hwRound(Gear^.Y); |
|
79 | 832 |
DeleteGear(Gear); |
89 | 833 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
79 | 834 |
for i:= 0 to 63 do |
498 | 835 |
AddGear(x, y, gtFlame, 0, _0, _0, 0); |
79 | 836 |
exit |
837 |
end; |
|
838 |
||
351 | 839 |
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
|
840 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
841 |
AllInactive:= false; |
351 | 842 |
Gear^.dY:= Gear^.dY + cGravity; |
843 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 844 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else |
439 | 845 |
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
|
846 |
begin |
351 | 847 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
498 | 848 |
if Gear^.dY > - _0_001 then Gear^.dY:= _0 |
351 | 849 |
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
|
850 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
851 |
CheckGearDrowning(Gear); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
852 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
853 |
|
511 | 854 |
if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
855 |
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
|
856 |
end; |
49 | 857 |
|
858 |
//////////////////////////////////////////////////////////////////////////////// |
|
557 | 859 |
const cSorterWorkTime = 640; |
860 |
var thexchar: array[0..cMaxTeams] of |
|
861 |
record |
|
862 |
dy, ny, dw: LongInt; |
|
49 | 863 |
team: PTeam; |
557 | 864 |
SortFactor: QWord; |
49 | 865 |
end; |
143 | 866 |
currsorter: PGear; |
49 | 867 |
|
868 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
371 | 869 |
var i: LongInt; |
49 | 870 |
begin |
871 |
AllInactive:= false; |
|
351 | 872 |
dec(Gear^.Timer); |
873 |
if (Gear^.Timer and 15) = 0 then |
|
557 | 874 |
for i:= 0 to Pred(TeamsCount) do |
49 | 875 |
with thexchar[i] do |
557 | 876 |
begin |
49 | 877 |
{$WARNINGS OFF} |
557 | 878 |
team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; |
879 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; |
|
49 | 880 |
{$WARNINGS ON} |
557 | 881 |
end; |
351 | 882 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
143 | 883 |
begin |
884 |
if currsorter = Gear then currsorter:= nil; |
|
49 | 885 |
DeleteGear(Gear) |
143 | 886 |
end |
49 | 887 |
end; |
888 |
||
889 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
547 | 890 |
var i, t: Longword; |
557 | 891 |
b: boolean; |
49 | 892 |
begin |
893 |
AllInactive:= false; |
|
557 | 894 |
|
547 | 895 |
for t:= 0 to Pred(TeamsCount) do |
557 | 896 |
with thexchar[t] do |
49 | 897 |
begin |
557 | 898 |
dy:= TeamsArray[t]^.DrawHealthY; |
899 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
900 |
team:= TeamsArray[t]; |
|
901 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
902 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
903 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
49 | 904 |
end; |
547 | 905 |
|
557 | 906 |
repeat |
907 |
b:= true; |
|
908 |
for t:= 0 to TeamsCount - 2 do |
|
909 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
49 | 910 |
begin |
557 | 911 |
thexchar[cMaxTeams]:= thexchar[t]; |
49 | 912 |
thexchar[t]:= thexchar[Succ(t)]; |
557 | 913 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
914 |
b:= false |
|
915 |
end |
|
916 |
until b; |
|
917 |
||
49 | 918 |
t:= cScreenHeight - 4; |
557 | 919 |
for i:= 0 to Pred(TeamsCount) do |
49 | 920 |
with thexchar[i] do |
921 |
begin |
|
351 | 922 |
dec(t, team^.HealthRect.h + 2); |
557 | 923 |
ny:= t; |
924 |
dy:= dy - ny |
|
49 | 925 |
end; |
547 | 926 |
|
557 | 927 |
Gear^.Timer:= cSorterWorkTime; |
351 | 928 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
143 | 929 |
currsorter:= Gear |
49 | 930 |
end; |
931 |
||
79 | 932 |
//////////////////////////////////////////////////////////////////////////////// |
933 |
procedure doStepShover(Gear: PGear); |
|
934 |
var HHGear: PGear; |
|
935 |
begin |
|
351 | 936 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
937 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
79 | 938 |
AmmoShove(Gear, 30, 115); |
351 | 939 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
79 | 940 |
DeleteGear(Gear) |
941 |
end; |
|
942 |
||
943 |
//////////////////////////////////////////////////////////////////////////////// |
|
944 |
procedure doStepFlame(Gear: PGear); |
|
945 |
begin |
|
946 |
AllInactive:= false; |
|
947 |
if not TestCollisionYwithGear(Gear, 1) then |
|
948 |
begin |
|
351 | 949 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
950 |
Gear^.dY:= Gear^.dY + cGravity; |
|
951 |
if hwAbs(Gear^.dX) > _0_1 then Gear^.dX:= Gear^.dX * _0_5; |
|
952 |
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; |
|
953 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
954 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 955 |
if not (Gear^.Y < _1024) then |
79 | 956 |
begin |
957 |
DeleteGear(Gear); |
|
958 |
exit |
|
959 |
end |
|
960 |
end else begin |
|
351 | 961 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
79 | 962 |
else begin |
506 | 963 |
// doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 2, 0); |
351 | 964 |
dec(Gear^.Health); |
965 |
Gear^.Timer:= 1250 - Gear^.Angle * 12 |
|
79 | 966 |
end |
967 |
end; |
|
968 |
||
351 | 969 |
if (((GameTicks div 8) mod 64) = Gear^.Angle) then |
79 | 970 |
AmmoFlameWork(Gear); |
971 |
||
351 | 972 |
if Gear^.Health = 0 then |
79 | 973 |
DeleteGear(Gear) |
974 |
end; |
|
82 | 975 |
|
976 |
//////////////////////////////////////////////////////////////////////////////// |
|
977 |
procedure doStepFirePunchWork(Gear: PGear); |
|
978 |
var HHGear: PGear; |
|
979 |
begin |
|
980 |
AllInactive:= false; |
|
351 | 981 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
82 | 982 |
begin |
983 |
DeleteGear(Gear); |
|
984 |
AfterAttack; |
|
985 |
exit |
|
986 |
end; |
|
987 |
||
351 | 988 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
989 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
82 | 990 |
begin |
351 | 991 |
Gear^.Tag:= hwRound(HHGear^.Y); |
498 | 992 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
351 | 993 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
994 |
Gear^.Y:= HHGear^.Y; |
|
82 | 995 |
AmmoShove(Gear, 30, 40); |
351 | 996 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
82 | 997 |
end; |
351 | 998 |
|
999 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1000 |
if not (HHGear^.dY.isNegative) then |
|
82 | 1001 |
begin |
542 | 1002 |
HHGear^.State:= HHGear^.State or gstMoving; |
82 | 1003 |
DeleteGear(Gear); |
1004 |
AfterAttack; |
|
1005 |
exit |
|
1006 |
end; |
|
351 | 1007 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1008 |
end; |
1009 |
||
1010 |
procedure doStepFirePunch(Gear: PGear); |
|
1011 |
var HHGear: PGear; |
|
1012 |
begin |
|
1013 |
AllInactive:= false; |
|
351 | 1014 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1015 |
DeleteCI(HHGear); |
498 | 1016 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
351 | 1017 |
SetLittle(HHGear^.dX); |
1018 |
HHGear^.dY:= - _0_3; |
|
82 | 1019 |
|
351 | 1020 |
Gear^.X:= HHGear^.X; |
498 | 1021 |
Gear^.dX:= SignAs(_0_45, HHGear^.dX); |
351 | 1022 |
Gear^.dY:= - _0_9; |
1023 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1024 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
82 | 1025 |
end; |
1026 |
||
263 | 1027 |
//////////////////////////////////////////////////////////////////////////////// |
1028 |
||
211 | 1029 |
procedure doStepParachute(Gear: PGear); |
1030 |
var HHGear: PGear; |
|
1031 |
begin |
|
351 | 1032 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1033 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
517 | 1034 |
DeleteCI(HHGear); |
82 | 1035 |
|
516 | 1036 |
inc(Gear^.Timer); |
1037 |
||
212 | 1038 |
if TestCollisionYwithGear(HHGear, 1) |
351 | 1039 |
or ((HHGear^.State and gstHHDriven) = 0) |
212 | 1040 |
or CheckGearDrowning(HHGear) then |
211 | 1041 |
begin |
1042 |
with HHGear^ do |
|
1043 |
begin |
|
1044 |
Message:= 0; |
|
568 | 1045 |
SetLittle(dX); |
498 | 1046 |
dY:= _0; |
211 | 1047 |
State:= State and not (gstAttacking or gstAttacked); |
542 | 1048 |
State:= State or gstMoving; |
211 | 1049 |
end; |
1050 |
DeleteGear(Gear); |
|
516 | 1051 |
if Gear^.Timer > 10 then |
1052 |
begin |
|
534 | 1053 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
516 | 1054 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) |
1055 |
end; |
|
211 | 1056 |
exit |
1057 |
end; |
|
1058 |
||
351 | 1059 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1060 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
|
211 | 1061 |
|
351 | 1062 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1063 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1064 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1065 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1066 |
|
351 | 1067 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1068 |
Gear^.X:= HHGear^.X; |
1069 |
Gear^.Y:= HHGear^.Y |
|
263 | 1070 |
end; |
211 | 1071 |
|
263 | 1072 |
//////////////////////////////////////////////////////////////////////////////// |
1073 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1074 |
begin |
|
1075 |
AllInactive:= false; |
|
498 | 1076 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1077 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
263 | 1078 |
begin |
351 | 1079 |
dec(Gear^.Health); |
1080 |
case Gear^.State of |
|
498 | 1081 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
1082 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
285 | 1083 |
end; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1084 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
263 | 1085 |
end; |
498 | 1086 |
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1087 |
end; |
1088 |
||
1089 |
procedure doStepAirAttack(Gear: PGear); |
|
1090 |
begin |
|
1091 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1092 |
|
408 | 1093 |
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 |
1094 |
else Gear^.Tag:= -1; |
|
498 | 1095 |
Gear^.X:= _1024 - _2048 * Gear^.Tag; |
1096 |
Gear^.Y:= -_128; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1097 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1098 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1099 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
498 | 1100 |
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
|
1101 |
addfilelog('attack: x = '+floattostr(gear^.dx)); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1102 |
|
351 | 1103 |
Gear^.Health:= 6; |
1104 |
Gear^.doStep:= @doStepAirAttackWork |
|
263 | 1105 |
end; |
1106 |
||
1107 |
//////////////////////////////////////////////////////////////////////////////// |
|
1108 |
||
1109 |
procedure doStepAirBomb(Gear: PGear); |
|
1110 |
begin |
|
1111 |
AllInactive:= false; |
|
1112 |
doStepFallingGear(Gear); |
|
351 | 1113 |
if (Gear^.State and gstCollision) <> 0 then |
263 | 1114 |
begin |
351 | 1115 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
263 | 1116 |
DeleteGear(Gear); |
1117 |
exit |
|
1118 |
end; |
|
1119 |
if (GameTicks and $3F) = 0 then |
|
498 | 1120 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1121 |
end; |
409 | 1122 |
|
1123 |
//////////////////////////////////////////////////////////////////////////////// |
|
1124 |
||
1125 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1126 |
var HHGear: PGear; |
409 | 1127 |
begin |
1128 |
AllInactive:= false; |
|
415 | 1129 |
|
1130 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1131 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1132 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1133 |
sprAmGirder, Gear^.State, true) then |
409 | 1134 |
begin |
415 | 1135 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
1136 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1137 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1138 |
DeleteGear(Gear); |
|
1139 |
isCursorVisible:= true |
|
409 | 1140 |
end |
415 | 1141 |
else begin |
1142 |
DeleteGear(Gear); |
|
1143 |
AfterAttack |
|
1144 |
end; |
|
1145 |
TargetPoint.X:= NoPointX |
|
409 | 1146 |
end; |
520 | 1147 |
|
1148 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1149 |
procedure doStepTeleportAfter(Gear: PGear); |
1150 |
var HHGear: PGear; |
|
1151 |
begin |
|
1152 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1153 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
1154 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1155 |
if TestCollisionYwithGear(HHGear, 1) then |
|
1156 |
begin |
|
1157 |
DeleteGear(Gear); |
|
1158 |
AfterAttack |
|
1159 |
end |
|
1160 |
end; |
|
520 | 1161 |
|
1162 |
procedure doStepTeleport(Gear: PGear); |
|
1163 |
var HHGear: PGear; |
|
1164 |
begin |
|
1165 |
AllInactive:= false; |
|
1166 |
||
1167 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1168 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1169 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1170 |
sprHHTelepMask, 0, false) then |
|
1171 |
begin |
|
1172 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1173 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1174 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1175 |
DeleteGear(Gear); |
|
1176 |
isCursorVisible:= true |
|
1177 |
end |
|
1178 |
else begin |
|
1179 |
DeleteCI(HHGear); |
|
525 | 1180 |
Gear^.doStep:= @doStepTeleportAfter; |
520 | 1181 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
1182 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
542 | 1183 |
HHGear^.State:= HHGear^.State or gstMoving |
520 | 1184 |
end; |
1185 |
TargetPoint.X:= NoPointX |
|
1186 |
end; |
|
534 | 1187 |
|
1188 |
//////////////////////////////////////////////////////////////////////////////// |
|
1189 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1190 |
var HHGear: PGear; |
|
1191 |
th: LongInt; |
|
1192 |
Msg, State: Longword; |
|
1193 |
begin |
|
1194 |
AllInactive:= false; |
|
1195 |
||
540 | 1196 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
534 | 1197 |
begin |
1198 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1199 |
Msg:= Gear^.Message and not gm_Switch; |
|
1200 |
DeleteGear(Gear); |
|
538 | 1201 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
1202 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1203 |
|
1204 |
HHGear:= CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear; |
|
538 | 1205 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
534 | 1206 |
HHGear^.Message:= Msg; |
1207 |
exit |
|
1208 |
end; |
|
1209 |
||
1210 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1211 |
begin |
|
1212 |
HHGear:= CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear; |
|
1213 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
|
1214 |
State:= HHGear^.State; |
|
1215 |
HHGear^.State:= 0; |
|
1216 |
HHGear^.Active:= false; |
|
1217 |
HHGear^.Z:= cHHZ; |
|
1218 |
RemoveGearFromList(HHGear); |
|
1219 |
InsertGearToList(HHGear); |
|
1220 |
||
1221 |
th:= CurrentTeam^.CurrHedgehog; |
|
1222 |
repeat |
|
551 | 1223 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
1224 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
|
534 | 1225 |
|
1226 |
HHGear:= CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear; |
|
1227 |
HHGear^.State:= State; |
|
1228 |
HHGear^.Active:= true; |
|
1229 |
FollowGear:= HHGear; |
|
1230 |
HHGear^.Z:= cCurrHHZ; |
|
1231 |
RemoveGearFromList(HHGear); |
|
1232 |
InsertGearToList(HHGear); |
|
1233 |
Gear^.X:= HHGear^.X; |
|
1234 |
Gear^.Y:= HHGear^.Y |
|
1235 |
end; |
|
1236 |
end; |
|
1237 |
||
1238 |
procedure doStepSwitcher(Gear: PGear); |
|
1239 |
var HHGear: PGear; |
|
1240 |
begin |
|
1241 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1242 |
||
1243 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1244 |
with HHGear^ do |
|
1245 |
begin |
|
1246 |
State:= State and not gstAttacking; |
|
1247 |
Message:= Message and not gm_Attack |
|
1248 |
end |
|
1249 |
end; |