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