]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/damage.qc
Merge branch 'master' into z411/bai-server
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / damage.qc
index 8b77c8b14af755f290c0e4ae83e01984a938ad80..9d1fadc00f76b8915f787ebe24e9601c228613e9 100644 (file)
@@ -171,6 +171,7 @@ void Obituary_SpecialDeath(
 
 float Obituary_WeaponDeath(
        entity notif_target,
+       entity attacker,
        float murder,
        int deathtype,
        string s1, string s2, string s3,
@@ -203,6 +204,20 @@ float Obituary_WeaponDeath(
                        s1, s2, s3, "",
                        f1, f2, 0, 0
                );
+               
+               // z411 special medals
+               if(attacker) {
+                       switch(death_message) {
+                               case WEAPON_SHOTGUN_MURDER_SLAP:
+                                       if(!cvar("g_melee_only")) { // don't spam humiliation if we're in melee_only mode
+                                               Give_Medal(attacker, HUMILIATION);
+                                       }
+                                       break;
+                               case WEAPON_ELECTRO_MURDER_COMBO:
+                                       Give_Medal(attacker, ELECTROBITCH);
+                                       break;
+                       }
+               }
        }
        else
        {
@@ -248,7 +263,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
        notif_anonymous = M_ARGV(5, bool);
 
        if(notif_anonymous)
-               attacker_name = "Anonymous player";
+               attacker_name = "???";
 
        #ifdef NOTIFICATIONS_DEBUG
        Debug_Notification(
@@ -292,12 +307,13 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                                }
                        }
                }
-               else if (!Obituary_WeaponDeath(targ, false, deathtype, targ.netname, deathlocation, "", CS(targ).killcount, 0))
+               else if (!Obituary_WeaponDeath(targ, NULL, false, deathtype, targ.netname, deathlocation, "", CS(targ).killcount, 0))
                {
                        backtrace("SUICIDE: what the hell happened here?\n");
                        return;
                }
                LogDeath("suicide", deathtype, targ, targ);
+               Send_Notification(NOTIF_ONE, targ, MSG_ANNCE, ANNCE_SUICIDE);
                if(deathtype != DEATH_AUTOTEAMCHANGE.m_id) // special case: don't negate frags if auto switched
                        GiveFrags(attacker, targ, -1, deathtype, weaponentity);
        }
@@ -316,7 +332,9 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
 
                        Send_Notification(NOTIF_ONE, attacker, MSG_CENTER, CENTER_DEATH_TEAMKILL_FRAG, targ.netname);
                        Send_Notification(NOTIF_ONE, targ, MSG_CENTER, CENTER_DEATH_TEAMKILL_FRAGGED, attacker_name);
-                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(targ.team, INFO_DEATH_TEAMKILL), targ.netname, attacker_name, deathlocation, CS(targ).killcount);
+                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(targ.team, INFO_DEATH_TEAMKILL),
+                               playername(targ.netname, targ.team, true), playername(attacker_name, attacker.team, true),
+                               deathlocation, CS(targ).killcount);
 
                        // In this case, the death message will ALWAYS be "foo was betrayed by bar"
                        // No need for specific death/weapon messages...
@@ -330,12 +348,12 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                        CS(attacker).killcount = CS(attacker).killcount + 1;
 
                        attacker.killsound += 1;
-
+                       
                        // TODO: improve SPREE_ITEM and KILL_SPREE_LIST
                        // these 2 macros are spread over multiple files
                        #define SPREE_ITEM(counta,countb,center,normal,gentle) \
                                case counta: \
-                                       Send_Notification(NOTIF_ONE, attacker, MSG_ANNCE, ANNCE_KILLSTREAK_##countb); \
+                                       Give_Medal(attacker, KILLSTREAK_##countb); \
                                        if (!warmup_stage) \
                                                PlayerStats_GameReport_Event_Player(attacker, PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_##counta, 1); \
                                        break;
@@ -351,6 +369,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                        {
                                checkrules_firstblood = true;
                                notif_firstblood = true; // modify the current messages so that they too show firstblood information
+                               Give_Medal(attacker, FIRSTBLOOD);
                                PlayerStats_GameReport_Event_Player(attacker, PLAYERSTATS_ACHIEVEMENT_FIRSTBLOOD, 1);
                                PlayerStats_GameReport_Event_Player(targ, PLAYERSTATS_ACHIEVEMENT_FIRSTVICTIM, 1);
 
@@ -363,6 +382,12 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                                kill_count_to_attacker = CS(attacker).killcount;
                                kill_count_to_target = 0;
                        }
+                       
+                       // Excellent check
+                       if(attacker.lastkill && attacker.lastkill > time - 2) {
+                               Give_Medal(attacker, EXCELLENT);
+                       }
+                       attacker.lastkill = time;
 
                        if(targ.istypefrag)
                        {
@@ -415,8 +440,8 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                        if(deathtype == DEATH_BUFF.m_id)
                                f3 = buff_FirstFromFlags(STAT(BUFFS, attacker)).m_id;
 
-                       if (!Obituary_WeaponDeath(targ, true, deathtype, targ.netname, attacker_name, deathlocation, CS(targ).killcount, kill_count_to_attacker))
-                               Obituary_SpecialDeath(targ, true, deathtype, targ.netname, attacker_name, deathlocation, CS(targ).killcount, kill_count_to_attacker, f3);
+                       if (!Obituary_WeaponDeath(targ, attacker, true, deathtype, playername(targ.netname, targ.team, true), playername(attacker_name, attacker.team, true), deathlocation, CS(targ).killcount, kill_count_to_attacker))
+                               Obituary_SpecialDeath(targ, true, deathtype, playername(targ.netname, targ.team, true), playername(attacker_name, attacker.team, true), deathlocation, CS(targ).killcount, kill_count_to_attacker, f3);
                }
        }
 
@@ -433,7 +458,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                        case DEATH_HURTTRIGGER:
                        {
                                Obituary_SpecialDeath(targ, false, deathtype,
-                                       targ.netname,
+                                       playername(targ.netname, targ.team, true),
                                        inflictor.message,
                                        deathlocation,
                                        CS(targ).killcount,
@@ -445,7 +470,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                        case DEATH_CUSTOM:
                        {
                                Obituary_SpecialDeath(targ, false, deathtype,
-                                       targ.netname,
+                                       playername(targ.netname, targ.team, true),
                                        ((strstrofs(deathmessage, "%", 0) < 0) ? strcat("%s ", deathmessage) : deathmessage),
                                        deathlocation,
                                        CS(targ).killcount,
@@ -456,12 +481,13 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
 
                        default:
                        {
-                               Obituary_SpecialDeath(targ, false, deathtype, targ.netname, deathlocation, "", CS(targ).killcount, 0, 0);
+                               Obituary_SpecialDeath(targ, false, deathtype, playername(targ.netname, targ.team, true), deathlocation, "", CS(targ).killcount, 0, 0);
                                break;
                        }
                }
 
                LogDeath("accident", deathtype, targ, targ);
+               Send_Notification(NOTIF_ONE, targ, MSG_ANNCE, ANNCE_ACCIDENT);
                GiveFrags(targ, targ, -1, deathtype, weaponentity);
 
                if(GameRules_scoring_add(targ, SCORE, 0) == -5)