From: AriosJentu Date: Sun, 25 Aug 2019 13:47:56 +0000 (+1000) Subject: Add achievement Self-Immortal - kill yourself with player whom shot X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3d9dbca232b47800d9c586b38ff64a9e8b8c1022;p=xonotic%2Fxonotic-data.pk3dir.git Add achievement Self-Immortal - kill yourself with player whom shot --- diff --git a/qcsrc/common/achievements.qc b/qcsrc/common/achievements.qc index 26d12da7e..28d96d7c7 100644 --- a/qcsrc/common/achievements.qc +++ b/qcsrc/common/achievements.qc @@ -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; } diff --git a/qcsrc/common/achievements.qh b/qcsrc/common/achievements.qh index 6183fbb57..9ca6c8d72 100644 --- a/qcsrc/common/achievements.qh +++ b/qcsrc/common/achievements.qh @@ -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)); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 186fbe9f3..80aca32d9 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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) diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index a648057f8..478c4d24c 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -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; diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index af52305d3..dae22c5c6 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -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; } // ======