X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fserver%2Fluaentity_sao.cpp;h=a4b37ee09401a60280ce1eabca0e2f94ae5432e2;hb=303329f2d6bc96f7756c72845de1bd87f62174a1;hp=82f6da2314f8392d66b924844f53d3d6a3a385c2;hpb=85c824ed136269ee3ee0b650406ce80c8a60c014;p=dragonfireclient.git diff --git a/src/server/luaentity_sao.cpp b/src/server/luaentity_sao.cpp index 82f6da231..a4b37ee09 100644 --- a/src/server/luaentity_sao.cpp +++ b/src/server/luaentity_sao.cpp @@ -337,19 +337,9 @@ u32 LuaEntitySAO::punch(v3f dir, if (result.did_punch) { setHP((s32)getHP() - result.damage, PlayerHPChangeReason(PlayerHPChangeReason::PLAYER_PUNCH, puncher)); - - // create message and add to list - sendPunchCommand(); } } - if (getHP() == 0 && !isGone()) { - clearParentAttachment(); - clearChildAttachments(); - m_env->getScriptIface()->luaentity_on_death(m_id, puncher); - markForRemoval(); - } - actionstream << puncher->getDescription() << " (id=" << puncher->getId() << ", hp=" << puncher->getHP() << ") punched " << getDescription() << " (id=" << m_id << ", hp=" << m_hp << @@ -402,6 +392,20 @@ std::string LuaEntitySAO::getDescription() void LuaEntitySAO::setHP(s32 hp, const PlayerHPChangeReason &reason) { m_hp = rangelim(hp, 0, U16_MAX); + + sendPunchCommand(); + + if (m_hp == 0 && !isGone()) { + clearParentAttachment(); + clearChildAttachments(); + if (m_registered) { + ServerActiveObject *killer = nullptr; + if (reason.type == PlayerHPChangeReason::PLAYER_PUNCH) + killer = reason.object; + m_env->getScriptIface()->luaentity_on_death(m_id, killer); + } + markForRemoval(); + } } u16 LuaEntitySAO::getHP() const