]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into Mario/wepent_experimental
authorMario <mario@smbclan.net>
Thu, 10 Nov 2016 16:05:48 +0000 (02:05 +1000)
committerMario <mario@smbclan.net>
Thu, 10 Nov 2016 16:05:48 +0000 (02:05 +1000)
18 files changed:
.gitlab-ci.yml
defaultXonotic.cfg
mutators.cfg
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/shownames.qc
qcsrc/common/ent_cs.qh
qcsrc/common/mutators/mutator/damagetext/damagetext.qc
qcsrc/common/mutators/mutator/instagib/sv_instagib.qc
qcsrc/common/mutators/mutator/melee_only/sv_melee_only.qc
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/overkill/sv_overkill.qc
qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc
qcsrc/common/triggers/func/train.qc
qcsrc/menu/xonotic/dialog_uid2name.qh
qcsrc/menu/xonotic/serverlist.qh
qcsrc/server/_all.qh
qcsrc/server/mutators/events.qh
qcsrc/server/player.qc

index 3c251dccc6bab8b822b9bf94bd5fb2e2c1d54d9e..3c4126b01d23bcbf383052bdaaffb6592f85ef32 100644 (file)
@@ -30,7 +30,7 @@ test_sv_game:
     - wget -O data/maps/g-23.waypoints.cache https://gitlab.com/xonotic/xonotic-maps.pk3dir/raw/master/maps/g-23.waypoints.cache
     - wget -O data/maps/g-23.waypoints.hardwired https://gitlab.com/xonotic/xonotic-maps.pk3dir/raw/master/maps/g-23.waypoints.hardwired
     - make
-    - EXPECT=0a9ea83e32e148da989cbbadc7421ea0
+    - EXPECT=93decd0a82cf911f02fb5572197db7f3
     - HASH=$(${ENGINE} -noconfig -nohome +exec serverbench.cfg
       | tee /dev/stderr
       | grep '^:'
index 5df6d59bb47423025b8a9eb9f089d284ea012e1d..bc346e94a7e6c66d1e10a0daadb4852a7a537c0d 100644 (file)
@@ -782,7 +782,7 @@ seta g_waypointsprite_turrets_maxdist 5000 "max distace for turret sprites"
 seta g_waypointsprite_tactical 1 "tactical overlay on turrets when in a vehicle"
 
 seta cl_damagetext "1" "Draw damage dealt where you hit the enemy"
-seta cl_damagetext_format "-{total}" "How to format the damage text. {health}, {armor}, {total}"
+seta cl_damagetext_format "-{total}" "How to format the damage text. {health}, {armor}, {total}, {potential}, {potential_health}"
 seta cl_damagetext_color "1 1 0" "Damage text color"
 seta cl_damagetext_color_per_weapon "0" "Damage text uses weapon color"
 seta cl_damagetext_size "8" "Damage text font size"
index abb74df30eebd389fe39cf431ad2a1d144380a26..54517d9f7bb75a7704804b8ceb3f37adc7765f03 100644 (file)
@@ -109,8 +109,9 @@ seta cl_spawn_near_teammate 1 "toggle for spawning near teammates (only effectiv
 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, if 2, clients can ignore this option"
+set g_spawn_near_teammate_ignore_spawnpoint_max 10 "if set, test at most this many of the available teammates"
 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_delay_death 3 "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"
 
@@ -420,4 +421,4 @@ set g_walljump 0 "Enable wall jumping mutator"
 set g_walljump_delay 1 "Minimum delay between wall jumps"
 set g_walljump_force 300 "How far to bounce/jump off the wall"
 set g_walljump_velocity_xy_factor 1.15 "How much to slow down along horizontal axis, higher value = higher deceleration, if factor is < 1, you accelerate by wall jumping"
-set g_walljump_velocity_z_factor 0.5 "Upwards velocity factor, multiplied by normal jump velocity"
\ No newline at end of file
+set g_walljump_velocity_z_factor 0.5 "Upwards velocity factor, multiplied by normal jump velocity"
index ef68e21b2000808fb0a8cec871bb86abda43ea39..994ff12aa59e4c6ca25a63591638d1e30397b458 100644 (file)
@@ -1121,11 +1121,11 @@ vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size)
                int weapon_stats = weapon_accuracy[i - WEP_FIRST];
 
                WepSet set = it.m_wepset;
