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