Resource icon

[Script] Hitfeed (kl_hitfeed_v2.2.pk3) 2.2

Snu

YEAAHHHHHHHHH
attachment.php


Just a mod that gives you a general idea of the chaos going on within races!
The hitfeed displays every hit registered between players, just like in FPS games, such as TF2 or Overwatch to name some good examples. Messages related to you in netgames are even highlighted a different colour!

attachment.php


Aside from that, what you see is what you get, it's non-intrusive, nice addition to have!
... although another main highlight of this mod is the amount of customization you can do with how it's displayed! You can change a lot of things about the hitfeed, such as name character limits, message limits and an even change the way hitmessages are displayed. (Icons, Names, or even Icons + Names!)

attachment.php


A full list of commands and what they do can be found here:
hitfeed: Toggles hitfeed. Defaults to On.
hf_displaymode: Changes the hitmessage displaymode. 1 = Names, 2 = Icons, 3 = Icons + Names. Defaults to 1.
hf_charlimit: Limits characters in a hitmessage name. Defaults to 21.
hf_messagelimit: Limits the number of hitmessages. Defaults to 4.
hf_backdrop: Toggles hitmessage backdrops. Defaults to On.
hf_highlightcolor: Changes the highlight colour. Defaults to White.
hf_colorednames: Toggles hitmessage coloured names. Defaults to On.
Upon joining a server with hitfeed added, it'll automatically try load hitfeed.cfg from /luafiles to preload your settings, so you can easily customize hitfeed to your liking! If you don't have the file, it'll automatically create one for you with all the commands set to their defaults for you to modify.

Additionally, there's custom mod support for hitfeed, allowing you to send your own messages, override the locations and even override some parameters relating to how base mod hitmessages appear! If you're interested in supporting your mods, I'll go into detail in the spoiler below;
Sending custom messages:
Of course, you'll need to make sure you have the graphics ready in your wad/pk3. Once you have them ready, when you want to display a message on the hitfeed it's as simple as calling this function in the script;

HF_SendHitMessage(table_t source, table_t victim, string icon, int color):
source and victim are set up as like tables, containing the information for them; {{string name, int color}, {string icon, int color}, player_t player}.
name is the string of the name you want to display for them.
icon is the string of the icon you want to display for them.
color is the color you want the respective fields to be displayed as. (Use skincolors! Hitfeed will convert them to video flags if necessary)
player is just used to determine if the hitmessage is relative to a certain player or not, and can be omitted.
Both source and victim can be set to nil to exclude them from the message.

icon is the name of the graphic for the hitmessage you want to display.
color is the color you want the hitmessage graphic to be. This can be omitted. (Use skincolors!)
All these fields (minus the player set in the source/victim) are really customizable, so go wild!

When calling the function, it's good to check if hitfeed is added, so it'd look something like this;
Code:
if (hitfeed) then HF_SendHitMessage(table_t source, table_t victim, patch_t patch, int color) end
For animated icons, you need to define the animated icon inside the check, like so;
Code:
if (hitfeed)
    if not HF_animIcon[animated patch] then HF_animIcon[animated patch] = {frames, tics} end
    HF_SendHitMessage(table_t source, table_t victim, patch_t patch, int color)
end
animated patch is the animated patch you're defining.
frames is how many frames there are in the animation.
tics is how many tics each frame lasts for.
An example of an animated patch definition is this;
Code:
HF_animIcon["K_HMINV"] = {6, 3}
When this patch is used, it will cycle through patches K_HMINV1 - K_HMINV6, staying on each frame for 6 tics.

Overriding The Hitfeed locations:
Overriding the hitfeed location is really simple, as you just need to use this function;

HF_OverrideLocation(int xpos, int ypos, int snapflags, int split):
xpos
is the x position after being overridden.
ypos is the y position after being overridden.
snapflags are the snapflags the hitfeed will use, corresponding to a direction. (TopLeft = 1, Left = 2, BottomLeft = 3, Top = 4, Middle = 5, Bottom = 6, TopRight = 7, Right = 8, BottomRight = 9)
split is what hitfeed location you want to override. (2 = 2p splitscreen, 3 = 3p/4p splitscreen, anything else = non-splitscreen)
Anything not defined, or set to nil, wont be overridden.

