]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add achievement Self-Immortal - kill yourself with player whom shot
authorAriosJentu <darthpoezd@gmail.com>
Sun, 25 Aug 2019 13:47:56 +0000 (23:47 +1000)
committerAriosJentu <darthpoezd@gmail.com>
Sun, 25 Aug 2019 13:47:56 +0000 (23:47 +1000)
qcsrc/common/achievements.qc
qcsrc/common/achievements.qh
qcsrc/server/client.qc
qcsrc/server/client.qh
qcsrc/server/g_damage.qc

index 26d12da7ea4b0740e0a030c51279b95aa49e32ef..28d96d7c78003113b5b40909e4aaa9d55fbe1837 100644 (file)
@@ -34,6 +34,7 @@ void Achievements_set_achievement_value(entity this, string achieve, int value)
        
        if (achieve == "multirailed") this.multirailed = value;
        if (achieve == "pointblank") this.pointblank = value;
+       if (achieve == "selfimmolation") this.selfimmolation = value;
 
        return;
 }
@@ -60,6 +61,7 @@ int Achievements_get_achievement_value(entity this, string achieve) {
 
        if (achieve == "multirailed") return this.multirailed;
        if (achieve == "pointblank") return this.pointblank;
+       if (achieve == "selfimmolation") return this.selfimmolation;
 
        return 0;
 }
index 6183fbb57f134c31a8916aaeb7f3e817cd8c0c38..9ca6c8d72a4273d1f587818608ca5bbafa0518eb 100644 (file)
@@ -28,6 +28,7 @@ CLASS(Achievements, Object)
        //New achievements
        ATTRIB(Achievements, multirailed, int, 0);
        ATTRIB(Achievements, pointblank, int, 0);
+       ATTRIB(Achievements, selfimmolation, int, 0);
 
        //Getters and setters for achievements  
        METHOD(Achievements, set_achievement_value, void(Achievements this, string achieve, int value));
index 186fbe9f30d27f08c6bbba64666dd11483455687..80aca32d99298dcb5a15b535ececda693c49a355 100644 (file)
@@ -2620,6 +2620,19 @@ void PlayerPreThink (entity this)
                        this.shotgun_inc_pointblank = 0;
                }
        }
+
+       //Check suicide
+       if (this.check_suicide) {
+
+               if (this.suicide) {
+                       entity achv = this.achievements;
+                       achv.inc_achievement(achv, "selfimmolation");
+                       achv.announce(achv, this, "Self-Immolation!", "selfimmolation");
+               }
+
+               this.suicide = 0;
+               this.check_suicide = 0;
+       }
 }
 
 void DrownPlayer(entity this)
index a648057f8abe0cc87fcd93bd169bce2e0c1cff25..478c4d24c091e607b559942e8392363b550637b1 100644 (file)
@@ -202,6 +202,8 @@ CLASS(Player, Client)
     ATTRIB(Player, shotgun_timer, bool, this.shotgun_timer);
     ATTRIB(Player, shotgun_bullets_received_from, entity, this.shotgun_bullets_received_from);
     ATTRIB(Player, shotgun_inc_pointblank, bool, this.shotgun_inc_pointblank);
+    ATTRIB(Player, check_suicide, bool, this.check_suicide);
+    ATTRIB(Player, suicide, bool, this.suicide);
 
     INIT(Player) {
         this.classname = STR_PLAYER;
index af52305d3f5708d5e574e9ca384ac97faa3ff391..dae22c5c67fccdeaedf045bf480d1d8a5fa71e49 100644 (file)
@@ -288,6 +288,12 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en
                LogDeath("suicide", deathtype, targ, targ);
                if(deathtype != DEATH_AUTOTEAMCHANGE.m_id) // special case: don't negate frags if auto switched
                        GiveFrags(attacker, targ, -1, deathtype, weaponentity);
+               
+               attacker.suicide = 1;
+       }
+
+       if (targ != attacker) {
+               attacker.check_suicide = 1;
        }
 
        // ======