author | unc0rr |
Wed, 02 May 2007 18:41:44 +0000 | |
changeset 503 | 2cfdc4bfc2be |
parent 498 | 9c8b385dc9a1 |
child 505 | fcba7d7aea0d |
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 |
75 | 293 |
AmmoShove(Gear, 25, 25); |
351 | 294 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLNoDamage or EXPLDoNotTouchHH); |
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); |
75 | 324 |
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); |
|
306 | 478 |
if BTSteps = 11 then |
305 | 479 |
begin |
480 |
BTSteps:= 0; |
|
351 | 481 |
Gear^.X:= HHGear^.X + Gear^.dX * cHHRadius * 2; |
482 |
Gear^.Y:= HHGear^.Y + Gear^.dY * cHHRadius * 2; |
|
483 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
305 | 484 |
AmmoShove(Gear, 3, 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; |
646 |
if (HHGear^.State and gstFalling) <> 0 then |
|
68 | 647 |
if TestCollisionYwithGear(HHGear, 1) then |
4 | 648 |
begin |
498 | 649 |
HHGear^.dY:= _0; |
4 | 650 |
CheckHHDamage(HHGear); |
351 | 651 |
HHGear^.State:= HHGear^.State and not (gstFalling or gstHHJumping); |
4 | 652 |
end else |
653 |
begin |
|
351 | 654 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
655 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
656 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
657 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
658 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
659 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
660 |
tt:= Gear^.Elasticity; |
|
498 | 661 |
tx:= _0; |
662 |
ty:= _0; |
|
663 |
while tt > _20 do |
|
4 | 664 |
begin |
498 | 665 |
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), hwSign(Gear^.dX)) |
351 | 666 |
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), hwSign(Gear^.dY)) then |
4 | 667 |
begin |
351 | 668 |
Gear^.X:= Gear^.X + tx; |
669 |
Gear^.Y:= Gear^.Y + ty; |
|
670 |
Gear^.Elasticity:= tt; |
|
671 |
Gear^.doStep:= @doStepRopeWork; |
|
4 | 672 |
with HHGear^ do State:= State and not gstAttacking; |
498 | 673 |
tt:= _0 |
4 | 674 |
end; |
351 | 675 |
tx:= tx + Gear^.dX - Gear^.dX; |
676 |
ty:= ty + Gear^.dY - Gear^.dY; |
|
498 | 677 |
tt:= tt - _2; |
4 | 678 |
end; |
679 |
end; |
|
680 |
CheckCollision(Gear); |
|
351 | 681 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 682 |
begin |
351 | 683 |
Gear^.doStep:= @doStepRopeWork; |
4 | 684 |
with HHGear^ do State:= State and not gstAttacking; |
498 | 685 |
if Gear^.Elasticity < _10 then |
686 |
Gear^.Elasticity:= _10000; |
|
4 | 687 |
end; |
688 |
||
351 | 689 |
if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then |
4 | 690 |
begin |
351 | 691 |
with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
4 | 692 |
begin |
693 |
State:= State and not gstAttacking; |
|
694 |
Message:= Message and not gm_Attack |
|
695 |
end; |
|
696 |
DeleteGear(Gear) |
|
697 |
end |
|
698 |
end; |
|
699 |
||
700 |
procedure doStepRope(Gear: PGear); |
|
701 |
begin |
|
351 | 702 |
Gear^.dX:= - Gear^.dX; |
703 |
Gear^.dY:= - Gear^.dY; |
|
704 |
Gear^.doStep:= @doStepRopeAttach |
|
4 | 705 |
end; |
706 |
||
707 |
//////////////////////////////////////////////////////////////////////////////// |
|
708 |
procedure doStepSmokeTrace(Gear: PGear); |
|
709 |
begin |
|
351 | 710 |
inc(Gear^.Timer); |
711 |
if Gear^.Timer > 64 then |
|
4 | 712 |
begin |
351 | 713 |
Gear^.Timer:= 0; |
714 |
dec(Gear^.State) |
|
4 | 715 |
end; |
351 | 716 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
717 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
718 |
if Gear^.State = 0 then DeleteGear(Gear) |
|
4 | 719 |
end; |
9 | 720 |
|
721 |
//////////////////////////////////////////////////////////////////////////////// |
|
722 |
procedure doStepExplosion(Gear: PGear); |
|
723 |
begin |
|
351 | 724 |
inc(Gear^.Timer); |
725 |
if Gear^.Timer > 75 then |
|
9 | 726 |
begin |
351 | 727 |
inc(Gear^.State); |
728 |
Gear^.Timer:= 0; |
|
729 |
if Gear^.State > 5 then DeleteGear(Gear) |
|
9 | 730 |
end; |
731 |
end; |
|
10 | 732 |
|
733 |
//////////////////////////////////////////////////////////////////////////////// |
|
734 |
procedure doStepMine(Gear: PGear); |
|
735 |
begin |
|
503 | 736 |
if (Gear^.State and (gstMoving or gstFalling)) <> 0 then |
10 | 737 |
begin |
503 | 738 |
DeleteCI(Gear); |
10 | 739 |
doStepFallingGear(Gear); |
503 | 740 |
if (Gear^.State and (gstMoving or gstFalling)) = 0 then |
13 | 741 |
begin |
503 | 742 |
AddGearCI(Gear); |
498 | 743 |
Gear^.dX:= _0; |
744 |
Gear^.dY:= _0 |
|
13 | 745 |
end; |
746 |
CalcRotationDirAngle(Gear); |
|
10 | 747 |
AllInactive:= false |
748 |
end; |
|
351 | 749 |
|
750 |
if ((Gear^.State and gsttmpFlag) <> 0) then |
|
751 |
if ((Gear^.State and gstAttacking) = 0) then |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
752 |
begin |
39 | 753 |
if ((GameTicks and $F) = 0) then |
351 | 754 |
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
|
755 |
end else // gstAttacking <> 0 |
10 | 756 |
begin |
757 |
AllInactive:= false; |
|
351 | 758 |
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false); |
759 |
if Gear^.Timer = 0 then |
|
10 | 760 |
begin |
351 | 761 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
10 | 762 |
DeleteGear(Gear) |
763 |
end; |
|
351 | 764 |
dec(Gear^.Timer); |
13 | 765 |
end else // gsttmpFlag = 0 |
351 | 766 |
if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
10 | 767 |
end; |
57 | 768 |
|
39 | 769 |
//////////////////////////////////////////////////////////////////////////////// |
770 |
procedure doStepDynamite(Gear: PGear); |
|
771 |
begin |
|
43 | 772 |
doStepFallingGear(Gear); |
773 |
AllInactive:= false; |
|
351 | 774 |
if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); |
775 |
if Gear^.Timer = 0 then |
|
39 | 776 |
begin |
351 | 777 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
43 | 778 |
DeleteGear(Gear); |
779 |
exit |
|
39 | 780 |
end; |
351 | 781 |
dec(Gear^.Timer); |
39 | 782 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
783 |
|
351 | 784 |
/////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
785 |
procedure doStepCase(Gear: PGear); |
371 | 786 |
var i, x, y: LongInt; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
787 |
begin |
351 | 788 |
if (Gear^.Message and gm_Destroy) > 0 then |
15 | 789 |
begin |
790 |
DeleteGear(Gear); |
|
435 | 791 |
FreeActionsList; |
441 | 792 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do |
793 |
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
|
15 | 794 |
exit |
795 |
end; |
|
796 |
||
351 | 797 |
if Gear^.Damage > 0 then |
79 | 798 |
begin |
351 | 799 |
x:= hwRound(Gear^.X); |
800 |
y:= hwRound(Gear^.Y); |
|
79 | 801 |
DeleteGear(Gear); |
89 | 802 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
79 | 803 |
for i:= 0 to 63 do |
498 | 804 |
AddGear(x, y, gtFlame, 0, _0, _0, 0); |
79 | 805 |
exit |
806 |
end; |
|
807 |
||
351 | 808 |
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
|
809 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
810 |
AllInactive:= false; |
351 | 811 |
Gear^.dY:= Gear^.dY + cGravity; |
812 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 813 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else |
439 | 814 |
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
|
815 |
begin |
351 | 816 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
498 | 817 |
if Gear^.dY > - _0_001 then Gear^.dY:= _0 |
351 | 818 |
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
|
819 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
820 |
CheckGearDrowning(Gear); |
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 |
|
351 | 823 |
if (Gear^.CollIndex = High(Longword)) and (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
824 |
else if (Gear^.CollIndex < High(Longword)) and (Gear^.dY.QWordValue <> 0) then DeleteCI(Gear); |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
825 |
end; |
49 | 826 |
|
827 |
//////////////////////////////////////////////////////////////////////////////// |
|
828 |
var thexchar: array[0..5] of record |
|
371 | 829 |
oy, ny: LongInt; |
49 | 830 |
team: PTeam; |
831 |
end; |
|
832 |
thexchcnt: Longword; |
|
143 | 833 |
currsorter: PGear; |
49 | 834 |
|
835 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
371 | 836 |
var i: LongInt; |
49 | 837 |
begin |
838 |
AllInactive:= false; |
|
351 | 839 |
dec(Gear^.Timer); |
840 |
if (Gear^.Timer and 15) = 0 then |
|
49 | 841 |
for i:= 0 to Pred(thexchcnt) do |
842 |
with thexchar[i] do |
|
843 |
{$WARNINGS OFF} |
|
351 | 844 |
team^.DrawHealthY:= ny + (oy - ny) * Gear^.Timer div 640; |
49 | 845 |
{$WARNINGS ON} |
351 | 846 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
143 | 847 |
begin |
848 |
if currsorter = Gear then currsorter:= nil; |
|
49 | 849 |
DeleteGear(Gear) |
143 | 850 |
end |
49 | 851 |
end; |
852 |
||
853 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
854 |
var team: PTeam; |
|
855 |
i, t: Longword; |
|
856 |
begin |
|
857 |
AllInactive:= false; |
|
858 |
team:= TeamsList; |
|
859 |
i:= 0; |
|
860 |
while team <> nil do |
|
861 |
begin |
|
351 | 862 |
thexchar[i].oy:= team^.DrawHealthY; |
49 | 863 |
thexchar[i].team:= team; |
864 |
inc(i); |
|
351 | 865 |
team:= team^.Next |
49 | 866 |
end; |
867 |
thexchcnt:= i; |
|
868 |
for i:= 1 to thexchcnt do |
|
869 |
for t:= 0 to thexchcnt - 2 do |
|
351 | 870 |
if thexchar[t].team^.TeamHealthBarWidth > thexchar[Succ(t)].team^.TeamHealthBarWidth then |
49 | 871 |
begin |
872 |
thexchar[5]:= thexchar[t]; |
|
873 |
thexchar[t]:= thexchar[Succ(t)]; |
|
874 |
thexchar[Succ(t)]:= thexchar[5] |
|
875 |
end; |
|
876 |
t:= cScreenHeight - 4; |
|
877 |
for i:= 0 to Pred(thexchcnt) do |
|
878 |
with thexchar[i] do |
|
879 |
begin |
|
351 | 880 |
dec(t, team^.HealthRect.h + 2); |
49 | 881 |
ny:= t |
882 |
end; |
|
351 | 883 |
Gear^.Timer:= 640; |
884 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
|
143 | 885 |
currsorter:= Gear |
49 | 886 |
end; |
887 |
||
79 | 888 |
//////////////////////////////////////////////////////////////////////////////// |
889 |
procedure doStepShover(Gear: PGear); |
|
890 |
var HHGear: PGear; |
|
891 |
begin |
|
351 | 892 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
893 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
79 | 894 |
AmmoShove(Gear, 30, 115); |
351 | 895 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
79 | 896 |
DeleteGear(Gear) |
897 |
end; |
|
898 |
||
899 |
//////////////////////////////////////////////////////////////////////////////// |
|
900 |
procedure doStepFlame(Gear: PGear); |
|
901 |
begin |
|
902 |
AllInactive:= false; |
|
903 |
if not TestCollisionYwithGear(Gear, 1) then |
|
904 |
begin |
|
351 | 905 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
906 |
Gear^.dY:= Gear^.dY + cGravity; |
|
907 |
if hwAbs(Gear^.dX) > _0_1 then Gear^.dX:= Gear^.dX * _0_5; |
|
908 |
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; |
|
909 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
910 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
498 | 911 |
if not (Gear^.Y < _1024) then |
79 | 912 |
begin |
913 |
DeleteGear(Gear); |
|
914 |
exit |
|
915 |
end |
|
916 |
end else begin |
|
351 | 917 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
79 | 918 |
else begin |
351 | 919 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 2, 0); |
920 |
dec(Gear^.Health); |
|
921 |
Gear^.Timer:= 1250 - Gear^.Angle * 12 |
|
79 | 922 |
end |
923 |
end; |
|
924 |
||
351 | 925 |
if (((GameTicks div 8) mod 64) = Gear^.Angle) then |
79 | 926 |
AmmoFlameWork(Gear); |
927 |
||
351 | 928 |
if Gear^.Health = 0 then |
79 | 929 |
DeleteGear(Gear) |
930 |
end; |
|
82 | 931 |
|
932 |
//////////////////////////////////////////////////////////////////////////////// |
|
933 |
procedure doStepFirePunchWork(Gear: PGear); |
|
934 |
var HHGear: PGear; |
|
935 |
begin |
|
936 |
AllInactive:= false; |
|
351 | 937 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
82 | 938 |
begin |
939 |
DeleteGear(Gear); |
|
940 |
AfterAttack; |
|
941 |
exit |
|
942 |
end; |
|
943 |
||
351 | 944 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
945 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
82 | 946 |
begin |
351 | 947 |
Gear^.Tag:= hwRound(HHGear^.Y); |
498 | 948 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
351 | 949 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
950 |
Gear^.Y:= HHGear^.Y; |
|
82 | 951 |
AmmoShove(Gear, 30, 40); |
351 | 952 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
82 | 953 |
end; |
351 | 954 |
|
955 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
956 |
if not (HHGear^.dY.isNegative) then |
|
82 | 957 |
begin |
351 | 958 |
HHGear^.State:= HHGear^.State or gstFalling; |
82 | 959 |
DeleteGear(Gear); |
960 |
AfterAttack; |
|
961 |
exit |
|
962 |
end; |
|
351 | 963 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 964 |
end; |
965 |
||
966 |
procedure doStepFirePunch(Gear: PGear); |
|
967 |
var HHGear: PGear; |
|
968 |
begin |
|
969 |
AllInactive:= false; |
|
351 | 970 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
498 | 971 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
351 | 972 |
SetLittle(HHGear^.dX); |
973 |
HHGear^.dY:= - _0_3; |
|
82 | 974 |
|
351 | 975 |
Gear^.X:= HHGear^.X; |
498 | 976 |
Gear^.dX:= SignAs(_0_45, HHGear^.dX); |
351 | 977 |
Gear^.dY:= - _0_9; |
978 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 979 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
82 | 980 |
end; |
981 |
||
263 | 982 |
//////////////////////////////////////////////////////////////////////////////// |
983 |
||
211 | 984 |
procedure doStepParachute(Gear: PGear); |
985 |
var HHGear: PGear; |
|
986 |
begin |
|
351 | 987 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
988 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
82 | 989 |
|
212 | 990 |
if TestCollisionYwithGear(HHGear, 1) |
351 | 991 |
or ((HHGear^.State and gstHHDriven) = 0) |
212 | 992 |
or CheckGearDrowning(HHGear) then |
211 | 993 |
begin |
994 |
with HHGear^ do |
|
995 |
begin |
|
996 |
Message:= 0; |
|
351 | 997 |
SetLittle(dx); |
498 | 998 |
dY:= _0; |
211 | 999 |
State:= State and not (gstAttacking or gstAttacked); |
1000 |
State:= State or gstFalling; |
|
1001 |
end; |
|
1002 |
DeleteGear(Gear); |
|
351 | 1003 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^.Ammo); |
1004 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
211 | 1005 |
exit |
1006 |
end; |
|
1007 |
||
351 | 1008 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1009 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
|
211 | 1010 |
|
351 | 1011 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1012 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1013 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1014 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1015 |
|
351 | 1016 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
263 | 1017 |
end; |
211 | 1018 |
|
263 | 1019 |
//////////////////////////////////////////////////////////////////////////////// |
351 | 1020 |
const cAirPlaneSpeed: hwFloat = (isNegative: false; QWordValue: 6012954214); // 1.4 |
1021 |
cBombsDistance: hwFloat = (isNegative: false; QWordValue: 128849018880); // 30 |
|
1022 |
cBombsSpeed : hwFloat = (isNegative: false; QWordValue: 429496729); |
|
263 | 1023 |
|
1024 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1025 |
begin |
|
1026 |
AllInactive:= false; |
|
498 | 1027 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
351 | 1028 |
if (Gear^.Health > 0)and( not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
263 | 1029 |
begin |
351 | 1030 |
dec(Gear^.Health); |
1031 |
case Gear^.State of |
|
498 | 1032 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
1033 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
285 | 1034 |
end; |
498 | 1035 |
Gear^.dX:= Gear^.dX + cBombsDistance * Gear^.Tag |
263 | 1036 |
end; |
498 | 1037 |
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1038 |
end; |
1039 |
||
1040 |
procedure doStepAirAttack(Gear: PGear); |
|
1041 |
begin |
|
1042 |
AllInactive:= false; |
|
408 | 1043 |
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 |
1044 |
else Gear^.Tag:= -1; |
|
498 | 1045 |
Gear^.X:= _1024 - _2048 * Gear^.Tag; |
1046 |
Gear^.Y:= -_128; |
|
1047 |
Gear^.dX:= int2hwFloat(TargetPoint.X) - |
|
1048 |
cBombsDistance * _5 * Gear^.Tag / _2; |
|
357 | 1049 |
|
498 | 1050 |
if TargetPoint.Y - hwRound(Gear^.Y) > 0 then |
1051 |
Gear^.dX:= Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(TargetPoint.Y) - Gear^.Y) * 2 / cGravity) * Gear^.Tag; |
|
351 | 1052 |
Gear^.Health:= 6; |
1053 |
Gear^.doStep:= @doStepAirAttackWork |
|
263 | 1054 |
end; |
1055 |
||
1056 |
//////////////////////////////////////////////////////////////////////////////// |
|
1057 |
||
1058 |
procedure doStepAirBomb(Gear: PGear); |
|
1059 |
begin |
|
1060 |
AllInactive:= false; |
|
1061 |
doStepFallingGear(Gear); |
|
351 | 1062 |
if (Gear^.State and gstCollision) <> 0 then |
263 | 1063 |
begin |
351 | 1064 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
263 | 1065 |
DeleteGear(Gear); |
1066 |
exit |
|
1067 |
end; |
|
1068 |
if (GameTicks and $3F) = 0 then |
|
498 | 1069 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1070 |
end; |
409 | 1071 |
|
1072 |
//////////////////////////////////////////////////////////////////////////////// |
|
1073 |
||
1074 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1075 |
var HHGear: PGear; |
409 | 1076 |
begin |
1077 |
AllInactive:= false; |
|
415 | 1078 |
|
1079 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1080 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1081 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
1082 |
sprAmGirder, Gear^.State) then |
|
1083 |
begin |
|
415 | 1084 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
1085 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1086 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1087 |
DeleteGear(Gear); |
|
1088 |
isCursorVisible:= true |
|
409 | 1089 |
end |
415 | 1090 |
else begin |
1091 |
DeleteGear(Gear); |
|
1092 |
AfterAttack |
|
1093 |
end; |
|
1094 |
TargetPoint.X:= NoPointX |
|
409 | 1095 |
end; |