-               if (weapon_stats < 0)
+               if (weapon_stats < 0 && !((weapons_stat & set) || (weapons_inmap & set)))
                {
-                       if (!(weapons_stat & set) && (it.spawnflags & WEP_FLAG_HIDDEN || it.spawnflags & WEP_FLAG_MUTATORBLOCKED))
-                               nHidden += 1;
-                       else if (!(weapons_stat & set || weapons_inmap & set))
+                       if (((it.spawnflags & WEP_FLAG_HIDDEN) || (it.spawnflags & WEP_FLAG_MUTATORBLOCKED)))
+                               ++nHidden;
+                       else
                                ++disownedcnt;
                }
        });
@@ -1199,7 +1199,7 @@ vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size)
                int weapon_stats = weapon_accuracy[i - WEP_FIRST];
 
                WepSet set = it.m_wepset;
-               if (weapon_stats < 0 && !(weapons_stat & set || weapons_inmap & set))
+               if (weapon_stats < 0 && !((weapons_stat & set) || (weapons_inmap & set)))
                        continue;
 
                float weapon_alpha;
index 6a4515ac14f128f4b20eba195a090b849a0a138c..76125e60b7e1a63224935ea7db8b22cf4b4e207e 100644 (file)
@@ -193,6 +193,8 @@ void Draw_ShowNames_All()
                        it.sameteam = false;
                }
                bool dead = entcs_IsDead(i) || entcs_IsSpectating(i);
+               if(gametype == MAPINFO_TYPE_CA)
+                       dead = (dead || entcs_IsEliminated(i));
                if (!it.csqcmodel_isdead) setorigin(it, entcs.origin);
                it.csqcmodel_isdead = dead;
                Draw_ShowNames(it);
index 65cdd83d3a71f4f5df325a8e90b727d936cb1300..ac06dc4788ff0eb0d403075c1a747dba8a62e105 100644 (file)
@@ -68,6 +68,17 @@ REGISTER_NET_TEMP(CLIENT_ENTCS)
 
        /**
      * @param i zero indexed player
+     */
+    .int frags;
+       bool entcs_IsEliminated(int i)
+       {
+               bool unconnected = !playerslots[i].gotscores;
+               entity e = entcs_receiver(i);
+               return unconnected || ((e) ? e.frags : stof(getplayerkeyvalue(i, "frags"))) == FRAGS_LMS_LOSER;
+       }
+
+       /**
+     * @param i zero indexed player
      */
        int entcs_GetClientColors(int i)
        {
index e55b9fcd91527f8b4b82d5a831303c27cf3a6e77..49826250172a80c148d5fe445130e6fa3395001f 100644 (file)
@@ -8,7 +8,7 @@ REGISTER_MUTATOR(damagetext, true);
 #if defined(CSQC) || defined(MENUQC)
 // no translatable cvar description please
 AUTOCVAR_SAVE(cl_damagetext,                        bool,   true,       "Draw damage dealt where you hit the enemy");
-AUTOCVAR_SAVE(cl_damagetext_format,                 string, "-{total}", "How to format the damage text. {health}, {armor}, {total}");
+AUTOCVAR_SAVE(cl_damagetext_format,             string, "-{total}", "How to format the damage text. {health}, {armor}, {total}, {potential}, {potential_health}");
 STATIC_INIT(DamageText_LegacyFormat) {
     if (strstrofs(autocvar_cl_damagetext_format, "{", 0) < 0) autocvar_cl_damagetext_format = "-{total}";
 }
@@ -37,6 +37,7 @@ CLASS(DamageText, Object)
     ATTRIB(DamageText, m_friendlyfire, bool, false);
     ATTRIB(DamageText, m_damage, int, 0);
     ATTRIB(DamageText, m_armordamage, int, 0);
+    ATTRIB(DamageText, m_potential_damage, int, 0);
     ATTRIB(DamageText, m_deathtype, int, 0);
     ATTRIB(DamageText, time_prev, float, time);
 
@@ -64,24 +65,27 @@ CLASS(DamageText, Object)
             s = strreplace("{health}", sprintf("%d", rint(this.m_damage / DAMAGETEXT_PRECISION_MULTIPLIER)), s);
             s = strreplace("{armor}",  sprintf("%d", rint(this.m_armordamage / DAMAGETEXT_PRECISION_MULTIPLIER)), s);
             s = strreplace("{total}",  sprintf("%d", rint((this.m_damage + this.m_armordamage) / DAMAGETEXT_PRECISION_MULTIPLIER)), s);
+            s = strreplace("{potential}",  sprintf("%d", rint(this.m_potential_damage/DAMAGETEXT_PRECISION_MULTIPLIER)), s);
+            s = strreplace("{potential_health}",  sprintf("%d", rint((this.m_potential_damage - this.m_armordamage)/DAMAGETEXT_PRECISION_MULTIPLIER)), s);
             drawcolorcodedstring2_builtin(pos, s, this.m_size * '1 1 0', rgb, this.alpha, DRAWFLAG_NORMAL);
         }
     }
     ATTRIB(DamageText, draw2d, void(DamageText), DamageText_draw2d);
 
