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