You can clear any override you have defined using this function;
HF_ClearOverride(int split):
split
defines what override you want to clear, with the same values as the parameter in the previous function.
Any override you have defined will also be cleared on MapLoad, so keep that in mind.

Overriding base mod hitmessages:
Finally, overriding base mod hitmessages. This is really simple, as there are 2 variables you can give to objects that will override the base mod's corresponding hitmessage fields;
mo.hf_overrideicon will override the icon of any base mod hitmessage caused by that object.
mo.hf_overridenamecolor will override the name color of any object that is sent in a base mod hit message, useful for team colours.
Just be sure to reset these to nil when you are done with them, otherwise it will keep overriding until you do.

Aaaand that's all there is to hitfeed modding! Like with any of my mods with custom mod support, any additional questions you may have can be DM'd to me here on the MB, or to me directly on Discord!

  • There are cases where an SPB or Eggbox explosion produces a Mine icon, there's nothing I can do about this for now.
  • There's a rare clash where if you hit someone with a thunder shield while invincible, it will display an invincibility icon instead of the thunder shield icon. This is due to how thunder shield hits are detected, there's nothing I can do about this to my knowledge.

Thanks to:

Lat':
Coding assistance and replay support.

v2.2:
  • Modding Changes:
    • You can now just set source and victim to nil in HF_SendHitMessage, instead of having to set every table index to nil.
v2.1:
  • General Changes:
    • Now uses I/O to load hitfeed.cfg instead of an exec command, preventing lagspikes if the cfg wasnt present.
      • I/O also creates a cfg file in /luafiles too with the default values if one is not present upon trying to load it.
    • Updated the code to use displayplayers.iterate, as it no longer crashes in replays as of v1.3.
v2:
  • General Changes:
    • Lots of the code was rewritten to be optimized, again!
      • This should reduce a lot of the very noticeable lag issues that was caused by having v1.1 added to a server.
    • The hf_minimalmode command has been scrapped, and a new command has been introduced in its place, hf_displaymode, allowing you to change how the hitfeed displays messages! It has 3 modes;
      • 1: Names only, the default setting.
      • 2: Icons only, what hf_minimalmode used to look like.
      • 3: Names + Icons, combines the previous 2 modes!
    • Names are now coloured based on a player's skincolor!
      • This can also be disabled with the newly added command, hf_colorednames.
    • Hitmessage backdrops can now be toggled with the newly added command, hf_backdrops, if you prefer them off.
    • 3P/4P splitscreen games no longer force minimal mode, or in v2's case hf_displaymode 2.
  • Bugfixes:
    • Hitmessage limits set with hf_messagelimit should now properly update when set with the command.
    • Hitfeed should now be compatible with interpolation builds of kart, if you use those.
    • Due to the rewrite, any issues with animated icons should be fixed.
  • Modding Changes:
    • Unfortunately, due to the rewrite. Any mods that supported v1.1 are incompatible with v2, and will require updating. It was either keep compatibility by keeping spaghetti code or rewrite it.
      • All you should need to update is the HM_SendHitMessage parameters and the offsets of your graphics, though.
    • The HF_SendHitMessage function is now a lot more customizable with the source and victim parameters, as you're no longer limited to just players.
    • Objects can now have 2 variables set to override certain base mod fields;
      • mo.hf_overrideicon: Can be set to override the icon they'll use in base mod hitmessages.
      • mo.hf_overridenamecolor: Can be set to override the color they'll use in base mod hitmessages.
    • The modding spoiler has been updated again. Alongside the changes listed here being accounted for, I've updated the entirety of the spoiler to be more concise and understandable.
