From b507e8fe3b756c08167b0889b3070833840989a8 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sat, 3 Dec 2011 20:04:00 +0100 Subject: [PATCH] g_spawn_near_teammate spawnpoint scoring mutator --- defaultXonotic.cfg | 2 ++ qcsrc/common/constants.qh | 1 + qcsrc/server/miscfunctions.qc | 2 ++ .../mutators/mutator_spawn_near_teammate.qc | 33 +++++++++++++++++++ qcsrc/server/mutators/mutators.qh | 2 ++ qcsrc/server/progs.src | 1 + 6 files changed, 41 insertions(+) create mode 100644 qcsrc/server/mutators/mutator_spawn_near_teammate.qc diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 378541e03..7e1c93152 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -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" diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index e42afed4e..fa6cc2cff 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -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 diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 5a575dd0e..f9a9990a4 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -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 index 000000000..36e7db118 --- /dev/null +++ b/qcsrc/server/mutators/mutator_spawn_near_teammate.qc @@ -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; +} diff --git a/qcsrc/server/mutators/mutators.qh b/qcsrc/server/mutators/mutators.qh index 1ae28abe5..ba7edaeec 100644 --- a/qcsrc/server/mutators/mutators.qh +++ b/qcsrc/server/mutators/mutators.qh @@ -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); diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index 64e6e6674..30a6d2783 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -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 -- 2.39.2