]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/ca_bots_fix
authorterencehill <piuntn@gmail.com>
Fri, 11 Nov 2016 18:14:55 +0000 (19:14 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 11 Nov 2016 18:14:55 +0000 (19:14 +0100)
23 files changed:
defaultXonotic.cfg
mutators.cfg
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/shownames.qc
qcsrc/common/ent_cs.qc
qcsrc/common/ent_cs.qh
qcsrc/common/items/item.qh
qcsrc/common/items/item/powerup.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/nix/sv_nix.qc
qcsrc/common/mutators/mutator/overkill/sv_overkill.qc
qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc
qcsrc/common/t_items.qc
qcsrc/common/t_items.qh
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 5df6d59bb47423025b8a9eb9f089d284ea012e1d..3f3cf443514fd2382b2722cda894d290da501b0f 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}: full damage not capped to target's health, {potential_health}: health damage not capped to target's health, {health(ph)}: shows potential_health too if different from health, {total(p)}: shows potential too if different from total"
 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"
@@ -795,7 +795,7 @@ seta cl_damagetext_accumulate_alpha_rel "0.65" "Only update existing damage text
 seta cl_damagetext_friendlyfire "1" "Show damage text for friendlyfire too"
 seta cl_damagetext_friendlyfire_color "1 0 0" "Damage text color for friendlyfire"
 
-set sv_itemstime 1 "enable networking of left time until respawn for items such as mega health and large armor"
+set sv_itemstime 1 "enable networking of time left until respawn for items such as mega health/armor and powerups"
 
 // so it can be stuffcmd-ed still
 set cl_gravity 800     "but ignored anyway"
index 2188f80070834fc6b34ae7deef98256e6c73fda9..b5e9b76df68c7dcc9a962a191b19fe54b63a997e 100644 (file)
@@ -125,8 +125,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"
 
@@ -436,4 +437,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 a89e84a03725d7f8ff16525ef81faa52e9d81d49..da53f68a0f15d52a06d7522566fe062a4047ad4c 100644 (file)
@@ -175,33 +175,26 @@ MACRO_END
        {
                int n = ReadByte();
                entity e = entcs_receiver(n);
-               #define X(e) { \
-                       setthink(e, entcs_think); \
-                       entcs_receiver(n, e); \
-               }
                if (e == NULL)
                {
                        if (!this)
-                       {
                                // initial = temp
                                e = new_pure(entcs_receiver);
-                               X(e);
-                       }
                        else
-                       {
                                // initial = linked
                                e = this;
-                               X(e);
-                       }
+                       setthink(e, entcs_think);
+                       entcs_receiver(n, e);
                }
                else if (e != this && this)
                {
                        // upgrade to linked
                        delete(e);
                        e = this;
-                       X(e);
+                       setthink(e, entcs_think);
+                       entcs_receiver(n, e);
                }
-               #undef X
+
                InterpolateOrigin_Undo(e);
                e.sv_entnum = n;
                int sf = ReadShort();
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 e46df6b3c31d8374ff0b5fc8084c84e78a5c1d64..bac127059daa12c6db32695d90aea95cf22f28ff 100644 (file)
@@ -1,4 +1,5 @@
 #pragma once
+#include <common/t_items.qh>
 
 const int IT_UNLIMITED_WEAPON_AMMO             =  BIT(0); // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup.
 const int IT_UNLIMITED_SUPERWEAPONS            =  BIT(1); // when this bit is set, superweapons don't expire. Checkpoints can give this powerup.
@@ -45,6 +46,10 @@ CLASS(GameItem, Object)
     ATTRIB(GameItem, m_color, vector, '1 1 1');
     ATTRIB(GameItem, m_waypoint, string);
     ATTRIB(GameItem, m_waypointblink, int, 1);
