]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/triggers.qc
Copy antiwall flag (fixes delayed antiwall triggers)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / triggers.qc
index a9050357f6e97b5bf7851968239bb266404b5f57..1f5139896d19eea55fa89b5c5d8085a9f2b37e9f 100644 (file)
@@ -1,3 +1,4 @@
+#include "triggers.qh"
 void SUB_DontUseTargets(entity this, entity actor, entity trigger) { }
 
 void SUB_UseTargets(entity this, entity actor, entity trigger);
@@ -5,7 +6,7 @@ void SUB_UseTargets(entity this, entity actor, entity trigger);
 void DelayThink(entity this)
 {
        SUB_UseTargets (this, this.enemy, NULL);
-       remove(this);
+       delete(this);
 }
 
 void FixSize(entity e)
@@ -163,6 +164,7 @@ void trigger_remove_generic(entity this)
 }
 #endif
 
+
 /*
 ==============================
 SUB_UseTargets
@@ -182,7 +184,8 @@ match (string)this.target and call their .use function
 
 ==============================
 */
-void SUB_UseTargets(entity this, entity actor, entity trigger)
+
+void SUB_UseTargets_Ex(entity this, entity actor, entity trigger, bool preventReuse)
 {
 //
 // check for a delay
@@ -200,6 +203,7 @@ void SUB_UseTargets(entity this, entity actor, entity trigger)
                t.target2 = this.target2;
                t.target3 = this.target3;
                t.target4 = this.target4;
+               t.antiwall_flag = this.antiwall_flag;
                return;
        }
 
@@ -225,7 +229,7 @@ void SUB_UseTargets(entity this, entity actor, entity trigger)
        if (s != "")
        {
                for(entity t = NULL; (t = find(t, targetname, s)); )
-                       remove(t);
+                       delete(t);
        }
 #endif
 
@@ -253,11 +257,11 @@ void SUB_UseTargets(entity this, entity actor, entity trigger)
                        int aw_flag = this.antiwall_flag;
                        for(entity t = NULL; (t = find(t, targetname, s)); )
                        {
-                               if(t.use)
+                               if(t.use && (t.sub_target_used != time || !preventReuse))
                                {
                                        if(this.target_random)
                                        {
-                                               RandomSelection_Add(t, 0, string_null, 1, 0);
+                                               RandomSelection_AddEnt(t, 1, 0);
                                        }
                                        else
                                        {
@@ -265,6 +269,8 @@ void SUB_UseTargets(entity this, entity actor, entity trigger)
                                                        t.antiwall_flag = aw_flag;
 
                                                t.use(t, actor, this);
+                                               if(preventReuse)
+                                                       t.sub_target_used = time;
                                        }
                                }
                        }
@@ -272,9 +278,16 @@ void SUB_UseTargets(entity this, entity actor, entity trigger)
        }
 
        if(this.target_random && RandomSelection_chosen_ent)
+       {
                RandomSelection_chosen_ent.use(RandomSelection_chosen_ent, actor, this);
+               if(preventReuse)
+                       RandomSelection_chosen_ent.sub_target_used = time;
+       }
 }
 
+void SUB_UseTargets(entity this, entity actor, entity trigger) { SUB_UseTargets_Ex(this, actor, trigger, false); }
+void SUB_UseTargets_PreventReuse(entity this, entity actor, entity trigger) { SUB_UseTargets_Ex(this, actor, trigger, true); }
+
 void SUB_UseTargets_self(entity this)
 {
        SUB_UseTargets(this, NULL, NULL);