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