author | unc0rr |
Mon, 23 Mar 2009 19:03:51 +0000 | |
changeset 1915 | c357f5b55320 |
parent 1914 | aab686a4e0c5 |
child 1918 | 975d5061712f |
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; |
1915 | 1417 |
x, y, tx, ty: hwFloat; |
409 | 1418 |
begin |
1419 |
AllInactive:= false; |
|
415 | 1420 |
|
1421 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1915 | 1422 |
tx:= int2hwFloat(TargetPoint.X); |
1423 |
ty:= int2hwFloat(TargetPoint.Y); |
|
1424 |
x:= HHGear^.X; |
|
1425 |
y:= HHGear^.Y; |
|
1909 | 1426 |
|
1915 | 1427 |
if (Distance(tx - x, ty - y) > _256) or |
1428 |
not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
|
1429 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1430 |
sprAmGirder, Gear^.State, true) then |
1133 | 1431 |
begin |
1914 | 1432 |
PlaySound(sndDenied, false, nil); |
1433 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1434 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1133 | 1435 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
1914 | 1436 |
isCursorVisible:= true; |
1437 |
DeleteGear(Gear) |
|
1133 | 1438 |
end |
1439 |
else begin |
|
1914 | 1440 |
PlaySound(sndPlaced, false, nil); |
1133 | 1441 |
DeleteGear(Gear); |
1909 | 1442 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
1914 | 1443 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) |
1444 |
end; |
|
1445 |
||
1909 | 1446 |
HHGear^.State:= HHGear^.State and not (gstAttacking or gstAttacked); |
1447 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
415 | 1448 |
TargetPoint.X:= NoPointX |
409 | 1449 |
end; |
520 | 1450 |
|
1451 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1452 |
procedure doStepTeleportAfter(Gear: PGear); |
912 | 1453 |
var HHGear: PGear; |
1454 |
begin |
|
1455 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1456 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases |
|
1457 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1458 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1459 |
or CheckGearDrowning(HHGear) then |
1460 |
begin |
|
1461 |
DeleteGear(Gear); |
|
1462 |
AfterAttack |
|
1463 |
end |
|
912 | 1464 |
end; |
1465 |
||
1466 |
procedure doStepTeleportAnim(Gear: PGear); |
|
525 | 1467 |
begin |
853 | 1468 |
inc(Gear^.Timer); |
1469 |
if Gear^.Timer = 65 then |
|
1470 |
begin |
|
1471 |
Gear^.Timer:= 0; |
|
1472 |
inc(Gear^.Pos); |
|
1473 |
if Gear^.Pos = 11 then |
|
912 | 1474 |
Gear^.doStep:= @doStepTeleportAfter |
853 | 1475 |
end |
525 | 1476 |
end; |
520 | 1477 |
|
1478 |
procedure doStepTeleport(Gear: PGear); |
|
1479 |
var HHGear: PGear; |
|
1480 |
begin |
|
1481 |
AllInactive:= false; |
|
1482 |
||
1483 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1484 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1485 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1486 |
sprHHTelepMask, 0, false) then |
|
853 | 1487 |
begin |
1488 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1489 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1490 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1491 |
DeleteGear(Gear); |
|
1492 |
isCursorVisible:= true |
|
1493 |
end |
|
1494 |
else begin |
|
1495 |
DeleteCI(HHGear); |
|
1496 |
SetAllHHToActive; |
|
912 | 1497 |
Gear^.doStep:= @doStepTeleportAnim; |
853 | 1498 |
Gear^.X:= HHGear^.X; |
1499 |
Gear^.Y:= HHGear^.Y; |
|
1500 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1501 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1502 |
HHGear^.State:= HHGear^.State or gstMoving |
|
1503 |
end; |
|
520 | 1504 |
TargetPoint.X:= NoPointX |
1505 |
end; |
|
534 | 1506 |
|
1507 |
//////////////////////////////////////////////////////////////////////////////// |
|
1508 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1509 |
var HHGear: PGear; |
|
1510 |
Msg, State: Longword; |
|
1511 |
begin |
|
1512 |
AllInactive:= false; |
|
1513 |
||
540 | 1514 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
1133 | 1515 |
begin |
1516 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1517 |
Msg:= Gear^.Message and not gm_Switch; |
|
1518 |
DeleteGear(Gear); |
|
1519 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
|
1520 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1521 |
|
1133 | 1522 |
HHGear:= CurrentHedgehog^.Gear; |
1523 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
1524 |
HHGear^.Message:= Msg; |
|
1525 |
exit |
|
1526 |
end; |
|
534 | 1527 |
|
1528 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1133 | 1529 |
begin |
1530 |
HHGear:= CurrentHedgehog^.Gear; |
|
1531 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
|
1532 |
Gear^.Message:= Gear^.Message and not gm_Switch; |
|
1533 |
State:= HHGear^.State; |
|
1534 |
HHGear^.State:= 0; |
|
1535 |
HHGear^.Active:= false; |
|
1536 |
HHGear^.Z:= cHHZ; |
|
1537 |
RemoveGearFromList(HHGear); |
|
1538 |
InsertGearToList(HHGear); |
|
534 | 1539 |
|
1133 | 1540 |
repeat |
1541 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
|
1542 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
|
652 | 1543 |
|
1133 | 1544 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
534 | 1545 |
|
1133 | 1546 |
HHGear:= CurrentHedgehog^.Gear; |
1547 |
HHGear^.State:= State; |
|
1548 |
HHGear^.Active:= true; |
|
1549 |
FollowGear:= HHGear; |
|
1550 |
HHGear^.Z:= cCurrHHZ; |
|
1551 |
RemoveGearFromList(HHGear); |
|
1552 |
InsertGearToList(HHGear); |
|
1553 |
Gear^.X:= HHGear^.X; |
|
1554 |
Gear^.Y:= HHGear^.Y |
|
1555 |
end; |
|
534 | 1556 |
end; |
1557 |
||
1558 |
procedure doStepSwitcher(Gear: PGear); |
|
1559 |
var HHGear: PGear; |
|
1560 |
begin |
|
1561 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1562 |
||
1563 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1564 |
with HHGear^ do |
|
1133 | 1565 |
begin |
1566 |
State:= State and not gstAttacking; |
|
1567 |
Message:= Message and not gm_Attack |
|
1568 |
end |
|
534 | 1569 |
end; |
924 | 1570 |
|
1571 |
//////////////////////////////////////////////////////////////////////////////// |
|
1572 |
procedure doStepMortar(Gear: PGear); |
|
1573 |
var dX, dY: hwFloat; |
|
1574 |
i: LongInt; |
|
963 | 1575 |
dxn, dyn: boolean; |
924 | 1576 |
begin |
1577 |
AllInactive:= false; |
|
963 | 1578 |
dxn:= Gear^.dX.isNegative; |
1579 |
dyn:= Gear^.dY.isNegative; |
|
1580 |
||
924 | 1581 |
doStepFallingGear(Gear); |
1582 |
if (Gear^.State and gstCollision) <> 0 then |
|
1583 |
begin |
|
1584 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
963 | 1585 |
|
1586 |
Gear^.dX.isNegative:= not dxn; |
|
1587 |
Gear^.dY.isNegative:= not dyn; |
|
924 | 1588 |
for i:= 0 to 4 do |
1589 |
begin |
|
963 | 1590 |
dX:= Gear^.dX + (GetRandom - _0_5) * _0_03; |
1591 |
dY:= Gear^.dY + (GetRandom - _0_5) * _0_03; |
|
1273 | 1592 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); |
924 | 1593 |
end; |
1594 |
||
1595 |
DeleteGear(Gear); |
|
1596 |
exit |
|
1597 |
end; |
|
963 | 1598 |
|
924 | 1599 |
if (GameTicks and $3F) = 0 then |
1600 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
1601 |
end; |
|
984 | 1602 |
|
1603 |
//////////////////////////////////////////////////////////////////////////////// |
|
1604 |
procedure doStepKamikazeWork(Gear: PGear); |
|
1605 |
const upd: Longword = 0; |
|
987 | 1606 |
var i: LongWord; |
984 | 1607 |
HHGear: PGear; |
1608 |
begin |
|
1609 |
AllInactive:= false; |
|
1610 |
||
1611 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1612 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1613 |
DeleteCI(HHGear); |
|
1614 |
||
1615 |
i:= 2; |
|
1616 |
repeat |
|
1617 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
1618 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
1619 |
HHGear^.X:= Gear^.X; |
|
1620 |
HHGear^.Y:= Gear^.Y; |
|
1621 |
||
1622 |
inc(Gear^.Damage, 2); |
|
1623 |
||
1200 | 1624 |
// if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
1625 |
// or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); |
|
984 | 1626 |
|
1627 |
dec(i) |
|
1628 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
|
1629 |
||
1630 |
inc(upd); |
|
1631 |
if upd > 3 then |
|
1632 |
begin |
|
987 | 1633 |
if Gear^.Health < 1500 then Gear^.Pos:= 2; |
1634 |
||
984 | 1635 |
AmmoShove(Gear, 30, 40); |
1636 |
||
1637 |
DrawTunnel(HHGear^.X - HHGear^.dX * 10, |
|
1200 | 1638 |
HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2, |
984 | 1639 |
HHGear^.dX, |
1640 |
HHGear^.dY, |
|
1641 |
20 + cHHRadius * 2, |
|
1200 | 1642 |
cHHRadius * 2 + 6); |
984 | 1643 |
|
1644 |
upd:= 0 |
|
1645 |
end; |
|
1646 |
||
1647 |
if Gear^.Health < Gear^.Damage then |
|
1648 |
begin |
|
1649 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1650 |
AfterAttack; |
|
1651 |
DeleteGear(Gear); |
|
1652 |
DeleteGear(HHGear); |
|
1653 |
end else |
|
1654 |
begin |
|
1655 |
dec(Gear^.Health, Gear^.Damage); |
|
1656 |
Gear^.Damage:= 0 |
|
1657 |
end |
|
1658 |
end; |
|
1659 |
||
987 | 1660 |
procedure doStepKamikazeIdle(Gear: PGear); |
1661 |
begin |
|
1662 |
AllInactive:= false; |
|
1663 |
dec(Gear^.Timer); |
|
1664 |
if Gear^.Timer = 0 then |
|
1665 |
begin |
|
1666 |
Gear^.Pos:= 1; |
|
1669 | 1667 |
PlaySound(sndKamikaze, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
987 | 1668 |
Gear^.doStep:= @doStepKamikazeWork |
1669 |
end |
|
1670 |
end; |
|
1671 |
||
984 | 1672 |
procedure doStepKamikaze(Gear: PGear); |
1673 |
var HHGear: PGear; |
|
1674 |
begin |
|
1675 |
AllInactive:= false; |
|
1676 |
||
1677 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1678 |
||
1679 |
HHGear^.dX:= Gear^.dX; |
|
1680 |
HHGear^.dY:= Gear^.dY; |
|
1681 |
||
1682 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
|
1683 |
Gear^.dY:= - _0_9; |
|
1684 |
||
987 | 1685 |
Gear^.Timer:= 550; |
1686 |
||
1687 |
Gear^.doStep:= @doStepKamikazeIdle |
|
984 | 1688 |
end; |
1689 |
||
1103 | 1690 |
//////////////////////////////////////////////////////////////////////////////// |
1691 |
const cakeh = 27; |
|
1110 | 1692 |
cakeDmg = 75; |
1103 | 1693 |
var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; end; |
1694 |
CakeI: Longword; |
|
1695 |
||
1110 | 1696 |
procedure doStepCakeExpl(Gear: PGear); |
1697 |
begin |
|
1698 |
inc(Gear^.Tag); |
|
1699 |
if Gear^.Tag < 2250 then exit; |
|
1700 |
||
1701 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, EXPLAutoSound); |
|
1702 |
AfterAttack; |
|
1703 |
DeleteGear(Gear) |
|
1704 |
end; |
|
1705 |
||
1109 | 1706 |
procedure doStepCakeDown(Gear: PGear); |
1133 | 1707 |
var gi: PGear; |
1708 |
dmg: LongInt; |
|
1109 | 1709 |
begin |
1710 |
AllInactive:= false; |
|
1711 |
||
1712 |
inc(Gear^.Tag); |
|
1713 |
if Gear^.Tag < 100 then exit; |
|
1714 |
Gear^.Tag:= 0; |
|
1715 |
||
1716 |
if Gear^.Pos = 0 then |
|
1717 |
begin |
|
1110 | 1718 |
gi:= GearsList; |
1719 |
while gi <> nil do |
|
1720 |
begin |
|
1721 |
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
|
1722 |
if (dmg > 1) and (gi^.Kind = gtHedgehog) then |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1723 |
if (CurrentHedgehog^.Gear = gi) and (not gi^.Invulnerable) then |
1867 | 1724 |
gi^.State:= gi^.State or gstLoser |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1725 |
else |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1726 |
gi^.State:= gi^.State or gstWinner; |
1110 | 1727 |
gi:= gi^.NextGear |
1728 |
end; |
|
1729 |
Gear^.doStep:= @doStepCakeExpl; |
|
1669 | 1730 |
PlaySound(sndCake, false, nil) |
1109 | 1731 |
end else dec(Gear^.Pos) |
1732 |
end; |
|
1733 |
||
1734 |
||
1089 | 1735 |
procedure doStepCakeWork(Gear: PGear); |
1736 |
const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0)); |
|
1737 |
var xx, yy, xxn, yyn: LongInt; |
|
1738 |
da: LongInt; |
|
1103 | 1739 |
tdx, tdy: hwFloat; |
1089 | 1740 |
|
1741 |
procedure PrevAngle; |
|
1742 |
begin |
|
1133 | 1743 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 - dA) mod 4 |
1089 | 1744 |
end; |
1745 |
||
1746 |
procedure NextAngle; |
|
1747 |
begin |
|
1133 | 1748 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 + dA) mod 4 |
1089 | 1749 |
end; |
1750 |
||
1088 | 1751 |
begin |
1089 | 1752 |
inc(Gear^.Tag); |
1108 | 1753 |
if Gear^.Tag < 7 then exit; |
1089 | 1754 |
|
1755 |
dA:= hwSign(Gear^.dX); |
|
1756 |
xx:= dirs[Gear^.Angle].x; |
|
1757 |
yy:= dirs[Gear^.Angle].y; |
|
1133 | 1758 |
xxn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x; |
1759 |
yyn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y; |
|
1089 | 1760 |
|
1761 |
if (xx = 0) then |
|
1762 |
if TestCollisionYwithGear(Gear, yy) then |
|
1763 |
PrevAngle |
|
1764 |
else begin |
|
1765 |
Gear^.Tag:= 0; |
|
1766 |
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
|
1767 |
if not TestCollisionXwithGear(Gear, xxn) then |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1768 |
begin |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1769 |
Gear^.X:= Gear^.X + int2hwFloat(xxn); |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1770 |
NextAngle |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1771 |
end; |
1089 | 1772 |
end; |
1773 |
||
1774 |
if (yy = 0) then |
|
1775 |
if TestCollisionXwithGear(Gear, xx) then |
|
1776 |
PrevAngle |
|
1777 |
else begin |
|
1778 |
Gear^.Tag:= 0; |
|
1779 |
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
|
1780 |
if not TestCollisionYwithGear(Gear, yyn) then |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1781 |
begin |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1782 |
Gear^.Y:= Gear^.Y + int2hwFloat(yyn); |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1783 |
NextAngle |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1784 |
end; |
1089 | 1785 |
end; |
1786 |
||
1103 | 1787 |
if Gear^.Tag = 0 then |
1788 |
begin |
|
1789 |
CakeI:= (CakeI + 1) mod cakeh; |
|
1790 |
tdx:= CakePoints[CakeI].x - Gear^.X; |
|
1791 |
tdy:= - CakePoints[CakeI].y + Gear^.Y; |
|
1792 |
CakePoints[CakeI].x:= Gear^.X; |
|
1793 |
CakePoints[CakeI].y:= Gear^.Y; |
|
1794 |
Gear^.DirAngle:= DxDy2Angle(tdx, tdy); |
|
1795 |
end; |
|
1796 |
||
1089 | 1797 |
dec(Gear^.Health); |
1090 | 1798 |
if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then |
1089 | 1799 |
begin |
1109 | 1800 |
FollowGear:= Gear; |
1801 |
Gear^.doStep:= @doStepCakeDown |
|
1089 | 1802 |
end |
1088 | 1803 |
end; |
1089 | 1804 |
|
1103 | 1805 |
procedure doStepCakeUp(Gear: PGear); |
1806 |
var i: Longword; |
|
1807 |
begin |
|
1808 |
AllInactive:= false; |
|
1809 |
||
1108 | 1810 |
inc(Gear^.Tag); |
1109 | 1811 |
if Gear^.Tag < 100 then exit; |
1108 | 1812 |
Gear^.Tag:= 0; |
1813 |
||
1109 | 1814 |
if Gear^.Pos = 6 then |
1103 | 1815 |
begin |
1816 |
for i:= 0 to Pred(cakeh) do |
|
1817 |
begin |
|
1818 |
CakePoints[i].x:= Gear^.X; |
|
1819 |
CakePoints[i].y:= Gear^.Y |
|
1820 |
end; |
|
1821 |
CakeI:= 0; |
|
1822 |
Gear^.doStep:= @doStepCakeWork |
|
1109 | 1823 |
end else inc(Gear^.Pos) |
1103 | 1824 |
end; |
1825 |
||
1089 | 1826 |
procedure doStepCakeFall(Gear: PGear); |
1827 |
begin |
|
1828 |
AllInactive:= false; |
|
1829 |
||
1830 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1831 |
if TestCollisionYwithGear(Gear, 1) then |
|
1103 | 1832 |
Gear^.doStep:= @doStepCakeUp |
1089 | 1833 |
else |
1834 |
begin |
|
1835 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1836 |
if CheckGearDrowning(Gear) then AfterAttack |
|
1837 |
end |
|
1838 |
end; |
|
1839 |
||
1840 |
procedure doStepCake(Gear: PGear); |
|
1841 |
var HHGear: PGear; |
|
1842 |
begin |
|
1843 |
AllInactive:= false; |
|
1844 |
||
1845 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1103 | 1846 |
HHGear^.Message:= HHGear^.Message and (not gm_Attack); |
1089 | 1847 |
DeleteCI(HHGear); |
1848 |
||
1106 | 1849 |
FollowGear:= Gear; |
1850 |
||
1089 | 1851 |
Gear^.doStep:= @doStepCakeFall |
1852 |
end; |
|
1853 |
||
1259 | 1854 |
//////////////////////////////////////////////////////////////////////////////// |
1284 | 1855 |
procedure doStepSeductionWork(Gear: PGear); |
1856 |
var x, y: LongInt; |
|
1259 | 1857 |
begin |
1858 |
AllInactive:= false; |
|
1284 | 1859 |
|
1860 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1861 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1862 |
x:= hwRound(Gear^.X); |
|
1863 |
y:= hwRound(Gear^.Y); |
|
1259 | 1864 |
|
1753 | 1865 |
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) then |
1284 | 1866 |
if (Land[y, x] <> 0) then |
1867 |
begin |
|
1868 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; |
|
1869 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative; |
|
1286 | 1870 |
Gear^.dX:= Gear^.dX * _1_5; |
1871 |
Gear^.dY:= Gear^.dY * _1_5 - _0_3; |
|
1284 | 1872 |
AmmoShove(Gear, 0, 40); |
1286 | 1873 |
AfterAttack; |
1284 | 1874 |
DeleteGear(Gear) |
1875 |
end |
|
1876 |
else |
|
1877 |
else |
|
1286 | 1878 |
begin |
1879 |
AfterAttack; |
|
1284 | 1880 |
DeleteGear(Gear) |
1286 | 1881 |
end |
1882 |
end; |
|
1883 |
||
1884 |
procedure doStepSeductionWear(Gear: PGear); |
|
1885 |
begin |
|
1886 |
AllInactive:= false; |
|
1887 |
inc(Gear^.Timer); |
|
1888 |
if Gear^.Timer > 250 then |
|
1889 |
begin |
|
1890 |
Gear^.Timer:= 0; |
|
1388 | 1891 |
inc(Gear^.Pos); |
1892 |
if Gear^.Pos = 5 then |
|
1669 | 1893 |
PlaySound(sndYoohoo, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) |
1286 | 1894 |
end; |
1367 | 1895 |
|
1896 |
if Gear^.Pos = 14 then |
|
1286 | 1897 |
Gear^.doStep:= @doStepSeductionWork |
1259 | 1898 |
end; |
1284 | 1899 |
|
1900 |
procedure doStepSeduction(Gear: PGear); |
|
1901 |
begin |
|
1902 |
AllInactive:= false; |
|
1903 |
DeleteCI(PHedgehog(Gear^.Hedgehog)^.Gear); |
|
1286 | 1904 |
Gear^.doStep:= @doStepSeductionWear |
1284 | 1905 |
end; |
1298 | 1906 |
|
1907 |
//////////////////////////////////////////////////////////////////////////////// |
|
1908 |
procedure doStepWaterUp(Gear: PGear); |
|
1909 |
var i: LongWord; |
|
1910 |
begin |
|
1911 |
AllInactive:= false; |
|
1912 |
||
1913 |
inc(Gear^.Timer); |
|
1914 |
if Gear^.Timer = 17 then |
|
1915 |
Gear^.Timer:= 0 |
|
1916 |
else |
|
1917 |
exit; |
|
1918 |
||
1919 |
if cWaterLine > 0 then |
|
1920 |
begin |
|
1921 |
dec(cWaterLine); |
|
1760 | 1922 |
for i:= 0 to LAND_WIDTH - 1 do |
1298 | 1923 |
Land[cWaterLine, i]:= 0; |
1924 |
SetAllToActive |
|
1925 |
end; |
|
1926 |
||
1927 |
inc(Gear^.Tag); |
|
1343 | 1928 |
if (Gear^.Tag = 47) or (cWaterLine = 0) then |
1298 | 1929 |
DeleteGear(Gear) |
1930 |
end; |
|
1573 | 1931 |
|
1932 |
//////////////////////////////////////////////////////////////////////////////// |
|
1590 | 1933 |
procedure doStepDrillDrilling(Gear: PGear); |
1633 | 1934 |
var t: PGearArray; |
1935 |
ox, oy: hwFloat; |
|
1573 | 1936 |
begin |
1590 | 1937 |
AllInactive:= false; |
1938 |
||
1633 | 1939 |
if (Gear^.Timer > 0) and ((Gear^.Timer mod 10) = 0) then |
1590 | 1940 |
begin |
1573 | 1941 |
ox:= Gear^.X; |
1942 |
oy:= Gear^.Y; |
|
1943 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1944 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1945 |
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6); |
|
1946 |
CheckGearDrowning(Gear); |
|
1590 | 1947 |
end; |
1948 |
||
1633 | 1949 |
t:= CheckGearsCollision(Gear); //fixes drill not exploding when touching HH bug |
1590 | 1950 |
if (Gear^.Timer = 0) |
1633 | 1951 |
or (t^.Count <> 0) |
1590 | 1952 |
or (not TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) |
1784 | 1953 |
and not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) |
1954 |
or (Land[hwRound(Gear^.Y), hwRound(Gear^.X)] = COLOR_INDESTRUCTIBLE) then |
|
1590 | 1955 |
begin //out of time or exited ground |
1956 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1957 |
DeleteGear(Gear); |
|
1958 |
exit |
|
1959 |
end; |
|
1960 |
||
1961 |
dec(Gear^.Timer); |
|
1573 | 1962 |
end; |
1963 |
||
1964 |
procedure doStepDrill(Gear: PGear); |
|
1590 | 1965 |
var t: PGearArray; |
1633 | 1966 |
oldDx, oldDy: hwFloat; |
1967 |
t2: hwFloat; |
|
1573 | 1968 |
begin |
1590 | 1969 |
AllInactive:= false; |
1573 | 1970 |
|
1590 | 1971 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
1972 |
oldDx:= Gear^.dX; |
|
1973 |
oldDy:= Gear^.dY; |
|
1974 |
||
1975 |
doStepFallingGear(Gear); |
|
1976 |
||
1977 |
if (GameTicks and $3F) = 0 then |
|
1978 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1573 | 1979 |
|
1633 | 1980 |
if ((Gear^.State and gstCollision) <> 0) then begin //hit |
1590 | 1981 |
Gear^.dX:= oldDx; |
1982 |
Gear^.dY:= oldDy; |
|
1633 | 1983 |
|
1590 | 1984 |
t:= CheckGearsCollision(Gear); |
1633 | 1985 |
if (t^.Count = 0) then begin //hit the ground not the HH |
1986 |
t2 := _0_5 / Distance(Gear^.dX, Gear^.dY); |
|
1987 |
Gear^.dX:= Gear^.dX * t2; |
|
1988 |
Gear^.dY:= Gear^.dY * t2; |
|
1989 |
end else begin //explode right on contact with HH |
|
1990 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1991 |
DeleteGear(Gear); |
|
1992 |
exit; |
|
1993 |
end; |
|
1994 |
||
1590 | 1995 |
Gear^.doStep:= @doStepDrillDrilling; |
1633 | 1996 |
dec(Gear^.Timer) |
1590 | 1997 |
end |
1998 |
end; |
|
1601 | 1999 |
|
1633 | 2000 |
//////////////////////////////////////////////////////////////////////////////// |
1601 | 2001 |
procedure doStepBallgunWork(Gear: PGear); |
2002 |
var HHGear: PGear; |
|
1630 | 2003 |
rx, ry: hwFloat; |
1601 | 2004 |
begin |
2005 |
AllInactive:= false; |
|
2006 |
dec(Gear^.Timer); |
|
2007 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2008 |
HedgehogChAngle(HHGear); |
|
2009 |
if (Gear^.Timer mod 100) = 0 then |
|
2010 |
begin |
|
1630 | 2011 |
rx:= rndSign(getRandom * _0_1); |
2012 |
ry:= rndSign(getRandom * _0_1); |
|
1631
6e313b3818ef
Remove debug stuff, ballgun 64but incompatibility fixed in previous revision
unc0rr
parents:
1630
diff
changeset
|
2013 |
|
1630 | 2014 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBall, 0, |
2015 |
SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, |
|
2016 |
AngleCos(HHGear^.Angle) * ( - _0_8) + ry, |
|
2017 |
0); |
|
1601 | 2018 |
|
1669 | 2019 |
PlaySound(sndGun, false, nil); |
1601 | 2020 |
end; |
2021 |
||
1643 | 2022 |
if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then |
1601 | 2023 |
begin |
2024 |
DeleteGear(Gear); |
|
1643 | 2025 |
AfterAttack |
2026 |
end |
|
1601 | 2027 |
end; |
2028 |
||
2029 |
procedure doStepBallgun(Gear: PGear); |
|
2030 |
var HHGear: PGear; |
|
2031 |
begin |
|
2032 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2033 |
HHGear^.Message:= HHGear^.Message and not (gm_Up or gm_Down); |
|
2034 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
|
2035 |
Gear^.doStep:= @doStepBallgunWork |
|
1633 | 2036 |
end; |
1689 | 2037 |
|
1696 | 2038 |
//////////////////////////////////////////////////////////////////////////////// |
1689 | 2039 |
procedure doStepRCPlaneWork(Gear: PGear); |
2040 |
const cAngleSpeed = 3; |
|
2041 |
var HHGear: PGear; |
|
2042 |
i: LongInt; |
|
2043 |
dX, dY: hwFloat; |
|
2044 |
fChanged: boolean; |
|
2045 |
trueAngle: Longword; |
|
2046 |
t: PGear; |
|
2047 |
begin |
|
2048 |
AllInactive:= false; |
|
2049 |
||
1696 | 2050 |
if Gear^.Timer > 0 then dec(Gear^.Timer); |
1689 | 2051 |
|
2052 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2053 |
FollowGear:= Gear; |
|
2054 |
||
2055 |
fChanged:= false; |
|
1696 | 2056 |
if ((HHGear^.State and gstHHDriven) = 0) or (Gear^.Timer = 0) then |
1689 | 2057 |
begin |
2058 |
fChanged:= true; |
|
1696 | 2059 |
if Gear^.Angle > 2048 then dec(Gear^.Angle) else |
2060 |
if Gear^.Angle < 2048 then inc(Gear^.Angle) else fChanged:= false |
|
2061 |
end |
|
2062 |
else |
|
2063 |
begin |
|
2064 |
if ((Gear^.Message and gm_Left) <> 0) then |
|
2065 |
begin |
|
2066 |
fChanged:= true; |
|
2067 |
Gear^.Angle:= (Gear^.Angle + (4096 - cAngleSpeed)) mod 4096 |
|
2068 |
end; |
|
1689 | 2069 |
|
1696 | 2070 |
if ((Gear^.Message and gm_Right) <> 0) then |
2071 |
begin |
|
2072 |
fChanged:= true; |
|
2073 |
Gear^.Angle:= (Gear^.Angle + cAngleSpeed) mod 4096 |
|
2074 |
end |
|
1689 | 2075 |
end; |
2076 |
||
2077 |
if fChanged then |
|
2078 |
begin |
|
2079 |
Gear^.dX.isNegative:= (Gear^.Angle > 2048); |
|
2080 |
if Gear^.dX.isNegative then |
|
2081 |
trueAngle:= 4096 - Gear^.Angle |
|
2082 |
else |
|
2083 |
trueAngle:= Gear^.Angle; |
|
2084 |
||
2085 |
Gear^.dX:= SignAs(AngleSin(trueAngle), Gear^.dX) * _0_25; |
|
2086 |
Gear^.dY:= AngleCos(trueAngle) * -_0_25; |
|
2087 |
end; |
|
2088 |
||
2089 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
2090 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
2091 |
||
2092 |
if (GameTicks and $FF) = 0 then |
|
1698 | 2093 |
if Gear^.Timer < 3500 then |
1696 | 2094 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0) |
2095 |
else |
|
2096 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1689 | 2097 |
|
1696 | 2098 |
if ((HHGear^.Message and gm_Attack) <> 0) and (Gear^.Health <> 0) then |
1689 | 2099 |
begin |
2100 |
HHGear^.Message := HHGear^.Message and not gm_Attack; |
|
1708 | 2101 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * _0_5, 0); |
1689 | 2102 |
dec(Gear^.Health) |
1712 | 2103 |
end; |
2104 |
||
2105 |
if ((HHGear^.Message and gm_LJump) <> 0) |
|
2106 |
and ((Gear^.State and gsttmpFlag) = 0) then |
|
2107 |
begin |
|
2108 |
Gear^.State:= Gear^.State or gsttmpFlag; |
|
2109 |
PauseMusic; |
|
2110 |
playSound(sndRideOfTheValkyries, false, nil); |
|
2111 |
end; |
|
1689 | 2112 |
|
2113 |
// pickup bonuses |
|
2114 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
2115 |
if t <> nil then |
|
2116 |
PickUp(HHGear, t); |
|
2117 |
||
2118 |
CheckCollision(Gear); |
|
2119 |
||
1712 | 2120 |
if ((Gear^.State and gstCollision) <> 0) |
2121 |
or CheckGearDrowning(Gear) then |
|
1689 | 2122 |
begin |
1712 | 2123 |
StopSound(sndRCPlane); |
2124 |
StopSound(sndRideOfTheValkyries); |
|
2125 |
ResumeMusic; |
|
2126 |
||
2127 |
if ((Gear^.State and gstCollision) <> 0) then |
|
1689 | 2128 |
begin |
1712 | 2129 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound); |
1714 | 2130 |
for i:= 0 to 32 do |
1712 | 2131 |
begin |
1714 | 2132 |
dX:= AngleCos(i * 64) * _0_5 * (GetRandom + _1); |
2133 |
dY:= AngleSin(i * 64) * _0_5 * (GetRandom + _1); |
|
1712 | 2134 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); |
2135 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, -dY, 0); |
|
2136 |
end; |
|
2137 |
DeleteGear(Gear) |
|
1689 | 2138 |
end; |
1713 | 2139 |
|
1689 | 2140 |
AfterAttack; |
1713 | 2141 |
CurAmmoGear:= nil; |
1697 | 2142 |
TurnTimeLeft:= 14 * 125; |
1712 | 2143 |
HHGear^.Message:= 0; |
1697 | 2144 |
ParseCommand('/taunt '#1, true) |
2145 |
end |
|
1689 | 2146 |
end; |
2147 |
||
2148 |
procedure doStepRCPlane(Gear: PGear); |
|
2149 |
var HHGear: PGear; |
|
2150 |
begin |
|
2151 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2152 |
HHGear^.Message:= 0; |
|
2153 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
|
2154 |
Gear^.Angle:= HHGear^.Angle; |
|
1696 | 2155 |
Gear^.Tag:= hwSign(HHGear^.dX); |
1689 | 2156 |
if HHGear^.dX.isNegative then Gear^.Angle:= 4096 - Gear^.Angle; |
2157 |
Gear^.doStep:= @doStepRCPlaneWork |
|
1712 | 2158 |
end; |