]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add killing spree achievements
authorAriosJentu <darthpoezd@gmail.com>
Fri, 23 Aug 2019 13:14:09 +0000 (23:14 +1000)
committerAriosJentu <darthpoezd@gmail.com>
Fri, 23 Aug 2019 13:14:09 +0000 (23:14 +1000)
qcsrc/server/g_damage.qc

index e14ecd6ce7808ebeeca7dd436dc1aa4d41db2127..8b169cd7123e47f50d4b155b8c49db68a5716060 100644 (file)
@@ -220,6 +220,11 @@ bool frag_centermessage_override(entity attacker, entity targ, int deathtype, in
        return MUTATOR_CALLHOOK(FragCenterMessage, attacker, targ, deathtype, kill_count_to_attacker, kill_count_to_target);
 }
 
+void announce_spree(int counta, entity achv, entity element) {
+       achv.inc_kill_achievement(achv, counta);
+       achv.announce(achv, element, achv.get_achievement_title_from_kills(counta), achv.get_achievement_name_from_kills(counta));
+}
+
 void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .entity weaponentity)
 {
        // Sanity check
@@ -314,6 +319,8 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
 
                        attacker.killsound += 1;
 
+                       entity achv = attacker.achievements;
+
                        // TODO: improve SPREE_ITEM and KILL_SPREE_LIST
                        // these 2 macros are spread over multiple files
                        #define SPREE_ITEM(counta,countb,center,normal,gentle) \
@@ -321,6 +328,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                                        Send_Notification(NOTIF_ONE, attacker, MSG_ANNCE, ANNCE_KILLSTREAK_##countb); \
                                        if (!warmup_stage) \
                                                PlayerStats_GameReport_Event_Player(attacker, PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_##counta, 1); \
+                                               announce_spree(counta, achv, attacker); \
                                        break;
 
                        switch(CS(attacker).killcount)
@@ -337,6 +345,11 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                                PlayerStats_GameReport_Event_Player(attacker, PLAYERSTATS_ACHIEVEMENT_FIRSTBLOOD, 1);
                                PlayerStats_GameReport_Event_Player(targ, PLAYERSTATS_ACHIEVEMENT_FIRSTVICTIM, 1);
 
+                               //Send achievement for first blood
+                               entity achv = attacker.achievements;
+                               achv.set_achievement_value(achv, "firstblood", 1);
+                               achv.announce(achv, attacker, "First Blood!", "firstblood");
+
                                // tell spree_inf and spree_cen that this is a first-blood and first-victim event
                                kill_count_to_attacker = -1;
                                kill_count_to_target = -2;