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