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