author | unc0rr |
Sat, 06 Dec 2008 11:53:50 +0000 | |
changeset 1541 | 61b3b32aede8 |
parent 1528 | 3fee15104c1d |
child 1545 | 76b90ff9739a |
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 |
|
574 |
HHGear^.Message:= (HHGear^.Message or gm_Left) and not gm_Right |
|
575 |
else |
|
576 |
HHGear^.Message:= (HHGear^.Message or gm_Right) and not gm_Left; |
|
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); |
70 | 629 |
const flCheck: boolean = false; |
4 | 630 |
var HHGear: PGear; |
1504 | 631 |
len, cs, cc, tx, ty, nx, ny: hwFloat; |
632 |
lx, ly: LongInt; |
|
4 | 633 |
|
1504 | 634 |
procedure DeleteMe; |
635 |
begin |
|
636 |
with HHGear^ do |
|
637 |
begin |
|
638 |
Message:= Message and not gm_Attack; |
|
639 |
State:= State or gstMoving; |
|
640 |
end; |
|
641 |
DeleteGear(Gear) |
|
642 |
end; |
|
4 | 643 |
|
644 |
begin |
|
351 | 645 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
108 | 646 |
|
351 | 647 |
if ((HHGear^.State and gstHHDriven) = 0) |
1504 | 648 |
or (CheckGearDrowning(HHGear)) then |
649 |
begin |
|
650 |
DeleteMe; |
|
651 |
exit |
|
652 |
end; |
|
928
b9064b48b001
Some preparation work for attacking from rope, parachute and etc.
unc0rr
parents:
925
diff
changeset
|
653 |
|
351 | 654 |
Gear^.dX:= HHGear^.X - Gear^.X; |
655 |
Gear^.dY:= HHGear^.Y - Gear^.Y; |
|
4 | 656 |
|
351 | 657 |
if (Gear^.Message and gm_Left <> 0) then HHGear^.dX:= HHGear^.dX - _0_0002 else |
658 |
if (Gear^.Message and gm_Right <> 0) then HHGear^.dX:= HHGear^.dX + _0_0002; |
|
4 | 659 |
|
351 | 660 |
if not TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= HHGear^.dY + cGravity; |
4 | 661 |
|
351 | 662 |
cs:= Gear^.dY + HHGear^.dY; |
663 |
cc:= Gear^.dX + HHGear^.dX; |
|
498 | 664 |
len:= _1 / Distance(cc, cs); |
789 | 665 |
cc:= cc * len; // rope vector plus hedgehog direction vector normalized |
108 | 666 |
cs:= cs * len; |
4 | 667 |
|
1361 | 668 |
nx:= SignAs(cs, HHGear^.dX) * 7; // hedgehog direction normalized with length 7 |
669 |
ny:= SignAs(cc, HHGear^.dY) * 7; |
|
789 | 670 |
|
4 | 671 |
flCheck:= not flCheck; |
672 |
if flCheck then // check whether rope needs dividing |
|
1504 | 673 |
begin |
674 |
len:= Gear^.Elasticity - _20; |
|
675 |
while len > _5 do |
|
676 |
begin |
|
677 |
tx:= cc*len; |
|
678 |
ty:= cs*len; |
|
679 |
lx:= hwRound(Gear^.X + tx + nx); |
|
680 |
ly:= hwRound(Gear^.Y + ty + ny); |
|
681 |
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0) and (Land[ly, lx] <> 0) then |
|
682 |
begin |
|
683 |
with RopePoints.ar[RopePoints.Count] do |
|
684 |
begin |
|
685 |
X:= Gear^.X; |
|
686 |
Y:= Gear^.Y; |
|
687 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); |
|
688 |
b:= (cc * HHGear^.dY) > (cs * HHGear^.dX); |
|
689 |
dLen:= len |
|
690 |
end; |
|
691 |
Gear^.X:= Gear^.X + tx; |
|
692 |
Gear^.Y:= Gear^.Y + ty; |
|
693 |
inc(RopePoints.Count); |
|
694 |
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); |
|
695 |
Gear^.Elasticity:= Gear^.Elasticity - len; |
|
696 |
Gear^.Friction:= Gear^.Friction - len; |
|
697 |
break |
|
698 |
end; |
|
699 |
len:= len - _0_5 |
|
700 |
end; |
|
701 |
end else |
|
702 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
|
703 |
begin |
|
704 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
705 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
706 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then |
|
707 |
begin |
|
708 |
dec(RopePoints.Count); |
|
709 |
Gear^.X:=RopePoints.ar[RopePoints.Count].X; |
|
710 |
Gear^.Y:=RopePoints.ar[RopePoints.Count].Y; |
|
711 |
Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
|
712 |
Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
713 |
end |
|
714 |
end; |
|
4 | 715 |
|
351 | 716 |
Gear^.dX:= HHGear^.X - Gear^.X; |
717 |
Gear^.dY:= HHGear^.Y - Gear^.Y; |
|
108 | 718 |
|
351 | 719 |
cs:= Gear^.dY + HHGear^.dY; |
720 |
cc:= Gear^.dX + HHGear^.dX; |
|
498 | 721 |
len:= _1 / Distance(cc, cs); |
108 | 722 |
cc:= cc * len; |
723 |
cs:= cs * len; |
|
4 | 724 |
|
351 | 725 |
HHGear^.dX:= HHGear^.X; |
726 |
HHGear^.dY:= HHGear^.Y; |
|
4 | 727 |
|
351 | 728 |
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then |
1504 | 729 |
if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
730 |
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity + _0_3; |
|
4 | 731 |
|
498 | 732 |
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then |
1504 | 733 |
if not (TestCollisionXwithGear(HHGear, -hwSign(Gear^.dX)) |
734 |
or TestCollisionYwithGear(HHGear, -hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity - _0_3; |
|
4 | 735 |
|
351 | 736 |
HHGear^.X:= Gear^.X + cc*Gear^.Elasticity; |
737 |
HHGear^.Y:= Gear^.Y + cs*Gear^.Elasticity; |
|
4 | 738 |
|
351 | 739 |
HHGear^.dX:= HHGear^.X - HHGear^.dX; |
740 |
HHGear^.dY:= HHGear^.Y - HHGear^.dY; |
|
4 | 741 |
|
351 | 742 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1504 | 743 |
HHGear^.dX:= -_0_6 * HHGear^.dX; |
351 | 744 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then |
1504 | 745 |
HHGear^.dY:= -_0_6 * HHGear^.dY; |
4 | 746 |
|
789 | 747 |
len:= Distance(HHGear^.dX, HHGear^.dY); |
940 | 748 |
if len > _0_8 then |
1504 | 749 |
begin |
750 |
len:= _0_8 / len; |
|
751 |
HHGear^.dX:= HHGear^.dX * len; |
|
752 |
HHGear^.dY:= HHGear^.dY * len; |
|
753 |
end; |
|
789 | 754 |
|
351 | 755 |
if (Gear^.Message and gm_Attack) <> 0 then |
1504 | 756 |
if (Gear^.State and gsttmpFlag) <> 0 then |
757 |
DeleteMe |
|
758 |
else |
|
759 |
else |
|
760 |
if (Gear^.State and gsttmpFlag) = 0 then |
|
761 |
Gear^.State:= Gear^.State or gsttmpFlag; |
|
4 | 762 |
end; |
763 |
||
764 |
||
765 |
procedure doStepRopeAttach(Gear: PGear); |
|
766 |
var HHGear: PGear; |
|
351 | 767 |
tx, ty, tt: hwFloat; |
4 | 768 |
begin |
351 | 769 |
Gear^.X:= Gear^.X - Gear^.dX; |
770 |
Gear^.Y:= Gear^.Y - Gear^.dY; |
|
498 | 771 |
Gear^.Elasticity:= Gear^.Elasticity + _1; |
351 | 772 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
517 | 773 |
DeleteCI(HHGear); |
542 | 774 |
if (HHGear^.State and gstMoving) <> 0 then |
1433 | 775 |
if TestCollisionYwithGear(HHGear, 1) then |
776 |
begin |
|
777 |
CheckHHDamage(HHGear); |
|
778 |
HHGear^.dY:= _0; |
|
779 |
HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); |
|
780 |
end else |
|
781 |
begin |
|
782 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
|
783 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
784 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
785 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
786 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
787 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
788 |
tt:= Gear^.Elasticity; |
|
789 |
tx:= _0; |
|
790 |
ty:= _0; |
|
791 |
while tt > _20 do |
|
792 |
begin |
|
793 |
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) |
|
794 |
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then |
|
795 |
begin |
|
796 |
Gear^.X:= Gear^.X + tx; |
|
797 |
Gear^.Y:= Gear^.Y + ty; |
|
798 |
Gear^.Elasticity:= tt; |
|
799 |
Gear^.doStep:= @doStepRopeWork; |
|
800 |
with HHGear^ do State:= State and not gstAttacking; |
|
801 |
tt:= _0 |
|
802 |
end; |
|
803 |
tx:= tx + Gear^.dX + Gear^.dX; |
|
804 |
ty:= ty + Gear^.dY + Gear^.dY; |
|
805 |
tt:= tt - _2; |
|
806 |
end; |
|
807 |
end; |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
808 |
|
4 | 809 |
CheckCollision(Gear); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
810 |
|
351 | 811 |
if (Gear^.State and gstCollision) <> 0 then |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
812 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
813 |
Gear^.doStep:= @doStepRopeWork; |
974
fc16141a0128
Prevent wrong aim direction when using rope after high jump
unc0rr
parents:
963
diff
changeset
|
814 |
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
|
815 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
816 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
817 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
818 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
819 |
if Gear^.Elasticity < _10 then |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
820 |
Gear^.Elasticity:= _10000; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
821 |
end; |
4 | 822 |
|
351 | 823 |
if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then |
1433 | 824 |
begin |
825 |
with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
|
826 |
begin |
|
827 |
State:= State and not gstAttacking; |
|
828 |
Message:= Message and not gm_Attack |
|
829 |
end; |
|
830 |
DeleteGear(Gear) |
|
831 |
end |
|
4 | 832 |
end; |
833 |
||
834 |
procedure doStepRope(Gear: PGear); |
|
835 |
begin |
|
351 | 836 |
Gear^.dX:= - Gear^.dX; |
837 |
Gear^.dY:= - Gear^.dY; |
|
838 |
Gear^.doStep:= @doStepRopeAttach |
|
4 | 839 |
end; |
840 |
||
841 |
//////////////////////////////////////////////////////////////////////////////// |
|
842 |
procedure doStepSmokeTrace(Gear: PGear); |
|
843 |
begin |
|
351 | 844 |
inc(Gear^.Timer); |
845 |
if Gear^.Timer > 64 then |
|
1133 | 846 |
begin |
847 |
Gear^.Timer:= 0; |
|
848 |
dec(Gear^.State) |
|
849 |
end; |
|
351 | 850 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
851 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
852 |
if Gear^.State = 0 then DeleteGear(Gear) |
|
4 | 853 |
end; |
9 | 854 |
|
855 |
//////////////////////////////////////////////////////////////////////////////// |
|
1045 | 856 |
procedure doStepExplosionWork(Gear: PGear); |
9 | 857 |
begin |
351 | 858 |
inc(Gear^.Timer); |
859 |
if Gear^.Timer > 75 then |
|
1133 | 860 |
begin |
861 |
inc(Gear^.State); |
|
862 |
Gear^.Timer:= 0; |
|
863 |
if Gear^.State > 5 then DeleteGear(Gear) |
|
864 |
end; |
|
9 | 865 |
end; |
10 | 866 |
|
1045 | 867 |
procedure doStepExplosion(Gear: PGear); |
868 |
var i: LongWord; |
|
869 |
begin |
|
1047 | 870 |
for i:= 0 to 31 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFire); |
871 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart); |
|
872 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart2); |
|
1045 | 873 |
Gear^.doStep:= @doStepExplosionWork |
874 |
end; |
|
875 |
||
10 | 876 |
//////////////////////////////////////////////////////////////////////////////// |
877 |
procedure doStepMine(Gear: PGear); |
|
878 |
begin |
|
542 | 879 |
if (Gear^.State and gstMoving) <> 0 then |
914 | 880 |
begin |
881 |
DeleteCI(Gear); |
|
882 |
doStepFallingGear(Gear); |
|
883 |
if (Gear^.State and gstMoving) = 0 then |
|
884 |
begin |
|
885 |
AddGearCI(Gear); |
|
886 |
Gear^.dX:= _0; |
|
887 |
Gear^.dY:= _0 |
|
888 |
end; |
|
889 |
CalcRotationDirAngle(Gear); |
|
890 |
AllInactive:= false |
|
891 |
end else |
|
892 |
if ((GameTicks and $3F) = 25) then |
|
893 |
doStepFallingGear(Gear); |
|
351 | 894 |
|
895 |
if ((Gear^.State and gsttmpFlag) <> 0) then |
|
1133 | 896 |
if ((Gear^.State and gstAttacking) = 0) then |
897 |
begin |
|
898 |
if ((GameTicks and $1F) = 0) then |
|
899 |
if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking |
|
900 |
end else // gstAttacking <> 0 |
|
901 |
begin |
|
902 |
AllInactive:= false; |
|
903 |
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false); |
|
904 |
if Gear^.Timer = 0 then |
|
905 |
begin |
|
906 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
907 |
DeleteGear(Gear); |
|
908 |
exit |
|
909 |
end; |
|
910 |
dec(Gear^.Timer); |
|
911 |
end else // gsttmpFlag = 0 |
|
912 |
if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
10 | 913 |
end; |
57 | 914 |
|
39 | 915 |
//////////////////////////////////////////////////////////////////////////////// |
916 |
procedure doStepDynamite(Gear: PGear); |
|
917 |
begin |
|
43 | 918 |
doStepFallingGear(Gear); |
919 |
AllInactive:= false; |
|
351 | 920 |
if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); |
921 |
if Gear^.Timer = 0 then |
|
1133 | 922 |
begin |
923 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
|
924 |
DeleteGear(Gear); |
|
925 |
exit |
|
926 |
end; |
|
351 | 927 |
dec(Gear^.Timer); |
39 | 928 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
929 |
|
351 | 930 |
/////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
931 |
procedure doStepCase(Gear: PGear); |
371 | 932 |
var i, x, y: LongInt; |
1436 | 933 |
k: TGearType; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
934 |
begin |
351 | 935 |
if (Gear^.Message and gm_Destroy) > 0 then |
1133 | 936 |
begin |
937 |
DeleteGear(Gear); |
|
938 |
FreeActionsList; |
|
939 |
SetAllToActive; // something (hh, mine, etc...) could be on top of the case |
|
940 |
with CurrentHedgehog^ do |
|
941 |
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
|
942 |
exit |
|
943 |
end; |
|
15 | 944 |
|
351 | 945 |
if Gear^.Damage > 0 then |
1133 | 946 |
begin |
947 |
x:= hwRound(Gear^.X); |
|
948 |
y:= hwRound(Gear^.Y); |
|
1436 | 949 |
k:= Gear^.Kind; |
950 |
DeleteGear(Gear); // <-- delete gear! |
|
951 |
||
952 |
if k = gtCase then |
|
1133 | 953 |
begin |
954 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
|
955 |
for i:= 0 to 63 do |
|
956 |
AddGear(x, y, gtFlame, 0, _0, _0, 0); |
|
957 |
end; |
|
958 |
exit |
|
959 |
end; |
|
79 | 960 |
|
351 | 961 |
if (Gear^.dY.QWordValue <> 0) or (not TestCollisionYwithGear(Gear, 1)) then |
1133 | 962 |
begin |
963 |
AllInactive:= false; |
|
964 |
Gear^.dY:= Gear^.dY + cGravity; |
|
965 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
966 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else |
|
967 |
if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then |
|
968 |
begin |
|
969 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
970 |
if Gear^.dY > - _0_001 then Gear^.dY:= _0 |
|
971 |
else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false); |
|
972 |
end; |
|
973 |
CheckGearDrowning(Gear); |
|
974 |
end; |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
975 |
|
511 | 976 |
if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
1133 | 977 |
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
|
978 |
end; |
49 | 979 |
|
980 |
//////////////////////////////////////////////////////////////////////////////// |
|
557 | 981 |
const cSorterWorkTime = 640; |
982 |
var thexchar: array[0..cMaxTeams] of |
|
1133 | 983 |
record |
984 |
dy, ny, dw: LongInt; |
|
985 |
team: PTeam; |
|
986 |
SortFactor: QWord; |
|
987 |
end; |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
988 |
currsorter: PGear = nil; |
49 | 989 |
|
990 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
371 | 991 |
var i: LongInt; |
49 | 992 |
begin |
993 |
AllInactive:= false; |
|
351 | 994 |
dec(Gear^.Timer); |
995 |
if (Gear^.Timer and 15) = 0 then |
|
1133 | 996 |
for i:= 0 to Pred(TeamsCount) do |
997 |
with thexchar[i] do |
|
998 |
begin |
|
999 |
{$WARNINGS OFF} |
|
1000 |
team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; |
|
1001 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; |
|
1002 |
{$WARNINGS ON} |
|
1003 |
end; |
|
1004 |
||
351 | 1005 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
1133 | 1006 |
begin |
1007 |
if currsorter = Gear then currsorter:= nil; |
|
1008 |
DeleteGear(Gear) |
|
1009 |
end |
|
49 | 1010 |
end; |
1011 |
||
1012 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
1133 | 1013 |
var i: Longword; |
1014 |
b: boolean; |
|
1015 |
t: LongInt; |
|
49 | 1016 |
begin |
1017 |
AllInactive:= false; |
|
557 | 1018 |
|
547 | 1019 |
for t:= 0 to Pred(TeamsCount) do |
1133 | 1020 |
with thexchar[t] do |
1021 |
begin |
|
1022 |
dy:= TeamsArray[t]^.DrawHealthY; |
|
1023 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
1024 |
team:= TeamsArray[t]; |
|
1025 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
1026 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
1027 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
1028 |
end; |
|
547 | 1029 |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
1030 |
if TeamsCount > 1 then |
1133 | 1031 |
repeat |
1032 |
b:= true; |
|
1033 |
for t:= 0 to TeamsCount - 2 do |
|
1034 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
1035 |
begin |
|
1036 |
thexchar[cMaxTeams]:= thexchar[t]; |
|
1037 |
thexchar[t]:= thexchar[Succ(t)]; |
|
1038 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
|
1039 |
b:= false |
|
1040 |
end |
|
1041 |
until b; |
|
557 | 1042 |
|
1120 | 1043 |
t:= - 4; |
557 | 1044 |
for i:= 0 to Pred(TeamsCount) do |
1133 | 1045 |
with thexchar[i] do |
1046 |
begin |
|
1047 |
dec(t, team^.HealthTex^.h + 2); |
|
1048 |
ny:= t; |
|
1049 |
dy:= dy - ny |
|
1050 |
end; |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
1051 |
|
557 | 1052 |
Gear^.Timer:= cSorterWorkTime; |
351 | 1053 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
143 | 1054 |
currsorter:= Gear |
49 | 1055 |
end; |
1056 |
||
79 | 1057 |
//////////////////////////////////////////////////////////////////////////////// |
854 | 1058 |
procedure doStepIdle(Gear: PGear); |
1059 |
begin |
|
1060 |
AllInactive:= false; |
|
925 | 1061 |
dec(Gear^.Timer); |
854 | 1062 |
if Gear^.Timer = 0 then |
1063 |
begin |
|
1064 |
DeleteGear(Gear); |
|
1065 |
AfterAttack |
|
1066 |
end |
|
1067 |
end; |
|
1068 |
||
79 | 1069 |
procedure doStepShover(Gear: PGear); |
1070 |
var HHGear: PGear; |
|
1071 |
begin |
|
351 | 1072 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1073 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1074 |
DeleteCI(HHGear); |
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1075 |
|
79 | 1076 |
AmmoShove(Gear, 30, 115); |
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1077 |
|
351 | 1078 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
854 | 1079 |
Gear^.Timer:= 250; |
1080 |
Gear^.doStep:= @doStepIdle |
|
79 | 1081 |
end; |
1082 |
||
1083 |
//////////////////////////////////////////////////////////////////////////////// |
|
925 | 1084 |
procedure doStepWhip(Gear: PGear); |
1085 |
var HHGear: PGear; |
|
1086 |
i: LongInt; |
|
1087 |
begin |
|
1088 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1089 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1090 |
DeleteCI(HHGear); |
925 | 1091 |
|
1092 |
for i:= 0 to 3 do |
|
1093 |
begin |
|
1094 |
AmmoShove(Gear, 30, 25); |
|
1095 |
Gear^.X:= Gear^.X + Gear^.dX * 5 |
|
1096 |
end; |
|
1097 |
||
1098 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
|
1099 |
Gear^.Timer:= 250; |
|
1100 |
Gear^.doStep:= @doStepIdle |
|
1101 |
end; |
|
1102 |
||
1103 |
//////////////////////////////////////////////////////////////////////////////// |
|
79 | 1104 |
procedure doStepFlame(Gear: PGear); |
1433 | 1105 |
var cWindFactor: hwFloat; |
79 | 1106 |
begin |
1107 |
AllInactive:= false; |
|
1433 | 1108 |
|
79 | 1109 |
if not TestCollisionYwithGear(Gear, 1) then |
1133 | 1110 |
begin |
1433 | 1111 |
cWindFactor:= cWindSpeed * 270; |
1112 |
||
1113 |
if hwAbs(Gear^.dX - cWindFactor) > _0_01 then |
|
1437 | 1114 |
Gear^.dX:= (Gear^.dX - cWindFactor) * _0_995 + cWindFactor; |
1297 | 1115 |
|
1133 | 1116 |
Gear^.dY:= Gear^.dY + cGravity; |
1117 |
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; |
|
1297 | 1118 |
|
1133 | 1119 |
Gear^.X:= Gear^.X + Gear^.dX; |
1120 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1297 | 1121 |
|
1417 | 1122 |
if not (hwRound(Gear^.Y) < cWaterLine) then |
1133 | 1123 |
begin |
1124 |
DeleteGear(Gear); |
|
1125 |
exit |
|
1126 |
end |
|
1127 |
end else begin |
|
1128 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
|
1129 |
else begin |
|
1528 | 1130 |
Gear^.Radius:= 7; |
1297 | 1131 |
AmmoShove(Gear, 3, 100); |
1132 |
Gear^.Radius:= 1; |
|
1133 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 4, EXPLNoDamage); |
|
1133 | 1134 |
dec(Gear^.Health); |
1297 | 1135 |
Gear^.Timer:= 1250 - Gear^.Tag * 12 |
1133 | 1136 |
end |
1137 |
end; |
|
79 | 1138 |
|
1295 | 1139 |
//if (((GameTicks div 8) mod 64) = Gear^.Tag) then |
1140 |
// AmmoFlameWork(Gear); |
|
79 | 1141 |
|
351 | 1142 |
if Gear^.Health = 0 then |
1133 | 1143 |
DeleteGear(Gear) |
79 | 1144 |
end; |
82 | 1145 |
|
1146 |
//////////////////////////////////////////////////////////////////////////////// |
|
1147 |
procedure doStepFirePunchWork(Gear: PGear); |
|
1148 |
var HHGear: PGear; |
|
1149 |
begin |
|
1150 |
AllInactive:= false; |
|
351 | 1151 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
1133 | 1152 |
begin |
1153 |
DeleteGear(Gear); |
|
1154 |
AfterAttack; |
|
1155 |
exit |
|
1156 |
end; |
|
82 | 1157 |
|
351 | 1158 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1159 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
1133 | 1160 |
begin |
1161 |
Gear^.Tag:= hwRound(HHGear^.Y); |
|
1162 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
|
1163 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1164 |
Gear^.Y:= HHGear^.Y; |
|
1165 |
AmmoShove(Gear, 30, 40); |
|
1166 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
|
1167 |
end; |
|
351 | 1168 |
|
1169 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1170 |
if not (HHGear^.dY.isNegative) then |
|
1133 | 1171 |
begin |
1172 |
HHGear^.State:= HHGear^.State or gstMoving; |
|
1173 |
DeleteGear(Gear); |
|
1174 |
AfterAttack; |
|
1175 |
exit |
|
1176 |
end; |
|
351 | 1177 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1178 |
end; |
1179 |
||
1180 |
procedure doStepFirePunch(Gear: PGear); |
|
1181 |
var HHGear: PGear; |
|
1182 |
begin |
|
1183 |
AllInactive:= false; |
|
351 | 1184 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1185 |
DeleteCI(HHGear); |
498 | 1186 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1187 |
HHGear^.dX:= SignAs(cLittle, Gear^.dX); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1188 |
|
351 | 1189 |
HHGear^.dY:= - _0_3; |
82 | 1190 |
|
351 | 1191 |
Gear^.X:= HHGear^.X; |
979
edb8f208c1d9
Fix firepunch direction when attacking from high jump
unc0rr
parents:
974
diff
changeset
|
1192 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
351 | 1193 |
Gear^.dY:= - _0_9; |
1194 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1195 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
1279 | 1196 |
|
1197 |
PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false) |
|
82 | 1198 |
end; |
1199 |
||
263 | 1200 |
//////////////////////////////////////////////////////////////////////////////// |
1201 |
||
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1202 |
procedure doStepParachuteWork(Gear: PGear); |
211 | 1203 |
var HHGear: PGear; |
1204 |
begin |
|
351 | 1205 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
82 | 1206 |
|
516 | 1207 |
inc(Gear^.Timer); |
1208 |
||
212 | 1209 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1210 |
or ((HHGear^.State and gstHHDriven) = 0) |
1211 |
or CheckGearDrowning(HHGear) |
|
1212 |
or ((Gear^.Message and gm_Attack) <> 0) then |
|
1213 |
begin |
|
1214 |
with HHGear^ do |
|
1215 |
begin |
|
1216 |
Message:= 0; |
|
1217 |
SetLittle(dX); |
|
1218 |
dY:= _0; |
|
1219 |
State:= State or gstMoving; |
|
1220 |
end; |
|
1221 |
DeleteGear(Gear); |
|
1222 |
exit |
|
1223 |
end; |
|
211 | 1224 |
|
351 | 1225 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1133 | 1226 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
211 | 1227 |
|
351 | 1228 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1229 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1230 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1231 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1232 |
|
351 | 1233 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1234 |
Gear^.X:= HHGear^.X; |
1235 |
Gear^.Y:= HHGear^.Y |
|
263 | 1236 |
end; |
211 | 1237 |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1238 |
procedure doStepParachute(Gear: PGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1239 |
var HHGear: PGear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1240 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1241 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1242 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1243 |
DeleteCI(HHGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1244 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1245 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1246 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1247 |
|
931 | 1248 |
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
|
1249 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1250 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1251 |
Gear^.doStep:= @doStepParachuteWork; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1252 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1253 |
Gear^.Message:= HHGear^.Message; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1254 |
doStepParachuteWork(Gear) |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1255 |
end; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1256 |
|
263 | 1257 |
//////////////////////////////////////////////////////////////////////////////// |
1258 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1507 | 1259 |
var i: Longint; |
263 | 1260 |
begin |
1261 |
AllInactive:= false; |
|
498 | 1262 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
1124 | 1263 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1264 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
1124 | 1265 |
begin |
1266 |
dec(Gear^.Health); |
|
1267 |
case Gear^.State of |
|
1268 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1269 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1507 | 1270 |
2: for i:= -17 to 17 do |
1271 |
FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, _0_01 * i, _0, 0); |
|
1124 | 1272 |
end; |
1273 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
|
1274 |
end; |
|
1275 |
||
1276 |
if (GameTicks and $3F) = 0 then |
|
1277 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1278 |
||
498 | 1279 |
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1280 |
end; |
1281 |
||
1282 |
procedure doStepAirAttack(Gear: PGear); |
|
1283 |
begin |
|
1284 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1285 |
|
1507 | 1286 |
if Gear^.X.QWordValue = 0 then |
1287 |
Gear^.Tag:= 1 |
|
1288 |
else |
|
1289 |
Gear^.Tag:= -1; |
|
1290 |
||
498 | 1291 |
Gear^.X:= _1024 - _2048 * Gear^.Tag; |
1124 | 1292 |
Gear^.Y:= -_300; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1293 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1294 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1295 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
1133 | 1296 |
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
|
1297 |
|
351 | 1298 |
Gear^.Health:= 6; |
801 | 1299 |
Gear^.doStep:= @doStepAirAttackWork; |
1300 |
PlaySound(sndIncoming, false) |
|
263 | 1301 |
end; |
1302 |
||
1303 |
//////////////////////////////////////////////////////////////////////////////// |
|
1304 |
||
1305 |
procedure doStepAirBomb(Gear: PGear); |
|
1306 |
begin |
|
1307 |
AllInactive:= false; |
|
1308 |
doStepFallingGear(Gear); |
|
351 | 1309 |
if (Gear^.State and gstCollision) <> 0 then |
1133 | 1310 |
begin |
1311 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1312 |
DeleteGear(Gear); |
|
1313 |
exit |
|
1314 |
end; |
|
263 | 1315 |
if (GameTicks and $3F) = 0 then |
1133 | 1316 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1317 |
end; |
409 | 1318 |
|
1319 |
//////////////////////////////////////////////////////////////////////////////// |
|
1320 |
||
1321 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1322 |
var HHGear: PGear; |
409 | 1323 |
begin |
1324 |
AllInactive:= false; |
|
415 | 1325 |
|
1326 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1327 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1328 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1329 |
sprAmGirder, Gear^.State, true) then |
1133 | 1330 |
begin |
1331 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1332 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1333 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1334 |
DeleteGear(Gear); |
|
1335 |
isCursorVisible:= true |
|
1336 |
end |
|
1337 |
else begin |
|
1338 |
DeleteGear(Gear); |
|
1339 |
AfterAttack |
|
1340 |
end; |
|
415 | 1341 |
TargetPoint.X:= NoPointX |
409 | 1342 |
end; |
520 | 1343 |
|
1344 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1345 |
procedure doStepTeleportAfter(Gear: PGear); |
912 | 1346 |
var HHGear: PGear; |
1347 |
begin |
|
1348 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1349 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases |
|
1350 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1351 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1352 |
or CheckGearDrowning(HHGear) then |
1353 |
begin |
|
1354 |
DeleteGear(Gear); |
|
1355 |
AfterAttack |
|
1356 |
end |
|
912 | 1357 |
end; |
1358 |
||
1359 |
procedure doStepTeleportAnim(Gear: PGear); |
|
525 | 1360 |
begin |
853 | 1361 |
inc(Gear^.Timer); |
1362 |
if Gear^.Timer = 65 then |
|
1363 |
begin |
|
1364 |
Gear^.Timer:= 0; |
|
1365 |
inc(Gear^.Pos); |
|
1366 |
if Gear^.Pos = 11 then |
|
912 | 1367 |
Gear^.doStep:= @doStepTeleportAfter |
853 | 1368 |
end |
525 | 1369 |
end; |
520 | 1370 |
|
1371 |
procedure doStepTeleport(Gear: PGear); |
|
1372 |
var HHGear: PGear; |
|
1373 |
begin |
|
1374 |
AllInactive:= false; |
|
1375 |
||
1376 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1377 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1378 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1379 |
sprHHTelepMask, 0, false) then |
|
853 | 1380 |
begin |
1381 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1382 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1383 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1384 |
DeleteGear(Gear); |
|
1385 |
isCursorVisible:= true |
|
1386 |
end |
|
1387 |
else begin |
|
1388 |
DeleteCI(HHGear); |
|
1389 |
SetAllHHToActive; |
|
912 | 1390 |
Gear^.doStep:= @doStepTeleportAnim; |
853 | 1391 |
Gear^.X:= HHGear^.X; |
1392 |
Gear^.Y:= HHGear^.Y; |
|
1393 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1394 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1395 |
HHGear^.State:= HHGear^.State or gstMoving |
|
1396 |
end; |
|
520 | 1397 |
TargetPoint.X:= NoPointX |
1398 |
end; |
|
534 | 1399 |
|
1400 |
//////////////////////////////////////////////////////////////////////////////// |
|
1401 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1402 |
var HHGear: PGear; |
|
1403 |
Msg, State: Longword; |
|
1404 |
begin |
|
1405 |
AllInactive:= false; |
|
1406 |
||
540 | 1407 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
1133 | 1408 |
begin |
1409 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1410 |
Msg:= Gear^.Message and not gm_Switch; |
|
1411 |
DeleteGear(Gear); |
|
1412 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
|
1413 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1414 |
|
1133 | 1415 |
HHGear:= CurrentHedgehog^.Gear; |
1416 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
1417 |
HHGear^.Message:= Msg; |
|
1418 |
exit |
|
1419 |
end; |
|
534 | 1420 |
|
1421 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1133 | 1422 |
begin |
1423 |
HHGear:= CurrentHedgehog^.Gear; |
|
1424 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
|
1425 |
Gear^.Message:= Gear^.Message and not gm_Switch; |
|
1426 |
State:= HHGear^.State; |
|
1427 |
HHGear^.State:= 0; |
|
1428 |
HHGear^.Active:= false; |
|
1429 |
HHGear^.Z:= cHHZ; |
|
1430 |
RemoveGearFromList(HHGear); |
|
1431 |
InsertGearToList(HHGear); |
|
534 | 1432 |
|
1133 | 1433 |
repeat |
1434 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
|
1435 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
|
652 | 1436 |
|
1133 | 1437 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
534 | 1438 |
|
1133 | 1439 |
HHGear:= CurrentHedgehog^.Gear; |
1440 |
HHGear^.State:= State; |
|
1441 |
HHGear^.Active:= true; |
|
1442 |
FollowGear:= HHGear; |
|
1443 |
HHGear^.Z:= cCurrHHZ; |
|
1444 |
RemoveGearFromList(HHGear); |
|
1445 |
InsertGearToList(HHGear); |
|
1446 |
Gear^.X:= HHGear^.X; |
|
1447 |
Gear^.Y:= HHGear^.Y |
|
1448 |
end; |
|
534 | 1449 |
end; |
1450 |
||
1451 |
procedure doStepSwitcher(Gear: PGear); |
|
1452 |
var HHGear: PGear; |
|
1453 |
begin |
|
1454 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1455 |
||
1456 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1457 |
with HHGear^ do |
|
1133 | 1458 |
begin |
1459 |
State:= State and not gstAttacking; |
|
1460 |
Message:= Message and not gm_Attack |
|
1461 |
end |
|
534 | 1462 |
end; |
924 | 1463 |
|
1464 |
//////////////////////////////////////////////////////////////////////////////// |
|
1465 |
procedure doStepMortar(Gear: PGear); |
|
1466 |
var dX, dY: hwFloat; |
|
1467 |
i: LongInt; |
|
963 | 1468 |
dxn, dyn: boolean; |
924 | 1469 |
begin |
1470 |
AllInactive:= false; |
|
963 | 1471 |
dxn:= Gear^.dX.isNegative; |
1472 |
dyn:= Gear^.dY.isNegative; |
|
1473 |
||
924 | 1474 |
doStepFallingGear(Gear); |
1475 |
if (Gear^.State and gstCollision) <> 0 then |
|
1476 |
begin |
|
1477 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
963 | 1478 |
|
1479 |
Gear^.dX.isNegative:= not dxn; |
|
1480 |
Gear^.dY.isNegative:= not dyn; |
|
924 | 1481 |
for i:= 0 to 4 do |
1482 |
begin |
|
963 | 1483 |
dX:= Gear^.dX + (GetRandom - _0_5) * _0_03; |
1484 |
dY:= Gear^.dY + (GetRandom - _0_5) * _0_03; |
|
1273 | 1485 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); |
924 | 1486 |
end; |
1487 |
||
1488 |
DeleteGear(Gear); |
|
1489 |
exit |
|
1490 |
end; |
|
963 | 1491 |
|
924 | 1492 |
if (GameTicks and $3F) = 0 then |
1493 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
1494 |
end; |
|
984 | 1495 |
|
1496 |
//////////////////////////////////////////////////////////////////////////////// |
|
1497 |
procedure doStepKamikazeWork(Gear: PGear); |
|
1498 |
const upd: Longword = 0; |
|
987 | 1499 |
var i: LongWord; |
984 | 1500 |
HHGear: PGear; |
1501 |
begin |
|
1502 |
AllInactive:= false; |
|
1503 |
||
1504 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1505 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1506 |
DeleteCI(HHGear); |
|
1507 |
||
1508 |
i:= 2; |
|
1509 |
repeat |
|
1510 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
1511 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
1512 |
HHGear^.X:= Gear^.X; |
|
1513 |
HHGear^.Y:= Gear^.Y; |
|
1514 |
||
1515 |
inc(Gear^.Damage, 2); |
|
1516 |
||
1200 | 1517 |
// if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
1518 |
// or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); |
|
984 | 1519 |
|
1520 |
dec(i) |
|
1521 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
|
1522 |
||
1523 |
inc(upd); |
|
1524 |
if upd > 3 then |
|
1525 |
begin |
|
987 | 1526 |
if Gear^.Health < 1500 then Gear^.Pos:= 2; |
1527 |
||
984 | 1528 |
AmmoShove(Gear, 30, 40); |
1529 |
||
1530 |
DrawTunnel(HHGear^.X - HHGear^.dX * 10, |
|
1200 | 1531 |
HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2, |
984 | 1532 |
HHGear^.dX, |
1533 |
HHGear^.dY, |
|
1534 |
20 + cHHRadius * 2, |
|
1200 | 1535 |
cHHRadius * 2 + 6); |
984 | 1536 |
|
1537 |
upd:= 0 |
|
1538 |
end; |
|
1539 |
||
1540 |
if Gear^.Health < Gear^.Damage then |
|
1541 |
begin |
|
1542 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1543 |
AfterAttack; |
|
1544 |
DeleteGear(Gear); |
|
1545 |
DeleteGear(HHGear); |
|
1546 |
end else |
|
1547 |
begin |
|
1548 |
dec(Gear^.Health, Gear^.Damage); |
|
1549 |
Gear^.Damage:= 0 |
|
1550 |
end |
|
1551 |
end; |
|
1552 |
||
987 | 1553 |
procedure doStepKamikazeIdle(Gear: PGear); |
1554 |
begin |
|
1555 |
AllInactive:= false; |
|
1556 |
dec(Gear^.Timer); |
|
1557 |
if Gear^.Timer = 0 then |
|
1558 |
begin |
|
1559 |
Gear^.Pos:= 1; |
|
992 | 1560 |
PlaySound(sndKamikaze, false); |
987 | 1561 |
Gear^.doStep:= @doStepKamikazeWork |
1562 |
end |
|
1563 |
end; |
|
1564 |
||
984 | 1565 |
procedure doStepKamikaze(Gear: PGear); |
1566 |
var HHGear: PGear; |
|
1567 |
begin |
|
1568 |
AllInactive:= false; |
|
1569 |
||
1570 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1571 |
||
1572 |
HHGear^.dX:= Gear^.dX; |
|
1573 |
HHGear^.dY:= Gear^.dY; |
|
1574 |
||
1575 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
|
1576 |
Gear^.dY:= - _0_9; |
|
1577 |
||
987 | 1578 |
Gear^.Timer:= 550; |
1579 |
||
1580 |
Gear^.doStep:= @doStepKamikazeIdle |
|
984 | 1581 |
end; |
1582 |
||
1103 | 1583 |
//////////////////////////////////////////////////////////////////////////////// |
1584 |
const cakeh = 27; |
|
1110 | 1585 |
cakeDmg = 75; |
1103 | 1586 |
var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; end; |
1587 |
CakeI: Longword; |
|
1588 |
||
1110 | 1589 |
procedure doStepCakeExpl(Gear: PGear); |
1590 |
begin |
|
1591 |
inc(Gear^.Tag); |
|
1592 |
if Gear^.Tag < 2250 then exit; |
|
1593 |
||
1594 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, EXPLAutoSound); |
|
1595 |
AfterAttack; |
|
1596 |
DeleteGear(Gear) |
|
1597 |
end; |
|
1598 |
||
1109 | 1599 |
procedure doStepCakeDown(Gear: PGear); |
1133 | 1600 |
var gi: PGear; |
1601 |
dmg: LongInt; |
|
1109 | 1602 |
begin |
1603 |
AllInactive:= false; |
|
1604 |
||
1605 |
inc(Gear^.Tag); |
|
1606 |
if Gear^.Tag < 100 then exit; |
|
1607 |
Gear^.Tag:= 0; |
|
1608 |
||
1609 |
if Gear^.Pos = 0 then |
|
1610 |
begin |
|
1110 | 1611 |
gi:= GearsList; |
1612 |
while gi <> nil do |
|
1613 |
begin |
|
1614 |
dmg:= cakeDmg * 2 - hwRound(Distance(gi^.X - Gear^.X, gi^.Y - Gear^.Y)); |
|
1615 |
if (dmg > 1) and (gi^.Kind = gtHedgehog) then |
|
1616 |
gi^.State:= gi^.State or gstWinner; |
|
1617 |
gi:= gi^.NextGear |
|
1618 |
end; |
|
1619 |
Gear^.doStep:= @doStepCakeExpl; |
|
1111 | 1620 |
PlaySound(sndCake, false) |
1109 | 1621 |
end else dec(Gear^.Pos) |
1622 |
end; |
|
1623 |
||
1624 |
||
1089 | 1625 |
procedure doStepCakeWork(Gear: PGear); |
1626 |
const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0)); |
|
1627 |
var xx, yy, xxn, yyn: LongInt; |
|
1628 |
da: LongInt; |
|
1103 | 1629 |
tdx, tdy: hwFloat; |
1089 | 1630 |
|
1631 |
procedure PrevAngle; |
|
1632 |
begin |
|
1133 | 1633 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 - dA) mod 4 |
1089 | 1634 |
end; |
1635 |
||
1636 |
procedure NextAngle; |
|
1637 |
begin |
|
1133 | 1638 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 + dA) mod 4 |
1089 | 1639 |
end; |
1640 |
||
1088 | 1641 |
begin |
1089 | 1642 |
inc(Gear^.Tag); |
1108 | 1643 |
if Gear^.Tag < 7 then exit; |
1089 | 1644 |
|
1645 |
dA:= hwSign(Gear^.dX); |
|
1646 |
xx:= dirs[Gear^.Angle].x; |
|
1647 |
yy:= dirs[Gear^.Angle].y; |
|
1133 | 1648 |
xxn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x; |
1649 |
yyn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y; |
|
1089 | 1650 |
|
1651 |
||
1652 |
if (xx = 0) then |
|
1653 |
if TestCollisionYwithGear(Gear, yy) then |
|
1654 |
PrevAngle |
|
1655 |
else begin |
|
1656 |
Gear^.Tag:= 0; |
|
1657 |
Gear^.Y:= Gear^.Y + int2hwFloat(yy); |
|
1658 |
if not TestCollisionXwithGear(Gear, xxn) then NextAngle |
|
1659 |
end; |
|
1660 |
||
1661 |
if (yy = 0) then |
|
1662 |
if TestCollisionXwithGear(Gear, xx) then |
|
1663 |
PrevAngle |
|
1664 |
else begin |
|
1665 |
Gear^.Tag:= 0; |
|
1666 |
Gear^.X:= Gear^.X + int2hwFloat(xx); |
|
1667 |
if not TestCollisionYwithGear(Gear, yyn) then NextAngle |
|
1668 |
end; |
|
1669 |
||
1103 | 1670 |
if Gear^.Tag = 0 then |
1671 |
begin |
|
1672 |
CakeI:= (CakeI + 1) mod cakeh; |
|
1673 |
tdx:= CakePoints[CakeI].x - Gear^.X; |
|
1674 |
tdy:= - CakePoints[CakeI].y + Gear^.Y; |
|
1675 |
CakePoints[CakeI].x:= Gear^.X; |
|
1676 |
CakePoints[CakeI].y:= Gear^.Y; |
|
1677 |
Gear^.DirAngle:= DxDy2Angle(tdx, tdy); |
|
1678 |
end; |
|
1679 |
||
1089 | 1680 |
dec(Gear^.Health); |
1090 | 1681 |
if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then |
1089 | 1682 |
begin |
1109 | 1683 |
FollowGear:= Gear; |
1684 |
Gear^.doStep:= @doStepCakeDown |
|
1089 | 1685 |
end |
1088 | 1686 |
end; |
1089 | 1687 |
|
1103 | 1688 |
procedure doStepCakeUp(Gear: PGear); |
1689 |
var i: Longword; |
|
1690 |
begin |
|
1691 |
AllInactive:= false; |
|
1692 |
||
1108 | 1693 |
inc(Gear^.Tag); |
1109 | 1694 |
if Gear^.Tag < 100 then exit; |
1108 | 1695 |
Gear^.Tag:= 0; |
1696 |
||
1109 | 1697 |
if Gear^.Pos = 6 then |
1103 | 1698 |
begin |
1699 |
for i:= 0 to Pred(cakeh) do |
|
1700 |
begin |
|
1701 |
CakePoints[i].x:= Gear^.X; |
|
1702 |
CakePoints[i].y:= Gear^.Y |
|
1703 |
end; |
|
1704 |
CakeI:= 0; |
|
1705 |
Gear^.doStep:= @doStepCakeWork |
|
1109 | 1706 |
end else inc(Gear^.Pos) |
1103 | 1707 |
end; |
1708 |
||
1089 | 1709 |
procedure doStepCakeFall(Gear: PGear); |
1710 |
begin |
|
1711 |
AllInactive:= false; |
|
1712 |
||
1713 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1714 |
if TestCollisionYwithGear(Gear, 1) then |
|
1103 | 1715 |
Gear^.doStep:= @doStepCakeUp |
1089 | 1716 |
else |
1717 |
begin |
|
1718 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1719 |
if CheckGearDrowning(Gear) then AfterAttack |
|
1720 |
end |
|
1721 |
end; |
|
1722 |
||
1723 |
procedure doStepCake(Gear: PGear); |
|
1724 |
var HHGear: PGear; |
|
1725 |
begin |
|
1726 |
AllInactive:= false; |
|
1727 |
||
1728 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1103 | 1729 |
HHGear^.Message:= HHGear^.Message and (not gm_Attack); |
1089 | 1730 |
DeleteCI(HHGear); |
1731 |
||
1106 | 1732 |
FollowGear:= Gear; |
1733 |
||
1089 | 1734 |
Gear^.doStep:= @doStepCakeFall |
1735 |
end; |
|
1736 |
||
1259 | 1737 |
//////////////////////////////////////////////////////////////////////////////// |
1284 | 1738 |
procedure doStepSeductionWork(Gear: PGear); |
1739 |
var x, y: LongInt; |
|
1259 | 1740 |
begin |
1741 |
AllInactive:= false; |
|
1284 | 1742 |
|
1743 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1744 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1745 |
x:= hwRound(Gear^.X); |
|
1746 |
y:= hwRound(Gear^.Y); |
|
1259 | 1747 |
|
1284 | 1748 |
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0) then |
1749 |
if (Land[y, x] <> 0) then |
|
1750 |
begin |
|
1751 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; |
|
1752 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative; |
|
1286 | 1753 |
Gear^.dX:= Gear^.dX * _1_5; |
1754 |
Gear^.dY:= Gear^.dY * _1_5 - _0_3; |
|
1284 | 1755 |
AmmoShove(Gear, 0, 40); |
1286 | 1756 |
AfterAttack; |
1284 | 1757 |
DeleteGear(Gear) |
1758 |
end |
|
1759 |
else |
|
1760 |
else |
|
1286 | 1761 |
begin |
1762 |
AfterAttack; |
|
1284 | 1763 |
DeleteGear(Gear) |
1286 | 1764 |
end |
1765 |
end; |
|
1766 |
||
1767 |
procedure doStepSeductionWear(Gear: PGear); |
|
1768 |
begin |
|
1769 |
AllInactive:= false; |
|
1770 |
inc(Gear^.Timer); |
|
1771 |
if Gear^.Timer > 250 then |
|
1772 |
begin |
|
1773 |
Gear^.Timer:= 0; |
|
1388 | 1774 |
inc(Gear^.Pos); |
1775 |
if Gear^.Pos = 5 then |
|
1776 |
PlaySound(sndYoohoo, false) |
|
1286 | 1777 |
end; |
1367 | 1778 |
|
1779 |
if Gear^.Pos = 14 then |
|
1286 | 1780 |
Gear^.doStep:= @doStepSeductionWork |
1259 | 1781 |
end; |
1284 | 1782 |
|
1783 |
procedure doStepSeduction(Gear: PGear); |
|
1784 |
begin |
|
1785 |
AllInactive:= false; |
|
1786 |
DeleteCI(PHedgehog(Gear^.Hedgehog)^.Gear); |
|
1286 | 1787 |
Gear^.doStep:= @doStepSeductionWear |
1284 | 1788 |
end; |
1298 | 1789 |
|
1790 |
//////////////////////////////////////////////////////////////////////////////// |
|
1791 |
procedure doStepWaterUp(Gear: PGear); |
|
1792 |
var i: LongWord; |
|
1793 |
begin |
|
1794 |
AllInactive:= false; |
|
1795 |
||
1796 |
inc(Gear^.Timer); |
|
1797 |
if Gear^.Timer = 17 then |
|
1798 |
Gear^.Timer:= 0 |
|
1799 |
else |
|
1800 |
exit; |
|
1801 |
||
1802 |
if cWaterLine > 0 then |
|
1803 |
begin |
|
1804 |
dec(cWaterLine); |
|
1805 |
for i:= 0 to 2047 do |
|
1806 |
Land[cWaterLine, i]:= 0; |
|
1807 |
SetAllToActive |
|
1808 |
end; |
|
1809 |
||
1810 |
inc(Gear^.Tag); |
|
1343 | 1811 |
if (Gear^.Tag = 47) or (cWaterLine = 0) then |
1298 | 1812 |
DeleteGear(Gear) |
1813 |
end; |