author | unc0rr |
Sun, 02 Dec 2007 17:29:20 +0000 | |
changeset 626 | a30171dbcd19 |
parent 602 | f7628ebfccde |
child 652 | 4cca0c7de609 |
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; |
602 | 823 |
with CurrentHedgehog^ do |
441 | 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); |
590 | 833 |
if Gear^.Kind = gtCase then |
834 |
begin |
|
835 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
|
836 |
for i:= 0 to 63 do |
|
837 |
AddGear(x, y, gtFlame, 0, _0, _0, 0); |
|
838 |
end; |
|
79 | 839 |
exit |
840 |
end; |
|
841 |
||
351 | 842 |
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
|
843 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
844 |
AllInactive:= false; |
351 | 845 |
Gear^.dY:= Gear^.dY + cGravity; |
846 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 847 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else |
439 | 848 |
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
|
849 |
begin |
351 | 850 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
498 | 851 |
if Gear^.dY > - _0_001 then Gear^.dY:= _0 |
351 | 852 |
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
|
853 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
854 |
CheckGearDrowning(Gear); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
855 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
856 |
|
511 | 857 |
if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
858 |
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
|
859 |
end; |
49 | 860 |
|
861 |
//////////////////////////////////////////////////////////////////////////////// |
|
557 | 862 |
const cSorterWorkTime = 640; |
863 |
var thexchar: array[0..cMaxTeams] of |
|
864 |
record |
|
865 |
dy, ny, dw: LongInt; |
|
49 | 866 |
team: PTeam; |
557 | 867 |
SortFactor: QWord; |
49 | 868 |
end; |
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
869 |
currsorter: PGear = nil; |
49 | 870 |
|
871 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
371 | 872 |
var i: LongInt; |
49 | 873 |
begin |
874 |
AllInactive:= false; |
|
351 | 875 |
dec(Gear^.Timer); |
876 |
if (Gear^.Timer and 15) = 0 then |
|
557 | 877 |
for i:= 0 to Pred(TeamsCount) do |
49 | 878 |
with thexchar[i] do |
557 | 879 |
begin |
49 | 880 |
{$WARNINGS OFF} |
557 | 881 |
team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; |
882 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; |
|
49 | 883 |
{$WARNINGS ON} |
557 | 884 |
end; |
351 | 885 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
143 | 886 |
begin |
887 |
if currsorter = Gear then currsorter:= nil; |
|
49 | 888 |
DeleteGear(Gear) |
143 | 889 |
end |
49 | 890 |
end; |
891 |
||
892 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
547 | 893 |
var i, t: Longword; |
557 | 894 |
b: boolean; |
49 | 895 |
begin |
896 |
AllInactive:= false; |
|
557 | 897 |
|
547 | 898 |
for t:= 0 to Pred(TeamsCount) do |
557 | 899 |
with thexchar[t] do |
49 | 900 |
begin |
557 | 901 |
dy:= TeamsArray[t]^.DrawHealthY; |
902 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
903 |
team:= TeamsArray[t]; |
|
904 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
905 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
906 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
49 | 907 |
end; |
547 | 908 |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
909 |
if TeamsCount > 1 then |
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
910 |
repeat |
557 | 911 |
b:= true; |
912 |
for t:= 0 to TeamsCount - 2 do |
|
913 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
49 | 914 |
begin |
557 | 915 |
thexchar[cMaxTeams]:= thexchar[t]; |
49 | 916 |
thexchar[t]:= thexchar[Succ(t)]; |
557 | 917 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
918 |
b:= false |
|
919 |
end |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
920 |
until b; |
557 | 921 |
|
49 | 922 |
t:= cScreenHeight - 4; |
557 | 923 |
for i:= 0 to Pred(TeamsCount) do |
49 | 924 |
with thexchar[i] do |
925 |
begin |
|
351 | 926 |
dec(t, team^.HealthRect.h + 2); |
557 | 927 |
ny:= t; |
928 |
dy:= dy - ny |
|
49 | 929 |
end; |
547 | 930 |
|
557 | 931 |
Gear^.Timer:= cSorterWorkTime; |
351 | 932 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
143 | 933 |
currsorter:= Gear |
49 | 934 |
end; |
935 |
||
79 | 936 |
//////////////////////////////////////////////////////////////////////////////// |
937 |
procedure doStepShover(Gear: PGear); |
|
938 |
var HHGear: PGear; |
|
939 |
begin |
|
351 | 940 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
941 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
79 | 942 |
AmmoShove(Gear, 30, 115); |
351 | 943 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
79 | 944 |
DeleteGear(Gear) |
945 |
end; |
|
946 |
||
947 |
//////////////////////////////////////////////////////////////////////////////// |
|
948 |
procedure doStepFlame(Gear: PGear); |
|
949 |
begin |
|
950 |
AllInactive:= false; |
|
951 |
if not TestCollisionYwithGear(Gear, 1) then |
|
952 |
begin |
|
351 | 953 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
954 |
Gear^.dY:= Gear^.dY + cGravity; |
|
955 |
if hwAbs(Gear^.dX) > _0_1 then Gear^.dX:= Gear^.dX * _0_5; |
|
956 |
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; |
|
957 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
958 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 959 |
if not (Gear^.Y < _1024) then |
79 | 960 |
begin |
961 |
DeleteGear(Gear); |
|
962 |
exit |
|
963 |
end |
|
964 |
end else begin |
|
351 | 965 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
79 | 966 |
else begin |
506 | 967 |
// doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 2, 0); |
351 | 968 |
dec(Gear^.Health); |
969 |
Gear^.Timer:= 1250 - Gear^.Angle * 12 |
|
79 | 970 |
end |
971 |
end; |
|
972 |
||
351 | 973 |
if (((GameTicks div 8) mod 64) = Gear^.Angle) then |
79 | 974 |
AmmoFlameWork(Gear); |
975 |
||
351 | 976 |
if Gear^.Health = 0 then |
79 | 977 |
DeleteGear(Gear) |
978 |
end; |
|
82 | 979 |
|
980 |
//////////////////////////////////////////////////////////////////////////////// |
|
981 |
procedure doStepFirePunchWork(Gear: PGear); |
|
982 |
var HHGear: PGear; |
|
983 |
begin |
|
984 |
AllInactive:= false; |
|
351 | 985 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
82 | 986 |
begin |
987 |
DeleteGear(Gear); |
|
988 |
AfterAttack; |
|
989 |
exit |
|
990 |
end; |
|
991 |
||
351 | 992 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
993 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
82 | 994 |
begin |
351 | 995 |
Gear^.Tag:= hwRound(HHGear^.Y); |
498 | 996 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
351 | 997 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
998 |
Gear^.Y:= HHGear^.Y; |
|
82 | 999 |
AmmoShove(Gear, 30, 40); |
351 | 1000 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
82 | 1001 |
end; |
351 | 1002 |
|
1003 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1004 |
if not (HHGear^.dY.isNegative) then |
|
82 | 1005 |
begin |
542 | 1006 |
HHGear^.State:= HHGear^.State or gstMoving; |
82 | 1007 |
DeleteGear(Gear); |
1008 |
AfterAttack; |
|
1009 |
exit |
|
1010 |
end; |
|
351 | 1011 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1012 |
end; |
1013 |
||
1014 |
procedure doStepFirePunch(Gear: PGear); |
|
1015 |
var HHGear: PGear; |
|
1016 |
begin |
|
1017 |
AllInactive:= false; |
|
351 | 1018 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1019 |
DeleteCI(HHGear); |
498 | 1020 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
351 | 1021 |
SetLittle(HHGear^.dX); |
1022 |
HHGear^.dY:= - _0_3; |
|
82 | 1023 |
|
351 | 1024 |
Gear^.X:= HHGear^.X; |
498 | 1025 |
Gear^.dX:= SignAs(_0_45, HHGear^.dX); |
351 | 1026 |
Gear^.dY:= - _0_9; |
1027 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1028 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
82 | 1029 |
end; |
1030 |
||
263 | 1031 |
//////////////////////////////////////////////////////////////////////////////// |
1032 |
||
211 | 1033 |
procedure doStepParachute(Gear: PGear); |
1034 |
var HHGear: PGear; |
|
1035 |
begin |
|
351 | 1036 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1037 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
517 | 1038 |
DeleteCI(HHGear); |
82 | 1039 |
|
516 | 1040 |
inc(Gear^.Timer); |
1041 |
||
212 | 1042 |
if TestCollisionYwithGear(HHGear, 1) |
351 | 1043 |
or ((HHGear^.State and gstHHDriven) = 0) |
212 | 1044 |
or CheckGearDrowning(HHGear) then |
211 | 1045 |
begin |
1046 |
with HHGear^ do |
|
1047 |
begin |
|
1048 |
Message:= 0; |
|
568 | 1049 |
SetLittle(dX); |
498 | 1050 |
dY:= _0; |
211 | 1051 |
State:= State and not (gstAttacking or gstAttacked); |
542 | 1052 |
State:= State or gstMoving; |
211 | 1053 |
end; |
1054 |
DeleteGear(Gear); |
|
516 | 1055 |
if Gear^.Timer > 10 then |
1056 |
begin |
|
534 | 1057 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
516 | 1058 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) |
1059 |
end; |
|
211 | 1060 |
exit |
1061 |
end; |
|
1062 |
||
351 | 1063 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1064 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
|
211 | 1065 |
|
351 | 1066 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1067 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1068 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1069 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1070 |
|
351 | 1071 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1072 |
Gear^.X:= HHGear^.X; |
1073 |
Gear^.Y:= HHGear^.Y |
|
263 | 1074 |
end; |
211 | 1075 |
|
263 | 1076 |
//////////////////////////////////////////////////////////////////////////////// |
1077 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1078 |
begin |
|
1079 |
AllInactive:= false; |
|
498 | 1080 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1081 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
263 | 1082 |
begin |
351 | 1083 |
dec(Gear^.Health); |
1084 |
case Gear^.State of |
|
498 | 1085 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
1086 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
285 | 1087 |
end; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1088 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
263 | 1089 |
end; |
498 | 1090 |
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1091 |
end; |
1092 |
||
1093 |
procedure doStepAirAttack(Gear: PGear); |
|
1094 |
begin |
|
1095 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1096 |
|
408 | 1097 |
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 |
1098 |
else Gear^.Tag:= -1; |
|
498 | 1099 |
Gear^.X:= _1024 - _2048 * Gear^.Tag; |
1100 |
Gear^.Y:= -_128; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1101 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1102 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1103 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
498 | 1104 |
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
|
1105 |
addfilelog('attack: x = '+floattostr(gear^.dx)); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1106 |
|
351 | 1107 |
Gear^.Health:= 6; |
1108 |
Gear^.doStep:= @doStepAirAttackWork |
|
263 | 1109 |
end; |
1110 |
||
1111 |
//////////////////////////////////////////////////////////////////////////////// |
|
1112 |
||
1113 |
procedure doStepAirBomb(Gear: PGear); |
|
1114 |
begin |
|
1115 |
AllInactive:= false; |
|
1116 |
doStepFallingGear(Gear); |
|
351 | 1117 |
if (Gear^.State and gstCollision) <> 0 then |
263 | 1118 |
begin |
351 | 1119 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
263 | 1120 |
DeleteGear(Gear); |
1121 |
exit |
|
1122 |
end; |
|
1123 |
if (GameTicks and $3F) = 0 then |
|
498 | 1124 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1125 |
end; |
409 | 1126 |
|
1127 |
//////////////////////////////////////////////////////////////////////////////// |
|
1128 |
||
1129 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1130 |
var HHGear: PGear; |
409 | 1131 |
begin |
1132 |
AllInactive:= false; |
|
415 | 1133 |
|
1134 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1135 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1136 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1137 |
sprAmGirder, Gear^.State, true) then |
409 | 1138 |
begin |
415 | 1139 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
1140 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1141 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1142 |
DeleteGear(Gear); |
|
1143 |
isCursorVisible:= true |
|
409 | 1144 |
end |
415 | 1145 |
else begin |
1146 |
DeleteGear(Gear); |
|
1147 |
AfterAttack |
|
1148 |
end; |
|
1149 |
TargetPoint.X:= NoPointX |
|
409 | 1150 |
end; |
520 | 1151 |
|
1152 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1153 |
procedure doStepTeleportAfter(Gear: PGear); |
1154 |
var HHGear: PGear; |
|
1155 |
begin |
|
1156 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1157 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
1158 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1159 |
if TestCollisionYwithGear(HHGear, 1) then |
|
1160 |
begin |
|
1161 |
DeleteGear(Gear); |
|
1162 |
AfterAttack |
|
1163 |
end |
|
1164 |
end; |
|
520 | 1165 |
|
1166 |
procedure doStepTeleport(Gear: PGear); |
|
1167 |
var HHGear: PGear; |
|
1168 |
begin |
|
1169 |
AllInactive:= false; |
|
1170 |
||
1171 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1172 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1173 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1174 |
sprHHTelepMask, 0, false) then |
|
1175 |
begin |
|
1176 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1177 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1178 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1179 |
DeleteGear(Gear); |
|
1180 |
isCursorVisible:= true |
|
1181 |
end |
|
1182 |
else begin |
|
1183 |
DeleteCI(HHGear); |
|
525 | 1184 |
Gear^.doStep:= @doStepTeleportAfter; |
520 | 1185 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
1186 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
542 | 1187 |
HHGear^.State:= HHGear^.State or gstMoving |
520 | 1188 |
end; |
1189 |
TargetPoint.X:= NoPointX |
|
1190 |
end; |
|
534 | 1191 |
|
1192 |
//////////////////////////////////////////////////////////////////////////////// |
|
1193 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1194 |
var HHGear: PGear; |
|
1195 |
Msg, State: Longword; |
|
1196 |
begin |
|
1197 |
AllInactive:= false; |
|
1198 |
||
540 | 1199 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
534 | 1200 |
begin |
1201 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1202 |
Msg:= Gear^.Message and not gm_Switch; |
|
1203 |
DeleteGear(Gear); |
|
538 | 1204 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
1205 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1206 |
|
602 | 1207 |
HHGear:= CurrentHedgehog^.Gear; |
538 | 1208 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
534 | 1209 |
HHGear^.Message:= Msg; |
1210 |
exit |
|
1211 |
end; |
|
1212 |
||
1213 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1214 |
begin |
|
602 | 1215 |
HHGear:= CurrentHedgehog^.Gear; |
534 | 1216 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
1217 |
State:= HHGear^.State; |
|
1218 |
HHGear^.State:= 0; |
|
1219 |
HHGear^.Active:= false; |
|
1220 |
HHGear^.Z:= cHHZ; |
|
1221 |
RemoveGearFromList(HHGear); |
|
1222 |
InsertGearToList(HHGear); |
|
1223 |
||
1224 |
repeat |
|
551 | 1225 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
602 | 1226 |
until (CurrentHedgehog^.Gear <> nil); |
534 | 1227 |
|
602 | 1228 |
HHGear:= CurrentHedgehog^.Gear; |
534 | 1229 |
HHGear^.State:= State; |
1230 |
HHGear^.Active:= true; |
|
1231 |
FollowGear:= HHGear; |
|
1232 |
HHGear^.Z:= cCurrHHZ; |
|
1233 |
RemoveGearFromList(HHGear); |
|
1234 |
InsertGearToList(HHGear); |
|
1235 |
Gear^.X:= HHGear^.X; |
|
1236 |
Gear^.Y:= HHGear^.Y |
|
1237 |
end; |
|
1238 |
end; |
|
1239 |
||
1240 |
procedure doStepSwitcher(Gear: PGear); |
|
1241 |
var HHGear: PGear; |
|
1242 |
begin |
|
1243 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1244 |
||
1245 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1246 |
with HHGear^ do |
|
1247 |
begin |
|
1248 |
State:= State and not gstAttacking; |
|
1249 |
Message:= Message and not gm_Attack |
|
1250 |
end |
|
1251 |
end; |