#include "tool.h" // For ToolCapabilities
#include "gamedef.h"
#include "player.h"
-#include "scriptapi.h"
+#include "cpp_api/scriptapi.h"
#include "genericobject.h"
#include "util/serialize.h"
return false;
}
+ bool collideWithObjects() {
+ return false;
+ }
+
private:
};
return false;
}
+ bool collideWithObjects() {
+ return false;
+ }
+
private:
float m_timer1;
float m_age;
return false;
}
+ bool collideWithObjects() {
+ return false;
+ }
private:
std::string m_itemstring;
LuaEntitySAO::~LuaEntitySAO()
{
if(m_registered){
- lua_State *L = m_env->getLua();
- scriptapi_luaentity_rm(L, m_id);
+ ENV_TO_SA(m_env)->luaentity_Remove(m_id);
}
}
ServerActiveObject::addedToEnvironment(dtime_s);
// Create entity from name
- lua_State *L = m_env->getLua();
- m_registered = scriptapi_luaentity_add(L, m_id, m_init_name.c_str());
+ m_registered = ENV_TO_SA(m_env)->luaentity_Add(m_id, m_init_name.c_str());
if(m_registered){
// Get properties
- scriptapi_luaentity_get_properties(L, m_id, &m_prop);
+ ENV_TO_SA(m_env)->luaentity_GetProperties(m_id, &m_prop);
// Initialize HP from properties
m_hp = m_prop.hp_max;
// Activate entity, supplying serialized state
- scriptapi_luaentity_activate(L, m_id, m_init_state.c_str(), dtime_s);
+ ENV_TO_SA(m_env)->luaentity_Activate(m_id, m_init_state.c_str(), dtime_s);
}
}
v3f p_acceleration = m_acceleration;
moveresult = collisionMoveSimple(m_env,m_env->getGameDef(),
pos_max_d, box, stepheight, dtime,
- p_pos, p_velocity, p_acceleration);
+ p_pos, p_velocity, p_acceleration,
+ this, m_prop.collideWithObjects);
// Apply results
m_base_position = p_pos;
m_velocity = p_velocity;
}
if(m_registered){
- lua_State *L = m_env->getLua();
- scriptapi_luaentity_step(L, m_id, dtime);
+ ENV_TO_SA(m_env)->luaentity_Step(m_id, dtime);
}
if(send_recommended == false)
os<<serializeString(m_init_name);
// state
if(m_registered){
- lua_State *L = m_env->getLua();
- std::string state = scriptapi_luaentity_get_staticdata(L, m_id);
+ std::string state = ENV_TO_SA(m_env)->luaentity_GetStaticdata(m_id);
os<<serializeLongString(state);
} else {
os<<serializeLongString(m_init_state);
{
setHP(getHP() - result.damage);
+
+ std::string punchername = "nil";
+
+ if ( puncher != 0 )
+ punchername = puncher->getDescription();
+
actionstream<<getDescription()<<" punched by "
- <<puncher->getDescription()<<", damage "<<result.damage
+ <<punchername<<", damage "<<result.damage
<<" hp, health now "<<getHP()<<" hp"<<std::endl;
{
m_removed = true;
}
- lua_State *L = m_env->getLua();
- scriptapi_luaentity_punch(L, m_id, puncher,
+ ENV_TO_SA(m_env)->luaentity_Punch(m_id, puncher,
time_from_last_punch, toolcap, dir);
return result.wear;
// It's best that attachments cannot be clicked
if(isAttached())
return;
- lua_State *L = m_env->getLua();
- scriptapi_luaentity_rightclick(L, m_id, clicker);
+ ENV_TO_SA(m_env)->luaentity_Rightclick(m_id, clicker);
}
void LuaEntitySAO::setPos(v3f pos)
return false;
}
+bool LuaEntitySAO::collideWithObjects(){
+ return m_prop.collideWithObjects;
+}
+
/*
PlayerSAO
*/
m_moved(false),
m_inventory_not_sent(false),
m_hp_not_sent(false),
+ m_breath_not_sent(false),
m_wielded_item_not_sent(false),
m_physics_override_speed(1),
m_physics_override_jump(1),
HitParams hitparams = getHitParams(m_armor_groups, toolcap,
time_from_last_punch);
+ std::string punchername = "nil";
+
+ if ( puncher != 0 )
+ punchername = puncher->getDescription();
+
actionstream<<"Player "<<m_player->getName()<<" punched by "
- <<puncher->getDescription()<<", damage "<<hitparams.hp
+ <<punchername<<", damage "<<hitparams.hp
<<" HP"<<std::endl;
setHP(getHP() - hitparams.hp);
}
}
+u16 PlayerSAO::getBreath() const
+{
+ return m_player->getBreath();
+}
+
+void PlayerSAO::setBreath(u16 breath)
+{
+ m_player->setBreath(breath);
+}
+
void PlayerSAO::setArmorGroups(const ItemGroupList &armor_groups)
{
m_armor_groups = armor_groups;
}
bool PlayerSAO::getCollisionBox(aabb3f *toset) {
- //player collision handling is already done clientside no need to do it twice
- return false;
+ //update collision box
+ *toset = m_player->getCollisionbox();
+
+ toset->MinEdge += m_base_position;
+ toset->MaxEdge += m_base_position;
+
+ return true;
+}
+
+bool PlayerSAO::collideWithObjects(){
+ return true;
}