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,
|
7652
|
104 |
haveDivided, bx, by: boolean;
|
7647
|
105 |
|
|
106 |
begin
|
|
107 |
if GameTicks mod 8 <> 0 then exit;
|
|
108 |
|
|
109 |
HHGear := Gear^.Hedgehog^.Gear;
|
|
110 |
|
|
111 |
if ((HHGear^.State and gstHHDriven) = 0)
|
|
112 |
or (CheckGearDrowning(HHGear)) or (Gear^.PortalCounter <> 0) then
|
|
113 |
begin
|
|
114 |
PlaySound(sndRopeRelease);
|
|
115 |
RopeDeleteMe(Gear, HHGear);
|
|
116 |
exit
|
|
117 |
end;
|
|
118 |
|
7648
|
119 |
HHGear^.dX.QWordValue:= HHGear^.dX.QWordValue shl 3;
|
|
120 |
HHGear^.dY.QWordValue:= HHGear^.dY.QWordValue shl 3;
|
|
121 |
|
7647
|
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 |
|
7652
|
183 |
sDx:= HHGear^.dX / 4;
|
|
184 |
sDy:= HHGear^.dY / 4;
|
7647
|
185 |
|
|
186 |
HHGear^.X:= tx;
|
|
187 |
HHGear^.Y:= ty;
|
|
188 |
|
|
189 |
i:= 0;
|
7652
|
190 |
bx:= TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX));
|
|
191 |
by:= TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) <> 0;
|
|
192 |
while not ((i = 4)
|
|
193 |
or bx
|
|
194 |
or by) do
|
7647
|
195 |
begin
|
|
196 |
inc(i);
|
|
197 |
HHGear^.X:= HHGear^.X + sDx;
|
|
198 |
HHGear^.Y:= HHGear^.Y + sDy;
|
7652
|
199 |
bx:= TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX));
|
|
200 |
by:= TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) <> 0;
|
7647
|
201 |
end;
|
|
202 |
////
|
|
203 |
|
7652
|
204 |
if not bx then HHGear^.dX:= HHGear^.X - tx;
|
|
205 |
if not by then HHGear^.dY:= HHGear^.Y - ty;
|
7647
|
206 |
|
|
207 |
haveDivided := false;
|
|
208 |
// check whether rope needs dividing
|
|
209 |
|
|
210 |
len := Gear^.Elasticity - _5;
|
|
211 |
nx := Gear^.X + mdX * len;
|
|
212 |
ny := Gear^.Y + mdY * len;
|
|
213 |
tx := mdX * _2_4; // should be the same as increase step
|
|
214 |
ty := mdY * _2_4;
|
|
215 |
|
|
216 |
while len > _3 do
|
|
217 |
begin
|
|
218 |
lx := hwRound(nx);
|
|
219 |
ly := hwRound(ny);
|
|
220 |
if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and ((Land[ly, lx] and $FF00) <> 0) then
|
|
221 |
begin
|
|
222 |
ny := _1 / Distance(ropeDx, ropeDy);
|
|
223 |
// old rope pos
|
|
224 |
nx := ropeDx * ny;
|
|
225 |
ny := ropeDy * ny;
|
|
226 |
|
|
227 |
with RopePoints.ar[RopePoints.Count] do
|
|
228 |
begin
|
|
229 |
X := Gear^.X;
|
|
230 |
Y := Gear^.Y;
|
|
231 |
if RopePoints.Count = 0 then
|
|
232 |
RopePoints.HookAngle := DxDy2Angle(Gear^.dY, Gear^.dX);
|
|
233 |
b := (nx * HHGear^.dY) > (ny * HHGear^.dX);
|
|
234 |
dLen := len
|
|
235 |
end;
|
|
236 |
|
|
237 |
with RopePoints.rounded[RopePoints.Count] do
|
|
238 |
begin
|
|
239 |
X := hwRound(Gear^.X);
|
|
240 |
Y := hwRound(Gear^.Y);
|
|
241 |
end;
|
|
242 |
|
|
243 |
Gear^.X := Gear^.X + nx * len;
|
|
244 |
Gear^.Y := Gear^.Y + ny * len;
|
|
245 |
inc(RopePoints.Count);
|
|
246 |
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true);
|
|
247 |
Gear^.Elasticity := Gear^.Elasticity - len;
|
|
248 |
Gear^.Friction := Gear^.Friction - len;
|
|
249 |
haveDivided := true;
|
|
250 |
break
|
|
251 |
end;
|
|
252 |
nx := nx - tx;
|
|
253 |
ny := ny - ty;
|
|
254 |
|
|
255 |
// len := len - _2_4 // should be the same as increase step
|
|
256 |
len.QWordValue := len.QWordValue - _2_4.QWordValue;
|
|
257 |
end;
|
|
258 |
|
|
259 |
if not haveDivided then
|
|
260 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed
|
|
261 |
begin
|
|
262 |
tx := RopePoints.ar[Pred(RopePoints.Count)].X;
|
|
263 |
ty := RopePoints.ar[Pred(RopePoints.Count)].Y;
|
|
264 |
mdX := tx - Gear^.X;
|
|
265 |
mdY := ty - Gear^.Y;
|
|
266 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor (mdX * (ty - HHGear^.Y) > (tx - HHGear^.X) * mdY) then
|
|
267 |
begin
|
|
268 |
dec(RopePoints.Count);
|
|
269 |
Gear^.X := RopePoints.ar[RopePoints.Count].X;
|
|
270 |
Gear^.Y := RopePoints.ar[RopePoints.Count].Y;
|
|
271 |
Gear^.Elasticity := Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen;
|
|
272 |
Gear^.Friction := Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen;
|
|
273 |
|
|
274 |
// restore hog position
|
|
275 |
len := _1 / Distance(mdX, mdY);
|
|
276 |
mdX := mdX * len;
|
|
277 |
mdY := mdY * len;
|
|
278 |
|
|
279 |
HHGear^.X := Gear^.X - mdX * Gear^.Elasticity;
|
|
280 |
HHGear^.Y := Gear^.Y - mdY * Gear^.Elasticity;
|
|
281 |
end
|
|
282 |
end;
|
|
283 |
|
|
284 |
haveCollision := false;
|
|
285 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then
|
|
286 |
begin
|
|
287 |
HHGear^.dX := -_0_6 * HHGear^.dX;
|
|
288 |
haveCollision := true
|
|
289 |
end;
|
|
290 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) <> 0 then
|
|
291 |
begin
|
|
292 |
HHGear^.dY := -_0_6 * HHGear^.dY;
|
|
293 |
haveCollision := true
|
|
294 |
end;
|
|
295 |
|
|
296 |
if haveCollision and (Gear^.Message and (gmLeft or gmRight) <> 0) and (Gear^.Message and (gmUp or gmDown) <> 0) then
|
|
297 |
begin
|
|
298 |
HHGear^.dX := SignAs(hwAbs(HHGear^.dX) + _1_6, HHGear^.dX);
|
|
299 |
HHGear^.dY := SignAs(hwAbs(HHGear^.dY) + _1_6, HHGear^.dY)
|
|
300 |
end;
|
|
301 |
|
|
302 |
len := hwSqr(HHGear^.dX) + hwSqr(HHGear^.dY);
|
|
303 |
if len > _49 then
|
|
304 |
begin
|
|
305 |
len := _7 / hwSqrt(len);
|
|
306 |
HHGear^.dX := HHGear^.dX * len;
|
|
307 |
HHGear^.dY := HHGear^.dY * len;
|
|
308 |
end;
|
|
309 |
|
|
310 |
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);
|
|
311 |
|
|
312 |
if not haveCollision then
|
|
313 |
begin
|
|
314 |
// backup gear location
|
|
315 |
tx:= Gear^.X;
|
|
316 |
ty:= Gear^.Y;
|
|
317 |
|
|
318 |
if RopePoints.Count > 0 then
|
|
319 |
begin
|
|
320 |
// set gear location to the remote end of the rope, the attachment point
|
|
321 |
Gear^.X:= RopePoints.ar[0].X;
|
|
322 |
Gear^.Y:= RopePoints.ar[0].Y;
|
|
323 |
end;
|
|
324 |
|
|
325 |
CheckCollision(Gear);
|
|
326 |
// if we haven't found any collision yet then check the other side too
|
|
327 |
if (Gear^.State and gstCollision) = 0 then
|
|
328 |
begin
|
|
329 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative;
|
|
330 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative;
|
|
331 |
CheckCollision(Gear);
|
|
332 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative;
|
|
333 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative;
|
|
334 |
end;
|
|
335 |
|
|
336 |
haveCollision:= (Gear^.State and gstCollision) <> 0;
|
|
337 |
|
|
338 |
// restore gear location
|
|
339 |
Gear^.X:= tx;
|
|
340 |
Gear^.Y:= ty;
|
|
341 |
end;
|
|
342 |
|
|
343 |
// if the attack key is pressed, lose rope contact as well
|
|
344 |
if (Gear^.Message and gmAttack) <> 0 then
|
|
345 |
haveCollision:= false;
|
|
346 |
|
|
347 |
if not haveCollision then
|
|
348 |
begin
|
|
349 |
if (Gear^.State and gsttmpFlag) <> 0 then
|
|
350 |
begin
|
|
351 |
PlaySound(sndRopeRelease);
|
|
352 |
if Gear^.Hedgehog^.CurAmmoType <> amParachute then
|
|
353 |
RopeWaitCollision(Gear, HHGear)
|
|
354 |
else
|
|
355 |
RopeDeleteMe(Gear, HHGear)
|
|
356 |
end
|
|
357 |
end
|
|
358 |
else
|
|
359 |
if (Gear^.State and gsttmpFlag) = 0 then
|
|
360 |
Gear^.State := Gear^.State or gsttmpFlag;
|
|
361 |
|
|
362 |
HHGear^.dX.QWordValue:= HHGear^.dX.QWordValue shr 3;
|
|
363 |
HHGear^.dY.QWordValue:= HHGear^.dY.QWordValue shr 3;
|
|
364 |
end;
|
|
365 |
|
|
366 |
procedure RopeRemoveFromAmmo(Gear, HHGear: PGear);
|
|
367 |
begin
|
|
368 |
if (Gear^.State and gstAttacked) = 0 then
|
|
369 |
begin
|
|
370 |
OnUsedAmmo(HHGear^.Hedgehog^);
|
|
371 |
Gear^.State := Gear^.State or gstAttacked
|
|
372 |
end;
|
|
373 |
ApplyAmmoChanges(HHGear^.Hedgehog^)
|
|
374 |
end;
|
|
375 |
|
|
376 |
procedure doStepRopeAttach(Gear: PGear);
|
|
377 |
var
|
|
378 |
HHGear: PGear;
|
|
379 |
tx, ty, tt: hwFloat;
|
|
380 |
begin
|
|
381 |
Gear^.X := Gear^.X - Gear^.dX;
|
|
382 |
Gear^.Y := Gear^.Y - Gear^.dY;
|
|
383 |
Gear^.Elasticity := Gear^.Elasticity + _1;
|
|
384 |
|
|
385 |
HHGear := Gear^.Hedgehog^.Gear;
|
|
386 |
DeleteCI(HHGear);
|
|
387 |
|
|
388 |
if (HHGear^.State and gstMoving) <> 0 then
|
|
389 |
begin
|
|
390 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then
|
|
391 |
SetLittle(HHGear^.dX);
|
|
392 |
if HHGear^.dY.isNegative and (TestCollisionYwithGear(HHGear, -1) <> 0) then
|
|
393 |
HHGear^.dY := _0;
|
|
394 |
|
|
395 |
HHGear^.X := HHGear^.X + HHGear^.dX;
|
|
396 |
Gear^.X := Gear^.X + HHGear^.dX;
|
|
397 |
|
|
398 |
if TestCollisionYwithGear(HHGear, 1) <> 0 then
|
|
399 |
begin
|
|
400 |
CheckHHDamage(HHGear);
|
|
401 |
HHGear^.dY := _0
|
|
402 |
//HHGear^.State:= HHGear^.State and (not (gstHHJumping or gstHHHJump));
|
|
403 |
end
|
|
404 |
else
|
|
405 |
begin
|
|
406 |
HHGear^.Y := HHGear^.Y + HHGear^.dY;
|
|
407 |
Gear^.Y := Gear^.Y + HHGear^.dY;
|
|
408 |
HHGear^.dY := HHGear^.dY + cGravity;
|
|
409 |
if (GameFlags and gfMoreWind) <> 0 then
|
|
410 |
HHGear^.dX := HHGear^.dX + cWindSpeed / HHGear^.Density
|
|
411 |
end;
|
|
412 |
|
|
413 |
tt := Gear^.Elasticity;
|
|
414 |
tx := _0;
|
|
415 |
ty := _0;
|
|
416 |
while tt > _20 do
|
|
417 |
begin
|
|
418 |
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
|
|
419 |
begin
|
|
420 |
Gear^.X := Gear^.X + tx;
|
|
421 |
Gear^.Y := Gear^.Y + ty;
|
|
422 |
Gear^.Elasticity := tt;
|
|
423 |
Gear^.doStep := @doStepRopeWork;
|
|
424 |
PlaySound(sndRopeAttach);
|
|
425 |
with HHGear^ do
|
|
426 |
begin
|
|
427 |
State := State and (not (gstAttacking or gstHHJumping or gstHHHJump));
|
|
428 |
Message := Message and (not gmAttack)
|
|
429 |
end;
|
|
430 |
|
|
431 |
RopeRemoveFromAmmo(Gear, HHGear);
|
|
432 |
|
|
433 |
tt := _0;
|
|
434 |
exit
|
|
435 |
end;
|
|
436 |
tx := tx + Gear^.dX + Gear^.dX;
|
|
437 |
ty := ty + Gear^.dY + Gear^.dY;
|
|
438 |
tt := tt - _2;
|
|
439 |
end;
|
|
440 |
end;
|
|
441 |
|
|
442 |
CheckCollision(Gear);
|
|
443 |
|
|
444 |
if (Gear^.State and gstCollision) <> 0 then
|
|
445 |
if Gear^.Elasticity < _10 then
|
|
446 |
Gear^.Elasticity := _10000
|
|
447 |
else
|
|
448 |
begin
|
|
449 |
Gear^.doStep := @doStepRopeWork;
|
|
450 |
PlaySound(sndRopeAttach);
|
|
451 |
with HHGear^ do
|
|
452 |
begin
|
|
453 |
State := State and (not (gstAttacking or gstHHJumping or gstHHHJump));
|
|
454 |
Message := Message and (not gmAttack)
|
|
455 |
end;
|
|
456 |
|
|
457 |
RopeRemoveFromAmmo(Gear, HHGear);
|
|
458 |
|
|
459 |
exit
|
|
460 |
end;
|
|
461 |
|
|
462 |
if (Gear^.Elasticity > Gear^.Friction)
|
|
463 |
or ((Gear^.Message and gmAttack) = 0)
|
|
464 |
or ((HHGear^.State and gstHHDriven) = 0)
|
|
465 |
or (HHGear^.Damage > 0) then
|
|
466 |
begin
|
|
467 |
with Gear^.Hedgehog^.Gear^ do
|
|
468 |
begin
|
|
469 |
State := State and (not gstAttacking);
|
|
470 |
Message := Message and (not gmAttack)
|
|
471 |
end;
|
|
472 |
DeleteGear(Gear);
|
|
473 |
exit;
|
|
474 |
end;
|
|
475 |
if CheckGearDrowning(HHGear) then DeleteGear(Gear)
|
|
476 |
end;
|
|
477 |
|
|
478 |
procedure doStepRope(Gear: PGear);
|
|
479 |
begin
|
|
480 |
Gear^.dX := - Gear^.dX;
|
|
481 |
Gear^.dY := - Gear^.dY;
|
|
482 |
Gear^.doStep := @doStepRopeAttach;
|
|
483 |
PlaySound(sndRopeShot)
|
|
484 |
end;
|
|
485 |
|
|
486 |
end. |