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