+#ifdef GAMEQC
+    ATTRIB(GameItem, m_glow, bool, false);
+    ATTRIB(GameItem, m_respawnsound, Sound, SND_ITEMRESPAWN);
+#endif
     METHOD(GameItem, display, void(GameItem this, void(string name, string icon) returns))
     {
         TC(GameItem, this);
index 002be54f805a91dc9b7d56e355a695f60d589b08..26d649d7adeb1a7f0a14e473205e00953fd4dd29 100644 (file)
@@ -26,6 +26,8 @@ REGISTER_ITEM(Strength, Powerup) {
 #ifdef GAMEQC
     this.m_model            =   MDL_Strength_ITEM;
     this.m_sound            =   SND_Strength;
+    this.m_glow             =   true;
+    this.m_respawnsound     =   SND_STRENGTH_RESPAWN;
 #endif
     this.m_name             =   "Strength Powerup";
     this.m_icon             =   "strength";
@@ -44,6 +46,8 @@ REGISTER_ITEM(Shield, Powerup) {
 #ifdef GAMEQC
     this.m_model            =   MDL_Shield_ITEM;
     this.m_sound            =   SND_Shield;
+    this.m_glow             =   true;
+    this.m_respawnsound     =   SND_SHIELD_RESPAWN;
 #endif
     this.m_name             =   "Shield";
     this.m_icon             =   "shield";
index e55b9fcd91527f8b4b82d5a831303c27cf3a6e77..b95cabb6ab7bfc0cc8d9debc9877660c08407dfa 100644 (file)
@@ -3,12 +3,19 @@
 #define DAMAGETEXT_PRECISION_MULTIPLIER 128
 #define DAMAGETEXT_SHORT_LIMIT 256 // the smallest value that we can't send as short - 2^15 (signed short) / DAMAGETEXT_PRECISION_MULTIPLIER
 
+const int DTFLAG_SAMETEAM = BIT(0);
+const int DTFLAG_BIG_HEALTH = BIT(1);
+const int DTFLAG_BIG_ARMOR = BIT(2);
+const int DTFLAG_BIG_POTENTIAL = BIT(3);
+const int DTFLAG_NO_ARMOR = BIT(4);
+const int DTFLAG_NO_POTENTIAL = BIT(5);
+
 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}: full damage not capped to target's health, {potential_health}: health damage not capped to target's health, {health(ph)}: shows potential_health too if different from health, {total(p)}: shows potential too if different from total");
 STATIC_INIT(DamageText_LegacyFormat) {
     if (strstrofs(autocvar_cl_damagetext_format, "{", 0) < 0) autocvar_cl_damagetext_format = "-{total}";
 }
@@ -37,6 +44,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);
 
@@ -60,28 +68,47 @@ CLASS(DamageText, Object)
                 Weapon w = DEATH_WEAPONOF(this.m_deathtype);
                 if (w != WEP_Null) rgb = w.wpcolor;
             }
+            int health = rint(this.m_damage / DAMAGETEXT_PRECISION_MULTIPLIER);
+            int total = rint((this.m_damage + this.m_armordamage) / DAMAGETEXT_PRECISION_MULTIPLIER);
+            int potential = rint(this.m_potential_damage / DAMAGETEXT_PRECISION_MULTIPLIER);
+            int potential_health = rint((this.m_potential_damage - this.m_armordamage) / DAMAGETEXT_PRECISION_MULTIPLIER);
+
             string s = autocvar_cl_damagetext_format;
