minetest / minetest

Luanti (formerly Minetest) is an open source voxel game-creation platform with easy modding and game creation
https://www.minetest.net/
Other
10.82k stars 2.03k forks source link

Add a minetest.register_on_punch_entity() #3917

Closed C1ffisme closed 6 years ago

C1ffisme commented 8 years ago

Currently, we have a global way to detect if you punched a node.

But we do not have one to globally detect if you have punched an entity.

An ideal usecase for this is to e.g. set a mob on fire if the puncher's sword's meta variable 'Fire' is set to true. (Or remove more health if the sword's 'Sharp' is true or if the player has the 'Strength' effect.)

0-afflatus commented 8 years ago

:+1: My usecase would be for an experience system, so fighting skills could be assessed.

C1ffisme commented 8 years ago

@0-afflatus That's another good idea... Since the stuff in minetest usually doesn't drop on the ground.

C1ffisme commented 8 years ago

Adding to my comment about enchantments, I found out about newlines in item descriptions, so these could easily go together to make a minecraft-like enchantment system. (Based off metadata, rather than tool definition from a different ID)

0-afflatus commented 8 years ago

This is related to #3615 if not a dupe

C1ffisme commented 8 years ago

@0-afflatus That is completely different. That is an issue on how fighting enemies with swords does not wear them. This is a feature request on giving us the ability to detect any time an entity has been punched by a player.

Actually, this could be counted as a solution for #3615.

0-afflatus commented 8 years ago

Actually, this could be counted as a solution for #3615.

So it's related, see sofar's comment.

C1ffisme commented 8 years ago

Okay... So it's related. It's still not a duplicate. (Erm... At least... Not an exact duplicate.)

paramat commented 6 years ago

Any core dev support?

SmallJoker commented 6 years ago

IMO we don't need the same function twice. on_punch already exists in the entity definition - and can be used to trigger an effect which is entity-specific. Overriding and/or extending that callback is no big deal if multiple types of entities should act the same way.

The major problem with such a callback is that the use of entities vary a lot - some are used as letters on signs, as falling nodes or for display purposes in item frames. Setting those on fire can cause undesired side-effects with those mods who will try to restore the entities as soon they're burnt.

EDIT: Add spacing. Long tests are tiring.