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