{jump=bool,right=bool,left=bool,LMB=bool,RMB=bool,sneak=bool,aux1=bool,down=bool,up=bool}
- get_player_control_bits(): returns integer with bit packed player pressed keys
bit nr/meaning: 0/up ,1/down ,2/left ,3/right ,4/jump ,5/aux1 ,6/sneak ,7/LMB ,8/RMB
+- set_physics_override(speed, jump, gravity)
+ modifies per-player walking speed, jump height, and gravity.
+ Values default to 1 and act as offsets to the physics settings
+ in minetest.conf. nil will keep the current setting.
InvRef: Reference to an inventory
methods:
PROTOCOL_VERSION 18:
damageGroups added to ToolCapabilities
sound_place added to ItemDefinition
+ PROTOCOL_VERSION 19:
+ GENERIC_CMD_SET_PHYSICS_OVERRIDE
*/
-#define LATEST_PROTOCOL_VERSION 18
+#define LATEST_PROTOCOL_VERSION 19
// Server's supported network protocol range
#define SERVER_PROTOCOL_VERSION_MIN 13
updateTexturePos();
}
+ else if(cmd == GENERIC_CMD_SET_PHYSICS_OVERRIDE)
+ {
+ float override_speed = readF1000(is);
+ float override_jump = readF1000(is);
+ float override_gravity = readF1000(is);
+ if(m_is_local_player)
+ {
+ LocalPlayer *player = m_env->getLocalPlayer();
+ player->physics_override_speed = override_speed;
+ player->physics_override_jump = override_jump;
+ player->physics_override_gravity = override_gravity;
+ }
+ }
else if(cmd == GENERIC_CMD_SET_ANIMATION)
{
m_animation_range = readV2F1000(is);
m_moved(false),
m_inventory_not_sent(false),
m_hp_not_sent(false),
- m_wielded_item_not_sent(false)
+ m_wielded_item_not_sent(false),
+ m_physics_override_speed(1),
+ m_physics_override_jump(1),
+ m_physics_override_gravity(1),
+ m_physics_override_sent(false)
{
assert(m_player);
assert(m_peer_id != 0);
writeF1000(os, m_player->getYaw());
writeS16(os, getHP());
- writeU8(os, 4 + m_bone_position.size()); // number of messages stuffed in here
+ writeU8(os, 5 + m_bone_position.size()); // number of messages stuffed in here
os<<serializeLongString(getPropertyPacket()); // message 1
os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
os<<serializeLongString(gob_cmd_update_animation(m_animation_range, m_animation_speed, m_animation_blend)); // 3
os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
}
os<<serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
+ os<<serializeLongString(gob_cmd_update_physics_override(m_physics_override_speed, m_physics_override_jump, m_physics_override_gravity)); // 5
}
else
{
m_messages_out.push_back(aom);
}
+ if(m_physics_override_sent == false){
+ m_physics_override_sent = true;
+ std::string str = gob_cmd_update_physics_override(m_physics_override_speed, m_physics_override_jump, m_physics_override_gravity);
+ // create message and add to list
+ ActiveObjectMessage aom(getId(), true, str);
+ m_messages_out.push_back(aom);
+ }
+
if(m_animation_sent == false){
m_animation_sent = true;
std::string str = gob_cmd_update_animation(m_animation_range, m_animation_speed, m_animation_blend);
float m_last_sent_position_timer;
float m_last_sent_move_precision;
bool m_armor_groups_sent;
-
+
v2f m_animation_range;
float m_animation_speed;
float m_animation_blend;
ItemGroupList m_armor_groups;
bool m_armor_groups_sent;
-
-
bool m_properties_sent;
struct ObjectProperties m_prop;
// Cached privileges for enforcement
bool m_inventory_not_sent;
bool m_hp_not_sent;
bool m_wielded_item_not_sent;
+
+ float m_physics_override_speed;
+ float m_physics_override_jump;
+ float m_physics_override_gravity;
+ bool m_physics_override_sent;
};
#endif
// Gravity
v3f speed = lplayer->getSpeed();
if(lplayer->in_liquid == false)
- speed.Y -= lplayer->movement_gravity * dtime_part * 2;
+ speed.Y -= lplayer->movement_gravity * lplayer->physics_override_gravity * dtime_part * 2;
// Liquid floating / sinking
if(lplayer->in_liquid && !lplayer->swimming_vertical)
return os.str();
}
+std::string gob_cmd_update_physics_override(float physics_override_speed, float physics_override_jump, float physics_override_gravity)
+{
+ std::ostringstream os(std::ios::binary);
+ // command
+ writeU8(os, GENERIC_CMD_SET_PHYSICS_OVERRIDE);
+ // parameters
+ writeF1000(os, physics_override_speed);
+ writeF1000(os, physics_override_jump);
+ writeF1000(os, physics_override_gravity);
+ return os.str();
+}
+
std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend)
{
std::ostringstream os(std::ios::binary);
#define GENERIC_CMD_SET_ANIMATION 6
#define GENERIC_CMD_SET_BONE_POSITION 7
#define GENERIC_CMD_SET_ATTACHMENT 8
+#define GENERIC_CMD_SET_PHYSICS_OVERRIDE 9
#include "object_properties.h"
std::string gob_cmd_set_properties(const ObjectProperties &prop);
#include "itemgroup.h"
std::string gob_cmd_update_armor_groups(const ItemGroupList &armor_groups);
+std::string gob_cmd_update_physics_override(float physics_override_speed, float physics_override_jump, float physics_override_gravity);
+
std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend);
std::string gob_cmd_update_bone_position(std::string bone, v3f position, v3f rotation);
v3f speedJ = getSpeed();
if(speedJ.Y >= -0.5 * BS)
{
- speedJ.Y = movement_speed_jump;
+ speedJ.Y = movement_speed_jump * physics_override_jump;
setSpeed(speedJ);
MtEvent *e = new SimpleTriggerEvent("PlayerJump");
incH = incV = movement_acceleration_default * BS * dtime;
// Accelerate to target speed with maximum increment
- accelerateHorizontal(speedH, incH);
- accelerateVertical(speedV, incV);
+ accelerateHorizontal(speedH * physics_override_speed, incH * physics_override_speed);
+ accelerateVertical(speedV * physics_override_speed, incV * physics_override_speed);
}
v3s16 LocalPlayer::getStandingNodePos()
movement_liquid_fluidity_smooth = 0.5 * BS;
movement_liquid_sink = 10 * BS;
movement_gravity = 9.81 * BS;
+
+ // Movement overrides are multipliers and must be 1 by default
+ physics_override_speed = 1;
+ physics_override_jump = 1;
+ physics_override_gravity = 1;
}
Player::~Player()
f32 movement_liquid_sink;
f32 movement_gravity;
+ float physics_override_speed;
+ float physics_override_jump;
+ float physics_override_gravity;
+
u16 hp;
float hurt_tilt_timer;
return 0;
}
+// set_physics_override(self, physics_override_speed, physics_override_jump, physics_override_gravity)
+int ObjectRef::l_set_physics_override(lua_State *L)
+{
+ ObjectRef *ref = checkobject(L, 1);
+ PlayerSAO *co = (PlayerSAO *) getobject(ref);
+ if(co == NULL) return 0;
+ // Do it
+ if(!lua_isnil(L, 2)){
+ co->m_physics_override_speed = lua_tonumber(L, 2);
+ co->m_physics_override_sent = false;
+ }
+ if(!lua_isnil(L, 3)){
+ co->m_physics_override_jump = lua_tonumber(L, 3);
+ co->m_physics_override_sent = false;
+ }
+ if(!lua_isnil(L, 4)){
+ co->m_physics_override_gravity = lua_tonumber(L, 4);
+ co->m_physics_override_sent = false;
+ }
+ return 0;
+}
+
// set_animation(self, frame_range, frame_speed, frame_blend)
int ObjectRef::l_set_animation(lua_State *L)
{
luamethod(ObjectRef, get_wielded_item),
luamethod(ObjectRef, set_wielded_item),
luamethod(ObjectRef, set_armor_groups),
+ luamethod(ObjectRef, set_physics_override),
luamethod(ObjectRef, set_animation),
luamethod(ObjectRef, set_bone_position),
luamethod(ObjectRef, set_attach),
// set_armor_groups(self, groups)
static int l_set_armor_groups(lua_State *L);
+ // set_physics_override(self, physics_override_speed, physics_override_jump, physics_override_gravity)
+ static int l_set_physics_override(lua_State *L);
+
// set_animation(self, frame_range, frame_speed, frame_blend)
static int l_set_animation(lua_State *L);
virtual void setArmorGroups(const ItemGroupList &armor_groups)
{}
+ virtual void setPhysicsOverride(float physics_override_speed, float physics_override_jump, float physics_override_gravity)
+ {}
virtual void setAnimation(v2f frames, float frame_speed, float frame_blend)
{}
virtual void setBonePosition(std::string bone, v3f position, v3f rotation)