DEADSOFTWARE

fix turret and projectiles
[d2df-sdl.git] / src / game / g_triggers.pas
index b8e39d6873b6601f479dd8f2593e2f97fcddef41..9ce8c0affc12cd9b8884fa381e40bd8c103ae392 100644 (file)
@@ -69,7 +69,7 @@ procedure g_Triggers_Press(ID: DWORD; ActivateType: Byte; ActivateUID: Word = 0)
 function g_Triggers_PressR(X, Y: Integer; Width, Height: Word; UID: Word;
                            ActivateType: Byte; IgnoreList: DWArray = nil): DWArray;
 procedure g_Triggers_PressL(X1, Y1, X2, Y2: Integer; UID: DWORD; ActivateType: Byte);
-procedure g_Triggers_PressC(CX, CY: Integer; Radius: Word; UID: Word; ActivateType: Byte);
+procedure g_Triggers_PressC(CX, CY: Integer; Radius: Word; UID: Word; ActivateType: Byte; IgnoreTrigger: Integer = -1);
 procedure g_Triggers_OpenAll();
 procedure g_Triggers_DecreaseSpawner(ID: DWORD);
 procedure g_Triggers_Free();
@@ -435,6 +435,7 @@ var
   Anim: TAnimation;
 begin
   Result := -1;
+  TextureID := DWORD(-1);
   snd := 'SOUND_WEAPON_FIREROCKET';
   Projectile := True;
   case ShotType of
@@ -1828,6 +1829,9 @@ begin
           if ShotSightTime > 0 then
             Exit;
 
+          // put this at the beginning so it doesn't trigger itself
+          TimeOut := Data.ShotWait + 1;
+
           wx := Data.ShotPos.X;
           wy := Data.ShotPos.Y;
           pAngle := -DegToRad(Data.ShotAngle);
@@ -1934,7 +1938,11 @@ begin
                   end;
             end;
 
-            else TargetUID := ActivateUID;
+            else begin
+              if (Data.ShotTarget <> TRIGGER_SHOT_TARGET_NONE) or
+                 (Data.ShotType <> TRIGGER_SHOT_REV) then
+                TargetUID := ActivateUID;
+            end;
           end;
 
           if (Data.ShotTarget = TRIGGER_SHOT_TARGET_NONE) or (TargetUID > 0) then
@@ -1956,8 +1964,6 @@ begin
               end;
             end;
           end;
-
-          TimeOut := Data.ShotWait + 1;
         end;
 
       TRIGGER_EFFECT:
@@ -2472,7 +2478,7 @@ begin
       end;
 end;
 
-procedure g_Triggers_PressC(CX, CY: Integer; Radius: Word; UID: Word; ActivateType: Byte);
+procedure g_Triggers_PressC(CX, CY: Integer; Radius: Word; UID: Word; ActivateType: Byte; IgnoreTrigger: Integer = -1);
 var
   a: Integer;
   k: Byte;
@@ -2498,7 +2504,8 @@ begin
   rsq := Radius * Radius;
 
   for a := 0 to High(gTriggers) do
-    if (gTriggers[a].TriggerType <> TRIGGER_NONE) and
+    if (gTriggers[a].ID <> DWORD(IgnoreTrigger)) and
+       (gTriggers[a].TriggerType <> TRIGGER_NONE) and
        (gTriggers[a].TimeOut = 0) and
        ((gTriggers[a].Keys and k) = gTriggers[a].Keys) and
        ByteBool(gTriggers[a].ActivateType and ActivateType) then