{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)
+- set_physics_override(speed, jump, gravity, sneak, sneak_glitch)
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.
+ sneak and sneak_glitch are booleans, default is true
- hud_add(hud definition): add a HUD element described by HUD def, returns ID number on success
- hud_remove(id): remove the HUD element of the specified id
- hud_change(id, stat, value): change a value of a previously added HUD element
float override_speed = readF1000(is);
float override_jump = readF1000(is);
float override_gravity = readF1000(is);
+ // these are sent inverted so we get true when the server sends nothing
+ bool sneak = !readU8(is);
+ bool sneak_glitch = !readU8(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;
+ player->physics_override_sneak = sneak;
+ player->physics_override_sneak_glitch = sneak_glitch;
}
}
else if(cmd == GENERIC_CMD_SET_ANIMATION)
m_physics_override_speed(1),
m_physics_override_jump(1),
m_physics_override_gravity(1),
+ m_physics_override_sneak(true),
+ m_physics_override_sneak_glitch(true),
m_physics_override_sent(false)
{
assert(m_player);
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
+ os<<serializeLongString(gob_cmd_update_physics_override(m_physics_override_speed,
+ m_physics_override_jump, m_physics_override_gravity, m_physics_override_sneak,
+ m_physics_override_sneak_glitch)); // 5
}
else
{
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);
+ std::string str = gob_cmd_update_physics_override(m_physics_override_speed,
+ m_physics_override_jump, m_physics_override_gravity,
+ m_physics_override_sneak, m_physics_override_sneak_glitch);
// create message and add to list
ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push_back(aom);
float m_physics_override_speed;
float m_physics_override_jump;
float m_physics_override_gravity;
+ bool m_physics_override_sneak;
+ bool m_physics_override_sneak_glitch;
bool m_physics_override_sent;
};
return os.str();
}
-std::string gob_cmd_update_physics_override(float physics_override_speed, float physics_override_jump, float physics_override_gravity)
+std::string gob_cmd_update_physics_override(float physics_override_speed, float physics_override_jump,
+ float physics_override_gravity, bool sneak, bool sneak_glitch)
{
std::ostringstream os(std::ios::binary);
// command
writeF1000(os, physics_override_speed);
writeF1000(os, physics_override_jump);
writeF1000(os, physics_override_gravity);
+ // these are sent inverted so we get true when the server sends nothing
+ writeU8(os, !sneak);
+ writeU8(os, !sneak_glitch);
return os.str();
}
#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_physics_override(float physics_override_speed,
+ float physics_override_jump, float physics_override_gravity, bool sneak, bool sneak_glitch);
std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend);
If sneaking, keep in range from the last walked node and don't
fall off from it
*/
- if(control.sneak && m_sneak_node_exists && !(fly_allowed && g_settings->getBool("free_move")) && !in_liquid)
+ if(control.sneak && m_sneak_node_exists &&
+ !(fly_allowed && g_settings->getBool("free_move")) && !in_liquid &&
+ physics_override_sneak)
{
f32 maxd = 0.5*BS + sneak_max;
v3f lwn_f = intToFloat(m_sneak_node, BS);
// node.
m_need_to_get_new_sneak_node = true;
}
- if(m_need_to_get_new_sneak_node)
+ if(m_need_to_get_new_sneak_node && physics_override_sneak)
{
v3s16 pos_i_bottom = floatToInt(position - v3f(0,BS/2,0), BS);
v2f player_p2df(position.X, position.Z);
// And the node above it has to be nonwalkable
if(nodemgr->get(map->getNode(p+v3s16(0,1,0))).walkable == true)
continue;
+ if (!physics_override_sneak_glitch) {
+ if (nodemgr->get(map->getNode(p+v3s16(0,2,0))).walkable)
+ continue;
+ }
}
catch(InvalidPositionException &e)
{
{
if(m_sneak_node_exists)
return m_sneak_node;
- return floatToInt(getPosition(), BS);
+ return floatToInt(getPosition() - v3f(0, BS, 0), 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;
+ physics_override_speed = 1;
+ physics_override_jump = 1;
+ physics_override_gravity = 1;
+ physics_override_sneak = true;
+ physics_override_sneak_glitch = true;
hud_flags = HUD_FLAG_HOTBAR_VISIBLE | HUD_FLAG_HEALTHBAR_VISIBLE |
HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE |
float physics_override_speed;
float physics_override_jump;
float physics_override_gravity;
+ bool physics_override_sneak;
+ bool physics_override_sneak_glitch;
u16 hp;
return 0;
}
-// set_physics_override(self, physics_override_speed, physics_override_jump, physics_override_gravity)
+// set_physics_override(self, physics_override_speed, physics_override_jump,
+// physics_override_gravity, sneak, sneak_glitch)
int ObjectRef::l_set_physics_override(lua_State *L)
{
ObjectRef *ref = checkobject(L, 1);
co->m_physics_override_gravity = lua_tonumber(L, 4);
co->m_physics_override_sent = false;
}
+ if (lua_isboolean(L, 5)) {
+ co->m_physics_override_sneak = lua_toboolean(L, 5);
+ co->m_physics_override_sent = false;
+ }
+ if (lua_isboolean(L, 6)) {
+ co->m_physics_override_sneak_glitch = lua_toboolean(L, 6);
+ co->m_physics_override_sent = false;
+ }
return 0;
}
// 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)
+ // set_physics_override(self, physics_override_speed, physics_override_jump,
+ // physics_override_gravity, sneak, sneak_glitch)
static int l_set_physics_override(lua_State *L);
// set_animation(self, frame_range, frame_speed, frame_blend)