author | unc0rr |
Thu, 24 May 2007 20:33:07 +0000 | |
changeset 521 | bc8fd78d7598 |
parent 520 | e83dfb7ffead |
child 522 | ca089787f59d |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
393 | 3 |
* Copyright (c) 2004-2007 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 |
4 | 24 |
begin |
351 | 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)) |
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); |
|
41 |
begin |
|
498 | 42 |
if _0_4 < Gear^.dY then Gear^.Damage:= Gear^.Damage + 1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70); |
4 | 43 |
end; |
44 |
||
45 |
//////////////////////////////////////////////////////////////////////////////// |
|
46 |
//////////////////////////////////////////////////////////////////////////////// |
|
47 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
351 | 48 |
var dAngle: hwFloat; |
4 | 49 |
begin |
351 | 50 |
dAngle:= (hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) * _0_1; |
51 |
if not Gear^.dX.isNegative then Gear^.DirAngle:= Gear^.DirAngle + dAngle |
|
52 |
else Gear^.DirAngle:= Gear^.DirAngle - dAngle; |
|
498 | 53 |
if Gear^.DirAngle.isNegative then Gear^.DirAngle:= Gear^.DirAngle + _16 |
54 |
else if _16 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle - _16 |
|
4 | 55 |
end; |
56 |
||
57 |
//////////////////////////////////////////////////////////////////////////////// |
|
58 |
procedure doStepDrowningGear(Gear: PGear); |
|
59 |
begin |
|
60 |
AllInactive:= false; |
|
351 | 61 |
Gear^.Y:= Gear^.Y + cDrownSpeed; |
62 |
if hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear) |
|
4 | 63 |
end; |
64 |
||
65 |
//////////////////////////////////////////////////////////////////////////////// |
|
66 |
procedure doStepFallingGear(Gear: PGear); |
|
67 |
begin |
|
503 | 68 |
Gear^.State:= Gear^.State and not gstCollision; |
69 |
||
70 |
if Gear^.dY.isNegative then |
|
4 | 71 |
begin |
503 | 72 |
Gear^.State:= Gear^.State or gstFalling; |
73 |
if TestCollisionYwithGear(Gear, -1) then |
|
74 |
begin |
|
75 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
76 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
77 |
Gear^.State:= Gear^.State or gstCollision |
|
78 |
end |
|
79 |
end else |
|
80 |
if TestCollisionYwithGear(Gear, 1) then |
|
81 |
begin |
|
82 |
Gear^.State:= Gear^.State and not gstFalling; |
|
83 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
84 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
85 |
Gear^.State:= Gear^.State or gstCollision |
|
86 |
end else Gear^.State:= Gear^.State or gstFalling; |
|
87 |
||
351 | 88 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
4 | 89 |
begin |
351 | 90 |
Gear^.dX:= - Gear^.dX * Gear^.Elasticity; |
91 |
Gear^.State:= Gear^.State or gstCollision |
|
4 | 92 |
end; |
503 | 93 |
|
94 |
if (Gear^.State and gstFalling) <> 0 then Gear^.dY:= Gear^.dY + cGravity; |
|
95 |
||
351 | 96 |
Gear^.X:= Gear^.X + Gear^.dX; |
97 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
4 | 98 |
CheckGearDrowning(Gear); |
503 | 99 |
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and |
100 |
((Gear^.State and gstFalling) = 0) then Gear^.State:= Gear^.State and not gstMoving |
|
101 |
else Gear^.State:= Gear^.State or gstMoving |
|
4 | 102 |
end; |
103 |
||
104 |
//////////////////////////////////////////////////////////////////////////////// |
|
105 |
procedure doStepCloud(Gear: PGear); |
|
106 |
begin |
|
351 | 107 |
Gear^.X:= Gear^.X + cWindSpeed * 200 + Gear^.dX; |
498 | 108 |
if hwRound(Gear^.Y) > -160 then Gear^.dY:= Gear^.dY - _1div50000 |
109 |
else Gear^.dY:= Gear^.dY + _1div50000; |
|
351 | 110 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
498 | 111 |
if hwRound(Gear^.X) < -cScreenWidth - 256 then Gear^.X:= int2hwFloat(cScreenWidth + 2048) else |
112 |
if hwRound(Gear^.X) > cScreenWidth + 2048 then Gear^.X:= int2hwFloat(-cScreenWidth - 256) |
|
4 | 113 |
end; |
114 |
||
115 |
//////////////////////////////////////////////////////////////////////////////// |
|
116 |
procedure doStepBomb(Gear: PGear); |
|
371 | 117 |
var i: LongInt; |
4 | 118 |
begin |
119 |
AllInactive:= false; |
|
120 |
doStepFallingGear(Gear); |
|
351 | 121 |
dec(Gear^.Timer); |
122 |
if Gear^.Timer = 0 then |
|
4 | 123 |
begin |
351 | 124 |
case Gear^.Kind of |
125 |
gtAmmo_Bomb: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
78 | 126 |
gtClusterBomb: begin |
351 | 127 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
78 | 128 |
for i:= 0 to 4 do |
498 | 129 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, (getrandom - _0_5) * _0_2, (getrandom - _3) * _0_08, 0); |
78 | 130 |
end |
131 |
end; |
|
4 | 132 |
DeleteGear(Gear); |
133 |
exit |
|
134 |
end; |
|
135 |
CalcRotationDirAngle(Gear); |
|
351 | 136 |
if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then PlaySound(sndGrenadeImpact, false) |
4 | 137 |
end; |
138 |
||
78 | 139 |
procedure doStepCluster(Gear: PGear); |
140 |
begin |
|
141 |
AllInactive:= false; |
|
142 |
doStepFallingGear(Gear); |
|
351 | 143 |
if (Gear^.State and gstCollision) <> 0 then |
78 | 144 |
begin |
351 | 145 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
78 | 146 |
DeleteGear(Gear); |
147 |
exit |
|
148 |
end; |
|
149 |
if (GameTicks and $1F) = 0 then |
|
498 | 150 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
78 | 151 |
end; |
152 |
||
4 | 153 |
//////////////////////////////////////////////////////////////////////////////// |
154 |
procedure doStepGrenade(Gear: PGear); |
|
155 |
begin |
|
156 |
AllInactive:= false; |
|
351 | 157 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
4 | 158 |
doStepFallingGear(Gear); |
351 | 159 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 160 |
begin |
351 | 161 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
4 | 162 |
DeleteGear(Gear); |
163 |
exit |
|
164 |
end; |
|
165 |
if (GameTicks and $3F) = 0 then |
|
498 | 166 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
4 | 167 |
end; |
168 |
||
169 |
//////////////////////////////////////////////////////////////////////////////// |
|
95 | 170 |
procedure doStepHealthTagWork(Gear: PGear); |
4 | 171 |
begin |
172 |
AllInactive:= false; |
|
351 | 173 |
dec(Gear^.Timer); |
174 |
Gear^.Y:= Gear^.Y - _0_08; |
|
175 |
if Gear^.Timer = 0 then |
|
4 | 176 |
begin |
351 | 177 |
PHedgehog(Gear^.Hedgehog)^.Gear^.Active:= true; // to let current hh die |
4 | 178 |
DeleteGear(Gear) |
179 |
end |
|
180 |
end; |
|
181 |
||
263 | 182 |
procedure doStepHealthTagWorkUnderWater(Gear: PGear); |
183 |
begin |
|
184 |
AllInactive:= false; |
|
351 | 185 |
Gear^.Y:= Gear^.Y - _0_08; |
498 | 186 |
if hwRound(Gear^.Y) < cWaterLine + 10 then |
263 | 187 |
DeleteGear(Gear) |
188 |
end; |
|
189 |
||
95 | 190 |
procedure doStepHealthTag(Gear: PGear); |
191 |
var s: shortstring; |
|
192 |
begin |
|
193 |
AllInactive:= false; |
|
351 | 194 |
str(Gear^.State, s); |
195 |
Gear^.Surf:= RenderString(s, PHedgehog(Gear^.Hedgehog)^.Team^.Color, fnt16); |
|
498 | 196 |
if hwRound(Gear^.Y) < cWaterLine then Gear^.doStep:= @doStepHealthTagWork |
197 |
else Gear^.doStep:= @doStepHealthTagWorkUnderWater |
|
95 | 198 |
end; |
199 |
||
4 | 200 |
//////////////////////////////////////////////////////////////////////////////// |
201 |
procedure doStepGrave(Gear: PGear); |
|
202 |
begin |
|
203 |
AllInactive:= false; |
|
498 | 204 |
if Gear^.dY.isNegative then |
205 |
if TestCollisionY(Gear, -1) then Gear^.dY:= _0; |
|
4 | 206 |
|
351 | 207 |
if not Gear^.dY.isNegative then |
68 | 208 |
if TestCollisionY(Gear, 1) then |
4 | 209 |
begin |
351 | 210 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
211 |
if Gear^.dY > - _1div1024 then |
|
4 | 212 |
begin |
351 | 213 |
Gear^.Active:= false; |
4 | 214 |
exit |
351 | 215 |
end else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false) |
4 | 216 |
end; |
351 | 217 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
4 | 218 |
CheckGearDrowning(Gear); |
351 | 219 |
Gear^.dY:= Gear^.dY + cGravity |
4 | 220 |
end; |
221 |
||
222 |
//////////////////////////////////////////////////////////////////////////////// |
|
223 |
procedure doStepUFOWork(Gear: PGear); |
|
351 | 224 |
var t: hwFloat; |
374 | 225 |
y: LongInt; |
4 | 226 |
begin |
227 |
AllInactive:= false; |
|
351 | 228 |
t:= Distance(Gear^.dX, Gear^.dY); |
229 |
Gear^.dX:= Gear^.Elasticity * (Gear^.dX + _0_000004 * (TargetPoint.X - hwRound(Gear^.X))); |
|
230 |
Gear^.dY:= Gear^.Elasticity * (Gear^.dY + _0_000004 * (TargetPoint.Y - hwRound(Gear^.Y))); |
|
231 |
t:= t / Distance(Gear^.dX, Gear^.dY); |
|
232 |
Gear^.dX:= Gear^.dX * t; |
|
233 |
Gear^.dY:= Gear^.dY * t; |
|
234 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
235 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
374 | 236 |
|
237 |
if (GameTicks and $3F) = 0 then |
|
238 |
begin |
|
239 |
y:= hwRound(Gear^.Y); |
|
240 |
if y + Gear^.Radius < cWaterLine then |
|
498 | 241 |
AddGear(hwRound(Gear^.X), y, gtSmokeTrace, 0, _0, _0, 0); |
374 | 242 |
end; |
243 |
||
4 | 244 |
CheckCollision(Gear); |
351 | 245 |
dec(Gear^.Timer); |
246 |
if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then |
|
4 | 247 |
begin |
351 | 248 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
4 | 249 |
DeleteGear(Gear); |
250 |
end; |
|
251 |
end; |
|
252 |
||
253 |
procedure doStepUFO(Gear: PGear); |
|
254 |
begin |
|
255 |
AllInactive:= false; |
|
351 | 256 |
Gear^.X:= Gear^.X + Gear^.dX; |
257 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
258 |
Gear^.dY:= Gear^.dY + cGravity; |
|
4 | 259 |
CheckCollision(Gear); |
351 | 260 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 261 |
begin |
351 | 262 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
4 | 263 |
DeleteGear(Gear); |
264 |
exit |
|
265 |
end; |
|
351 | 266 |
dec(Gear^.Timer); |
267 |
if Gear^.Timer = 0 then |
|
4 | 268 |
begin |
351 | 269 |
Gear^.Timer:= 5000; |
270 |
Gear^.doStep:= @doStepUFOWork |
|
4 | 271 |
end; |
272 |
end; |
|
273 |
||
274 |
//////////////////////////////////////////////////////////////////////////////// |
|
275 |
procedure doStepShotgunShot(Gear: PGear); |
|
276 |
var i: LongWord; |
|
277 |
begin |
|
278 |
AllInactive:= false; |
|
351 | 279 |
if Gear^.Timer > 0 then |
4 | 280 |
begin |
351 | 281 |
dec(Gear^.Timer); |
282 |
if Gear^.Timer = 0 then PlaySound(sndShotgunFire, false); |
|
4 | 283 |
exit |
284 |
end; |
|
285 |
i:= 200; |
|
286 |
repeat |
|
351 | 287 |
Gear^.X:= Gear^.X + Gear^.dX; |
288 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
4 | 289 |
CheckCollision(Gear); |
351 | 290 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 291 |
begin |
506 | 292 |
Gear^.X:= Gear^.X + Gear^.dX * 8; |
293 |
Gear^.Y:= Gear^.Y + Gear^.dY * 8; |
|
294 |
ShotgunShot(Gear); |
|
4 | 295 |
DeleteGear(Gear); |
75 | 296 |
AfterAttack; |
4 | 297 |
exit |
298 |
end; |
|
299 |
dec(i) |
|
300 |
until i = 0; |
|
498 | 301 |
if (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then |
95 | 302 |
begin |
303 |
DeleteGear(Gear); |
|
304 |
AfterAttack |
|
305 |
end |
|
4 | 306 |
end; |
307 |
||
308 |
//////////////////////////////////////////////////////////////////////////////// |
|
38 | 309 |
procedure doStepDEagleShot(Gear: PGear); |
310 |
var i, x, y: LongWord; |
|
351 | 311 |
oX, oY: hwFloat; |
38 | 312 |
begin |
313 |
AllInactive:= false; |
|
37 | 314 |
i:= 80; |
351 | 315 |
oX:= Gear^.X; |
316 |
oY:= Gear^.Y; |
|
37 | 317 |
repeat |
351 | 318 |
Gear^.X:= Gear^.X + Gear^.dX; |
319 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
320 |
x:= hwRound(Gear^.X); |
|
321 |
y:= hwRound(Gear^.Y); |
|
38 | 322 |
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0) |
351 | 323 |
and (Land[y, x] <> 0) then inc(Gear^.Damage); |
519 | 324 |
if Gear^.Damage > 5 then AmmoShove(Gear, 7, 20); |
38 | 325 |
dec(i) |
351 | 326 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
327 |
if Gear^.Damage > 0 then |
|
37 | 328 |
begin |
351 | 329 |
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82 - i, 1); |
330 |
dec(Gear^.Health, Gear^.Damage); |
|
331 |
Gear^.Damage:= 0 |
|
37 | 332 |
end; |
498 | 333 |
if (Gear^.Health <= 0) or (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then |
37 | 334 |
DeleteGear(Gear) |
335 |
end; |
|
336 |
||
337 |
//////////////////////////////////////////////////////////////////////////////// |
|
4 | 338 |
procedure doStepActionTimer(Gear: PGear); |
339 |
begin |
|
351 | 340 |
dec(Gear^.Timer); |
341 |
case Gear^.Kind of |
|
83 | 342 |
gtATStartGame: begin |
4 | 343 |
AllInactive:= false; |
351 | 344 |
if Gear^.Timer = 0 then |
83 | 345 |
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); |
4 | 346 |
end; |
83 | 347 |
gtATSmoothWindCh: begin |
351 | 348 |
if Gear^.Timer = 0 then |
6 | 349 |
begin |
351 | 350 |
if WindBarWidth < Gear^.Tag then inc(WindBarWidth) |
351 |
else if WindBarWidth > Gear^.Tag then dec(WindBarWidth); |
|
352 |
if WindBarWidth <> Gear^.Tag then Gear^.Timer:= 10; |
|
83 | 353 |
end |
354 |
end; |
|
355 |
gtATFinishGame: begin |
|
356 |
AllInactive:= false; |
|
351 | 357 |
if Gear^.Timer = 0 then |
113 | 358 |
begin |
359 |
SendIPC('N'); |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
360 |
SendIPC('q'); |
83 | 361 |
GameState:= gsExit |
113 | 362 |
end |
6 | 363 |
end; |
4 | 364 |
end; |
351 | 365 |
if Gear^.Timer = 0 then DeleteGear(Gear) |
4 | 366 |
end; |
367 |
||
368 |
//////////////////////////////////////////////////////////////////////////////// |
|
369 |
procedure doStepPickHammerWork(Gear: PGear); |
|
371 | 370 |
var i, ei: LongInt; |
4 | 371 |
HHGear: PGear; |
372 |
begin |
|
70 | 373 |
AllInactive:= false; |
351 | 374 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
375 |
dec(Gear^.Timer); |
|
376 |
if (Gear^.Timer = 0)or((Gear^.Message and gm_Destroy) <> 0)or((HHGear^.State and gstHHDriven) = 0) then |
|
4 | 377 |
begin |
282 | 378 |
StopSound(sndPickhammer); |
4 | 379 |
DeleteGear(Gear); |
380 |
AfterAttack; |
|
381 |
exit |
|
382 |
end; |
|
422 | 383 |
|
384 |
if (Gear^.Timer mod 33) = 0 then |
|
385 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y) + 6, 6, EXPLDontDraw); |
|
386 |
||
387 |
if (Gear^.Timer mod 47) = 0 then |
|
4 | 388 |
begin |
371 | 389 |
i:= hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
390 |
ei:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
4 | 391 |
while i <= ei do |
392 |
begin |
|
422 | 393 |
DrawExplosion(i, hwRound(Gear^.Y) + 3, 3); |
4 | 394 |
inc(i, 1) |
395 |
end; |
|
351 | 396 |
Gear^.X:= Gear^.X + Gear^.dX; |
397 |
Gear^.Y:= Gear^.Y + _1_9; |
|
42 | 398 |
SetAllHHToActive; |
4 | 399 |
end; |
400 |
if TestCollisionYwithGear(Gear, 1) then |
|
401 |
begin |
|
498 | 402 |
Gear^.dY:= _0; |
351 | 403 |
SetLittle(HHGear^.dX); |
498 | 404 |
HHGear^.dY:= _0; |
4 | 405 |
end else |
406 |
begin |
|
351 | 407 |
Gear^.dY:= Gear^.dY + cGravity; |
408 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 409 |
if Gear^.Y > _1024 then Gear^.Timer:= 1 |
4 | 410 |
end; |
411 |
||
351 | 412 |
Gear^.X:= Gear^.X + HHGear^.dX; |
413 |
HHGear^.X:= Gear^.X; |
|
498 | 414 |
HHGear^.Y:= Gear^.Y - int2hwFloat(cHHRadius); |
4 | 415 |
|
351 | 416 |
if (Gear^.Message and gm_Attack) <> 0 then |
417 |
if (Gear^.State and gsttmpFlag) <> 0 then Gear^.Timer:= 1 else else |
|
418 |
if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
419 |
if ((Gear^.Message and gm_Left) <> 0) then Gear^.dX:= - _0_3 else |
|
420 |
if ((Gear^.Message and gm_Right) <> 0) then Gear^.dX:= _0_3 |
|
498 | 421 |
else Gear^.dX:= _0; |
4 | 422 |
end; |
423 |
||
424 |
procedure doStepPickHammer(Gear: PGear); |
|
371 | 425 |
var i, y: LongInt; |
4 | 426 |
ar: TRangeArray; |
427 |
begin |
|
428 |
i:= 0; |
|
498 | 429 |
y:= hwRound(Gear^.Y) - cHHRadius * 2; |
351 | 430 |
while y < hwRound(Gear^.Y) do |
4 | 431 |
begin |
371 | 432 |
ar[i].Left := hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
433 |
ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
4 | 434 |
inc(y, 2); |
435 |
inc(i) |
|
436 |
end; |
|
498 | 437 |
DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius * 2, 2, Pred(i)); |
351 | 438 |
Gear^.dY:= PHedgehog(Gear^.Hedgehog)^.Gear^.dY; |
282 | 439 |
PlaySound(sndPickhammer, true); |
4 | 440 |
doStepPickHammerWork(Gear); |
351 | 441 |
Gear^.doStep:= @doStepPickHammerWork |
4 | 442 |
end; |
443 |
||
444 |
//////////////////////////////////////////////////////////////////////////////// |
|
371 | 445 |
var BTPrevAngle, BTSteps: LongInt; |
302 | 446 |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
447 |
procedure doStepBlowTorchWork(Gear: PGear); |
302 | 448 |
var HHGear: PGear; |
305 | 449 |
b: boolean; |
302 | 450 |
begin |
451 |
AllInactive:= false; |
|
351 | 452 |
dec(Gear^.Timer); |
453 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
454 |
|
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
455 |
HedgehogChAngle(HHGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
456 |
|
305 | 457 |
b:= false; |
458 |
||
371 | 459 |
if abs(LongInt(HHGear^.Angle) - BTPrevAngle) > 7 then |
305 | 460 |
begin |
498 | 461 |
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX); |
355 | 462 |
Gear^.dY:= AngleCos(HHGear^.Angle) * ( - _0_5); |
351 | 463 |
BTPrevAngle:= HHGear^.Angle; |
358 | 464 |
b:= true |
305 | 465 |
end; |
466 |
||
351 | 467 |
if Gear^.Timer mod cHHStepTicks = 0 then |
302 | 468 |
begin |
305 | 469 |
b:= true; |
498 | 470 |
if Gear^.dX.isNegative then HHGear^.Message:= (HHGear^.Message or gm_Left) and not gm_Right |
471 |
else HHGear^.Message:= (HHGear^.Message or gm_Right) and not gm_Left; |
|
357 | 472 |
|
473 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
302 | 474 |
HedgehogStep(HHGear); |
357 | 475 |
HHGear^.State:= HHGear^.State or gstAttacking; |
305 | 476 |
|
477 |
inc(BTSteps); |
|
511 | 478 |
if BTSteps = 7 then |
305 | 479 |
begin |
480 |
BTSteps:= 0; |
|
511 | 481 |
Gear^.X:= HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); |
482 |
Gear^.Y:= HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); |
|
351 | 483 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
511 | 484 |
AmmoShove(Gear, 2, 14); |
351 | 485 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
305 | 486 |
end; |
487 |
||
351 | 488 |
if (HHGear^.State and gstFalling) <> 0 then Gear^.Timer:= 0 |
302 | 489 |
end; |
305 | 490 |
|
491 |
if b then |
|
498 | 492 |
DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - _4 - Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, |
351 | 493 |
Gear^.dX, Gear^.dY, |
306 | 494 |
cHHRadius * 5, cHHRadius * 2 + 6); |
305 | 495 |
|
351 | 496 |
if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) then |
302 | 497 |
begin |
351 | 498 |
HHGear^.Message:= 0; |
302 | 499 |
DeleteGear(Gear); |
500 |
AfterAttack |
|
501 |
end |
|
502 |
end; |
|
503 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
504 |
procedure doStepBlowTorch(Gear: PGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
505 |
var HHGear: PGear; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
506 |
begin |
371 | 507 |
BTPrevAngle:= High(LongInt); |
305 | 508 |
BTSteps:= 0; |
351 | 509 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
510 |
HHGear^.Message:= 0; |
|
511 |
Gear^.doStep:= @doStepBlowTorchWork |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
512 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
513 |
|
302 | 514 |
//////////////////////////////////////////////////////////////////////////////// |
515 |
||
4 | 516 |
procedure doStepRopeWork(Gear: PGear); |
70 | 517 |
const flCheck: boolean = false; |
4 | 518 |
var HHGear: PGear; |
351 | 519 |
len, cs, cc, tx, ty: hwFloat; |
108 | 520 |
lx, ly: LongInt; |
4 | 521 |
|
522 |
procedure DeleteMe; |
|
523 |
begin |
|
524 |
with HHGear^ do |
|
525 |
begin |
|
526 |
Message:= Message and not gm_Attack; |
|
527 |
State:= State or gstFalling; |
|
528 |
end; |
|
529 |
DeleteGear(Gear); |
|
351 | 530 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^.Ammo); |
531 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) |
|
4 | 532 |
end; |
533 |
||
534 |
begin |
|
351 | 535 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
108 | 536 |
|
351 | 537 |
if ((HHGear^.State and gstHHDriven) = 0) |
80 | 538 |
or (CheckGearDrowning(HHGear)) then |
4 | 539 |
begin |
540 |
DeleteMe; |
|
541 |
exit |
|
542 |
end; |
|
351 | 543 |
Gear^.dX:= HHGear^.X - Gear^.X; |
544 |
Gear^.dY:= HHGear^.Y - Gear^.Y; |
|
4 | 545 |
|
351 | 546 |
if (Gear^.Message and gm_Left <> 0) then HHGear^.dX:= HHGear^.dX - _0_0002 else |
547 |
if (Gear^.Message and gm_Right <> 0) then HHGear^.dX:= HHGear^.dX + _0_0002; |
|
4 | 548 |
|
351 | 549 |
if not TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= HHGear^.dY + cGravity; |
4 | 550 |
|
351 | 551 |
cs:= Gear^.dY + HHGear^.dY; |
552 |
cc:= Gear^.dX + HHGear^.dX; |
|
498 | 553 |
len:= _1 / Distance(cc, cs); |
108 | 554 |
cc:= cc * len; |
555 |
cs:= cs * len; |
|
4 | 556 |
|
557 |
flCheck:= not flCheck; |
|
558 |
if flCheck then // check whether rope needs dividing |
|
559 |
begin |
|
498 | 560 |
len:= Gear^.Elasticity - _20; |
561 |
while len > _5 do |
|
4 | 562 |
begin |
563 |
tx:= cc*len; |
|
564 |
ty:= cs*len; |
|
351 | 565 |
lx:= hwRound(Gear^.X + tx) + hwSign(HHGear^.dX); |
566 |
ly:= hwRound(Gear^.Y + ty) + hwSign(HHGear^.dY); |
|
4 | 567 |
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0)and (Land[ly, lx] <> 0) then |
568 |
begin |
|
569 |
with RopePoints.ar[RopePoints.Count] do |
|
570 |
begin |
|
351 | 571 |
X:= Gear^.X; |
572 |
Y:= Gear^.Y; |
|
370
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
358
diff
changeset
|
573 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle32(Gear^.dY, Gear^.dX); |
351 | 574 |
b:= (cc * HHGear^.dY) > (cs * HHGear^.dX); |
4 | 575 |
dLen:= len |
576 |
end; |
|
351 | 577 |
Gear^.X:= Gear^.X + tx; |
578 |
Gear^.Y:= Gear^.Y + ty; |
|
4 | 579 |
inc(RopePoints.Count); |
351 | 580 |
Gear^.Elasticity:= Gear^.Elasticity - len; |
581 |
Gear^.Friction:= Gear^.Friction - len; |
|
4 | 582 |
break |
583 |
end; |
|
498 | 584 |
len:= len - _3 |
4 | 585 |
end; |
586 |
end else |
|
587 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
|
588 |
begin |
|
589 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
590 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
351 | 591 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then |
4 | 592 |
begin |
593 |
dec(RopePoints.Count); |
|
351 | 594 |
Gear^.X:=RopePoints.ar[RopePoints.Count].X; |
595 |
Gear^.Y:=RopePoints.ar[RopePoints.Count].Y; |
|
596 |
Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
|
597 |
Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
4 | 598 |
end |
599 |
end; |
|
600 |
||
351 | 601 |
Gear^.dX:= HHGear^.X - Gear^.X; |
602 |
Gear^.dY:= HHGear^.Y - Gear^.Y; |
|
108 | 603 |
|
351 | 604 |
cs:= Gear^.dY + HHGear^.dY; |
605 |
cc:= Gear^.dX + HHGear^.dX; |
|
498 | 606 |
len:= _1 / Distance(cc, cs); |
108 | 607 |
cc:= cc * len; |
608 |
cs:= cs * len; |
|
4 | 609 |
|
351 | 610 |
HHGear^.dX:= HHGear^.X; |
611 |
HHGear^.dY:= HHGear^.Y; |
|
4 | 612 |
|
351 | 613 |
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then |
614 |
if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
|
615 |
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity + _0_3; |
|
4 | 616 |
|
498 | 617 |
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then |
351 | 618 |
if not (TestCollisionXwithGear(HHGear, -hwSign(Gear^.dX)) |
619 |
or TestCollisionYwithGear(HHGear, -hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity - _0_3; |
|
4 | 620 |
|
351 | 621 |
HHGear^.X:= Gear^.X + cc*Gear^.Elasticity; |
622 |
HHGear^.Y:= Gear^.Y + cs*Gear^.Elasticity; |
|
4 | 623 |
|
351 | 624 |
HHGear^.dX:= HHGear^.X - HHGear^.dX; |
625 |
HHGear^.dY:= HHGear^.Y - HHGear^.dY; |
|
4 | 626 |
|
351 | 627 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
628 |
HHGear^.dX:= -_0_6 * HHGear^.dX; |
|
629 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then |
|
630 |
HHGear^.dY:= -_0_6 * HHGear^.dY; |
|
4 | 631 |
|
351 | 632 |
if (Gear^.Message and gm_Attack) <> 0 then |
633 |
if (Gear^.State and gsttmpFlag) <> 0 then DeleteMe else |
|
634 |
else if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
4 | 635 |
end; |
636 |
||
637 |
||
638 |
procedure doStepRopeAttach(Gear: PGear); |
|
639 |
var HHGear: PGear; |
|
351 | 640 |
tx, ty, tt: hwFloat; |
4 | 641 |
begin |
351 | 642 |
Gear^.X:= Gear^.X - Gear^.dX; |
643 |
Gear^.Y:= Gear^.Y - Gear^.dY; |
|
498 | 644 |
Gear^.Elasticity:= Gear^.Elasticity + _1; |
351 | 645 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
517 | 646 |
DeleteCI(HHGear); |
351 | 647 |
if (HHGear^.State and gstFalling) <> 0 then |
68 | 648 |
if TestCollisionYwithGear(HHGear, 1) then |
4 | 649 |
begin |
498 | 650 |
HHGear^.dY:= _0; |
4 | 651 |
CheckHHDamage(HHGear); |
351 | 652 |
HHGear^.State:= HHGear^.State and not (gstFalling or gstHHJumping); |
4 | 653 |
end else |
654 |
begin |
|
351 | 655 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
656 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
657 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
658 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
659 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
660 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
661 |
tt:= Gear^.Elasticity; |
|
498 | 662 |
tx:= _0; |
663 |
ty:= _0; |
|
664 |
while tt > _20 do |
|
4 | 665 |
begin |
517 | 666 |
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) |
667 |
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then |
|
4 | 668 |
begin |
351 | 669 |
Gear^.X:= Gear^.X + tx; |
670 |
Gear^.Y:= Gear^.Y + ty; |
|
671 |
Gear^.Elasticity:= tt; |
|
672 |
Gear^.doStep:= @doStepRopeWork; |
|
4 | 673 |
with HHGear^ do State:= State and not gstAttacking; |
498 | 674 |
tt:= _0 |
4 | 675 |
end; |
517 | 676 |
tx:= tx + Gear^.dX + Gear^.dX; |
677 |
ty:= ty + Gear^.dY + Gear^.dY; |
|
498 | 678 |
tt:= tt - _2; |
4 | 679 |
end; |
680 |
end; |
|
681 |
CheckCollision(Gear); |
|
351 | 682 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 683 |
begin |
351 | 684 |
Gear^.doStep:= @doStepRopeWork; |
4 | 685 |
with HHGear^ do State:= State and not gstAttacking; |
498 | 686 |
if Gear^.Elasticity < _10 then |
687 |
Gear^.Elasticity:= _10000; |
|
4 | 688 |
end; |
689 |
||
351 | 690 |
if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then |
4 | 691 |
begin |
351 | 692 |
with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
4 | 693 |
begin |
694 |
State:= State and not gstAttacking; |
|
695 |
Message:= Message and not gm_Attack |
|
696 |
end; |
|
697 |
DeleteGear(Gear) |
|
698 |
end |
|
699 |
end; |
|
700 |
||
701 |
procedure doStepRope(Gear: PGear); |
|
702 |
begin |
|
351 | 703 |
Gear^.dX:= - Gear^.dX; |
704 |
Gear^.dY:= - Gear^.dY; |
|
705 |
Gear^.doStep:= @doStepRopeAttach |
|
4 | 706 |
end; |
707 |
||
708 |
//////////////////////////////////////////////////////////////////////////////// |
|
709 |
procedure doStepSmokeTrace(Gear: PGear); |
|
710 |
begin |
|
351 | 711 |
inc(Gear^.Timer); |
712 |
if Gear^.Timer > 64 then |
|
4 | 713 |
begin |
351 | 714 |
Gear^.Timer:= 0; |
715 |
dec(Gear^.State) |
|
4 | 716 |
end; |
351 | 717 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
718 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
719 |
if Gear^.State = 0 then DeleteGear(Gear) |
|
4 | 720 |
end; |
9 | 721 |
|
722 |
//////////////////////////////////////////////////////////////////////////////// |
|
723 |
procedure doStepExplosion(Gear: PGear); |
|
724 |
begin |
|
351 | 725 |
inc(Gear^.Timer); |
726 |
if Gear^.Timer > 75 then |
|
9 | 727 |
begin |
351 | 728 |
inc(Gear^.State); |
729 |
Gear^.Timer:= 0; |
|
730 |
if Gear^.State > 5 then DeleteGear(Gear) |
|
9 | 731 |
end; |
732 |
end; |
|
10 | 733 |
|
734 |
//////////////////////////////////////////////////////////////////////////////// |
|
735 |
procedure doStepMine(Gear: PGear); |
|
736 |
begin |
|
503 | 737 |
if (Gear^.State and (gstMoving or gstFalling)) <> 0 then |
10 | 738 |
begin |
503 | 739 |
DeleteCI(Gear); |
10 | 740 |
doStepFallingGear(Gear); |
503 | 741 |
if (Gear^.State and (gstMoving or gstFalling)) = 0 then |
13 | 742 |
begin |
503 | 743 |
AddGearCI(Gear); |
498 | 744 |
Gear^.dX:= _0; |
745 |
Gear^.dY:= _0 |
|
13 | 746 |
end; |
747 |
CalcRotationDirAngle(Gear); |
|
10 | 748 |
AllInactive:= false |
749 |
end; |
|
351 | 750 |
|
751 |
if ((Gear^.State and gsttmpFlag) <> 0) then |
|
752 |
if ((Gear^.State and gstAttacking) = 0) then |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
753 |
begin |
39 | 754 |
if ((GameTicks and $F) = 0) then |
351 | 755 |
if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
756 |
end else // gstAttacking <> 0 |
10 | 757 |
begin |
758 |
AllInactive:= false; |
|
351 | 759 |
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false); |
760 |
if Gear^.Timer = 0 then |
|
10 | 761 |
begin |
351 | 762 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
521 | 763 |
DeleteGear(Gear); |
764 |
exit |
|
10 | 765 |
end; |
351 | 766 |
dec(Gear^.Timer); |
13 | 767 |
end else // gsttmpFlag = 0 |
351 | 768 |
if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
10 | 769 |
end; |
57 | 770 |
|
39 | 771 |
//////////////////////////////////////////////////////////////////////////////// |
772 |
procedure doStepDynamite(Gear: PGear); |
|
773 |
begin |
|
43 | 774 |
doStepFallingGear(Gear); |
775 |
AllInactive:= false; |
|
351 | 776 |
if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); |
777 |
if Gear^.Timer = 0 then |
|
39 | 778 |
begin |
351 | 779 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
43 | 780 |
DeleteGear(Gear); |
781 |
exit |
|
39 | 782 |
end; |
351 | 783 |
dec(Gear^.Timer); |
39 | 784 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
785 |
|
351 | 786 |
/////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
787 |
procedure doStepCase(Gear: PGear); |
371 | 788 |
var i, x, y: LongInt; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
789 |
begin |
351 | 790 |
if (Gear^.Message and gm_Destroy) > 0 then |
15 | 791 |
begin |
792 |
DeleteGear(Gear); |
|
435 | 793 |
FreeActionsList; |
441 | 794 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do |
795 |
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
|
15 | 796 |
exit |
797 |
end; |
|
798 |
||
351 | 799 |
if Gear^.Damage > 0 then |
79 | 800 |
begin |
351 | 801 |
x:= hwRound(Gear^.X); |
802 |
y:= hwRound(Gear^.Y); |
|
79 | 803 |
DeleteGear(Gear); |
89 | 804 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
79 | 805 |
for i:= 0 to 63 do |
498 | 806 |
AddGear(x, y, gtFlame, 0, _0, _0, 0); |
79 | 807 |
exit |
808 |
end; |
|
809 |
||
351 | 810 |
if (Gear^.dY.QWordValue <> 0) or (not TestCollisionYwithGear(Gear, 1)) then |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
811 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
812 |
AllInactive:= false; |
351 | 813 |
Gear^.dY:= Gear^.dY + cGravity; |
814 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 815 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else |
439 | 816 |
if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
817 |
begin |
351 | 818 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
498 | 819 |
if Gear^.dY > - _0_001 then Gear^.dY:= _0 |
351 | 820 |
else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false); |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
821 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
822 |
CheckGearDrowning(Gear); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
823 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
824 |
|
511 | 825 |
if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
826 |
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
|
827 |
end; |
49 | 828 |
|
829 |
//////////////////////////////////////////////////////////////////////////////// |
|
830 |
var thexchar: array[0..5] of record |
|
371 | 831 |
oy, ny: LongInt; |
49 | 832 |
team: PTeam; |
833 |
end; |
|
834 |
thexchcnt: Longword; |
|
143 | 835 |
currsorter: PGear; |
49 | 836 |
|
837 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
371 | 838 |
var i: LongInt; |
49 | 839 |
begin |
840 |
AllInactive:= false; |
|
351 | 841 |
dec(Gear^.Timer); |
842 |
if (Gear^.Timer and 15) = 0 then |
|
49 | 843 |
for i:= 0 to Pred(thexchcnt) do |
844 |
with thexchar[i] do |
|
845 |
{$WARNINGS OFF} |
|
351 | 846 |
team^.DrawHealthY:= ny + (oy - ny) * Gear^.Timer div 640; |
49 | 847 |
{$WARNINGS ON} |
351 | 848 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
143 | 849 |
begin |
850 |
if currsorter = Gear then currsorter:= nil; |
|
49 | 851 |
DeleteGear(Gear) |
143 | 852 |
end |
49 | 853 |
end; |
854 |
||
855 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
856 |
var team: PTeam; |
|
857 |
i, t: Longword; |
|
858 |
begin |
|
859 |
AllInactive:= false; |
|
860 |
team:= TeamsList; |
|
861 |
i:= 0; |
|
862 |
while team <> nil do |
|
863 |
begin |
|
351 | 864 |
thexchar[i].oy:= team^.DrawHealthY; |
49 | 865 |
thexchar[i].team:= team; |
866 |
inc(i); |
|
351 | 867 |
team:= team^.Next |
49 | 868 |
end; |
869 |
thexchcnt:= i; |
|
870 |
for i:= 1 to thexchcnt do |
|
871 |
for t:= 0 to thexchcnt - 2 do |
|
351 | 872 |
if thexchar[t].team^.TeamHealthBarWidth > thexchar[Succ(t)].team^.TeamHealthBarWidth then |
49 | 873 |
begin |
874 |
thexchar[5]:= thexchar[t]; |
|
875 |
thexchar[t]:= thexchar[Succ(t)]; |
|
876 |
thexchar[Succ(t)]:= thexchar[5] |
|
877 |
end; |
|
878 |
t:= cScreenHeight - 4; |
|
879 |
for i:= 0 to Pred(thexchcnt) do |
|
880 |
with thexchar[i] do |
|
881 |
begin |
|
351 | 882 |
dec(t, team^.HealthRect.h + 2); |
49 | 883 |
ny:= t |
884 |
end; |
|
351 | 885 |
Gear^.Timer:= 640; |
886 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
|
143 | 887 |
currsorter:= Gear |
49 | 888 |
end; |
889 |
||
79 | 890 |
//////////////////////////////////////////////////////////////////////////////// |
891 |
procedure doStepShover(Gear: PGear); |
|
892 |
var HHGear: PGear; |
|
893 |
begin |
|
351 | 894 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
895 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
79 | 896 |
AmmoShove(Gear, 30, 115); |
351 | 897 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
79 | 898 |
DeleteGear(Gear) |
899 |
end; |
|
900 |
||
901 |
//////////////////////////////////////////////////////////////////////////////// |
|
902 |
procedure doStepFlame(Gear: PGear); |
|
903 |
begin |
|
904 |
AllInactive:= false; |
|
905 |
if not TestCollisionYwithGear(Gear, 1) then |
|
906 |
begin |
|
351 | 907 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
908 |
Gear^.dY:= Gear^.dY + cGravity; |
|
909 |
if hwAbs(Gear^.dX) > _0_1 then Gear^.dX:= Gear^.dX * _0_5; |
|
910 |
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; |
|
911 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
912 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 913 |
if not (Gear^.Y < _1024) then |
79 | 914 |
begin |
915 |
DeleteGear(Gear); |
|
916 |
exit |
|
917 |
end |
|
918 |
end else begin |
|
351 | 919 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
79 | 920 |
else begin |
506 | 921 |
// doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 2, 0); |
351 | 922 |
dec(Gear^.Health); |
923 |
Gear^.Timer:= 1250 - Gear^.Angle * 12 |
|
79 | 924 |
end |
925 |
end; |
|
926 |
||
351 | 927 |
if (((GameTicks div 8) mod 64) = Gear^.Angle) then |
79 | 928 |
AmmoFlameWork(Gear); |
929 |
||
351 | 930 |
if Gear^.Health = 0 then |
79 | 931 |
DeleteGear(Gear) |
932 |
end; |
|
82 | 933 |
|
934 |
//////////////////////////////////////////////////////////////////////////////// |
|
935 |
procedure doStepFirePunchWork(Gear: PGear); |
|
936 |
var HHGear: PGear; |
|
937 |
begin |
|
938 |
AllInactive:= false; |
|
351 | 939 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
82 | 940 |
begin |
941 |
DeleteGear(Gear); |
|
942 |
AfterAttack; |
|
943 |
exit |
|
944 |
end; |
|
945 |
||
351 | 946 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
947 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
82 | 948 |
begin |
351 | 949 |
Gear^.Tag:= hwRound(HHGear^.Y); |
498 | 950 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
351 | 951 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
952 |
Gear^.Y:= HHGear^.Y; |
|
82 | 953 |
AmmoShove(Gear, 30, 40); |
351 | 954 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
82 | 955 |
end; |
351 | 956 |
|
957 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
958 |
if not (HHGear^.dY.isNegative) then |
|
82 | 959 |
begin |
351 | 960 |
HHGear^.State:= HHGear^.State or gstFalling; |
82 | 961 |
DeleteGear(Gear); |
962 |
AfterAttack; |
|
963 |
exit |
|
964 |
end; |
|
351 | 965 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 966 |
end; |
967 |
||
968 |
procedure doStepFirePunch(Gear: PGear); |
|
969 |
var HHGear: PGear; |
|
970 |
begin |
|
971 |
AllInactive:= false; |
|
351 | 972 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 973 |
DeleteCI(HHGear); |
498 | 974 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
351 | 975 |
SetLittle(HHGear^.dX); |
976 |
HHGear^.dY:= - _0_3; |
|
82 | 977 |
|
351 | 978 |
Gear^.X:= HHGear^.X; |
498 | 979 |
Gear^.dX:= SignAs(_0_45, HHGear^.dX); |
351 | 980 |
Gear^.dY:= - _0_9; |
981 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 982 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
82 | 983 |
end; |
984 |
||
263 | 985 |
//////////////////////////////////////////////////////////////////////////////// |
986 |
||
211 | 987 |
procedure doStepParachute(Gear: PGear); |
988 |
var HHGear: PGear; |
|
989 |
begin |
|
351 | 990 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
991 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
517 | 992 |
DeleteCI(HHGear); |
82 | 993 |
|
516 | 994 |
inc(Gear^.Timer); |
995 |
||
212 | 996 |
if TestCollisionYwithGear(HHGear, 1) |
351 | 997 |
or ((HHGear^.State and gstHHDriven) = 0) |
212 | 998 |
or CheckGearDrowning(HHGear) then |
211 | 999 |
begin |
1000 |
with HHGear^ do |
|
1001 |
begin |
|
1002 |
Message:= 0; |
|
351 | 1003 |
SetLittle(dx); |
498 | 1004 |
dY:= _0; |
211 | 1005 |
State:= State and not (gstAttacking or gstAttacked); |
1006 |
State:= State or gstFalling; |
|
1007 |
end; |
|
1008 |
DeleteGear(Gear); |
|
516 | 1009 |
if Gear^.Timer > 10 then |
1010 |
begin |
|
1011 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^.Ammo); |
|
1012 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) |
|
1013 |
end; |
|
211 | 1014 |
exit |
1015 |
end; |
|
1016 |
||
351 | 1017 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1018 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
|
211 | 1019 |
|
351 | 1020 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1021 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1022 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1023 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1024 |
|
351 | 1025 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
263 | 1026 |
end; |
211 | 1027 |
|
263 | 1028 |
//////////////////////////////////////////////////////////////////////////////// |
351 | 1029 |
const cAirPlaneSpeed: hwFloat = (isNegative: false; QWordValue: 6012954214); // 1.4 |
1030 |
cBombsDistance: hwFloat = (isNegative: false; QWordValue: 128849018880); // 30 |
|
1031 |
cBombsSpeed : hwFloat = (isNegative: false; QWordValue: 429496729); |
|
263 | 1032 |
|
1033 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1034 |
begin |
|
1035 |
AllInactive:= false; |
|
498 | 1036 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
351 | 1037 |
if (Gear^.Health > 0)and( not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
263 | 1038 |
begin |
351 | 1039 |
dec(Gear^.Health); |
1040 |
case Gear^.State of |
|
498 | 1041 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
1042 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
285 | 1043 |
end; |
498 | 1044 |
Gear^.dX:= Gear^.dX + cBombsDistance * Gear^.Tag |
263 | 1045 |
end; |
498 | 1046 |
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1047 |
end; |
1048 |
||
1049 |
procedure doStepAirAttack(Gear: PGear); |
|
1050 |
begin |
|
1051 |
AllInactive:= false; |
|
408 | 1052 |
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 |
1053 |
else Gear^.Tag:= -1; |
|
498 | 1054 |
Gear^.X:= _1024 - _2048 * Gear^.Tag; |
1055 |
Gear^.Y:= -_128; |
|
1056 |
Gear^.dX:= int2hwFloat(TargetPoint.X) - |
|
1057 |
cBombsDistance * _5 * Gear^.Tag / _2; |
|
357 | 1058 |
|
498 | 1059 |
if TargetPoint.Y - hwRound(Gear^.Y) > 0 then |
1060 |
Gear^.dX:= Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(TargetPoint.Y) - Gear^.Y) * 2 / cGravity) * Gear^.Tag; |
|
351 | 1061 |
Gear^.Health:= 6; |
1062 |
Gear^.doStep:= @doStepAirAttackWork |
|
263 | 1063 |
end; |
1064 |
||
1065 |
//////////////////////////////////////////////////////////////////////////////// |
|
1066 |
||
1067 |
procedure doStepAirBomb(Gear: PGear); |
|
1068 |
begin |
|
1069 |
AllInactive:= false; |
|
1070 |
doStepFallingGear(Gear); |
|
351 | 1071 |
if (Gear^.State and gstCollision) <> 0 then |
263 | 1072 |
begin |
351 | 1073 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
263 | 1074 |
DeleteGear(Gear); |
1075 |
exit |
|
1076 |
end; |
|
1077 |
if (GameTicks and $3F) = 0 then |
|
498 | 1078 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1079 |
end; |
409 | 1080 |
|
1081 |
//////////////////////////////////////////////////////////////////////////////// |
|
1082 |
||
1083 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1084 |
var HHGear: PGear; |
409 | 1085 |
begin |
1086 |
AllInactive:= false; |
|
415 | 1087 |
|
1088 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1089 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1090 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1091 |
sprAmGirder, Gear^.State, true) then |
409 | 1092 |
begin |
415 | 1093 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
1094 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1095 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1096 |
DeleteGear(Gear); |
|
1097 |
isCursorVisible:= true |
|
409 | 1098 |
end |
415 | 1099 |
else begin |
1100 |
DeleteGear(Gear); |
|
1101 |
AfterAttack |
|
1102 |
end; |
|
1103 |
TargetPoint.X:= NoPointX |
|
409 | 1104 |
end; |
520 | 1105 |
|
1106 |
//////////////////////////////////////////////////////////////////////////////// |
|
1107 |
||
1108 |
procedure doStepTeleport(Gear: PGear); |
|
1109 |
var HHGear: PGear; |
|
1110 |
begin |
|
1111 |
AllInactive:= false; |
|
1112 |
||
1113 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1114 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1115 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1116 |
sprHHTelepMask, 0, false) then |
|
1117 |
begin |
|
1118 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1119 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1120 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1121 |
DeleteGear(Gear); |
|
1122 |
isCursorVisible:= true |
|
1123 |
end |
|
1124 |
else begin |
|
1125 |
DeleteCI(HHGear); |
|
1126 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1127 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1128 |
DeleteGear(Gear); |
|
1129 |
AfterAttack |
|
1130 |
end; |
|
1131 |
TargetPoint.X:= NoPointX |
|
1132 |
end; |