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