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