Ignore punches with no damage in the actionstream

master
SmallJoker 2015-03-11 20:52:47 +01:00 committed by est31
parent ecdfbfc8dc
commit bb5f830d16
1 changed files with 18 additions and 23 deletions

View File

@ -442,21 +442,17 @@ int LuaEntitySAO::punch(v3f dir,
punchitem, punchitem,
time_from_last_punch); time_from_last_punch);
if(result.did_punch) if (result.did_punch) {
{
setHP(getHP() - result.damage); setHP(getHP() - result.damage);
if (result.damage > 0) {
std::string punchername = "nil"; std::string punchername = puncher ? puncher->getDescription() : "nil";
if ( puncher != 0 )
punchername = puncher->getDescription();
actionstream << getDescription() << " punched by " actionstream << getDescription() << " punched by "
<< punchername << ", damage " << result.damage << punchername << ", damage " << result.damage
<< " hp, health now " << getHP() << " hp" << std::endl; << " hp, health now " << getHP() << " hp" << std::endl;
}
{
std::string str = gob_cmd_punched(result.damage, getHP()); std::string str = gob_cmd_punched(result.damage, getHP());
// create message and add to list // create message and add to list
ActiveObjectMessage aom(getId(), true, str); ActiveObjectMessage aom(getId(), true, str);
@ -465,7 +461,6 @@ int LuaEntitySAO::punch(v3f dir,
if (getHP() == 0) if (getHP() == 0)
m_removed = true; m_removed = true;
}
m_env->getScriptIface()->luaentity_Punch(m_id, puncher, m_env->getScriptIface()->luaentity_Punch(m_id, puncher,
time_from_last_punch, toolcap, dir); time_from_last_punch, toolcap, dir);