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