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