author | unc0rr |
Mon, 19 Jan 2009 15:34:11 +0000 | |
changeset 1714 | 10de2dcaa34f |
parent 1713 | 194ed95f9e8d |
child 1719 | b8a5c7180e48 |
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; |
|
498 | 393 |
if (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) 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); |
|
38 | 412 |
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 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; |
498 | 423 |
if (Gear^.Health <= 0) or (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then |
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); |
|
577 |
if (HHGear^.Damage > 0) then Gear^.Timer:= 0 |
|
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); |
|
1504 | 715 |
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0) and (Land[ly, lx] <> 0) then |
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; |
|
1624
3cbf01d31e5c
- Fix bug when hedgehog was unable to drop some weapons from rope if it thrown rope in jump
unc0rr
parents:
1603
diff
changeset
|
825 |
with HHGear^ do State:= State and not (gstAttacking or gstMoving); |
1433 | 826 |
tt:= _0 |
827 |
end; |
|
828 |
tx:= tx + Gear^.dX + Gear^.dX; |
|
829 |
ty:= ty + Gear^.dY + Gear^.dY; |
|
830 |
tt:= tt - _2; |
|
831 |
end; |
|
832 |
end; |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
833 |
|
4 | 834 |
CheckCollision(Gear); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
835 |
|
351 | 836 |
if (Gear^.State and gstCollision) <> 0 then |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
837 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
838 |
Gear^.doStep:= @doStepRopeWork; |
974
fc16141a0128
Prevent wrong aim direction when using rope after high jump
unc0rr
parents:
963
diff
changeset
|
839 |
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
|
840 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
841 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
842 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
843 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
844 |
if Gear^.Elasticity < _10 then |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
845 |
Gear^.Elasticity:= _10000; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
846 |
end; |
4 | 847 |
|
1634
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset
|
848 |
if (Gear^.Elasticity > Gear^.Friction) |
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset
|
849 |
or ((Gear^.Message and gm_Attack) = 0) |
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset
|
850 |
or (HHGear^.Damage > 0) then |
1433 | 851 |
begin |
852 |
with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
|
853 |
begin |
|
854 |
State:= State and not gstAttacking; |
|
855 |
Message:= Message and not gm_Attack |
|
856 |
end; |
|
857 |
DeleteGear(Gear) |
|
858 |
end |
|
4 | 859 |
end; |
860 |
||
861 |
procedure doStepRope(Gear: PGear); |
|
862 |
begin |
|
351 | 863 |
Gear^.dX:= - Gear^.dX; |
864 |
Gear^.dY:= - Gear^.dY; |
|
865 |
Gear^.doStep:= @doStepRopeAttach |
|
4 | 866 |
end; |
867 |
||
868 |
//////////////////////////////////////////////////////////////////////////////// |
|
869 |
procedure doStepSmokeTrace(Gear: PGear); |
|
870 |
begin |
|
351 | 871 |
inc(Gear^.Timer); |
872 |
if Gear^.Timer > 64 then |
|
1133 | 873 |
begin |
874 |
Gear^.Timer:= 0; |
|
875 |
dec(Gear^.State) |
|
876 |
end; |
|
351 | 877 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
878 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
879 |
if Gear^.State = 0 then DeleteGear(Gear) |
|
4 | 880 |
end; |
9 | 881 |
|
882 |
//////////////////////////////////////////////////////////////////////////////// |
|
1045 | 883 |
procedure doStepExplosionWork(Gear: PGear); |
9 | 884 |
begin |
351 | 885 |
inc(Gear^.Timer); |
886 |
if Gear^.Timer > 75 then |
|
1133 | 887 |
begin |
888 |
inc(Gear^.State); |
|
889 |
Gear^.Timer:= 0; |
|
890 |
if Gear^.State > 5 then DeleteGear(Gear) |
|
891 |
end; |
|
9 | 892 |
end; |
10 | 893 |
|
1045 | 894 |
procedure doStepExplosion(Gear: PGear); |
895 |
var i: LongWord; |
|
896 |
begin |
|
1047 | 897 |
for i:= 0 to 31 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFire); |
898 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart); |
|
899 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart2); |
|
1045 | 900 |
Gear^.doStep:= @doStepExplosionWork |
901 |
end; |
|
902 |
||
10 | 903 |
//////////////////////////////////////////////////////////////////////////////// |
904 |
procedure doStepMine(Gear: PGear); |
|
905 |
begin |
|
542 | 906 |
if (Gear^.State and gstMoving) <> 0 then |
914 | 907 |
begin |
908 |
DeleteCI(Gear); |
|
909 |
doStepFallingGear(Gear); |
|
910 |
if (Gear^.State and gstMoving) = 0 then |
|
911 |
begin |
|
912 |
AddGearCI(Gear); |
|
913 |
Gear^.dX:= _0; |
|
914 |
Gear^.dY:= _0 |
|
915 |
end; |
|
916 |
CalcRotationDirAngle(Gear); |
|
917 |
AllInactive:= false |
|
918 |
end else |
|
919 |
if ((GameTicks and $3F) = 25) then |
|
920 |
doStepFallingGear(Gear); |
|
351 | 921 |
|
922 |
if ((Gear^.State and gsttmpFlag) <> 0) then |
|
1133 | 923 |
if ((Gear^.State and gstAttacking) = 0) then |
924 |
begin |
|
925 |
if ((GameTicks and $1F) = 0) then |
|
926 |
if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking |
|
927 |
end else // gstAttacking <> 0 |
|
928 |
begin |
|
929 |
AllInactive:= false; |
|
1669 | 930 |
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false, nil); |
1133 | 931 |
if Gear^.Timer = 0 then |
932 |
begin |
|
933 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
934 |
DeleteGear(Gear); |
|
935 |
exit |
|
936 |
end; |
|
937 |
dec(Gear^.Timer); |
|
938 |
end else // gsttmpFlag = 0 |
|
939 |
if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
10 | 940 |
end; |
57 | 941 |
|
39 | 942 |
//////////////////////////////////////////////////////////////////////////////// |
943 |
procedure doStepDynamite(Gear: PGear); |
|
944 |
begin |
|
43 | 945 |
doStepFallingGear(Gear); |
946 |
AllInactive:= false; |
|
351 | 947 |
if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); |
948 |
if Gear^.Timer = 0 then |
|
1133 | 949 |
begin |
950 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
|
951 |
DeleteGear(Gear); |
|
952 |
exit |
|
953 |
end; |
|
351 | 954 |
dec(Gear^.Timer); |
39 | 955 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
956 |
|
351 | 957 |
/////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
958 |
procedure doStepCase(Gear: PGear); |
371 | 959 |
var i, x, y: LongInt; |
1436 | 960 |
k: TGearType; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
961 |
begin |
351 | 962 |
if (Gear^.Message and gm_Destroy) > 0 then |
1133 | 963 |
begin |
964 |
DeleteGear(Gear); |
|
965 |
FreeActionsList; |
|
966 |
SetAllToActive; // something (hh, mine, etc...) could be on top of the case |
|
967 |
with CurrentHedgehog^ do |
|
968 |
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
|
969 |
exit |
|
970 |
end; |
|
15 | 971 |
|
351 | 972 |
if Gear^.Damage > 0 then |
1133 | 973 |
begin |
974 |
x:= hwRound(Gear^.X); |
|
975 |
y:= hwRound(Gear^.Y); |
|
1436 | 976 |
k:= Gear^.Kind; |
977 |
DeleteGear(Gear); // <-- delete gear! |
|
978 |
||
979 |
if k = gtCase then |
|
1133 | 980 |
begin |
981 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
|
982 |
for i:= 0 to 63 do |
|
983 |
AddGear(x, y, gtFlame, 0, _0, _0, 0); |
|
984 |
end; |
|
985 |
exit |
|
986 |
end; |
|
79 | 987 |
|
351 | 988 |
if (Gear^.dY.QWordValue <> 0) or (not TestCollisionYwithGear(Gear, 1)) then |
1133 | 989 |
begin |
990 |
AllInactive:= false; |
|
991 |
Gear^.dY:= Gear^.dY + cGravity; |
|
992 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
993 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else |
|
994 |
if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then |
|
995 |
begin |
|
996 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
997 |
if Gear^.dY > - _0_001 then Gear^.dY:= _0 |
|
1669 | 998 |
else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false, nil); |
1133 | 999 |
end; |
1000 |
CheckGearDrowning(Gear); |
|
1001 |
end; |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1002 |
|
511 | 1003 |
if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
1133 | 1004 |
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
|
1005 |
end; |
49 | 1006 |
|
1007 |
//////////////////////////////////////////////////////////////////////////////// |
|
557 | 1008 |
const cSorterWorkTime = 640; |
1009 |
var thexchar: array[0..cMaxTeams] of |
|
1133 | 1010 |
record |
1011 |
dy, ny, dw: LongInt; |
|
1012 |
team: PTeam; |
|
1013 |
SortFactor: QWord; |
|
1014 |
end; |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
1015 |
currsorter: PGear = nil; |
49 | 1016 |
|
1017 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
371 | 1018 |
var i: LongInt; |
49 | 1019 |
begin |
1020 |
AllInactive:= false; |
|
351 | 1021 |
dec(Gear^.Timer); |
1022 |
if (Gear^.Timer and 15) = 0 then |
|
1133 | 1023 |
for i:= 0 to Pred(TeamsCount) do |
1024 |
with thexchar[i] do |
|
1025 |
begin |
|
1026 |
{$WARNINGS OFF} |
|
1027 |
team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; |
|
1028 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; |
|
1029 |
{$WARNINGS ON} |
|
1030 |
end; |
|
1031 |
||
351 | 1032 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
1133 | 1033 |
begin |
1034 |
if currsorter = Gear then currsorter:= nil; |
|
1035 |
DeleteGear(Gear) |
|
1036 |
end |
|
49 | 1037 |
end; |
1038 |
||
1039 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
1133 | 1040 |
var i: Longword; |
1041 |
b: boolean; |
|
1042 |
t: LongInt; |
|
49 | 1043 |
begin |
1044 |
AllInactive:= false; |
|
557 | 1045 |
|
547 | 1046 |
for t:= 0 to Pred(TeamsCount) do |
1133 | 1047 |
with thexchar[t] do |
1048 |
begin |
|
1049 |
dy:= TeamsArray[t]^.DrawHealthY; |
|
1050 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
1051 |
team:= TeamsArray[t]; |
|
1052 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
1053 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
1054 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
1055 |
end; |
|
547 | 1056 |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
1057 |
if TeamsCount > 1 then |
1133 | 1058 |
repeat |
1059 |
b:= true; |
|
1060 |
for t:= 0 to TeamsCount - 2 do |
|
1061 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
1062 |
begin |
|
1063 |
thexchar[cMaxTeams]:= thexchar[t]; |
|
1064 |
thexchar[t]:= thexchar[Succ(t)]; |
|
1065 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
|
1066 |
b:= false |
|
1067 |
end |
|
1068 |
until b; |
|
557 | 1069 |
|
1120 | 1070 |
t:= - 4; |
557 | 1071 |
for i:= 0 to Pred(TeamsCount) do |
1133 | 1072 |
with thexchar[i] do |
1073 |
begin |
|
1074 |
dec(t, team^.HealthTex^.h + 2); |
|
1075 |
ny:= t; |
|
1076 |
dy:= dy - ny |
|
1077 |
end; |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
1078 |
|
557 | 1079 |
Gear^.Timer:= cSorterWorkTime; |
351 | 1080 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
143 | 1081 |
currsorter:= Gear |
49 | 1082 |
end; |
1083 |
||
79 | 1084 |
//////////////////////////////////////////////////////////////////////////////// |
854 | 1085 |
procedure doStepIdle(Gear: PGear); |
1086 |
begin |
|
1087 |
AllInactive:= false; |
|
925 | 1088 |
dec(Gear^.Timer); |
854 | 1089 |
if Gear^.Timer = 0 then |
1090 |
begin |
|
1091 |
DeleteGear(Gear); |
|
1092 |
AfterAttack |
|
1093 |
end |
|
1094 |
end; |
|
1095 |
||
79 | 1096 |
procedure doStepShover(Gear: PGear); |
1097 |
var HHGear: PGear; |
|
1098 |
begin |
|
351 | 1099 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1100 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1101 |
DeleteCI(HHGear); |
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1102 |
|
79 | 1103 |
AmmoShove(Gear, 30, 115); |
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1104 |
|
351 | 1105 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
854 | 1106 |
Gear^.Timer:= 250; |
1107 |
Gear^.doStep:= @doStepIdle |
|
79 | 1108 |
end; |
1109 |
||
1110 |
//////////////////////////////////////////////////////////////////////////////// |
|
925 | 1111 |
procedure doStepWhip(Gear: PGear); |
1112 |
var HHGear: PGear; |
|
1113 |
i: LongInt; |
|
1114 |
begin |
|
1115 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1116 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1117 |
DeleteCI(HHGear); |
925 | 1118 |
|
1119 |
for i:= 0 to 3 do |
|
1120 |
begin |
|
1121 |
AmmoShove(Gear, 30, 25); |
|
1122 |
Gear^.X:= Gear^.X + Gear^.dX * 5 |
|
1123 |
end; |
|
1124 |
||
1125 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
|
1126 |
Gear^.Timer:= 250; |
|
1127 |
Gear^.doStep:= @doStepIdle |
|
1128 |
end; |
|
1129 |
||
1130 |
//////////////////////////////////////////////////////////////////////////////// |
|
79 | 1131 |
procedure doStepFlame(Gear: PGear); |
1132 |
begin |
|
1133 |
AllInactive:= false; |
|
1433 | 1134 |
|
79 | 1135 |
if not TestCollisionYwithGear(Gear, 1) then |
1133 | 1136 |
begin |
1586 | 1137 |
if hwAbs(Gear^.dX) > _0_01 then |
1138 |
Gear^.dX:= Gear^.dX * _0_995; |
|
1297 | 1139 |
|
1133 | 1140 |
Gear^.dY:= Gear^.dY + cGravity; |
1586 | 1141 |
if hwAbs(Gear^.dY) > _0_08 then Gear^.dY:= Gear^.dY * _0_995; |
1297 | 1142 |
|
1586 | 1143 |
Gear^.X:= Gear^.X + Gear^.dX + cWindSpeed * 270; |
1133 | 1144 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
1297 | 1145 |
|
1417 | 1146 |
if not (hwRound(Gear^.Y) < cWaterLine) then |
1133 | 1147 |
begin |
1148 |
DeleteGear(Gear); |
|
1149 |
exit |
|
1150 |
end |
|
1151 |
end else begin |
|
1152 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
|
1153 |
else begin |
|
1586 | 1154 |
Gear^.Radius:= 9; |
1155 |
AmmoShove(Gear, 4, 100); |
|
1297 | 1156 |
Gear^.Radius:= 1; |
1157 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 4, EXPLNoDamage); |
|
1133 | 1158 |
dec(Gear^.Health); |
1586 | 1159 |
Gear^.Timer:= 450 - Gear^.Tag * 8 |
1133 | 1160 |
end |
1161 |
end; |
|
79 | 1162 |
|
1295 | 1163 |
//if (((GameTicks div 8) mod 64) = Gear^.Tag) then |
1164 |
// AmmoFlameWork(Gear); |
|
79 | 1165 |
|
351 | 1166 |
if Gear^.Health = 0 then |
1133 | 1167 |
DeleteGear(Gear) |
79 | 1168 |
end; |
82 | 1169 |
|
1170 |
//////////////////////////////////////////////////////////////////////////////// |
|
1171 |
procedure doStepFirePunchWork(Gear: PGear); |
|
1172 |
var HHGear: PGear; |
|
1173 |
begin |
|
1174 |
AllInactive:= false; |
|
351 | 1175 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
1133 | 1176 |
begin |
1177 |
DeleteGear(Gear); |
|
1178 |
AfterAttack; |
|
1179 |
exit |
|
1180 |
end; |
|
82 | 1181 |
|
351 | 1182 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1183 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
1133 | 1184 |
begin |
1185 |
Gear^.Tag:= hwRound(HHGear^.Y); |
|
1186 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
|
1187 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1188 |
Gear^.Y:= HHGear^.Y; |
|
1189 |
AmmoShove(Gear, 30, 40); |
|
1190 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
|
1191 |
end; |
|
351 | 1192 |
|
1193 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1194 |
if not (HHGear^.dY.isNegative) then |
|
1133 | 1195 |
begin |
1196 |
HHGear^.State:= HHGear^.State or gstMoving; |
|
1197 |
DeleteGear(Gear); |
|
1198 |
AfterAttack; |
|
1199 |
exit |
|
1200 |
end; |
|
351 | 1201 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1202 |
end; |
1203 |
||
1204 |
procedure doStepFirePunch(Gear: PGear); |
|
1205 |
var HHGear: PGear; |
|
1206 |
begin |
|
1207 |
AllInactive:= false; |
|
351 | 1208 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1209 |
DeleteCI(HHGear); |
498 | 1210 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1211 |
HHGear^.dX:= SignAs(cLittle, Gear^.dX); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1212 |
|
351 | 1213 |
HHGear^.dY:= - _0_3; |
82 | 1214 |
|
351 | 1215 |
Gear^.X:= HHGear^.X; |
979
edb8f208c1d9
Fix firepunch direction when attacking from high jump
unc0rr
parents:
974
diff
changeset
|
1216 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
351 | 1217 |
Gear^.dY:= - _0_9; |
1218 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1219 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
1279 | 1220 |
|
1669 | 1221 |
PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false, PHedgehog(HHGear^.Hedgehog)^.Team^.voicepack) |
82 | 1222 |
end; |
1223 |
||
263 | 1224 |
//////////////////////////////////////////////////////////////////////////////// |
1225 |
||
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1226 |
procedure doStepParachuteWork(Gear: PGear); |
211 | 1227 |
var HHGear: PGear; |
1228 |
begin |
|
351 | 1229 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
82 | 1230 |
|
516 | 1231 |
inc(Gear^.Timer); |
1232 |
||
212 | 1233 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1234 |
or ((HHGear^.State and gstHHDriven) = 0) |
1235 |
or CheckGearDrowning(HHGear) |
|
1236 |
or ((Gear^.Message and gm_Attack) <> 0) then |
|
1237 |
begin |
|
1238 |
with HHGear^ do |
|
1239 |
begin |
|
1240 |
Message:= 0; |
|
1241 |
SetLittle(dX); |
|
1242 |
dY:= _0; |
|
1243 |
State:= State or gstMoving; |
|
1244 |
end; |
|
1245 |
DeleteGear(Gear); |
|
1246 |
exit |
|
1247 |
end; |
|
211 | 1248 |
|
351 | 1249 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1133 | 1250 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
211 | 1251 |
|
351 | 1252 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1253 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1254 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1255 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1256 |
|
351 | 1257 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1258 |
Gear^.X:= HHGear^.X; |
1259 |
Gear^.Y:= HHGear^.Y |
|
263 | 1260 |
end; |
211 | 1261 |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1262 |
procedure doStepParachute(Gear: PGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1263 |
var HHGear: PGear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1264 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1265 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1266 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1267 |
DeleteCI(HHGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1268 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1269 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1270 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1271 |
|
931 | 1272 |
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
|
1273 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1274 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1275 |
Gear^.doStep:= @doStepParachuteWork; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1276 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1277 |
Gear^.Message:= HHGear^.Message; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1278 |
doStepParachuteWork(Gear) |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1279 |
end; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1280 |
|
263 | 1281 |
//////////////////////////////////////////////////////////////////////////////// |
1282 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1507 | 1283 |
var i: Longint; |
263 | 1284 |
begin |
1285 |
AllInactive:= false; |
|
498 | 1286 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
1124 | 1287 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1288 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
1124 | 1289 |
begin |
1290 |
dec(Gear^.Health); |
|
1291 |
case Gear^.State of |
|
1292 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1293 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1586 | 1294 |
2: for i:= -19 to 19 do |
1295 |
FollowGear:= AddGear(hwRound(Gear^.X) + i div 3, hwRound(Gear^.Y), gtFlame, 0, _0_001 * i, _0, 0); |
|
1124 | 1296 |
end; |
1297 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
|
1298 |
end; |
|
1299 |
||
1300 |
if (GameTicks and $3F) = 0 then |
|
1301 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1302 |
||
498 | 1303 |
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1304 |
end; |
1305 |
||
1306 |
procedure doStepAirAttack(Gear: PGear); |
|
1307 |
begin |
|
1308 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1309 |
|
1507 | 1310 |
if Gear^.X.QWordValue = 0 then |
1311 |
Gear^.Tag:= 1 |
|
1312 |
else |
|
1313 |
Gear^.Tag:= -1; |
|
1314 |
||
498 | 1315 |
Gear^.X:= _1024 - _2048 * Gear^.Tag; |
1124 | 1316 |
Gear^.Y:= -_300; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1317 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1318 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1319 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
1133 | 1320 |
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
|
1321 |
|
351 | 1322 |
Gear^.Health:= 6; |
801 | 1323 |
Gear^.doStep:= @doStepAirAttackWork; |
1669 | 1324 |
PlaySound(sndIncoming, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) |
263 | 1325 |
end; |
1326 |
||
1327 |
//////////////////////////////////////////////////////////////////////////////// |
|
1328 |
||
1329 |
procedure doStepAirBomb(Gear: PGear); |
|
1330 |
begin |
|
1331 |
AllInactive:= false; |
|
1332 |
doStepFallingGear(Gear); |
|
351 | 1333 |
if (Gear^.State and gstCollision) <> 0 then |
1133 | 1334 |
begin |
1335 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1336 |
DeleteGear(Gear); |
|
1337 |
exit |
|
1338 |
end; |
|
263 | 1339 |
if (GameTicks and $3F) = 0 then |
1133 | 1340 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1341 |
end; |
409 | 1342 |
|
1343 |
//////////////////////////////////////////////////////////////////////////////// |
|
1344 |
||
1345 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1346 |
var HHGear: PGear; |
409 | 1347 |
begin |
1348 |
AllInactive:= false; |
|
415 | 1349 |
|
1350 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1351 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1352 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1353 |
sprAmGirder, Gear^.State, true) then |
1133 | 1354 |
begin |
1355 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1356 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1357 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1358 |
DeleteGear(Gear); |
|
1359 |
isCursorVisible:= true |
|
1360 |
end |
|
1361 |
else begin |
|
1362 |
DeleteGear(Gear); |
|
1363 |
AfterAttack |
|
1364 |
end; |
|
415 | 1365 |
TargetPoint.X:= NoPointX |
409 | 1366 |
end; |
520 | 1367 |
|
1368 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1369 |
procedure doStepTeleportAfter(Gear: PGear); |
912 | 1370 |
var HHGear: PGear; |
1371 |
begin |
|
1372 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1373 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases |
|
1374 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1375 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1376 |
or CheckGearDrowning(HHGear) then |
1377 |
begin |
|
1378 |
DeleteGear(Gear); |
|
1379 |
AfterAttack |
|
1380 |
end |
|
912 | 1381 |
end; |
1382 |
||
1383 |
procedure doStepTeleportAnim(Gear: PGear); |
|
525 | 1384 |
begin |
853 | 1385 |
inc(Gear^.Timer); |
1386 |
if Gear^.Timer = 65 then |
|
1387 |
begin |
|
1388 |
Gear^.Timer:= 0; |
|
1389 |
inc(Gear^.Pos); |
|
1390 |
if Gear^.Pos = 11 then |
|
912 | 1391 |
Gear^.doStep:= @doStepTeleportAfter |
853 | 1392 |
end |
525 | 1393 |
end; |
520 | 1394 |
|
1395 |
procedure doStepTeleport(Gear: PGear); |
|
1396 |
var HHGear: PGear; |
|
1397 |
begin |
|
1398 |
AllInactive:= false; |
|
1399 |
||
1400 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1401 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1402 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1403 |
sprHHTelepMask, 0, false) then |
|
853 | 1404 |
begin |
1405 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1406 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1407 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1408 |
DeleteGear(Gear); |
|
1409 |
isCursorVisible:= true |
|
1410 |
end |
|
1411 |
else begin |
|
1412 |
DeleteCI(HHGear); |
|
1413 |
SetAllHHToActive; |
|
912 | 1414 |
Gear^.doStep:= @doStepTeleportAnim; |
853 | 1415 |
Gear^.X:= HHGear^.X; |
1416 |
Gear^.Y:= HHGear^.Y; |
|
1417 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1418 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1419 |
HHGear^.State:= HHGear^.State or gstMoving |
|
1420 |
end; |
|
520 | 1421 |
TargetPoint.X:= NoPointX |
1422 |
end; |
|
534 | 1423 |
|
1424 |
//////////////////////////////////////////////////////////////////////////////// |
|
1425 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1426 |
var HHGear: PGear; |
|
1427 |
Msg, State: Longword; |
|
1428 |
begin |
|
1429 |
AllInactive:= false; |
|
1430 |
||
540 | 1431 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
1133 | 1432 |
begin |
1433 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1434 |
Msg:= Gear^.Message and not gm_Switch; |
|
1435 |
DeleteGear(Gear); |
|
1436 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
|
1437 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1438 |
|
1133 | 1439 |
HHGear:= CurrentHedgehog^.Gear; |
1440 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
1441 |
HHGear^.Message:= Msg; |
|
1442 |
exit |
|
1443 |
end; |
|
534 | 1444 |
|
1445 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1133 | 1446 |
begin |
1447 |
HHGear:= CurrentHedgehog^.Gear; |
|
1448 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
|
1449 |
Gear^.Message:= Gear^.Message and not gm_Switch; |
|
1450 |
State:= HHGear^.State; |
|
1451 |
HHGear^.State:= 0; |
|
1452 |
HHGear^.Active:= false; |
|
1453 |
HHGear^.Z:= cHHZ; |
|
1454 |
RemoveGearFromList(HHGear); |
|
1455 |
InsertGearToList(HHGear); |
|
534 | 1456 |
|
1133 | 1457 |
repeat |
1458 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
|
1459 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
|
652 | 1460 |
|
1133 | 1461 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
534 | 1462 |
|
1133 | 1463 |
HHGear:= CurrentHedgehog^.Gear; |
1464 |
HHGear^.State:= State; |
|
1465 |
HHGear^.Active:= true; |
|
1466 |
FollowGear:= HHGear; |
|
1467 |
HHGear^.Z:= cCurrHHZ; |
|
1468 |
RemoveGearFromList(HHGear); |
|
1469 |
InsertGearToList(HHGear); |
|
1470 |
Gear^.X:= HHGear^.X; |
|
1471 |
Gear^.Y:= HHGear^.Y |
|
1472 |
end; |
|
534 | 1473 |
end; |
1474 |
||
1475 |
procedure doStepSwitcher(Gear: PGear); |
|
1476 |
var HHGear: PGear; |
|
1477 |
begin |
|
1478 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1479 |
||
1480 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1481 |
with HHGear^ do |
|
1133 | 1482 |
begin |
1483 |
State:= State and not gstAttacking; |
|
1484 |
Message:= Message and not gm_Attack |
|
1485 |
end |
|
534 | 1486 |
end; |
924 | 1487 |
|
1488 |
//////////////////////////////////////////////////////////////////////////////// |
|
1489 |
procedure doStepMortar(Gear: PGear); |
|
1490 |
var dX, dY: hwFloat; |
|
1491 |
i: LongInt; |
|
963 | 1492 |
dxn, dyn: boolean; |
924 | 1493 |
begin |
1494 |
AllInactive:= false; |
|
963 | 1495 |
dxn:= Gear^.dX.isNegative; |
1496 |
dyn:= Gear^.dY.isNegative; |
|
1497 |
||
924 | 1498 |
doStepFallingGear(Gear); |
1499 |
if (Gear^.State and gstCollision) <> 0 then |
|
1500 |
begin |
|
1501 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
963 | 1502 |
|
1503 |
Gear^.dX.isNegative:= not dxn; |
|
1504 |
Gear^.dY.isNegative:= not dyn; |
|
924 | 1505 |
for i:= 0 to 4 do |
1506 |
begin |
|
963 | 1507 |
dX:= Gear^.dX + (GetRandom - _0_5) * _0_03; |
1508 |
dY:= Gear^.dY + (GetRandom - _0_5) * _0_03; |
|
1273 | 1509 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); |
924 | 1510 |
end; |
1511 |
||
1512 |
DeleteGear(Gear); |
|
1513 |
exit |
|
1514 |
end; |
|
963 | 1515 |
|
924 | 1516 |
if (GameTicks and $3F) = 0 then |
1517 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
1518 |
end; |
|
984 | 1519 |
|
1520 |
//////////////////////////////////////////////////////////////////////////////// |
|
1521 |
procedure doStepKamikazeWork(Gear: PGear); |
|
1522 |
const upd: Longword = 0; |
|
987 | 1523 |
var i: LongWord; |
984 | 1524 |
HHGear: PGear; |
1525 |
begin |
|
1526 |
AllInactive:= false; |
|
1527 |
||
1528 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1529 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1530 |
DeleteCI(HHGear); |
|
1531 |
||
1532 |
i:= 2; |
|
1533 |
repeat |
|
1534 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
1535 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
1536 |
HHGear^.X:= Gear^.X; |
|
1537 |
HHGear^.Y:= Gear^.Y; |
|
1538 |
||
1539 |
inc(Gear^.Damage, 2); |
|
1540 |
||
1200 | 1541 |
// if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
1542 |
// or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); |
|
984 | 1543 |
|
1544 |
dec(i) |
|
1545 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
|
1546 |
||
1547 |
inc(upd); |
|
1548 |
if upd > 3 then |
|
1549 |
begin |
|
987 | 1550 |
if Gear^.Health < 1500 then Gear^.Pos:= 2; |
1551 |
||
984 | 1552 |
AmmoShove(Gear, 30, 40); |
1553 |
||
1554 |
DrawTunnel(HHGear^.X - HHGear^.dX * 10, |
|
1200 | 1555 |
HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2, |
984 | 1556 |
HHGear^.dX, |
1557 |
HHGear^.dY, |
|
1558 |
20 + cHHRadius * 2, |
|
1200 | 1559 |
cHHRadius * 2 + 6); |
984 | 1560 |
|
1561 |
upd:= 0 |
|
1562 |
end; |
|
1563 |
||
1564 |
if Gear^.Health < Gear^.Damage then |
|
1565 |
begin |
|
1566 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1567 |
AfterAttack; |
|
1568 |
DeleteGear(Gear); |
|
1569 |
DeleteGear(HHGear); |
|
1570 |
end else |
|
1571 |
begin |
|
1572 |
dec(Gear^.Health, Gear^.Damage); |
|
1573 |
Gear^.Damage:= 0 |
|
1574 |
end |
|
1575 |
end; |
|
1576 |
||
987 | 1577 |
procedure doStepKamikazeIdle(Gear: PGear); |
1578 |
begin |
|
1579 |
AllInactive:= false; |
|
1580 |
dec(Gear^.Timer); |
|
1581 |
if Gear^.Timer = 0 then |
|
1582 |
begin |
|
1583 |
Gear^.Pos:= 1; |
|
1669 | 1584 |
PlaySound(sndKamikaze, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
987 | 1585 |
Gear^.doStep:= @doStepKamikazeWork |
1586 |
end |
|
1587 |
end; |
|
1588 |
||
984 | 1589 |
procedure doStepKamikaze(Gear: PGear); |
1590 |
var HHGear: PGear; |
|
1591 |
begin |
|
1592 |
AllInactive:= false; |
|
1593 |
||
1594 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1595 |
||
1596 |
HHGear^.dX:= Gear^.dX; |
|
1597 |
HHGear^.dY:= Gear^.dY; |
|
1598 |
||
1599 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
|
1600 |
Gear^.dY:= - _0_9; |
|
1601 |
||
987 | 1602 |
Gear^.Timer:= 550; |
1603 |
||
1604 |
Gear^.doStep:= @doStepKamikazeIdle |
|
984 | 1605 |
end; |
1606 |
||
1103 | 1607 |
//////////////////////////////////////////////////////////////////////////////// |
1608 |
const cakeh = 27; |
|
1110 | 1609 |
cakeDmg = 75; |
1103 | 1610 |
var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; end; |
1611 |
CakeI: Longword; |
|
1612 |
||
1110 | 1613 |
procedure doStepCakeExpl(Gear: PGear); |
1614 |
begin |
|
1615 |
inc(Gear^.Tag); |
|
1616 |
if Gear^.Tag < 2250 then exit; |
|
1617 |
||
1618 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, EXPLAutoSound); |
|
1619 |
AfterAttack; |
|
1620 |
DeleteGear(Gear) |
|
1621 |
end; |
|
1622 |
||
1109 | 1623 |
procedure doStepCakeDown(Gear: PGear); |
1133 | 1624 |
var gi: PGear; |
1625 |
dmg: LongInt; |
|
1109 | 1626 |
begin |
1627 |
AllInactive:= false; |
|
1628 |
||
1629 |
inc(Gear^.Tag); |
|
1630 |
if Gear^.Tag < 100 then exit; |
|
1631 |
Gear^.Tag:= 0; |
|
1632 |
||
1633 |
if Gear^.Pos = 0 then |
|
1634 |
begin |
|
1110 | 1635 |
gi:= GearsList; |
1636 |
while gi <> nil do |
|
1637 |
begin |
|
1638 |
dmg:= cakeDmg * 2 - hwRound(Distance(gi^.X - Gear^.X, gi^.Y - Gear^.Y)); |
|
1639 |
if (dmg > 1) and (gi^.Kind = gtHedgehog) then |
|
1640 |
gi^.State:= gi^.State or gstWinner; |
|
1641 |
gi:= gi^.NextGear |
|
1642 |
end; |
|
1643 |
Gear^.doStep:= @doStepCakeExpl; |
|
1669 | 1644 |
PlaySound(sndCake, false, nil) |
1109 | 1645 |
end else dec(Gear^.Pos) |
1646 |
end; |
|
1647 |
||
1648 |
||
1089 | 1649 |
procedure doStepCakeWork(Gear: PGear); |
1650 |
const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0)); |
|
1651 |
var xx, yy, xxn, yyn: LongInt; |
|
1652 |
da: LongInt; |
|
1103 | 1653 |
tdx, tdy: hwFloat; |
1089 | 1654 |
|
1655 |
procedure PrevAngle; |
|
1656 |
begin |
|
1133 | 1657 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 - dA) mod 4 |
1089 | 1658 |
end; |
1659 |
||
1660 |
procedure NextAngle; |
|
1661 |
begin |
|
1133 | 1662 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 + dA) mod 4 |
1089 | 1663 |
end; |
1664 |
||
1088 | 1665 |
begin |
1089 | 1666 |
inc(Gear^.Tag); |
1108 | 1667 |
if Gear^.Tag < 7 then exit; |
1089 | 1668 |
|
1669 |
dA:= hwSign(Gear^.dX); |
|
1670 |
xx:= dirs[Gear^.Angle].x; |
|
1671 |
yy:= dirs[Gear^.Angle].y; |
|
1133 | 1672 |
xxn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x; |
1673 |
yyn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y; |
|
1089 | 1674 |
|
1675 |
if (xx = 0) then |
|
1676 |
if TestCollisionYwithGear(Gear, yy) then |
|
1677 |
PrevAngle |
|
1678 |
else begin |
|
1679 |
Gear^.Tag:= 0; |
|
1680 |
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
|
1681 |
if not TestCollisionXwithGear(Gear, xxn) then |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1682 |
begin |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1683 |
Gear^.X:= Gear^.X + int2hwFloat(xxn); |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1684 |
NextAngle |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1685 |
end; |
1089 | 1686 |
end; |
1687 |
||
1688 |
if (yy = 0) then |
|
1689 |
if TestCollisionXwithGear(Gear, xx) then |
|
1690 |
PrevAngle |
|
1691 |
else begin |
|
1692 |
Gear^.Tag:= 0; |
|
1693 |
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
|
1694 |
if not TestCollisionYwithGear(Gear, yyn) then |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1695 |
begin |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1696 |
Gear^.Y:= Gear^.Y + int2hwFloat(yyn); |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1697 |
NextAngle |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1698 |
end; |
1089 | 1699 |
end; |
1700 |
||
1103 | 1701 |
if Gear^.Tag = 0 then |
1702 |
begin |
|
1703 |
CakeI:= (CakeI + 1) mod cakeh; |
|
1704 |
tdx:= CakePoints[CakeI].x - Gear^.X; |
|
1705 |
tdy:= - CakePoints[CakeI].y + Gear^.Y; |
|
1706 |
CakePoints[CakeI].x:= Gear^.X; |
|
1707 |
CakePoints[CakeI].y:= Gear^.Y; |
|
1708 |
Gear^.DirAngle:= DxDy2Angle(tdx, tdy); |
|
1709 |
end; |
|
1710 |
||
1089 | 1711 |
dec(Gear^.Health); |
1090 | 1712 |
if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then |
1089 | 1713 |
begin |
1109 | 1714 |
FollowGear:= Gear; |
1715 |
Gear^.doStep:= @doStepCakeDown |
|
1089 | 1716 |
end |
1088 | 1717 |
end; |
1089 | 1718 |
|
1103 | 1719 |
procedure doStepCakeUp(Gear: PGear); |
1720 |
var i: Longword; |
|
1721 |
begin |
|
1722 |
AllInactive:= false; |
|
1723 |
||
1108 | 1724 |
inc(Gear^.Tag); |
1109 | 1725 |
if Gear^.Tag < 100 then exit; |
1108 | 1726 |
Gear^.Tag:= 0; |
1727 |
||
1109 | 1728 |
if Gear^.Pos = 6 then |
1103 | 1729 |
begin |
1730 |
for i:= 0 to Pred(cakeh) do |
|
1731 |
begin |
|
1732 |
CakePoints[i].x:= Gear^.X; |
|
1733 |
CakePoints[i].y:= Gear^.Y |
|
1734 |
end; |
|
1735 |
CakeI:= 0; |
|
1736 |
Gear^.doStep:= @doStepCakeWork |
|
1109 | 1737 |
end else inc(Gear^.Pos) |
1103 | 1738 |
end; |
1739 |
||
1089 | 1740 |
procedure doStepCakeFall(Gear: PGear); |
1741 |
begin |
|
1742 |
AllInactive:= false; |
|
1743 |
||
1744 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1745 |
if TestCollisionYwithGear(Gear, 1) then |
|
1103 | 1746 |
Gear^.doStep:= @doStepCakeUp |
1089 | 1747 |
else |
1748 |
begin |
|
1749 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1750 |
if CheckGearDrowning(Gear) then AfterAttack |
|
1751 |
end |
|
1752 |
end; |
|
1753 |
||
1754 |
procedure doStepCake(Gear: PGear); |
|
1755 |
var HHGear: PGear; |
|
1756 |
begin |
|
1757 |
AllInactive:= false; |
|
1758 |
||
1759 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1103 | 1760 |
HHGear^.Message:= HHGear^.Message and (not gm_Attack); |
1089 | 1761 |
DeleteCI(HHGear); |
1762 |
||
1106 | 1763 |
FollowGear:= Gear; |
1764 |
||
1089 | 1765 |
Gear^.doStep:= @doStepCakeFall |
1766 |
end; |
|
1767 |
||
1259 | 1768 |
//////////////////////////////////////////////////////////////////////////////// |
1284 | 1769 |
procedure doStepSeductionWork(Gear: PGear); |
1770 |
var x, y: LongInt; |
|
1259 | 1771 |
begin |
1772 |
AllInactive:= false; |
|
1284 | 1773 |
|
1774 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1775 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1776 |
x:= hwRound(Gear^.X); |
|
1777 |
y:= hwRound(Gear^.Y); |
|
1259 | 1778 |
|
1284 | 1779 |
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0) then |
1780 |
if (Land[y, x] <> 0) then |
|
1781 |
begin |
|
1782 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; |
|
1783 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative; |
|
1286 | 1784 |
Gear^.dX:= Gear^.dX * _1_5; |
1785 |
Gear^.dY:= Gear^.dY * _1_5 - _0_3; |
|
1284 | 1786 |
AmmoShove(Gear, 0, 40); |
1286 | 1787 |
AfterAttack; |
1284 | 1788 |
DeleteGear(Gear) |
1789 |
end |
|
1790 |
else |
|
1791 |
else |
|
1286 | 1792 |
begin |
1793 |
AfterAttack; |
|
1284 | 1794 |
DeleteGear(Gear) |
1286 | 1795 |
end |
1796 |
end; |
|
1797 |
||
1798 |
procedure doStepSeductionWear(Gear: PGear); |
|
1799 |
begin |
|
1800 |
AllInactive:= false; |
|
1801 |
inc(Gear^.Timer); |
|
1802 |
if Gear^.Timer > 250 then |
|
1803 |
begin |
|
1804 |
Gear^.Timer:= 0; |
|
1388 | 1805 |
inc(Gear^.Pos); |
1806 |
if Gear^.Pos = 5 then |
|
1669 | 1807 |
PlaySound(sndYoohoo, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) |
1286 | 1808 |
end; |
1367 | 1809 |
|
1810 |
if Gear^.Pos = 14 then |
|
1286 | 1811 |
Gear^.doStep:= @doStepSeductionWork |
1259 | 1812 |
end; |
1284 | 1813 |
|
1814 |
procedure doStepSeduction(Gear: PGear); |
|
1815 |
begin |
|
1816 |
AllInactive:= false; |
|
1817 |
DeleteCI(PHedgehog(Gear^.Hedgehog)^.Gear); |
|
1286 | 1818 |
Gear^.doStep:= @doStepSeductionWear |
1284 | 1819 |
end; |
1298 | 1820 |
|
1821 |
//////////////////////////////////////////////////////////////////////////////// |
|
1822 |
procedure doStepWaterUp(Gear: PGear); |
|
1823 |
var i: LongWord; |
|
1824 |
begin |
|
1825 |
AllInactive:= false; |
|
1826 |
||
1827 |
inc(Gear^.Timer); |
|
1828 |
if Gear^.Timer = 17 then |
|
1829 |
Gear^.Timer:= 0 |
|
1830 |
else |
|
1831 |
exit; |
|
1832 |
||
1833 |
if cWaterLine > 0 then |
|
1834 |
begin |
|
1835 |
dec(cWaterLine); |
|
1836 |
for i:= 0 to 2047 do |
|
1837 |
Land[cWaterLine, i]:= 0; |
|
1838 |
SetAllToActive |
|
1839 |
end; |
|
1840 |
||
1841 |
inc(Gear^.Tag); |
|
1343 | 1842 |
if (Gear^.Tag = 47) or (cWaterLine = 0) then |
1298 | 1843 |
DeleteGear(Gear) |
1844 |
end; |
|
1573 | 1845 |
|
1846 |
//////////////////////////////////////////////////////////////////////////////// |
|
1590 | 1847 |
procedure doStepDrillDrilling(Gear: PGear); |
1633 | 1848 |
var t: PGearArray; |
1849 |
ox, oy: hwFloat; |
|
1573 | 1850 |
begin |
1590 | 1851 |
AllInactive:= false; |
1852 |
||
1633 | 1853 |
if (Gear^.Timer > 0) and ((Gear^.Timer mod 10) = 0) then |
1590 | 1854 |
begin |
1573 | 1855 |
ox:= Gear^.X; |
1856 |
oy:= Gear^.Y; |
|
1857 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1858 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1859 |
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6); |
|
1860 |
CheckGearDrowning(Gear); |
|
1590 | 1861 |
end; |
1862 |
||
1633 | 1863 |
t:= CheckGearsCollision(Gear); //fixes drill not exploding when touching HH bug |
1590 | 1864 |
if (Gear^.Timer = 0) |
1633 | 1865 |
or (t^.Count <> 0) |
1590 | 1866 |
or (not TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) |
1867 |
and not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) then |
|
1868 |
begin //out of time or exited ground |
|
1869 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1870 |
DeleteGear(Gear); |
|
1871 |
exit |
|
1872 |
end; |
|
1873 |
||
1874 |
dec(Gear^.Timer); |
|
1573 | 1875 |
end; |
1876 |
||
1877 |
procedure doStepDrill(Gear: PGear); |
|
1590 | 1878 |
var t: PGearArray; |
1633 | 1879 |
oldDx, oldDy: hwFloat; |
1880 |
t2: hwFloat; |
|
1573 | 1881 |
begin |
1590 | 1882 |
AllInactive:= false; |
1573 | 1883 |
|
1590 | 1884 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
1885 |
oldDx:= Gear^.dX; |
|
1886 |
oldDy:= Gear^.dY; |
|
1887 |
||
1888 |
doStepFallingGear(Gear); |
|
1889 |
||
1890 |
if (GameTicks and $3F) = 0 then |
|
1891 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1573 | 1892 |
|
1633 | 1893 |
if ((Gear^.State and gstCollision) <> 0) then begin //hit |
1590 | 1894 |
Gear^.dX:= oldDx; |
1895 |
Gear^.dY:= oldDy; |
|
1633 | 1896 |
|
1590 | 1897 |
t:= CheckGearsCollision(Gear); |
1633 | 1898 |
if (t^.Count = 0) then begin //hit the ground not the HH |
1899 |
t2 := _0_5 / Distance(Gear^.dX, Gear^.dY); |
|
1900 |
Gear^.dX:= Gear^.dX * t2; |
|
1901 |
Gear^.dY:= Gear^.dY * t2; |
|
1902 |
end else begin //explode right on contact with HH |
|
1903 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1904 |
DeleteGear(Gear); |
|
1905 |
exit; |
|
1906 |
end; |
|
1907 |
||
1590 | 1908 |
Gear^.doStep:= @doStepDrillDrilling; |
1633 | 1909 |
dec(Gear^.Timer) |
1590 | 1910 |
end |
1911 |
end; |
|
1601 | 1912 |
|
1633 | 1913 |
//////////////////////////////////////////////////////////////////////////////// |
1601 | 1914 |
procedure doStepBallgunWork(Gear: PGear); |
1915 |
var HHGear: PGear; |
|
1630 | 1916 |
rx, ry: hwFloat; |
1601 | 1917 |
begin |
1918 |
AllInactive:= false; |
|
1919 |
dec(Gear^.Timer); |
|
1920 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1921 |
HedgehogChAngle(HHGear); |
|
1922 |
if (Gear^.Timer mod 100) = 0 then |
|
1923 |
begin |
|
1630 | 1924 |
rx:= rndSign(getRandom * _0_1); |
1925 |
ry:= rndSign(getRandom * _0_1); |
|
1631
6e313b3818ef
Remove debug stuff, ballgun 64but incompatibility fixed in previous revision
unc0rr
parents:
1630
diff
changeset
|
1926 |
|
1630 | 1927 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBall, 0, |
1928 |
SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, |
|
1929 |
AngleCos(HHGear^.Angle) * ( - _0_8) + ry, |
|
1930 |
0); |
|
1601 | 1931 |
|
1669 | 1932 |
PlaySound(sndGun, false, nil); |
1601 | 1933 |
end; |
1934 |
||
1643 | 1935 |
if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then |
1601 | 1936 |
begin |
1937 |
DeleteGear(Gear); |
|
1643 | 1938 |
AfterAttack |
1939 |
end |
|
1601 | 1940 |
end; |
1941 |
||
1942 |
procedure doStepBallgun(Gear: PGear); |
|
1943 |
var HHGear: PGear; |
|
1944 |
begin |
|
1945 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1946 |
HHGear^.Message:= HHGear^.Message and not (gm_Up or gm_Down); |
|
1947 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
|
1948 |
Gear^.doStep:= @doStepBallgunWork |
|
1633 | 1949 |
end; |
1689 | 1950 |
|
1696 | 1951 |
//////////////////////////////////////////////////////////////////////////////// |
1689 | 1952 |
procedure doStepRCPlaneWork(Gear: PGear); |
1953 |
const cAngleSpeed = 3; |
|
1954 |
var HHGear: PGear; |
|
1955 |
i: LongInt; |
|
1956 |
dX, dY: hwFloat; |
|
1957 |
fChanged: boolean; |
|
1958 |
trueAngle: Longword; |
|
1959 |
t: PGear; |
|
1960 |
begin |
|
1961 |
AllInactive:= false; |
|
1962 |
||
1696 | 1963 |
if Gear^.Timer > 0 then dec(Gear^.Timer); |
1689 | 1964 |
|
1965 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1966 |
FollowGear:= Gear; |
|
1967 |
||
1968 |
fChanged:= false; |
|
1696 | 1969 |
if ((HHGear^.State and gstHHDriven) = 0) or (Gear^.Timer = 0) then |
1689 | 1970 |
begin |
1971 |
fChanged:= true; |
|
1696 | 1972 |
if Gear^.Angle > 2048 then dec(Gear^.Angle) else |
1973 |
if Gear^.Angle < 2048 then inc(Gear^.Angle) else fChanged:= false |
|
1974 |
end |
|
1975 |
else |
|
1976 |
begin |
|
1977 |
if ((Gear^.Message and gm_Left) <> 0) then |
|
1978 |
begin |
|
1979 |
fChanged:= true; |
|
1980 |
Gear^.Angle:= (Gear^.Angle + (4096 - cAngleSpeed)) mod 4096 |
|
1981 |
end; |
|
1689 | 1982 |
|
1696 | 1983 |
if ((Gear^.Message and gm_Right) <> 0) then |
1984 |
begin |
|
1985 |
fChanged:= true; |
|
1986 |
Gear^.Angle:= (Gear^.Angle + cAngleSpeed) mod 4096 |
|
1987 |
end |
|
1689 | 1988 |
end; |
1989 |
||
1990 |
if fChanged then |
|
1991 |
begin |
|
1992 |
Gear^.dX.isNegative:= (Gear^.Angle > 2048); |
|
1993 |
if Gear^.dX.isNegative then |
|
1994 |
trueAngle:= 4096 - Gear^.Angle |
|
1995 |
else |
|
1996 |
trueAngle:= Gear^.Angle; |
|
1997 |
||
1998 |
Gear^.dX:= SignAs(AngleSin(trueAngle), Gear^.dX) * _0_25; |
|
1999 |
Gear^.dY:= AngleCos(trueAngle) * -_0_25; |
|
2000 |
end; |
|
2001 |
||
2002 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
2003 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
2004 |
||
2005 |
if (GameTicks and $FF) = 0 then |
|
1698 | 2006 |
if Gear^.Timer < 3500 then |
1696 | 2007 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0) |
2008 |
else |
|
2009 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1689 | 2010 |
|
1696 | 2011 |
if ((HHGear^.Message and gm_Attack) <> 0) and (Gear^.Health <> 0) then |
1689 | 2012 |
begin |
2013 |
HHGear^.Message := HHGear^.Message and not gm_Attack; |
|
1708 | 2014 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * _0_5, 0); |
1689 | 2015 |
dec(Gear^.Health) |
1712 | 2016 |
end; |
2017 |
||
2018 |
// Ride of the Valkyries |
|
2019 |
// This does actually work, interestingly, if music is turned off |
|
2020 |
// However, I'm not actually sure how this works with game state, and some |
|
2021 |
// sort of flag specific to the purpose of avoiding duplicate playSounds might be better. Can't use lastChan reasonably, unfortunately |
|
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; |