]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/player.qc
Merge branch 'master' into Mario/wepent_experimental
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / player.qc
index 9125b50d7cab1969108371ed2bd744194387495f..0454731aeb5bc081ab6f83762f31cc0372902f21 100644 (file)
@@ -24,6 +24,7 @@
 #include "../common/effects/qc/all.qh"
 #include "../common/mutators/mutator/waypoints/waypointsprites.qh"
 #include "../common/triggers/include.qh"
+#include "../common/wepent.qh"
 
 #include "weapons/weaponstats.qh"
 
@@ -485,6 +486,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
 
        valid_damage_for_weaponstats = 0;
        Weapon awep = WEP_Null;
+       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
 
        if(vbot || IS_REAL_CLIENT(this))
        if(abot || IS_REAL_CLIENT(attacker))
@@ -492,7 +494,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
        if(DIFF_TEAM(this, attacker))
        {
                if(DEATH_ISSPECIAL(deathtype))
-                       awep = PS(attacker).m_weapon;
+                       awep = attacker.(weaponentity).m_weapon;
                else
                        awep = DEATH_WEAPONOF(deathtype);
                valid_damage_for_weaponstats = 1;
@@ -502,7 +504,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
        da = da - max(this.armorvalue, 0);
        if(valid_damage_for_weaponstats)
        {
-               WeaponStats_LogDamage(awep.m_id, abot, PS(this).m_weapon.m_id, vbot, dh + da);
+               WeaponStats_LogDamage(awep.m_id, abot, this.(weaponentity).m_weapon.m_id, vbot, dh + da);
        }
        if (damage)
        {
@@ -521,7 +523,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
                }
 
                if(valid_damage_for_weaponstats)
-                       WeaponStats_LogKill(awep.m_id, abot, PS(this).m_weapon.m_id, vbot);
+                       WeaponStats_LogKill(awep.m_id, abot, this.(weaponentity).m_weapon.m_id, vbot);
 
                if(autocvar_sv_gentle < 1)
                if(sound_allowed(MSG_BROADCAST, attacker))
@@ -560,16 +562,14 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
                MUTATOR_CALLHOOK(PlayerDies, inflictor, attacker, this, deathtype, damage);
                excess = M_ARGV(4, float);
 
-               Weapon wep = PS(this).m_weapon;
-               /*for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               Weapon wep = this.(weaponentity).m_weapon;
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
-                       .entity weaponentity = weaponentities[slot];
-                       wep.wr_playerdeath(wep, this, weaponentity);
-               }*/
-               .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-               wep.wr_playerdeath(wep, this, weaponentity);
+                       .entity went = weaponentities[slot];
+                       wep.wr_playerdeath(wep, this, went);
+               }
 
-               RemoveGrapplingHook(this);
+               RemoveGrapplingHooks(this);
 
                Portal_ClearAllLater(this);
 
@@ -591,7 +591,11 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
                // clear waypoints
                WaypointSprite_PlayerDead(this);
                // throw a weapon
-               SpawnThrownWeapon(this, this.origin + (this.mins + this.maxs) * 0.5, PS(this).m_switchweapon.m_id);
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       .entity went = weaponentities[slot];
+                       SpawnThrownWeapon(this, this.origin + (this.mins + this.maxs) * 0.5, this.(went).m_switchweapon.m_id, went);
+               }
 
                // become fully visible
                this.alpha = default_player_alpha;
@@ -909,6 +913,9 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
                ret = 1;
        }
 
+       MUTATOR_CALLHOOK(ChatMessage, source, ret);
+       ret = M_ARGV(1, int);
+
        if(sourcemsgstr != "" && ret != 0)
        {
                if(ret < 0) // faked message, because the player is muted
@@ -920,16 +927,19 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
                else if(privatesay) // private message, between 2 people only
                {
                        sprint(source, sourcemsgstr);
-                       sprint(privatesay, msgstr);
                        if (!autocvar_g_chat_tellprivacy) { dedicated_print(msgstr); } // send to server console too if "tellprivacy" is disabled
-                       if(cmsgstr != "")
-                               centerprint(privatesay, cmsgstr);
+                       if(!MUTATOR_CALLHOOK(ChatMessageTo, privatesay, source))
+                       {
+                               sprint(privatesay, msgstr);
+                               if(cmsgstr != "")
+                                       centerprint(privatesay, cmsgstr);
+                       }
                }
                else if ( teamsay && source.active_minigame )
                {
                        sprint(source, sourcemsgstr);
                        dedicated_print(msgstr); // send to server console too
-                       FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source && it.active_minigame == source.active_minigame, sprint(it, msgstr));
+                       FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source && it.active_minigame == source.active_minigame && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), sprint(it, msgstr));
                }
                else if(teamsay > 0) // team message, only sent to team mates
                {
@@ -937,7 +947,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
                        dedicated_print(msgstr); // send to server console too
                        if(sourcecmsgstr != "")
                                centerprint(source, sourcecmsgstr);
-                       FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it != source && it.team == source.team, {
+                       FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && it != source && it.team == source.team && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), {
                                sprint(it, msgstr);
                                if(cmsgstr != "")
                                        centerprint(it, cmsgstr);
@@ -947,7 +957,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
                {
                        sprint(source, sourcemsgstr);
                        dedicated_print(msgstr); // send to server console too
-                       FOREACH_CLIENT(!IS_PLAYER(it) && IS_REAL_CLIENT(it) && it != source, sprint(it, msgstr));
+                       FOREACH_CLIENT(!IS_PLAYER(it) && IS_REAL_CLIENT(it) && it != source && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), sprint(it, msgstr));
                }
                else
                {
@@ -956,7 +966,7 @@ int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodc
                 dedicated_print(msgstr); // send to server console too
                 MX_Say(strcat(playername(source), "^7: ", msgin));
             }
-            FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source, sprint(it, msgstr));
+            FOREACH_CLIENT(IS_REAL_CLIENT(it) && it != source && !MUTATOR_CALLHOOK(ChatMessageTo, it, source), sprint(it, msgstr));
         }
        }