-    void DamageText_update(DamageText this, vector _origin, int _health, int _armor, int _deathtype) {
+    void DamageText_update(DamageText this, vector _origin, int _health, int _armor, int _potential_damage, int _deathtype) {
         this.m_damage = _health;
         this.m_armordamage = _armor;
+        this.m_potential_damage = _potential_damage;
         this.m_deathtype = _deathtype;
         setorigin(this, _origin);
         this.alpha = autocvar_cl_damagetext_alpha_start;
     }
 
-    CONSTRUCTOR(DamageText, int _group, vector _origin, int _health, int _armor, int _deathtype, bool _friendlyfire) {
+    CONSTRUCTOR(DamageText, int _group, vector _origin, int _health, int _armor, int _potential_damage, int _deathtype, bool _friendlyfire) {
         CONSTRUCT(DamageText);
         this.m_group = _group;
         this.m_friendlyfire = _friendlyfire;
-        DamageText_update(this, _origin, _health, _armor, _deathtype);
+        DamageText_update(this, _origin, _health, _armor, _potential_damage, _deathtype);
                IL_PUSH(g_drawables_2d, this);
     }
 ENDCLASS(DamageText)
@@ -102,6 +106,7 @@ MUTATOR_HOOKFUNCTION(damagetext, PlayerDamaged) {
     const float health = M_ARGV(2, float);
     const float armor = M_ARGV(3, float);
     const int deathtype = M_ARGV(5, int);
+    const float potential_damage = M_ARGV(6, float);
     const vector location = hit.origin;
     FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
         if (
@@ -113,6 +118,7 @@ MUTATOR_HOOKFUNCTION(damagetext, PlayerDamaged) {
             int flags = SAME_TEAM(hit, attacker); // BIT(0)
             if (health >= DAMAGETEXT_SHORT_LIMIT) flags |= BIT(1);
             if (armor >= DAMAGETEXT_SHORT_LIMIT) flags |= BIT(2);
+            if (potential_damage >= DAMAGETEXT_SHORT_LIMIT) flags |= BIT(3);
 
             msg_entity = it;
             WriteHeader(MSG_ONE, damagetext);
@@ -130,6 +136,8 @@ MUTATOR_HOOKFUNCTION(damagetext, PlayerDamaged) {
             else WriteShort(MSG_ONE, health * DAMAGETEXT_PRECISION_MULTIPLIER);
             if (armor >= DAMAGETEXT_SHORT_LIMIT) WriteInt24_t(MSG_ONE, armor * DAMAGETEXT_PRECISION_MULTIPLIER);
             else WriteShort(MSG_ONE, armor * DAMAGETEXT_PRECISION_MULTIPLIER);
+            if (potential_damage >= DAMAGETEXT_SHORT_LIMIT) WriteInt24_t(MSG_ONE, potential_damage * DAMAGETEXT_PRECISION_MULTIPLIER);
+            else WriteShort(MSG_ONE, potential_damage * DAMAGETEXT_PRECISION_MULTIPLIER);
         }
     ));
 }
@@ -144,11 +152,13 @@ NET_HANDLE(damagetext, bool isNew)
     int flags = ReadByte();
     bool friendlyfire = flags & 1;
 
-    int health, armor;
+    int health, armor, potential_damage;
     if (flags & BIT(1)) health = ReadInt24_t();
     else health = ReadShort();
     if (flags & BIT(2)) armor = ReadInt24_t();
     else armor = ReadShort();
+    if (flags & BIT(3)) potential_damage = ReadInt24_t();
+    else potential_damage = ReadShort();
 
     return = true;
     if (autocvar_cl_damagetext) {
@@ -158,12 +168,12 @@ NET_HANDLE(damagetext, bool isNew)
         if (autocvar_cl_damagetext_accumulate_range) {
             for (entity e = findradius(location, autocvar_cl_damagetext_accumulate_range); e; e = e.chain) {
                 if (e.instanceOfDamageText && e.m_group == group && e.alpha > autocvar_cl_damagetext_accumulate_alpha_rel * autocvar_cl_damagetext_alpha_start) {
-                    DamageText_update(e, location, e.m_damage + health, e.m_armordamage + armor, deathtype);
+                    DamageText_update(e, location, e.m_damage + health, e.m_armordamage + armor, e.m_potential_damage + potential_damage, deathtype);
                     return;
                 }
             }
         }
-        make_impure(NEW(DamageText, group, location, health, armor, deathtype, friendlyfire));
+        make_impure(NEW(DamageText, group, location, health, armor, potential_damage, deathtype, friendlyfire));
     }
 }
 #endif
@@ -207,6 +217,7 @@ CLASS(XonoticDamageTextSettings, XonoticTab)
                 setDependent(e, "cl_damagetext", 1, 1);
         this.TR(this);
         this.TR(this);
+        // friendly fire
             this.TD(this, 1, 3, e = makeXonoticCheckBox(0, "cl_damagetext_friendlyfire", _("Draw damage numbers for friendly fire")));
                 setDependent(e, "cl_damagetext", 1, 1);
         this.TR(this);
index 6135e72b556a1aa3d7934fdbc4d631b161981df4..4c6dc15a3c0bff02b9dcaa75435e5789b2c9673f 100644 (file)
@@ -360,6 +360,12 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, SetStartItems)
        start_items |= IT_UNLIMITED_SUPERWEAPONS;
 }
 
