mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-18 10:45:27 +02:00
Implement adding velocity to player from Lua
The intended usecase is knockback, but there's potential for more.
This commit is contained in:
@@ -67,7 +67,7 @@ const ToClientCommandHandler toClientCommandTable[TOCLIENT_NUM_MSG_TYPES] =
|
||||
null_command_handler,
|
||||
{ "TOCLIENT_TIME_OF_DAY", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_TimeOfDay }, // 0x29
|
||||
{ "TOCLIENT_CSM_RESTRICTION_FLAGS", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_CSMRestrictionFlags }, // 0x2A
|
||||
null_command_handler,
|
||||
{ "TOCLIENT_PLAYER_SPEED", TOCLIENT_STATE_CONNECTED, &Client::handleCommand_PlayerSpeed }, // 0x2B
|
||||
null_command_handler,
|
||||
null_command_handler,
|
||||
null_command_handler,
|
||||
|
@@ -1383,6 +1383,17 @@ void Client::handleCommand_CSMRestrictionFlags(NetworkPacket *pkt)
|
||||
loadMods();
|
||||
}
|
||||
|
||||
void Client::handleCommand_PlayerSpeed(NetworkPacket *pkt)
|
||||
{
|
||||
v3f added_vel;
|
||||
|
||||
*pkt >> added_vel;
|
||||
|
||||
LocalPlayer *player = m_env.getLocalPlayer();
|
||||
assert(player != NULL);
|
||||
player->addVelocity(added_vel);
|
||||
}
|
||||
|
||||
/*
|
||||
* Mod channels
|
||||
*/
|
||||
|
@@ -194,6 +194,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
New network float format
|
||||
ContentFeatures version 13
|
||||
Add full Euler rotations instead of just yaw
|
||||
Add TOCLIENT_PLAYER_SPEED
|
||||
*/
|
||||
|
||||
#define LATEST_PROTOCOL_VERSION 37
|
||||
@@ -295,6 +296,11 @@ enum ToClientCommand
|
||||
u32 CSMRestrictionFlags byteflag
|
||||
*/
|
||||
|
||||
TOCLIENT_PLAYER_SPEED = 0x2B,
|
||||
/*
|
||||
v3f added_vel
|
||||
*/
|
||||
|
||||
// (oops, there is some gap here)
|
||||
|
||||
TOCLIENT_CHAT_MESSAGE = 0x2F,
|
||||
|
@@ -156,7 +156,7 @@ const ClientCommandFactory clientCommandFactoryTable[TOCLIENT_NUM_MSG_TYPES] =
|
||||
null_command_factory,
|
||||
{ "TOCLIENT_TIME_OF_DAY", 0, true }, // 0x29
|
||||
{ "TOCLIENT_CSM_RESTRICTION_FLAGS", 0, true }, // 0x2A
|
||||
null_command_factory,
|
||||
{ "TOCLIENT_PLAYER_SPEED", 0, true }, // 0x2B
|
||||
null_command_factory,
|
||||
null_command_factory,
|
||||
null_command_factory,
|
||||
|
Reference in New Issue
Block a user