]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add functions to get achievements names
authorAriosJentu <darthpoezd@gmail.com>
Fri, 23 Aug 2019 13:12:50 +0000 (23:12 +1000)
committerAriosJentu <darthpoezd@gmail.com>
Fri, 23 Aug 2019 13:12:50 +0000 (23:12 +1000)
qcsrc/common/achievements.qc
qcsrc/common/achievements.qh

index 3b96e4031fee6030d127aaffcd515cab59d00969..74269e94deb75147fb24337277db51afbb8ce98c 100644 (file)
@@ -14,52 +14,81 @@ void Achievements_detach(entity this) {
 
 void Achievements_set_achievement_value(entity this, string achieve, int value) {
 
-       if (achieve == "triple_kill") { this.triple_kill = value; }
-       if (achieve == "rage") { this.rage = value; }
-       if (achieve == "massacre") { this.massacre = value; }
-       if (achieve == "mayhem") { this.mayhem = value; }
-       if (achieve == "berserker") { this.berserker = value; }
-       if (achieve == "carnage") { this.carnage = value; }
-       if (achieve == "armageddon") { this.armageddon = value; }
-
-       if (achieve == "firstblood") { this.firstblood = value; }
-
-       if (achieve == "airshot") { this.airshot = value; }
-       if (achieve == "amazing") { this.amazing = value; }
-       if (achieve == "awesome") { this.awesome = value; }
-       if (achieve == "botlike") { this.botlike = value; }
-       if (achieve == "electrobitch") { this.electrobitch = value; }
-       if (achieve == "impressive") { this.impressive = value; }
-       if (achieve == "flyingyoda") { this.flyingyoda = value; }
-       if (achieve == "multirailed") { this.multirailed = value; }
+       if (achieve == "triple_kill") this.triple_kill = value;
+       if (achieve == "rage") this.rage = value;
+       if (achieve == "massacre") this.massacre = value;
+       if (achieve == "mayhem") this.mayhem = value;
+       if (achieve == "berserker") this.berserker = value;
+       if (achieve == "carnage") this.carnage = value;
+       if (achieve == "armageddon") this.armageddon = value;
+
+       if (achieve == "firstblood") this.firstblood = value;
+
+       if (achieve == "airshot") this.airshot = value;
+       if (achieve == "amazing") this.amazing = value;
+       if (achieve == "awesome") this.awesome = value;
+       if (achieve == "botlike") this.botlike = value;
+       if (achieve == "electrobitch") this.electrobitch = value;
+       if (achieve == "impressive") this.impressive = value;
+       if (achieve == "flyingyoda") this.flyingyoda = value;
+       if (achieve == "multirailed") this.multirailed = value;
 
        return;
 }
 
 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; }
-       if (achieve == "mayhem") { return this.mayhem; }
-       if (achieve == "berserker") { return this.berserker; }
-       if (achieve == "carnage") { return this.carnage; }
-       if (achieve == "armageddon") { return this.armageddon; }
-
-       if (achieve == "firstblood") { return this.firstblood; }
-
-       if (achieve == "airshot") { return this.airshot; }
-       if (achieve == "amazing") { return this.amazing; }
-       if (achieve == "awesome") { return this.awesome; }
-       if (achieve == "botlike") { return this.botlike; }
-       if (achieve == "electrobitch") { return this.electrobitch; }
-       if (achieve == "impressive") { return this.impressive; }
-       if (achieve == "flyingyoda") { return this.flyingyoda; }
-       if (achieve == "multirailed") { return this.multirailed; }
+       if (achieve == "triple_kill") return this.triple_kill;
+       if (achieve == "rage") return this.rage;
+       if (achieve == "massacre") return this.massacre;
+       if (achieve == "mayhem") return this.mayhem;
+       if (achieve == "berserker") return this.berserker;
+       if (achieve == "carnage") return this.carnage;
+       if (achieve == "armageddon") return this.armageddon;
+
+       if (achieve == "firstblood") return this.firstblood;
+
+       if (achieve == "airshot") return this.airshot;
+       if (achieve == "amazing") return this.amazing;
+       if (achieve == "awesome") return this.awesome;
+       if (achieve == "botlike") return this.botlike;
+       if (achieve == "electrobitch") return this.electrobitch;
+       if (achieve == "impressive") return this.impressive;
+       if (achieve == "flyingyoda") return this.flyingyoda;
+       if (achieve == "multirailed") return this.multirailed;
 
        return 0;
 }
 
+string Achievements_get_achievement_name_from_kills(int kills) {
+
+       if (kills == 3) return "triple_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 "";
+}
+
+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));
+}
+
 void Achievements_add_achievement_value(entity this, string achieve, int value) {
        Achievements_set_achievement_value(this, achieve, Achievements_get_achievement_value(this, achieve)+value);
 }
index a2afc1af1c8fe1f8b9faed7db8ea81e9f6060366..bb51aab9b17b0ecd0d0db3062a5586302dfe5377 100644 (file)
@@ -26,12 +26,19 @@ CLASS(Achievements, Object)
        ATTRIB(Achievements, flyingyoda, int, 0); //In Yoda maybe incorrect conditions
        ATTRIB(Achievements, multirailed, int, 0);
 
+       //Getters and setters for achievements  
        METHOD(Achievements, set_achievement_value, void(Achievements this, string achieve, int value));
        METHOD(Achievements, get_achievement_value, int(Achievements this, string achieve));
        METHOD(Achievements, add_achievement_value, void(Achievements this, string achieve, int value));
+       METHOD(Achievements, inc_kill_achievement, void(Achievements this, int kills));
        METHOD(Achievements, inc_achievement, void(Achievements this, string achieve));
-       METHOD(Achievements, announce, void(Achievements this, entity whom, string title, string achieve));
 
+       METHOD(Achievements, get_achievement_name_from_kills, string(int kills));
+       METHOD(Achievements, get_achievement_title_from_kills, string(int kills));
+
+       //Announce functions
+       METHOD(Achievements, announce, void(Achievements this, entity whom, string title, string achieve));
+       
        CONSTRUCTOR(Achievements, entity aplayer) 
        {
                CONSTRUCT(Achievements);