+MUTATOR_HOOKFUNCTION(mutator_instagib, SetWeaponArena)
+{
+       // turn weapon arena off
+       M_ARGV(0, string) = "off";
+}
+
 void replace_with_insta_cells(entity item)
 {
        entity e = spawn();
index a8347499841b77d034adb39efac4853400343f29..5bd896ea279fc3178b1f5c3a7c1cdbda94441bbe 100644 (file)
@@ -8,6 +8,12 @@ MUTATOR_HOOKFUNCTION(melee_only, SetStartItems, CBC_ORDER_LAST)
        start_weapons = warmup_start_weapons = WEPSET(SHOTGUN);
 }
 
+MUTATOR_HOOKFUNCTION(melee_only, SetWeaponArena)
+{
+       // turn weapon arena off
+       M_ARGV(0, string) = "off";
+}
+
 MUTATOR_HOOKFUNCTION(melee_only, ForbidThrowCurrentWeapon)
 {
        return true;
index 71fb67af894d91c4f8c04aa83816ab357536b5e5..24d8c87cc0cbbfe1ca97ab8c0ec962c1160b430d 100644 (file)
@@ -1177,18 +1177,6 @@ CLASS(NadeOffhand, OffhandWeapon)
     METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed))
     {
        entity held_nade = player.nade;
-               if (held_nade)
-               {
-                       player.nade_timer = bound(0, (time - held_nade.nade_time_primed) / autocvar_g_nades_nade_lifetime, 1);
-                       // LOG_TRACEF("%d %d", player.nade_timer, time - held_nade.nade_time_primed);
-                       makevectors(player.angles);
-                       held_nade.velocity = player.velocity;
-                       setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
-                       held_nade.angles_y = player.angles.y;
-
-                       if (time + 0.1 >= held_nade.wait)
-                               toss_nade(player, false, '0 0 0', time + 0.05);
-               }
 
         if (!CanThrowNade(player)) return;
         if (!(time > player.nade_refire)) return;
@@ -1230,6 +1218,20 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink)
 
        if (player.nade && (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton);
 
+       entity held_nade = player.nade;
+       if (held_nade)
+       {
+               player.nade_timer = bound(0, (time - held_nade.nade_time_primed) / autocvar_g_nades_nade_lifetime, 1);
+               // LOG_TRACEF("%d %d", player.nade_timer, time - held_nade.nade_time_primed);
+               makevectors(player.angles);
+               held_nade.velocity = player.velocity;
+               setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
+               held_nade.angles_y = player.angles.y;
+
+               if (time + 0.1 >= held_nade.wait)
+                       toss_nade(player, false, '0 0 0', time + 0.05);
+       }
+
        if(IS_PLAYER(player))
        {
                if ( autocvar_g_nades_bonus && autocvar_g_nades )
index 0c7e6b027e3e4a355bf53ca9f8e222335628cf56..85beb641f0a91d3db6e1c2becde94a5080d4b96f 100644 (file)
@@ -265,6 +265,12 @@ MUTATOR_HOOKFUNCTION(ok, SetStartItems, CBC_ORDER_LAST)
        start_weapons = warmup_start_weapons = ok_start_items;
 }
 
+MUTATOR_HOOKFUNCTION(ok, SetWeaponArena)
+{
+       // turn weapon arena off
+       M_ARGV(0, string) = "off";
+}
+
 MUTATOR_HOOKFUNCTION(ok, BuildMutatorsString)
 {
        M_ARGV(0, string) = strcat(M_ARGV(0, string), ":OK");
index 123b8caa03fbd9876d16af1c140b0a59479504fe..e4b784371525776b05566d4cb521902701dcb8e0 100644 (file)
@@ -1,10 +1,13 @@
 #include "sv_spawn_near_teammate.qh"
 
+const float FLOAT_MAX = 340282346638528859811704183484516925440.0f;
+
 float autocvar_g_spawn_near_teammate_distance;
 int autocvar_g_spawn_near_teammate_ignore_spawnpoint;
+int autocvar_g_spawn_near_teammate_ignore_spawnpoint_max;
 float autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay;
 float autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death;
-int autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health;
+bool autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health;
 bool autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath;
 
 REGISTER_MUTATOR(spawn_near_teammate, cvar("g_spawn_near_teammate"));
@@ -12,7 +15,6 @@ REGISTER_MUTATOR(spawn_near_teammate, cvar("g_spawn_near_teammate"));
 .entity msnt_lookat;
 
 .float msnt_timer;
-.vector msnt_deathloc;
 
 .float cvar_cl_spawn_near_teammate;
 
@@ -80,86 +82,124 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn)
                        player.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death;
 
                entity best_mate = NULL;
-               vector best_spot = '0 0 0';
-               float pc = 0, best_dist = 0, dist = 0;
-               FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
-                       if((autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health >= 0 && it.health >= autocvar_g_balance_health_regenstable) || autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health == 0)
-                       if(!IS_DEAD(it))
-                       if(it.msnt_timer < time)
-                       if(SAME_TEAM(player, it))
-                       if(time > it.spawnshieldtime) // spawn shielding
-                       if(!forbidWeaponUse(it))
-                       if(STAT(FROZEN, it) == 0)
-                       if(it != player)
+               vector best_pos = '0 0 0';
+               float best_dist2 = FLOAT_MAX;
+               int tested = 0;
+               FOREACH_CLIENT_RANDOM(IS_PLAYER(it), LAMBDA(
+                       if (autocvar_g_spawn_near_teammate_ignore_spawnpoint_max && tested >= autocvar_g_spawn_near_teammate_ignore_spawnpoint_max) break;
+                       if (!SAME_TEAM(player, it)) continue;
+                       if (autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health && it.health < autocvar_g_balance_health_regenstable) continue;
+                       if (IS_DEAD(it)) continue;
+                       if (time < it.msnt_timer) continue;
+                       if (time < it.spawnshieldtime) continue;
+                       if (forbidWeaponUse(it)) continue;
+                       if (it == player) continue;
+
+                       tested++; // i consider a teammate to be available when he passes the checks above
+
+                       vector horiz_vel = vec2(it.velocity);
+                       // when walking slowly sideways, we assume the player wants a clear shot ahead - spawn behind him according to where he's looking
+                       // when running fast, spawn behind him according to his direction of movement to prevent colliding with the newly spawned player
+                       if (vdist(horiz_vel, >, autocvar_sv_maxspeed + 50))
+                               fixedmakevectors(vectoangles(horiz_vel));
+                       else
+                               fixedmakevectors(it.angles); // .angles is the angle of the model - usually/always 0 pitch
+
+                       // test different spots close to mate - trace upwards so it works on uneven surfaces
+                       // don't spawn in front of player or directly behind to avoid players shooting each other
+                       // test the potential spots in pairs (first pair is better than second and so on) but don't prefer one side
+                       RandomSelection_Init();
+                       for(int i = 0; i < 6; ++i)
                        {
-                               tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - '0 0 100', MOVE_NOMONSTERS, it);
-                               if(trace_fraction != 1.0)
-                               if(!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY))
+                               switch(i)
                                {
-                                       pc = pointcontents(trace_endpos + '0 0 1');
-                                       if(pc == CONTENT_EMPTY)
+                                       case 0:
+                                               tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 64 + v_right * 128 + v_up * 64, MOVE_NOMONSTERS, it);
+                                               break;
+                                       case 1:
+                                               tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 64 - v_right * 128 + v_up * 64, MOVE_NOMONSTERS, it);
+                                               break;
+                                       case 2:
+                                               tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 192 + v_up * 64, MOVE_NOMONSTERS, it);
+                                               break;
+                                       case 3:
+                                               tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_right * 192 + v_up * 64, MOVE_NOMONSTERS, it);
+                                               break;
+                                       case 4:
+                                               tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 128 + v_right * 64 + v_up * 64, MOVE_NOMONSTERS, it);
+                                               break;
+                                       case 5:
+                                               tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 128 - v_right * 64 + v_up * 64, MOVE_NOMONSTERS, it);
+                                               break;
+                               }
+
+                               vector horizontal_trace_endpos = trace_endpos;
+                               //te_lightning1(NULL, it.origin, horizontal_trace_endpos);
+                               if (trace_fraction != 1.0) goto skip;
+
+                               // 400 is about the height of a typical laser jump (in overkill)
+                               // not traceline because we need space for the whole player, not just his origin
+                               tracebox(horizontal_trace_endpos, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), horizontal_trace_endpos - '0 0 400', MOVE_NORMAL, it);
+                               vector vectical_trace_endpos = trace_endpos;
+                               //te_lightning1(NULL, horizontal_trace_endpos, vectical_trace_endpos);
+                               if (trace_startsolid) goto skip; // inside another player
+                               if (trace_fraction == 1.0) goto skip; // above void or too high
+                               if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY) goto skip;
+                               if (pointcontents(vectical_trace_endpos) != CONTENT_EMPTY) goto skip; // no lava or slime (or water which i assume would be annoying anyway)
+                               if (tracebox_hits_trigger_hurt(horizontal_trace_endpos, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), vectical_trace_endpos)) goto skip;
+
+                               // make sure the spawned player will have floor ahead (or at least a wall - he shouldn't fall as soon as he starts moving)
+                               vector floor_test_start = vectical_trace_endpos + v_up * STAT(PL_MAX, NULL).z + v_forward * STAT(PL_MAX, NULL).x; // top front of player's bbox - highest point we know is not inside solid
+                               traceline(floor_test_start, floor_test_start + v_forward * 100 - v_up * 128, MOVE_NOMONSTERS, it);
+                               //te_beam(NULL, floor_test_start, trace_endpos);
+                               if (trace_fraction == 1.0) goto skip;
+
+                               if (autocvar_g_nades) {
+                                       bool nade_in_range = false;
+                                       IL_EACH(g_projectiles, it.classname == "nade",
                                        {
-                                               if(vdist(it.velocity, >, 5))
-                                                       fixedmakevectors(vectoangles(it.velocity));
-                                               else
-                                                       fixedmakevectors(it.angles);
+                                               if (vdist(it.origin - vectical_trace_endpos, <, autocvar_g_nades_nade_radius)) {
+                                                       nade_in_range = true;
+                                                       goto skip;
+                                               }
+                                       });
+                                       if (nade_in_range) goto skip;
+                               }
+
+                               // here, we know we found a good spot
+                               RandomSelection_Add(it, 0, string_null, vectical_trace_endpos, 1, 1);
+                               //te_lightning1(NULL, vectical_trace_endpos, vectical_trace_endpos + v_forward * 10);
 
