diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/clientserver.h | 1 | ||||
-rw-r--r-- | src/content_cao.cpp | 5 | ||||
-rw-r--r-- | src/content_sao.cpp | 5 | ||||
-rw-r--r-- | src/object_properties.cpp | 5 | ||||
-rw-r--r-- | src/object_properties.h | 1 | ||||
-rw-r--r-- | src/script/common/c_content.cpp | 1 |
6 files changed, 17 insertions, 1 deletions
diff --git a/src/clientserver.h b/src/clientserver.h index 264da5179..ebfe7f3c7 100644 --- a/src/clientserver.h +++ b/src/clientserver.h @@ -102,6 +102,7 @@ SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time, float time_speed); drowning, leveled and liquid_range added to ContentFeatures stepheight and collideWithObjects added to object properties version, heat and humidity transfer in MapBock + added new property to entities automatic_face_movement_dir */ #define LATEST_PROTOCOL_VERSION 21 diff --git a/src/content_cao.cpp b/src/content_cao.cpp index bbee0bc83..20f5fd3db 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -1210,6 +1210,11 @@ public: m_yaw += dtime * m_prop.automatic_rotate * 180 / M_PI; updateNodePos(); } + + if (getParent() == NULL && m_prop.automatic_face_movement_dir){ + m_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI; + updateNodePos(); + } } void updateTexturePos() diff --git a/src/content_sao.cpp b/src/content_sao.cpp index ed660cf10..f3ccd6db0 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "cpp_api/scriptapi.h" #include "genericobject.h" #include "util/serialize.h" +#include "util/mathconstants.h" std::map<u16, ServerActiveObject::Factory> ServerActiveObject::m_types; @@ -522,6 +523,10 @@ void LuaEntitySAO::step(float dtime, bool send_recommended) * dtime * m_acceleration; m_velocity += dtime * m_acceleration; } + + if(m_prop.automatic_face_movement_dir){ + m_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI; + } } if(m_registered){ diff --git a/src/object_properties.cpp b/src/object_properties.cpp index 1602f03f2..7fad25cce 100644 --- a/src/object_properties.cpp +++ b/src/object_properties.cpp @@ -40,7 +40,8 @@ ObjectProperties::ObjectProperties(): is_visible(true), makes_footstep_sound(false), automatic_rotate(0), - stepheight(0) + stepheight(0), + automatic_face_movement_dir(false) { textures.push_back("unknown_object.png"); colors.push_back(video::SColor(255,255,255,255)); @@ -102,6 +103,7 @@ void ObjectProperties::serialize(std::ostream &os) const } writeU8(os, collideWithObjects); writeF1000(os,stepheight); + writeU8(os, automatic_face_movement_dir); // Add stuff only at the bottom. // Never remove anything, because we don't want new versions of this } @@ -136,6 +138,7 @@ void ObjectProperties::deSerialize(std::istream &is) } collideWithObjects = readU8(is); stepheight = readF1000(is); + automatic_face_movement_dir = readU8(is); }catch(SerializationError &e){} } else diff --git a/src/object_properties.h b/src/object_properties.h index e8188cb60..edc9c39d6 100644 --- a/src/object_properties.h +++ b/src/object_properties.h @@ -45,6 +45,7 @@ struct ObjectProperties bool makes_footstep_sound; float automatic_rotate; f32 stepheight; + bool automatic_face_movement_dir; ObjectProperties(); diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index ca7c7fde9..cb2b0e737 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -190,6 +190,7 @@ void read_object_properties(lua_State *L, int index, getfloatfield(L, -1, "automatic_rotate", prop->automatic_rotate); getfloatfield(L, -1, "stepheight", prop->stepheight); prop->stepheight*=BS; + getboolfield(L, -1, "automatic_face_movement_dir", prop->automatic_face_movement_dir); } /******************************************************************************/ |