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