Knockback has been added! Yes, yes, yesssss!
https://github.com/minetest/minetest/pull/8685
There will be 2 new functions, player:add_player_velocity and minetest.calculate_knockback.
lua_api.txt additions:
Code: Select all
* `add_player_velocity(vel)`
* Adds to player velocity, this happens client-side and only once.
* Does not apply during free_move.
* Note that since the player speed is normalized at each move step,
increasing e.g. Y velocity beyond what would usually be achieved
(see: physics overrides) will cause existing X/Z velocity to be reduced.
* Example: `add_player_velocity({x=0, y=6.5, z=0})` is equivalent to
pressing the jump key (assuming default settings)
Code: Select all
* `minetest.calculate_knockback(player, hitter, time_from_last_punch,
tool_capabilities, dir, distance, damage)`
* Returns the amount of knockback applied on the punched player.
* Arguments are equivalent to `register_on_punchplayer`, except the following:
* `distance`: distance between puncher and punched player
* This function can be overriden by mods that wish to modify this behaviour.
* You may want to cache and call the old function to allow multiple mods to
change knockback behaviour.