From 6f39575ce04030f6301ee31f9f5f2d0973aeab2a Mon Sep 17 00:00:00 2001 From: AriosJentu Date: Wed, 28 Aug 2019 01:43:02 +1000 Subject: [PATCH] Add achievement for the most suicides at match --- qcsrc/common/achievements.qc | 3 +++ qcsrc/common/achievements.qh | 1 + qcsrc/server/g_world.qc | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/qcsrc/common/achievements.qc b/qcsrc/common/achievements.qc index 51be86530..38fa48e5f 100644 --- a/qcsrc/common/achievements.qc +++ b/qcsrc/common/achievements.qc @@ -27,6 +27,7 @@ void Achievements_set_achievement_value(entity this, string achieve, int value) if (achieve == "secondplace") this.secondplace = value; if (achieve == "thirdplace") this.thirdplace = value; if (achieve == "mostdamage") this.mostdamage = value; + if (achieve == "suicider") this.suicider = value; if (achieve == "airshot") this.airshot = value; if (achieve == "amazing") this.amazing = value; @@ -58,6 +59,7 @@ int Achievements_get_achievement_value(entity this, string achieve) { if (achieve == "secondplace") return this.secondplace; if (achieve == "thirdplace") return this.thirdplace; if (achieve == "mostdamage") return this.mostdamage; + if (achieve == "suicider") return this.suicider; if (achieve == "airshot") return this.airshot; if (achieve == "amazing") return this.amazing; @@ -89,6 +91,7 @@ string Achievements_get_achievement_title(string achieve) { if (achieve == "secondplace") return "Second Place!"; if (achieve == "thirdplace") return "Third Place!"; if (achieve == "mostdamage") return "Most Damage!"; + if (achieve == "suicider") return "Master of Suicide!"; if (achieve == "airshot") return "Air Shot!"; if (achieve == "amazing") return "Amazing!"; diff --git a/qcsrc/common/achievements.qh b/qcsrc/common/achievements.qh index a916b26d0..fab08ca5c 100644 --- a/qcsrc/common/achievements.qh +++ b/qcsrc/common/achievements.qh @@ -19,6 +19,7 @@ CLASS(Achievements, Object) ATTRIB(Achievements, secondplace, bool, 0); ATTRIB(Achievements, thirdplace, bool, 0); ATTRIB(Achievements, mostdamage, bool, 0); + ATTRIB(Achievements, suicider, bool, 0); //Notificated achievements ATTRIB(Achievements, airshot, int, 0); diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 119dc59e5..21c24fb46 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -1638,6 +1638,7 @@ void NextLevel() entity secondplace = spawn(); entity thirdplace = spawn(); entity mostdamage = spawn(); + entity suicider = spawn(); FOREACH_CLIENT(IS_PLAYER(it), { @@ -1648,6 +1649,10 @@ void NextLevel() if (!mostdamage) { mostdamage = it; } + + if (!suicider) { + suicider = it; + } float itaverage = PlayerScore_Get(it, SP_KILLS) / PlayerScore_Get(it, SP_SUICIDES); float plaverage = PlayerScore_Get(firstplace, SP_KILLS) / PlayerScore_Get(firstplace, SP_SUICIDES); @@ -1663,12 +1668,17 @@ void NextLevel() mostdamage = it; } + if (PlayerScore_Get(it, SP_SUICIDES) > PlayerScore_Get(suicider, SP_SUICIDES)) { + suicider = it; + } + }); if (IS_PLAYER(firstplace)) increase_achieve(firstplace, "firstplace"); if (IS_PLAYER(secondplace)) increase_achieve(secondplace, "secondplace"); if (IS_PLAYER(thirdplace)) increase_achieve(thirdplace, "thirdplace"); if (IS_PLAYER(mostdamage)) increase_achieve(mostdamage, "mostdamage"); + if (IS_PLAYER(suicider)) increase_achieve(suicider, "suicider"); } -- 2.39.2