]> 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 99c99153aaa54e3e74a591d998b6640fd6bfb3d1..0a0c76ad8b95721c5f1e942e3f20337ed4566721 100644 (file)
@@ -124,6 +124,7 @@ void LogDeath(string mode, int deathtype, entity killer, entity killed)
 
 void Obituary_SpecialDeath(
        entity notif_target,
+       entity attacker,
        float murder,
        int deathtype,
        string s1, string s2, string s3,
@@ -165,10 +166,15 @@ void Obituary_SpecialDeath(
                        f1, f2, f3, 0
                );
        }
+       
+       if(deathtype == DEATH_TELEFRAG.m_id) {
+               Give_Medal(attacker, TELEFRAG);
+       }
 }
 
 float Obituary_WeaponDeath(
        entity notif_target,
+       entity attacker,
        float murder,
        int deathtype,
        string s1, string s2, string s3,
@@ -201,6 +207,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
        {
@@ -272,7 +292,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                {
                        if(deathtype == DEATH_TEAMCHANGE.m_id || deathtype == DEATH_AUTOTEAMCHANGE.m_id)
                        {
-                               Obituary_SpecialDeath(targ, false, deathtype, targ.netname, deathlocation, "", targ.team, 0, 0);
+                               Obituary_SpecialDeath(targ, NULL, false, deathtype, targ.netname, deathlocation, "", targ.team, 0, 0);
                        }
                        else
                        {
@@ -280,26 +300,27 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                                {
                                        case DEATH_MIRRORDAMAGE:
                                        {
-                                               Obituary_SpecialDeath(targ, false, deathtype, targ.netname, deathlocation, "", CS(targ).killcount, 0, 0);
+                                               Obituary_SpecialDeath(targ, NULL, false, deathtype, targ.netname, deathlocation, "", CS(targ).killcount, 0, 0);
                                                break;
                                        }
                                        case DEATH_HURTTRIGGER:
-                                               Obituary_SpecialDeath(targ, false, deathtype, targ.netname, inflictor.message, deathlocation, CS(targ).killcount, 0, 0);
+                                               Obituary_SpecialDeath(targ, NULL, false, deathtype, targ.netname, inflictor.message, deathlocation, CS(targ).killcount, 0, 0);
                                                break;
                                        default:
                                        {
-                                               Obituary_SpecialDeath(targ, false, deathtype, targ.netname, deathlocation, "", CS(targ).killcount, 0, 0);
+                                               Obituary_SpecialDeath(targ, NULL, false, deathtype, targ.netname, deathlocation, "", CS(targ).killcount, 0, 0);
                                                break;
                                        }
                                }
                        }
                }
-               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);
        }
@@ -318,7 +339,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...
@@ -332,12 +355,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;
@@ -353,6 +376,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);
 
@@ -365,6 +389,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 - autocvar_g_medals_excellent_time) {
+                               Give_Medal(attacker, EXCELLENT);
+                       }
+                       attacker.lastkill = time;
 
                        if(targ.istypefrag)
                        {
@@ -417,8 +447,8 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                        if(deathtype == DEATH_BUFF.m_id)
                                f3 = buff_FirstFromFlags(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, attacker, true, deathtype, playername(targ.netname, targ.team, true), playername(attacker_name, attacker.team, true), deathlocation, CS(targ).killcount, kill_count_to_attacker, f3);
                }
        }
 
@@ -434,8 +464,8 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                        // and there will be a REAL DEATH_VOID implementation which mappers will use.
                        case DEATH_HURTTRIGGER:
                        {
-                               Obituary_SpecialDeath(targ, false, deathtype,
-                                       targ.netname,
+                               Obituary_SpecialDeath(targ, NULL, false, deathtype,
+                                       playername(targ.netname, targ.team, true),
                                        inflictor.message,
                                        deathlocation,
                                        CS(targ).killcount,
@@ -446,8 +476,8 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
 
                        case DEATH_CUSTOM:
                        {
-                               Obituary_SpecialDeath(targ, false, deathtype,
-                                       targ.netname,
+                               Obituary_SpecialDeath(targ, NULL, false, deathtype,
+                                       playername(targ.netname, targ.team, true),
                                        ((strstrofs(deathmessage, "%", 0) < 0) ? strcat("%s ", deathmessage) : deathmessage),
                                        deathlocation,
                                        CS(targ).killcount,
@@ -458,12 +488,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, NULL, 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)