Visual indicator of weapon cooldown?

Post Reply
featherfurl
New member
Posts: 5
Joined: Thu Dec 01, 2022 01:29

Visual indicator of weapon cooldown?

by featherfurl » Post

Hi all,

I've been enjoying how easy it is to maintain a modded minetest server, but I haven't been able to find a mod that provides visual or aural feedback to indicate to players that weapons have a 1 second cooldown between hits. This has led people to believe that minetest's hit-detection is worse than it is. Are there any mods around that implement this I've happened to miss?

User avatar
Blockhead
Member
Posts: 1622
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: Visual indicator of weapon cooldown?

by Blockhead » Post

Ok so I looked into this and fired up a test mod with a 5 second punch interval to exaggerate the effect. The visual indication provided by Minetest is the animation where the wielded item in your first person view slowly raises back up to its normal resting position. If you continuously hold the left mouse button you will continuously punch, but if you pause between punches you can actually see that the time the item takes to return to its resting position is its full punch interval (or the hand's full punch interval if the item has none defined).

As for creating anything more than this, like the visual indicator that Minecraft has, it would take a mod that runs at a frequent interval and checks if the player's wielded item has changed. Also, every entity in the game would need to have its on_punch record the punch interval of the tool the player used to do the punching as well as the time they last punched. Lastly, a global callback would need to redraw a HUD with the punch cooldown indicator for the player at a regular interval.

In my testing I found the engine seems to track the punch interval by recording the item type used, which means for instance you can't switch weapons rapidly to overcome the interval if you had say, two diamond swrods, since they'd be treated the same. Actually that does not make the mod harder to write because we would still do the same itemstack comparison (I'm not actually sure if you can get the exact slot the player is wielding on their hotbar).
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

featherfurl
New member
Posts: 5
Joined: Thu Dec 01, 2022 01:29

Re: Visual indicator of weapon cooldown?

by featherfurl » Post

Interesting! I'll check it out myself. I looked through the docs a bit to try to find a config setting that lets me change the punch interval globally, but I didn't find one. Can you link me to documentation that will show me how to alter it?

User avatar
Blockhead
Member
Posts: 1622
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: Visual indicator of weapon cooldown?

by Blockhead » Post

featherfurl wrote:
Thu Dec 01, 2022 09:37
Interesting! I'll check it out myself. I looked through the docs a bit to try to find a config setting that lets me change the punch interval globally, but I didn't find one. Can you link me to documentation that will show me how to alter it?
Ah yes, the "hand" is a special item that isn't properly documented in lua_api.txt. It's the item with no name whatsoever, the "" name. The hand is used for any tool capabilities that the wielded item doesn't have, including the default punch interval. You can't globally override all items' punch intervals without overriding all items though. Here is an example: Minetest Game, like most games, sets its own definition for the hand.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

featherfurl
New member
Posts: 5
Joined: Thu Dec 01, 2022 01:29

Re: Visual indicator of weapon cooldown?

by featherfurl » Post

Shame there's no global multiplier, but changing all of these at once should at least be scriptable.

Astrobe
Member
Posts: 571
Joined: Sun Apr 01, 2018 10:46

Re: Visual indicator of weapon cooldown?

by Astrobe » Post

featherfurl wrote:
Fri Dec 02, 2022 04:04
Shame there's no global multiplier, but changing all of these at once should at least be scriptable.
You can. Iterate over items, look for the "full_punch_interval" property in their tool_capabilities, change it. But actually that's really a property you want to fine-tune on a case-by-case basis, in my experience.

Astrobe
Member
Posts: 571
Joined: Sun Apr 01, 2018 10:46

Re: Visual indicator of weapon cooldown?

by Astrobe » Post

Blockhead wrote:
Thu Dec 01, 2022 02:12
Ok so I looked into this and fired up a test mod with a 5 second punch interval to exaggerate the effect. The visual indication provided by Minetest is the animation where the wielded item in your first person view slowly raises back up to its normal resting position. If you continuously hold the left mouse button you will continuously punch, but if you pause between punches you can actually see that the time the item takes to return to its resting position is its full punch interval (or the hand's full punch interval if the item has none defined).

As for creating anything more than this, like the visual indicator that Minecraft has, it would take a mod that runs at a frequent interval and checks if the player's wielded item has changed. Also, every entity in the game would need to have its on_punch record the punch interval of the tool the player used to do the punching as well as the time they last punched. Lastly, a global callback would need to redraw a HUD with the punch cooldown indicator for the player at a regular interval.

In my testing I found the engine seems to track the punch interval by recording the item type used, which means for instance you can't switch weapons rapidly to overcome the interval if you had say, two diamond swrods, since they'd be treated the same. Actually that does not make the mod harder to write because we would still do the same itemstack comparison (I'm not actually sure if you can get the exact slot the player is wielding on their hotbar).
Can confirm all this.

For an audio feedback and against (MobRedo) mobs specifically, one can at least play a specific sound when the player punches again while on cooldown, and prevent any damage (instead of a smaller damage amount based on the cooldown time remaining).

FWIW, I received criticism from a player new to MT exactly for the lack of HUD indication. I am kind of split about this issue (if I could do anything about it anyway), because I consider it part of my game mechanic to time your punches right to maximize your DPS, and the weapon animation is a good enough helper in this case.

On the other hand, this isn't the first time this issue pops on the forum. Players apparently don't connect the dots between this animation and the damage done. But it could be an issue with games as well, perhaps they don't use the punch_interval enough (one does notice the difference between 0.5 and 1s) so players cannot figure things out.

I think an engine-manage crosshair change would be a nice addition. Ideally, if a texture for that exists (e.g. crosshair_cooldown) the engine uses it, otherwise do nothing. That would make the feature half-optional (the texture can be added by a mod, game, or texture pack).

The other thing I am missing personally is the possibility to force a cooldown, to be used in on_secondary_use() for instance. It's too easy to pre-spam punches when a hostile comes at you.

Well, that's a couple of letters for Santa Sam.

User avatar
Mantar
Member
Posts: 584
Joined: Thu Oct 05, 2017 18:46
Contact:

Re: Visual indicator of weapon cooldown?

by Mantar » Post

If you can find the specific cooldown of the item you've punched with, you should be able to play a sound when it's complete with minetest.after(). Since, as pointed out above, the cooldown carries over even when you swap items, you wouldn't even need to worry about swapping.
Could maybe put an on_use on your weapons to do this? (I don't recall if on_use will override the default punch behavior offhand, you'd have to test it)
on_use-> check if you're pointing at an entity -> if so, fire off the sound after a delay
Lead dev of Exile, git repo: https://codeberg.org/Mantar/Exile

Awkanimus
Member
Posts: 13
Joined: Mon Nov 28, 2022 21:31
GitHub: Awkanimus
In-game: Awkanimus

Re: Visual indicator of weapon cooldown?

by Awkanimus » Post

Since I started playing (very recently) this has been one of my major wishlist items. I think that this indicator would make the game much more accessible for non-vetern players. I found myself experimenting to try to figure out if weapon cooldown was even a thing as some of the videos I've seen have spam clicking audible.

A mod or an engine change which makes weapon cooldown visual in some way would dramatically help newer players.

User avatar
Mantar
Member
Posts: 584
Joined: Thu Oct 05, 2017 18:46
Contact:

Re: Visual indicator of weapon cooldown?

by Mantar » Post

Well if you want it visual, instead of playing a sound, you could probably apply a texture overlay to the wield item for a moment to make it flash. I believe Mineclone does this for the player object when you get hit.
I'm not sure offhand if you'd need to be using a wielditem mod to do this, or if the engine's wielditem can be overridden.
Lead dev of Exile, git repo: https://codeberg.org/Mantar/Exile

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests