author | unc0rr |
Sun, 01 Mar 2009 17:24:25 +0000 | |
changeset 1849 | 2a989e5abda6 |
parent 1830 | b3e9ab82c364 |
child 1861 | 98de5dc5fda7 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
1689 | 3 |
* Copyright (c) 2004-2009 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 |
1133 | 24 |
begin |
25 |
CheckGearDrowning:= true; |
|
26 |
Gear^.State:= gstDrowning; |
|
27 |
Gear^.doStep:= @doStepDrowningGear; |
|
1669 | 28 |
PlaySound(sndSplash, false, nil) |
1133 | 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)) |
1133 | 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 |
1849 | 43 |
if(Gear^.Invulnerable) then exit; |
522 | 44 |
if _0_4 < Gear^.dY then |
1123 | 45 |
begin |
46 |
if _0_6 < Gear^.dY then |
|
1669 | 47 |
PlaySound(sndOw4, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) |
1123 | 48 |
else |
1669 | 49 |
PlaySound(sndOw1, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
1123 | 50 |
|
51 |
dmg:= 1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70); |
|
52 |
inc(Gear^.Damage, dmg); |
|
1505 | 53 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, dmg, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color); |
1123 | 54 |
end |
4 | 55 |
end; |
56 |
||
57 |
//////////////////////////////////////////////////////////////////////////////// |
|
58 |
//////////////////////////////////////////////////////////////////////////////// |
|
59 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
60 |
var dAngle: real; |
4 | 61 |
begin |
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
62 |
dAngle:= (hwAbs(Gear^.dX) + hwAbs(Gear^.dY)).QWordValue / $80000000; |
1133 | 63 |
if not Gear^.dX.isNegative then |
64 |
Gear^.DirAngle:= Gear^.DirAngle + dAngle |
|
65 |
else |
|
66 |
Gear^.DirAngle:= Gear^.DirAngle - dAngle; |
|
67 |
||
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
68 |
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
|
69 |
else if 360 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle - 360 |
4 | 70 |
end; |
71 |
||
72 |
//////////////////////////////////////////////////////////////////////////////// |
|
73 |
procedure doStepDrowningGear(Gear: PGear); |
|
74 |
begin |
|
75 |
AllInactive:= false; |
|
351 | 76 |
Gear^.Y:= Gear^.Y + cDrownSpeed; |
77 |
if hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear) |
|
4 | 78 |
end; |
79 |
||
80 |
//////////////////////////////////////////////////////////////////////////////// |
|
81 |
procedure doStepFallingGear(Gear: PGear); |
|
542 | 82 |
var isFalling: boolean; |
4 | 83 |
begin |
503 | 84 |
Gear^.State:= Gear^.State and not gstCollision; |
85 |
||
86 |
if Gear^.dY.isNegative then |
|
1133 | 87 |
begin |
88 |
isFalling:= true; |
|
89 |
if TestCollisionYwithGear(Gear, -1) then |
|
90 |
begin |
|
91 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
92 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
93 |
Gear^.State:= Gear^.State or gstCollision |
|
94 |
end |
|
95 |
end else |
|
96 |
if TestCollisionYwithGear(Gear, 1) then |
|
97 |
begin |
|
98 |
isFalling:= false; |
|
99 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
100 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
101 |
Gear^.State:= Gear^.State or gstCollision |
|
102 |
end else isFalling:= true; |
|
503 | 103 |
|
351 | 104 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
1133 | 105 |
begin |
106 |
Gear^.dX:= - Gear^.dX * Gear^.Elasticity; |
|
107 |
Gear^.dY:= Gear^.dY * Gear^.Elasticity; |
|
108 |
Gear^.State:= Gear^.State or gstCollision |
|
109 |
end; |
|
503 | 110 |
|
542 | 111 |
if isFalling then Gear^.dY:= Gear^.dY + cGravity; |
503 | 112 |
|
351 | 113 |
Gear^.X:= Gear^.X + Gear^.dX; |
114 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
4 | 115 |
CheckGearDrowning(Gear); |
503 | 116 |
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and |
1133 | 117 |
(not isFalling) then |
118 |
Gear^.State:= Gear^.State and not gstMoving |
|
119 |
else |
|
120 |
Gear^.State:= Gear^.State or gstMoving |
|
4 | 121 |
end; |
122 |
||
123 |
//////////////////////////////////////////////////////////////////////////////// |
|
124 |
procedure doStepBomb(Gear: PGear); |
|
371 | 125 |
var i: LongInt; |
919 | 126 |
dX, dY: hwFloat; |
4 | 127 |
begin |
128 |
AllInactive:= false; |
|
1263 | 129 |
|
4 | 130 |
doStepFallingGear(Gear); |
1263 | 131 |
|
351 | 132 |
dec(Gear^.Timer); |
133 |
if Gear^.Timer = 0 then |
|
1133 | 134 |
begin |
135 |
case Gear^.Kind of |
|
136 |
gtAmmo_Bomb: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1603 | 137 |
gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 40, EXPLAutoSound); |
1133 | 138 |
gtClusterBomb: begin |
139 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
140 |
for i:= 0 to 4 do |
|
141 |
begin |
|
142 |
dX:= rndSign(GetRandom * _0_1); |
|
143 |
dY:= (GetRandom - _3) * _0_08; |
|
1261 | 144 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); |
145 |
end |
|
146 |
end; |
|
147 |
gtWatermelon: begin |
|
148 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
|
149 |
for i:= 0 to 5 do |
|
150 |
begin |
|
151 |
dX:= rndSign(GetRandom * _0_1); |
|
1496 | 152 |
dY:= (GetRandom - _1_5) * _0_3; |
1262 | 153 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMelonPiece, 0, dX, dY, 75)^.DirAngle:= i * 60; |
1133 | 154 |
end |
1263 | 155 |
end; |
1555 | 156 |
gtHellishBomb: begin |
157 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 90, EXPLAutoSound); |
|
158 |
for i:= 0 to 127 do |
|
159 |
begin |
|
160 |
dX:= AngleCos(i * 16) * _0_5 * (GetRandom + _1); |
|
161 |
dY:= AngleSin(i * 16) * _0_5 * (GetRandom + _1); |
|
162 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); |
|
163 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, -dY, 0); |
|
164 |
end |
|
165 |
end; |
|
1133 | 166 |
end; |
167 |
DeleteGear(Gear); |
|
168 |
exit |
|
169 |
end; |
|
1263 | 170 |
|
4 | 171 |
CalcRotationDirAngle(Gear); |
1263 | 172 |
|
173 |
if Gear^.Kind = gtHellishBomb then |
|
1279 | 174 |
begin |
1669 | 175 |
if Gear^.Timer = 3000 then PlaySound(sndHellish, false, nil); |
1279 | 176 |
|
1263 | 177 |
if (GameTicks and $3F) = 0 then |
178 |
if (Gear^.State and gstCollision) = 0 then |
|
179 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0); |
|
1279 | 180 |
end; |
1263 | 181 |
|
1158 | 182 |
if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then |
183 |
if (hwAbs(Gear^.dX) > _0_1) or |
|
184 |
(hwAbs(Gear^.dY) > _0_1) then |
|
1669 | 185 |
PlaySound(sndGrenadeImpact, false, nil) |
4 | 186 |
end; |
187 |
||
1279 | 188 |
procedure doStepWatermelon(Gear: PGear); |
189 |
begin |
|
190 |
AllInactive:= false; |
|
1669 | 191 |
PlaySound(sndMelon, false, nil); |
1279 | 192 |
Gear^.doStep:= @doStepBomb |
193 |
end; |
|
194 |
||
78 | 195 |
procedure doStepCluster(Gear: PGear); |
196 |
begin |
|
197 |
AllInactive:= false; |
|
198 |
doStepFallingGear(Gear); |
|
351 | 199 |
if (Gear^.State and gstCollision) <> 0 then |
1133 | 200 |
begin |
1261 | 201 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Timer, EXPLAutoSound); |
1133 | 202 |
DeleteGear(Gear); |
203 |
exit |
|
204 |
end; |
|
1262 | 205 |
|
206 |
if Gear^.Kind = gtMelonPiece then |
|
207 |
CalcRotationDirAngle(Gear) |
|
208 |
else |
|
209 |
if (GameTicks and $1F) = 0 then |
|
210 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
78 | 211 |
end; |
212 |
||
4 | 213 |
//////////////////////////////////////////////////////////////////////////////// |
214 |
procedure doStepGrenade(Gear: PGear); |
|
215 |
begin |
|
216 |
AllInactive:= false; |
|
351 | 217 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
4 | 218 |
doStepFallingGear(Gear); |
351 | 219 |
if (Gear^.State and gstCollision) <> 0 then |
1133 | 220 |
begin |
221 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
222 |
DeleteGear(Gear); |
|
223 |
exit |
|
224 |
end; |
|
4 | 225 |
if (GameTicks and $3F) = 0 then |
1133 | 226 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
4 | 227 |
end; |
228 |
||
229 |
//////////////////////////////////////////////////////////////////////////////// |
|
95 | 230 |
procedure doStepHealthTagWork(Gear: PGear); |
4 | 231 |
begin |
522 | 232 |
if Gear^.Kind = gtHealthTag then |
1505 | 233 |
AllInactive:= false; |
234 |
||
351 | 235 |
dec(Gear^.Timer); |
522 | 236 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
1505 | 237 |
|
351 | 238 |
if Gear^.Timer = 0 then |
1133 | 239 |
begin |
240 |
if Gear^.Kind = gtHealthTag then |
|
241 |
PHedgehog(Gear^.Hedgehog)^.Gear^.Active:= true; // to let current hh die |
|
242 |
DeleteGear(Gear) |
|
243 |
end |
|
4 | 244 |
end; |
245 |
||
263 | 246 |
procedure doStepHealthTagWorkUnderWater(Gear: PGear); |
247 |
begin |
|
1505 | 248 |
AllInactive:= false; |
1495 | 249 |
|
351 | 250 |
Gear^.Y:= Gear^.Y - _0_08; |
1495 | 251 |
|
498 | 252 |
if hwRound(Gear^.Y) < cWaterLine + 10 then |
1505 | 253 |
DeleteGear(Gear) |
263 | 254 |
end; |
255 |
||
95 | 256 |
procedure doStepHealthTag(Gear: PGear); |
257 |
var s: shortstring; |
|
258 |
begin |
|
1505 | 259 |
AllInactive:= false; |
260 |
Gear^.dY:= -_0_08; |
|
522 | 261 |
|
351 | 262 |
str(Gear^.State, s); |
1505 | 263 |
Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, fnt16); |
264 |
||
265 |
if hwRound(Gear^.Y) < cWaterLine then |
|
266 |
Gear^.doStep:= @doStepHealthTagWork |
|
267 |
else |
|
268 |
Gear^.doStep:= @doStepHealthTagWorkUnderWater; |
|
269 |
||
762 | 270 |
Gear^.Y:= Gear^.Y - int2hwFloat(Gear^.Tex^.h) |
95 | 271 |
end; |
272 |
||
4 | 273 |
//////////////////////////////////////////////////////////////////////////////// |
274 |
procedure doStepGrave(Gear: PGear); |
|
275 |
begin |
|
276 |
AllInactive:= false; |
|
498 | 277 |
if Gear^.dY.isNegative then |
278 |
if TestCollisionY(Gear, -1) then Gear^.dY:= _0; |
|
4 | 279 |
|
351 | 280 |
if not Gear^.dY.isNegative then |
68 | 281 |
if TestCollisionY(Gear, 1) then |
4 | 282 |
begin |
351 | 283 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
284 |
if Gear^.dY > - _1div1024 then |
|
4 | 285 |
begin |
351 | 286 |
Gear^.Active:= false; |
4 | 287 |
exit |
1669 | 288 |
end else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false, nil) |
4 | 289 |
end; |
1505 | 290 |
|
351 | 291 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
4 | 292 |
CheckGearDrowning(Gear); |
351 | 293 |
Gear^.dY:= Gear^.dY + cGravity |
4 | 294 |
end; |
295 |
||
296 |
//////////////////////////////////////////////////////////////////////////////// |
|
297 |
procedure doStepUFOWork(Gear: PGear); |
|
351 | 298 |
var t: hwFloat; |
374 | 299 |
y: LongInt; |
4 | 300 |
begin |
301 |
AllInactive:= false; |
|
351 | 302 |
t:= Distance(Gear^.dX, Gear^.dY); |
303 |
Gear^.dX:= Gear^.Elasticity * (Gear^.dX + _0_000004 * (TargetPoint.X - hwRound(Gear^.X))); |
|
304 |
Gear^.dY:= Gear^.Elasticity * (Gear^.dY + _0_000004 * (TargetPoint.Y - hwRound(Gear^.Y))); |
|
305 |
t:= t / Distance(Gear^.dX, Gear^.dY); |
|
306 |
Gear^.dX:= Gear^.dX * t; |
|
307 |
Gear^.dY:= Gear^.dY * t; |
|
308 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
309 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
374 | 310 |
|
311 |
if (GameTicks and $3F) = 0 then |
|
312 |
begin |
|
313 |
y:= hwRound(Gear^.Y); |
|
314 |
if y + Gear^.Radius < cWaterLine then |
|
498 | 315 |
AddGear(hwRound(Gear^.X), y, gtSmokeTrace, 0, _0, _0, 0); |
374 | 316 |
end; |
317 |
||
4 | 318 |
CheckCollision(Gear); |
351 | 319 |
dec(Gear^.Timer); |
320 |
if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then |
|
4 | 321 |
begin |
560 | 322 |
StopSound(sndUFO); |
351 | 323 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
4 | 324 |
DeleteGear(Gear); |
325 |
end; |
|
326 |
end; |
|
327 |
||
328 |
procedure doStepUFO(Gear: PGear); |
|
329 |
begin |
|
330 |
AllInactive:= false; |
|
351 | 331 |
Gear^.X:= Gear^.X + Gear^.dX; |
332 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
333 |
Gear^.dY:= Gear^.dY + cGravity; |
|
4 | 334 |
CheckCollision(Gear); |
351 | 335 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 336 |
begin |
351 | 337 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
4 | 338 |
DeleteGear(Gear); |
339 |
exit |
|
340 |
end; |
|
351 | 341 |
dec(Gear^.Timer); |
342 |
if Gear^.Timer = 0 then |
|
4 | 343 |
begin |
1669 | 344 |
PlaySound(sndUFO, true, nil); |
351 | 345 |
Gear^.Timer:= 5000; |
346 |
Gear^.doStep:= @doStepUFOWork |
|
4 | 347 |
end; |
348 |
end; |
|
349 |
||
350 |
//////////////////////////////////////////////////////////////////////////////// |
|
876 | 351 |
procedure doStepShotIdle(Gear: PGear); |
352 |
begin |
|
353 |
AllInactive:= false; |
|
354 |
inc(Gear^.Timer); |
|
355 |
if Gear^.Timer > 75 then |
|
356 |
begin |
|
357 |
DeleteGear(Gear); |
|
358 |
AfterAttack |
|
359 |
end |
|
360 |
end; |
|
361 |
||
4 | 362 |
procedure doStepShotgunShot(Gear: PGear); |
363 |
var i: LongWord; |
|
364 |
begin |
|
365 |
AllInactive:= false; |
|
876 | 366 |
|
367 |
if ((Gear^.State and gstAnimation) = 0) then |
|
368 |
begin |
|
369 |
dec(Gear^.Timer); |
|
370 |
if Gear^.Timer = 0 then |
|
371 |
begin |
|
1669 | 372 |
PlaySound(sndShotgunFire, false, nil); |
876 | 373 |
Gear^.State:= Gear^.State or gstAnimation |
374 |
end; |
|
375 |
exit |
|
376 |
end |
|
377 |
else inc(Gear^.Timer); |
|
378 |
||
4 | 379 |
i:= 200; |
380 |
repeat |
|
351 | 381 |
Gear^.X:= Gear^.X + Gear^.dX; |
382 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
4 | 383 |
CheckCollision(Gear); |
351 | 384 |
if (Gear^.State and gstCollision) <> 0 then |
876 | 385 |
begin |
386 |
Gear^.X:= Gear^.X + Gear^.dX * 8; |
|
387 |
Gear^.Y:= Gear^.Y + Gear^.dY * 8; |
|
388 |
ShotgunShot(Gear); |
|
389 |
Gear^.doStep:= @doStepShotIdle; |
|
390 |
exit |
|
391 |
end; |
|
4 | 392 |
dec(i) |
393 |
until i = 0; |
|
1760 | 394 |
if (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then |
876 | 395 |
Gear^.doStep:= @doStepShotIdle |
4 | 396 |
end; |
397 |
||
398 |
//////////////////////////////////////////////////////////////////////////////// |
|
559 | 399 |
procedure doStepDEagleShotWork(Gear: PGear); |
38 | 400 |
var i, x, y: LongWord; |
351 | 401 |
oX, oY: hwFloat; |
38 | 402 |
begin |
403 |
AllInactive:= false; |
|
876 | 404 |
inc(Gear^.Timer); |
37 | 405 |
i:= 80; |
351 | 406 |
oX:= Gear^.X; |
407 |
oY:= Gear^.Y; |
|
37 | 408 |
repeat |
351 | 409 |
Gear^.X:= Gear^.X + Gear^.dX; |
410 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
411 |
x:= hwRound(Gear^.X); |
|
412 |
y:= hwRound(Gear^.Y); |
|
1753 | 413 |
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) |
351 | 414 |
and (Land[y, x] <> 0) then inc(Gear^.Damage); |
519 | 415 |
if Gear^.Damage > 5 then AmmoShove(Gear, 7, 20); |
38 | 416 |
dec(i) |
351 | 417 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
418 |
if Gear^.Damage > 0 then |
|
37 | 419 |
begin |
351 | 420 |
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82 - i, 1); |
421 |
dec(Gear^.Health, Gear^.Damage); |
|
422 |
Gear^.Damage:= 0 |
|
37 | 423 |
end; |
1760 | 424 |
|
425 |
if (Gear^.Health <= 0) |
|
426 |
or (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) |
|
427 |
or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then |
|
876 | 428 |
Gear^.doStep:= @doStepShotIdle |
37 | 429 |
end; |
430 |
||
559 | 431 |
procedure doStepDEagleShot(Gear: PGear); |
432 |
begin |
|
1669 | 433 |
PlaySound(sndGun, false, nil); |
559 | 434 |
Gear^.doStep:= @doStepDEagleShotWork |
435 |
end; |
|
436 |
||
37 | 437 |
//////////////////////////////////////////////////////////////////////////////// |
4 | 438 |
procedure doStepActionTimer(Gear: PGear); |
439 |
begin |
|
351 | 440 |
dec(Gear^.Timer); |
441 |
case Gear^.Kind of |
|
83 | 442 |
gtATStartGame: begin |
4 | 443 |
AllInactive:= false; |
351 | 444 |
if Gear^.Timer = 0 then |
83 | 445 |
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); |
4 | 446 |
end; |
83 | 447 |
gtATSmoothWindCh: begin |
351 | 448 |
if Gear^.Timer = 0 then |
6 | 449 |
begin |
351 | 450 |
if WindBarWidth < Gear^.Tag then inc(WindBarWidth) |
451 |
else if WindBarWidth > Gear^.Tag then dec(WindBarWidth); |
|
452 |
if WindBarWidth <> Gear^.Tag then Gear^.Timer:= 10; |
|
83 | 453 |
end |
454 |
end; |
|
455 |
gtATFinishGame: begin |
|
456 |
AllInactive:= false; |
|
351 | 457 |
if Gear^.Timer = 0 then |
113 | 458 |
begin |
459 |
SendIPC('N'); |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
460 |
SendIPC('q'); |
83 | 461 |
GameState:= gsExit |
113 | 462 |
end |
6 | 463 |
end; |
4 | 464 |
end; |
351 | 465 |
if Gear^.Timer = 0 then DeleteGear(Gear) |
4 | 466 |
end; |
467 |
||
468 |
//////////////////////////////////////////////////////////////////////////////// |
|
469 |
procedure doStepPickHammerWork(Gear: PGear); |
|
371 | 470 |
var i, ei: LongInt; |
4 | 471 |
HHGear: PGear; |
472 |
begin |
|
70 | 473 |
AllInactive:= false; |
351 | 474 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
475 |
dec(Gear^.Timer); |
|
476 |
if (Gear^.Timer = 0)or((Gear^.Message and gm_Destroy) <> 0)or((HHGear^.State and gstHHDriven) = 0) then |
|
1200 | 477 |
begin |
478 |
StopSound(sndPickhammer); |
|
479 |
DeleteGear(Gear); |
|
480 |
AfterAttack; |
|
481 |
exit |
|
482 |
end; |
|
845 | 483 |
|
422 | 484 |
if (Gear^.Timer mod 33) = 0 then |
1200 | 485 |
begin |
486 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
487 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y) + 7, 6, EXPLDontDraw); |
|
488 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
|
489 |
end; |
|
422 | 490 |
|
491 |
if (Gear^.Timer mod 47) = 0 then |
|
1200 | 492 |
begin |
493 |
i:= hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
|
494 |
ei:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
495 |
while i <= ei do |
|
496 |
begin |
|
497 |
DrawExplosion(i, hwRound(Gear^.Y) + 3, 3); |
|
498 |
inc(i, 1) |
|
499 |
end; |
|
500 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
501 |
Gear^.Y:= Gear^.Y + _1_9; |
|
502 |
SetAllHHToActive; |
|
503 |
end; |
|
4 | 504 |
if TestCollisionYwithGear(Gear, 1) then |
1200 | 505 |
begin |
506 |
Gear^.dY:= _0; |
|
507 |
SetLittle(HHGear^.dX); |
|
508 |
HHGear^.dY:= _0; |
|
509 |
end else |
|
510 |
begin |
|
511 |
Gear^.dY:= Gear^.dY + cGravity; |
|
512 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1417 | 513 |
if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer:= 1 |
1200 | 514 |
end; |
4 | 515 |
|
351 | 516 |
Gear^.X:= Gear^.X + HHGear^.dX; |
517 |
HHGear^.X:= Gear^.X; |
|
498 | 518 |
HHGear^.Y:= Gear^.Y - int2hwFloat(cHHRadius); |
4 | 519 |
|
351 | 520 |
if (Gear^.Message and gm_Attack) <> 0 then |
521 |
if (Gear^.State and gsttmpFlag) <> 0 then Gear^.Timer:= 1 else else |
|
522 |
if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
523 |
if ((Gear^.Message and gm_Left) <> 0) then Gear^.dX:= - _0_3 else |
|
524 |
if ((Gear^.Message and gm_Right) <> 0) then Gear^.dX:= _0_3 |
|
498 | 525 |
else Gear^.dX:= _0; |
4 | 526 |
end; |
527 |
||
528 |
procedure doStepPickHammer(Gear: PGear); |
|
371 | 529 |
var i, y: LongInt; |
4 | 530 |
ar: TRangeArray; |
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
531 |
HHGear: PGear; |
4 | 532 |
begin |
533 |
i:= 0; |
|
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
534 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
535 |
|
498 | 536 |
y:= hwRound(Gear^.Y) - cHHRadius * 2; |
351 | 537 |
while y < hwRound(Gear^.Y) do |
4 | 538 |
begin |
371 | 539 |
ar[i].Left := hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
540 |
ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
4 | 541 |
inc(y, 2); |
542 |
inc(i) |
|
543 |
end; |
|
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
544 |
|
498 | 545 |
DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius * 2, 2, Pred(i)); |
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
546 |
Gear^.dY:= HHGear^.dY; |
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
547 |
DeleteCI(HHGear); |
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
548 |
|
1669 | 549 |
PlaySound(sndPickhammer, true, nil); |
4 | 550 |
doStepPickHammerWork(Gear); |
351 | 551 |
Gear^.doStep:= @doStepPickHammerWork |
4 | 552 |
end; |
553 |
||
554 |
//////////////////////////////////////////////////////////////////////////////// |
|
371 | 555 |
var BTPrevAngle, BTSteps: LongInt; |
302 | 556 |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
557 |
procedure doStepBlowTorchWork(Gear: PGear); |
302 | 558 |
var HHGear: PGear; |
1528 | 559 |
b: boolean; |
560 |
prevX: LongInt; |
|
302 | 561 |
begin |
562 |
AllInactive:= false; |
|
351 | 563 |
dec(Gear^.Timer); |
564 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
565 |
|
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
566 |
HedgehogChAngle(HHGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
567 |
|
305 | 568 |
b:= false; |
569 |
||
371 | 570 |
if abs(LongInt(HHGear^.Angle) - BTPrevAngle) > 7 then |
1528 | 571 |
begin |
572 |
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX); |
|
573 |
Gear^.dY:= AngleCos(HHGear^.Angle) * ( - _0_5); |
|
574 |
BTPrevAngle:= HHGear^.Angle; |
|
575 |
b:= true |
|
576 |
end; |
|
577 |
||
578 |
if ((HHGear^.State and gstMoving) <> 0) then |
|
579 |
begin |
|
580 |
doStepHedgehogMoving(HHGear); |
|
1736 | 581 |
if (HHGear^.State and gstHHDriven) = 0 then Gear^.Timer:= 0 |
1528 | 582 |
end; |
305 | 583 |
|
351 | 584 |
if Gear^.Timer mod cHHStepTicks = 0 then |
1528 | 585 |
begin |
586 |
b:= true; |
|
587 |
if Gear^.dX.isNegative then |
|
1547 | 588 |
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Left |
1528 | 589 |
else |
1547 | 590 |
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Right; |
305 | 591 |
|
1528 | 592 |
if ((HHGear^.State and gstMoving) = 0) then |
593 |
begin |
|
594 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
595 |
prevX:= hwRound(HHGear^.X); |
|
596 |
||
597 |
HedgehogStep(HHGear); |
|
598 |
||
599 |
if (prevX = hwRound(HHGear^.X)) then HHGear^.X:= HHGear^.X + SignAs(_1, HHGear^.dX); |
|
600 |
HHGear^.State:= HHGear^.State or gstAttacking |
|
601 |
end; |
|
305 | 602 |
|
1528 | 603 |
inc(BTSteps); |
604 |
if BTSteps = 7 then |
|
605 |
begin |
|
606 |
BTSteps:= 0; |
|
607 |
Gear^.X:= HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); |
|
608 |
Gear^.Y:= HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); |
|
609 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1643 | 610 |
AmmoShove(Gear, 2, 15); |
1528 | 611 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
612 |
end; |
|
613 |
end; |
|
305 | 614 |
|
615 |
if b then |
|
498 | 616 |
DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - _4 - Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, |
351 | 617 |
Gear^.dX, Gear^.dY, |
1501 | 618 |
cHHRadius * 5, cHHRadius * 2 + 7); |
305 | 619 |
|
1784 | 620 |
if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) or (Land[hwRound(HHGear^.Y), hwRound(HHGear^.X + Gear^.dX * 32)] = COLOR_INDESTRUCTIBLE) then |
1528 | 621 |
begin |
622 |
HHGear^.Message:= 0; |
|
623 |
HHGear^.State:= HHGear^.State and (not gstNotKickable); |
|
624 |
DeleteGear(Gear); |
|
625 |
AfterAttack |
|
626 |
end |
|
302 | 627 |
end; |
628 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
629 |
procedure doStepBlowTorch(Gear: PGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
630 |
var HHGear: PGear; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
631 |
begin |
371 | 632 |
BTPrevAngle:= High(LongInt); |
305 | 633 |
BTSteps:= 0; |
351 | 634 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
635 |
HHGear^.Message:= 0; |
|
1528 | 636 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
351 | 637 |
Gear^.doStep:= @doStepBlowTorchWork |
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
638 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
639 |
|
302 | 640 |
//////////////////////////////////////////////////////////////////////////////// |
641 |
||
1781 | 642 |
procedure doStepRope(Gear: PGear); forward; |
643 |
||
644 |
procedure doStepRopeAfterAttack(Gear: PGear); |
|
645 |
var HHGear: PGear; |
|
646 |
begin |
|
647 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
648 |
if ((HHGear^.State and gstHHDriven) = 0) |
|
649 |
or (CheckGearDrowning(HHGear)) |
|
650 |
or TestCollisionYwithGear(HHGear, 1) then |
|
651 |
begin |
|
652 |
DeleteGear(Gear); |
|
653 |
exit |
|
654 |
end; |
|
655 |
||
1785 | 656 |
HedgehogChAngle(HHGear); |
657 |
||
1781 | 658 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
659 |
if HHGear^.dY.isNegative and TestCollisionYwithGear(HHGear, -1) then HHGear^.dY:= _0; |
|
660 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
661 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
662 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
663 |
||
664 |
if (Gear^.Message and gm_Attack) <> 0 then |
|
665 |
begin |
|
666 |
Gear^.X:= HHGear^.X; |
|
667 |
Gear^.Y:= HHGear^.Y; |
|
668 |
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX); |
|
669 |
Gear^.dY:= -AngleCos(HHGear^.Angle); |
|
670 |
Gear^.Friction:= _450; |
|
671 |
Gear^.Elasticity:= _0; |
|
672 |
Gear^.State:= Gear^.State and not gsttmpflag; |
|
673 |
Gear^.doStep:= @doStepRope |
|
674 |
end |
|
675 |
end; |
|
676 |
||
4 | 677 |
procedure doStepRopeWork(Gear: PGear); |
678 |
var HHGear: PGear; |
|
1669 | 679 |
len, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY: hwFloat; |
1504 | 680 |
lx, ly: LongInt; |
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
681 |
haveCollision, |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
682 |
haveDivided: boolean; |
4 | 683 |
|
1504 | 684 |
procedure DeleteMe; |
685 |
begin |
|
686 |
with HHGear^ do |
|
687 |
begin |
|
688 |
Message:= Message and not gm_Attack; |
|
689 |
State:= State or gstMoving; |
|
690 |
end; |
|
691 |
DeleteGear(Gear) |
|
692 |
end; |
|
4 | 693 |
|
1781 | 694 |
procedure WaitCollision; |
695 |
begin |
|
696 |
with HHGear^ do |
|
697 |
begin |
|
698 |
Message:= Message and not gm_Attack; |
|
699 |
State:= State or gstMoving; |
|
700 |
end; |
|
701 |
RopePoints.Count:= 0; |
|
702 |
Gear^.Elasticity:= _0; |
|
703 |
Gear^.doStep:= @doStepRopeAfterAttack |
|
704 |
end; |
|
705 |
||
4 | 706 |
begin |
351 | 707 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
108 | 708 |
|
351 | 709 |
if ((HHGear^.State and gstHHDriven) = 0) |
1504 | 710 |
or (CheckGearDrowning(HHGear)) then |
711 |
begin |
|
712 |
DeleteMe; |
|
713 |
exit |
|
714 |
end; |
|
928
b9064b48b001
Some preparation work for attacking from rope, parachute and etc.
unc0rr
parents:
925
diff
changeset
|
715 |
|
351 | 716 |
if (Gear^.Message and gm_Left <> 0) then HHGear^.dX:= HHGear^.dX - _0_0002 else |
717 |
if (Gear^.Message and gm_Right <> 0) then HHGear^.dX:= HHGear^.dX + _0_0002; |
|
4 | 718 |
|
351 | 719 |
if not TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= HHGear^.dY + cGravity; |
4 | 720 |
|
1652 | 721 |
ropeDx:= HHGear^.X - Gear^.X; // vector between hedgehog and rope attaching point |
722 |
ropeDy:= HHGear^.Y - Gear^.Y; |
|
723 |
||
724 |
mdX:= ropeDx + HHGear^.dX; |
|
725 |
mdY:= ropeDy + HHGear^.dY; |
|
726 |
len:= _1 / Distance(mdX, mdY); |
|
727 |
mdX:= mdX * len; // rope vector plus hedgehog direction vector normalized |
|
728 |
mdY:= mdY * len; |
|
729 |
||
730 |
Gear^.dX:= mdX; // for visual purposes only |
|
731 |
Gear^.dY:= mdY; |
|
732 |
||
733 |
///// |
|
734 |
tx:= HHGear^.X; |
|
735 |
ty:= HHGear^.Y; |
|
4 | 736 |
|
1652 | 737 |
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then |
738 |
if not (TestCollisionXwithGear(HHGear, hwSign(ropeDx)) |
|
739 |
or TestCollisionYwithGear(HHGear, hwSign(ropeDy))) then |
|
740 |
Gear^.Elasticity:= Gear^.Elasticity + _0_3; |
|
741 |
||
742 |
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then |
|
743 |
if not (TestCollisionXwithGear(HHGear, -hwSign(ropeDx)) |
|
744 |
or TestCollisionYwithGear(HHGear, -hwSign(ropeDy))) then |
|
745 |
Gear^.Elasticity:= Gear^.Elasticity - _0_3; |
|
746 |
||
747 |
HHGear^.X:= Gear^.X + mdX * Gear^.Elasticity; |
|
748 |
HHGear^.Y:= Gear^.Y + mdY * Gear^.Elasticity; |
|
749 |
||
750 |
HHGear^.dX:= HHGear^.X - tx; |
|
751 |
HHGear^.dY:= HHGear^.Y - ty; |
|
752 |
//// |
|
753 |
||
1554 | 754 |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
755 |
haveDivided:= false; |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
756 |
// check whether rope needs dividing |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
757 |
len:= _1 / Distance(ropeDx, ropeDy); // old rope pos |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
758 |
nx:= ropeDx * len; |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
759 |
ny:= ropeDy * len; |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
760 |
|
1652 | 761 |
len:= Gear^.Elasticity - _0_3x70; |
762 |
while len > _0_3 do |
|
1504 | 763 |
begin |
1652 | 764 |
lx:= hwRound(Gear^.X + mdX * len); |
765 |
ly:= hwRound(Gear^.Y + mdY * len); |
|
1753 | 766 |
if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (Land[ly, lx] <> 0) then |
1504 | 767 |
begin |
768 |
with RopePoints.ar[RopePoints.Count] do |
|
769 |
begin |
|
770 |
X:= Gear^.X; |
|
771 |
Y:= Gear^.Y; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
772 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); |
1652 | 773 |
b:= (nx * HHGear^.dY) > (ny * HHGear^.dX); |
1504 | 774 |
dLen:= len |
775 |
end; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
776 |
Gear^.X:= Gear^.X + nx * len; |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
777 |
Gear^.Y:= Gear^.Y + ny * len; |
1504 | 778 |
inc(RopePoints.Count); |
779 |
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); |
|
780 |
Gear^.Elasticity:= Gear^.Elasticity - len; |
|
781 |
Gear^.Friction:= Gear^.Friction - len; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
782 |
haveDivided:= true; |
1504 | 783 |
break |
784 |
end; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
785 |
len:= len - _0_3 // should be the same as increase step |
1504 | 786 |
end; |
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
787 |
|
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
788 |
if not haveDivided then |
1504 | 789 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
790 |
begin |
|
791 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
792 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
793 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then |
|
794 |
begin |
|
795 |
dec(RopePoints.Count); |
|
1652 | 796 |
Gear^.X:= RopePoints.ar[RopePoints.Count].X; |
797 |
Gear^.Y:= RopePoints.ar[RopePoints.Count].Y; |
|
1504 | 798 |
Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
799 |
Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
800 |
end |
|
801 |
end; |
|
4 | 802 |
|
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
803 |
haveCollision:= false; |
351 | 804 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
805 |
begin |
1504 | 806 |
HHGear^.dX:= -_0_6 * HHGear^.dX; |
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
807 |
haveCollision:= true |
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
808 |
end; |
351 | 809 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then |
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
810 |
begin |
1504 | 811 |
HHGear^.dY:= -_0_6 * HHGear^.dY; |
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
812 |
haveCollision:= true |
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
813 |
end; |
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
814 |
|
1579
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset
|
815 |
if haveCollision |
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset
|
816 |
and (Gear^.Message and (gm_Left or gm_Right) <> 0) |
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset
|
817 |
and (Gear^.Message and (gm_Up or gm_Down) <> 0) then |
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
818 |
begin |
1579
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset
|
819 |
HHGear^.dX:= SignAs(hwAbs(HHGear^.dX) + _0_2, HHGear^.dX); |
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset
|
820 |
HHGear^.dY:= SignAs(hwAbs(HHGear^.dY) + _0_2, HHGear^.dY) |
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
821 |
end; |
4 | 822 |
|
789 | 823 |
len:= Distance(HHGear^.dX, HHGear^.dY); |
940 | 824 |
if len > _0_8 then |
1504 | 825 |
begin |
826 |
len:= _0_8 / len; |
|
827 |
HHGear^.dX:= HHGear^.dX * len; |
|
828 |
HHGear^.dY:= HHGear^.dY * len; |
|
829 |
end; |
|
789 | 830 |
|
351 | 831 |
if (Gear^.Message and gm_Attack) <> 0 then |
1504 | 832 |
if (Gear^.State and gsttmpFlag) <> 0 then |
1781 | 833 |
WaitCollision |
1504 | 834 |
else |
835 |
else |
|
836 |
if (Gear^.State and gsttmpFlag) = 0 then |
|
837 |
Gear^.State:= Gear^.State or gsttmpFlag; |
|
4 | 838 |
end; |
839 |
||
840 |
procedure doStepRopeAttach(Gear: PGear); |
|
841 |
var HHGear: PGear; |
|
1781 | 842 |
tx, ty, tt: hwFloat; |
843 |
||
844 |
procedure RemoveFromAmmo; |
|
845 |
begin |
|
846 |
if (Gear^.State and gstAttacked) = 0 then |
|
847 |
begin |
|
848 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
|
849 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
850 |
Gear^.State:= Gear^.State or gstAttacked |
|
851 |
end |
|
852 |
end; |
|
853 |
||
4 | 854 |
begin |
351 | 855 |
Gear^.X:= Gear^.X - Gear^.dX; |
856 |
Gear^.Y:= Gear^.Y - Gear^.dY; |
|
498 | 857 |
Gear^.Elasticity:= Gear^.Elasticity + _1; |
351 | 858 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
517 | 859 |
DeleteCI(HHGear); |
542 | 860 |
if (HHGear^.State and gstMoving) <> 0 then |
1433 | 861 |
if TestCollisionYwithGear(HHGear, 1) then |
862 |
begin |
|
863 |
CheckHHDamage(HHGear); |
|
864 |
HHGear^.dY:= _0; |
|
865 |
HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); |
|
866 |
end else |
|
867 |
begin |
|
868 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
|
869 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
870 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
871 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
872 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
873 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
874 |
tt:= Gear^.Elasticity; |
|
875 |
tx:= _0; |
|
876 |
ty:= _0; |
|
877 |
while tt > _20 do |
|
878 |
begin |
|
879 |
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) |
|
880 |
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then |
|
881 |
begin |
|
882 |
Gear^.X:= Gear^.X + tx; |
|
883 |
Gear^.Y:= Gear^.Y + ty; |
|
884 |
Gear^.Elasticity:= tt; |
|
885 |
Gear^.doStep:= @doStepRopeWork; |
|
1752
769986d39202
Fix accidental rope removinf from ammo in some cases
unc0rr
parents:
1736
diff
changeset
|
886 |
with HHGear^ do State:= State and not (gstAttacking or gstMoving or gstHHHJump); |
1781 | 887 |
|
888 |
RemoveFromAmmo; |
|
889 |
||
1752
769986d39202
Fix accidental rope removinf from ammo in some cases
unc0rr
parents:
1736
diff
changeset
|
890 |
tt:= _0; |
769986d39202
Fix accidental rope removinf from ammo in some cases
unc0rr
parents:
1736
diff
changeset
|
891 |
exit |
1433 | 892 |
end; |
893 |
tx:= tx + Gear^.dX + Gear^.dX; |
|
894 |
ty:= ty + Gear^.dY + Gear^.dY; |
|
895 |
tt:= tt - _2; |
|
896 |
end; |
|
897 |
end; |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
898 |
|
4 | 899 |
CheckCollision(Gear); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
900 |
|
351 | 901 |
if (Gear^.State and gstCollision) <> 0 then |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
902 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
903 |
Gear^.doStep:= @doStepRopeWork; |
974
fc16141a0128
Prevent wrong aim direction when using rope after high jump
unc0rr
parents:
963
diff
changeset
|
904 |
with HHGear^ do State:= State and not (gstAttacking or gstHHHJump); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
905 |
|
1781 | 906 |
RemoveFromAmmo; |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
907 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
908 |
if Gear^.Elasticity < _10 then |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
909 |
Gear^.Elasticity:= _10000; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
910 |
end; |
4 | 911 |
|
1634
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset
|
912 |
if (Gear^.Elasticity > Gear^.Friction) |
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset
|
913 |
or ((Gear^.Message and gm_Attack) = 0) |
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset
|
914 |
or (HHGear^.Damage > 0) then |
1433 | 915 |
begin |
916 |
with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
|
917 |
begin |
|
918 |
State:= State and not gstAttacking; |
|
919 |
Message:= Message and not gm_Attack |
|
920 |
end; |
|
921 |
DeleteGear(Gear) |
|
922 |
end |
|
4 | 923 |
end; |
924 |
||
925 |
procedure doStepRope(Gear: PGear); |
|
926 |
begin |
|
351 | 927 |
Gear^.dX:= - Gear^.dX; |
928 |
Gear^.dY:= - Gear^.dY; |
|
929 |
Gear^.doStep:= @doStepRopeAttach |
|
4 | 930 |
end; |
931 |
||
932 |
//////////////////////////////////////////////////////////////////////////////// |
|
933 |
procedure doStepSmokeTrace(Gear: PGear); |
|
934 |
begin |
|
351 | 935 |
inc(Gear^.Timer); |
936 |
if Gear^.Timer > 64 then |
|
1133 | 937 |
begin |
938 |
Gear^.Timer:= 0; |
|
939 |
dec(Gear^.State) |
|
940 |
end; |
|
351 | 941 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
942 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
943 |
if Gear^.State = 0 then DeleteGear(Gear) |
|
4 | 944 |
end; |
9 | 945 |
|
946 |
//////////////////////////////////////////////////////////////////////////////// |
|
1045 | 947 |
procedure doStepExplosionWork(Gear: PGear); |
9 | 948 |
begin |
351 | 949 |
inc(Gear^.Timer); |
950 |
if Gear^.Timer > 75 then |
|
1133 | 951 |
begin |
952 |
inc(Gear^.State); |
|
953 |
Gear^.Timer:= 0; |
|
954 |
if Gear^.State > 5 then DeleteGear(Gear) |
|
955 |
end; |
|
9 | 956 |
end; |
10 | 957 |
|
1045 | 958 |
procedure doStepExplosion(Gear: PGear); |
959 |
var i: LongWord; |
|
960 |
begin |
|
1047 | 961 |
for i:= 0 to 31 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFire); |
962 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart); |
|
963 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart2); |
|
1045 | 964 |
Gear^.doStep:= @doStepExplosionWork |
965 |
end; |
|
966 |
||
10 | 967 |
//////////////////////////////////////////////////////////////////////////////// |
968 |
procedure doStepMine(Gear: PGear); |
|
969 |
begin |
|
542 | 970 |
if (Gear^.State and gstMoving) <> 0 then |
914 | 971 |
begin |
972 |
DeleteCI(Gear); |
|
973 |
doStepFallingGear(Gear); |
|
974 |
if (Gear^.State and gstMoving) = 0 then |
|
975 |
begin |
|
976 |
AddGearCI(Gear); |
|
977 |
Gear^.dX:= _0; |
|
978 |
Gear^.dY:= _0 |
|
979 |
end; |
|
980 |
CalcRotationDirAngle(Gear); |
|
981 |
AllInactive:= false |
|
982 |
end else |
|
983 |
if ((GameTicks and $3F) = 25) then |
|
984 |
doStepFallingGear(Gear); |
|
351 | 985 |
|
986 |
if ((Gear^.State and gsttmpFlag) <> 0) then |
|
1133 | 987 |
if ((Gear^.State and gstAttacking) = 0) then |
988 |
begin |
|
989 |
if ((GameTicks and $1F) = 0) then |
|
990 |
if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking |
|
991 |
end else // gstAttacking <> 0 |
|
992 |
begin |
|
993 |
AllInactive:= false; |
|
1669 | 994 |
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false, nil); |
1133 | 995 |
if Gear^.Timer = 0 then |
996 |
begin |
|
997 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
998 |
DeleteGear(Gear); |
|
999 |
exit |
|
1000 |
end; |
|
1001 |
dec(Gear^.Timer); |
|
1002 |
end else // gsttmpFlag = 0 |
|
1003 |
if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
10 | 1004 |
end; |
57 | 1005 |
|
39 | 1006 |
//////////////////////////////////////////////////////////////////////////////// |
1007 |
procedure doStepDynamite(Gear: PGear); |
|
1008 |
begin |
|
43 | 1009 |
doStepFallingGear(Gear); |
1010 |
AllInactive:= false; |
|
351 | 1011 |
if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); |
1012 |
if Gear^.Timer = 0 then |
|
1133 | 1013 |
begin |
1014 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
|
1015 |
DeleteGear(Gear); |
|
1016 |
exit |
|
1017 |
end; |
|
351 | 1018 |
dec(Gear^.Timer); |
39 | 1019 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1020 |
|
351 | 1021 |
/////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1022 |
procedure doStepCase(Gear: PGear); |
371 | 1023 |
var i, x, y: LongInt; |
1436 | 1024 |
k: TGearType; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1025 |
begin |
351 | 1026 |
if (Gear^.Message and gm_Destroy) > 0 then |
1133 | 1027 |
begin |
1028 |
DeleteGear(Gear); |
|
1029 |
FreeActionsList; |
|
1030 |
SetAllToActive; // something (hh, mine, etc...) could be on top of the case |
|
1031 |
with CurrentHedgehog^ do |
|
1032 |
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
|
1033 |
exit |
|
1034 |
end; |
|
15 | 1035 |
|
351 | 1036 |
if Gear^.Damage > 0 then |
1133 | 1037 |
begin |
1038 |
x:= hwRound(Gear^.X); |
|
1039 |
y:= hwRound(Gear^.Y); |
|
1436 | 1040 |
k:= Gear^.Kind; |
1041 |
DeleteGear(Gear); // <-- delete gear! |
|
1042 |
||
1043 |
if k = gtCase then |
|
1133 | 1044 |
begin |
1045 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
|
1046 |
for i:= 0 to 63 do |
|
1047 |
AddGear(x, y, gtFlame, 0, _0, _0, 0); |
|
1048 |
end; |
|
1049 |
exit |
|
1050 |
end; |
|
79 | 1051 |
|
351 | 1052 |
if (Gear^.dY.QWordValue <> 0) or (not TestCollisionYwithGear(Gear, 1)) then |
1133 | 1053 |
begin |
1054 |
AllInactive:= false; |
|
1055 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1056 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1057 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else |
|
1058 |
if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then |
|
1059 |
begin |
|
1060 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
1061 |
if Gear^.dY > - _0_001 then Gear^.dY:= _0 |
|
1669 | 1062 |
else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false, nil); |
1133 | 1063 |
end; |
1064 |
CheckGearDrowning(Gear); |
|
1065 |
end; |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1066 |
|
511 | 1067 |
if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
1133 | 1068 |
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
|
1069 |
end; |
49 | 1070 |
|
1071 |
//////////////////////////////////////////////////////////////////////////////// |
|
557 | 1072 |
const cSorterWorkTime = 640; |
1073 |
var thexchar: array[0..cMaxTeams] of |
|
1133 | 1074 |
record |
1075 |
dy, ny, dw: LongInt; |
|
1076 |
team: PTeam; |
|
1077 |
SortFactor: QWord; |
|
1078 |
end; |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
1079 |
currsorter: PGear = nil; |
49 | 1080 |
|
1081 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
371 | 1082 |
var i: LongInt; |
49 | 1083 |
begin |
1084 |
AllInactive:= false; |
|
351 | 1085 |
dec(Gear^.Timer); |
1086 |
if (Gear^.Timer and 15) = 0 then |
|
1133 | 1087 |
for i:= 0 to Pred(TeamsCount) do |
1088 |
with thexchar[i] do |
|
1089 |
begin |
|
1090 |
{$WARNINGS OFF} |
|
1091 |
team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; |
|
1092 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; |
|
1093 |
{$WARNINGS ON} |
|
1094 |
end; |
|
1095 |
||
351 | 1096 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
1133 | 1097 |
begin |
1098 |
if currsorter = Gear then currsorter:= nil; |
|
1099 |
DeleteGear(Gear) |
|
1100 |
end |
|
49 | 1101 |
end; |
1102 |
||
1103 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
1133 | 1104 |
var i: Longword; |
1105 |
b: boolean; |
|
1106 |
t: LongInt; |
|
49 | 1107 |
begin |
1108 |
AllInactive:= false; |
|
557 | 1109 |
|
547 | 1110 |
for t:= 0 to Pred(TeamsCount) do |
1133 | 1111 |
with thexchar[t] do |
1112 |
begin |
|
1113 |
dy:= TeamsArray[t]^.DrawHealthY; |
|
1114 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
1115 |
team:= TeamsArray[t]; |
|
1116 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
1117 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
1118 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
1119 |
end; |
|
547 | 1120 |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
1121 |
if TeamsCount > 1 then |
1133 | 1122 |
repeat |
1123 |
b:= true; |
|
1124 |
for t:= 0 to TeamsCount - 2 do |
|
1125 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
1126 |
begin |
|
1127 |
thexchar[cMaxTeams]:= thexchar[t]; |
|
1128 |
thexchar[t]:= thexchar[Succ(t)]; |
|
1129 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
|
1130 |
b:= false |
|
1131 |
end |
|
1132 |
until b; |
|
557 | 1133 |
|
1120 | 1134 |
t:= - 4; |
557 | 1135 |
for i:= 0 to Pred(TeamsCount) do |
1133 | 1136 |
with thexchar[i] do |
1137 |
begin |
|
1138 |
dec(t, team^.HealthTex^.h + 2); |
|
1139 |
ny:= t; |
|
1140 |
dy:= dy - ny |
|
1141 |
end; |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
1142 |
|
557 | 1143 |
Gear^.Timer:= cSorterWorkTime; |
351 | 1144 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
143 | 1145 |
currsorter:= Gear |
49 | 1146 |
end; |
1147 |
||
79 | 1148 |
//////////////////////////////////////////////////////////////////////////////// |
854 | 1149 |
procedure doStepIdle(Gear: PGear); |
1150 |
begin |
|
1151 |
AllInactive:= false; |
|
925 | 1152 |
dec(Gear^.Timer); |
854 | 1153 |
if Gear^.Timer = 0 then |
1154 |
begin |
|
1155 |
DeleteGear(Gear); |
|
1156 |
AfterAttack |
|
1157 |
end |
|
1158 |
end; |
|
1159 |
||
79 | 1160 |
procedure doStepShover(Gear: PGear); |
1161 |
var HHGear: PGear; |
|
1162 |
begin |
|
351 | 1163 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1164 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1165 |
DeleteCI(HHGear); |
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1166 |
|
79 | 1167 |
AmmoShove(Gear, 30, 115); |
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1168 |
|
351 | 1169 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
854 | 1170 |
Gear^.Timer:= 250; |
1171 |
Gear^.doStep:= @doStepIdle |
|
79 | 1172 |
end; |
1173 |
||
1174 |
//////////////////////////////////////////////////////////////////////////////// |
|
925 | 1175 |
procedure doStepWhip(Gear: PGear); |
1176 |
var HHGear: PGear; |
|
1177 |
i: LongInt; |
|
1178 |
begin |
|
1179 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1180 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1181 |
DeleteCI(HHGear); |
925 | 1182 |
|
1183 |
for i:= 0 to 3 do |
|
1184 |
begin |
|
1185 |
AmmoShove(Gear, 30, 25); |
|
1186 |
Gear^.X:= Gear^.X + Gear^.dX * 5 |
|
1187 |
end; |
|
1188 |
||
1189 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
|
1190 |
Gear^.Timer:= 250; |
|
1191 |
Gear^.doStep:= @doStepIdle |
|
1192 |
end; |
|
1193 |
||
1194 |
//////////////////////////////////////////////////////////////////////////////// |
|
79 | 1195 |
procedure doStepFlame(Gear: PGear); |
1196 |
begin |
|
1197 |
AllInactive:= false; |
|
1433 | 1198 |
|
79 | 1199 |
if not TestCollisionYwithGear(Gear, 1) then |
1133 | 1200 |
begin |
1586 | 1201 |
if hwAbs(Gear^.dX) > _0_01 then |
1202 |
Gear^.dX:= Gear^.dX * _0_995; |
|
1297 | 1203 |
|
1133 | 1204 |
Gear^.dY:= Gear^.dY + cGravity; |
1830 | 1205 |
if hwAbs(Gear^.dY) > _0_2 then Gear^.dY:= Gear^.dY * _0_995; |
1297 | 1206 |
|
1830 | 1207 |
Gear^.X:= Gear^.X + Gear^.dX + cWindSpeed * 640; |
1133 | 1208 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
1297 | 1209 |
|
1417 | 1210 |
if not (hwRound(Gear^.Y) < cWaterLine) then |
1133 | 1211 |
begin |
1212 |
DeleteGear(Gear); |
|
1213 |
exit |
|
1214 |
end |
|
1215 |
end else begin |
|
1216 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
|
1217 |
else begin |
|
1586 | 1218 |
Gear^.Radius:= 9; |
1219 |
AmmoShove(Gear, 4, 100); |
|
1297 | 1220 |
Gear^.Radius:= 1; |
1221 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 4, EXPLNoDamage); |
|
1133 | 1222 |
dec(Gear^.Health); |
1586 | 1223 |
Gear^.Timer:= 450 - Gear^.Tag * 8 |
1133 | 1224 |
end |
1225 |
end; |
|
79 | 1226 |
|
1295 | 1227 |
//if (((GameTicks div 8) mod 64) = Gear^.Tag) then |
1228 |
// AmmoFlameWork(Gear); |
|
79 | 1229 |
|
351 | 1230 |
if Gear^.Health = 0 then |
1133 | 1231 |
DeleteGear(Gear) |
79 | 1232 |
end; |
82 | 1233 |
|
1234 |
//////////////////////////////////////////////////////////////////////////////// |
|
1235 |
procedure doStepFirePunchWork(Gear: PGear); |
|
1236 |
var HHGear: PGear; |
|
1237 |
begin |
|
1238 |
AllInactive:= false; |
|
351 | 1239 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
1133 | 1240 |
begin |
1241 |
DeleteGear(Gear); |
|
1242 |
AfterAttack; |
|
1243 |
exit |
|
1244 |
end; |
|
82 | 1245 |
|
351 | 1246 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1247 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
1133 | 1248 |
begin |
1249 |
Gear^.Tag:= hwRound(HHGear^.Y); |
|
1250 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
|
1251 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1252 |
Gear^.Y:= HHGear^.Y; |
|
1253 |
AmmoShove(Gear, 30, 40); |
|
1254 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
|
1255 |
end; |
|
351 | 1256 |
|
1257 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1258 |
if not (HHGear^.dY.isNegative) then |
|
1133 | 1259 |
begin |
1260 |
HHGear^.State:= HHGear^.State or gstMoving; |
|
1261 |
DeleteGear(Gear); |
|
1262 |
AfterAttack; |
|
1263 |
exit |
|
1264 |
end; |
|
351 | 1265 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1266 |
end; |
1267 |
||
1268 |
procedure doStepFirePunch(Gear: PGear); |
|
1269 |
var HHGear: PGear; |
|
1270 |
begin |
|
1271 |
AllInactive:= false; |
|
351 | 1272 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1273 |
DeleteCI(HHGear); |
498 | 1274 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1275 |
HHGear^.dX:= SignAs(cLittle, Gear^.dX); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1276 |
|
351 | 1277 |
HHGear^.dY:= - _0_3; |
82 | 1278 |
|
351 | 1279 |
Gear^.X:= HHGear^.X; |
979
edb8f208c1d9
Fix firepunch direction when attacking from high jump
unc0rr
parents:
974
diff
changeset
|
1280 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
351 | 1281 |
Gear^.dY:= - _0_9; |
1282 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1283 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
1279 | 1284 |
|
1669 | 1285 |
PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false, PHedgehog(HHGear^.Hedgehog)^.Team^.voicepack) |
82 | 1286 |
end; |
1287 |
||
263 | 1288 |
//////////////////////////////////////////////////////////////////////////////// |
1289 |
||
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1290 |
procedure doStepParachuteWork(Gear: PGear); |
211 | 1291 |
var HHGear: PGear; |
1292 |
begin |
|
351 | 1293 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
82 | 1294 |
|
516 | 1295 |
inc(Gear^.Timer); |
1296 |
||
212 | 1297 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1298 |
or ((HHGear^.State and gstHHDriven) = 0) |
1299 |
or CheckGearDrowning(HHGear) |
|
1300 |
or ((Gear^.Message and gm_Attack) <> 0) then |
|
1301 |
begin |
|
1302 |
with HHGear^ do |
|
1303 |
begin |
|
1304 |
Message:= 0; |
|
1305 |
SetLittle(dX); |
|
1306 |
dY:= _0; |
|
1307 |
State:= State or gstMoving; |
|
1308 |
end; |
|
1309 |
DeleteGear(Gear); |
|
1310 |
exit |
|
1311 |
end; |
|
211 | 1312 |
|
351 | 1313 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1133 | 1314 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
211 | 1315 |
|
351 | 1316 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1317 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1318 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1319 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1320 |
|
351 | 1321 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1322 |
Gear^.X:= HHGear^.X; |
1323 |
Gear^.Y:= HHGear^.Y |
|
263 | 1324 |
end; |
211 | 1325 |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1326 |
procedure doStepParachute(Gear: PGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1327 |
var HHGear: PGear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1328 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1329 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1330 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1331 |
DeleteCI(HHGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1332 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1333 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1334 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1335 |
|
931 | 1336 |
HHGear^.State:= HHGear^.State and not (gstAttacking or gstAttacked or gstMoving); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1337 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1338 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1339 |
Gear^.doStep:= @doStepParachuteWork; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1340 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1341 |
Gear^.Message:= HHGear^.Message; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1342 |
doStepParachuteWork(Gear) |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1343 |
end; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1344 |
|
263 | 1345 |
//////////////////////////////////////////////////////////////////////////////// |
1346 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1507 | 1347 |
var i: Longint; |
263 | 1348 |
begin |
1349 |
AllInactive:= false; |
|
498 | 1350 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
1124 | 1351 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1352 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
1124 | 1353 |
begin |
1354 |
dec(Gear^.Health); |
|
1355 |
case Gear^.State of |
|
1356 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1357 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1586 | 1358 |
2: for i:= -19 to 19 do |
1359 |
FollowGear:= AddGear(hwRound(Gear^.X) + i div 3, hwRound(Gear^.Y), gtFlame, 0, _0_001 * i, _0, 0); |
|
1124 | 1360 |
end; |
1361 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
|
1362 |
end; |
|
1363 |
||
1364 |
if (GameTicks and $3F) = 0 then |
|
1365 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1366 |
||
1753 | 1367 |
if (hwRound(Gear^.X) > (LAND_WIDTH+1024)) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1368 |
end; |
1369 |
||
1370 |
procedure doStepAirAttack(Gear: PGear); |
|
1371 |
begin |
|
1372 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1373 |
|
1507 | 1374 |
if Gear^.X.QWordValue = 0 then |
1771 | 1375 |
begin |
1376 |
Gear^.Tag:= 1; |
|
1377 |
Gear^.X:= -_1024; |
|
1378 |
end |
|
1507 | 1379 |
else |
1771 | 1380 |
begin |
1507 | 1381 |
Gear^.Tag:= -1; |
1771 | 1382 |
Gear^.X:= int2hwFloat(LAND_WIDTH + 1024); |
1383 |
end; |
|
1507 | 1384 |
|
1784 | 1385 |
Gear^.Y:= int2hwFloat(topY-300); |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1386 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1387 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1388 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
1133 | 1389 |
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
|
1390 |
|
351 | 1391 |
Gear^.Health:= 6; |
801 | 1392 |
Gear^.doStep:= @doStepAirAttackWork; |
1669 | 1393 |
PlaySound(sndIncoming, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) |
263 | 1394 |
end; |
1395 |
||
1396 |
//////////////////////////////////////////////////////////////////////////////// |
|
1397 |
||
1398 |
procedure doStepAirBomb(Gear: PGear); |
|
1399 |
begin |
|
1400 |
AllInactive:= false; |
|
1401 |
doStepFallingGear(Gear); |
|
351 | 1402 |
if (Gear^.State and gstCollision) <> 0 then |
1133 | 1403 |
begin |
1404 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1405 |
DeleteGear(Gear); |
|
1406 |
exit |
|
1407 |
end; |
|
263 | 1408 |
if (GameTicks and $3F) = 0 then |
1133 | 1409 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1410 |
end; |
409 | 1411 |
|
1412 |
//////////////////////////////////////////////////////////////////////////////// |
|
1413 |
||
1414 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1415 |
var HHGear: PGear; |
409 | 1416 |
begin |
1417 |
AllInactive:= false; |
|
415 | 1418 |
|
1419 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1420 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1421 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1422 |
sprAmGirder, Gear^.State, true) then |
1133 | 1423 |
begin |
1424 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1425 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1426 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1427 |
DeleteGear(Gear); |
|
1428 |
isCursorVisible:= true |
|
1429 |
end |
|
1430 |
else begin |
|
1431 |
DeleteGear(Gear); |
|
1432 |
AfterAttack |
|
1433 |
end; |
|
415 | 1434 |
TargetPoint.X:= NoPointX |
409 | 1435 |
end; |
520 | 1436 |
|
1437 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1438 |
procedure doStepTeleportAfter(Gear: PGear); |
912 | 1439 |
var HHGear: PGear; |
1440 |
begin |
|
1441 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1442 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases |
|
1443 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1444 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1445 |
or CheckGearDrowning(HHGear) then |
1446 |
begin |
|
1447 |
DeleteGear(Gear); |
|
1448 |
AfterAttack |
|
1449 |
end |
|
912 | 1450 |
end; |
1451 |
||
1452 |
procedure doStepTeleportAnim(Gear: PGear); |
|
525 | 1453 |
begin |
853 | 1454 |
inc(Gear^.Timer); |
1455 |
if Gear^.Timer = 65 then |
|
1456 |
begin |
|
1457 |
Gear^.Timer:= 0; |
|
1458 |
inc(Gear^.Pos); |
|
1459 |
if Gear^.Pos = 11 then |
|
912 | 1460 |
Gear^.doStep:= @doStepTeleportAfter |
853 | 1461 |
end |
525 | 1462 |
end; |
520 | 1463 |
|
1464 |
procedure doStepTeleport(Gear: PGear); |
|
1465 |
var HHGear: PGear; |
|
1466 |
begin |
|
1467 |
AllInactive:= false; |
|
1468 |
||
1469 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1470 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1471 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1472 |
sprHHTelepMask, 0, false) then |
|
853 | 1473 |
begin |
1474 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1475 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1476 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1477 |
DeleteGear(Gear); |
|
1478 |
isCursorVisible:= true |
|
1479 |
end |
|
1480 |
else begin |
|
1481 |
DeleteCI(HHGear); |
|
1482 |
SetAllHHToActive; |
|
912 | 1483 |
Gear^.doStep:= @doStepTeleportAnim; |
853 | 1484 |
Gear^.X:= HHGear^.X; |
1485 |
Gear^.Y:= HHGear^.Y; |
|
1486 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1487 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1488 |
HHGear^.State:= HHGear^.State or gstMoving |
|
1489 |
end; |
|
520 | 1490 |
TargetPoint.X:= NoPointX |
1491 |
end; |
|
534 | 1492 |
|
1493 |
//////////////////////////////////////////////////////////////////////////////// |
|
1494 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1495 |
var HHGear: PGear; |
|
1496 |
Msg, State: Longword; |
|
1497 |
begin |
|
1498 |
AllInactive:= false; |
|
1499 |
||
540 | 1500 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
1133 | 1501 |
begin |
1502 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1503 |
Msg:= Gear^.Message and not gm_Switch; |
|
1504 |
DeleteGear(Gear); |
|
1505 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
|
1506 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1507 |
|
1133 | 1508 |
HHGear:= CurrentHedgehog^.Gear; |
1509 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
1510 |
HHGear^.Message:= Msg; |
|
1511 |
exit |
|
1512 |
end; |
|
534 | 1513 |
|
1514 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1133 | 1515 |
begin |
1516 |
HHGear:= CurrentHedgehog^.Gear; |
|
1517 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
|
1518 |
Gear^.Message:= Gear^.Message and not gm_Switch; |
|
1519 |
State:= HHGear^.State; |
|
1520 |
HHGear^.State:= 0; |
|
1521 |
HHGear^.Active:= false; |
|
1522 |
HHGear^.Z:= cHHZ; |
|
1523 |
RemoveGearFromList(HHGear); |
|
1524 |
InsertGearToList(HHGear); |
|
534 | 1525 |
|
1133 | 1526 |
repeat |
1527 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
|
1528 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
|
652 | 1529 |
|
1133 | 1530 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
534 | 1531 |
|
1133 | 1532 |
HHGear:= CurrentHedgehog^.Gear; |
1533 |
HHGear^.State:= State; |
|
1534 |
HHGear^.Active:= true; |
|
1535 |
FollowGear:= HHGear; |
|
1536 |
HHGear^.Z:= cCurrHHZ; |
|
1537 |
RemoveGearFromList(HHGear); |
|
1538 |
InsertGearToList(HHGear); |
|
1539 |
Gear^.X:= HHGear^.X; |
|
1540 |
Gear^.Y:= HHGear^.Y |
|
1541 |
end; |
|
534 | 1542 |
end; |
1543 |
||
1544 |
procedure doStepSwitcher(Gear: PGear); |
|
1545 |
var HHGear: PGear; |
|
1546 |
begin |
|
1547 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1548 |
||
1549 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1550 |
with HHGear^ do |
|
1133 | 1551 |
begin |
1552 |
State:= State and not gstAttacking; |
|
1553 |
Message:= Message and not gm_Attack |
|
1554 |
end |
|
534 | 1555 |
end; |
924 | 1556 |
|
1557 |
//////////////////////////////////////////////////////////////////////////////// |
|
1558 |
procedure doStepMortar(Gear: PGear); |
|
1559 |
var dX, dY: hwFloat; |
|
1560 |
i: LongInt; |
|
963 | 1561 |
dxn, dyn: boolean; |
924 | 1562 |
begin |
1563 |
AllInactive:= false; |
|
963 | 1564 |
dxn:= Gear^.dX.isNegative; |
1565 |
dyn:= Gear^.dY.isNegative; |
|
1566 |
||
924 | 1567 |
doStepFallingGear(Gear); |
1568 |
if (Gear^.State and gstCollision) <> 0 then |
|
1569 |
begin |
|
1570 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
963 | 1571 |
|
1572 |
Gear^.dX.isNegative:= not dxn; |
|
1573 |
Gear^.dY.isNegative:= not dyn; |
|
924 | 1574 |
for i:= 0 to 4 do |
1575 |
begin |
|
963 | 1576 |
dX:= Gear^.dX + (GetRandom - _0_5) * _0_03; |
1577 |
dY:= Gear^.dY + (GetRandom - _0_5) * _0_03; |
|
1273 | 1578 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); |
924 | 1579 |
end; |
1580 |
||
1581 |
DeleteGear(Gear); |
|
1582 |
exit |
|
1583 |
end; |
|
963 | 1584 |
|
924 | 1585 |
if (GameTicks and $3F) = 0 then |
1586 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
1587 |
end; |
|
984 | 1588 |
|
1589 |
//////////////////////////////////////////////////////////////////////////////// |
|
1590 |
procedure doStepKamikazeWork(Gear: PGear); |
|
1591 |
const upd: Longword = 0; |
|
987 | 1592 |
var i: LongWord; |
984 | 1593 |
HHGear: PGear; |
1594 |
begin |
|
1595 |
AllInactive:= false; |
|
1596 |
||
1597 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1598 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1599 |
DeleteCI(HHGear); |
|
1600 |
||
1601 |
i:= 2; |
|
1602 |
repeat |
|
1603 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
1604 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
1605 |
HHGear^.X:= Gear^.X; |
|
1606 |
HHGear^.Y:= Gear^.Y; |
|
1607 |
||
1608 |
inc(Gear^.Damage, 2); |
|
1609 |
||
1200 | 1610 |
// if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
1611 |
// or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); |
|
984 | 1612 |
|
1613 |
dec(i) |
|
1614 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
|
1615 |
||
1616 |
inc(upd); |
|
1617 |
if upd > 3 then |
|
1618 |
begin |
|
987 | 1619 |
if Gear^.Health < 1500 then Gear^.Pos:= 2; |
1620 |
||
984 | 1621 |
AmmoShove(Gear, 30, 40); |
1622 |
||
1623 |
DrawTunnel(HHGear^.X - HHGear^.dX * 10, |
|
1200 | 1624 |
HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2, |
984 | 1625 |
HHGear^.dX, |
1626 |
HHGear^.dY, |
|
1627 |
20 + cHHRadius * 2, |
|
1200 | 1628 |
cHHRadius * 2 + 6); |
984 | 1629 |
|
1630 |
upd:= 0 |
|
1631 |
end; |
|
1632 |
||
1633 |
if Gear^.Health < Gear^.Damage then |
|
1634 |
begin |
|
1635 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1636 |
AfterAttack; |
|
1637 |
DeleteGear(Gear); |
|
1638 |
DeleteGear(HHGear); |
|
1639 |
end else |
|
1640 |
begin |
|
1641 |
dec(Gear^.Health, Gear^.Damage); |
|
1642 |
Gear^.Damage:= 0 |
|
1643 |
end |
|
1644 |
end; |
|
1645 |
||
987 | 1646 |
procedure doStepKamikazeIdle(Gear: PGear); |
1647 |
begin |
|
1648 |
AllInactive:= false; |
|
1649 |
dec(Gear^.Timer); |
|
1650 |
if Gear^.Timer = 0 then |
|
1651 |
begin |
|
1652 |
Gear^.Pos:= 1; |
|
1669 | 1653 |
PlaySound(sndKamikaze, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
987 | 1654 |
Gear^.doStep:= @doStepKamikazeWork |
1655 |
end |
|
1656 |
end; |
|
1657 |
||
984 | 1658 |
procedure doStepKamikaze(Gear: PGear); |
1659 |
var HHGear: PGear; |
|
1660 |
begin |
|
1661 |
AllInactive:= false; |
|
1662 |
||
1663 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1664 |
||
1665 |
HHGear^.dX:= Gear^.dX; |
|
1666 |
HHGear^.dY:= Gear^.dY; |
|
1667 |
||
1668 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
|
1669 |
Gear^.dY:= - _0_9; |
|
1670 |
||
987 | 1671 |
Gear^.Timer:= 550; |
1672 |
||
1673 |
Gear^.doStep:= @doStepKamikazeIdle |
|
984 | 1674 |
end; |
1675 |
||
1103 | 1676 |
//////////////////////////////////////////////////////////////////////////////// |
1677 |
const cakeh = 27; |
|
1110 | 1678 |
cakeDmg = 75; |
1103 | 1679 |
var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; end; |
1680 |
CakeI: Longword; |
|
1681 |
||
1110 | 1682 |
procedure doStepCakeExpl(Gear: PGear); |
1683 |
begin |
|
1684 |
inc(Gear^.Tag); |
|
1685 |
if Gear^.Tag < 2250 then exit; |
|
1686 |
||
1687 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, EXPLAutoSound); |
|
1688 |
AfterAttack; |
|
1689 |
DeleteGear(Gear) |
|
1690 |
end; |
|
1691 |
||
1109 | 1692 |
procedure doStepCakeDown(Gear: PGear); |
1133 | 1693 |
var gi: PGear; |
1694 |
dmg: LongInt; |
|
1109 | 1695 |
begin |
1696 |
AllInactive:= false; |
|
1697 |
||
1698 |
inc(Gear^.Tag); |
|
1699 |
if Gear^.Tag < 100 then exit; |
|
1700 |
Gear^.Tag:= 0; |
|
1701 |
||
1702 |
if Gear^.Pos = 0 then |
|
1703 |
begin |
|
1110 | 1704 |
gi:= GearsList; |
1705 |
while gi <> nil do |
|
1706 |
begin |
|
1707 |
dmg:= cakeDmg * 2 - hwRound(Distance(gi^.X - Gear^.X, gi^.Y - Gear^.Y)); |
|
1849 | 1708 |
if (dmg > 1) and (gi^.Kind = gtHedgehog) and (not gi^.Invulnerable) then |
1110 | 1709 |
gi^.State:= gi^.State or gstWinner; |
1710 |
gi:= gi^.NextGear |
|
1711 |
end; |
|
1712 |
Gear^.doStep:= @doStepCakeExpl; |
|
1669 | 1713 |
PlaySound(sndCake, false, nil) |
1109 | 1714 |
end else dec(Gear^.Pos) |
1715 |
end; |
|
1716 |
||
1717 |
||
1089 | 1718 |
procedure doStepCakeWork(Gear: PGear); |
1719 |
const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0)); |
|
1720 |
var xx, yy, xxn, yyn: LongInt; |
|
1721 |
da: LongInt; |
|
1103 | 1722 |
tdx, tdy: hwFloat; |
1089 | 1723 |
|
1724 |
procedure PrevAngle; |
|
1725 |
begin |
|
1133 | 1726 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 - dA) mod 4 |
1089 | 1727 |
end; |
1728 |
||
1729 |
procedure NextAngle; |
|
1730 |
begin |
|
1133 | 1731 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 + dA) mod 4 |
1089 | 1732 |
end; |
1733 |
||
1088 | 1734 |
begin |
1089 | 1735 |
inc(Gear^.Tag); |
1108 | 1736 |
if Gear^.Tag < 7 then exit; |
1089 | 1737 |
|
1738 |
dA:= hwSign(Gear^.dX); |
|
1739 |
xx:= dirs[Gear^.Angle].x; |
|
1740 |
yy:= dirs[Gear^.Angle].y; |
|
1133 | 1741 |
xxn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x; |
1742 |
yyn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y; |
|
1089 | 1743 |
|
1744 |
if (xx = 0) then |
|
1745 |
if TestCollisionYwithGear(Gear, yy) then |
|
1746 |
PrevAngle |
|
1747 |
else begin |
|
1748 |
Gear^.Tag:= 0; |
|
1749 |
Gear^.Y:= Gear^.Y + int2hwFloat(yy); |
|
1635
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1750 |
if not TestCollisionXwithGear(Gear, xxn) then |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1751 |
begin |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1752 |
Gear^.X:= Gear^.X + int2hwFloat(xxn); |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1753 |
NextAngle |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1754 |
end; |
1089 | 1755 |
end; |
1756 |
||
1757 |
if (yy = 0) then |
|
1758 |
if TestCollisionXwithGear(Gear, xx) then |
|
1759 |
PrevAngle |
|
1760 |
else begin |
|
1761 |
Gear^.Tag:= 0; |
|
1762 |
Gear^.X:= Gear^.X + int2hwFloat(xx); |
|
1635
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1763 |
if not TestCollisionYwithGear(Gear, yyn) then |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1764 |
begin |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1765 |
Gear^.Y:= Gear^.Y + int2hwFloat(yyn); |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1766 |
NextAngle |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1767 |
end; |
1089 | 1768 |
end; |
1769 |
||
1103 | 1770 |
if Gear^.Tag = 0 then |
1771 |
begin |
|
1772 |
CakeI:= (CakeI + 1) mod cakeh; |
|
1773 |
tdx:= CakePoints[CakeI].x - Gear^.X; |
|
1774 |
tdy:= - CakePoints[CakeI].y + Gear^.Y; |
|
1775 |
CakePoints[CakeI].x:= Gear^.X; |
|
1776 |
CakePoints[CakeI].y:= Gear^.Y; |
|
1777 |
Gear^.DirAngle:= DxDy2Angle(tdx, tdy); |
|
1778 |
end; |
|
1779 |
||
1089 | 1780 |
dec(Gear^.Health); |
1090 | 1781 |
if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then |
1089 | 1782 |
begin |
1109 | 1783 |
FollowGear:= Gear; |
1784 |
Gear^.doStep:= @doStepCakeDown |
|
1089 | 1785 |
end |
1088 | 1786 |
end; |
1089 | 1787 |
|
1103 | 1788 |
procedure doStepCakeUp(Gear: PGear); |
1789 |
var i: Longword; |
|
1790 |
begin |
|
1791 |
AllInactive:= false; |
|
1792 |
||
1108 | 1793 |
inc(Gear^.Tag); |
1109 | 1794 |
if Gear^.Tag < 100 then exit; |
1108 | 1795 |
Gear^.Tag:= 0; |
1796 |
||
1109 | 1797 |
if Gear^.Pos = 6 then |
1103 | 1798 |
begin |
1799 |
for i:= 0 to Pred(cakeh) do |
|
1800 |
begin |
|
1801 |
CakePoints[i].x:= Gear^.X; |
|
1802 |
CakePoints[i].y:= Gear^.Y |
|
1803 |
end; |
|
1804 |
CakeI:= 0; |
|
1805 |
Gear^.doStep:= @doStepCakeWork |
|
1109 | 1806 |
end else inc(Gear^.Pos) |
1103 | 1807 |
end; |
1808 |
||
1089 | 1809 |
procedure doStepCakeFall(Gear: PGear); |
1810 |
begin |
|
1811 |
AllInactive:= false; |
|
1812 |
||
1813 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1814 |
if TestCollisionYwithGear(Gear, 1) then |
|
1103 | 1815 |
Gear^.doStep:= @doStepCakeUp |
1089 | 1816 |
else |
1817 |
begin |
|
1818 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1819 |
if CheckGearDrowning(Gear) then AfterAttack |
|
1820 |
end |
|
1821 |
end; |
|
1822 |
||
1823 |
procedure doStepCake(Gear: PGear); |
|
1824 |
var HHGear: PGear; |
|
1825 |
begin |
|
1826 |
AllInactive:= false; |
|
1827 |
||
1828 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1103 | 1829 |
HHGear^.Message:= HHGear^.Message and (not gm_Attack); |
1089 | 1830 |
DeleteCI(HHGear); |
1831 |
||
1106 | 1832 |
FollowGear:= Gear; |
1833 |
||
1089 | 1834 |
Gear^.doStep:= @doStepCakeFall |
1835 |
end; |
|
1836 |
||
1259 | 1837 |
//////////////////////////////////////////////////////////////////////////////// |
1284 | 1838 |
procedure doStepSeductionWork(Gear: PGear); |
1839 |
var x, y: LongInt; |
|
1259 | 1840 |
begin |
1841 |
AllInactive:= false; |
|
1284 | 1842 |
|
1843 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1844 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1845 |
x:= hwRound(Gear^.X); |
|
1846 |
y:= hwRound(Gear^.Y); |
|
1259 | 1847 |
|
1753 | 1848 |
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) then |
1284 | 1849 |
if (Land[y, x] <> 0) then |
1850 |
begin |
|
1851 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; |
|
1852 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative; |
|
1286 | 1853 |
Gear^.dX:= Gear^.dX * _1_5; |
1854 |
Gear^.dY:= Gear^.dY * _1_5 - _0_3; |
|
1284 | 1855 |
AmmoShove(Gear, 0, 40); |
1286 | 1856 |
AfterAttack; |
1284 | 1857 |
DeleteGear(Gear) |
1858 |
end |
|
1859 |
else |
|
1860 |
else |
|
1286 | 1861 |
begin |
1862 |
AfterAttack; |
|
1284 | 1863 |
DeleteGear(Gear) |
1286 | 1864 |
end |
1865 |
end; |
|
1866 |
||
1867 |
procedure doStepSeductionWear(Gear: PGear); |
|
1868 |
begin |
|
1869 |
AllInactive:= false; |
|
1870 |
inc(Gear^.Timer); |
|
1871 |
if Gear^.Timer > 250 then |
|
1872 |
begin |
|
1873 |
Gear^.Timer:= 0; |
|
1388 | 1874 |
inc(Gear^.Pos); |
1875 |
if Gear^.Pos = 5 then |
|
1669 | 1876 |
PlaySound(sndYoohoo, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) |
1286 | 1877 |
end; |
1367 | 1878 |
|
1879 |
if Gear^.Pos = 14 then |
|
1286 | 1880 |
Gear^.doStep:= @doStepSeductionWork |
1259 | 1881 |
end; |
1284 | 1882 |
|
1883 |
procedure doStepSeduction(Gear: PGear); |
|
1884 |
begin |
|
1885 |
AllInactive:= false; |
|
1886 |
DeleteCI(PHedgehog(Gear^.Hedgehog)^.Gear); |
|
1286 | 1887 |
Gear^.doStep:= @doStepSeductionWear |
1284 | 1888 |
end; |
1298 | 1889 |
|
1890 |
//////////////////////////////////////////////////////////////////////////////// |
|
1891 |
procedure doStepWaterUp(Gear: PGear); |
|
1892 |
var i: LongWord; |
|
1893 |
begin |
|
1894 |
AllInactive:= false; |
|
1895 |
||
1896 |
inc(Gear^.Timer); |
|
1897 |
if Gear^.Timer = 17 then |
|
1898 |
Gear^.Timer:= 0 |
|
1899 |
else |
|
1900 |
exit; |
|
1901 |
||
1902 |
if cWaterLine > 0 then |
|
1903 |
begin |
|
1904 |
dec(cWaterLine); |
|
1760 | 1905 |
for i:= 0 to LAND_WIDTH - 1 do |
1298 | 1906 |
Land[cWaterLine, i]:= 0; |
1907 |
SetAllToActive |
|
1908 |
end; |
|
1909 |
||
1910 |
inc(Gear^.Tag); |
|
1343 | 1911 |
if (Gear^.Tag = 47) or (cWaterLine = 0) then |
1298 | 1912 |
DeleteGear(Gear) |
1913 |
end; |
|
1573 | 1914 |
|
1915 |
//////////////////////////////////////////////////////////////////////////////// |
|
1590 | 1916 |
procedure doStepDrillDrilling(Gear: PGear); |
1633 | 1917 |
var t: PGearArray; |
1918 |
ox, oy: hwFloat; |
|
1573 | 1919 |
begin |
1590 | 1920 |
AllInactive:= false; |
1921 |
||
1633 | 1922 |
if (Gear^.Timer > 0) and ((Gear^.Timer mod 10) = 0) then |
1590 | 1923 |
begin |
1573 | 1924 |
ox:= Gear^.X; |
1925 |
oy:= Gear^.Y; |
|
1926 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1927 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1928 |
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6); |
|
1929 |
CheckGearDrowning(Gear); |
|
1590 | 1930 |
end; |
1931 |
||
1633 | 1932 |
t:= CheckGearsCollision(Gear); //fixes drill not exploding when touching HH bug |
1590 | 1933 |
if (Gear^.Timer = 0) |
1633 | 1934 |
or (t^.Count <> 0) |
1590 | 1935 |
or (not TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) |
1784 | 1936 |
and not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) |
1937 |
or (Land[hwRound(Gear^.Y), hwRound(Gear^.X)] = COLOR_INDESTRUCTIBLE) then |
|
1590 | 1938 |
begin //out of time or exited ground |
1939 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1940 |
DeleteGear(Gear); |
|
1941 |
exit |
|
1942 |
end; |
|
1943 |
||
1944 |
dec(Gear^.Timer); |
|
1573 | 1945 |
end; |
1946 |
||
1947 |
procedure doStepDrill(Gear: PGear); |
|
1590 | 1948 |
var t: PGearArray; |
1633 | 1949 |
oldDx, oldDy: hwFloat; |
1950 |
t2: hwFloat; |
|
1573 | 1951 |
begin |
1590 | 1952 |
AllInactive:= false; |
1573 | 1953 |
|
1590 | 1954 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
1955 |
oldDx:= Gear^.dX; |
|
1956 |
oldDy:= Gear^.dY; |
|
1957 |
||
1958 |
doStepFallingGear(Gear); |
|
1959 |
||
1960 |
if (GameTicks and $3F) = 0 then |
|
1961 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1573 | 1962 |
|
1633 | 1963 |
if ((Gear^.State and gstCollision) <> 0) then begin //hit |
1590 | 1964 |
Gear^.dX:= oldDx; |
1965 |
Gear^.dY:= oldDy; |
|
1633 | 1966 |
|
1590 | 1967 |
t:= CheckGearsCollision(Gear); |
1633 | 1968 |
if (t^.Count = 0) then begin //hit the ground not the HH |
1969 |
t2 := _0_5 / Distance(Gear^.dX, Gear^.dY); |
|
1970 |
Gear^.dX:= Gear^.dX * t2; |
|
1971 |
Gear^.dY:= Gear^.dY * t2; |
|
1972 |
end else begin //explode right on contact with HH |
|
1973 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1974 |
DeleteGear(Gear); |
|
1975 |
exit; |
|
1976 |
end; |
|
1977 |
||
1590 | 1978 |
Gear^.doStep:= @doStepDrillDrilling; |
1633 | 1979 |
dec(Gear^.Timer) |
1590 | 1980 |
end |
1981 |
end; |
|
1601 | 1982 |
|
1633 | 1983 |
//////////////////////////////////////////////////////////////////////////////// |
1601 | 1984 |
procedure doStepBallgunWork(Gear: PGear); |
1985 |
var HHGear: PGear; |
|
1630 | 1986 |
rx, ry: hwFloat; |
1601 | 1987 |
begin |
1988 |
AllInactive:= false; |
|
1989 |
dec(Gear^.Timer); |
|
1990 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1991 |
HedgehogChAngle(HHGear); |
|
1992 |
if (Gear^.Timer mod 100) = 0 then |
|
1993 |
begin |
|
1630 | 1994 |
rx:= rndSign(getRandom * _0_1); |
1995 |
ry:= rndSign(getRandom * _0_1); |
|
1631
6e313b3818ef
Remove debug stuff, ballgun 64but incompatibility fixed in previous revision
unc0rr
parents:
1630
diff
changeset
|
1996 |
|
1630 | 1997 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBall, 0, |
1998 |
SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, |
|
1999 |
AngleCos(HHGear^.Angle) * ( - _0_8) + ry, |
|
2000 |
0); |
|
1601 | 2001 |
|
1669 | 2002 |
PlaySound(sndGun, false, nil); |
1601 | 2003 |
end; |
2004 |
||
1643 | 2005 |
if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then |
1601 | 2006 |
begin |
2007 |
DeleteGear(Gear); |
|
1643 | 2008 |
AfterAttack |
2009 |
end |
|
1601 | 2010 |
end; |
2011 |
||
2012 |
procedure doStepBallgun(Gear: PGear); |
|
2013 |
var HHGear: PGear; |
|
2014 |
begin |
|
2015 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2016 |
HHGear^.Message:= HHGear^.Message and not (gm_Up or gm_Down); |
|
2017 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
|
2018 |
Gear^.doStep:= @doStepBallgunWork |
|
1633 | 2019 |
end; |
1689 | 2020 |
|
1696 | 2021 |
//////////////////////////////////////////////////////////////////////////////// |
1689 | 2022 |
procedure doStepRCPlaneWork(Gear: PGear); |
2023 |
const cAngleSpeed = 3; |
|
2024 |
var HHGear: PGear; |
|
2025 |
i: LongInt; |
|
2026 |
dX, dY: hwFloat; |
|
2027 |
fChanged: boolean; |
|
2028 |
trueAngle: Longword; |
|
2029 |
t: PGear; |
|
2030 |
begin |
|
2031 |
AllInactive:= false; |
|
2032 |
||
1696 | 2033 |
if Gear^.Timer > 0 then dec(Gear^.Timer); |
1689 | 2034 |
|
2035 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2036 |
FollowGear:= Gear; |
|
2037 |
||
2038 |
fChanged:= false; |
|
1696 | 2039 |
if ((HHGear^.State and gstHHDriven) = 0) or (Gear^.Timer = 0) then |
1689 | 2040 |
begin |
2041 |
fChanged:= true; |
|
1696 | 2042 |
if Gear^.Angle > 2048 then dec(Gear^.Angle) else |
2043 |
if Gear^.Angle < 2048 then inc(Gear^.Angle) else fChanged:= false |
|
2044 |
end |
|
2045 |
else |
|
2046 |
begin |
|
2047 |
if ((Gear^.Message and gm_Left) <> 0) then |
|
2048 |
begin |
|
2049 |
fChanged:= true; |
|
2050 |
Gear^.Angle:= (Gear^.Angle + (4096 - cAngleSpeed)) mod 4096 |
|
2051 |
end; |
|
1689 | 2052 |
|
1696 | 2053 |
if ((Gear^.Message and gm_Right) <> 0) then |
2054 |
begin |
|
2055 |
fChanged:= true; |
|
2056 |
Gear^.Angle:= (Gear^.Angle + cAngleSpeed) mod 4096 |
|
2057 |
end |
|
1689 | 2058 |
end; |
2059 |
||
2060 |
if fChanged then |
|
2061 |
begin |
|
2062 |
Gear^.dX.isNegative:= (Gear^.Angle > 2048); |
|
2063 |
if Gear^.dX.isNegative then |
|
2064 |
trueAngle:= 4096 - Gear^.Angle |
|
2065 |
else |
|
2066 |
trueAngle:= Gear^.Angle; |
|
2067 |
||
2068 |
Gear^.dX:= SignAs(AngleSin(trueAngle), Gear^.dX) * _0_25; |
|
2069 |
Gear^.dY:= AngleCos(trueAngle) * -_0_25; |
|
2070 |
end; |
|
2071 |
||
2072 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
2073 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
2074 |
||
2075 |
if (GameTicks and $FF) = 0 then |
|
1698 | 2076 |
if Gear^.Timer < 3500 then |
1696 | 2077 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0) |
2078 |
else |
|
2079 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1689 | 2080 |
|
1696 | 2081 |
if ((HHGear^.Message and gm_Attack) <> 0) and (Gear^.Health <> 0) then |
1689 | 2082 |
begin |
2083 |
HHGear^.Message := HHGear^.Message and not gm_Attack; |
|
1708 | 2084 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * _0_5, 0); |
1689 | 2085 |
dec(Gear^.Health) |
1712 | 2086 |
end; |
2087 |
||
2088 |
if ((HHGear^.Message and gm_LJump) <> 0) |
|
2089 |
and ((Gear^.State and gsttmpFlag) = 0) then |
|
2090 |
begin |
|
2091 |
Gear^.State:= Gear^.State or gsttmpFlag; |
|
2092 |
PauseMusic; |
|
2093 |
playSound(sndRideOfTheValkyries, false, nil); |
|
2094 |
end; |
|
1689 | 2095 |
|
2096 |
// pickup bonuses |
|
2097 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
2098 |
if t <> nil then |
|
2099 |
PickUp(HHGear, t); |
|
2100 |
||
2101 |
CheckCollision(Gear); |
|
2102 |
||
1712 | 2103 |
if ((Gear^.State and gstCollision) <> 0) |
2104 |
or CheckGearDrowning(Gear) then |
|
1689 | 2105 |
begin |
1712 | 2106 |
StopSound(sndRCPlane); |
2107 |
StopSound(sndRideOfTheValkyries); |
|
2108 |
ResumeMusic; |
|
2109 |
||
2110 |
if ((Gear^.State and gstCollision) <> 0) then |
|
1689 | 2111 |
begin |
1712 | 2112 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound); |
1714 | 2113 |
for i:= 0 to 32 do |
1712 | 2114 |
begin |
1714 | 2115 |
dX:= AngleCos(i * 64) * _0_5 * (GetRandom + _1); |
2116 |
dY:= AngleSin(i * 64) * _0_5 * (GetRandom + _1); |
|
1712 | 2117 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); |
2118 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, -dY, 0); |
|
2119 |
end; |
|
2120 |
DeleteGear(Gear) |
|
1689 | 2121 |
end; |
1713 | 2122 |
|
1689 | 2123 |
AfterAttack; |
1713 | 2124 |
CurAmmoGear:= nil; |
1697 | 2125 |
TurnTimeLeft:= 14 * 125; |
1712 | 2126 |
HHGear^.Message:= 0; |
1697 | 2127 |
ParseCommand('/taunt '#1, true) |
2128 |
end |
|
1689 | 2129 |
end; |
2130 |
||
2131 |
procedure doStepRCPlane(Gear: PGear); |
|
2132 |
var HHGear: PGear; |
|
2133 |
begin |
|
2134 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2135 |
HHGear^.Message:= 0; |
|
2136 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
|
2137 |
Gear^.Angle:= HHGear^.Angle; |
|
1696 | 2138 |
Gear^.Tag:= hwSign(HHGear^.dX); |
1689 | 2139 |
if HHGear^.dX.isNegative then Gear^.Angle:= 4096 - Gear^.Angle; |
2140 |
Gear^.doStep:= @doStepRCPlaneWork |
|
1712 | 2141 |
end; |