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