author | unc0rr |
Thu, 01 Feb 2007 21:42:11 +0000 | |
changeset 377 | d9b88dbdf5a9 |
parent 374 | 95169697cc38 |
child 393 | db01cc79f278 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
79 | 3 |
* Copyright (c) 2004, 2005, 2006 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; |
|
351 | 380 |
if (Gear^.Timer and $3F) = 0 then |
4 | 381 |
begin |
371 | 382 |
i:= hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
383 |
ei:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
4 | 384 |
while i <= ei do |
385 |
begin |
|
351 | 386 |
doMakeExplosion(i, hwRound(Gear^.Y) + 3, 3, 0); |
4 | 387 |
inc(i, 1) |
388 |
end; |
|
351 | 389 |
Gear^.X:= Gear^.X + Gear^.dX; |
390 |
Gear^.Y:= Gear^.Y + _1_9; |
|
42 | 391 |
SetAllHHToActive; |
4 | 392 |
end; |
393 |
if TestCollisionYwithGear(Gear, 1) then |
|
394 |
begin |
|
351 | 395 |
Gear^.dY:= 0; |
396 |
SetLittle(HHGear^.dX); |
|
397 |
HHGear^.dY:= 0; |
|
4 | 398 |
end else |
399 |
begin |
|
351 | 400 |
Gear^.dY:= Gear^.dY + cGravity; |
401 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
402 |
if Gear^.Y > 1024 then Gear^.Timer:= 1 |
|
4 | 403 |
end; |
404 |
||
351 | 405 |
Gear^.X:= Gear^.X + HHGear^.dX; |
406 |
HHGear^.X:= Gear^.X; |
|
407 |
HHGear^.Y:= Gear^.Y - cHHRadius; |
|
4 | 408 |
|
351 | 409 |
if (Gear^.Message and gm_Attack) <> 0 then |
410 |
if (Gear^.State and gsttmpFlag) <> 0 then Gear^.Timer:= 1 else else |
|
411 |
if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
412 |
if ((Gear^.Message and gm_Left) <> 0) then Gear^.dX:= - _0_3 else |
|
413 |
if ((Gear^.Message and gm_Right) <> 0) then Gear^.dX:= _0_3 |
|
414 |
else Gear^.dX:= 0; |
|
4 | 415 |
end; |
416 |
||
417 |
procedure doStepPickHammer(Gear: PGear); |
|
371 | 418 |
var i, y: LongInt; |
4 | 419 |
ar: TRangeArray; |
420 |
begin |
|
421 |
i:= 0; |
|
351 | 422 |
y:= hwRound(Gear^.Y) - cHHRadius*2; |
423 |
while y < hwRound(Gear^.Y) do |
|
4 | 424 |
begin |
371 | 425 |
ar[i].Left := hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
426 |
ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
4 | 427 |
inc(y, 2); |
428 |
inc(i) |
|
429 |
end; |
|
351 | 430 |
DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius*2, 2, Pred(i)); |
431 |
Gear^.dY:= PHedgehog(Gear^.Hedgehog)^.Gear^.dY; |
|
282 | 432 |
PlaySound(sndPickhammer, true); |
4 | 433 |
doStepPickHammerWork(Gear); |
351 | 434 |
Gear^.doStep:= @doStepPickHammerWork |
4 | 435 |
end; |
436 |
||
437 |
//////////////////////////////////////////////////////////////////////////////// |
|
371 | 438 |
var BTPrevAngle, BTSteps: LongInt; |
302 | 439 |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
440 |
procedure doStepBlowTorchWork(Gear: PGear); |
302 | 441 |
var HHGear: PGear; |
305 | 442 |
b: boolean; |
302 | 443 |
begin |
444 |
AllInactive:= false; |
|
351 | 445 |
dec(Gear^.Timer); |
446 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
447 |
|
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
448 |
HedgehogChAngle(HHGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
449 |
|
305 | 450 |
b:= false; |
451 |
||
371 | 452 |
if abs(LongInt(HHGear^.Angle) - BTPrevAngle) > 7 then |
305 | 453 |
begin |
355 | 454 |
Gear^.dX:= hwSign(HHGear^.dX) * AngleSin(HHGear^.Angle) * _0_5; |
455 |
Gear^.dY:= AngleCos(HHGear^.Angle) * ( - _0_5); |
|
351 | 456 |
BTPrevAngle:= HHGear^.Angle; |
358 | 457 |
b:= true |
305 | 458 |
end; |
459 |
||
351 | 460 |
if Gear^.Timer mod cHHStepTicks = 0 then |
302 | 461 |
begin |
305 | 462 |
b:= true; |
351 | 463 |
if Gear^.dX < 0 then HHGear^.Message:= (HHGear^.Message or gm_Left) and not gm_Right |
464 |
else HHGear^.Message:= (HHGear^.Message or gm_Right) and not gm_Left; |
|
357 | 465 |
|
466 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
302 | 467 |
HedgehogStep(HHGear); |
357 | 468 |
HHGear^.State:= HHGear^.State or gstAttacking; |
305 | 469 |
|
470 |
inc(BTSteps); |
|
306 | 471 |
if BTSteps = 11 then |
305 | 472 |
begin |
473 |
BTSteps:= 0; |
|
351 | 474 |
Gear^.X:= HHGear^.X + Gear^.dX * cHHRadius * 2; |
475 |
Gear^.Y:= HHGear^.Y + Gear^.dY * cHHRadius * 2; |
|
476 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
305 | 477 |
AmmoShove(Gear, 3, 14); |
351 | 478 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
305 | 479 |
end; |
480 |
||
351 | 481 |
if (HHGear^.State and gstFalling) <> 0 then Gear^.Timer:= 0 |
302 | 482 |
end; |
305 | 483 |
|
484 |
if b then |
|
351 | 485 |
DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - 4 - Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, |
486 |
Gear^.dX, Gear^.dY, |
|
306 | 487 |
cHHRadius * 5, cHHRadius * 2 + 6); |
305 | 488 |
|
351 | 489 |
if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) then |
302 | 490 |
begin |
351 | 491 |
HHGear^.Message:= 0; |
302 | 492 |
DeleteGear(Gear); |
493 |
AfterAttack |
|
494 |
end |
|
495 |
end; |
|
496 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
497 |
procedure doStepBlowTorch(Gear: PGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
498 |
var HHGear: PGear; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
499 |
begin |
371 | 500 |
BTPrevAngle:= High(LongInt); |
305 | 501 |
BTSteps:= 0; |
351 | 502 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
503 |
HHGear^.Message:= 0; |
|
504 |
Gear^.doStep:= @doStepBlowTorchWork |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
505 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
506 |
|
302 | 507 |
//////////////////////////////////////////////////////////////////////////////// |
508 |
||
4 | 509 |
procedure doStepRopeWork(Gear: PGear); |
70 | 510 |
const flCheck: boolean = false; |
4 | 511 |
var HHGear: PGear; |
351 | 512 |
len, cs, cc, tx, ty: hwFloat; |
108 | 513 |
lx, ly: LongInt; |
4 | 514 |
|
515 |
procedure DeleteMe; |
|
516 |
begin |
|
517 |
with HHGear^ do |
|
518 |
begin |
|
519 |
Message:= Message and not gm_Attack; |
|
520 |
State:= State or gstFalling; |
|
521 |
end; |
|
522 |
DeleteGear(Gear); |
|
351 | 523 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^.Ammo); |
524 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) |
|
4 | 525 |
end; |
526 |
||
527 |
begin |
|
351 | 528 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
108 | 529 |
|
351 | 530 |
if ((HHGear^.State and gstHHDriven) = 0) |
80 | 531 |
or (CheckGearDrowning(HHGear)) then |
4 | 532 |
begin |
533 |
DeleteMe; |
|
534 |
exit |
|
535 |
end; |
|
351 | 536 |
Gear^.dX:= HHGear^.X - Gear^.X; |
537 |
Gear^.dY:= HHGear^.Y - Gear^.Y; |
|
4 | 538 |
|
351 | 539 |
if (Gear^.Message and gm_Left <> 0) then HHGear^.dX:= HHGear^.dX - _0_0002 else |
540 |
if (Gear^.Message and gm_Right <> 0) then HHGear^.dX:= HHGear^.dX + _0_0002; |
|
4 | 541 |
|
351 | 542 |
if not TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= HHGear^.dY + cGravity; |
4 | 543 |
|
351 | 544 |
cs:= Gear^.dY + HHGear^.dY; |
545 |
cc:= Gear^.dX + HHGear^.dX; |
|
546 |
len:= 1 / Distance(cc, cs); |
|
108 | 547 |
cc:= cc * len; |
548 |
cs:= cs * len; |
|
4 | 549 |
|
550 |
flCheck:= not flCheck; |
|
551 |
if flCheck then // check whether rope needs dividing |
|
552 |
begin |
|
351 | 553 |
len:= Gear^.Elasticity - 20; |
4 | 554 |
while len > 5 do |
555 |
begin |
|
556 |
tx:= cc*len; |
|
557 |
ty:= cs*len; |
|
351 | 558 |
lx:= hwRound(Gear^.X + tx) + hwSign(HHGear^.dX); |
559 |
ly:= hwRound(Gear^.Y + ty) + hwSign(HHGear^.dY); |
|
4 | 560 |
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0)and (Land[ly, lx] <> 0) then |
561 |
begin |
|
562 |
with RopePoints.ar[RopePoints.Count] do |
|
563 |
begin |
|
351 | 564 |
X:= Gear^.X; |
565 |
Y:= Gear^.Y; |
|
370
c75410fe3133
- Repair bots: they can walk and use bazooka, possible cannot jump (why?)
unc0rr
parents:
358
diff
changeset
|
566 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle32(Gear^.dY, Gear^.dX); |
351 | 567 |
b:= (cc * HHGear^.dY) > (cs * HHGear^.dX); |
4 | 568 |
dLen:= len |
569 |
end; |
|
351 | 570 |
Gear^.X:= Gear^.X + tx; |
571 |
Gear^.Y:= Gear^.Y + ty; |
|
4 | 572 |
inc(RopePoints.Count); |
351 | 573 |
Gear^.Elasticity:= Gear^.Elasticity - len; |
574 |
Gear^.Friction:= Gear^.Friction - len; |
|
4 | 575 |
break |
576 |
end; |
|
577 |
len:= len - 3 |
|
578 |
end; |
|
579 |
end else |
|
580 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
|
581 |
begin |
|
582 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
583 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
351 | 584 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then |
4 | 585 |
begin |
586 |
dec(RopePoints.Count); |
|
351 | 587 |
Gear^.X:=RopePoints.ar[RopePoints.Count].X; |
588 |
Gear^.Y:=RopePoints.ar[RopePoints.Count].Y; |
|
589 |
Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
|
590 |
Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
4 | 591 |
end |
592 |
end; |
|
593 |
||
351 | 594 |
Gear^.dX:= HHGear^.X - Gear^.X; |
595 |
Gear^.dY:= HHGear^.Y - Gear^.Y; |
|
108 | 596 |
|
351 | 597 |
cs:= Gear^.dY + HHGear^.dY; |
598 |
cc:= Gear^.dX + HHGear^.dX; |
|
599 |
len:= 1 / Distance(cc, cs); |
|
108 | 600 |
cc:= cc * len; |
601 |
cs:= cs * len; |
|
4 | 602 |
|
351 | 603 |
HHGear^.dX:= HHGear^.X; |
604 |
HHGear^.dY:= HHGear^.Y; |
|
4 | 605 |
|
351 | 606 |
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then |
607 |
if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
|
608 |
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity + _0_3; |
|
4 | 609 |
|
351 | 610 |
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > 30) 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 |
HHGear^.X:= Gear^.X + cc*Gear^.Elasticity; |
615 |
HHGear^.Y:= Gear^.Y + cs*Gear^.Elasticity; |
|
4 | 616 |
|
351 | 617 |
HHGear^.dX:= HHGear^.X - HHGear^.dX; |
618 |
HHGear^.dY:= HHGear^.Y - HHGear^.dY; |
|
4 | 619 |
|
351 | 620 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
621 |
HHGear^.dX:= -_0_6 * HHGear^.dX; |
|
622 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then |
|
623 |
HHGear^.dY:= -_0_6 * HHGear^.dY; |
|
4 | 624 |
|
351 | 625 |
if (Gear^.Message and gm_Attack) <> 0 then |
626 |
if (Gear^.State and gsttmpFlag) <> 0 then DeleteMe else |
|
627 |
else if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
4 | 628 |
end; |
629 |
||
630 |
||
631 |
procedure doStepRopeAttach(Gear: PGear); |
|
632 |
var HHGear: PGear; |
|
351 | 633 |
tx, ty, tt: hwFloat; |
4 | 634 |
begin |
351 | 635 |
Gear^.X:= Gear^.X - Gear^.dX; |
636 |
Gear^.Y:= Gear^.Y - Gear^.dY; |
|
637 |
Gear^.Elasticity:= Gear^.Elasticity + 1; |
|
638 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
639 |
if (HHGear^.State and gstFalling) <> 0 then |
|
68 | 640 |
if TestCollisionYwithGear(HHGear, 1) then |
4 | 641 |
begin |
351 | 642 |
HHGear^.dY:= 0; |
4 | 643 |
CheckHHDamage(HHGear); |
351 | 644 |
HHGear^.State:= HHGear^.State and not (gstFalling or gstHHJumping); |
4 | 645 |
end else |
646 |
begin |
|
351 | 647 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
648 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
649 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
650 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
651 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
652 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
653 |
tt:= Gear^.Elasticity; |
|
4 | 654 |
tx:= 0; |
655 |
ty:= 0; |
|
656 |
while tt > 20 do |
|
657 |
begin |
|
351 | 658 |
if TestCollisionXwithXYShift(Gear, hwRound(tx), hwRound(ty), hwSign(Gear^.dX)) |
659 |
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), hwSign(Gear^.dY)) then |
|
4 | 660 |
begin |
351 | 661 |
Gear^.X:= Gear^.X + tx; |
662 |
Gear^.Y:= Gear^.Y + ty; |
|
663 |
Gear^.Elasticity:= tt; |
|
664 |
Gear^.doStep:= @doStepRopeWork; |
|
4 | 665 |
with HHGear^ do State:= State and not gstAttacking; |
666 |
tt:= 0 |
|
667 |
end; |
|
351 | 668 |
tx:= tx + Gear^.dX - Gear^.dX; |
669 |
ty:= ty + Gear^.dY - Gear^.dY; |
|
670 |
tt:= tt - 2; |
|
4 | 671 |
end; |
672 |
end; |
|
673 |
CheckCollision(Gear); |
|
351 | 674 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 675 |
begin |
351 | 676 |
Gear^.doStep:= @doStepRopeWork; |
4 | 677 |
with HHGear^ do State:= State and not gstAttacking; |
351 | 678 |
if Gear^.Elasticity < 10 then |
679 |
Gear^.Elasticity:= 10000; |
|
4 | 680 |
end; |
681 |
||
351 | 682 |
if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then |
4 | 683 |
begin |
351 | 684 |
with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
4 | 685 |
begin |
686 |
State:= State and not gstAttacking; |
|
687 |
Message:= Message and not gm_Attack |
|
688 |
end; |
|
689 |
DeleteGear(Gear) |
|
690 |
end |
|
691 |
end; |
|
692 |
||
693 |
procedure doStepRope(Gear: PGear); |
|
694 |
begin |
|
351 | 695 |
Gear^.dX:= - Gear^.dX; |
696 |
Gear^.dY:= - Gear^.dY; |
|
697 |
Gear^.doStep:= @doStepRopeAttach |
|
4 | 698 |
end; |
699 |
||
700 |
//////////////////////////////////////////////////////////////////////////////// |
|
701 |
procedure doStepSmokeTrace(Gear: PGear); |
|
702 |
begin |
|
351 | 703 |
inc(Gear^.Timer); |
704 |
if Gear^.Timer > 64 then |
|
4 | 705 |
begin |
351 | 706 |
Gear^.Timer:= 0; |
707 |
dec(Gear^.State) |
|
4 | 708 |
end; |
351 | 709 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
710 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
711 |
if Gear^.State = 0 then DeleteGear(Gear) |
|
4 | 712 |
end; |
9 | 713 |
|
714 |
//////////////////////////////////////////////////////////////////////////////// |
|
715 |
procedure doStepExplosion(Gear: PGear); |
|
716 |
begin |
|
351 | 717 |
inc(Gear^.Timer); |
718 |
if Gear^.Timer > 75 then |
|
9 | 719 |
begin |
351 | 720 |
inc(Gear^.State); |
721 |
Gear^.Timer:= 0; |
|
722 |
if Gear^.State > 5 then DeleteGear(Gear) |
|
9 | 723 |
end; |
724 |
end; |
|
10 | 725 |
|
726 |
//////////////////////////////////////////////////////////////////////////////// |
|
727 |
procedure doStepMine(Gear: PGear); |
|
728 |
begin |
|
351 | 729 |
if (Gear^.dX.QWordValue <> 0) or (Gear^.dY.QWordValue <> 0) then |
10 | 730 |
begin |
351 | 731 |
if Gear^.CollIndex < High(Longword) then DeleteCI(Gear); |
10 | 732 |
doStepFallingGear(Gear); |
351 | 733 |
if Gear^.Active = false then |
13 | 734 |
begin |
351 | 735 |
if Gear^.CollIndex = High(Longword) then AddGearCI(Gear); |
736 |
Gear^.dX:= 0; |
|
737 |
Gear^.dY:= 0 |
|
13 | 738 |
end; |
739 |
CalcRotationDirAngle(Gear); |
|
10 | 740 |
AllInactive:= false |
741 |
end; |
|
351 | 742 |
|
743 |
if ((Gear^.State and gsttmpFlag) <> 0) then |
|
744 |
if ((Gear^.State and gstAttacking) = 0) then |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
745 |
begin |
39 | 746 |
if ((GameTicks and $F) = 0) then |
351 | 747 |
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
|
748 |
end else // gstAttacking <> 0 |
10 | 749 |
begin |
750 |
AllInactive:= false; |
|
351 | 751 |
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false); |
752 |
if Gear^.Timer = 0 then |
|
10 | 753 |
begin |
351 | 754 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
10 | 755 |
DeleteGear(Gear) |
756 |
end; |
|
351 | 757 |
dec(Gear^.Timer); |
13 | 758 |
end else // gsttmpFlag = 0 |
351 | 759 |
if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
10 | 760 |
end; |
57 | 761 |
|
39 | 762 |
//////////////////////////////////////////////////////////////////////////////// |
763 |
procedure doStepDynamite(Gear: PGear); |
|
764 |
begin |
|
43 | 765 |
doStepFallingGear(Gear); |
766 |
AllInactive:= false; |
|
351 | 767 |
if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); |
768 |
if Gear^.Timer = 0 then |
|
39 | 769 |
begin |
351 | 770 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
43 | 771 |
DeleteGear(Gear); |
772 |
exit |
|
39 | 773 |
end; |
351 | 774 |
dec(Gear^.Timer); |
39 | 775 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
776 |
|
351 | 777 |
/////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
778 |
procedure doStepCase(Gear: PGear); |
371 | 779 |
var i, x, y: LongInt; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
780 |
begin |
351 | 781 |
if (Gear^.Message and gm_Destroy) > 0 then |
15 | 782 |
begin |
783 |
DeleteGear(Gear); |
|
784 |
exit |
|
785 |
end; |
|
786 |
||
351 | 787 |
if Gear^.Damage > 0 then |
79 | 788 |
begin |
351 | 789 |
x:= hwRound(Gear^.X); |
790 |
y:= hwRound(Gear^.Y); |
|
79 | 791 |
DeleteGear(Gear); |
89 | 792 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
79 | 793 |
for i:= 0 to 63 do |
351 | 794 |
AddGear(x, y, gtFlame, 0, 0, 0, 0); |
79 | 795 |
exit |
796 |
end; |
|
797 |
||
351 | 798 |
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
|
799 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
800 |
AllInactive:= false; |
351 | 801 |
Gear^.dY:= Gear^.dY + cGravity; |
802 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
803 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= 0 else |
|
804 |
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
|
805 |
begin |
351 | 806 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
807 |
if Gear^.dY > - _0_001 then Gear^.dY:= 0 |
|
808 |
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
|
809 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
810 |
CheckGearDrowning(Gear); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
811 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
812 |
|
351 | 813 |
if (Gear^.CollIndex = High(Longword)) and (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
814 |
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
|
815 |
end; |
49 | 816 |
|
817 |
//////////////////////////////////////////////////////////////////////////////// |
|
818 |
var thexchar: array[0..5] of record |
|
371 | 819 |
oy, ny: LongInt; |
49 | 820 |
team: PTeam; |
821 |
end; |
|
822 |
thexchcnt: Longword; |
|
143 | 823 |
currsorter: PGear; |
49 | 824 |
|
825 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
371 | 826 |
var i: LongInt; |
49 | 827 |
begin |
828 |
AllInactive:= false; |
|
351 | 829 |
dec(Gear^.Timer); |
830 |
if (Gear^.Timer and 15) = 0 then |
|
49 | 831 |
for i:= 0 to Pred(thexchcnt) do |
832 |
with thexchar[i] do |
|
833 |
{$WARNINGS OFF} |
|
351 | 834 |
team^.DrawHealthY:= ny + (oy - ny) * Gear^.Timer div 640; |
49 | 835 |
{$WARNINGS ON} |
351 | 836 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
143 | 837 |
begin |
838 |
if currsorter = Gear then currsorter:= nil; |
|
49 | 839 |
DeleteGear(Gear) |
143 | 840 |
end |
49 | 841 |
end; |
842 |
||
843 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
844 |
var team: PTeam; |
|
845 |
i, t: Longword; |
|
846 |
begin |
|
847 |
AllInactive:= false; |
|
848 |
team:= TeamsList; |
|
849 |
i:= 0; |
|
850 |
while team <> nil do |
|
851 |
begin |
|
351 | 852 |
thexchar[i].oy:= team^.DrawHealthY; |
49 | 853 |
thexchar[i].team:= team; |
854 |
inc(i); |
|
351 | 855 |
team:= team^.Next |
49 | 856 |
end; |
857 |
thexchcnt:= i; |
|
858 |
for i:= 1 to thexchcnt do |
|
859 |
for t:= 0 to thexchcnt - 2 do |
|
351 | 860 |
if thexchar[t].team^.TeamHealthBarWidth > thexchar[Succ(t)].team^.TeamHealthBarWidth then |
49 | 861 |
begin |
862 |
thexchar[5]:= thexchar[t]; |
|
863 |
thexchar[t]:= thexchar[Succ(t)]; |
|
864 |
thexchar[Succ(t)]:= thexchar[5] |
|
865 |
end; |
|
866 |
t:= cScreenHeight - 4; |
|
867 |
for i:= 0 to Pred(thexchcnt) do |
|
868 |
with thexchar[i] do |
|
869 |
begin |
|
351 | 870 |
dec(t, team^.HealthRect.h + 2); |
49 | 871 |
ny:= t |
872 |
end; |
|
351 | 873 |
Gear^.Timer:= 640; |
874 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
|
143 | 875 |
currsorter:= Gear |
49 | 876 |
end; |
877 |
||
79 | 878 |
//////////////////////////////////////////////////////////////////////////////// |
879 |
procedure doStepShover(Gear: PGear); |
|
880 |
var HHGear: PGear; |
|
881 |
begin |
|
351 | 882 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
883 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
79 | 884 |
AmmoShove(Gear, 30, 115); |
351 | 885 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
79 | 886 |
DeleteGear(Gear) |
887 |
end; |
|
888 |
||
889 |
//////////////////////////////////////////////////////////////////////////////// |
|
890 |
procedure doStepFlame(Gear: PGear); |
|
891 |
begin |
|
892 |
AllInactive:= false; |
|
893 |
if not TestCollisionYwithGear(Gear, 1) then |
|
894 |
begin |
|
351 | 895 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
896 |
Gear^.dY:= Gear^.dY + cGravity; |
|
897 |
if hwAbs(Gear^.dX) > _0_1 then Gear^.dX:= Gear^.dX * _0_5; |
|
898 |
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; |
|
899 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
900 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
901 |
if Gear^.Y > 1023 then |
|
79 | 902 |
begin |
903 |
DeleteGear(Gear); |
|
904 |
exit |
|
905 |
end |
|
906 |
end else begin |
|
351 | 907 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
79 | 908 |
else begin |
351 | 909 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 2, 0); |
910 |
dec(Gear^.Health); |
|
911 |
Gear^.Timer:= 1250 - Gear^.Angle * 12 |
|
79 | 912 |
end |
913 |
end; |
|
914 |
||
351 | 915 |
if (((GameTicks div 8) mod 64) = Gear^.Angle) then |
79 | 916 |
AmmoFlameWork(Gear); |
917 |
||
351 | 918 |
if Gear^.Health = 0 then |
79 | 919 |
DeleteGear(Gear) |
920 |
end; |
|
82 | 921 |
|
922 |
//////////////////////////////////////////////////////////////////////////////// |
|
923 |
procedure doStepFirePunchWork(Gear: PGear); |
|
924 |
var HHGear: PGear; |
|
925 |
begin |
|
926 |
AllInactive:= false; |
|
351 | 927 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
82 | 928 |
begin |
929 |
DeleteGear(Gear); |
|
930 |
AfterAttack; |
|
931 |
exit |
|
932 |
end; |
|
933 |
||
351 | 934 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
935 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
82 | 936 |
begin |
351 | 937 |
Gear^.Tag:= hwRound(HHGear^.Y); |
938 |
DrawTunnel(HHGear^.X - cHHRadius, HHGear^.Y - 1, _0_5, 0, cHHRadius * 4, 2); |
|
939 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
940 |
Gear^.Y:= HHGear^.Y; |
|
82 | 941 |
AmmoShove(Gear, 30, 40); |
351 | 942 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
82 | 943 |
end; |
351 | 944 |
|
945 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
946 |
if not (HHGear^.dY.isNegative) then |
|
82 | 947 |
begin |
351 | 948 |
HHGear^.State:= HHGear^.State or gstFalling; |
82 | 949 |
DeleteGear(Gear); |
950 |
AfterAttack; |
|
951 |
exit |
|
952 |
end; |
|
351 | 953 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 954 |
end; |
955 |
||
956 |
procedure doStepFirePunch(Gear: PGear); |
|
957 |
var HHGear: PGear; |
|
958 |
begin |
|
959 |
AllInactive:= false; |
|
351 | 960 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
961 |
HHGear^.X:= hwRound(HHGear^.X) - _0_5; |
|
962 |
SetLittle(HHGear^.dX); |
|
963 |
HHGear^.dY:= - _0_3; |
|
82 | 964 |
|
351 | 965 |
Gear^.X:= HHGear^.X; |
966 |
Gear^.dX:= hwSign(HHGear^.dX) * _0_45; |
|
967 |
Gear^.dY:= - _0_9; |
|
968 |
Gear^.doStep:= @doStepFirePunchWork; |
|
969 |
DrawTunnel(HHGear^.X - cHHRadius, HHGear^.Y + 1, _0_5, 0, cHHRadius * 4, 5); |
|
82 | 970 |
end; |
971 |
||
263 | 972 |
//////////////////////////////////////////////////////////////////////////////// |
973 |
||
211 | 974 |
procedure doStepParachute(Gear: PGear); |
975 |
var HHGear: PGear; |
|
976 |
begin |
|
351 | 977 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
978 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
82 | 979 |
|
212 | 980 |
if TestCollisionYwithGear(HHGear, 1) |
351 | 981 |
or ((HHGear^.State and gstHHDriven) = 0) |
212 | 982 |
or CheckGearDrowning(HHGear) then |
211 | 983 |
begin |
984 |
with HHGear^ do |
|
985 |
begin |
|
986 |
Message:= 0; |
|
351 | 987 |
SetLittle(dx); |
211 | 988 |
dY:= 0; |
989 |
State:= State and not (gstAttacking or gstAttacked); |
|
990 |
State:= State or gstFalling; |
|
991 |
end; |
|
992 |
DeleteGear(Gear); |
|
351 | 993 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^.Ammo); |
994 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
211 | 995 |
exit |
996 |
end; |
|
997 |
||
351 | 998 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
999 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
|
211 | 1000 |
|
351 | 1001 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1002 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1003 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1004 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1005 |
|
351 | 1006 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
263 | 1007 |
end; |
211 | 1008 |
|
263 | 1009 |
//////////////////////////////////////////////////////////////////////////////// |
351 | 1010 |
const cAirPlaneSpeed: hwFloat = (isNegative: false; QWordValue: 6012954214); // 1.4 |
1011 |
cBombsDistance: hwFloat = (isNegative: false; QWordValue: 128849018880); // 30 |
|
1012 |
cBombsSpeed : hwFloat = (isNegative: false; QWordValue: 429496729); |
|
263 | 1013 |
|
1014 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1015 |
begin |
|
1016 |
AllInactive:= false; |
|
351 | 1017 |
Gear^.X:= Gear^.X + cAirPlaneSpeed; |
1018 |
if (Gear^.Health > 0)and( not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
|
263 | 1019 |
begin |
351 | 1020 |
dec(Gear^.Health); |
1021 |
case Gear^.State of |
|
1022 |
0: AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed, 0, 0); |
|
1023 |
1: AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed, 0, 0); |
|
285 | 1024 |
end; |
351 | 1025 |
Gear^.dX:= Gear^.dX + cBombsDistance |
263 | 1026 |
end; |
351 | 1027 |
if Gear^.X > 3072 then DeleteGear(Gear) |
263 | 1028 |
end; |
1029 |
||
1030 |
procedure doStepAirAttack(Gear: PGear); |
|
371 | 1031 |
var t: LongInt; |
263 | 1032 |
begin |
1033 |
AllInactive:= false; |
|
351 | 1034 |
Gear^.X:= -1024; |
1035 |
Gear^.Y:= -128; |
|
1036 |
Gear^.dX:= TargetPoint.X - |
|
357 | 1037 |
cBombsDistance * 5 / 2; |
1038 |
||
1039 |
if TargetPoint.Y - Gear^.Y > 0 then |
|
1040 |
Gear^.dX:= Gear^.dX - cBombsSpeed * hwSqrt(2 * (TargetPoint.Y - Gear^.Y) / cGravity); |
|
351 | 1041 |
Gear^.Health:= 6; |
1042 |
Gear^.doStep:= @doStepAirAttackWork |
|
263 | 1043 |
end; |
1044 |
||
1045 |
//////////////////////////////////////////////////////////////////////////////// |
|
1046 |
||
1047 |
procedure doStepAirBomb(Gear: PGear); |
|
1048 |
begin |
|
1049 |
AllInactive:= false; |
|
1050 |
doStepFallingGear(Gear); |
|
351 | 1051 |
if (Gear^.State and gstCollision) <> 0 then |
263 | 1052 |
begin |
351 | 1053 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
263 | 1054 |
DeleteGear(Gear); |
1055 |
exit |
|
1056 |
end; |
|
1057 |
if (GameTicks and $3F) = 0 then |
|
351 | 1058 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, 0, 0, 0) |
211 | 1059 |
end; |