v1.1:
  • General Changes:
    • Lots of the code was rewritten/optimized.
    • The hf_xpos, hf_ypos and hf_snapflags commands were scrapped, since there's really no reason to change the default location of the hitfeed manually.
      • However, since these commands were scrapped this means there are now definitive locations for the hitfeed in splitscreen!
    • Hyudoro item steals now produce a message in the hitfeed.
    • Shrink now produces a message in the hitfeed.
    • The default message limit was lowered from 5 to 4.
    • The icon for pancakes was resized a little.
  • Bugfixes:
    • The hitfeed should no longer flicker when playing with local splitscreen players.
    • Animated icons no longer animate faster in splitscreen.
  • Modding changes:
    • You can now control where the hitfeed will appear with a new function: HF_OverrideLocation(int xpos, int ypos, int snapflags, int split).
      • Additionally, you can clear any override you have set to restore it to the default location with another new function: HF_ClearOverride(int split)
      • Without using this function though, the hitfeed will return to its default location on mapload.
    • Lots of stuff was exposed for use, such as the table containing all the hitmessages for the hitfeed to display.
    • You can now choose to display a hitmessage without source or victim with the HF_SendHitMessage function.
    • The modding spoiler has been updated to accommodate for all these changes.
v1:
  • Initial release.

With that all out of the way, I hope you enjoy hitfeed as much as I did making it, happy karting and battling! (Hitfeed is WAY more useful in battle, try it out!)

Supporters / Co-Authors:
 

Attachments

  • kart0578.gif
    kart0578.gif
    4.2 MB · Views: 13,524
  • kart0640.gif
    kart0640.gif
    6.8 MB · Views: 13,062
  • kart0649.gif
    kart0649.gif
    7.3 MB · Views: 12,592
  • kl_hitfeed-v2.2.pk3
    30.8 KB · Views: 861
Last edited by a moderator:
Wouldn't be a initial release from me without an update shortly after said release!

This update includes a couple of changes, such as new hitfeed messages for Hyudoro item steals and Shrink, splitscreen locations for the hitfeed and additions for modders!

A full changelog is available in the original post.
 
Idk if this could be related or not, but I'm trying to add Hitfeed support to RTD. For some reason, the 6th graphic in the animation is only being displayed for a single tic before going back to the first one (duration is set to TICRATE/4 ala a quarter of a second)

Could you look into this problem? Thanks in advance!
 
Just a few months off from being a full year, but this long overdue update for Hitfeed is now live!

The entire script for drawing hitmessages has been rewritten and there have been optimizations across the board, getting rid of the very noticeable lag that Hitfeed caused in for clients. Alongside that, 3 new commands for customization has been added, including a brand new display method for the Hitfeed! Moddability for custom mods has also been improved and expanded upon. (Although any mods that supported Hitfeed will need to be updated)
I've also included hitfeed.cfg in the zip attached to the original post, containing all the default values for commands. I'd advise putting this in your root kart folder to minimize long lag spikes when you join a server with hitfeed added.

As usual, the full changelog is available to be read in the original post.
 
Last edited:
Hitfeed v2.1 is now available!

The main reason for this overdue update is to use the I/O library included in v1.3! No longer will games lagspike if someone joins without hitfeed.cfg present. Additionally, I/O will also create hitfeed.cfg for you in /luafiles if it's not present when trying to load it.

There's not many other changes in this update, but a full changelog is included in the main post as usual.
 
Hitfeed v2.2 is now available!

This is just a quick patch that includes stuff I wish I included in v2.1, but this patch specifically tailored towards modders! You can now just set source and victim to nil in HF_SendHitMessage, instead of having to set each table index to nil. The documentation has also been updated to be a little more concise. (Don't worry about compatibility either, any mods currently supporting v2/v2.1 won't break. This is simply just for ease of use in the future!)

Unless any bugs arise, this will probably be the last Hitfeed update for awhile.
 
I'm getting a warning at the console of my dedicated server
WARNING: ...dons/Other (KL)/kl_hitfeed-v2.2.pk3|Lua/IOconfig.lua:36: bad argument #1 to 'COM_BufInsertText' (PLAYER_T* expected, got nil)

Any idea if you can fix it?
 

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top