Merge branch 'Mario/spawnsystem_mutator' into Mario/overkill
authorMario <mario.mario@y7mail.com>
Mon, 7 Oct 2013 23:44:33 +0000 (16:44 -0700)
committerMario <mario.mario@y7mail.com>
Mon, 7 Oct 2013 23:44:33 +0000 (16:44 -0700)
mutators.cfg
qcsrc/server/autocvars.qh
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/mutator_overkill.qc
qcsrc/server/mutators/mutator_spawn_near_teammate.qc

index b25fb13..ef60d81 100644 (file)
@@ -37,11 +37,6 @@ set g_minstagib_speed_highspeed 1.5 "speed-multiplier that applies while you car
 //  overkill
 // ==========
 set g_overkill 0 "enable overkill"
-set g_overkill_spawnsystem 1 "experimental spawnsystem"
-set g_overkill_spawnsystem_delay 2.5 "how long to wait before its OK to spawn at a player after someone just spawned at this player"
-set g_overkill_spawnsystem_delay_death 0 "how long to wait before its OK to spawn at a player after death "
-set g_overkill_spawnsystem_check_health 1 "only allow spawn at this player if hes health is full"
-set g_overkill_spawnsystem_close2death 1 "spawn as close as possible to where we died"
 
 set g_overkill_100a_anyway 1
 set g_overkill_100h_anyway 1
@@ -110,6 +105,11 @@ set g_rocket_flying 0 "set to 1 to enable rocket flying in all balance configs"
 // =====================
 set g_spawn_near_teammate 0 "if set, players prefer spawns near a team mate"
 set g_spawn_near_teammate_distance 640 "max distance to consider a spawn to be near a team mate"
+set g_spawn_near_teammate_ignore_spawnpoint 0 "ignore spawnpoints and spawn right at team mates"
+set g_spawn_near_teammate_ignore_spawnpoint_delay 2.5 "how long to wait before its OK to spawn at a player after someone just spawned at this player"
+set g_spawn_near_teammate_ignore_spawnpoint_delay_death 0 "how long to wait before its OK to spawn at a player after death"
+set g_spawn_near_teammate_ignore_spawnpoint_check_health 1 "only allow spawn at this player if their health is full"
+set g_spawn_near_teammate_ignore_spawnpoint_closetodeath 1 "spawn as close to death location as possible"
 
 
 // ========================
@@ -189,3 +189,4 @@ set g_campcheck 0 "damages campers every few seconds"
 set g_campcheck_interval 10
 set g_campcheck_damage 100
 set g_campcheck_distance 1800
+
index 808186c..1909ee4 100644 (file)
@@ -1280,11 +1280,6 @@ float autocvar_g_campcheck_damage;
 float autocvar_g_campcheck_distance;
 float autocvar_g_campcheck_interval;
 float autocvar_g_jump_grunt;
-float autocvar_g_overkill_spawnsystem;
-float autocvar_g_overkill_spawnsystem_delay;
-float autocvar_g_overkill_spawnsystem_delay_death;
-float autocvar_g_overkill_spawnsystem_check_health;
-float autocvar_g_overkill_spawnsystem_close2death;
 float autocvar_g_overkill_powerups_replace;
 float autocvar_g_overkill_superguns_respawn_time;
 float autocvar_g_overkill_100h_anyway;
@@ -1293,3 +1288,9 @@ float autocvar_g_overkill_ammo_start;
 float autocvar_g_overkill_ammo_charge;
 float autocvar_g_overkill_ammo_charge_notice;
 float autocvar_g_overkill_ammo_charge_limit;
+float autocvar_g_spawn_near_teammate_distance;
+float autocvar_g_spawn_near_teammate_ignore_spawnpoint;
+float autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay;
+float autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death;
+float autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health;
+float autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath;
index ccfc440..77459d3 100644 (file)
@@ -905,7 +905,7 @@ void readlevelcvars(void)
                { if(cvar(mut_cvar) && dependence) { MUTATOR_ADD(mut_name); } }
                
        CHECK_MUTATOR_ADD("g_dodging", mutator_dodging, 1);
-       CHECK_MUTATOR_ADD("g_spawn_near_teammate", mutator_spawn_near_teammate, 1);
+       CHECK_MUTATOR_ADD("g_spawn_near_teammate", mutator_spawn_near_teammate, teamplay);
        CHECK_MUTATOR_ADD("g_physical_items", mutator_physical_items, 1);
        CHECK_MUTATOR_ADD("g_touchexplode", mutator_touchexplode, 1);
        CHECK_MUTATOR_ADD("g_minstagib", mutator_minstagib, 1);
index 228a1f1..713866d 100644 (file)
@@ -172,95 +172,7 @@ MUTATOR_HOOKFUNCTION(ok_PlayerSpawn)
        else
                self.ok_use_ammocharge = 0;
 
