]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add one method to get achievement title, replace announce function
authorAriosJentu <darthpoezd@gmail.com>
Sun, 25 Aug 2019 16:10:16 +0000 (02:10 +1000)
committerAriosJentu <darthpoezd@gmail.com>
Sun, 25 Aug 2019 16:10:16 +0000 (02:10 +1000)
qcsrc/common/achievements.qc
qcsrc/common/achievements.qh
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/electro.qc
qcsrc/common/weapons/weapon/minelayer.qc
qcsrc/common/weapons/weapon/mortar.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/server/client.qc
qcsrc/server/g_damage.qc

index 813918391da224eee52eab262b328ec1b7b39e29..4c499dc72beeb8b950ae9bf6b3fced7173f6ea4d 100644 (file)
@@ -39,8 +39,8 @@ void Achievements_set_achievement_value(entity this, string achieve, int value)
        return;
 }
 
-int Achievements_get_achievement_value(entity this, string achieve) {
 
+int Achievements_get_achievement_value(entity this, string achieve) {
        if (achieve == "triple_kill") return this.triple_kill;
        if (achieve == "rage") return this.rage;
        if (achieve == "massacre") return this.massacre;
@@ -66,6 +66,32 @@ int Achievements_get_achievement_value(entity this, string achieve) {
        return 0;
 }
 
+string Achievements_get_achievement_title(string achieve) {
+       
+       if (achieve == "triple_kill") return "Tripple Kill!";
+       if (achieve == "rage") return "Rage!";
+       if (achieve == "massacre") return "Massacre!";
+       if (achieve == "mayhem") return "Mayhem!";
+       if (achieve == "berserker") return "Berserker!";
+       if (achieve == "carnage") return "Carnage!";
+       if (achieve == "armageddon") return "Armageddon!";
+
+       if (achieve == "firstblood") return "First Blood!";
+
+       if (achieve == "airshot") return "Air Shot!";
+       if (achieve == "amazing") return "Amazing!";
+       if (achieve == "awesome") return "Awesome!";
+       if (achieve == "botlike") return "Botlike!";
+       if (achieve == "electrobitch") return "Electro-BITCH!";
+       if (achieve == "impressive") return "Impressive!";
+       if (achieve == "flyingyoda") return "Yoda!";
+
+       if (achieve == "multirailed") return "Multi Railed!";
+       if (achieve == "pointblank") return "Point Blank!";
+       if (achieve == "selfimmolation") return "Self-Immolation!";
+       return "";
+}
+
 string Achievements_get_achievement_name_from_kills(int kills) {
 
        if (kills == 3) return "triple_kill";
@@ -78,18 +104,6 @@ string Achievements_get_achievement_name_from_kills(int kills) {
        return "";
 }
 
-string Achievements_get_achievement_title_from_kills(int kills) {
-
-       if (kills == 3) return "Tripple Kill!";
-       if (kills == 5) return "Rage!";
-       if (kills == 10) return "Massacre!";
-       if (kills == 15) return "Mayhem!";
-       if (kills == 20) return "Berserker!";
-       if (kills == 25) return "Carnage!";
-       if (kills == 30) return "Armageddon!";
-       return "";
-}
-
 void Achievements_inc_kill_achievement(entity this, int kills) {
 
        return Achievements_inc_achievement(this, Achievements_get_achievement_name_from_kills(kills));
@@ -103,8 +117,9 @@ void Achievements_inc_achievement(entity this, string achieve) {
        return Achievements_add_achievement_value(this, achieve, 1);
 }
 
-void Achievements_announce(Achievements this, entity whom, string title, string achieve) {
+void Achievements_announce(Achievements this, entity whom, string achieve) {
        #ifdef SVQC
+               string title = Achievements_get_achievement_title(achieve);
                centerprint(whom, strcat(title, " [", ftos(this.get_achievement_value(this, achieve)), "]"));
                print(strcat(whom.netname, " got ", achieve, " achievement.\n"));
        #endif
index 9ca6c8d72a4273d1f587818608ca5bbafa0518eb..c198b21b196adb79ae1ee6fd8048316933c6a516 100644 (file)
@@ -37,11 +37,12 @@ CLASS(Achievements, Object)
        METHOD(Achievements, inc_kill_achievement, void(Achievements this, int kills));
        METHOD(Achievements, inc_achievement, void(Achievements this, string achieve));
 
+       //Static methods
        METHOD(Achievements, get_achievement_name_from_kills, string(int kills));
-       METHOD(Achievements, get_achievement_title_from_kills, string(int kills));
+       METHOD(Achievements, get_achievement_title, string(string achieve));
 
        //Announce functions
-       METHOD(Achievements, announce, void(Achievements this, entity whom, string title, string achieve));
+       METHOD(Achievements, announce, void(Achievements this, entity whom, string achieve));
        
        CONSTRUCTOR(Achievements, entity aplayer) 
        {
index 77b0d811add4e81ad831acf6624e7a673eb632eb..5ffc24e3e0c1cc88afe69dea43fe425245c67210 100644 (file)
@@ -26,7 +26,7 @@ void W_Devastator_Explode(entity this, entity directhitentity)
                                        if(IsFlying(directhitentity)) {
                                                Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT);
                                                achs.inc_achievement(achs, "airshot");
-                                               achs.announce(achs, this.realowner, "Air Shot!", "airshot");
+                                               achs.announce(achs, this.realowner, "airshot");
                                        }
 
        this.event_damage = func_null;
index eb9613efad2923da0f7ab36b3ae5ee3faa51a3d9..6602382ec4439a4a95d3b18a2aaa5236aee3aa24 100644 (file)
@@ -82,7 +82,7 @@ void W_Electro_Explode(entity this, entity directhitentity)
                                        if(IsFlying(directhitentity)) {
                                                Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
                                                achs.inc_achievement(achs, "electrobitch");
-                                               achs.announce(achs, this.realowner, "Electro-BITCH!", "electrobitch");
+                                               achs.announce(achs, this.realowner, "electrobitch");
                                        }
 
        this.event_damage = func_null;
index 312cfddfdac2f2236a0ebd16bc9a0c54aa5d575d..85ba995938eea0dffe394e3e5502dcc50a963ae4 100644 (file)
@@ -62,7 +62,7 @@ void W_MineLayer_Explode(entity this, entity directhitentity)
                                        if(IsFlying(directhitentity)) {
                                                Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT);
                                                achs.inc_achievement(achs, "airshot");
-                                               achs.announce(achs, this.realowner, "Air Shot!", "airshot");
+                                               achs.announce(achs, this.realowner, "airshot");
                                        }
 
        this.event_damage = func_null;
index 5db968bf4eb444a548502dff8033242cca88cb50..e8a73fc9577822ee6c4da80bd36bac878bafdcf4 100644 (file)
@@ -12,7 +12,7 @@ void W_Mortar_Grenade_Explode(entity this, entity directhitentity)
                                        if(IsFlying(directhitentity)) {
                                                Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT);
                                                achs.inc_achievement(achs, "airshot");
-                                               achs.announce(achs, this.realowner, "Air Shot!", "airshot");
+                                               achs.announce(achs, this.realowner, "airshot");
                                        }
 
        this.event_damage = func_null;
@@ -41,7 +41,7 @@ void W_Mortar_Grenade_Explode2(entity this, entity directhitentity)
                                        if(IsFlying(directhitentity)){
                                                Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT);
                                                achs.inc_achievement(achs, "airshot");
-                                               achs.announce(achs, this.realowner, "Air Shot!", "airshot");
+                                               achs.announce(achs, this.realowner, "airshot");
                                        }
 
        this.event_damage = func_null;
index 83426ec15678b90db9385699a779ba060cf39791..91927a6a8533fb264baece9dffcada0de01a5e5f 100644 (file)
@@ -134,7 +134,7 @@ void W_Vaporizer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        if (damage_goodhits > 1) {
                Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
                achs.inc_achievement(achs, "multirailed");
-               achs.announce(achs, actor, "Multi Railed!", "multirailed");
+               achs.announce(achs, actor, "multirailed");
        }
 
        if(yoda && flying) {
@@ -146,7 +146,7 @@ void W_Vaporizer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        {
                Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
                achs.inc_achievement(achs, "impressive");
-               achs.announce(achs, actor, "Impressive!", "impressive");
+               achs.announce(achs, actor, "impressive");
                damage_goodhits = 0; // only every second time
        }
 
@@ -169,7 +169,7 @@ void W_RocketMinsta_Laser_Explode (entity this, entity directhitentity)
                                        if(IsFlying(directhitentity)) {
                                                Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
                                                achs.inc_achievement(achs, "electrobitch");
-                                               achs.announce(achs, this.realowner, "Electro-BITCH!", "electrobitch");
+                                               achs.announce(achs, this.realowner, "electrobitch");
                                        }
 
        this.event_damage = func_null;
index 3cf18adc5ae946f9e6c4e7516d8430d101dce2ef..dc579217018717da099840f7ba1d2f3bc11aff30 100644 (file)
@@ -145,7 +145,7 @@ void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float i
        if (damage_goodhits > 1) {
                Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
                achs.inc_achievement(achs, "multirailed");
-               achs.announce(achs, actor, "Multi Railed!", "multirailed");
+               achs.announce(achs, actor, "multirailed");
        }
 
        if(yoda && flying) {
@@ -157,7 +157,7 @@ void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float i
        {
                Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE);
                achs.inc_achievement(achs, "impressive"); 
-               achs.announce(achs, actor, "Impressive!", "impressive");
+               achs.announce(achs, actor, "impressive");
                damage_goodhits = 0; // only every second time
        }
 
index ddb6bbe565df358fcae35d13c987085b4d8a6ea1..7207b9675f2b24fc4caf6ea5d2ca4ec065a5642f 100644 (file)
@@ -2605,7 +2605,7 @@ void PlayerPreThink (entity this)
                        entity achv = this.achievements;
                        
                        achv.inc_achievement(achv, "pointblank");
-                       achv.announce(achv, this, "Point Blank!", "pointblank");
+                       achv.announce(achv, this, "pointblank");
                }
 
                this.pointblank_checker = 0;
@@ -2618,7 +2618,7 @@ void PlayerPreThink (entity this)
                if (this.suicide) {
                        entity achv = this.achievements;
                        achv.inc_achievement(achv, "selfimmolation");
-                       achv.announce(achv, this, "Self-Immolation!", "selfimmolation");
+                       achv.announce(achv, this, "selfimmolation");
                }
 
                this.suicide = 0;
index d9dcc32a483a506b2239c34ae175abdef89942e7..8655fafc8695c376ece2caca059ef03f6e9770cf 100644 (file)
@@ -222,7 +222,7 @@ bool frag_centermessage_override(entity attacker, entity targ, int deathtype, in
 
 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));
+       achv.announce(achv, element, achv.get_achievement_name_from_kills(counta));
 }
 
 void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .entity weaponentity)
@@ -348,7 +348,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                                //Send achievement for first blood
                                entity achv = attacker.achievements;
                                achv.set_achievement_value(achv, "firstblood", 1);
-                               achv.announce(achv, attacker, "First Blood!", "firstblood");
+                               achv.announce(achv, attacker, "firstblood");
 
                                // tell spree_inf and spree_cen that this is a first-blood and first-victim event
                                kill_count_to_attacker = -1;