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