Initial support for attacking from rope
authorunc0rr
Tue, 13 May 2008 20:00:48 +0000
changeset 930 3f61bd3b08fd
parent 929 9456e1e77369
child 931 ab4d98858a40
Initial support for attacking from rope
hedgewars/HHHandlers.inc
hedgewars/uConsts.pas
hedgewars/uGears.pas
--- a/hedgewars/HHHandlers.inc	Mon May 12 19:49:36 2008 +0000
+++ b/hedgewars/HHHandlers.inc	Tue May 13 20:00:48 2008 +0000
@@ -144,8 +144,10 @@
         uStats.AmmoUsed(Ammo^[CurSlot, CurAmmo].AmmoType);
 
         Power:= 0;
-        if CurAmmoGear <> nil then
+        if (CurAmmoGear <> nil)
+           and (((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_AltUse) = 0){check for dropping ammo from rope} then
            begin
+           CurAmmoGear^.Ammo:= @(Ammo^[CurSlot, CurAmmo]);
            Message:= Message or gm_Attack;
            CurAmmoGear^.Message:= Message
            end else begin
@@ -468,20 +470,32 @@
 		PickUp(Gear, t)
 	end;
 
+if (CurAmmoGear = nil) then
+	if (((Gear^.Message and gm_Attack) <> 0)
+		or ((Gear^.State and gstAttacking) <> 0)) then
+		Attack(Gear) // should be before others to avoid desync with '/put' msg and changing weapon msgs
+	else
+else with PHedgehog(Gear^.Hedgehog)^ do
+	 if ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) <> 0)
+		and ((Gear^.Message and gm_LJump) <> 0)
+		and (((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_AltUse) <> 0) then Attack(Gear);
+
+if (CurAmmoGear = nil)
+	or ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) <> 0) then
+	begin
+	if ((Gear^.Message and gm_Slot) <> 0) then ChangeAmmo(Gear);
+
+	if ((Gear^.Message and gm_Weapon) <> 0) then HHSetWeapon(Gear);
+
+	if ((Gear^.Message and gm_Timer) <> 0) then HHSetTimer(Gear);
+	end;
+
 if CurAmmoGear <> nil then
    begin
    CurAmmoGear^.Message:= Gear^.Message;
    exit
    end;
 
-if ((Gear^.Message and gm_Attack) <> 0) or
-   ((Gear^.State and gstAttacking) <> 0) then Attack(Gear); // should be before others to avoid desync with '/put' msg and changing weapon msgs
-
-if ((Gear^.Message and gm_Slot) <> 0) then ChangeAmmo(Gear);
-
-if ((Gear^.Message and gm_Weapon) <> 0) then HHSetWeapon(Gear);
-
-if ((Gear^.Message and gm_Timer) <> 0) then HHSetTimer(Gear);
 
 if (Gear^.State and gstMoving) <> 0 then
    begin
--- a/hedgewars/uConsts.pas	Mon May 12 19:49:36 2008 +0000
+++ b/hedgewars/uConsts.pas	Tue May 13 20:00:48 2008 +0000
@@ -85,6 +85,7 @@
                   Name: string[15];
                   end;
 
+     PAmmo = ^TAmmo;
      TAmmo = record
              Propz: LongWord;
              Count: LongWord;
@@ -197,6 +198,8 @@
       ammoprop_AttackingPut = $00000080;
       ammoprop_DontHold     = $00000100;
       ammoprop_AltAttack    = $00000200;
+      ammoprop_AltUse       = $00000400;
+
       AMMO_INFINITE = High(LongWord);
 
       EXPLAllDamageInRadius = $00000001;
@@ -440,7 +443,8 @@
                                    Probability: 0;
                                    NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_Timerable or
-                                                 ammoprop_Power;
+                                                 ammoprop_Power or
+                                                 ammoprop_AltUse;
                                           Count: AMMO_INFINITE;
                                           NumPerTurn: 0;
                                           Timer: 3000;
@@ -458,7 +462,8 @@
                                    Probability: 100;
                                    NumberInCase: 3;
                                    Ammo: (Propz: ammoprop_Timerable or
-                                                 ammoprop_Power;
+                                                 ammoprop_Power or
+                                                 ammoprop_AltUse;
                                           Count: 5;
                                           NumPerTurn: 0;
                                           Timer: 3000;
@@ -475,7 +480,8 @@
                                    NameTex: nil;
                                    Probability: 0;
                                    NumberInCase: 1;
-                                   Ammo: (Propz: ammoprop_Power;
+                                   Ammo: (Propz: ammoprop_Power or
+                                                 ammoprop_AltUse;
                                           Count: AMMO_INFINITE;
                                           NumPerTurn: 0;
                                           Timer: 0;
@@ -586,7 +592,8 @@
                                    Probability: 100;
                                    NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_NoCrosshair or
-                                                 ammoprop_DontHold;
+                                                 ammoprop_DontHold or
+                                                 ammoprop_AltUse;
                                           Count: 2;
                                           NumPerTurn: 0;
                                           Timer: 0;
@@ -622,7 +629,8 @@
                                    NumberInCase: 1;
                                    Ammo: (Propz: ammoprop_NoCrosshair or
                                                  ammoprop_AttackInMove or
-                                                 ammoprop_DontHold;
+                                                 ammoprop_DontHold or
+                                                 ammoprop_AltUse;
                                           Count: 1;
                                           NumPerTurn: 0;
                                           Timer: 0;
--- a/hedgewars/uGears.pas	Mon May 12 19:49:36 2008 +0000
+++ b/hedgewars/uGears.pas	Tue May 13 20:00:48 2008 +0000
@@ -28,6 +28,7 @@
      TGear = record
              NextGear, PrevGear: PGear;
              Active: Boolean;
+             Ammo : PAmmo;
              State : Longword;
              X : hwFloat;
              Y : hwFloat;