author | unc0rr |
Sat, 07 Mar 2009 17:49:11 +0000 | |
changeset 1867 | 2fc0e1e39b11 |
parent 1865 | ebc6dfca60d4 |
child 1869 | 490005509a7b |
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 |
|
1867 | 51 |
if (CurrentHedgehog^.Gear = Gear) and (not Gear^.Invulnerable) then |
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); |
|