From 15164040e8d63ceffa62bf5a5ab481a9d2f2f6ca Mon Sep 17 00:00:00 2001 From: AriosJentu Date: Mon, 26 Aug 2019 02:10:16 +1000 Subject: [PATCH] Add one method to get achievement title, replace announce function --- qcsrc/common/achievements.qc | 43 +++++++++++++++-------- qcsrc/common/achievements.qh | 5 +-- qcsrc/common/weapons/weapon/devastator.qc | 2 +- qcsrc/common/weapons/weapon/electro.qc | 2 +- qcsrc/common/weapons/weapon/minelayer.qc | 2 +- qcsrc/common/weapons/weapon/mortar.qc | 4 +-- qcsrc/common/weapons/weapon/vaporizer.qc | 6 ++-- qcsrc/common/weapons/weapon/vortex.qc | 4 +-- qcsrc/server/client.qc | 4 +-- qcsrc/server/g_damage.qc | 4 +-- 10 files changed, 46 insertions(+), 30 deletions(-) diff --git a/qcsrc/common/achievements.qc b/qcsrc/common/achievements.qc index 813918391..4c499dc72 100644 --- a/qcsrc/common/achievements.qc +++ b/qcsrc/common/achievements.qc @@ -39,8 +39,8 @@ void Achievements_set_achievement_value(entity this, string achieve, int value) return; } -int Achievements_get_achievement_value(entity this, string achieve) { +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; @@ -66,6 +66,32 @@ int Achievements_get_achievement_value(entity this, string achieve) { return 0; } +string Achievements_get_achievement_title(string achieve) { + + if (achieve == "triple_kill") return "Tripple Kill!"; + if (achieve == "rage") return "Rage!"; + if (achieve == "massacre") return "Massacre!"; + if (achieve == "mayhem") return "Mayhem!"; + if (achieve == "berserker") return "Berserker!"; + if (achieve == "carnage") return "Carnage!"; + if (achieve == "armageddon") return "Armageddon!"; + + if (achieve == "firstblood") return "First Blood!"; + + if (achieve == "airshot") return "Air Shot!"; + if (achieve == "amazing") return "Amazing!"; + if (achieve == "awesome") return "Awesome!"; + if (achieve == "botlike") return "Botlike!"; + if (achieve == "electrobitch") return "Electro-BITCH!"; + if (achieve == "impressive") return "Impressive!"; + if (achieve == "flyingyoda") return "Yoda!"; + + if (achieve == "multirailed") return "Multi Railed!"; + if (achieve == "pointblank") return "Point Blank!"; + if (achieve == "selfimmolation") return "Self-Immolation!"; + return ""; +} + string Achievements_get_achievement_name_from_kills(int kills) { if (kills == 3) return "triple_kill"; @@ -78,18 +104,6 @@ string Achievements_get_achievement_name_from_kills(int kills) { 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)); @@ -103,8 +117,9 @@ void Achievements_inc_achievement(entity this, string achieve) { return Achievements_add_achievement_value(this, achieve, 1); } -void Achievements_announce(Achievements this, entity whom, string title, string achieve) { +void Achievements_announce(Achievements this, entity whom, string achieve) { #ifdef SVQC + string title = Achievements_get_achievement_title(achieve); centerprint(whom, strcat(title, " [", ftos(this.get_achievement_value(this, achieve)), "]")); print(strcat(whom.netname, " got ", achieve, " achievement.\n")); #endif diff --git a/qcsrc/common/achievements.qh b/qcsrc/common/achievements.qh index 9ca6c8d72..c198b21b1 100644 --- a/qcsrc/common/achievements.qh +++ b/qcsrc/common/achievements.qh @@ -37,11 +37,12 @@ CLASS(Achievements, Object) METHOD(Achievements, inc_kill_achievement, void(Achievements this, int kills)); METHOD(Achievements, inc_achievement, void(Achievements this, string achieve)); + //Static methods METHOD(Achievements, get_achievement_name_from_kills, string(int kills)); - METHOD(Achievements, get_achievement_title_from_kills, string(int kills)); + METHOD(Achievements, get_achievement_title, string(string achieve)); //Announce functions - METHOD(Achievements, announce, void(Achievements this, entity whom, string title, string achieve)); + METHOD(Achievements, announce, void(Achievements this, entity whom, string achieve)); CONSTRUCTOR(Achievements, entity aplayer) { diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index 77b0d811a..5ffc24e3e 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -26,7 +26,7 @@ void W_Devastator_Explode(entity this, entity directhitentity) if(IsFlying(directhitentity)) { Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT); achs.inc_achievement(achs, "airshot"); - achs.announce(achs, this.realowner, "Air Shot!", "airshot"); + achs.announce(achs, this.realowner, "airshot"); } this.event_damage = func_null; diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index eb9613efa..6602382ec 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -82,7 +82,7 @@ void W_Electro_Explode(entity this, entity directhitentity) if(IsFlying(directhitentity)) { Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH); achs.inc_achievement(achs, "electrobitch"); - achs.announce(achs, this.realowner, "Electro-BITCH!", "electrobitch"); + achs.announce(achs, this.realowner, "electrobitch"); } this.event_damage = func_null; diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index 312cfddfd..85ba99593 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -62,7 +62,7 @@ void W_MineLayer_Explode(entity this, entity directhitentity) if(IsFlying(directhitentity)) { Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT); achs.inc_achievement(achs, "airshot"); - achs.announce(achs, this.realowner, "Air Shot!", "airshot"); + achs.announce(achs, this.realowner, "airshot"); } this.event_damage = func_null; diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index 5db968bf4..e8a73fc95 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -12,7 +12,7 @@ void W_Mortar_Grenade_Explode(entity this, entity directhitentity) if(IsFlying(directhitentity)) { Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT); achs.inc_achievement(achs, "airshot"); - achs.announce(achs, this.realowner, "Air Shot!", "airshot"); + achs.announce(achs, this.realowner, "airshot"); } this.event_damage = func_null; @@ -41,7 +41,7 @@ void W_Mortar_Grenade_Explode2(entity this, entity directhitentity) if(IsFlying(directhitentity)){ Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT); achs.inc_achievement(achs, "airshot"); - achs.announce(achs, this.realowner, "Air Shot!", "airshot"); + achs.announce(achs, this.realowner, "airshot"); } this.event_damage = func_null; diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index 83426ec15..91927a6a8 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -134,7 +134,7 @@ void W_Vaporizer_Attack(Weapon thiswep, entity actor, .entity weaponentity) if (damage_goodhits > 1) { Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH); achs.inc_achievement(achs, "multirailed"); - achs.announce(achs, actor, "Multi Railed!", "multirailed"); + achs.announce(achs, actor, "multirailed"); } if(yoda && flying) { @@ -146,7 +146,7 @@ void W_Vaporizer_Attack(Weapon thiswep, entity actor, .entity weaponentity) { Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE); achs.inc_achievement(achs, "impressive"); - achs.announce(achs, actor, "Impressive!", "impressive"); + achs.announce(achs, actor, "impressive"); damage_goodhits = 0; // only every second time } @@ -169,7 +169,7 @@ void W_RocketMinsta_Laser_Explode (entity this, entity directhitentity) if(IsFlying(directhitentity)) { Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH); achs.inc_achievement(achs, "electrobitch"); - achs.announce(achs, this.realowner, "Electro-BITCH!", "electrobitch"); + achs.announce(achs, this.realowner, "electrobitch"); } this.event_damage = func_null; diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 3cf18adc5..dc5792170 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -145,7 +145,7 @@ void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float i if (damage_goodhits > 1) { Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH); achs.inc_achievement(achs, "multirailed"); - achs.announce(achs, actor, "Multi Railed!", "multirailed"); + achs.announce(achs, actor, "multirailed"); } if(yoda && flying) { @@ -157,7 +157,7 @@ void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float i { Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_IMPRESSIVE); achs.inc_achievement(achs, "impressive"); - achs.announce(achs, actor, "Impressive!", "impressive"); + achs.announce(achs, actor, "impressive"); damage_goodhits = 0; // only every second time } diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index ddb6bbe56..7207b9675 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -2605,7 +2605,7 @@ void PlayerPreThink (entity this) entity achv = this.achievements; achv.inc_achievement(achv, "pointblank"); - achv.announce(achv, this, "Point Blank!", "pointblank"); + achv.announce(achv, this, "pointblank"); } this.pointblank_checker = 0; @@ -2618,7 +2618,7 @@ void PlayerPreThink (entity this) if (this.suicide) { entity achv = this.achievements; achv.inc_achievement(achv, "selfimmolation"); - achv.announce(achv, this, "Self-Immolation!", "selfimmolation"); + achv.announce(achv, this, "selfimmolation"); } this.suicide = 0; diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index d9dcc32a4..8655fafc8 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -222,7 +222,7 @@ bool frag_centermessage_override(entity attacker, entity targ, int deathtype, in void announce_spree(int counta, entity achv, entity element) { achv.inc_kill_achievement(achv, counta); - achv.announce(achv, element, achv.get_achievement_title_from_kills(counta), achv.get_achievement_name_from_kills(counta)); + achv.announce(achv, element, achv.get_achievement_name_from_kills(counta)); } void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .entity weaponentity) @@ -348,7 +348,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype, .en //Send achievement for first blood entity achv = attacker.achievements; achv.set_achievement_value(achv, "firstblood", 1); - achv.announce(achv, attacker, "First Blood!", "firstblood"); + achv.announce(achv, attacker, "firstblood"); // tell spree_inf and spree_cen that this is a first-blood and first-victim event kill_count_to_attacker = -1; -- 2.39.2