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