From 57f6fd4b4bbd3fbe8180a1cf80c4e81ecaff2e61 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 11 Aug 2019 16:24:26 +1000 Subject: [PATCH] Add a mutator hook to append special item codes to the death log --- qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc | 7 +++++++ qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc | 9 +++++++-- qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qh | 3 +++ qcsrc/server/bot/api.qh | 3 --- qcsrc/server/g_damage.qc | 9 +++------ qcsrc/server/mutators/events.qh | 8 ++++++++ 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc index 2484240a2..939c70e29 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc +++ b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc @@ -2593,6 +2593,13 @@ MUTATOR_HOOKFUNCTION(ctf, DropSpecialItems) ctf_Handle_Throw(frag_target, NULL, DROP_THROW); } +MUTATOR_HOOKFUNCTION(ctf, LogDeath_AppendItemCodes) +{ + entity player = M_ARGV(0, entity); + if(player.flagcarried) + M_ARGV(1, string) = strcat(M_ARGV(1, string), "F"); // item codes +} + // ========== // Spawnfuncs diff --git a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc index d33696ad3..5ff31c7be 100644 --- a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc +++ b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc @@ -61,8 +61,6 @@ int kh_Team_ByID(int t) return 0; } -//entity kh_worldkeylist; -.entity kh_worldkeynext; entity kh_controller; //bool kh_tracking_enabled; int kh_teams; @@ -1293,6 +1291,13 @@ MUTATOR_HOOKFUNCTION(kh, HavocBot_ChooseRole) return true; } +MUTATOR_HOOKFUNCTION(kh, LogDeath_AppendItemCodes) +{ + entity player = M_ARGV(0, entity); + if(player.kh_next) + M_ARGV(1, string) = strcat(M_ARGV(1, string), "K"); // item codes +} + MUTATOR_HOOKFUNCTION(kh, DropSpecialItems) { entity frag_target = M_ARGV(0, entity); diff --git a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qh b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qh index 345a3d166..66321c3d9 100644 --- a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qh +++ b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qh @@ -21,6 +21,9 @@ REGISTER_MUTATOR(kh, false) return 0; } +entity kh_worldkeylist; +.entity kh_worldkeynext; + #define FOR_EACH_KH_KEY(v) for(v = kh_worldkeylist; v; v = v.kh_worldkeynext ) // ALL OF THESE should be removed in the future, as other code should not have to care diff --git a/qcsrc/server/bot/api.qh b/qcsrc/server/bot/api.qh index 3f434dbec..35b52e3d9 100644 --- a/qcsrc/server/bot/api.qh +++ b/qcsrc/server/bot/api.qh @@ -15,9 +15,6 @@ const int WAYPOINTFLAG_DEAD_END = BIT(16); // Useless WP detection temporary fl const int WAYPOINTFLAG_LADDER = BIT(15); const int WAYPOINTFLAG_JUMP = BIT(14); -entity kh_worldkeylist; -.entity kh_worldkeynext; - float bot_custom_weapon; float bot_weapons_close[Weapons_MAX]; float bot_weapons_far[Weapons_MAX]; diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 0901ab447..7599dfd5c 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -74,8 +74,6 @@ void GiveFrags(entity attacker, entity targ, float f, int deathtype, .entity wea UpdateFrags(attacker, f); } -.entity kh_next; - string AppendItemcodes(string s, entity player) { for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) @@ -91,12 +89,11 @@ string AppendItemcodes(string s, entity player) s = strcat(s, "S"); if(time < player.invincible_finished) s = strcat(s, "I"); - if(player.flagcarried != NULL) - s = strcat(s, "F"); if(PHYS_INPUT_BUTTON_CHAT(player)) s = strcat(s, "T"); - if(player.kh_next) - s = strcat(s, "K"); + // TODO: include these codes as a flag on the item itself + MUTATOR_CALLHOOK(LogDeath_AppendItemCodes, player, s); + s = M_ARGV(1, string); return s; } diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index f0237b27e..cd09b1def 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -1222,3 +1222,11 @@ MUTATOR_HOOKABLE(Unfreeze, EV_Unfreeze); /**/ o(int, MUTATOR_ARGV_0_int) \ /**/ MUTATOR_HOOKABLE(GetPlayerLimit, EV_GetPlayerLimit); + +/** include special item codes for a death to the game log */ +#define EV_LogDeath_AppendItemCodes(i, o) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ + /** item codes */ i(string, MUTATOR_ARGV_1_string) \ + /**/ o(string, MUTATOR_ARGV_1_string) \ + /**/ +MUTATOR_HOOKABLE(LogDeath_AppendItemCodes, EV_LogDeath_AppendItemCodes); -- 2.39.2