-       if(autocvar_g_overkill_spawnsystem_delay_death)
-               self.ok_spawnsys_timer = time + autocvar_g_overkill_spawnsystem_delay_death;
-
-       if(teamplay == 0 || autocvar_g_overkill_spawnsystem == 0)
-               return FALSE;
-
-       entity team_mate, best_mate = world;
-       vector best_spot = '0 0 0';
-       float pc = 0., best_dist = 0., dist = 0.;
-       FOR_EACH_PLAYER(team_mate)
-       {
-               if((autocvar_g_overkill_spawnsystem_check_health != 0 && team_mate.health >= 100) || autocvar_g_overkill_spawnsystem_check_health == 0)
-                       if(team_mate.deadflag == DEAD_NO)
-                               if(team_mate.ok_spawnsys_timer < time)
-                                       if(team_mate.team == self.team && (g_ctf || g_tdm || g_keyhunt))
-                                               if(team_mate != self)
-                                               {
-                                                       tracebox(team_mate.origin, PL_MIN, PL_MAX, team_mate.origin - '0 0 100', MOVE_WORLDONLY, team_mate);
-                                                       if(trace_fraction != 1.0)
-                                                               if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
-                                                               {
-                                                                       pc = pointcontents(trace_endpos + '0 0 1');
-                                                                       if(pc == CONTENT_EMPTY)
-                                                                       {
-                                                                               if(vlen(team_mate.velocity) > 5)
-                                                                                       fixedmakevectors(vectoangles(team_mate.velocity));
-                                                                               else
-                                                                                       fixedmakevectors(team_mate.angles);
-
-                                                                               for(pc = 0; pc != 5; ++pc) // test 5 diffrent spots close to mate
-                                                                               {
-                                                                                       switch(pc)
-                                                                                       {
-                                                                                       case 0:
-                                                                                               tracebox(team_mate.origin , PL_MIN, PL_MAX, team_mate.origin + v_right * 128, MOVE_NORMAL, team_mate);
-                                                                                               break;
-                                                                                       case 1:
-                                                                                               tracebox(team_mate.origin , PL_MIN, PL_MAX,team_mate.origin - v_right * 128 , MOVE_NORMAL, team_mate);
-                                                                                               break;
-                                                                                       case 2:
-                                                                                               tracebox(team_mate.origin , PL_MIN, PL_MAX, team_mate.origin + v_right * 64 - v_forward * 64, MOVE_NORMAL, team_mate);
-                                                                                               break;
-                                                                                       case 3:
-                                                                                               tracebox(team_mate.origin , PL_MIN, PL_MAX, team_mate.origin - v_right * 64 - v_forward * 64, MOVE_NORMAL, team_mate);
-                                                                                               break;
-                                                                                       case 4:
-                                                                                               tracebox(team_mate.origin , PL_MIN, PL_MAX, team_mate.origin - v_forward * 128, MOVE_NORMAL, team_mate);
-                                                                                               break;
-                                                                                       }
-
-                                                                                       if(trace_fraction == 1.0)
-                                                                                       {
-                                                                                               traceline(trace_endpos + '0 0 4', trace_endpos - '0 0 100', MOVE_NORMAL, team_mate);
-                                                                                               if(trace_fraction != 1.0)
-                                                                                               {
-                                                                                                       if(autocvar_g_overkill_spawnsystem_close2death)
-                                                                                                       {
-                                                                                                               dist = vlen(trace_endpos - self.ok_deathloc);
-                                                                                                               if(dist < best_dist || best_dist == 0)
-                                                                                                               {
-                                                                                                                       best_dist = dist;
-                                                                                                                       best_spot = trace_endpos;
-                                                                                                                       best_mate = team_mate;
-                                                                                                               }
-                                                                                                       }
-                                                                                                       else
-                                                                                                       {
-                                                                                                               setorigin(self, trace_endpos);
-                                                                                                               self.angles = team_mate.angles;
-                                                                                                               team_mate.ok_spawnsys_timer = time + autocvar_g_overkill_spawnsystem_delay;
-                                                                                                               return FALSE;
-                                                                                                       }
-                                                                                               }
-                                                                                       }
-                                                                               }
-                                                                       }
-                                                               }
-                                               }
-       }
-
-       if(autocvar_g_overkill_spawnsystem_close2death)
-               if(best_dist)
-               {
-                       setorigin(self, best_spot);
-                       self.angles = best_mate.angles;
-                       best_mate.ok_spawnsys_timer = time + autocvar_g_overkill_spawnsystem_delay;
-               }
-
-       return 0;
+       return FALSE;
 }
 
 void start_hmg()
index 4d0746d..8aec0bd 100644 (file)
@@ -1,8 +1,13 @@
-float autocvar_g_spawn_near_teammate_distance;
 .entity msnt_lookat;
 
