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