]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
g_spawn_near_teammate spawnpoint scoring mutator
authorRudolf Polzer <divverent@xonotic.org>
Sat, 3 Dec 2011 19:04:00 +0000 (20:04 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Sat, 3 Dec 2011 19:04:00 +0000 (20:04 +0100)
defaultXonotic.cfg
qcsrc/common/constants.qh
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/mutator_spawn_near_teammate.qc [new file with mode: 0644]
qcsrc/server/mutators/mutators.qh
qcsrc/server/progs.src

index 378541e03974c8686855618870b5a57e203db6d4..7e1c931529345217ab50cabbdfda8d37be1b4cd7 100644 (file)
@@ -609,6 +609,8 @@ seta g_freezetag_frozen_force 0.6 "How much to multiply the force on a frozen pl
 
 set g_spawn_furthest 0.5 "this amount of the spawns shall be far away from any players"
 set g_spawn_useallspawns 0 "use all spawns, e.g. also team spawns in non-teamplay, and all spawns, even enemy spawns, in teamplay"
+set g_spawn_near_teammate 0 "if set, players prefer spawns near a team mate"
+set g_spawn_near_teammate_distance 384 "max distance to consider a spawn to be near a team mate"
 // respawn delay
 set g_respawn_delay 2 "number of seconds you have to wait before you can respawn again"
 set g_respawn_waves 0 "respawn in waves (every n seconds), intended to decrease overwhelming base attacks"
index e42afed4ef047f09406a0785744ff0d98890df16..fa6cc2cff18f89fb40a61aa2ba716d048ad35348 100644 (file)
@@ -578,3 +578,4 @@ float HUD_MENU_ENABLE               = 0;
 // spawnpoint prios
 #define SPAWN_PRIO_GOOD_DISTANCE        100
 #define SPAWN_PRIO_RACE_PREVIOUS_SPAWN   50
+#define SPAWN_PRIO_NEAR_TEAMMATE         10
index 5a575dd0e3dcb0a3833ebef50a0ed6d88fa83695..f9a9990a4c4349ca6d018d0283016754b28a9452 100644 (file)
@@ -1086,6 +1086,8 @@ void readlevelcvars(void)
                MUTATOR_ADD(mutator_rocketflying);
        if(cvar("g_vampire"))
                MUTATOR_ADD(mutator_vampire);
+       if(cvar("g_spawn_near_teammate"))
+               MUTATOR_ADD(mutator_spawn_near_teammate);
 
        if(cvar("sv_allow_fullbright"))
                serverflags |= SERVERFLAG_ALLOW_FULLBRIGHT;
diff --git a/qcsrc/server/mutators/mutator_spawn_near_teammate.qc b/qcsrc/server/mutators/mutator_spawn_near_teammate.qc
new file mode 100644 (file)
index 0000000..36e7db1
--- /dev/null
@@ -0,0 +1,33 @@
+float autocvar_g_spawn_near_teammate_distance;
+
+MUTATOR_HOOKFUNCTION(msnt_Spawn_Score) {
+       entity p;
+
+       if(!teamplay)
+               return 0;
+
+       FOR_EACH_PLAYER(p) if(p != self) if(p.team == self.team) if(!p.deadflag)
+       {
+               if(vlen(spawn_score_spot.origin - p.origin) > autocvar_g_spawn_near_teammate_distance)
+                       continue;
+               if(!checkpvs(spawn_score_spot.origin, p))
+                       continue;
+               /*
+               if(self == nextent(world))
+               {
+                       te_explosion(p.origin);
+                       print(p.netname, " should be nearby\n");
+               }
+               */
+               spawn_score_x += SPAWN_PRIO_NEAR_TEAMMATE;
+       }
+
+       return 0;
+}
+
+MUTATOR_DEFINITION(mutator_spawn_near_teammate)
+{
+       MUTATOR_HOOK(Spawn_Score, msnt_Spawn_Score, CBC_ORDER_ANY);
+
+       return 0;
+}
index 1ae28abe54ff961700c030d9e305119aa51bd5ec..ba7edaeecb2f2dadeb5f13001d3e9c0ff9af12f9 100644 (file)
@@ -7,3 +7,5 @@ MUTATOR_DECLARATION(mutator_nix);
 MUTATOR_DECLARATION(mutator_dodging);
 MUTATOR_DECLARATION(mutator_rocketflying);
 MUTATOR_DECLARATION(mutator_vampire);
+
+MUTATOR_DECLARATION(mutator_spawn_near_teammate);
index 64e6e66741b1ab3936f41180d6ed78bc4a20d67c..30a6d27836205f3eb46615e6ab7ace2ba9d8b50c 100644 (file)
@@ -195,6 +195,7 @@ mutators/mutator_nix.qc
 mutators/mutator_dodging.qc
 mutators/mutator_rocketflying.qc
 mutators/mutator_vampire.qc
+mutators/mutator_spawn_near_teammate.qc
 
 ../warpzonelib/anglestransform.qc
 ../warpzonelib/mathlib.qc