-                                               for(pc = 0; pc < 4; ++pc) // test 4 diffrent spots close to mate
+LABEL(skip)
+                               if (i % 2 == 1 && RandomSelection_chosen_ent)
+                               {
+                                       if (autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath)
+                                       {
+                                               float dist2 = vlen2(RandomSelection_chosen_ent.origin - player.death_origin);
+                                               if (dist2 < best_dist2)
                                                {
-                                                       switch(pc)
-                                                       {
-                                                               case 0:
-                                                                       tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 128, MOVE_NOMONSTERS, it);
-                                                                       break;
-                                                               case 1:
-                                                                       tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_right * 128 , MOVE_NOMONSTERS, it);
-                                                                       break;
-                                                               case 2:
-                                                                       tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 128 - v_forward * 64, MOVE_NOMONSTERS, it);
-                                                                       break;
-                                                               case 3:
-                                                                       tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_right * 128 - v_forward * 64, MOVE_NOMONSTERS, it);
-                                                                       break;
-                                                               //case 4:
-                                                                       //tracebox(it.origin , STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 128, MOVE_NOMONSTERS, it);
-                                                                       //break;
-                                                       }
-
-                                                       if(trace_fraction == 1.0)
-                                                       {
-                                                               traceline(trace_endpos + '0 0 4', trace_endpos - '0 0 100', MOVE_NOMONSTERS, it);
-                                                               if(trace_fraction != 1.0)
-                                                               {
-                                                                       if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath)
-                                                                       {
-                                                                               dist = vlen(trace_endpos - player.msnt_deathloc);
-                                                                               if(dist < best_dist || best_dist == 0)
-                                                                               {
-                                                                                       best_dist = dist;
-                                                                                       best_spot = trace_endpos;
-                                                                                       best_mate = it;
-                                                                               }
-                                                                       }
-                                                                       else
-                                                                       {
-                                                                               setorigin(player, trace_endpos);
-                                                                               player.angles = it.angles;
-                                                                               player.angles_z = 0; // never spawn tilted even if the spot says to
-                                                                               it.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay;
-                                                                               return;
-                                                                       }
-                                                               }
-                                                       }
+                                                       best_dist2 = dist2;
+                                                       best_pos = RandomSelection_chosen_vec;
+                                                       best_mate = RandomSelection_chosen_ent;
                                                }
                                        }
