author | unc0rr |
Sun, 22 Mar 2009 17:44:00 +0000 | |
changeset 1910 | ae0addb05791 |
parent 1909 | 30fa1608b54f |
child 1914 | aab686a4e0c5 |
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 |
|
1861 | 51 |
dmg:= modifyDamage(1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70)); |
1123 | 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; |
|
1892 | 690 |
State:= State and not gstWinner; |
1504 | 691 |
end; |
692 |
DeleteGear(Gear) |
|
693 |
end; |
|
4 | 694 |
|
1781 | 695 |
procedure WaitCollision; |
696 |
begin |
|
697 |
with HHGear^ do |
|
698 |
begin |
|
699 |
Message:= Message and not gm_Attack; |
|
700 |
State:= State or gstMoving; |
|
701 |
end; |
|
702 |
RopePoints.Count:= 0; |
|
703 |
Gear^.Elasticity:= _0; |
|
704 |
Gear^.doStep:= @doStepRopeAfterAttack |
|
705 |
end; |
|
706 |
||
4 | 707 |
begin |
351 | 708 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
108 | 709 |
|
351 | 710 |
if ((HHGear^.State and gstHHDriven) = 0) |
1504 | 711 |
or (CheckGearDrowning(HHGear)) then |
712 |
begin |
|
713 |
DeleteMe; |
|
714 |
exit |
|
715 |
end; |
|
928
b9064b48b001
Some preparation work for attacking from rope, parachute and etc.
unc0rr
parents:
925
diff
changeset
|
716 |
|
351 | 717 |
if (Gear^.Message and gm_Left <> 0) then HHGear^.dX:= HHGear^.dX - _0_0002 else |
718 |
if (Gear^.Message and gm_Right <> 0) then HHGear^.dX:= HHGear^.dX + _0_0002; |
|
4 | 719 |
|
351 | 720 |
if not TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= HHGear^.dY + cGravity; |
4 | 721 |
|
1652 | 722 |
ropeDx:= HHGear^.X - Gear^.X; // vector between hedgehog and rope attaching point |
723 |
ropeDy:= HHGear^.Y - Gear^.Y; |
|
724 |
||
725 |
mdX:= ropeDx + HHGear^.dX; |
|
726 |
mdY:= ropeDy + HHGear^.dY; |
|
727 |
len:= _1 / Distance(mdX, mdY); |
|
728 |
mdX:= mdX * len; // rope vector plus hedgehog direction vector normalized |
|
729 |
mdY:= mdY * len; |
|
730 |
||
731 |
Gear^.dX:= mdX; // for visual purposes only |
|
732 |
Gear^.dY:= mdY; |
|
733 |
||
734 |
///// |
|
735 |
tx:= HHGear^.X; |
|
736 |
ty:= HHGear^.Y; |
|
4 | 737 |
|
1652 | 738 |
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then |
739 |
if not (TestCollisionXwithGear(HHGear, hwSign(ropeDx)) |
|
740 |
or TestCollisionYwithGear(HHGear, hwSign(ropeDy))) then |
|
741 |
Gear^.Elasticity:= Gear^.Elasticity + _0_3; |
|
742 |
||
743 |
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then |
|
744 |
if not (TestCollisionXwithGear(HHGear, -hwSign(ropeDx)) |
|
745 |
or TestCollisionYwithGear(HHGear, -hwSign(ropeDy))) then |
|
746 |
Gear^.Elasticity:= Gear^.Elasticity - _0_3; |
|
747 |
||
748 |
HHGear^.X:= Gear^.X + mdX * Gear^.Elasticity; |
|
749 |
HHGear^.Y:= Gear^.Y + mdY * Gear^.Elasticity; |
|
750 |
||
751 |
HHGear^.dX:= HHGear^.X - tx; |
|
752 |
HHGear^.dY:= HHGear^.Y - ty; |
|
753 |
//// |
|
754 |
||
1554 | 755 |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
756 |
haveDivided:= false; |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
757 |
// check whether rope needs dividing |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
758 |
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
|
759 |
nx:= ropeDx * len; |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
760 |
ny:= ropeDy * len; |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
761 |
|
1652 | 762 |
len:= Gear^.Elasticity - _0_3x70; |
763 |
while len > _0_3 do |
|
1504 | 764 |
begin |
1652 | 765 |
lx:= hwRound(Gear^.X + mdX * len); |
766 |
ly:= hwRound(Gear^.Y + mdY * len); |
|
1753 | 767 |
if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (Land[ly, lx] <> 0) then |
1504 | 768 |
begin |
769 |
with RopePoints.ar[RopePoints.Count] do |
|
770 |
begin |
|
771 |
X:= Gear^.X; |
|
772 |
Y:= Gear^.Y; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
773 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); |
1652 | 774 |
b:= (nx * HHGear^.dY) > (ny * HHGear^.dX); |
1504 | 775 |
dLen:= len |
776 |
end; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
777 |
Gear^.X:= Gear^.X + nx * len; |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
778 |
Gear^.Y:= Gear^.Y + ny * len; |
1504 | 779 |
inc(RopePoints.Count); |
780 |
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); |
|
781 |
Gear^.Elasticity:= Gear^.Elasticity - len; |
|
782 |
Gear^.Friction:= Gear^.Friction - len; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
783 |
haveDivided:= true; |
1504 | 784 |
break |
785 |
end; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
786 |
len:= len - _0_3 // should be the same as increase step |
1504 | 787 |
end; |
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
788 |
|
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
789 |
if not haveDivided then |
1504 | 790 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
791 |
begin |
|
792 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
793 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
794 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then |
|
795 |
begin |
|
796 |
dec(RopePoints.Count); |
|
1652 | 797 |
Gear^.X:= RopePoints.ar[RopePoints.Count].X; |
798 |
Gear^.Y:= RopePoints.ar[RopePoints.Count].Y; |
|
1504 | 799 |
Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
800 |
Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
801 |
end |
|
802 |
end; |
|
4 | 803 |
|
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
|
804 |
haveCollision:= false; |
351 | 805 |
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
|
806 |
begin |
1504 | 807 |
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
|
808 |
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
|
809 |
end; |
351 | 810 |
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
|
811 |
begin |
1504 | 812 |
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
|
813 |
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
|
814 |
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
|
815 |
|
1579
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset
|
816 |
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
|
817 |
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
|
818 |
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
|
819 |
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
|
820 |
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
|
821 |
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
|
822 |
end; |
4 | 823 |
|
789 | 824 |
len:= Distance(HHGear^.dX, HHGear^.dY); |
940 | 825 |
if len > _0_8 then |
1504 | 826 |
begin |
827 |
len:= _0_8 / len; |
|
828 |
HHGear^.dX:= HHGear^.dX * len; |
|
829 |
HHGear^.dY:= HHGear^.dY * len; |
|
830 |
end; |
|
789 | 831 |
|
351 | 832 |
if (Gear^.Message and gm_Attack) <> 0 then |
1504 | 833 |
if (Gear^.State and gsttmpFlag) <> 0 then |
1781 | 834 |
WaitCollision |
1504 | 835 |
else |
836 |
else |
|
837 |
if (Gear^.State and gsttmpFlag) = 0 then |
|
838 |
Gear^.State:= Gear^.State or gsttmpFlag; |
|
4 | 839 |
end; |
840 |
||
841 |
procedure doStepRopeAttach(Gear: PGear); |
|
842 |
var HHGear: PGear; |
|
1781 | 843 |
tx, ty, tt: hwFloat; |
844 |
||
845 |
procedure RemoveFromAmmo; |
|
846 |
begin |
|
847 |
if (Gear^.State and gstAttacked) = 0 then |
|
848 |
begin |
|
849 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
|
850 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
851 |
Gear^.State:= Gear^.State or gstAttacked |
|
852 |
end |
|
853 |
end; |
|
854 |
||
4 | 855 |
begin |
351 | 856 |
Gear^.X:= Gear^.X - Gear^.dX; |
857 |
Gear^.Y:= Gear^.Y - Gear^.dY; |
|
498 | 858 |
Gear^.Elasticity:= Gear^.Elasticity + _1; |
351 | 859 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
517 | 860 |
DeleteCI(HHGear); |
542 | 861 |
if (HHGear^.State and gstMoving) <> 0 then |
1433 | 862 |
if TestCollisionYwithGear(HHGear, 1) then |
863 |
begin |
|
864 |
CheckHHDamage(HHGear); |
|
865 |
HHGear^.dY:= _0; |
|
866 |
HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); |
|
867 |
end else |
|
868 |
begin |
|
869 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
|
870 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
871 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
872 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
873 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
874 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
875 |
tt:= Gear^.Elasticity; |
|
876 |
tx:= _0; |
|
877 |
ty:= _0; |
|
878 |
while tt > _20 do |
|
879 |
begin |
|
880 |
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) |
|
881 |
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then |
|
882 |
begin |
|
883 |
Gear^.X:= Gear^.X + tx; |
|
884 |
Gear^.Y:= Gear^.Y + ty; |
|
885 |
Gear^.Elasticity:= tt; |
|
886 |
Gear^.doStep:= @doStepRopeWork; |
|
1752
769986d39202
Fix accidental rope removinf from ammo in some cases
unc0rr
parents:
1736
diff
changeset
|
887 |
with HHGear^ do State:= State and not (gstAttacking or gstMoving or gstHHHJump); |
1781 | 888 |
|
889 |
RemoveFromAmmo; |
|
890 |
||
1752
769986d39202
Fix accidental rope removinf from ammo in some cases
unc0rr
parents:
1736
diff
changeset
|
891 |
tt:= _0; |
769986d39202
Fix accidental rope removinf from ammo in some cases
unc0rr
parents:
1736
diff
changeset
|
892 |
exit |
1433 | 893 |
end; |
894 |
tx:= tx + Gear^.dX + Gear^.dX; |
|
895 |
ty:= ty + Gear^.dY + Gear^.dY; |
|
896 |
tt:= tt - _2; |
|
897 |
end; |
|
898 |
end; |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
899 |
|
4 | 900 |
CheckCollision(Gear); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
901 |
|
351 | 902 |
if (Gear^.State and gstCollision) <> 0 then |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
903 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
904 |
Gear^.doStep:= @doStepRopeWork; |
974
fc16141a0128
Prevent wrong aim direction when using rope after high jump
unc0rr
parents:
963
diff
changeset
|
905 |
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
|
906 |
|
1781 | 907 |
RemoveFromAmmo; |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
908 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
909 |
if Gear^.Elasticity < _10 then |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
910 |
Gear^.Elasticity:= _10000; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
911 |
end; |
4 | 912 |
|
1634
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset
|
913 |
if (Gear^.Elasticity > Gear^.Friction) |
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset
|
914 |
or ((Gear^.Message and gm_Attack) = 0) |
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset
|
915 |
or (HHGear^.Damage > 0) then |
1433 | 916 |
begin |
917 |
with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
|
918 |
begin |
|
919 |
State:= State and not gstAttacking; |
|
920 |
Message:= Message and not gm_Attack |
|
921 |
end; |
|
922 |
DeleteGear(Gear) |
|
923 |
end |
|
4 | 924 |
end; |
925 |
||
926 |
procedure doStepRope(Gear: PGear); |
|
927 |
begin |
|
351 | 928 |
Gear^.dX:= - Gear^.dX; |
929 |
Gear^.dY:= - Gear^.dY; |
|
930 |
Gear^.doStep:= @doStepRopeAttach |
|
4 | 931 |
end; |
932 |
||
933 |
//////////////////////////////////////////////////////////////////////////////// |
|
934 |
procedure doStepSmokeTrace(Gear: PGear); |
|
935 |
begin |
|
351 | 936 |
inc(Gear^.Timer); |
937 |
if Gear^.Timer > 64 then |
|
1133 | 938 |
begin |
939 |
Gear^.Timer:= 0; |
|
940 |
dec(Gear^.State) |
|
941 |
end; |
|
351 | 942 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
943 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
944 |
if Gear^.State = 0 then DeleteGear(Gear) |
|
4 | 945 |
end; |
9 | 946 |
|
947 |
//////////////////////////////////////////////////////////////////////////////// |
|
1045 | 948 |
procedure doStepExplosionWork(Gear: PGear); |
9 | 949 |
begin |
351 | 950 |
inc(Gear^.Timer); |
951 |
if Gear^.Timer > 75 then |
|
1133 | 952 |
begin |
953 |
inc(Gear^.State); |
|
954 |
Gear^.Timer:= 0; |
|
955 |
if Gear^.State > 5 then DeleteGear(Gear) |
|
956 |
end; |
|
9 | 957 |
end; |
10 | 958 |
|
1045 | 959 |
procedure doStepExplosion(Gear: PGear); |
960 |
var i: LongWord; |
|
961 |
begin |
|
1047 | 962 |
for i:= 0 to 31 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFire); |
963 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart); |
|
964 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart2); |
|
1045 | 965 |
Gear^.doStep:= @doStepExplosionWork |
966 |
end; |
|
967 |
||
10 | 968 |
//////////////////////////////////////////////////////////////////////////////// |
969 |
procedure doStepMine(Gear: PGear); |
|
970 |
begin |
|
542 | 971 |
if (Gear^.State and gstMoving) <> 0 then |
914 | 972 |
begin |
973 |
DeleteCI(Gear); |
|
974 |
doStepFallingGear(Gear); |
|
975 |
if (Gear^.State and gstMoving) = 0 then |
|
976 |
begin |
|
977 |
AddGearCI(Gear); |
|
978 |
Gear^.dX:= _0; |
|
979 |
Gear^.dY:= _0 |
|
980 |
end; |
|
981 |
CalcRotationDirAngle(Gear); |
|
982 |
AllInactive:= false |
|
983 |
end else |
|
984 |
if ((GameTicks and $3F) = 25) then |
|
985 |
doStepFallingGear(Gear); |
|
351 | 986 |
|
987 |
if ((Gear^.State and gsttmpFlag) <> 0) then |
|
1133 | 988 |
if ((Gear^.State and gstAttacking) = 0) then |
989 |
begin |
|
990 |
if ((GameTicks and $1F) = 0) then |
|
991 |
if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking |
|
992 |
end else // gstAttacking <> 0 |
|
993 |
begin |
|
994 |
AllInactive:= false; |
|
1669 | 995 |
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false, nil); |
1133 | 996 |
if Gear^.Timer = 0 then |
997 |
begin |
|
998 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
999 |
DeleteGear(Gear); |
|
1000 |
exit |
|
1001 |
end; |
|
1002 |
dec(Gear^.Timer); |
|
1003 |
end else // gsttmpFlag = 0 |
|
1004 |
if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
10 | 1005 |
end; |
57 | 1006 |
|
39 | 1007 |
//////////////////////////////////////////////////////////////////////////////// |
1008 |
procedure doStepDynamite(Gear: PGear); |
|
1009 |
begin |
|
43 | 1010 |
doStepFallingGear(Gear); |
1011 |
AllInactive:= false; |
|
351 | 1012 |
if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); |
1013 |
if Gear^.Timer = 0 then |
|
1133 | 1014 |
begin |
1015 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
|
1016 |
DeleteGear(Gear); |
|
1017 |
exit |
|
1018 |
end; |
|
351 | 1019 |
dec(Gear^.Timer); |
39 | 1020 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1021 |
|
351 | 1022 |
/////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1023 |
procedure doStepCase(Gear: PGear); |
371 | 1024 |
var i, x, y: LongInt; |
1436 | 1025 |
k: TGearType; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1026 |
begin |
351 | 1027 |
if (Gear^.Message and gm_Destroy) > 0 then |
1133 | 1028 |
begin |
1029 |
DeleteGear(Gear); |
|
1030 |
FreeActionsList; |
|
1031 |
SetAllToActive; // something (hh, mine, etc...) could be on top of the case |
|
1032 |
with CurrentHedgehog^ do |
|
1033 |
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
|
1034 |
exit |
|
1035 |
end; |
|
15 | 1036 |
|
351 | 1037 |
if Gear^.Damage > 0 then |
1133 | 1038 |
begin |
1039 |
x:= hwRound(Gear^.X); |
|
1040 |
y:= hwRound(Gear^.Y); |
|
1436 | 1041 |
k:= Gear^.Kind; |
1042 |
DeleteGear(Gear); // <-- delete gear! |
|
1043 |
||
1044 |
if k = gtCase then |
|
1133 | 1045 |
begin |
1046 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
|
1047 |
for i:= 0 to 63 do |
|
1048 |
AddGear(x, y, gtFlame, 0, _0, _0, 0); |
|
1049 |
end; |
|
1050 |
exit |
|
1051 |
end; |
|
79 | 1052 |
|
351 | 1053 |
if (Gear^.dY.QWordValue <> 0) or (not TestCollisionYwithGear(Gear, 1)) then |
1133 | 1054 |
begin |
1055 |
AllInactive:= false; |
|
1056 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1057 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1058 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else |
|
1059 |
if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then |
|
1060 |
begin |
|
1061 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
1062 |
if Gear^.dY > - _0_001 then Gear^.dY:= _0 |
|
1669 | 1063 |
else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false, nil); |
1133 | 1064 |
end; |
1065 |
CheckGearDrowning(Gear); |
|
1066 |
end; |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1067 |
|
511 | 1068 |
if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
1133 | 1069 |
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
|
1070 |
end; |
49 | 1071 |
|
1072 |
//////////////////////////////////////////////////////////////////////////////// |
|
557 | 1073 |
const cSorterWorkTime = 640; |
1074 |
var thexchar: array[0..cMaxTeams] of |
|
1133 | 1075 |
record |
1076 |
dy, ny, dw: LongInt; |
|
1077 |
team: PTeam; |
|
1078 |
SortFactor: QWord; |
|
1079 |
end; |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
1080 |
currsorter: PGear = nil; |
49 | 1081 |
|
1082 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
371 | 1083 |
var i: LongInt; |
49 | 1084 |
begin |
1085 |
AllInactive:= false; |
|
351 | 1086 |
dec(Gear^.Timer); |
1087 |
if (Gear^.Timer and 15) = 0 then |
|
1133 | 1088 |
for i:= 0 to Pred(TeamsCount) do |
1089 |
with thexchar[i] do |
|
1090 |
begin |
|
1091 |
{$WARNINGS OFF} |
|
1092 |
team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; |
|
1093 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; |
|
1094 |
{$WARNINGS ON} |
|
1095 |
end; |
|
1096 |
||
351 | 1097 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
1133 | 1098 |
begin |
1099 |
if currsorter = Gear then currsorter:= nil; |
|
1100 |
DeleteGear(Gear) |
|
1101 |
end |
|
49 | 1102 |
end; |
1103 |
||
1104 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
1133 | 1105 |
var i: Longword; |
1106 |
b: boolean; |
|
1107 |
t: LongInt; |
|
49 | 1108 |
begin |
1109 |
AllInactive:= false; |
|
557 | 1110 |
|
547 | 1111 |
for t:= 0 to Pred(TeamsCount) do |
1133 | 1112 |
with thexchar[t] do |
1113 |
begin |
|
1114 |
dy:= TeamsArray[t]^.DrawHealthY; |
|
1115 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
1116 |
team:= TeamsArray[t]; |
|
1117 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
1118 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
1119 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
1120 |
end; |
|
547 | 1121 |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
1122 |
if TeamsCount > 1 then |
1133 | 1123 |
repeat |
1124 |
b:= true; |
|
1125 |
for t:= 0 to TeamsCount - 2 do |
|
1126 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
1127 |
begin |
|
1128 |
thexchar[cMaxTeams]:= thexchar[t]; |
|
1129 |
thexchar[t]:= thexchar[Succ(t)]; |
|
1130 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
|
1131 |
b:= false |
|
1132 |
end |
|
1133 |
until b; |
|
557 | 1134 |
|
1120 | 1135 |
t:= - 4; |
557 | 1136 |
for i:= 0 to Pred(TeamsCount) do |
1133 | 1137 |
with thexchar[i] do |
1138 |
begin |
|
1139 |
dec(t, team^.HealthTex^.h + 2); |
|
1140 |
ny:= t; |
|
1141 |
dy:= dy - ny |
|
1142 |
end; |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
1143 |
|
557 | 1144 |
Gear^.Timer:= cSorterWorkTime; |
351 | 1145 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
143 | 1146 |
currsorter:= Gear |
49 | 1147 |
end; |
1148 |
||
79 | 1149 |
//////////////////////////////////////////////////////////////////////////////// |
854 | 1150 |
procedure doStepIdle(Gear: PGear); |
1151 |
begin |
|
1152 |
AllInactive:= false; |
|
925 | 1153 |
dec(Gear^.Timer); |
854 | 1154 |
if Gear^.Timer = 0 then |
1155 |
begin |
|
1156 |
DeleteGear(Gear); |
|
1157 |
AfterAttack |
|
1158 |
end |
|
1159 |
end; |
|
1160 |
||
79 | 1161 |
procedure doStepShover(Gear: PGear); |
1162 |
var HHGear: PGear; |
|
1163 |
begin |
|
351 | 1164 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1165 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1166 |
DeleteCI(HHGear); |
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1167 |
|
79 | 1168 |
AmmoShove(Gear, 30, 115); |
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1169 |
|
351 | 1170 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
854 | 1171 |
Gear^.Timer:= 250; |
1172 |
Gear^.doStep:= @doStepIdle |
|
79 | 1173 |
end; |
1174 |
||
1175 |
//////////////////////////////////////////////////////////////////////////////// |
|
925 | 1176 |
procedure doStepWhip(Gear: PGear); |
1177 |
var HHGear: PGear; |
|
1178 |
i: LongInt; |
|
1179 |
begin |
|
1180 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1181 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1182 |
DeleteCI(HHGear); |
925 | 1183 |
|
1184 |
for i:= 0 to 3 do |
|
1185 |
begin |
|
1186 |
AmmoShove(Gear, 30, 25); |
|
1187 |
Gear^.X:= Gear^.X + Gear^.dX * 5 |
|
1188 |
end; |
|
1189 |
||
1190 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
|
1191 |
Gear^.Timer:= 250; |
|
1192 |
Gear^.doStep:= @doStepIdle |
|
1193 |
end; |
|
1194 |
||
1195 |
//////////////////////////////////////////////////////////////////////////////// |
|
79 | 1196 |
procedure doStepFlame(Gear: PGear); |
1197 |
begin |
|
1198 |
AllInactive:= false; |
|
1433 | 1199 |
|
79 | 1200 |
if not TestCollisionYwithGear(Gear, 1) then |
1133 | 1201 |
begin |
1586 | 1202 |
if hwAbs(Gear^.dX) > _0_01 then |
1203 |
Gear^.dX:= Gear^.dX * _0_995; |
|
1297 | 1204 |
|
1133 | 1205 |
Gear^.dY:= Gear^.dY + cGravity; |
1830 | 1206 |
if hwAbs(Gear^.dY) > _0_2 then Gear^.dY:= Gear^.dY * _0_995; |
1297 | 1207 |
|
1830 | 1208 |
Gear^.X:= Gear^.X + Gear^.dX + cWindSpeed * 640; |
1133 | 1209 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
1297 | 1210 |
|
1417 | 1211 |
if not (hwRound(Gear^.Y) < cWaterLine) then |
1133 | 1212 |
begin |
1213 |
DeleteGear(Gear); |
|
1214 |
exit |
|
1215 |
end |
|
1216 |
end else begin |
|
1217 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
|
1218 |
else begin |
|
1586 | 1219 |
Gear^.Radius:= 9; |
1220 |
AmmoShove(Gear, 4, 100); |
|
1297 | 1221 |
Gear^.Radius:= 1; |
1222 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 4, EXPLNoDamage); |
|
1133 | 1223 |
dec(Gear^.Health); |
1586 | 1224 |
Gear^.Timer:= 450 - Gear^.Tag * 8 |
1133 | 1225 |
end |
1226 |
end; |
|
79 | 1227 |
|
1295 | 1228 |
//if (((GameTicks div 8) mod 64) = Gear^.Tag) then |
1229 |
// AmmoFlameWork(Gear); |
|
79 | 1230 |
|
351 | 1231 |
if Gear^.Health = 0 then |
1133 | 1232 |
DeleteGear(Gear) |
79 | 1233 |
end; |
82 | 1234 |
|
1235 |
//////////////////////////////////////////////////////////////////////////////// |
|
1236 |
procedure doStepFirePunchWork(Gear: PGear); |
|
1237 |
var HHGear: PGear; |
|
1238 |
begin |
|
1239 |
AllInactive:= false; |
|
351 | 1240 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
1133 | 1241 |
begin |
1242 |
DeleteGear(Gear); |
|
1243 |
AfterAttack; |
|
1244 |
exit |
|
1245 |
end; |
|
82 | 1246 |
|
351 | 1247 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1248 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
1133 | 1249 |
begin |
1250 |
Gear^.Tag:= hwRound(HHGear^.Y); |
|
1251 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
|
1252 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1253 |
Gear^.Y:= HHGear^.Y; |
|
1254 |
AmmoShove(Gear, 30, 40); |
|
1255 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
|
1256 |
end; |
|
351 | 1257 |
|
1258 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1259 |
if not (HHGear^.dY.isNegative) then |
|
1133 | 1260 |
begin |
1261 |
HHGear^.State:= HHGear^.State or gstMoving; |
|
1262 |
DeleteGear(Gear); |
|
1263 |
AfterAttack; |
|
1264 |
exit |
|
1265 |
end; |
|
351 | 1266 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1267 |
end; |
1268 |
||
1269 |
procedure doStepFirePunch(Gear: PGear); |
|
1270 |
var HHGear: PGear; |
|
1271 |
begin |
|
1272 |
AllInactive:= false; |
|
351 | 1273 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1274 |
DeleteCI(HHGear); |
498 | 1275 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1276 |
HHGear^.dX:= SignAs(cLittle, Gear^.dX); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1277 |
|
351 | 1278 |
HHGear^.dY:= - _0_3; |
82 | 1279 |
|
351 | 1280 |
Gear^.X:= HHGear^.X; |
979
edb8f208c1d9
Fix firepunch direction when attacking from high jump
unc0rr
parents:
974
diff
changeset
|
1281 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
351 | 1282 |
Gear^.dY:= - _0_9; |
1283 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1284 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
1279 | 1285 |
|
1669 | 1286 |
PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false, PHedgehog(HHGear^.Hedgehog)^.Team^.voicepack) |
82 | 1287 |
end; |
1288 |
||
263 | 1289 |
//////////////////////////////////////////////////////////////////////////////// |
1290 |
||
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1291 |
procedure doStepParachuteWork(Gear: PGear); |
211 | 1292 |
var HHGear: PGear; |
1293 |
begin |
|
351 | 1294 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
82 | 1295 |
|
516 | 1296 |
inc(Gear^.Timer); |
1297 |
||
212 | 1298 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1299 |
or ((HHGear^.State and gstHHDriven) = 0) |
1300 |
or CheckGearDrowning(HHGear) |
|
1301 |
or ((Gear^.Message and gm_Attack) <> 0) then |
|
1302 |
begin |
|
1303 |
with HHGear^ do |
|
1304 |
begin |
|
1305 |
Message:= 0; |
|
1306 |
SetLittle(dX); |
|
1307 |
dY:= _0; |
|
1308 |
State:= State or gstMoving; |
|
1309 |
end; |
|
1310 |
DeleteGear(Gear); |
|
1311 |
exit |
|
1312 |
end; |
|
211 | 1313 |
|
351 | 1314 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1133 | 1315 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
211 | 1316 |
|
351 | 1317 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1318 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1319 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1320 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1321 |
|
351 | 1322 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1323 |
Gear^.X:= HHGear^.X; |
1324 |
Gear^.Y:= HHGear^.Y |
|
263 | 1325 |
end; |
211 | 1326 |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1327 |
procedure doStepParachute(Gear: PGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1328 |
var HHGear: PGear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1329 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1330 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1331 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1332 |
DeleteCI(HHGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1333 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1334 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1335 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1336 |
|
931 | 1337 |
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
|
1338 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1339 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1340 |
Gear^.doStep:= @doStepParachuteWork; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1341 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1342 |
Gear^.Message:= HHGear^.Message; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1343 |
doStepParachuteWork(Gear) |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1344 |
end; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1345 |
|
263 | 1346 |
//////////////////////////////////////////////////////////////////////////////// |
1347 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1507 | 1348 |
var i: Longint; |
263 | 1349 |
begin |
1350 |
AllInactive:= false; |
|
498 | 1351 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
1124 | 1352 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1353 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
1124 | 1354 |
begin |
1355 |
dec(Gear^.Health); |
|
1356 |
case Gear^.State of |
|
1357 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1358 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1586 | 1359 |
2: for i:= -19 to 19 do |
1360 |
FollowGear:= AddGear(hwRound(Gear^.X) + i div 3, hwRound(Gear^.Y), gtFlame, 0, _0_001 * i, _0, 0); |
|
1124 | 1361 |
end; |
1362 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
|
1363 |
end; |
|
1364 |
||
1365 |
if (GameTicks and $3F) = 0 then |
|
1366 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1367 |
||
1753 | 1368 |
if (hwRound(Gear^.X) > (LAND_WIDTH+1024)) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1369 |
end; |
1370 |
||
1371 |
procedure doStepAirAttack(Gear: PGear); |
|
1372 |
begin |
|
1373 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1374 |
|
1507 | 1375 |
if Gear^.X.QWordValue = 0 then |
1771 | 1376 |
begin |
1377 |
Gear^.Tag:= 1; |
|
1378 |
Gear^.X:= -_1024; |
|
1379 |
end |
|
1507 | 1380 |
else |
1771 | 1381 |
begin |
1507 | 1382 |
Gear^.Tag:= -1; |
1771 | 1383 |
Gear^.X:= int2hwFloat(LAND_WIDTH + 1024); |
1384 |
end; |
|
1507 | 1385 |
|
1784 | 1386 |
Gear^.Y:= int2hwFloat(topY-300); |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1387 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1388 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1389 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
1133 | 1390 |
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
|
1391 |
|
351 | 1392 |
Gear^.Health:= 6; |
801 | 1393 |
Gear^.doStep:= @doStepAirAttackWork; |
1669 | 1394 |
PlaySound(sndIncoming, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) |
263 | 1395 |
end; |
1396 |
||
1397 |
//////////////////////////////////////////////////////////////////////////////// |
|
1398 |
||
1399 |
procedure doStepAirBomb(Gear: PGear); |
|
1400 |
begin |
|
1401 |
AllInactive:= false; |
|
1402 |
doStepFallingGear(Gear); |
|
351 | 1403 |
if (Gear^.State and gstCollision) <> 0 then |
1133 | 1404 |
begin |
1405 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1406 |
DeleteGear(Gear); |
|
1407 |
exit |
|
1408 |
end; |
|
263 | 1409 |
if (GameTicks and $3F) = 0 then |
1133 | 1410 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1411 |
end; |
409 | 1412 |
|
1413 |
//////////////////////////////////////////////////////////////////////////////// |
|
1414 |
||
1415 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1416 |
var HHGear: PGear; |
1909 | 1417 |
x, y, tx, ty: LongInt; |
409 | 1418 |
begin |
1419 |
AllInactive:= false; |
|
415 | 1420 |
|
1421 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1909 | 1422 |
tx:= TargetPoint.X; |
1423 |
ty:= TargetPoint.Y; |
|
1424 |
x:= hwRound(HHGear^.X); |
|
1425 |
y:= hwRound(HHGear^.Y); |
|
1426 |
||
1427 |
// use a circle instead? |
|
1428 |
if (abs(tx-x) > 256) or |
|
1429 |
(abs(ty-y) > 256) or |
|
1430 |
not TryPlaceOnLand(tx - SpritesData[sprAmGirder].Width div 2, |
|
1431 |
ty - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1432 |
sprAmGirder, Gear^.State, true) then |
1133 | 1433 |
begin |
1434 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1435 |
DeleteGear(Gear); |
|
1909 | 1436 |
isCursorVisible:= true |
1133 | 1437 |
end |
1438 |
else begin |
|
1439 |
DeleteGear(Gear); |
|
1909 | 1440 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
1441 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
1442 |
isCursorVisible:= false |
|
1443 |
end; |
|
1444 |
HHGear^.State:= HHGear^.State and not (gstAttacking or gstAttacked); |
|
1445 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
415 | 1446 |
TargetPoint.X:= NoPointX |
409 | 1447 |
end; |
520 | 1448 |
|
1449 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1450 |
procedure doStepTeleportAfter(Gear: PGear); |
912 | 1451 |
var HHGear: PGear; |
1452 |
begin |
|
1453 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1454 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases |
|
1455 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1456 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1457 |
or CheckGearDrowning(HHGear) then |
1458 |
begin |
|
1459 |
DeleteGear(Gear); |
|
1460 |
AfterAttack |
|
1461 |
end |
|
912 | 1462 |
end; |
1463 |
||
1464 |
procedure doStepTeleportAnim(Gear: PGear); |
|
525 | 1465 |
begin |
853 | 1466 |
inc(Gear^.Timer); |
1467 |
if Gear^.Timer = 65 then |
|
1468 |
begin |
|
1469 |
Gear^.Timer:= 0; |
|
1470 |
inc(Gear^.Pos); |
|
1471 |
if Gear^.Pos = 11 then |
|
912 | 1472 |
Gear^.doStep:= @doStepTeleportAfter |
853 | 1473 |
end |
525 | 1474 |
end; |
520 | 1475 |
|
1476 |
procedure doStepTeleport(Gear: PGear); |
|
1477 |
var HHGear: PGear; |
|
1478 |
begin |
|
1479 |
AllInactive:= false; |
|
1480 |
||
1481 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1482 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1483 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1484 |
sprHHTelepMask, 0, false) then |
|
853 | 1485 |
begin |
1486 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1487 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1488 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1489 |
DeleteGear(Gear); |
|
1490 |
isCursorVisible:= true |
|
1491 |
end |
|
1492 |
else begin |
|
1493 |
DeleteCI(HHGear); |
|
1494 |
SetAllHHToActive; |
|
912 | 1495 |
Gear^.doStep:= @doStepTeleportAnim; |
853 | 1496 |
Gear^.X:= HHGear^.X; |
1497 |
Gear^.Y:= HHGear^.Y; |
|
1498 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1499 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1500 |
HHGear^.State:= HHGear^.State or gstMoving |
|
1501 |
end; |
|
520 | 1502 |
TargetPoint.X:= NoPointX |
1503 |
end; |
|
534 | 1504 |
|
1505 |
//////////////////////////////////////////////////////////////////////////////// |
|
1506 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1507 |
var HHGear: PGear; |
|
1508 |
Msg, State: Longword; |
|
1509 |
begin |
|
1510 |
AllInactive:= false; |
|
1511 |
||
540 | 1512 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
1133 | 1513 |
begin |
1514 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1515 |
Msg:= Gear^.Message and not gm_Switch; |
|
1516 |
DeleteGear(Gear); |
|
1517 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
|
1518 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1519 |
|
1133 | 1520 |
HHGear:= CurrentHedgehog^.Gear; |
1521 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
1522 |
HHGear^.Message:= Msg; |
|
1523 |
exit |
|
1524 |
end; |
|
534 | 1525 |
|
1526 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1133 | 1527 |
begin |
1528 |
HHGear:= CurrentHedgehog^.Gear; |
|
1529 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
|
1530 |
Gear^.Message:= Gear^.Message and not gm_Switch; |
|
1531 |
State:= HHGear^.State; |
|
1532 |
HHGear^.State:= 0; |
|
1533 |
HHGear^.Active:= false; |
|
1534 |
HHGear^.Z:= cHHZ; |
|
1535 |
RemoveGearFromList(HHGear); |
|
1536 |
InsertGearToList(HHGear); |
|
534 | 1537 |
|
1133 | 1538 |
repeat |
1539 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
|
1540 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
|
652 | 1541 |
|
1133 | 1542 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
534 | 1543 |
|
1133 | 1544 |
HHGear:= CurrentHedgehog^.Gear; |
1545 |
HHGear^.State:= State; |
|
1546 |
HHGear^.Active:= true; |
|
1547 |
FollowGear:= HHGear; |
|
1548 |
HHGear^.Z:= cCurrHHZ; |
|
1549 |
RemoveGearFromList(HHGear); |
|
1550 |
InsertGearToList(HHGear); |
|
1551 |
Gear^.X:= HHGear^.X; |
|
1552 |
Gear^.Y:= HHGear^.Y |
|
1553 |
end; |
|
534 | 1554 |
end; |
1555 |
||
1556 |
procedure doStepSwitcher(Gear: PGear); |
|
1557 |
var HHGear: PGear; |
|
1558 |
begin |
|
1559 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1560 |
||
1561 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1562 |
with HHGear^ do |
|
1133 | 1563 |
begin |
1564 |
State:= State and not gstAttacking; |
|
1565 |
Message:= Message and not gm_Attack |
|
1566 |
end |
|
534 | 1567 |
end; |
924 | 1568 |
|
1569 |
//////////////////////////////////////////////////////////////////////////////// |
|
1570 |
procedure doStepMortar(Gear: PGear); |
|
1571 |
var dX, dY: hwFloat; |
|
1572 |
i: LongInt; |
|
963 | 1573 |
dxn, dyn: boolean; |
924 | 1574 |
begin |
1575 |
AllInactive:= false; |
|
963 | 1576 |
dxn:= Gear^.dX.isNegative; |
1577 |
dyn:= Gear^.dY.isNegative; |
|
1578 |
||
924 | 1579 |
doStepFallingGear(Gear); |
1580 |
if (Gear^.State and gstCollision) <> 0 then |
|
1581 |
begin |
|
1582 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
963 | 1583 |
|
1584 |
Gear^.dX.isNegative:= not dxn; |
|
1585 |
Gear^.dY.isNegative:= not dyn; |
|
924 | 1586 |
for i:= 0 to 4 do |
1587 |
begin |
|
963 | 1588 |
dX:= Gear^.dX + (GetRandom - _0_5) * _0_03; |
1589 |
dY:= Gear^.dY + (GetRandom - _0_5) * _0_03; |
|
1273 | 1590 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); |
924 | 1591 |
end; |
1592 |
||
1593 |
DeleteGear(Gear); |
|
1594 |
exit |
|
1595 |
end; |
|
963 | 1596 |
|
924 | 1597 |
if (GameTicks and $3F) = 0 then |
1598 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
1599 |
end; |
|
984 | 1600 |
|
1601 |
//////////////////////////////////////////////////////////////////////////////// |
|
1602 |
procedure doStepKamikazeWork(Gear: PGear); |
|
1603 |
const upd: Longword = 0; |
|
987 | 1604 |
var i: LongWord; |
984 | 1605 |
HHGear: PGear; |
1606 |
begin |
|
1607 |
AllInactive:= false; |
|
1608 |
||
1609 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1610 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1611 |
DeleteCI(HHGear); |
|
1612 |
||
1613 |
i:= 2; |
|
1614 |
repeat |
|
1615 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
1616 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
1617 |
HHGear^.X:= Gear^.X; |
|
1618 |
HHGear^.Y:= Gear^.Y; |
|
1619 |
||
1620 |
inc(Gear^.Damage, 2); |
|
1621 |
||
1200 | 1622 |
// if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
1623 |
// or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); |
|
984 | 1624 |
|
1625 |
dec(i) |
|
1626 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
|
1627 |
||
1628 |
inc(upd); |
|
1629 |
if upd > 3 then |
|
1630 |
begin |
|
987 | 1631 |
if Gear^.Health < 1500 then Gear^.Pos:= 2; |
1632 |
||
984 | 1633 |
AmmoShove(Gear, 30, 40); |
1634 |
||
1635 |
DrawTunnel(HHGear^.X - HHGear^.dX * 10, |
|
1200 | 1636 |
HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2, |
984 | 1637 |
HHGear^.dX, |
1638 |
HHGear^.dY, |
|
1639 |
20 + cHHRadius * 2, |
|
1200 | 1640 |
cHHRadius * 2 + 6); |
984 | 1641 |
|
1642 |
upd:= 0 |
|
1643 |
end; |
|
1644 |
||
1645 |
if Gear^.Health < Gear^.Damage then |
|
1646 |
begin |
|
1647 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1648 |
AfterAttack; |
|
1649 |
DeleteGear(Gear); |
|
1650 |
DeleteGear(HHGear); |
|
1651 |
end else |
|
1652 |
begin |
|
1653 |
dec(Gear^.Health, Gear^.Damage); |
|
1654 |
Gear^.Damage:= 0 |
|
1655 |
end |
|
1656 |
end; |
|
1657 |
||
987 | 1658 |
procedure doStepKamikazeIdle(Gear: PGear); |
1659 |
begin |
|
1660 |
AllInactive:= false; |
|
1661 |
dec(Gear^.Timer); |
|
1662 |
if Gear^.Timer = 0 then |
|
1663 |
begin |
|
1664 |
Gear^.Pos:= 1; |
|
1669 | 1665 |
PlaySound(sndKamikaze, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
987 | 1666 |
Gear^.doStep:= @doStepKamikazeWork |
1667 |
end |
|
1668 |
end; |
|
1669 |
||
984 | 1670 |
procedure doStepKamikaze(Gear: PGear); |
1671 |
var HHGear: PGear; |
|
1672 |
begin |
|
1673 |
AllInactive:= false; |
|
1674 |
||
1675 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1676 |
||
1677 |
HHGear^.dX:= Gear^.dX; |
|
1678 |
HHGear^.dY:= Gear^.dY; |
|
1679 |
||
1680 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
|
1681 |
Gear^.dY:= - _0_9; |
|
1682 |
||
987 | 1683 |
Gear^.Timer:= 550; |
1684 |
||
1685 |
Gear^.doStep:= @doStepKamikazeIdle |
|
984 | 1686 |
end; |
1687 |
||
1103 | 1688 |
//////////////////////////////////////////////////////////////////////////////// |
1689 |
const cakeh = 27; |
|
1110 | 1690 |
cakeDmg = 75; |
1103 | 1691 |
var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; end; |
1692 |
CakeI: Longword; |
|
1693 |
||
1110 | 1694 |
procedure doStepCakeExpl(Gear: PGear); |
1695 |
begin |
|
1696 |
inc(Gear^.Tag); |
|
1697 |
if Gear^.Tag < 2250 then exit; |
|
1698 |
||
1699 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, EXPLAutoSound); |
|
1700 |
AfterAttack; |
|
1701 |
DeleteGear(Gear) |
|
1702 |
end; |
|
1703 |
||
1109 | 1704 |
procedure doStepCakeDown(Gear: PGear); |
1133 | 1705 |
var gi: PGear; |
1706 |
dmg: LongInt; |
|
1109 | 1707 |
begin |
1708 |
AllInactive:= false; |
|
1709 |
||
1710 |
inc(Gear^.Tag); |
|
1711 |
if Gear^.Tag < 100 then exit; |
|
1712 |
Gear^.Tag:= 0; |
|
1713 |
||
1714 |
if Gear^.Pos = 0 then |
|
1715 |
begin |
|
1110 | 1716 |
gi:= GearsList; |
1717 |
while gi <> nil do |
|
1718 |
begin |
|
1719 |
dmg:= cakeDmg * 2 - hwRound(Distance(gi^.X - Gear^.X, gi^.Y - Gear^.Y)); |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1720 |
if (dmg > 1) and (gi^.Kind = gtHedgehog) then |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1721 |
if (CurrentHedgehog^.Gear = gi) and (not gi^.Invulnerable) then |
1867 | 1722 |
gi^.State:= gi^.State or gstLoser |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1723 |
else |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1724 |
gi^.State:= gi^.State or gstWinner; |
1110 | 1725 |
gi:= gi^.NextGear |
1726 |
end; |
|
1727 |
Gear^.doStep:= @doStepCakeExpl; |
|
1669 | 1728 |
PlaySound(sndCake, false, nil) |
1109 | 1729 |
end else dec(Gear^.Pos) |
1730 |
end; |
|
1731 |
||
1732 |
||
1089 | 1733 |
procedure doStepCakeWork(Gear: PGear); |
1734 |
const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0)); |
|
1735 |
var xx, yy, xxn, yyn: LongInt; |
|
1736 |
da: LongInt; |
|
1103 | 1737 |
tdx, tdy: hwFloat; |
1089 | 1738 |
|
1739 |
procedure PrevAngle; |
|
1740 |
begin |
|
1133 | 1741 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 - dA) mod 4 |
1089 | 1742 |
end; |
1743 |
||
1744 |
procedure NextAngle; |
|
1745 |
begin |
|
1133 | 1746 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 + dA) mod 4 |
1089 | 1747 |
end; |
1748 |
||
1088 | 1749 |
begin |
1089 | 1750 |
inc(Gear^.Tag); |
1108 | 1751 |
if Gear^.Tag < 7 then exit; |
1089 | 1752 |
|
1753 |
dA:= hwSign(Gear^.dX); |
|
1754 |
xx:= dirs[Gear^.Angle].x; |
|
1755 |
yy:= dirs[Gear^.Angle].y; |
|
1133 | 1756 |
xxn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x; |
1757 |
yyn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y; |
|
1089 | 1758 |
|
1759 |
if (xx = 0) then |
|
1760 |
if TestCollisionYwithGear(Gear, yy) then |
|
1761 |
PrevAngle |
|
1762 |
else begin |
|
1763 |
Gear^.Tag:= 0; |
|
1764 |
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
|
1765 |
if not TestCollisionXwithGear(Gear, xxn) then |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1766 |
begin |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1767 |
Gear^.X:= Gear^.X + int2hwFloat(xxn); |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1768 |
NextAngle |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1769 |
end; |
1089 | 1770 |
end; |
1771 |
||
1772 |
if (yy = 0) then |
|
1773 |
if TestCollisionXwithGear(Gear, xx) then |
|
1774 |
PrevAngle |
|
1775 |
else begin |
|
1776 |
Gear^.Tag:= 0; |
|
1777 |
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
|
1778 |
if not TestCollisionYwithGear(Gear, yyn) then |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1779 |
begin |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1780 |
Gear^.Y:= Gear^.Y + int2hwFloat(yyn); |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1781 |
NextAngle |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1782 |
end; |
1089 | 1783 |
end; |
1784 |
||
1103 | 1785 |
if Gear^.Tag = 0 then |
1786 |
begin |
|
1787 |
CakeI:= (CakeI + 1) mod cakeh; |
|
1788 |
tdx:= CakePoints[CakeI].x - Gear^.X; |
|
1789 |
tdy:= - CakePoints[CakeI].y + Gear^.Y; |
|
1790 |
CakePoints[CakeI].x:= Gear^.X; |
|
1791 |
CakePoints[CakeI].y:= Gear^.Y; |
|
1792 |
Gear^.DirAngle:= DxDy2Angle(tdx, tdy); |
|
1793 |
end; |
|
1794 |
||
1089 | 1795 |
dec(Gear^.Health); |
1090 | 1796 |
if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then |
1089 | 1797 |
begin |
1109 | 1798 |
FollowGear:= Gear; |
1799 |
Gear^.doStep:= @doStepCakeDown |
|
1089 | 1800 |
end |
1088 | 1801 |
end; |
1089 | 1802 |
|
1103 | 1803 |
procedure doStepCakeUp(Gear: PGear); |
1804 |
var i: Longword; |
|
1805 |
begin |
|
1806 |
AllInactive:= false; |
|
1807 |
||
1108 | 1808 |
inc(Gear^.Tag); |
1109 | 1809 |
if Gear^.Tag < 100 then exit; |
1108 | 1810 |
Gear^.Tag:= 0; |
1811 |
||
1109 | 1812 |
if Gear^.Pos = 6 then |
1103 | 1813 |
begin |
1814 |
for i:= 0 to Pred(cakeh) do |
|
1815 |
begin |
|
1816 |
CakePoints[i].x:= Gear^.X; |
|
1817 |
CakePoints[i].y:= Gear^.Y |
|
1818 |
end; |
|
1819 |
CakeI:= 0; |
|
1820 |
Gear^.doStep:= @doStepCakeWork |
|
1109 | 1821 |
end else inc(Gear^.Pos) |
1103 | 1822 |
end; |
1823 |
||
1089 | 1824 |
procedure doStepCakeFall(Gear: PGear); |
1825 |
begin |
|
1826 |
AllInactive:= false; |
|
1827 |
||
1828 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1829 |
if TestCollisionYwithGear(Gear, 1) then |
|
1103 | 1830 |
Gear^.doStep:= @doStepCakeUp |
1089 | 1831 |
else |
1832 |
begin |
|
1833 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1834 |
if CheckGearDrowning(Gear) then AfterAttack |
|
1835 |
end |
|
1836 |
end; |
|
1837 |
||
1838 |
procedure doStepCake(Gear: PGear); |
|
1839 |
var HHGear: PGear; |
|
1840 |
begin |
|
1841 |
AllInactive:= false; |
|
1842 |
||
1843 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1103 | 1844 |
HHGear^.Message:= HHGear^.Message and (not gm_Attack); |
1089 | 1845 |
DeleteCI(HHGear); |
1846 |
||
1106 | 1847 |
FollowGear:= Gear; |
1848 |
||
1089 | 1849 |
Gear^.doStep:= @doStepCakeFall |
1850 |
end; |
|
1851 |
||
1259 | 1852 |
//////////////////////////////////////////////////////////////////////////////// |
1284 | 1853 |
procedure doStepSeductionWork(Gear: PGear); |
1854 |
var x, y: LongInt; |
|
1259 | 1855 |
begin |
1856 |
AllInactive:= false; |
|
1284 | 1857 |
|
1858 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1859 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1860 |
x:= hwRound(Gear^.X); |
|
1861 |
y:= hwRound(Gear^.Y); |
|
1259 | 1862 |
|
1753 | 1863 |
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) then |
1284 | 1864 |
if (Land[y, x] <> 0) then |
1865 |
begin |
|
1866 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; |
|
1867 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative; |
|
1286 | 1868 |
Gear^.dX:= Gear^.dX * _1_5; |
1869 |
Gear^.dY:= Gear^.dY * _1_5 - _0_3; |
|
1284 | 1870 |
AmmoShove(Gear, 0, 40); |
1286 | 1871 |
AfterAttack; |
1284 | 1872 |
DeleteGear(Gear) |
1873 |
end |
|
1874 |
else |
|
1875 |
else |
|
1286 | 1876 |
begin |
1877 |
AfterAttack; |
|
1284 | 1878 |
DeleteGear(Gear) |
1286 | 1879 |
end |
1880 |
end; |
|
1881 |
||
1882 |
procedure doStepSeductionWear(Gear: PGear); |
|
1883 |
begin |
|
1884 |
AllInactive:= false; |
|
1885 |
inc(Gear^.Timer); |
|
1886 |
if Gear^.Timer > 250 then |
|
1887 |
begin |
|
1888 |
Gear^.Timer:= 0; |
|
1388 | 1889 |
inc(Gear^.Pos); |
1890 |
if Gear^.Pos = 5 then |
|
1669 | 1891 |
PlaySound(sndYoohoo, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) |
1286 | 1892 |
end; |
1367 | 1893 |
|
1894 |
if Gear^.Pos = 14 then |
|
1286 | 1895 |
Gear^.doStep:= @doStepSeductionWork |
1259 | 1896 |
end; |
1284 | 1897 |
|
1898 |
procedure doStepSeduction(Gear: PGear); |
|
1899 |
begin |
|
1900 |
AllInactive:= false; |
|
1901 |
DeleteCI(PHedgehog(Gear^.Hedgehog)^.Gear); |
|
1286 | 1902 |
Gear^.doStep:= @doStepSeductionWear |
1284 | 1903 |
end; |
1298 | 1904 |
|
1905 |
//////////////////////////////////////////////////////////////////////////////// |
|
1906 |
procedure doStepWaterUp(Gear: PGear); |
|
1907 |
var i: LongWord; |
|
1908 |
begin |
|
1909 |
AllInactive:= false; |
|
1910 |
||
1911 |
inc(Gear^.Timer); |
|
1912 |
if Gear^.Timer = 17 then |
|
1913 |
Gear^.Timer:= 0 |
|
1914 |
else |
|
1915 |
exit; |
|
1916 |
||
1917 |
if cWaterLine > 0 then |
|
1918 |
begin |
|
1919 |
dec(cWaterLine); |
|
1760 | 1920 |
for i:= 0 to LAND_WIDTH - 1 do |
1298 | 1921 |
Land[cWaterLine, i]:= 0; |
1922 |
SetAllToActive |
|
1923 |
end; |
|
1924 |
||
1925 |
inc(Gear^.Tag); |
|
1343 | 1926 |
if (Gear^.Tag = 47) or (cWaterLine = 0) then |
1298 | 1927 |
DeleteGear(Gear) |
1928 |
end; |
|
1573 | 1929 |
|
1930 |
//////////////////////////////////////////////////////////////////////////////// |
|
1590 | 1931 |
procedure doStepDrillDrilling(Gear: PGear); |
1633 | 1932 |
var t: PGearArray; |
1933 |
ox, oy: hwFloat; |
|
1573 | 1934 |
begin |
1590 | 1935 |
AllInactive:= false; |
1936 |
||
1633 | 1937 |
if (Gear^.Timer > 0) and ((Gear^.Timer mod 10) = 0) then |
1590 | 1938 |
begin |
1573 | 1939 |
ox:= Gear^.X; |
1940 |
oy:= Gear^.Y; |
|
1941 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1942 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1943 |
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6); |
|
1944 |
CheckGearDrowning(Gear); |
|
1590 | 1945 |
end; |
1946 |
||
1633 | 1947 |
t:= CheckGearsCollision(Gear); //fixes drill not exploding when touching HH bug |
1590 | 1948 |
if (Gear^.Timer = 0) |
1633 | 1949 |
or (t^.Count <> 0) |
1590 | 1950 |
or (not TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) |
1784 | 1951 |
and not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) |
1952 |
or (Land[hwRound(Gear^.Y), hwRound(Gear^.X)] = COLOR_INDESTRUCTIBLE) then |
|
1590 | 1953 |
begin //out of time or exited ground |
1954 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1955 |
DeleteGear(Gear); |
|
1956 |
exit |
|
1957 |
end; |
|
1958 |
||
1959 |
dec(Gear^.Timer); |
|
1573 | 1960 |
end; |
1961 |
||
1962 |
procedure doStepDrill(Gear: PGear); |
|
1590 | 1963 |
var t: PGearArray; |
1633 | 1964 |
oldDx, oldDy: hwFloat; |
1965 |
t2: hwFloat; |
|
1573 | 1966 |
begin |
1590 | 1967 |
AllInactive:= false; |
1573 | 1968 |
|
1590 | 1969 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
1970 |
oldDx:= Gear^.dX; |
|
1971 |
oldDy:= Gear^.dY; |
|
1972 |
||
1973 |
doStepFallingGear(Gear); |
|
1974 |
||
1975 |
if (GameTicks and $3F) = 0 then |
|
1976 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1573 | 1977 |
|
1633 | 1978 |
if ((Gear^.State and gstCollision) <> 0) then begin //hit |
1590 | 1979 |
Gear^.dX:= oldDx; |
1980 |
Gear^.dY:= oldDy; |
|
1633 | 1981 |
|
1590 | 1982 |
t:= CheckGearsCollision(Gear); |
1633 | 1983 |
if (t^.Count = 0) then begin //hit the ground not the HH |
1984 |
t2 := _0_5 / Distance(Gear^.dX, Gear^.dY); |
|
1985 |
Gear^.dX:= Gear^.dX * t2; |
|
1986 |
Gear^.dY:= Gear^.dY * t2; |
|
1987 |
end else begin //explode right on contact with HH |
|
1988 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1989 |
DeleteGear(Gear); |
|
1990 |
exit; |
|
1991 |
end; |
|
1992 |
||
1590 | 1993 |
Gear^.doStep:= @doStepDrillDrilling; |
1633 | 1994 |
dec(Gear^.Timer) |
1590 | 1995 |
end |
1996 |
end; |
|
1601 | 1997 |
|
1633 | 1998 |
//////////////////////////////////////////////////////////////////////////////// |
1601 | 1999 |
procedure doStepBallgunWork(Gear: PGear); |
2000 |
var HHGear: PGear; |
|
1630 | 2001 |
rx, ry: hwFloat; |
1601 | 2002 |
begin |
2003 |
AllInactive:= false; |
|
2004 |
dec(Gear^.Timer); |
|
2005 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2006 |
HedgehogChAngle(HHGear); |
|
2007 |
if (Gear^.Timer mod 100) = 0 then |
|
2008 |
begin |
|
1630 | 2009 |
rx:= rndSign(getRandom * _0_1); |
2010 |
ry:= rndSign(getRandom * _0_1); |
|
1631
6e313b3818ef
Remove debug stuff, ballgun 64but incompatibility fixed in previous revision
unc0rr
parents:
1630
diff
changeset
|
2011 |
|
1630 | 2012 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBall, 0, |
2013 |
SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, |
|
2014 |
AngleCos(HHGear^.Angle) * ( - _0_8) + ry, |
|
2015 |
0); |
|
1601 | 2016 |
|
1669 | 2017 |
PlaySound(sndGun, false, nil); |
1601 | 2018 |
end; |
2019 |
||
1643 | 2020 |
if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then |
1601 | 2021 |
begin |
2022 |
DeleteGear(Gear); |
|
1643 | 2023 |
AfterAttack |
2024 |
end |
|
1601 | 2025 |
end; |
2026 |
||
2027 |
procedure doStepBallgun(Gear: PGear); |
|
2028 |
var HHGear: PGear; |
|
2029 |
begin |
|
2030 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2031 |
HHGear^.Message:= HHGear^.Message and not (gm_Up or gm_Down); |
|
2032 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
|
2033 |
Gear^.doStep:= @doStepBallgunWork |
|
1633 | 2034 |
end; |
1689 | 2035 |
|
1696 | 2036 |
//////////////////////////////////////////////////////////////////////////////// |
1689 | 2037 |
procedure doStepRCPlaneWork(Gear: PGear); |
2038 |
const cAngleSpeed = 3; |
|
2039 |
var HHGear: PGear; |
|
2040 |
i: LongInt; |
|
2041 |
dX, dY: hwFloat; |
|
2042 |
fChanged: boolean; |
|
2043 |
trueAngle: Longword; |
|
2044 |
t: PGear; |
|
2045 |
begin |
|
2046 |
AllInactive:= false; |
|
2047 |
||
1696 | 2048 |
if Gear^.Timer > 0 then dec(Gear^.Timer); |
1689 | 2049 |
|
2050 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2051 |
FollowGear:= Gear; |
|
2052 |
||
2053 |
fChanged:= false; |
|
1696 | 2054 |
if ((HHGear^.State and gstHHDriven) = 0) or (Gear^.Timer = 0) then |
1689 | 2055 |
begin |
2056 |
fChanged:= true; |
|
1696 | 2057 |
if Gear^.Angle > 2048 then dec(Gear^.Angle) else |
2058 |
if Gear^.Angle < 2048 then inc(Gear^.Angle) else fChanged:= false |
|
2059 |
end |
|
2060 |
else |
|
2061 |
begin |
|
2062 |
if ((Gear^.Message and gm_Left) <> 0) then |
|
2063 |
begin |
|
2064 |
fChanged:= true; |
|
2065 |
Gear^.Angle:= (Gear^.Angle + (4096 - cAngleSpeed)) mod 4096 |
|
2066 |
end; |
|
1689 | 2067 |
|
1696 | 2068 |
if ((Gear^.Message and gm_Right) <> 0) then |
2069 |
begin |
|
2070 |
fChanged:= true; |
|
2071 |
Gear^.Angle:= (Gear^.Angle + cAngleSpeed) mod 4096 |
|
2072 |
end |
|
1689 | 2073 |
end; |
2074 |
||
2075 |
if fChanged then |
|
2076 |
begin |
|
2077 |
Gear^.dX.isNegative:= (Gear^.Angle > 2048); |
|
2078 |
if Gear^.dX.isNegative then |
|
2079 |
trueAngle:= 4096 - Gear^.Angle |
|
2080 |
else |
|
2081 |
trueAngle:= Gear^.Angle; |
|
2082 |
||
2083 |
Gear^.dX:= SignAs(AngleSin(trueAngle), Gear^.dX) * _0_25; |
|
2084 |
Gear^.dY:= AngleCos(trueAngle) * -_0_25; |
|
2085 |
end; |
|
2086 |
||
2087 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
2088 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
2089 |
||
2090 |
if (GameTicks and $FF) = 0 then |
|
1698 | 2091 |
if Gear^.Timer < 3500 then |
1696 | 2092 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0) |
2093 |
else |
|
2094 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1689 | 2095 |
|
1696 | 2096 |
if ((HHGear^.Message and gm_Attack) <> 0) and (Gear^.Health <> 0) then |
1689 | 2097 |
begin |
2098 |
HHGear^.Message := HHGear^.Message and not gm_Attack; |
|
1708 | 2099 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * _0_5, 0); |
1689 | 2100 |
dec(Gear^.Health) |
1712 | 2101 |
end; |
2102 |
||
2103 |
if ((HHGear^.Message and gm_LJump) <> 0) |
|
2104 |
and ((Gear^.State and gsttmpFlag) = 0) then |
|
2105 |
begin |
|
2106 |
Gear^.State:= Gear^.State or gsttmpFlag; |
|
2107 |
PauseMusic; |
|
2108 |
playSound(sndRideOfTheValkyries, false, nil); |
|
2109 |
end; |
|
1689 | 2110 |
|
2111 |
// pickup bonuses |
|
2112 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
2113 |
if t <> nil then |
|
2114 |
PickUp(HHGear, t); |
|
2115 |
||
2116 |
CheckCollision(Gear); |
|
2117 |
||
1712 | 2118 |
if ((Gear^.State and gstCollision) <> 0) |
2119 |
or CheckGearDrowning(Gear) then |
|
1689 | 2120 |
begin |
1712 | 2121 |
StopSound(sndRCPlane); |
2122 |
StopSound(sndRideOfTheValkyries); |
|
2123 |
ResumeMusic; |
|
2124 |
||
2125 |
if ((Gear^.State and gstCollision) <> 0) then |
|
1689 | 2126 |
begin |
1712 | 2127 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound); |
1714 | 2128 |
for i:= 0 to 32 do |
1712 | 2129 |
begin |
1714 | 2130 |
dX:= AngleCos(i * 64) * _0_5 * (GetRandom + _1); |
2131 |
dY:= AngleSin(i * 64) * _0_5 * (GetRandom + _1); |
|
1712 | 2132 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); |
2133 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, -dY, 0); |
|
2134 |
end; |
|
2135 |
DeleteGear(Gear) |
|
1689 | 2136 |
end; |
1713 | 2137 |
|
1689 | 2138 |
AfterAttack; |
1713 | 2139 |
CurAmmoGear:= nil; |
1697 | 2140 |
TurnTimeLeft:= 14 * 125; |
1712 | 2141 |
HHGear^.Message:= 0; |
1697 | 2142 |
ParseCommand('/taunt '#1, true) |
2143 |
end |
|
1689 | 2144 |
end; |
2145 |
||
2146 |
procedure doStepRCPlane(Gear: PGear); |
|
2147 |
var HHGear: PGear; |
|
2148 |
begin |
|
2149 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2150 |
HHGear^.Message:= 0; |
|
2151 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
|
2152 |
Gear^.Angle:= HHGear^.Angle; |
|
1696 | 2153 |
Gear^.Tag:= hwSign(HHGear^.dX); |
1689 | 2154 |
if HHGear^.dX.isNegative then Gear^.Angle:= 4096 - Gear^.Angle; |
2155 |
Gear^.doStep:= @doStepRCPlaneWork |
|
1712 | 2156 |
end; |