]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a mutator hook to append special item codes to the death log
authorMario <mario@smbclan.net>
Sun, 11 Aug 2019 06:24:26 +0000 (16:24 +1000)
committerMario <mario@smbclan.net>
Sun, 11 Aug 2019 06:24:26 +0000 (16:24 +1000)
qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc
qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc
qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qh
qcsrc/server/bot/api.qh
qcsrc/server/g_damage.qc
qcsrc/server/mutators/events.qh

index 2484240a26d1c83c62b9487bdcf85ff7d984b6ff..939c70e29ea858597260439a21ea3db98c19f78c 100644 (file)
@@ -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
index d33696ad3772a88fca49f0620dbb693eb0f4b792..5ff31c7beaf754c8a143cce2e23979ec38548666 100644 (file)
@@ -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);
index 345a3d166e0a6f7a0ab65f31e42770716a955b4c..66321c3d9d17f81917d886ce51c8cb1feb749c7a 100644 (file)
@@ -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
index 3f434dbecc7ab529dcc0794ba514e31c60e4eb68..35b52e3d9121de10f322853ea0d92d9c14a51e81 100644 (file)
@@ -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];
index 0901ab44780555d28da3646ef409a62741981321..7599dfd5cb567fbe70251a0934b2dd45bb0d61cd 100644 (file)
@@ -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;
 }
 
index f0237b27ee8b8d55d588fe6386d49deb803d7090..cd09b1defd7ff9051dd5d96e041fd9c303561d0d 100644 (file)
@@ -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);