From 5cd2cd7531bf32782f72799f9dd2195c69b071e8 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sat, 3 Dec 2011 20:43:22 +0100 Subject: [PATCH] more stuff... look at teammate --- defaultXonotic.cfg | 2 +- qcsrc/common/constants.qh | 7 +-- qcsrc/server/cl_client.qc | 15 ++++--- qcsrc/server/mutators/base.qh | 3 +- .../mutators/mutator_spawn_near_teammate.qc | 44 +++++++++++++++---- 5 files changed, 50 insertions(+), 21 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 7e1c93152..acae53764 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -610,7 +610,7 @@ 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" +set g_spawn_near_teammate_distance 640 "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 fa6cc2cff..7e5e99edb 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -576,6 +576,7 @@ float HUD_MENU_ENABLE = 0; #define SERVERFLAG_PLAYERSTATS 4 // spawnpoint prios -#define SPAWN_PRIO_GOOD_DISTANCE 100 -#define SPAWN_PRIO_RACE_PREVIOUS_SPAWN 50 -#define SPAWN_PRIO_NEAR_TEAMMATE 10 +#define SPAWN_PRIO_NEAR_TEAMMATE_FOUND 200 +#define SPAWN_PRIO_NEAR_TEAMMATE_SAMETEAM 100 +#define SPAWN_PRIO_RACE_PREVIOUS_SPAWN 50 +#define SPAWN_PRIO_GOOD_DISTANCE 10 diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 9d220fc12..c21fc7871 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -162,7 +162,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck) prio += SPAWN_PRIO_GOOD_DISTANCE; spawn_score = prio * '1 0 0' + shortest * '0 1 0'; - spawn_score_spot = spot; + spawn_spot = spot; // filter out spots for assault if(spot.target != "") { @@ -996,12 +996,6 @@ void PutClientInServer (void) race_PostSpawn(spot); - if(autocvar_spawn_debug) - { - sprint(self, strcat("spawnpoint origin: ", vtos(spot.origin), "\n")); - remove(spot); // usefull for checking if there are spawnpoints, that let drop through the floor - } - //stuffcmd(self, "chase_active 0"); //stuffcmd(self, "set viewsize $tmpviewsize \n"); @@ -1040,8 +1034,15 @@ void PutClientInServer (void) activator = world; self = oldself; + spawn_spot = spot; MUTATOR_CALLHOOK(PlayerSpawn); + if(autocvar_spawn_debug) + { + sprint(self, strcat("spawnpoint origin: ", vtos(spot.origin), "\n")); + remove(spot); // usefull for checking if there are spawnpoints, that let drop through the floor + } + self.switchweapon = w_getbestweapon(self); self.cnt = -1; // W_LastWeapon will not complain self.weapon = 0; diff --git a/qcsrc/server/mutators/base.qh b/qcsrc/server/mutators/base.qh index 8778829aa..e668c1da1 100644 --- a/qcsrc/server/mutators/base.qh +++ b/qcsrc/server/mutators/base.qh @@ -45,6 +45,7 @@ MUTATOR_HOOKABLE(MakePlayerObserver); // called when a player becomes observer, after shared setup MUTATOR_HOOKABLE(PlayerSpawn); + entity spawn_spot; // spot that was used, or world // called when a player spawns as player, after shared setup, before his weapon is chosen (so items may be changed in here) MUTATOR_HOOKABLE(ClientDisconnect); @@ -194,6 +195,6 @@ MUTATOR_HOOKABLE(Spawn_Score); // return 1 to make the spawnpoint unusable // INPUT entity self; // player wanting to spawn - entity spawn_score_spot; // spot to be evaluated + entity spawn_spot; // spot to be evaluated // IN+OUT vector spawn_score; // _x is priority, _y is "distance" diff --git a/qcsrc/server/mutators/mutator_spawn_near_teammate.qc b/qcsrc/server/mutators/mutator_spawn_near_teammate.qc index 36e7db118..4d0746dec 100644 --- a/qcsrc/server/mutators/mutator_spawn_near_teammate.qc +++ b/qcsrc/server/mutators/mutator_spawn_near_teammate.qc @@ -1,25 +1,50 @@ float autocvar_g_spawn_near_teammate_distance; +.entity msnt_lookat; -MUTATOR_HOOKFUNCTION(msnt_Spawn_Score) { +MUTATOR_HOOKFUNCTION(msnt_Spawn_Score) +{ entity p; + spawn_spot.msnt_lookat = world; + if(!teamplay) return 0; + RandomSelection_Init(); 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) + float l = vlen(spawn_spot.origin - p.origin); + if(l > autocvar_g_spawn_near_teammate_distance) continue; - if(!checkpvs(spawn_score_spot.origin, p)) + if(l < 48) continue; + if(!checkpvs(spawn_spot.origin, p)) + continue; + RandomSelection_Add(p, 0, string_null, 1, 1); + } + + if(RandomSelection_chosen_ent) + { + spawn_spot.msnt_lookat = RandomSelection_chosen_ent; + spawn_score_x += SPAWN_PRIO_NEAR_TEAMMATE_FOUND; + } + else if(self.team == spawn_spot.team) + spawn_score_x += SPAWN_PRIO_NEAR_TEAMMATE_SAMETEAM; // prefer same team, if we can't find a spawn near teammate + + return 0; +} + +MUTATOR_HOOKFUNCTION(msnt_PlayerSpawn) +{ + if(spawn_spot.msnt_lookat) + { + self.angles = vectoangles(spawn_spot.msnt_lookat.origin - self.origin); + self.angles_x = -self.angles_x; /* - if(self == nextent(world)) - { - te_explosion(p.origin); - print(p.netname, " should be nearby\n"); - } + sprint(self, "You should be looking at ", spawn_spot.msnt_lookat.netname, "^7.\n"); + sprint(self, "distance: ", vtos(spawn_spot.msnt_lookat.origin - self.origin), "\n"); + sprint(self, "angles: ", vtos(self.angles), "\n"); */ - spawn_score_x += SPAWN_PRIO_NEAR_TEAMMATE; } return 0; @@ -28,6 +53,7 @@ MUTATOR_HOOKFUNCTION(msnt_Spawn_Score) { MUTATOR_DEFINITION(mutator_spawn_near_teammate) { MUTATOR_HOOK(Spawn_Score, msnt_Spawn_Score, CBC_ORDER_ANY); + MUTATOR_HOOK(PlayerSpawn, msnt_PlayerSpawn, CBC_ORDER_ANY); return 0; } -- 2.39.2