if (achieve == "armageddon") this.armageddon = value;
if (achieve == "firstblood") this.firstblood = value;
+ if (achieve == "firstplace") this.firstplace = value;
+ if (achieve == "secondplace") this.secondplace = value;
+ if (achieve == "thirdplace") this.thirdplace = value;
+ if (achieve == "mostdamage") this.mostdamage = value;
if (achieve == "airshot") this.airshot = value;
if (achieve == "amazing") this.amazing = value;
if (achieve == "armageddon") return this.armageddon;
if (achieve == "firstblood") return this.firstblood;
+ if (achieve == "firstplace") return this.firstplace;
+ if (achieve == "secondplace") return this.secondplace;
+ if (achieve == "thirdplace") return this.thirdplace;
+ if (achieve == "mostdamage") return this.mostdamage;
if (achieve == "airshot") return this.airshot;
if (achieve == "amazing") return this.amazing;
if (achieve == "armageddon") return "Armageddon!";
if (achieve == "firstblood") return "First Blood!";
+ if (achieve == "firstplace") return "First Place!";
+ if (achieve == "secondplace") return "Second Place!";
+ if (achieve == "thirdplace") return "Third Place!";
+ if (achieve == "mostdamage") return "Most Damage!";
if (achieve == "airshot") return "Air Shot!";
if (achieve == "amazing") return "Amazing!";
//Boolean achievements (can be set only once)
ATTRIB(Achievements, firstblood, bool, 0);
+ ATTRIB(Achievements, firstplace, bool, 0);
+ ATTRIB(Achievements, secondplace, bool, 0);
+ ATTRIB(Achievements, thirdplace, bool, 0);
+ ATTRIB(Achievements, mostdamage, bool, 0);
//Notificated achievements
ATTRIB(Achievements, airshot, 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));
METHOD(Achievements, get_achievement_value, int(Achievements this, string achieve));
}
}
+void increase_achieve(entity player, string name) {
+ player.achievements.inc_achievement(player.achievements, name);
+ player.achievements.announce(player.achievements, player, name);
+}
+
/*
go to the next level for deathmatch
only called if a time or frag limit has expired
MUTATOR_CALLHOOK(MatchEnd);
localcmd("\nsv_hook_gameend\n");
+
+
+ //Achievements
+ entity firstplace = spawn();
+ entity secondplace = spawn();
+ entity thirdplace = spawn();
+ entity mostdamage = spawn();
+
+ FOREACH_CLIENT(IS_PLAYER(it), {
+
+ if (!firstplace) {
+ firstplace = it;
+ }
+
+ if (!mostdamage) {
+ mostdamage = 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);
+ bool cond = (firstplace.totalfrags == it.totalfrags && itaverage > plaverage);
+
+ if (it.totalfrags > firstplace.totalfrags || cond) {
+ thirdplace = secondplace;
+ secondplace = firstplace;
+ firstplace = it;
+ }
+
+ if (PlayerScore_Get(it, SP_DMG) > PlayerScore_Get(mostdamage, SP_DMG)) {
+ mostdamage = 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");
+
+
}