Skip to content

Commit 251e3e0

Browse files
sapierPilzAdam
sapier
authored andcommittedJul 30, 2013
Add support for setting stepheight for entities
1 parent ff7c380 commit 251e3e0

7 files changed

+12
-5
lines changed
 

‎doc/lua_api.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,7 @@ Object Properties
18601860
is_visible = true,
18611861
makes_footstep_sound = false,
18621862
automatic_rotate = false,
1863+
stepheight = 0,
18631864
}
18641865

18651866
Entity definition (register_entity)

‎src/clientserver.h

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time, float time_speed);
100100
TOSERVER_BREATH
101101
range added to ItemDefinition
102102
drowning, leveled and liquid_range added to ContentFeatures
103+
stepheight and collideWithObjects added to object properties
103104
*/
104105

105106
#define LATEST_PROTOCOL_VERSION 21

‎src/content_cao.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1150,12 +1150,11 @@ class GenericCAO : public ClientActiveObject
11501150
box.MaxEdge *= BS;
11511151
collisionMoveResult moveresult;
11521152
f32 pos_max_d = BS*0.125; // Distance per iteration
1153-
f32 stepheight = 0;
11541153
v3f p_pos = m_position;
11551154
v3f p_velocity = m_velocity;
11561155
v3f p_acceleration = m_acceleration;
11571156
moveresult = collisionMoveSimple(env,env->getGameDef(),
1158-
pos_max_d, box, stepheight, dtime,
1157+
pos_max_d, box, m_prop.stepheight, dtime,
11591158
p_pos, p_velocity, p_acceleration,
11601159
this, m_prop.collideWithObjects);
11611160
// Apply results

‎src/content_sao.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -505,14 +505,14 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
505505
box.MaxEdge *= BS;
506506
collisionMoveResult moveresult;
507507
f32 pos_max_d = BS*0.25; // Distance per iteration
508-
f32 stepheight = 0; // Maximum climbable step height
509508
v3f p_pos = m_base_position;
510509
v3f p_velocity = m_velocity;
511510
v3f p_acceleration = m_acceleration;
512511
moveresult = collisionMoveSimple(m_env,m_env->getGameDef(),
513-
pos_max_d, box, stepheight, dtime,
512+
pos_max_d, box, m_prop.stepheight, dtime,
514513
p_pos, p_velocity, p_acceleration,
515514
this, m_prop.collideWithObjects);
515+
516516
// Apply results
517517
m_base_position = p_pos;
518518
m_velocity = p_velocity;

‎src/object_properties.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ ObjectProperties::ObjectProperties():
3939
initial_sprite_basepos(0,0),
4040
is_visible(true),
4141
makes_footstep_sound(false),
42-
automatic_rotate(0)
42+
automatic_rotate(0),
43+
stepheight(0)
4344
{
4445
textures.push_back("unknown_object.png");
4546
colors.push_back(video::SColor(255,255,255,255));
@@ -100,6 +101,7 @@ void ObjectProperties::serialize(std::ostream &os) const
100101
writeARGB8(os, colors[i]);
101102
}
102103
writeU8(os, collideWithObjects);
104+
writeF1000(os,stepheight);
103105
// Add stuff only at the bottom.
104106
// Never remove anything, because we don't want new versions of this
105107
}
@@ -133,6 +135,7 @@ void ObjectProperties::deSerialize(std::istream &is)
133135
colors.push_back(readARGB8(is));
134136
}
135137
collideWithObjects = readU8(is);
138+
stepheight = readF1000(is);
136139
}catch(SerializationError &e){}
137140
}
138141
else

‎src/object_properties.h

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct ObjectProperties
4444
bool is_visible;
4545
bool makes_footstep_sound;
4646
float automatic_rotate;
47+
f32 stepheight;
4748

4849

4950
ObjectProperties();

‎src/script/common/c_content.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ void read_object_properties(lua_State *L, int index,
188188
getboolfield(L, -1, "is_visible", prop->is_visible);
189189
getboolfield(L, -1, "makes_footstep_sound", prop->makes_footstep_sound);
190190
getfloatfield(L, -1, "automatic_rotate", prop->automatic_rotate);
191+
getfloatfield(L, -1, "stepheight", prop->stepheight);
192+
prop->stepheight*=BS;
191193
}
192194

193195
/******************************************************************************/

0 commit comments

Comments
 (0)
Please sign in to comment.