]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Another 2 gamemode specific checks killed
authorMario <mario@smbclan.net>
Wed, 14 Oct 2015 15:29:29 +0000 (01:29 +1000)
committerMario <mario@smbclan.net>
Wed, 14 Oct 2015 15:29:29 +0000 (01:29 +1000)
qcsrc/common/turrets/sv_turrets.qc
qcsrc/server/mutators/events.qh
qcsrc/server/mutators/gamemode_onslaught.qc

index e1c23c7ab0e476022d01e7bf501a6cb362d612b8..ec7ce3711e95f21c13a0834703bb4962045c9afb 100644 (file)
@@ -708,9 +708,8 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl
        if(e_target.alpha <= 0.3)
                return -1;
 
-       if(g_onslaught)
-               if (substring(e_target.classname, 0, 10) == "onslaught_") // don't attack onslaught targets, that's the player's job!
-                       return - 3;
+       if(MUTATOR_CALLHOOK(TurretValidateTarget, e_turret, e_target, validate_flags))
+               return ret_float;
 
        if (validate_flags & TFL_TARGETSELECT_NO)
                return -4;
@@ -1019,24 +1018,9 @@ void turret_fire()
 
 void turret_think()
 {SELFPARAM();
-       entity e;
-
        self.nextthink = time + self.ticrate;
 
-       // ONS uses somewhat backwards linking.
-       if (teamplay)
-       {
-               if (g_onslaught)
-                       if (self.target)
-                       {
-                               e = find(world, targetname,self.target);
-                               if (e != world)
-                                       self.team = e.team;
-                       }
-
-               if (self.team != self.tur_head.team)
-                       turret_respawn();
-       }
+       MUTATOR_CALLHOOK(TurretThink, self);
 
 #ifdef TURRET_DEBUG
        if (self.tur_debug_tmr1 < time)
@@ -1065,7 +1049,7 @@ void turret_think()
        if (self.shoot_flags & TFL_SHOOT_HITALLVALID)
        {
                // Do a self.turret_fire for every valid target.
-               e = findradius(self.origin,self.target_range);
+               entity e = findradius(self.origin,self.target_range);
                while (e)
                {
                        if(e.takedamage)
index 44801a25620f37b11498222cf4bf54a8b29bf124..93861ffae59e98aa194660518f1dae964843fddf 100644 (file)
@@ -784,4 +784,19 @@ entity wp_sendto;
 int wp_sendflags;
 int wp_flag;
 MUTATOR_HOOKABLE(SendWaypoint, EV_SendWaypoint);
+
+#define EV_TurretValidateTarget(i, o) \
+    /**/ i(entity, turret_this) \
+    /**/ i(entity, turret_target) \
+    /**/ i(int, turret_vflags) \
+    /**/
+entity turret_this;
+entity turret_target;
+int turret_vflags;
+MUTATOR_HOOKABLE(TurretValidateTarget, EV_TurretValidateTarget);
+
+#define EV_TurretThink(i, o) \
+    /**/ i(entity, __self) \
+    /**/
+MUTATOR_HOOKABLE(TurretThink, EV_TurretThink);
 #endif
index 68318f4d6b97c72149260ecee961021a63d31bc1..53cf0c7980ac1caa3d387aa3d6ff7527e872e35a 100644 (file)
@@ -2066,6 +2066,34 @@ MUTATOR_HOOKFUNCTION(ons, SendWaypoint)
        return false;
 }
 
+MUTATOR_HOOKFUNCTION(ons, TurretValidateTarget)
+{
+       if(substring(turret_target.classname, 0, 10) == "onslaught_") // don't attack onslaught targets, that's the player's job!
+       {
+               ret_float = -3;
+               return true;
+       }
+
+       return false;
+}
+
+MUTATOR_HOOKFUNCTION(ons, TurretThink)
+{
+       // ONS uses somewhat backwards linking.
+       if(self.target)
+       {
+               entity e = find(world, targetname, self.target);
+               if (e != world)
+                       self.team = e.team;
+       }
+
+       if(self.team != self.tur_head.team)
+               turret_respawn();
+
+       return false;
+}
+
+
 // ==========
 // Spawnfuncs
 // ==========