7647
|
1 |
(*
|
|
2 |
* Hedgewars, a free turn based strategy game
|
|
3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
|
|
4 |
*
|
|
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
|
|
8 |
*
|
|
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.
|
|
13 |
*
|
|
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
|
|
17 |
*)
|
|
18 |
|
|
19 |
{$INCLUDE "options.inc"}
|
|
20 |
unit uGearsHandlersRope;
|
|
21 |
interface
|
|
22 |
|
|
23 |
uses uTypes;
|
|
24 |
|
|
25 |
procedure doStepRope(Gear: PGear);
|
|
26 |
|
|
27 |
implementation
|
|
28 |
uses uConsts, uFloat, uCollisions, uVariables, uGearsList, uSound, uGearsUtils,
|
|
29 |
uAmmos, uDebug, uUtils, uGearsHedgehog, uGearsRender;
|
|
30 |
|
|
31 |
procedure doStepRopeAfterAttack(Gear: PGear);
|
|
32 |
var
|
|
33 |
HHGear: PGear;
|
|
34 |
begin
|
|
35 |
HHGear := Gear^.Hedgehog^.Gear;
|
|
36 |
if ((HHGear^.State and gstHHDriven) = 0)
|
|
37 |
or (CheckGearDrowning(HHGear))
|
|
38 |
or (TestCollisionYwithGear(HHGear, 1) <> 0) then
|
|
39 |
begin
|
|
40 |
DeleteGear(Gear);
|
|
41 |
isCursorVisible := false;
|
|
42 |
ApplyAmmoChanges(HHGear^.Hedgehog^);
|
|
43 |
exit
|
|
44 |
end;
|
|
45 |
|
|
46 |
HedgehogChAngle(HHGear);
|
|
47 |
|
|
48 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then
|
|
49 |
SetLittle(HHGear^.dX);
|
|
50 |
|
|
51 |
if HHGear^.dY.isNegative and (TestCollisionYwithGear(HHGear, -1) <> 0) then
|
|
52 |
HHGear^.dY := _0;
|
|
53 |
HHGear^.X := HHGear^.X + HHGear^.dX;
|
|
54 |
HHGear^.Y := HHGear^.Y + HHGear^.dY;
|
|
55 |
HHGear^.dY := HHGear^.dY + cGravity;
|
|
56 |
|
|
57 |
if (GameFlags and gfMoreWind) <> 0 then
|
|
58 |
HHGear^.dX := HHGear^.dX + cWindSpeed / HHGear^.Density;
|
|
59 |
|
|
60 |
if (Gear^.Message and gmAttack) <> 0 then
|
|
61 |
begin
|
|
62 |
Gear^.X := HHGear^.X;
|
|
63 |
Gear^.Y := HHGear^.Y;
|
|
64 |
|
|
65 |
ApplyAngleBounds(Gear^.Hedgehog^, amRope);
|
|
66 |
|
|
67 |
Gear^.dX := SignAs(AngleSin(HHGear^.Angle), HHGear^.dX);
|
|
68 |
Gear^.dY := -AngleCos(HHGear^.Angle);
|
|
69 |
Gear^.Friction := _4_5 * cRopePercent;
|
|
70 |
Gear^.Elasticity := _0;
|
|
71 |
Gear^.State := Gear^.State and (not gsttmpflag);
|
|
72 |
Gear^.doStep := @doStepRope;
|
|
73 |
end
|
|
74 |
end;
|
|
75 |
|
|
76 |
procedure RopeDeleteMe(Gear, HHGear: PGear);
|
|
77 |
begin
|
|
78 |
with HHGear^ do
|
|
79 |
begin
|
|
80 |
Message := Message and (not gmAttack);
|
|
81 |
State := (State or gstMoving) and (not gstWinner);
|
|
82 |
end;
|
|
83 |
DeleteGear(Gear)
|
|
84 |
end;
|
|
85 |
|
|
86 |
procedure RopeWaitCollision(Gear, HHGear: PGear);
|
|
87 |
begin
|
|
88 |
with HHGear^ do
|
|
89 |
begin
|
|
90 |
Message := Message and (not gmAttack);
|
|
91 |
State := State or gstMoving;
|
|
92 |
end;
|
|
93 |
RopePoints.Count := 0;
|
|
94 |
Gear^.Elasticity := _0;
|
|
95 |
Gear^.doStep := @doStepRopeAfterAttack
|
|
96 |
end;
|
|
97 |
|
|
98 |
procedure doStepRopeWork(Gear: PGear);
|
|
99 |
var
|
|
100 |
HHGear: PGear;
|
|
101 |
len, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY, sDx, sDy: hwFloat;
|
|
102 |
i, lx, ly, cd: LongInt;
|
|
103 |
haveCollision,
|
|
104 |
haveDivided: boolean;
|
|
105 |
|
|
106 |
begin
|
|
107 |
if GameTicks mod 8 <> 0 then exit;
|
|
108 |
|
|
109 |
HHGear := Gear^.Hedgehog^.Gear;
|
|
110 |
|
|
111 |
HHGear^.dX.QWordValue:= HHGear^.dX.QWordValue shl 3;
|
|
112 |
HHGear^.dY.QWordValue:= HHGear^.dY.QWordValue shl 3;
|
|
113 |
|
|
114 |
if ((HHGear^.State and gstHHDriven) = 0)
|
|
115 |
or (CheckGearDrowning(HHGear)) or (Gear^.PortalCounter <> 0) then
|
|
116 |
begin
|
|
117 |
PlaySound(sndRopeRelease);
|
|
118 |
RopeDeleteMe(Gear, HHGear);
|
|
119 |
exit
|
|
120 |
end;
|
|
121 |
|
|
122 |
if (Gear^.Message and gmLeft <> 0) and (not TestCollisionXwithGear(HHGear, -1)) then
|
|
123 |
HHGear^.dX := HHGear^.dX - _0_0128;
|
|
124 |
|
|
125 |
if (Gear^.Message and gmRight <> 0) and (not TestCollisionXwithGear(HHGear, 1)) then
|
|
126 |
HHGear^.dX := HHGear^.dX + _0_0128;
|
|
127 |
|
|
128 |
// vector between hedgehog and rope attaching point
|
|
129 |
ropeDx := HHGear^.X - Gear^.X;
|
|
130 |
ropeDy := HHGear^.Y - Gear^.Y;
|
|
131 |
|
|
132 |
if TestCollisionYwithGear(HHGear, 1) = 0 then
|
|
133 |
begin
|
|
134 |
|
|
135 |
// depending on the rope vector we know which X-side to check for collision
|
|
136 |
// in order to find out if the hog can still be moved by gravity
|
|
137 |
if ropeDx.isNegative = RopeDy.IsNegative then
|
|
138 |
cd:= -1
|
|
139 |
else
|
|
140 |
cd:= 1;
|
|
141 |
|
|
142 |
// apply gravity if there is no obstacle
|
|
143 |
if not TestCollisionXwithGear(HHGear, cd) then
|
|
144 |
HHGear^.dY := HHGear^.dY + cGravity * 64;
|
|
145 |
|
|
146 |
if (GameFlags and gfMoreWind) <> 0 then
|
|
147 |
// apply wind if there's no obstacle
|
|
148 |
if not TestCollisionXwithGear(HHGear, hwSign(cWindSpeed)) then
|
|
149 |
HHGear^.dX := HHGear^.dX + cWindSpeed * 64 / HHGear^.Density;
|
|
150 |
end;
|
|
151 |
|
|
152 |
mdX := ropeDx + HHGear^.dX;
|
|
153 |
mdY := ropeDy + HHGear^.dY;
|
|
154 |
len := _1 / Distance(mdX, mdY);
|
|
155 |
// rope vector plus hedgehog direction vector normalized
|
|
156 |
mdX := mdX * len;
|
|
157 |
mdY := mdY * len;
|
|
158 |
|
|
159 |
// for visual purposes only
|
|
160 |
Gear^.dX := mdX;
|
|
161 |
Gear^.dY := mdY;
|
|
162 |
|
|
163 |
/////
|
|
164 |
tx := HHGear^.X;
|
|
165 |
ty := HHGear^.Y;
|
|
166 |
|
|
167 |
if ((Gear^.Message and gmDown) <> 0) and (Gear^.Elasticity < Gear^.Friction) then
|
|
168 |
if not (TestCollisionXwithGear(HHGear, hwSign(ropeDx))
|
|
169 |
or (TestCollisionYwithGear(HHGear, hwSign(ropeDy)) <> 0)) then
|
|
170 |
Gear^.Elasticity := Gear^.Elasticity + _2_4;
|
|
171 |
|
|
172 |
if ((Gear^.Message and gmUp) <> 0) and (Gear^.Elasticity > _30) then
|
|
173 |
if not (TestCollisionXwithGear(HHGear, -hwSign(ropeDx))
|
|
174 |
or (TestCollisionYwithGear(HHGear, -hwSign(ropeDy)) <> 0)) then
|
|
175 |
Gear^.Elasticity := Gear^.Elasticity - _2_4;
|
|
176 |
|
|
177 |
HHGear^.X := Gear^.X + mdX * Gear^.Elasticity;
|
|
178 |
HHGear^.Y := Gear^.Y + mdY * Gear^.Elasticity;
|
|
179 |
|
|
180 |
HHGear^.dX := Gear^.X + mdX * Gear^.Elasticity - tx;
|
|
181 |
HHGear^.dY := Gear^.Y + mdY * Gear^.Elasticity - ty;
|
|
182 |
|
|
183 |
sDx:= HHGear^.dX / 8;
|
|
184 |
sDy:= HHGear^.dY / 8;
|
|
185 |
|
|
186 |
HHGear^.X:= tx;
|
|
187 |
HHGear^.Y:= ty;
|
|
188 |
|
|
189 |
i:= 0;
|
|
190 |
while not ((i = 8)
|
|
191 |
or TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX))
|
|
192 |
or (TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) <> 0)) do
|
|
193 |
begin
|
|
194 |
inc(i);
|
|
195 |
HHGear^.X:= HHGear^.X + sDx;
|
|
196 |
HHGear^.Y:= HHGear^.Y + sDy;
|
|
197 |
end;
|
|
198 |
////
|
|
199 |
|
|
200 |
|
|
201 |
haveDivided := false;
|
|
202 |
// check whether rope needs dividing
|
|
203 |
|
|
204 |
len := Gear^.Elasticity - _5;
|
|
205 |
nx := Gear^.X + mdX * len;
|
|
206 |
ny := Gear^.Y + mdY * len;
|
|
207 |
tx := mdX * _2_4; // should be the same as increase step
|
|
208 |
ty := mdY * _2_4;
|
|
209 |
|
|
210 |
while len > _3 do
|
|
211 |
begin
|
|
212 |
lx := hwRound(nx);
|
|
213 |
ly := hwRound(ny);
|
|
214 |
if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and ((Land[ly, lx] and $FF00) <> 0) then
|
|
215 |
begin
|
|
216 |
ny := _1 / Distance(ropeDx, ropeDy);
|
|
217 |
// old rope pos
|
|
218 |
nx := ropeDx * ny;
|
|
219 |
ny := ropeDy * ny;
|
|
220 |
|
|
221 |
with RopePoints.ar[RopePoints.Count] do
|
|
222 |
begin
|
|
223 |
X := Gear^.X;
|
|
224 |
Y := Gear^.Y;
|
|
225 |
if RopePoints.Count = 0 then
|
|
226 |
RopePoints.HookAngle := DxDy2Angle(Gear^.dY, Gear^.dX);
|
|
227 |
b := (nx * HHGear^.dY) > (ny * HHGear^.dX);
|
|
228 |
dLen := len
|
|
229 |
end;
|
|
230 |
|
|
231 |
with RopePoints.rounded[RopePoints.Count] do
|
|
232 |
begin
|
|
233 |
X := hwRound(Gear^.X);
|
|
234 |
Y := hwRound(Gear^.Y);
|
|
235 |
end;
|
|
236 |
|
|
237 |
Gear^.X := Gear^.X + nx * len;
|
|
238 |
Gear^.Y := Gear^.Y + ny * len;
|
|
239 |
inc(RopePoints.Count);
|
|
240 |
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true);
|
|
241 |
Gear^.Elasticity := Gear^.Elasticity - len;
|
|
242 |
Gear^.Friction := Gear^.Friction - len;
|
|
243 |
haveDivided := true;
|
|
244 |
break
|
|
245 |
end;
|
|
246 |
nx := nx - tx;
|
|
247 |
ny := ny - ty;
|
|
248 |
|
|
249 |
// len := len - _2_4 // should be the same as increase step
|
|
250 |
len.QWordValue := len.QWordValue - _2_4.QWordValue;
|
|
251 |
end;
|
|
252 |
|
|
253 |
if not haveDivided then
|
|
254 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed
|
|
255 |
begin
|
|
256 |
tx := RopePoints.ar[Pred(RopePoints.Count)].X;
|
|
257 |
ty := RopePoints.ar[Pred(RopePoints.Count)].Y;
|
|
258 |
mdX := tx - Gear^.X;
|
|
259 |
mdY := ty - Gear^.Y;
|
|
260 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor (mdX * (ty - HHGear^.Y) > (tx - HHGear^.X) * mdY) then
|
|
261 |
begin
|
|
262 |
dec(RopePoints.Count);
|
|
263 |
Gear^.X := RopePoints.ar[RopePoints.Count].X;
|
|
264 |
Gear^.Y := RopePoints.ar[RopePoints.Count].Y;
|
|
265 |
Gear^.Elasticity := Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen;
|
|
266 |
Gear^.Friction := Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen;
|
|
267 |
|
|
268 |
// restore hog position
|
|
269 |
len := _1 / Distance(mdX, mdY);
|
|
270 |
mdX := mdX * len;
|
|
271 |
mdY := mdY * len;
|
|
272 |
|
|
273 |
HHGear^.X := Gear^.X - mdX * Gear^.Elasticity;
|
|
274 |
HHGear^.Y := Gear^.Y - mdY * Gear^.Elasticity;
|
|
275 |
end
|
|
276 |
end;
|
|
277 |
|
|
278 |
haveCollision := false;
|
|
279 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then
|
|
280 |
begin
|
|
281 |
HHGear^.dX := -_0_6 * HHGear^.dX;
|
|
282 |
haveCollision := true
|
|
283 |
end;
|
|
284 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) <> 0 then
|
|
285 |
begin
|
|
286 |
HHGear^.dY := -_0_6 * HHGear^.dY;
|
|
287 |
haveCollision := true
|
|
288 |
end;
|
|
289 |
|
|
290 |
if haveCollision and (Gear^.Message and (gmLeft or gmRight) <> 0) and (Gear^.Message and (gmUp or gmDown) <> 0) then
|
|
291 |
begin
|
|
292 |
HHGear^.dX := SignAs(hwAbs(HHGear^.dX) + _1_6, HHGear^.dX);
|
|
293 |
HHGear^.dY := SignAs(hwAbs(HHGear^.dY) + _1_6, HHGear^.dY)
|
|
294 |
end;
|
|
295 |
|
|
296 |
len := hwSqr(HHGear^.dX) + hwSqr(HHGear^.dY);
|
|
297 |
if len > _49 then
|
|
298 |
begin
|
|
299 |
len := _7 / hwSqrt(len);
|
|
300 |
HHGear^.dX := HHGear^.dX * len;
|
|
301 |
HHGear^.dY := HHGear^.dY * len;
|
|
302 |
end;
|
|
303 |
|
|
304 |
haveCollision:= ((hwRound(Gear^.Y) and LAND_HEIGHT_MASK) = 0) and ((hwRound(Gear^.X) and LAND_WIDTH_MASK) = 0) and ((Land[hwRound(Gear^.Y), hwRound(Gear^.X)]) <> 0);
|
|
305 |
|
|
306 |
if not haveCollision then
|
|
307 |
begin
|
|
308 |
// backup gear location
|
|
309 |
tx:= Gear^.X;
|
|
310 |
ty:= Gear^.Y;
|
|
311 |
|
|
312 |
if RopePoints.Count > 0 then
|
|
313 |
begin
|
|
314 |
// set gear location to the remote end of the rope, the attachment point
|
|
315 |
Gear^.X:= RopePoints.ar[0].X;
|
|
316 |
Gear^.Y:= RopePoints.ar[0].Y;
|
|
317 |
end;
|
|
318 |
|
|
319 |
CheckCollision(Gear);
|
|
320 |
// if we haven't found any collision yet then check the other side too
|
|
321 |
if (Gear^.State and gstCollision) = 0 then
|
|
322 |
begin
|
|
323 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative;
|
|
324 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative;
|
|
325 |
CheckCollision(Gear);
|
|
326 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative;
|
|
327 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative;
|
|
328 |
end;
|
|
329 |
|
|
330 |
haveCollision:= (Gear^.State and gstCollision) <> 0;
|
|
331 |
|
|
332 |
// restore gear location
|
|
333 |
Gear^.X:= tx;
|
|
334 |
Gear^.Y:= ty;
|
|
335 |
end;
|
|
336 |
|
|
337 |
// if the attack key is pressed, lose rope contact as well
|
|
338 |
if (Gear^.Message and gmAttack) <> 0 then
|
|
339 |
haveCollision:= false;
|
|
340 |
|
|
341 |
if not haveCollision then
|
|
342 |
begin
|
|
343 |
if (Gear^.State and gsttmpFlag) <> 0 then
|
|
344 |
begin
|
|
345 |
PlaySound(sndRopeRelease);
|
|
346 |
if Gear^.Hedgehog^.CurAmmoType <> amParachute then
|
|
347 |
RopeWaitCollision(Gear, HHGear)
|
|
348 |
else
|
|
349 |
RopeDeleteMe(Gear, HHGear)
|
|
350 |
end
|
|
351 |
end
|
|
352 |
else
|
|
353 |
if (Gear^.State and gsttmpFlag) = 0 then
|
|
354 |
Gear^.State := Gear^.State or gsttmpFlag;
|
|
355 |
|
|
356 |
HHGear^.dX.QWordValue:= HHGear^.dX.QWordValue shr 3;
|
|
357 |
HHGear^.dY.QWordValue:= HHGear^.dY.QWordValue shr 3;
|
|
358 |
end;
|
|
359 |
|
|
360 |
procedure RopeRemoveFromAmmo(Gear, HHGear: PGear);
|
|
361 |
begin
|
|
362 |
if (Gear^.State and gstAttacked) = 0 then
|
|
363 |
begin
|
|
364 |
OnUsedAmmo(HHGear^.Hedgehog^);
|
|
365 |
Gear^.State := Gear^.State or gstAttacked
|
|
366 |
end;
|
|
367 |
ApplyAmmoChanges(HHGear^.Hedgehog^)
|
|
368 |
end;
|
|
369 |
|
|
370 |
procedure doStepRopeAttach(Gear: PGear);
|
|
371 |
var
|
|
372 |
HHGear: PGear;
|
|
373 |
tx, ty, tt: hwFloat;
|
|
374 |
begin
|
|
375 |
Gear^.X := Gear^.X - Gear^.dX;
|
|
376 |
Gear^.Y := Gear^.Y - Gear^.dY;
|
|
377 |
Gear^.Elasticity := Gear^.Elasticity + _1;
|
|
378 |
|
|
379 |
HHGear := Gear^.Hedgehog^.Gear;
|
|
380 |
DeleteCI(HHGear);
|
|
381 |
|
|
382 |
if (HHGear^.State and gstMoving) <> 0 then
|
|
383 |
begin
|
|
384 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then
|
|
385 |
SetLittle(HHGear^.dX);
|
|
386 |
if HHGear^.dY.isNegative and (TestCollisionYwithGear(HHGear, -1) <> 0) then
|
|
387 |
HHGear^.dY := _0;
|
|
388 |
|
|
389 |
HHGear^.X := HHGear^.X + HHGear^.dX;
|
|
390 |
Gear^.X := Gear^.X + HHGear^.dX;
|
|
391 |
|
|
392 |
if TestCollisionYwithGear(HHGear, 1) <> 0 then
|
|
393 |
begin
|
|
394 |
CheckHHDamage(HHGear);
|
|
395 |
HHGear^.dY := _0
|
|
396 |
//HHGear^.State:= HHGear^.State and (not (gstHHJumping or gstHHHJump));
|
|
397 |
end
|
|
398 |
else
|
|
399 |
begin
|
|
400 |
HHGear^.Y := HHGear^.Y + HHGear^.dY;
|
|
401 |
Gear^.Y := Gear^.Y + HHGear^.dY;
|
|
402 |
HHGear^.dY := HHGear^.dY + cGravity;
|
|
403 |
if (GameFlags and gfMoreWind) <> 0 then
|
|
404 |
HHGear^.dX := HHGear^.dX + cWindSpeed / HHGear^.Density
|
|
405 |
end;
|
|
406 |
|
|
407 |
tt := Gear^.Elasticity;
|
|
408 |
tx := _0;
|
|
409 |
ty := _0;
|
|
410 |
while tt > _20 do
|
|
411 |
begin
|
|
412 |
if ((hwRound(Gear^.Y+ty) and LAND_HEIGHT_MASK) = 0) and ((hwRound(Gear^.X+tx) and LAND_WIDTH_MASK) = 0) and ((Land[hwRound(Gear^.Y+ty), hwRound(Gear^.X+tx)] and $FF00) <> 0) then
|
|
413 |
begin
|
|
414 |
Gear^.X := Gear^.X + tx;
|
|
415 |
Gear^.Y := Gear^.Y + ty;
|
|
416 |
Gear^.Elasticity := tt;
|
|
417 |
Gear^.doStep := @doStepRopeWork;
|
|
418 |
PlaySound(sndRopeAttach);
|
|
419 |
with HHGear^ do
|
|
420 |
begin
|
|
421 |
State := State and (not (gstAttacking or gstHHJumping or gstHHHJump));
|
|
422 |
Message := Message and (not gmAttack)
|
|
423 |
end;
|
|
424 |
|
|
425 |
RopeRemoveFromAmmo(Gear, HHGear);
|
|
426 |
|
|
427 |
tt := _0;
|
|
428 |
exit
|
|
429 |
end;
|
|
430 |
tx := tx + Gear^.dX + Gear^.dX;
|
|
431 |
ty := ty + Gear^.dY + Gear^.dY;
|
|
432 |
tt := tt - _2;
|
|
433 |
end;
|
|
434 |
end;
|
|
435 |
|
|
436 |
CheckCollision(Gear);
|
|
437 |
|
|
438 |
if (Gear^.State and gstCollision) <> 0 then
|
|
439 |
if Gear^.Elasticity < _10 then
|
|
440 |
Gear^.Elasticity := _10000
|
|
441 |
else
|
|
442 |
begin
|
|
443 |
Gear^.doStep := @doStepRopeWork;
|
|
444 |
PlaySound(sndRopeAttach);
|
|
445 |
with HHGear^ do
|
|
446 |
begin
|
|
447 |
State := State and (not (gstAttacking or gstHHJumping or gstHHHJump));
|
|
448 |
Message := Message and (not gmAttack)
|
|
449 |
end;
|
|
450 |
|
|
451 |
RopeRemoveFromAmmo(Gear, HHGear);
|
|
452 |
|
|
453 |
exit
|
|
454 |
end;
|
|
455 |
|
|
456 |
if (Gear^.Elasticity > Gear^.Friction)
|
|
457 |
or ((Gear^.Message and gmAttack) = 0)
|
|
458 |
or ((HHGear^.State and gstHHDriven) = 0)
|
|
459 |
or (HHGear^.Damage > 0) then
|
|
460 |
begin
|
|
461 |
with Gear^.Hedgehog^.Gear^ do
|
|
462 |
begin
|
|
463 |
State := State and (not gstAttacking);
|
|
464 |
Message := Message and (not gmAttack)
|
|
465 |
end;
|
|
466 |
DeleteGear(Gear);
|
|
467 |
exit;
|
|
468 |
end;
|
|
469 |
if CheckGearDrowning(HHGear) then DeleteGear(Gear)
|
|
470 |
end;
|
|
471 |
|
|
472 |
procedure doStepRope(Gear: PGear);
|
|
473 |
begin
|
|
474 |
Gear^.dX := - Gear^.dX;
|
|
475 |
Gear^.dY := - Gear^.dY;
|
|
476 |
Gear^.doStep := @doStepRopeAttach;
|
|
477 |
PlaySound(sndRopeShot)
|
|
478 |
end;
|
|
479 |
|
|
480 |
end. |