]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_damage.qc
Also re-write how spree_cen works-- this code crashes gmqcc on compile
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_damage.qc
index 86d0e7c67c3c48618811e7d07db3c80e1dd92f3d..9923ef2d03f4897ff87c3c766f552f9c12ecd656 100644 (file)
@@ -342,7 +342,7 @@ void Obituary_SpecialDeath(entity notif_target, float murder, float deathtype, s
 }
 
 float w_deathtype;
-float Obituary_WeaponDeath(entity notif_target, float murder, float deathtype, string s1, string s2, float f1)
+float Obituary_WeaponDeath(entity notif_target, float murder, float deathtype, string s1, string s2, float f1, float f2)
 {
        float death_weapon = DEATH_WEAPONOF(deathtype);
 
@@ -354,8 +354,8 @@ float Obituary_WeaponDeath(entity notif_target, float murder, float deathtype, s
 
                if(death_message)
                {
-                       Send_Notification_WOVA(NOTIF_ONE, notif_target, MSG_WEAPON, death_message, s1, s2, "", "", f1, 0, 0, 0);
-                       Send_Notification_WOVA(NOTIF_ANY_EXCEPT, notif_target, MSG_INFO, msg_weapon_notifs[death_message - 1].nent_msginfo.nent_id, s1, s2, "", "", f1, 0, 0, 0);
+                       Send_Notification_WOVA(NOTIF_ONE, notif_target, MSG_WEAPON, death_message, s1, s2, "", "", f1, f2, 0, 0);
+                       Send_Notification_WOVA(NOTIF_ANY_EXCEPT, notif_target, MSG_INFO, msg_weapon_notifs[death_message - 1].nent_msginfo.nent_id, s1, s2, "", "", f1, f2, 0, 0);
                        //print(Get_Field_Value(F_INFVAL, MSG_WEAPON, death_message), "\n");
                }
                else { dprint(sprintf("Obituary_WeaponDeath(): ^1Deathtype ^7(%s-%d)^1 has no notification for weapon %d!\n", Deathtype_Name(deathtype), deathtype, death_weapon)); }
@@ -415,7 +415,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, float deathtype)
                        
                        Obituary_SpecialDeath(targ, FALSE, deathtype, s1, s2, f1, f2, 0);
                }
-               else if not(Obituary_WeaponDeath(targ, FALSE, deathtype, targ.netname, "", targ.killcount))
+               else if not(Obituary_WeaponDeath(targ, FALSE, deathtype, targ.netname, "", targ.killcount, 0))
                {
                        backtrace("SUICIDE: what the hell happened here?\n");
                }
@@ -436,8 +436,8 @@ void Obituary(entity attacker, entity inflictor, entity targ, float deathtype)
 
                        attacker.killcount = 0;
                        
-                       Send_Notification(NOTIF_ONE, attacker, MSG_DEATH, DEATH_TEAMKILL_FRAG, s2);
-                       Send_Notification(NOTIF_ONE, targ, MSG_DEATH, DEATH_TEAMKILL_FRAGGED, s1);
+                       Send_Notification(NOTIF_ONE, attacker, MSG_CENTER, CENTER_DEATH_TEAMKILL_FRAG, s2);
+                       Send_Notification(NOTIF_ONE, targ, MSG_CENTER, CENTER_DEATH_TEAMKILL_FRAGGED, s1);
                        Send_Notification(NOTIF_ANY, world, MSG_INFO, APP_TEAM_NUM_4(targ.team, INFO_DEATH_TEAMKILL_), s2, s1, targ.killcount);
 
                        // In this case, the death message will ALWAYS be "foo was betrayed by bar"
@@ -450,26 +450,20 @@ void Obituary(entity attacker, entity inflictor, entity targ, float deathtype)
 
                        attacker.taunt_soundtime = time + 1;
                        attacker.killcount = attacker.killcount + 1;