-            s = strreplace("{health}", sprintf("%d", rint(this.m_damage / DAMAGETEXT_PRECISION_MULTIPLIER)), s);
+            s = strreplace("{health}", sprintf("%d", health), 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("{total}",  sprintf("%d", total), s);
+            s = strreplace("{potential}",  sprintf("%d", potential), s);
+            s = strreplace("{potential_health}",  sprintf("%d", potential_health), s);
+
+            s = strreplace("{health(ph)}", (
+                               (health == potential_health)
+                               ? sprintf("%d",      health)
+                               : sprintf("%d (%d)", health, potential_health)
+               ), s);
+            s = strreplace("{total(p)}", (
+                               (total == potential)
+                               ? sprintf("%d",      total)
+                               : sprintf("%d (%d)", total, potential)
+               ), 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 +129,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 (
@@ -110,9 +138,13 @@ MUTATOR_HOOKFUNCTION(damagetext, PlayerDamaged) {
             (SV_DAMAGETEXT_SPECTATORS_ONLY() && IS_SPEC(it) && it.enemy == attacker) ||
             (SV_DAMAGETEXT_SPECTATORS_ONLY() && IS_OBSERVER(it))
         ) {
-            int flags = SAME_TEAM(hit, attacker); // BIT(0)
-            if (health >= DAMAGETEXT_SHORT_LIMIT) flags |= BIT(1);
-            if (armor >= DAMAGETEXT_SHORT_LIMIT) flags |= BIT(2);
+            int flags = 0;
+            if (SAME_TEAM(hit, attacker)) flags |= DTFLAG_SAMETEAM;
+            if (health >= DAMAGETEXT_SHORT_LIMIT) flags |= DTFLAG_BIG_HEALTH;
+            if (armor >= DAMAGETEXT_SHORT_LIMIT) flags |= DTFLAG_BIG_ARMOR;
+            if (potential_damage >= DAMAGETEXT_SHORT_LIMIT) flags |= DTFLAG_BIG_POTENTIAL;
+            if (!armor) flags |= DTFLAG_NO_ARMOR;
+            if (fabs((armor + health) - potential_damage) < 0.0001) flags |= DTFLAG_NO_POTENTIAL;
 
             msg_entity = it;
             WriteHeader(MSG_ONE, damagetext);
@@ -126,10 +158,18 @@ MUTATOR_HOOKFUNCTION(damagetext, PlayerDamaged) {
             // we need to send a few decimal places to minimize errors when accumulating damage
             // sending them multiplied saves bandwidth compared to using WriteCoord,
             // however if the multiplied damage would be too much for (signed) short, we send an int24
-            if (health >= DAMAGETEXT_SHORT_LIMIT) WriteInt24_t(MSG_ONE, health * DAMAGETEXT_PRECISION_MULTIPLIER);
+            if (flags & DTFLAG_BIG_HEALTH) WriteInt24_t(MSG_ONE, health * DAMAGETEXT_PRECISION_MULTIPLIER);
             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 (!(flags & DTFLAG_NO_ARMOR))
+            {
+                if (flags & DTFLAG_BIG_ARMOR) WriteInt24_t(MSG_ONE, armor * DAMAGETEXT_PRECISION_MULTIPLIER);
+                else WriteShort(MSG_ONE, armor * DAMAGETEXT_PRECISION_MULTIPLIER);
+            }
+            if (!(flags & DTFLAG_NO_POTENTIAL))
+            {
+                if (flags & DTFLAG_BIG_POTENTIAL) WriteInt24_t(MSG_ONE, potential_damage * DAMAGETEXT_PRECISION_MULTIPLIER);
+                else WriteShort(MSG_ONE, potential_damage * DAMAGETEXT_PRECISION_MULTIPLIER);
+                       }
         }
     ));
 }
@@ -142,13 +182,17 @@ NET_HANDLE(damagetext, bool isNew)
     vector location = vec3(ReadCoord(), ReadCoord(), ReadCoord());
     int deathtype = ReadInt24_t();
     int flags = ReadByte();
-    bool friendlyfire = flags & 1;
+    bool friendlyfire = flags & DTFLAG_SAMETEAM;
 
-    int health, armor;
-    if (flags & BIT(1)) health = ReadInt24_t();
+    int health, armor, potential_damage;
+    if (flags & DTFLAG_BIG_HEALTH) health = ReadInt24_t();
     else health = ReadShort();
-    if (flags & BIT(2)) armor = ReadInt24_t();
+    if (flags & DTFLAG_NO_ARMOR) armor = 0;
+    else if (flags & DTFLAG_BIG_ARMOR) armor = ReadInt24_t();
     else armor = ReadShort();
+    if (flags & DTFLAG_NO_POTENTIAL) potential_damage = health + armor;
+    else if (flags & DTFLAG_BIG_POTENTIAL) potential_damage = ReadInt24_t();
+    else potential_damage = ReadShort();
 
     return = true;
     if (autocvar_cl_damagetext) {
@@ -158,12 +202,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 +251,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..a542921221a6a37bc7bddf4bb485f26fdcbd8d08 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;
@@ -17,10 +23,10 @@ MUTATOR_HOOKFUNCTION(melee_only, FilterItem)
 {
        entity item = M_ARGV(0, entity);
 
-       switch (item.items)
+       switch (item.itemdef)
        {
-               case ITEM_HealthSmall.m_itemid:
-               case ITEM_ArmorSmall.m_itemid:
+               case ITEM_HealthSmall:
+               case ITEM_ArmorSmall:
                        return false;
        }
 
index 0d804a91427374c74219435695f929a56e84a25f..6ec9c23213f132f95e95993202b74494422f3ce2 100644 (file)
@@ -1174,18 +1174,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;
@@ -1227,6 +1215,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 39072cefc7d2ba0ab9697a9f3a104599b2a40dc9..143b3c6edf63200089fd825c41508f636a18905a 100644 (file)
@@ -232,24 +232,13 @@ MUTATOR_HOOKFUNCTION(nix, FilterItem)
 {
        entity item = M_ARGV(0, entity);
 
-       switch (item.items)
+       if(item.itemdef.instanceOfHealth || item.itemdef.instanceOfArmor)
        {
-               case ITEM_HealthSmall.m_itemid:
-               case ITEM_HealthMedium.m_itemid:
-               case ITEM_HealthLarge.m_itemid:
-               case ITEM_HealthMega.m_itemid:
-               case ITEM_ArmorSmall.m_itemid:
-               case ITEM_ArmorMedium.m_itemid:
-               case ITEM_ArmorLarge.m_itemid:
-               case ITEM_ArmorMega.m_itemid:
-                       if (autocvar_g_nix_with_healtharmor)
-                               return false;
-                       break;
-               case ITEM_Strength.m_itemid:
-               case ITEM_Shield.m_itemid:
-                       if (autocvar_g_nix_with_powerups)
-                               return false;
-                       break;
+               return !autocvar_g_nix_with_healtharmor;
+       }
+       else if(item.itemdef.instanceOfPowerup)
+       {
+               return !autocvar_g_nix_with_powerups;
        }
 
        return true; // delete all other items
index d47da6c3c38ed43c3949eed8042f94941d8beef9..21a191a0e67c82b080d962ec034fa668fa997324 100644 (file)
@@ -341,6 +341,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 7424d695aa041cf2eb557576d209df327ae60a77..3a7aea729e945ae59ac1c6c6f5e5104b15c2eb47 100644 (file)
@@ -183,7 +183,7 @@ NET_HANDLE(ENT_CLIENT_ITEM, bool isnew)
             if(this.ItemStatus & ITS_ALLOWFB)
                 this.effects |= EF_FULLBRIGHT;
 
-        if(this.ItemStatus & ITS_POWERUP)
+        if(this.ItemStatus & ITS_GLOW)
         {
             if(this.ItemStatus & ITS_AVAILABLE)
                 this.effects |= (EF_ADDITIVE | EF_FULLBRIGHT);
@@ -423,6 +423,7 @@ void Item_Show (entity e, float mode)
 {
        e.effects &= ~(EF_ADDITIVE | EF_STARDUST | EF_FULLBRIGHT | EF_NODEPTHTEST);
        e.ItemStatus &= ~ITS_STAYWEP;
+       entity def = e.itemdef;
        if (mode > 0)
        {
                // make the item look normal, and be touchable
@@ -440,7 +441,6 @@ void Item_Show (entity e, float mode)
                e.ItemStatus &= ~ITS_AVAILABLE;
        }
        else {
-       entity def = e.itemdef;
        bool nostay = def.instanceOfWeaponPickup ? !!(def.m_weapon.weapons & WEPSET_SUPERWEAPONS) : false // no weapon-stay on superweapons
                || e.team // weapon stay isn't supported for teamed weapons
                ;
@@ -463,8 +463,8 @@ void Item_Show (entity e, float mode)
                e.ItemStatus &= ~ITS_AVAILABLE;
        }}
 
-       if (e.items & ITEM_Strength.m_itemid || e.items & ITEM_Shield.m_itemid)
-               e.ItemStatus |= ITS_POWERUP;
+       if (def.m_glow)
+               e.ItemStatus |= ITS_GLOW;
 
        if (autocvar_g_nodepthtestitems)
                e.effects |= EF_NODEPTHTEST;
@@ -497,13 +497,7 @@ void Item_ItemsTime_SetTimesForAllPlayers();
 void Item_Respawn (entity this)
 {
        Item_Show(this, 1);
-       // this is ugly...
-       if(this.items == ITEM_Strength.m_itemid)
-               sound (this, CH_TRIGGER, SND_STRENGTH_RESPAWN, VOL_BASE, ATTEN_NORM);   // play respawn sound
-       else if(this.items == ITEM_Shield.m_itemid)
-               sound (this, CH_TRIGGER, SND_SHIELD_RESPAWN, VOL_BASE, ATTEN_NORM);     // play respawn sound
-       else
-               sound (this, CH_TRIGGER, SND_ITEMRESPAWN, VOL_BASE, ATTEN_NORM);        // play respawn sound
+       sound(this, CH_TRIGGER, this.itemdef.m_respawnsound, VOL_BASE, ATTEN_NORM);     // play respawn sound
        setorigin(this, this.origin);
 
     if (Item_ItemsTime_Allow(this.itemdef) || this.weapons & WEPSET_SUPERWEAPONS)
index 06e14555ed0aca53537f9c2143ceabfc96b5b2b7..f2308c35767756933f7c9c49be74e3668d79a2f5 100644 (file)
@@ -12,7 +12,7 @@ const int ISF_STATUS                  = BIT(3);
     const int ITS_AVAILABLE        = BIT(3);
     const int ITS_ALLOWFB                  = BIT(4);
     const int ITS_ALLOWSI                  = BIT(5);
-    const int ITS_POWERUP                  = BIT(6);
+    const int ITS_GLOW                     = BIT(6);
 const int ISF_COLORMAP                         = BIT(4);
 const int ISF_DROP                             = BIT(5);
 const int ISF_ANGLES                   = BIT(6);
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 9d7d8af916e5d621230698b9accc6b2d1d840bae..21c8ef9a5c114e92b0650f4ca5b6ec251a14d3a5 100644 (file)
@@ -359,6 +359,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 77eae0aa20c516594e1e5b71c43f637468a83a2b..904447c218418c936f5f933cce7cf13062813c61 100644 (file)
@@ -509,9 +509,9 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
        {
                WeaponStats_LogDamage(awep.m_id, abot, PS(this).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)