1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Entity damage system WIP; Remove C++ mobs

This commit is contained in:
Perttu Ahola 2012-03-04 21:08:03 +02:00
parent f1cb91cd93
commit e9cdb938fe
14 changed files with 516 additions and 3296 deletions

View file

@ -169,16 +169,18 @@ std::string ServerRemotePlayer::getStaticData()
return "";
}
void ServerRemotePlayer::punch(ServerActiveObject *puncher,
int ServerRemotePlayer::punch(v3f dir,
const ToolCapabilities *toolcap,
ServerActiveObject *puncher,
float time_from_last_punch)
{
if(!puncher)
return;
if(!toolcap)
return 0;
// No effect if PvP disabled
if(g_settings->getBool("enable_pvp") == false){
if(puncher->getType() == ACTIVEOBJECT_TYPE_PLAYER)
return;
return 0;
}
// "Material" groups of the player
@ -186,19 +188,13 @@ void ServerRemotePlayer::punch(ServerActiveObject *puncher,
groups["choppy"] = 2;
groups["fleshy"] = 3;
IItemDefManager *idef = m_env->getGameDef()->idef();
ItemStack punchitem = puncher->getWieldedItem();
ToolCapabilities tp = punchitem.getToolCapabilities(idef);
HitParams hitparams = getHitParams(groups, &tp, time_from_last_punch);
HitParams hitparams = getHitParams(groups, toolcap, time_from_last_punch);
actionstream<<"Player "<<getName()<<" punched by "
<<puncher->getDescription()<<", damage "<<hitparams.hp
<<" HP"<<std::endl;
setHP(getHP() - hitparams.hp);
punchitem.addWear(hitparams.wear, idef);
puncher->setWieldedItem(punchitem);
if(hitparams.hp != 0)
{
@ -211,6 +207,8 @@ void ServerRemotePlayer::punch(ServerActiveObject *puncher,
ActiveObjectMessage aom(getId(), false, os.str());
m_messages_out.push_back(aom);
}
return hitparams.wear;
}
void ServerRemotePlayer::rightClick(ServerActiveObject *clicker)