^ rotation = {x=num, y=num, z=num}
- set_properties(object property table)
LuaEntitySAO-only: (no-op for other objects)
-- setvelocity({x=num, y=num, z=num})
+- setvelocity({x=num, y=num, z=num}, time, {x=num, y=num, z=num})
+ ^ velocity to set, time to apply this velocity (optional), value after time passed(optional)
- getvelocity() -> {x=num, y=num, z=num}
-- setacceleration({x=num, y=num, z=num})
+- setacceleration({x=num, y=num, z=num}, time, {x=num, y=num, z=num})
+^ acceleration to set, time to apply this acceleration (optional), value after time passed(optional)
- getacceleration() -> {x=num, y=num, z=num}
- setyaw(radians)
- getyaw() -> radians
void GenericCAO::removeFromScene(bool permanent)
{
// Should be true when removing the object permanently and false when refreshing (eg: updating visuals)
- if((m_env != NULL) && (permanent))
+ if((m_env != NULL) && (permanent))
{
for(std::vector<u16>::iterator ci = m_children.begin();
ci != m_children.end(); ci++)
} else {
v3f lastpos = pos_translator.vect_show;
+ if ((m_vel_time_left > 0) && ((m_vel_time_left - dtime) < 0)) {
+ m_velocity = m_vel_reset_value;
+ }
+
+ if ((m_accel_time_left > 0) && ((m_accel_time_left - dtime) < 0)) {
+ m_acceleration = m_accel_reset_value;
+ }
+
if(m_prop.physical)
{
core::aabbox3d<f32> box = m_prop.collisionbox;
}
}
+ if (m_accel_time_left > 0) {
+ m_accel_time_left -= dtime;
+ }
+
+ if (m_vel_time_left > 0) {
+ m_vel_time_left -= dtime;
+ }
+
m_anim_timer += dtime;
if(m_anim_timer >= m_anim_framelength)
{
} else {
pos_translator.init(m_position);
}
+
+ // read more detailed movement information available from new servers only
+ try {
+ m_accel_time_left = readF1000(is);
+ m_accel_reset_value = readV3F1000(is);
+ m_vel_time_left = readF1000(is);
+ m_vel_reset_value = readV3F1000(is);
+ }
+ catch(SerializationError &e) {}
+
updateNodePos();
}
else if(cmd == GENERIC_CMD_SET_TEXTURE_MOD) {
u8 m_last_light;
bool m_is_visible;
+ float m_accel_time_left;
+ float m_vel_time_left;
+ v3f m_accel_reset_value;
+ v3f m_vel_reset_value;
+
std::vector<u16> m_children;
public:
m_last_sent_position_timer(0),
m_last_sent_move_precision(0),
m_armor_groups_sent(false),
+ m_accel_time_left(-1),
+ m_accel_reset_value(v3f(0,0,0)),
+ m_vel_time_left(-1),
+ m_vel_reset_value(v3f(0,0,0)),
m_animation_speed(0),
m_animation_blend(0),
m_animation_sent(false),
m_velocity += dtime * m_acceleration;
}
+
+ if ((m_vel_time_left > 0) && ((m_vel_time_left - dtime) < 0)) {
+ m_velocity = m_vel_reset_value;
+ }
+
+ if ((m_accel_time_left > 0) && ((m_accel_time_left - dtime) < 0)) {
+ m_acceleration = m_accel_reset_value;
+ }
+
if((m_prop.automatic_face_movement_dir) &&
(fabs(m_velocity.Z) > 0.001 || fabs(m_velocity.X) > 0.001)){
m_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI + m_prop.automatic_face_movement_dir_offset;
}
}
+ if (m_accel_time_left > 0) {
+ m_accel_time_left -= dtime;
+ }
+
+ if (m_vel_time_left > 0) {
+ m_vel_time_left -= dtime;
+ }
+
if(m_registered){
m_env->getScriptIface()->luaentity_Step(m_id, dtime);
}
return 0;
}
- // It's best that attachments cannot be punched
+ // It's best that attachments cannot be punched
if(isAttached())
return 0;
m_properties_sent = false;
}
-void LuaEntitySAO::setVelocity(v3f velocity)
+void LuaEntitySAO::setVelocity(v3f velocity, float application_time,
+ v3f reset_value)
{
m_velocity = velocity;
+ m_vel_time_left = application_time;
+ m_vel_reset_value = reset_value;
}
v3f LuaEntitySAO::getVelocity()
return m_velocity;
}
-void LuaEntitySAO::setAcceleration(v3f acceleration)
+void LuaEntitySAO::setAcceleration(v3f acceleration, float application_time,
+ v3f reset_value)
{
m_acceleration = acceleration;
+ m_accel_time_left = application_time;
+ m_accel_reset_value = reset_value;
}
v3f LuaEntitySAO::getAcceleration()
m_yaw,
do_interpolate,
is_movement_end,
- update_interval
+ update_interval,
+ m_accel_time_left,
+ m_accel_reset_value,
+ m_vel_time_left,
+ m_vel_reset_value
);
// create message and add to list
ActiveObjectMessage aom(getId(), false, str);
ServerActiveObject *puncher,
float time_from_last_punch)
{
- // It's best that attachments cannot be punched
+ // It's best that attachments cannot be punched
if(isAttached())
return 0;
ObjectProperties* accessObjectProperties();
void notifyObjectPropertiesModified();
/* LuaEntitySAO-specific */
- void setVelocity(v3f velocity);
+ void setVelocity(v3f velocity, float application_time, v3f reset_value);
v3f getVelocity();
- void setAcceleration(v3f acceleration);
+ void setAcceleration(v3f acceleration, float application_time, v3f reset_value);
v3f getAcceleration();
void setYaw(float yaw);
float getYaw();
float m_last_sent_move_precision;
bool m_armor_groups_sent;
+
+ float m_accel_time_left;
+ v3f m_accel_reset_value;
+ float m_vel_time_left;
+ v3f m_vel_reset_value;
+
v2f m_animation_range;
float m_animation_speed;
float m_animation_blend;
f32 yaw,
bool do_interpolate,
bool is_movement_end,
- f32 update_interval
+ f32 update_interval,
+ float accel_time_left,
+ v3f accel_reset_value,
+ float m_vel_time_left,
+ v3f vel_reset_value
){
std::ostringstream os(std::ios::binary);
// command
writeU8(os, is_movement_end);
// update_interval (for interpolation)
writeF1000(os, update_interval);
+ // update automatic acceleration disable values
+ writeF1000(os, accel_time_left);
+ writeV3F1000(os, accel_reset_value);
+ // update automatic velocity disable values
+ writeF1000(os, m_vel_time_left);
+ writeV3F1000(os, vel_reset_value);
+
return os.str();
}
std::string gob_cmd_set_texture_mod(const std::string &mod)
{
std::ostringstream os(std::ios::binary);
- // command
+ // command
writeU8(os, GENERIC_CMD_SET_TEXTURE_MOD);
// parameters
os<<serializeString(mod);
std::string gob_cmd_punched(s16 damage, s16 result_hp)
{
std::ostringstream os(std::ios::binary);
- // command
+ // command
writeU8(os, GENERIC_CMD_PUNCHED);
// damage
writeS16(os, damage);
float physics_override_gravity, bool sneak, bool sneak_glitch)
{
std::ostringstream os(std::ios::binary);
- // command
+ // command
writeU8(os, GENERIC_CMD_SET_PHYSICS_OVERRIDE);
// parameters
writeF1000(os, physics_override_speed);
std::string gob_cmd_update_animation(v2f frames, float frame_speed, float frame_blend)
{
std::ostringstream os(std::ios::binary);
- // command
+ // command
writeU8(os, GENERIC_CMD_SET_ANIMATION);
// parameters
writeV2F1000(os, frames);
std::string gob_cmd_update_bone_position(std::string bone, v3f position, v3f rotation)
{
std::ostringstream os(std::ios::binary);
- // command
+ // command
writeU8(os, GENERIC_CMD_SET_BONE_POSITION);
// parameters
os<<serializeString(bone);
std::string gob_cmd_update_attachment(int parent_id, std::string bone, v3f position, v3f rotation)
{
std::ostringstream os(std::ios::binary);
- // command
+ // command
writeU8(os, GENERIC_CMD_SET_ATTACHMENT);
// parameters
writeS16(os, parent_id);
f32 yaw,
bool do_interpolate,
bool is_movement_end,
- f32 update_interval
+ f32 update_interval,
+ float accel_time_left = -1,
+ v3f accel_reset_value = v3f(0,0,0),
+ float m_vel_time_left = -1,
+ v3f vel_reset_value = v3f(0,0,0)
);
std::string gob_cmd_set_texture_mod(const std::string &mod);
LuaEntitySAO *co = getluaobject(ref);
if(co == NULL) return 0;
v3f pos = checkFloatPos(L, 2);
+ float application_time = -1;
+ v3f reset_value = v3f(0,0,0);
+
+ if(!lua_isnoneornil(L, 3))
+ application_time = lua_tonumber(L, 3);
+
+ if(!lua_isnoneornil(L, 4))
+ reset_value = checkFloatPos(L, 4);
+
// Do it
- co->setVelocity(pos);
+ co->setVelocity(pos, application_time, reset_value);
return 0;
}
if(co == NULL) return 0;
// pos
v3f pos = checkFloatPos(L, 2);
+ float application_time = -1;
+ v3f reset_value = v3f(0,0,0);
+
+ if(!lua_isnoneornil(L, 3))
+ application_time = lua_tonumber(L, 3);
+
+ if(!lua_isnoneornil(L, 4))
+ reset_value = checkFloatPos(L, 4);
+
// Do it
- co->setAcceleration(pos);
+ co->setAcceleration(pos, application_time, reset_value);
return 0;
}