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