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