author | unc0rr |
Sun, 11 Mar 2007 17:19:28 +0000 | |
changeset 495 | 62c1c2b4414c |
parent 441 | f2920f08ea5f |
child 498 | 9c8b385dc9a1 |
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; |
441 | 789 |
with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do |
790 |
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
|
15 | 791 |
exit |
792 |
end; |
|
793 |
||
351 | 794 |
if Gear^.Damage > 0 then |
79 | 795 |
begin |
351 | 796 |
x:= hwRound(Gear^.X); |
797 |
y:= hwRound(Gear^.Y); |
|
79 | 798 |
DeleteGear(Gear); |
89 | 799 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
79 | 800 |
for i:= 0 to 63 do |
351 | 801 |
AddGear(x, y, gtFlame, 0, 0, 0, 0); |
79 | 802 |
exit |
803 |
end; |
|
804 |
||
351 | 805 |
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
|
806 |
begin |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
807 |
AllInactive:= false; |
351 | 808 |
Gear^.dY:= Gear^.dY + cGravity; |
809 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
810 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= 0 else |
|
439 | 811 |
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
|
812 |
begin |
351 | 813 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
814 |
if Gear^.dY > - _0_001 then Gear^.dY:= 0 |
|
815 |
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
|
816 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
817 |
CheckGearDrowning(Gear); |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
818 |
end; |
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
819 |
|
351 | 820 |
if (Gear^.CollIndex = High(Longword)) and (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
821 |
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
|
822 |
end; |
49 | 823 |
|
824 |
//////////////////////////////////////////////////////////////////////////////// |
|
825 |
var thexchar: array[0..5] of record |
|
371 | 826 |
oy, ny: LongInt; |
49 | 827 |
team: PTeam; |
828 |
end; |
|
829 |
thexchcnt: Longword; |
|
143 | 830 |
currsorter: PGear; |
49 | 831 |
|
832 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
371 | 833 |
var i: LongInt; |
49 | 834 |
begin |
835 |
AllInactive:= false; |
|
351 | 836 |
dec(Gear^.Timer); |
837 |
if (Gear^.Timer and 15) = 0 then |
|
49 | 838 |
for i:= 0 to Pred(thexchcnt) do |
839 |
with thexchar[i] do |
|
840 |
{$WARNINGS OFF} |
|
351 | 841 |
team^.DrawHealthY:= ny + (oy - ny) * Gear^.Timer div 640; |
49 | 842 |
{$WARNINGS ON} |
351 | 843 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
143 | 844 |
begin |
845 |
if currsorter = Gear then currsorter:= nil; |
|
49 | 846 |
DeleteGear(Gear) |
143 | 847 |
end |
49 | 848 |
end; |
849 |
||
850 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
851 |
var team: PTeam; |
|
852 |
i, t: Longword; |
|
853 |
begin |
|
854 |
AllInactive:= false; |
|
855 |
team:= TeamsList; |
|
856 |
i:= 0; |
|
857 |
while team <> nil do |
|
858 |
begin |
|
351 | 859 |
thexchar[i].oy:= team^.DrawHealthY; |
49 | 860 |
thexchar[i].team:= team; |
861 |
inc(i); |
|
351 | 862 |
team:= team^.Next |
49 | 863 |
end; |
864 |
thexchcnt:= i; |
|
865 |
for i:= 1 to thexchcnt do |
|
866 |
for t:= 0 to thexchcnt - 2 do |
|
351 | 867 |
if thexchar[t].team^.TeamHealthBarWidth > thexchar[Succ(t)].team^.TeamHealthBarWidth then |
49 | 868 |
begin |
869 |
thexchar[5]:= thexchar[t]; |
|
870 |
thexchar[t]:= thexchar[Succ(t)]; |
|
871 |
thexchar[Succ(t)]:= thexchar[5] |
|
872 |
end; |
|
873 |
t:= cScreenHeight - 4; |
|
874 |
for i:= 0 to Pred(thexchcnt) do |
|
875 |
with thexchar[i] do |
|
876 |
begin |
|
351 | 877 |
dec(t, team^.HealthRect.h + 2); |
49 | 878 |
ny:= t |
879 |
end; |
|
351 | 880 |
Gear^.Timer:= 640; |
881 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
|
143 | 882 |
currsorter:= Gear |
49 | 883 |
end; |
884 |
||
79 | 885 |
//////////////////////////////////////////////////////////////////////////////// |
886 |
procedure doStepShover(Gear: PGear); |
|
887 |
var HHGear: PGear; |
|
888 |
begin |
|
351 | 889 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
890 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
79 | 891 |
AmmoShove(Gear, 30, 115); |
351 | 892 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
79 | 893 |
DeleteGear(Gear) |
894 |
end; |
|
895 |
||
896 |
//////////////////////////////////////////////////////////////////////////////// |
|
897 |
procedure doStepFlame(Gear: PGear); |
|
898 |
begin |
|
899 |
AllInactive:= false; |
|
900 |
if not TestCollisionYwithGear(Gear, 1) then |
|
901 |
begin |
|
351 | 902 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
903 |
Gear^.dY:= Gear^.dY + cGravity; |
|
904 |
if hwAbs(Gear^.dX) > _0_1 then Gear^.dX:= Gear^.dX * _0_5; |
|
905 |
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; |
|
906 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
907 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
908 |
if Gear^.Y > 1023 then |
|
79 | 909 |
begin |
910 |
DeleteGear(Gear); |
|
911 |
exit |
|
912 |
end |
|
913 |
end else begin |
|
351 | 914 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
79 | 915 |
else begin |
351 | 916 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 2, 0); |
917 |
dec(Gear^.Health); |
|
918 |
Gear^.Timer:= 1250 - Gear^.Angle * 12 |
|
79 | 919 |
end |
920 |
end; |
|
921 |
||
351 | 922 |
if (((GameTicks div 8) mod 64) = Gear^.Angle) then |
79 | 923 |
AmmoFlameWork(Gear); |
924 |
||
351 | 925 |
if Gear^.Health = 0 then |
79 | 926 |
DeleteGear(Gear) |
927 |
end; |
|
82 | 928 |
|
929 |
//////////////////////////////////////////////////////////////////////////////// |
|
930 |
procedure doStepFirePunchWork(Gear: PGear); |
|
931 |
var HHGear: PGear; |
|
932 |
begin |
|
933 |
AllInactive:= false; |
|
351 | 934 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
82 | 935 |
begin |
936 |
DeleteGear(Gear); |
|
937 |
AfterAttack; |
|
938 |
exit |
|
939 |
end; |
|
940 |
||
351 | 941 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
942 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
82 | 943 |
begin |
351 | 944 |
Gear^.Tag:= hwRound(HHGear^.Y); |
945 |
DrawTunnel(HHGear^.X - cHHRadius, HHGear^.Y - 1, _0_5, 0, cHHRadius * 4, 2); |
|
946 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
947 |
Gear^.Y:= HHGear^.Y; |
|
82 | 948 |
AmmoShove(Gear, 30, 40); |
351 | 949 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
82 | 950 |
end; |
351 | 951 |
|
952 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
953 |
if not (HHGear^.dY.isNegative) then |
|
82 | 954 |
begin |
351 | 955 |
HHGear^.State:= HHGear^.State or gstFalling; |
82 | 956 |
DeleteGear(Gear); |
957 |
AfterAttack; |
|
958 |
exit |
|
959 |
end; |
|
351 | 960 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 961 |
end; |
962 |
||
963 |
procedure doStepFirePunch(Gear: PGear); |
|
964 |
var HHGear: PGear; |
|
965 |
begin |
|
966 |
AllInactive:= false; |
|
351 | 967 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
968 |
HHGear^.X:= hwRound(HHGear^.X) - _0_5; |
|
969 |
SetLittle(HHGear^.dX); |
|
970 |
HHGear^.dY:= - _0_3; |
|
82 | 971 |
|
351 | 972 |
Gear^.X:= HHGear^.X; |
973 |
Gear^.dX:= hwSign(HHGear^.dX) * _0_45; |
|
974 |
Gear^.dY:= - _0_9; |
|
975 |
Gear^.doStep:= @doStepFirePunchWork; |
|
976 |
DrawTunnel(HHGear^.X - cHHRadius, HHGear^.Y + 1, _0_5, 0, cHHRadius * 4, 5); |
|
82 | 977 |
end; |
978 |
||
263 | 979 |
//////////////////////////////////////////////////////////////////////////////// |
980 |
||
211 | 981 |
procedure doStepParachute(Gear: PGear); |
982 |
var HHGear: PGear; |
|
983 |
begin |
|
351 | 984 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
985 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
82 | 986 |
|
212 | 987 |
if TestCollisionYwithGear(HHGear, 1) |
351 | 988 |
or ((HHGear^.State and gstHHDriven) = 0) |
212 | 989 |
or CheckGearDrowning(HHGear) then |
211 | 990 |
begin |
991 |
with HHGear^ do |
|
992 |
begin |
|
993 |
Message:= 0; |
|
351 | 994 |
SetLittle(dx); |
211 | 995 |
dY:= 0; |
996 |
State:= State and not (gstAttacking or gstAttacked); |
|
997 |
State:= State or gstFalling; |
|
998 |
end; |
|
999 |
DeleteGear(Gear); |
|
351 | 1000 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^.Ammo); |
1001 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
211 | 1002 |
exit |
1003 |
end; |
|
1004 |
||
351 | 1005 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1006 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
|
211 | 1007 |
|
351 | 1008 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1009 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1010 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1011 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1012 |
|
351 | 1013 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
263 | 1014 |
end; |
211 | 1015 |
|
263 | 1016 |
//////////////////////////////////////////////////////////////////////////////// |
351 | 1017 |
const cAirPlaneSpeed: hwFloat = (isNegative: false; QWordValue: 6012954214); // 1.4 |
1018 |
cBombsDistance: hwFloat = (isNegative: false; QWordValue: 128849018880); // 30 |
|
1019 |
cBombsSpeed : hwFloat = (isNegative: false; QWordValue: 429496729); |
|
263 | 1020 |
|
1021 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1022 |
begin |
|
1023 |
AllInactive:= false; |
|
408 | 1024 |
Gear^.X:= Gear^.X + Gear^.Tag * cAirPlaneSpeed; |
351 | 1025 |
if (Gear^.Health > 0)and( not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
263 | 1026 |
begin |
351 | 1027 |
dec(Gear^.Health); |
1028 |
case Gear^.State of |
|
437 | 1029 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.Tag * cBombsSpeed, 0, 0); |
1030 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, Gear^.Tag * cBombsSpeed, 0, 0); |
|
285 | 1031 |
end; |
408 | 1032 |
Gear^.dX:= Gear^.dX + Gear^.Tag * cBombsDistance |
263 | 1033 |
end; |
408 | 1034 |
if (Gear^.X > 3072) or (Gear^.X < -1024) then DeleteGear(Gear) |
263 | 1035 |
end; |
1036 |
||
1037 |
procedure doStepAirAttack(Gear: PGear); |
|
1038 |
begin |
|
1039 |
AllInactive:= false; |
|
408 | 1040 |
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 |
1041 |
else Gear^.Tag:= -1; |
|
1042 |
Gear^.X:= 1024 - Gear^.Tag * 2048; |
|
351 | 1043 |
Gear^.Y:= -128; |
1044 |
Gear^.dX:= TargetPoint.X - |
|
408 | 1045 |
Gear^.Tag * cBombsDistance * 5 / 2; |
357 | 1046 |
|
1047 |
if TargetPoint.Y - Gear^.Y > 0 then |
|
408 | 1048 |
Gear^.dX:= Gear^.dX - Gear^.Tag * cBombsSpeed * hwSqrt(2 * (TargetPoint.Y - Gear^.Y) / cGravity); |
351 | 1049 |
Gear^.Health:= 6; |
1050 |
Gear^.doStep:= @doStepAirAttackWork |
|
263 | 1051 |
end; |
1052 |
||
1053 |
//////////////////////////////////////////////////////////////////////////////// |
|
1054 |
||
1055 |
procedure doStepAirBomb(Gear: PGear); |
|
1056 |
begin |
|
1057 |
AllInactive:= false; |
|
1058 |
doStepFallingGear(Gear); |
|
351 | 1059 |
if (Gear^.State and gstCollision) <> 0 then |
263 | 1060 |
begin |
351 | 1061 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
263 | 1062 |
DeleteGear(Gear); |
1063 |
exit |
|
1064 |
end; |
|
1065 |
if (GameTicks and $3F) = 0 then |
|
351 | 1066 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, 0, 0, 0) |
211 | 1067 |
end; |
409 | 1068 |
|
1069 |
//////////////////////////////////////////////////////////////////////////////// |
|
1070 |
||
1071 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1072 |
var HHGear: PGear; |
409 | 1073 |
begin |
1074 |
AllInactive:= false; |
|
415 | 1075 |
|
1076 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1077 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1078 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
1079 |
sprAmGirder, Gear^.State) then |
|
1080 |
begin |
|
415 | 1081 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
1082 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1083 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1084 |
DeleteGear(Gear); |
|
1085 |
isCursorVisible:= true |
|
409 | 1086 |
end |
415 | 1087 |
else begin |
1088 |
DeleteGear(Gear); |
|
1089 |
AfterAttack |
|
1090 |
end; |
|
1091 |
TargetPoint.X:= NoPointX |
|
409 | 1092 |
end; |