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