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