-                       
-                       #define ADD_ACHIEVEMENT_CASE(numa,numb) \
-                               case numa: \
+
+                       #define SPREE_ITEM(counta,countb,normal,gentle) \
+                               case counta: \
                                { \
-                                       AnnounceTo(attacker, strcat(#numb, "kills")); \
-                                       PlayerStats_Event(attacker, PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_##numa, 1); \
+                                       AnnounceTo(attacker, strcat(#countb, "kills")); \
+                                       PlayerStats_Event(attacker, PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_##counta, 1); \
                                        break; \
                                }
                        switch(attacker.killcount)
                        {
-                               ADD_ACHIEVEMENT_CASE(3, 03)
-                               ADD_ACHIEVEMENT_CASE(5, 05)
-                               ADD_ACHIEVEMENT_CASE(10, 10)
-                               ADD_ACHIEVEMENT_CASE(15, 15)
-                               ADD_ACHIEVEMENT_CASE(20, 20)
-                               ADD_ACHIEVEMENT_CASE(25, 25)
-                               ADD_ACHIEVEMENT_CASE(30, 30)
+                               KILL_SPREE_LIST
                                default: break;
                        }
-                       #undef ADD_ACHIEVEMENT_CASE
+                       #undef SPREE_ITEM
 
                        if(!checkrules_firstblood)
                        {
@@ -484,59 +478,62 @@ void Obituary(entity attacker, entity inflictor, entity targ, float deathtype)
                                if(targ.istypefrag)
                                {
                                        if(attacker.FRAG_VERBOSE)
-                                               Send_Notification(NOTIF_ONE, attacker, MSG_DEATH, DEATH_MURDER_TYPEFRAG_FIRST_VERBOSE, s2, s1, (IS_BOT_CLIENT(targ) ? NO_MSG : targ.ping));
+                                               Send_Notification(NOTIF_ONE, attacker, MSG_CENTER, CENTER_DEATH_MURDER_TYPEFRAG_FIRST_VERBOSE, targ.netname, (IS_BOT_CLIENT(targ) ? NO_MSG : targ.ping));
                                        else
-                                               Send_Notification(NOTIF_ONE, attacker, MSG_DEATH, DEATH_MURDER_TYPEFRAG_FIRST, s2, s1);
+                                               Send_Notification(NOTIF_ONE, attacker, MSG_CENTER, CENTER_DEATH_MURDER_TYPEFRAG_FIRST, targ.netname);
 
                                        if(targ.FRAG_VERBOSE)
-                                               Send_Notification(NOTIF_ONE, targ, MSG_DEATH, DEATH_MURDER_TYPEFRAGGED_FIRST_VERBOSE, s1, attacker.health, attacker.armorvalue, (IS_BOT_CLIENT(attacker) ? NO_MSG : attacker.ping));
+                                               Send_Notification(NOTIF_ONE, targ, MSG_CENTER, CENTER_DEATH_MURDER_TYPEFRAGGED_FIRST_VERBOSE, attacker.netname, attacker.health, attacker.armorvalue, (IS_BOT_CLIENT(attacker) ? NO_MSG : attacker.ping));
                                        else
-                                               Send_Notification(NOTIF_ONE, targ, MSG_DEATH, DEATH_MURDER_TYPEFRAGGED_FIRST, s1);
+                                               Send_Notification(NOTIF_ONE, targ, MSG_CENTER, CENTER_DEATH_MURDER_TYPEFRAGGED_FIRST, attacker.netname);
                                }
                                else
                                {
                                        if(attacker.FRAG_VERBOSE)
-                                               Send_Notification(NOTIF_ONE, attacker, MSG_DEATH, DEATH_MURDER_FRAG_FIRST_VERBOSE, s2, s1, (IS_BOT_CLIENT(targ) ? NO_MSG : targ.ping));
+                                               Send_Notification(NOTIF_ONE, attacker, MSG_CENTER, CENTER_DEATH_MURDER_FRAG_FIRST_VERBOSE, targ.netname, (IS_BOT_CLIENT(targ) ? NO_MSG : targ.ping));
                                        else
-                                               Send_Notification(NOTIF_ONE, attacker, MSG_DEATH, DEATH_MURDER_FRAG_FIRST, s2, s1);
+                                               Send_Notification(NOTIF_ONE, attacker, MSG_CENTER, CENTER_DEATH_MURDER_FRAG_FIRST, targ.netname);
 
                                        if(targ.FRAG_VERBOSE)
-                                               Send_Notification(NOTIF_ONE, targ, MSG_DEATH, DEATH_MURDER_FRAGGED_FIRST_VERBOSE, s1, attacker.health, attacker.armorvalue, (IS_BOT_CLIENT(attacker) ? NO_MSG : attacker.ping));
+                                               Send_Notification(NOTIF_ONE, targ, MSG_CENTER, CENTER_DEATH_MURDER_FRAGGED_FIRST_VERBOSE, attacker.netname, attacker.health, attacker.armorvalue, (IS_BOT_CLIENT(attacker) ? NO_MSG : attacker.ping));
                                        else
-                                               Send_Notification(NOTIF_ONE, targ, MSG_DEATH, DEATH_MURDER_FRAGGED_FIRST, s1);
+                                               Send_Notification(NOTIF_ONE, targ, MSG_CENTER, CENTER_DEATH_MURDER_FRAGGED_FIRST, attacker.netname);
                                }
+
+                               // -1 means firstblood
+                               if not(Obituary_WeaponDeath(targ, TRUE, deathtype, targ.netname, attacker.netname, -1, -1))
+                                       Obituary_SpecialDeath(targ, TRUE, deathtype, targ.netname, attacker.netname, -1, -1, 0);
                        }
                        else // normal frags, kill sprees listed
                        {
                                if(targ.istypefrag)
                                {
                                        if(attacker.FRAG_VERBOSE)
-                                               Send_Notification(NOTIF_ONE, attacker, MSG_DEATH, DEATH_MURDER_TYPEFRAG_VERBOSE, s2, attacker.killcount, (IS_BOT_CLIENT(targ) ? NO_MSG : targ.ping));
+                                               Send_Notification(NOTIF_ONE, attacker, MSG_CENTER, CENTER_DEATH_MURDER_TYPEFRAG_VERBOSE, targ.netname, attacker.killcount, (IS_BOT_CLIENT(targ) ? NO_MSG : targ.ping));
                                        else
-                                               Send_Notification(NOTIF_ONE, attacker, MSG_DEATH, DEATH_MURDER_TYPEFRAG, s2, attacker.killcount);
+                                               Send_Notification(NOTIF_ONE, attacker, MSG_CENTER, CENTER_DEATH_MURDER_TYPEFRAG, targ.netname, attacker.killcount);
 
                                        if(targ.FRAG_VERBOSE)
-                                               Send_Notification(NOTIF_ONE, targ, MSG_DEATH, DEATH_MURDER_TYPEFRAGGED_VERBOSE, s1, attacker.health, attacker.armorvalue, (IS_BOT_CLIENT(attacker) ? NO_MSG : attacker.ping));
+                                               Send_Notification(NOTIF_ONE, targ, MSG_CENTER, CENTER_DEATH_MURDER_TYPEFRAGGED_VERBOSE, attacker.netname, attacker.health, attacker.armorvalue, (IS_BOT_CLIENT(attacker) ? NO_MSG : attacker.ping));
                                        else
-                                               Send_Notification(NOTIF_ONE, targ, MSG_DEATH, DEATH_MURDER_TYPEFRAGGED, s1);
+                                               Send_Notification(NOTIF_ONE, targ, MSG_CENTER, CENTER_DEATH_MURDER_TYPEFRAGGED, attacker.netname);
                                }
                                else
                                {
                                        if(attacker.FRAG_VERBOSE)
-                                               Send_Notification(NOTIF_ONE, attacker, MSG_DEATH, DEATH_MURDER_FRAG_VERBOSE, s2, attacker.killcount, (IS_BOT_CLIENT(targ) ? NO_MSG : targ.ping));
+                                               Send_Notification(NOTIF_ONE, attacker, MSG_CENTER, CENTER_DEATH_MURDER_FRAG_VERBOSE, targ.netname, attacker.killcount, (IS_BOT_CLIENT(targ) ? NO_MSG : targ.ping));
                                        else
-                                               Send_Notification(NOTIF_ONE, attacker, MSG_DEATH, DEATH_MURDER_FRAG, s2, attacker.killcount);
+                                               Send_Notification(NOTIF_ONE, attacker, MSG_CENTER, CENTER_DEATH_MURDER_FRAG, targ.netname, attacker.killcount);
 
                                        if(targ.FRAG_VERBOSE)
-                                               Send_Notification(NOTIF_ONE, targ, MSG_DEATH, DEATH_MURDER_FRAGGED_VERBOSE, s1, attacker.health, attacker.armorvalue, (IS_BOT_CLIENT(attacker) ? NO_MSG : attacker.ping));
+                                               Send_Notification(NOTIF_ONE, targ, MSG_CENTER, CENTER_DEATH_MURDER_FRAGGED_VERBOSE, attacker.netname, attacker.health, attacker.armorvalue, (IS_BOT_CLIENT(attacker) ? NO_MSG : attacker.ping));
                                        else
-                                               Send_Notification(NOTIF_ONE, targ, MSG_DEATH, DEATH_MURDER_FRAGGED, s1);
+                                               Send_Notification(NOTIF_ONE, targ, MSG_CENTER, CENTER_DEATH_MURDER_FRAGGED, attacker.netname);
                                }
-                       }
 
-                       //print("targ_killcount = ", ftos(targ.killcount), ", attacker_killcount = ", ftos(attacker.killcount), ".\n");
-                       if not(Obituary_WeaponDeath(targ, TRUE, deathtype, targ.netname, attacker.netname, targ.killcount))
-                               Obituary_SpecialDeath(targ, TRUE, deathtype, s2, s1, targ.killcount, 0, 0);
+                               if not(Obituary_WeaponDeath(targ, TRUE, deathtype, targ.netname, attacker.netname, targ.killcount, attacker.killcount))
+                                       Obituary_SpecialDeath(targ, TRUE, deathtype, targ.netname, attacker.netname, targ.killcount, attacker.killcount, 0);
+                       }
                }
        }