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