]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add basic relay activation support to spawn points
authorMario <mario.mario@y7mail.com>
Wed, 31 Jul 2024 04:47:11 +0000 (14:47 +1000)
committerMario <mario.mario@y7mail.com>
Wed, 31 Jul 2024 04:47:11 +0000 (14:47 +1000)
qcsrc/server/spawnpoints.qc

index 0a4ee0c2b46e840865b01f68c6899dd9b5e658ff..19f03f010a099ca3c46ca9e657c8bf7ff39cc92f 100644 (file)
@@ -75,6 +75,27 @@ void spawnpoint_use(entity this, entity actor, entity trigger)
        //LOG_INFO("spawnpoint was used!\n");
 }
 
+bool spawnpoint_customize(entity this, entity client)
+{
+       return (this.active == ACTIVE_ACTIVE);
+}
+
+void spawnpoint_setactive(entity this, int act)
+{
+       int old_status = this.active;
+       if(act == ACTIVE_TOGGLE)
+               this.active = (this.active == ACTIVE_ACTIVE) ? ACTIVE_NOT : ACTIVE_ACTIVE;
+       else
+               this.active = act;
+
+       if(this.active != old_status)
+       {
+               // mappers may attempt to let players disable enemy spawns
+               if(teamplay && have_team_spawns > 0)
+                       some_spawn_has_been_used = true;
+               this.SendFlags |= 1;
+       }
+}
 void spawnpoint_reset(entity this)
 {
        this.SendFlags |= 1; // update team since it was restored during reset
@@ -125,6 +146,9 @@ void relocate_spawnpoint(entity this)
         }
     }
 
+    this.active = ACTIVE_ACTIVE;
+    this.setactive = spawnpoint_setactive;
+    setcefc(this, spawnpoint_customize);
     this.use = spawnpoint_use;
     setthink(this, spawnpoint_think);
     this.nextthink = time + 0.5 + random() * 2; // shouldn't need it for a little second
@@ -222,6 +246,9 @@ vector Spawn_Score(entity this, entity spot, float mindist, float teamcheck, boo
                if(!spot.target || spot.target == "")
                        return '-1 0 0';
 
+       if(spot.active != ACTIVE_ACTIVE && targetcheck)
+               return '-1 0 0';
+
        if(IS_REAL_CLIENT(this))
        {
                if(spot.restriction == 1)