author | unc0rr |
Tue, 22 Apr 2008 12:40:43 +0000 | |
changeset 856 | beecc5c5c71c |
parent 854 | fef7f2d908bf |
child 876 | d5b6e0ae5755 |
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; |
|
845 | 401 |
|
422 | 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 |
820
a26537586400
Fix fall without damage trick, which could be performed with not attached rope
unc0rr
parents:
819
diff
changeset
|
680 |
CheckHHDamage(HHGear); |
498 | 681 |
HHGear^.dY:= _0; |
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 |
//////////////////////////////////////////////////////////////////////////////// |
854 | 938 |
procedure doStepIdle(Gear: PGear); |
939 |
begin |
|
940 |
AllInactive:= false; |
|
941 |
dec(Gear^.Timer);addfilelog(inttostr(Gear^.Timer)); |
|
942 |
if Gear^.Timer = 0 then |
|
943 |
begin |
|
944 |
DeleteGear(Gear); |
|
945 |
AfterAttack |
|
946 |
end |
|
947 |
end; |
|
948 |
||
79 | 949 |
procedure doStepShover(Gear: PGear); |
950 |
var HHGear: PGear; |
|
951 |
begin |
|
351 | 952 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
953 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
79 | 954 |
AmmoShove(Gear, 30, 115); |
351 | 955 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
854 | 956 |
Gear^.Timer:= 250; |
957 |
Gear^.doStep:= @doStepIdle |
|
79 | 958 |
end; |
959 |
||
960 |
//////////////////////////////////////////////////////////////////////////////// |
|
961 |
procedure doStepFlame(Gear: PGear); |
|
962 |
begin |
|
963 |
AllInactive:= false; |
|
964 |
if not TestCollisionYwithGear(Gear, 1) then |
|
965 |
begin |
|
351 | 966 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
967 |
Gear^.dY:= Gear^.dY + cGravity; |
|
968 |
if hwAbs(Gear^.dX) > _0_1 then Gear^.dX:= Gear^.dX * _0_5; |
|
969 |
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; |
|
970 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
971 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 972 |
if not (Gear^.Y < _1024) then |
79 | 973 |
begin |
974 |
DeleteGear(Gear); |
|
975 |
exit |
|
976 |
end |
|
977 |
end else begin |
|
351 | 978 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
79 | 979 |
else begin |
506 | 980 |
// doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 2, 0); |
351 | 981 |
dec(Gear^.Health); |
982 |
Gear^.Timer:= 1250 - Gear^.Angle * 12 |
|
79 | 983 |
end |
984 |
end; |
|
985 |
||
351 | 986 |
if (((GameTicks div 8) mod 64) = Gear^.Angle) then |
79 | 987 |
AmmoFlameWork(Gear); |
988 |
||
351 | 989 |
if Gear^.Health = 0 then |
79 | 990 |
DeleteGear(Gear) |
991 |
end; |
|
82 | 992 |
|
993 |
//////////////////////////////////////////////////////////////////////////////// |
|
994 |
procedure doStepFirePunchWork(Gear: PGear); |
|
995 |
var HHGear: PGear; |
|
996 |
begin |
|
997 |
AllInactive:= false; |
|
351 | 998 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
82 | 999 |
begin |
1000 |
DeleteGear(Gear); |
|
1001 |
AfterAttack; |
|
1002 |
exit |
|
1003 |
end; |
|
1004 |
||
351 | 1005 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1006 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
82 | 1007 |
begin |
351 | 1008 |
Gear^.Tag:= hwRound(HHGear^.Y); |
498 | 1009 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
351 | 1010 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
1011 |
Gear^.Y:= HHGear^.Y; |
|
82 | 1012 |
AmmoShove(Gear, 30, 40); |
351 | 1013 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
82 | 1014 |
end; |
351 | 1015 |
|
1016 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1017 |
if not (HHGear^.dY.isNegative) then |
|
82 | 1018 |
begin |
542 | 1019 |
HHGear^.State:= HHGear^.State or gstMoving; |
82 | 1020 |
DeleteGear(Gear); |
1021 |
AfterAttack; |
|
1022 |
exit |
|
1023 |
end; |
|
351 | 1024 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1025 |
end; |
1026 |
||
1027 |
procedure doStepFirePunch(Gear: PGear); |
|
1028 |
var HHGear: PGear; |
|
1029 |
begin |
|
1030 |
AllInactive:= false; |
|
351 | 1031 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1032 |
DeleteCI(HHGear); |
498 | 1033 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
351 | 1034 |
SetLittle(HHGear^.dX); |
1035 |
HHGear^.dY:= - _0_3; |
|
82 | 1036 |
|
351 | 1037 |
Gear^.X:= HHGear^.X; |
498 | 1038 |
Gear^.dX:= SignAs(_0_45, HHGear^.dX); |
351 | 1039 |
Gear^.dY:= - _0_9; |
1040 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1041 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
82 | 1042 |
end; |
1043 |
||
263 | 1044 |
//////////////////////////////////////////////////////////////////////////////// |
1045 |
||
211 | 1046 |
procedure doStepParachute(Gear: PGear); |
1047 |
var HHGear: PGear; |
|
817 | 1048 |
Timer: Longword; |
211 | 1049 |
begin |
351 | 1050 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1051 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
517 | 1052 |
DeleteCI(HHGear); |
82 | 1053 |
|
516 | 1054 |
inc(Gear^.Timer); |
1055 |
||
212 | 1056 |
if TestCollisionYwithGear(HHGear, 1) |
351 | 1057 |
or ((HHGear^.State and gstHHDriven) = 0) |
212 | 1058 |
or CheckGearDrowning(HHGear) then |
211 | 1059 |
begin |
1060 |
with HHGear^ do |
|
1061 |
begin |
|
1062 |
Message:= 0; |
|
568 | 1063 |
SetLittle(dX); |
498 | 1064 |
dY:= _0; |
211 | 1065 |
State:= State and not (gstAttacking or gstAttacked); |
542 | 1066 |
State:= State or gstMoving; |
211 | 1067 |
end; |
817 | 1068 |
Timer:= Gear^.Timer; |
211 | 1069 |
DeleteGear(Gear); |
817 | 1070 |
if Timer > 10 then |
516 | 1071 |
begin |
534 | 1072 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
516 | 1073 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) |
1074 |
end; |
|
211 | 1075 |
exit |
1076 |
end; |
|
1077 |
||
351 | 1078 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1079 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
|
211 | 1080 |
|
351 | 1081 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1082 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1083 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1084 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1085 |
|
351 | 1086 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1087 |
Gear^.X:= HHGear^.X; |
1088 |
Gear^.Y:= HHGear^.Y |
|
263 | 1089 |
end; |
211 | 1090 |
|
263 | 1091 |
//////////////////////////////////////////////////////////////////////////////// |
1092 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1093 |
begin |
|
1094 |
AllInactive:= false; |
|
498 | 1095 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1096 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
263 | 1097 |
begin |
351 | 1098 |
dec(Gear^.Health); |
1099 |
case Gear^.State of |
|
498 | 1100 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
1101 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
285 | 1102 |
end; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1103 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
263 | 1104 |
end; |
498 | 1105 |
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1106 |
end; |
1107 |
||
1108 |
procedure doStepAirAttack(Gear: PGear); |
|
1109 |
begin |
|
1110 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1111 |
|
408 | 1112 |
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 |
1113 |
else Gear^.Tag:= -1; |
|
498 | 1114 |
Gear^.X:= _1024 - _2048 * Gear^.Tag; |
1115 |
Gear^.Y:= -_128; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1116 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1117 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1118 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
498 | 1119 |
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
|
1120 |
|
351 | 1121 |
Gear^.Health:= 6; |
801 | 1122 |
Gear^.doStep:= @doStepAirAttackWork; |
1123 |
PlaySound(sndIncoming, false) |
|
263 | 1124 |
end; |
1125 |
||
1126 |
//////////////////////////////////////////////////////////////////////////////// |
|
1127 |
||
1128 |
procedure doStepAirBomb(Gear: PGear); |
|
1129 |
begin |
|
1130 |
AllInactive:= false; |
|
1131 |
doStepFallingGear(Gear); |
|
351 | 1132 |
if (Gear^.State and gstCollision) <> 0 then |
263 | 1133 |
begin |
351 | 1134 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
263 | 1135 |
DeleteGear(Gear); |
1136 |
exit |
|
1137 |
end; |
|
1138 |
if (GameTicks and $3F) = 0 then |
|
498 | 1139 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1140 |
end; |
409 | 1141 |
|
1142 |
//////////////////////////////////////////////////////////////////////////////// |
|
1143 |
||
1144 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1145 |
var HHGear: PGear; |
409 | 1146 |
begin |
1147 |
AllInactive:= false; |
|
415 | 1148 |
|
1149 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1150 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1151 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1152 |
sprAmGirder, Gear^.State, true) then |
409 | 1153 |
begin |
415 | 1154 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
1155 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1156 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1157 |
DeleteGear(Gear); |
|
1158 |
isCursorVisible:= true |
|
409 | 1159 |
end |
415 | 1160 |
else begin |
1161 |
DeleteGear(Gear); |
|
1162 |
AfterAttack |
|
1163 |
end; |
|
1164 |
TargetPoint.X:= NoPointX |
|
409 | 1165 |
end; |
520 | 1166 |
|
1167 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1168 |
procedure doStepTeleportAfter(Gear: PGear); |
1169 |
begin |
|
853 | 1170 |
inc(Gear^.Timer); |
1171 |
if Gear^.Timer = 65 then |
|
1172 |
begin |
|
1173 |
Gear^.Timer:= 0; |
|
1174 |
inc(Gear^.Pos); |
|
1175 |
if Gear^.Pos = 11 then |
|
1176 |
begin |
|
1177 |
DeleteGear(Gear); |
|
1178 |
AfterAttack |
|
1179 |
end |
|
1180 |
end |
|
525 | 1181 |
end; |
520 | 1182 |
|
1183 |
procedure doStepTeleport(Gear: PGear); |
|
1184 |
var HHGear: PGear; |
|
1185 |
begin |
|
1186 |
AllInactive:= false; |
|
1187 |
||
1188 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1189 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1190 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1191 |
sprHHTelepMask, 0, false) then |
|
853 | 1192 |
begin |
1193 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1194 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1195 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1196 |
DeleteGear(Gear); |
|
1197 |
isCursorVisible:= true |
|
1198 |
end |
|
1199 |
else begin |
|
1200 |
DeleteCI(HHGear); |
|
1201 |
SetAllHHToActive; |
|
1202 |
Gear^.doStep:= @doStepTeleportAfter; |
|
1203 |
Gear^.X:= HHGear^.X; |
|
1204 |
Gear^.Y:= HHGear^.Y; |
|
1205 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1206 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1207 |
HHGear^.State:= HHGear^.State or gstMoving |
|
1208 |
end; |
|
520 | 1209 |
TargetPoint.X:= NoPointX |
1210 |
end; |
|
534 | 1211 |
|
1212 |
//////////////////////////////////////////////////////////////////////////////// |
|
1213 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1214 |
var HHGear: PGear; |
|
1215 |
Msg, State: Longword; |
|
1216 |
begin |
|
1217 |
AllInactive:= false; |
|
1218 |
||
540 | 1219 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
534 | 1220 |
begin |
1221 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1222 |
Msg:= Gear^.Message and not gm_Switch; |
|
1223 |
DeleteGear(Gear); |
|
538 | 1224 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
1225 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1226 |
|
602 | 1227 |
HHGear:= CurrentHedgehog^.Gear; |
538 | 1228 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
534 | 1229 |
HHGear^.Message:= Msg; |
1230 |
exit |
|
1231 |
end; |
|
1232 |
||
1233 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1234 |
begin |
|
602 | 1235 |
HHGear:= CurrentHedgehog^.Gear; |
534 | 1236 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
809 | 1237 |
Gear^.Message:= Gear^.Message and not gm_Switch; |
534 | 1238 |
State:= HHGear^.State; |
1239 |
HHGear^.State:= 0; |
|
1240 |
HHGear^.Active:= false; |
|
1241 |
HHGear^.Z:= cHHZ; |
|
1242 |
RemoveGearFromList(HHGear); |
|
1243 |
InsertGearToList(HHGear); |
|
1244 |
||
1245 |
repeat |
|
551 | 1246 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
652 | 1247 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
1248 |
||
1249 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
|
534 | 1250 |
|
602 | 1251 |
HHGear:= CurrentHedgehog^.Gear; |
534 | 1252 |
HHGear^.State:= State; |
1253 |
HHGear^.Active:= true; |
|
1254 |
FollowGear:= HHGear; |
|
1255 |
HHGear^.Z:= cCurrHHZ; |
|
1256 |
RemoveGearFromList(HHGear); |
|
1257 |
InsertGearToList(HHGear); |
|
1258 |
Gear^.X:= HHGear^.X; |
|
1259 |
Gear^.Y:= HHGear^.Y |
|
1260 |
end; |
|
1261 |
end; |
|
1262 |
||
1263 |
procedure doStepSwitcher(Gear: PGear); |
|
1264 |
var HHGear: PGear; |
|
1265 |
begin |
|
1266 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1267 |
||
1268 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1269 |
with HHGear^ do |
|
1270 |
begin |
|
1271 |
State:= State and not gstAttacking; |
|
1272 |
Message:= Message and not gm_Attack |
|
1273 |
end |
|
1274 |
end; |