+.float msnt_timer;
+.vector msnt_deathloc;
+
 MUTATOR_HOOKFUNCTION(msnt_Spawn_Score)
 {
+       if(autocvar_g_spawn_near_teammate_ignore_spawnpoint)
+               return 0;
+
        entity p;
 
        spawn_spot.msnt_lookat = world;
@@ -36,7 +41,97 @@ MUTATOR_HOOKFUNCTION(msnt_Spawn_Score)
 
 MUTATOR_HOOKFUNCTION(msnt_PlayerSpawn)
 {
-       if(spawn_spot.msnt_lookat)
+       if(autocvar_g_spawn_near_teammate_ignore_spawnpoint)
+       {
+               if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death)
+                       self.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death;
+                       
+               entity team_mate, best_mate = world;
+               vector best_spot = '0 0 0';
+               float pc = 0, best_dist = 0, dist = 0;
+               FOR_EACH_PLAYER(team_mate)
+               {
+                       if((autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health >= 0 && team_mate.health >= autocvar_g_balance_health_regenstable) || autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health == 0)
+                       if(team_mate.deadflag == DEAD_NO)
+                       if(team_mate.msnt_timer < time)
+                       if(SAME_TEAM(self, team_mate))
+                       if(time > team_mate.spawnshieldtime) // spawn shielding
+                       if(team_mate.freezetag_frozen == 0)
+                       if(team_mate != self)
+                       {
+                               tracebox(team_mate.origin, PL_MIN, PL_MAX, team_mate.origin - '0 0 100', MOVE_WORLDONLY, team_mate);
+                               if(trace_fraction != 1.0)
+                               if not(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
+                               {
+                                       pc = pointcontents(trace_endpos + '0 0 1');
+                                       if(pc == CONTENT_EMPTY)
+                                       {
+                                               if(vlen(team_mate.velocity) > 5)
+                                                       fixedmakevectors(vectoangles(team_mate.velocity));
+                                               else
+                                                       fixedmakevectors(team_mate.angles);
+
+                                               for(pc = 0; pc != 5; ++pc) // test 5 diffrent spots close to mate
+                                               {
+                                                       switch(pc)
+                                                       {
+                                                               case 0:
+                                                                       tracebox(team_mate.origin , PL_MIN, PL_MAX, team_mate.origin + v_right * 128, MOVE_NORMAL, team_mate);
+                                                                       break;
+                                                               case 1:
+                                                                       tracebox(team_mate.origin , PL_MIN, PL_MAX, team_mate.origin - v_right * 128 , MOVE_NORMAL, team_mate);
+                                                                       break;
+                                                               case 2:
+                                                                       tracebox(team_mate.origin , PL_MIN, PL_MAX, team_mate.origin + v_right * 64 - v_forward * 64, MOVE_NORMAL, team_mate);
+                                                                       break;
+                                                               case 3:
+                                                                       tracebox(team_mate.origin , PL_MIN, PL_MAX, team_mate.origin - v_right * 64 - v_forward * 64, MOVE_NORMAL, team_mate);
+                                                                       break;
+                                                               case 4:
+                                                                       tracebox(team_mate.origin , PL_MIN, PL_MAX, team_mate.origin - v_forward * 128, MOVE_NORMAL, team_mate);
+                                                                       break;
+                                                       }
+
+                                                       if(trace_fraction == 1.0)
+                                                       {
+                                                               traceline(trace_endpos + '0 0 4', trace_endpos - '0 0 100', MOVE_NORMAL, team_mate);
+                                                               if(trace_fraction != 1.0)
+                                                               {
+                                                                       if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath)
+                                                                       {
+                                                                               dist = vlen(trace_endpos - self.msnt_deathloc);
+                                                                               if(dist < best_dist || best_dist == 0)
+                                                                               {
+                                                                                       best_dist = dist;
+                                                                                       best_spot = trace_endpos;
+                                                                                       best_mate = team_mate;
+                                                                               }
+                                                                       }
+                                                                       else
+                                                                       {
+                                                                               setorigin(self, trace_endpos);
+                                                                               self.angles = team_mate.angles;
+                                                                               team_mate.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay;
+                                                                               return 0;
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath)
+               if(best_dist)
+               {
+                       setorigin(self, best_spot);
+                       self.angles = best_mate.angles;
+                       self.fixangle = TRUE;
+                       best_mate.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay;
+               }
+       }
+       else if(spawn_spot.msnt_lookat)
        {
                self.angles = vectoangles(spawn_spot.msnt_lookat.origin - self.origin);
                self.angles_x = -self.angles_x;
@@ -50,10 +145,17 @@ MUTATOR_HOOKFUNCTION(msnt_PlayerSpawn)
        return 0;
 }
 
+MUTATOR_HOOKFUNCTION(msnt_PlayerDies)
+{
+       self.msnt_deathloc = self.origin;
+       return 0;
+}
+
 MUTATOR_DEFINITION(mutator_spawn_near_teammate)
 {
        MUTATOR_HOOK(Spawn_Score, msnt_Spawn_Score, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerSpawn, msnt_PlayerSpawn, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayerDies, msnt_PlayerDies, CBC_ORDER_ANY);
 
        return 0;
 }