1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-12 16:58:39 +00:00

Add GenericCAO and player armor groups, but don't use them yet

This commit is contained in:
Perttu Ahola 2012-03-29 16:10:11 +03:00
parent a9ddbb4beb
commit 443f45eca1
7 changed files with 532 additions and 25 deletions

View file

@ -605,17 +605,6 @@ void LuaEntitySAO::rightClick(ServerActiveObject *clicker)
scriptapi_luaentity_rightclick(L, m_id, clicker);
}
void LuaEntitySAO::setHP(s16 hp)
{
if(hp < 0) hp = 0;
m_hp = hp;
}
s16 LuaEntitySAO::getHP() const
{
return m_hp;
}
void LuaEntitySAO::setPos(v3f pos)
{
m_base_position = pos;
@ -645,6 +634,23 @@ std::string LuaEntitySAO::getDescription()
return os.str();
}
void LuaEntitySAO::setHP(s16 hp)
{
if(hp < 0) hp = 0;
m_hp = hp;
}
s16 LuaEntitySAO::getHP() const
{
return m_hp;
}
void LuaEntitySAO::setArmorGroups(const ItemGroupList &armor_groups)
{
m_armor_groups = armor_groups;
m_armor_groups_sent = false;
}
void LuaEntitySAO::setVelocity(v3f velocity)
{
m_velocity = velocity;
@ -708,12 +714,6 @@ std::string LuaEntitySAO::getName()
return m_init_name;
}
void LuaEntitySAO::setArmorGroups(const ItemGroupList &armor_groups)
{
m_armor_groups = armor_groups;
m_armor_groups_sent = false;
}
void LuaEntitySAO::sendPosition(bool do_interpolate, bool is_movement_end)
{
m_last_sent_move_precision = m_base_position.getDistanceFrom(
@ -766,6 +766,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_):
m_time_from_last_punch(0),
m_wield_index(0),
m_position_not_sent(false),
m_armor_groups_sent(false),
m_teleported(false),
m_inventory_not_sent(false),
m_hp_not_sent(false),
@ -775,6 +776,8 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_):
assert(m_peer_id != 0);
setBasePosition(m_player->getPosition());
m_inventory = &m_player->inventory;
m_armor_groups["choppy"] = 2;
m_armor_groups["fleshy"] = 3;
}
PlayerSAO::~PlayerSAO()
@ -960,12 +963,8 @@ int PlayerSAO::punch(v3f dir,
return 0;
}
// "Material" groups of the player
ItemGroupList groups;
groups["choppy"] = 2;
groups["fleshy"] = 3;
HitParams hitparams = getHitParams(groups, toolcap, time_from_last_punch);
HitParams hitparams = getHitParams(m_armor_groups, toolcap,
time_from_last_punch);
actionstream<<"Player "<<m_player->getName()<<" punched by "
<<puncher->getDescription()<<", damage "<<hitparams.hp
@ -1031,6 +1030,12 @@ void PlayerSAO::setHP(s16 hp)
}
}
void PlayerSAO::setArmorGroups(const ItemGroupList &armor_groups)
{
m_armor_groups = armor_groups;
m_armor_groups_sent = false;
}
Inventory* PlayerSAO::getInventory()
{
return m_inventory;