+                                       else
+                                       {
+                                               setorigin(player, RandomSelection_chosen_vec);
+                                               player.angles = RandomSelection_chosen_ent.angles;
+                                               player.angles_z = 0; // never spawn tilted even if the spot says to
+                                               RandomSelection_chosen_ent.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay;
+                                               return;
+                                       }
+                                       break; // don't test the other spots near this teammate, go to the next one
                                }
                        }
                ));
 
                if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath)
-               if(best_dist)
+               if(best_mate)
                {
-                       setorigin(player, best_spot);
+                       setorigin(player, best_pos);
                        player.angles = best_mate.angles;
                        player.angles_z = 0; // never spawn tilted even if the spot says to
                        best_mate.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay;
@@ -178,11 +218,4 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn)
        }
 }
 
-MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerDies)
-{
-       entity frag_target = M_ARGV(0, entity);
-
-       frag_target.msnt_deathloc = frag_target.origin;
-}
-
 REPLICATE(cvar_cl_spawn_near_teammate, bool, "cl_spawn_near_teammate");
index dd9eaac860a5efe24dc0f7d09b71569b356f5fc2..2e4356bab3214d5f124150e20975ee14056e0126 100644 (file)
@@ -1,5 +1,6 @@
 #include "train.qh"
 .float train_wait_turning;
