# HG changeset patch # User sheepluva # Date 1293876935 -3600 # Node ID 83ee0a10903b182a29fd97f278d9b3736e536118 # Parent 0f408159a33f94b8ca46bea3c7bf58e89cae26ae my attempt of "detach rope if the Land[] vanishes" diff -r 0f408159a33f -r 83ee0a10903b hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Fri Dec 31 23:09:06 2010 +0100 +++ b/hedgewars/GSHandlers.inc Sat Jan 01 11:15:35 2011 +0100 @@ -1362,19 +1362,19 @@ if (GameFlags and gfMoreWind) <> 0 then HHGear^.dX := HHGear^.dX + cWindSpeed / HHGear^.Density; end; + // vector between hedgehog and rope attaching point ropeDx := HHGear^.X - Gear^.X; - // vector between hedgehog and rope attaching point ropeDy := HHGear^.Y - Gear^.Y; mdX := ropeDx + HHGear^.dX; mdY := ropeDy + HHGear^.dY; len := _1 / Distance(mdX, mdY); + // rope vector plus hedgehog direction vector normalized mdX := mdX * len; - // rope vector plus hedgehog direction vector normalized mdY := mdY * len; + // for visual purposes only Gear^.dX := mdX; - // for visual purposes only Gear^.dY := mdY; ///// @@ -1502,8 +1502,27 @@ HHGear^.dY := HHGear^.dY * len; end; - - if (Gear^.Message and gmAttack) <> 0 then + if RopePoints.Count > 0 then + begin + // backup gear location + tx:= Gear^.X; + ty:= Gear^.Y; + + // set gear location to the remote end of the rope, the attachment point + Gear^.X:= RopePoints.ar[0].X; + Gear^.Y:= RopePoints.ar[0].Y; + + CheckCollisionWithLand(Gear); + + // restore gear location + Gear^.X:= tx; + Gear^.Y:= ty; + end + else + CheckCollisionWithLand(Gear); + + if ((Gear^.Message and gmAttack) <> 0) + or ((Gear^.State and gstCollision) = 0) then if (Gear^.State and gsttmpFlag) <> 0 then with Gear^.Hedgehog^ do begin @@ -1517,6 +1536,7 @@ else if (Gear^.State and gsttmpFlag) = 0 then Gear^.State := Gear^.State or gsttmpFlag; + end; procedure doStepRopeAttach(Gear: PGear);