- Continue preparation for implementing attack from rope and parachute
authorunc0rr
Mon, 12 May 2008 19:49:36 +0000
changeset 929 9456e1e77369
parent 928 b9064b48b001
child 930 3f61bd3b08fd
- Continue preparation for implementing attack from rope and parachute - Parachute turns off when space button is pressed
hedgewars/CCHandlers.inc
hedgewars/GSHandlers.inc
--- a/hedgewars/CCHandlers.inc	Mon May 12 15:00:20 2008 +0000
+++ b/hedgewars/CCHandlers.inc	Mon May 12 19:49:36 2008 +0000
@@ -232,8 +232,7 @@
 with CurrentHedgehog^.Gear^ do
      begin
      {$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear^.State = '+inttostr(State));{$ENDIF}
-     if ((State and gstHHDriven) <> 0) and
-        ((State and (gstAttacked or gstHHChooseTarget)) = 0) then
+     if ((State and gstHHDriven) <> 0) then
         begin
         FollowGear:= CurrentHedgehog^.Gear;
         if not CurrentTeam^.ExtDriven then SendIPC('A');
--- a/hedgewars/GSHandlers.inc	Mon May 12 15:00:20 2008 +0000
+++ b/hedgewars/GSHandlers.inc	Mon May 12 19:49:36 2008 +0000
@@ -571,9 +571,7 @@
            Message:= Message and not gm_Attack;
            State:= State or gstMoving;
            end;
-      DeleteGear(Gear);
-      OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^);
-      ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^)
+      DeleteGear(Gear)
     end;
 
 begin
@@ -736,14 +734,20 @@
             tt:= tt - _2;
             end;
       end;
+
 CheckCollision(Gear);
+
 if (Gear^.State and gstCollision) <> 0 then
-   begin
-   Gear^.doStep:= @doStepRopeWork;
-   with HHGear^ do State:= State and not gstAttacking;
-   if Gear^.Elasticity < _10 then
-      Gear^.Elasticity:= _10000;
-   end;
+	begin
+	Gear^.doStep:= @doStepRopeWork;
+	with HHGear^ do State:= State and not gstAttacking;
+
+	OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^);
+	ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^);
+	
+	if Gear^.Elasticity < _10 then
+		Gear^.Elasticity:= _10000;
+	end;
 
 if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then
    begin
@@ -1093,35 +1097,26 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 
-procedure doStepParachute(Gear: PGear);
+procedure doStepParachuteWork(Gear: PGear);
 var HHGear: PGear;
-    Timer: Longword;
 begin
 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
-HHGear^.State:= HHGear^.State and not gstAttacking;
-DeleteCI(HHGear);
 
 inc(Gear^.Timer);
 
 if TestCollisionYwithGear(HHGear, 1)
    or ((HHGear^.State and gstHHDriven) = 0)
-   or CheckGearDrowning(HHGear) then
+   or CheckGearDrowning(HHGear)
+   or ((Gear^.Message and gm_Attack) <> 0) then
    begin
    with HHGear^ do
         begin
         Message:= 0;
         SetLittle(dX);
         dY:= _0;
-        State:= State and not (gstAttacking or gstAttacked);
         State:= State or gstMoving;
         end;
-   Timer:= Gear^.Timer;
    DeleteGear(Gear);
-   if Timer > 10 then
-      begin
-      OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^);
-      ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^)
-      end;
    exit
    end;
 
@@ -1138,6 +1133,26 @@
 Gear^.Y:= HHGear^.Y
 end;
 
+procedure doStepParachute(Gear: PGear);
+var HHGear: PGear;
+    Timer: Longword;
+begin
+HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
+
+DeleteCI(HHGear);
+
+OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^);
+ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^);
+
+HHGear^.State:= HHGear^.State and not (gstAttacking or gstAttacked);
+HHGear^.Message:= HHGear^.Message and not gm_Attack;
+
+Gear^.doStep:= @doStepParachuteWork;
+
+Gear^.Message:= HHGear^.Message;
+doStepParachuteWork(Gear)
+end;
+
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepAirAttackWork(Gear: PGear);
 begin