+.entity future_target;
 void train_next(entity this);
 #ifdef SVQC
 void train_use(entity this, entity actor, entity trigger);
@@ -14,7 +15,7 @@ void train_wait(entity this)
        {
                entity targ, cp;
                vector ang;
-               targ = find(NULL, targetname, this.target);
+               targ = this.future_target;
                if((this.spawnflags & 1) && targ.curvetarget)
                        cp = find(NULL, targetname, targ.curvetarget);
                else
@@ -41,7 +42,7 @@ void train_wait(entity this)
 #endif
 
 #ifdef SVQC
-       entity tg = find(NULL, targetname, this.target);
+       entity tg = this.future_target;
        if(tg.spawnflags & 4)
        {
                this.use = train_use;
@@ -62,13 +63,34 @@ void train_wait(entity this)
        }
 }
 
+entity train_next_find(entity this)
+{
+       if(this.target_random)
+       {
+               RandomSelection_Init();
+               for(entity t = NULL; (t = find(t, targetname, this.target));)
+               {
+                       RandomSelection_AddEnt(t, 1, 0);
+               }
+               return RandomSelection_chosen_ent;
+       }
+       else
+       {
+               return find(NULL, targetname, this.target);
+       }
+}
+
 void train_next(entity this)
 {
-       entity targ, cp = NULL;
+       entity targ = NULL, cp = NULL;
        vector cp_org = '0 0 0';
 
-       targ = find(NULL, targetname, this.target);
+       targ = this.future_target;
+
        this.target = targ.target;
+       this.target_random = targ.target_random;
+       this.future_target = train_next_find(targ);
+
        if (this.spawnflags & 1)
        {
                if(targ.curvetarget)
@@ -186,9 +208,11 @@ void train_use(entity this, entity actor, entity trigger)
 
 void func_train_find(entity this)
 {
-       entity targ;
-       targ = find(NULL, targetname, this.target);
+       entity targ = train_next_find(this);
        this.target = targ.target;
+       this.target_random = targ.target_random;
+       // save the future target for later
+       this.future_target = train_next_find(targ);
        if (this.target == "")
                objerror(this, "func_train_find: no next target");
        SUB_SETORIGIN(this, targ.origin - this.view_ofs);
index 7b5f23b694ba6991ebf52b1512376d227345188e..187d08068e9342bd5471fb81a3e04a1e1b0f35d6 100644 (file)
@@ -3,7 +3,7 @@
 #include "rootdialog.qh"
 CLASS(XonoticUid2NameDialog, XonoticRootDialog)
        METHOD(XonoticUid2NameDialog, fill, void(entity));
-       ATTRIB(XonoticUid2NameDialog, title, string);
+       ATTRIB(XonoticUid2NameDialog, title, string, "");
        ATTRIB(XonoticUid2NameDialog, color, vector, SKINCOLOR_DIALOG_TEAMSELECT);
        ATTRIB(XonoticUid2NameDialog, intendedWidth, float, 0.5);
        ATTRIB(XonoticUid2NameDialog, rows, float, 4);
index 50c766e69051527be55929f7b4524c22ab228f14..e45abfda33b528cce9e9e72035dd4ab1807d47c5 100644 (file)
@@ -154,8 +154,8 @@ int category_draw_count;
        SLIST_CATEGORY(CAT_SERVERS,      "CAT_NORMAL",  "CAT_SERVERS",  CTX(_("SLCAT^Servers"))) \
        SLIST_CATEGORY(CAT_XPM,          "CAT_NORMAL",  "CAT_SERVERS",  CTX(_("SLCAT^Competitive Mode"))) \
        SLIST_CATEGORY(CAT_MODIFIED,     "",            "CAT_SERVERS",  CTX(_("SLCAT^Modified Servers"))) \
-       SLIST_CATEGORY(CAT_OVERKILL,     "",            "CAT_SERVERS",  CTX(_("SLCAT^Overkill Mode"))) \
-       SLIST_CATEGORY(CAT_INSTAGIB,     "",            "CAT_SERVERS",  CTX(_("SLCAT^InstaGib Mode"))) \
+       SLIST_CATEGORY(CAT_OVERKILL,     "",            "CAT_SERVERS",  CTX(_("SLCAT^Overkill"))) \
+       SLIST_CATEGORY(CAT_INSTAGIB,     "",            "CAT_SERVERS",  CTX(_("SLCAT^InstaGib"))) \
        SLIST_CATEGORY(CAT_DEFRAG,       "",            "CAT_SERVERS",  CTX(_("SLCAT^Defrag Mode")))
 
 #define SLIST_CATEGORY_AUTOCVAR(name) autocvar_menu_slist_categories_##name##_override
index ed3083a1203fd94c69943efb17341c80c45127d1..1fabe4d0f965aa9abd6b564b180ad4e83637a96d 100644 (file)
@@ -43,6 +43,37 @@ const string STR_OBSERVER = "observer";
 
 #define FOREACH_CLIENT(cond, body) FOREACH_CLIENTSLOT(IS_CLIENT(it) && (cond), body)
 
+// using the "inside out" version of knuth-fisher-yates shuffle
+// https://en.wikipedia.org/wiki/Fisher–Yates_shuffle
+entity _FCR_clients[255];
+bool _FCR_entered = false;
+#define FOREACH_CLIENT_RANDOM(cond, body) \
+       MACRO_BEGIN { \
+               if (_FCR_entered) LOG_FATAL("FOREACH_CLIENT_RANDOM must not be nested"); \
+               _FCR_entered = true; \
+               int _cnt = 0; \
+               FOREACH_CLIENT(cond, LAMBDA( \
+                       int _j = floor(random() * (_cnt + 1)); \
+                       if (_j == _cnt) \
+                       { \
+                               _FCR_clients[_cnt] = it; \
+                       } \
+                       else \
+                       { \
+                               _FCR_clients[_cnt] = _FCR_clients[_j]; \
+                               _FCR_clients[_j] = it; \
+                       } \
+                       _cnt++; \
+               )); \
+               for (int _i = 0; _i < _cnt; ++_i) \
+               { \
+                       const noref int i = _i; \
+                       ITER_CONST noref entity it = _FCR_clients[i]; \
+                       if (cond) { LAMBDA(body) } \
+               } \
+               _FCR_entered = false; \
+       } MACRO_END
+
 // NOTE: FOR_EACH_MONSTER deprecated! Use the following instead: IL_EACH(g_monsters, true, { code; });
 
 #include <common/effects/all.qh>
index 3135d4e3d3d629a43b1d3f4c8ca68167bccf1d83..5276a64e9392f579c9cf9fe1096d1b531cfc6e0a 100644 (file)
@@ -361,6 +361,7 @@ MUTATOR_HOOKABLE(PlayerDamage_Calculate, EV_PlayerDamage_Calculate);
     /** armor     */ i(float,    MUTATOR_ARGV_3_float) \
     /** location  */ i(vector, MUTATOR_ARGV_4_vector) \
     /** deathtype */ i(int,    MUTATOR_ARGV_5_int) \
+    /** potential_damage     */ i(float,    MUTATOR_ARGV_6_float) \
     /**/
 MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged);
 
index f466c4dde1cd996030227084cb06b78df89bab7c..4a4d1301f58c25aa4f9220ca81c17c717f55b0f8 100644 (file)
@@ -511,9 +511,9 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
        {
                WeaponStats_LogDamage(awep.m_id, abot, this.(weaponentity).m_weapon.m_id, vbot, dh + da);
        }
-       if (dh + da)
+       if (damage)
        {
-               MUTATOR_CALLHOOK(PlayerDamaged, attacker, this, dh, da, hitloc, deathtype);
+               MUTATOR_CALLHOOK(PlayerDamaged, attacker, this, dh, da, hitloc, deathtype, damage);
        }
 
        if (this.health < 1)