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