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