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