Skip to content

Commit

Permalink
Add support for setting stepheight for entities
Browse files Browse the repository at this point in the history
  • Loading branch information
sapier authored and PilzAdam committed Jul 30, 2013
1 parent ff7c380 commit 251e3e0
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions doc/lua_api.txt
Expand Up @@ -1860,6 +1860,7 @@ Object Properties
is_visible = true,
makes_footstep_sound = false,
automatic_rotate = false,
stepheight = 0,
}

Entity definition (register_entity)
Expand Down
1 change: 1 addition & 0 deletions src/clientserver.h
Expand Up @@ -100,6 +100,7 @@ SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time, float time_speed);
TOSERVER_BREATH
range added to ItemDefinition
drowning, leveled and liquid_range added to ContentFeatures
stepheight and collideWithObjects added to object properties
*/

#define LATEST_PROTOCOL_VERSION 21
Expand Down
3 changes: 1 addition & 2 deletions src/content_cao.cpp
Expand Up @@ -1150,12 +1150,11 @@ class GenericCAO : public ClientActiveObject
box.MaxEdge *= BS;
collisionMoveResult moveresult;
f32 pos_max_d = BS*0.125; // Distance per iteration
f32 stepheight = 0;
v3f p_pos = m_position;
v3f p_velocity = m_velocity;
v3f p_acceleration = m_acceleration;
moveresult = collisionMoveSimple(env,env->getGameDef(),
pos_max_d, box, stepheight, dtime,
pos_max_d, box, m_prop.stepheight, dtime,
p_pos, p_velocity, p_acceleration,
this, m_prop.collideWithObjects);
// Apply results
Expand Down
4 changes: 2 additions & 2 deletions src/content_sao.cpp
Expand Up @@ -505,14 +505,14 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
box.MaxEdge *= BS;
collisionMoveResult moveresult;
f32 pos_max_d = BS*0.25; // Distance per iteration
f32 stepheight = 0; // Maximum climbable step height
v3f p_pos = m_base_position;
v3f p_velocity = m_velocity;
v3f p_acceleration = m_acceleration;
moveresult = collisionMoveSimple(m_env,m_env->getGameDef(),
pos_max_d, box, stepheight, dtime,
pos_max_d, box, m_prop.stepheight, dtime,
p_pos, p_velocity, p_acceleration,
this, m_prop.collideWithObjects);

// Apply results
m_base_position = p_pos;
m_velocity = p_velocity;
Expand Down
5 changes: 4 additions & 1 deletion src/object_properties.cpp
Expand Up @@ -39,7 +39,8 @@ ObjectProperties::ObjectProperties():
initial_sprite_basepos(0,0),
is_visible(true),
makes_footstep_sound(false),
automatic_rotate(0)
automatic_rotate(0),
stepheight(0)
{
textures.push_back("unknown_object.png");
colors.push_back(video::SColor(255,255,255,255));
Expand Down Expand Up @@ -100,6 +101,7 @@ void ObjectProperties::serialize(std::ostream &os) const
writeARGB8(os, colors[i]);
}
writeU8(os, collideWithObjects);
writeF1000(os,stepheight);
// Add stuff only at the bottom.
// Never remove anything, because we don't want new versions of this
}
Expand Down Expand Up @@ -133,6 +135,7 @@ void ObjectProperties::deSerialize(std::istream &is)
colors.push_back(readARGB8(is));
}
collideWithObjects = readU8(is);
stepheight = readF1000(is);
}catch(SerializationError &e){}
}
else
Expand Down
1 change: 1 addition & 0 deletions src/object_properties.h
Expand Up @@ -44,6 +44,7 @@ struct ObjectProperties
bool is_visible;
bool makes_footstep_sound;
float automatic_rotate;
f32 stepheight;


ObjectProperties();
Expand Down
2 changes: 2 additions & 0 deletions src/script/common/c_content.cpp
Expand Up @@ -188,6 +188,8 @@ void read_object_properties(lua_State *L, int index,
getboolfield(L, -1, "is_visible", prop->is_visible);
getboolfield(L, -1, "makes_footstep_sound", prop->makes_footstep_sound);
getfloatfield(L, -1, "automatic_rotate", prop->automatic_rotate);
getfloatfield(L, -1, "stepheight", prop->stepheight);
prop->stepheight*=BS;
}

/******************************************************************************/
Expand Down

0 comments on commit 251e3e0

Please sign in to comment.