Add support for entities to automatic face movement direction

This commit is contained in:
sapier 2013-07-31 17:29:25 +02:00 committed by PilzAdam
parent d718b0b34e
commit fc571ad46d
7 changed files with 18 additions and 1 deletions

@ -1863,6 +1863,7 @@ Object Properties
makes_footstep_sound = false,
automatic_rotate = false,
stepheight = 0,
automatic_face_movement_dir = false,
}
Entity definition (register_entity)

@ -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

@ -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()

@ -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){

@ -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

@ -45,6 +45,7 @@ struct ObjectProperties
bool makes_footstep_sound;
float automatic_rotate;
f32 stepheight;
bool automatic_face_movement_dir;
ObjectProperties();

@ -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);
}
/******************************************************************************/