diff --git a/skymp5-server/cpp/server_guest_lib/ActionListener.cpp b/skymp5-server/cpp/server_guest_lib/ActionListener.cpp index 6bdee38b18..56cb0b713c 100644 --- a/skymp5-server/cpp/server_guest_lib/ActionListener.cpp +++ b/skymp5-server/cpp/server_guest_lib/ActionListener.cpp @@ -856,48 +856,48 @@ void ActionListener::OnHit(const RawMessageData& rawMsgData_, float healthPercentage = currentActorValues.healthPercentage; - bool isRemoteBowAttack = false; - - auto sourceLookupResult = - targetActor.GetParent()->GetEspm().GetBrowser().LookupById(hitData.source); - if (sourceLookupResult.rec && - sourceLookupResult.rec->GetType() == espm::WEAP::kType) { - auto weapData = - espm::GetData(hitData.source, targetActor.GetParent()); - if (weapData.weapDNAM) { - if (weapData.weapDNAM->animType == espm::WEAP::AnimType::Bow || - weapData.weapDNAM->animType == espm::WEAP::AnimType::Crossbow) { - if (!hitData.isBashAttack) { - isRemoteBowAttack = true; + if (targetActor.IsBlockActive()) { + if (ShouldBeBlocked(*aggressor, targetActor)) { + bool isRemoteBowAttack = false; + + auto sourceLookupResult = + targetActor.GetParent()->GetEspm().GetBrowser().LookupById( + hitData.source); + if (sourceLookupResult.rec && + sourceLookupResult.rec->GetType() == espm::WEAP::kType) { + auto weapData = + espm::GetData(hitData.source, targetActor.GetParent()); + if (weapData.weapDNAM) { + if (weapData.weapDNAM->animType == espm::WEAP::AnimType::Bow || + weapData.weapDNAM->animType == espm::WEAP::AnimType::Crossbow) { + if (!hitData.isBashAttack) { + isRemoteBowAttack = true; + } + } } } - } - } - - bool isBlockingByShield = false; - auto targetActorEquipmentEntries = targetActor.GetEquipment().inv.entries; - for (auto& entry : targetActorEquipmentEntries) { - if (entry.extra.worn != Inventory::Worn::None) { - auto res = targetActor.GetParent()->GetEspm().GetBrowser().LookupById( - entry.baseId); - if (res.rec && res.rec->GetType() == espm::ARMO::kType) { - auto data = - espm::GetData(entry.baseId, targetActor.GetParent()); - bool isShield = data.equipSlotId > 0; - if (isShield) { - isBlockingByShield = isShield; + bool isBlockingByShield = false; + + auto targetActorEquipmentEntries = + targetActor.GetEquipment().inv.entries; + for (auto& entry : targetActorEquipmentEntries) { + if (entry.extra.worn != Inventory::Worn::None) { + auto res = + targetActor.GetParent()->GetEspm().GetBrowser().LookupById( + entry.baseId); + if (res.rec && res.rec->GetType() == espm::ARMO::kType) { + auto data = + espm::GetData(entry.baseId, targetActor.GetParent()); + bool isShield = data.equipSlotId > 0; + if (isShield) { + isBlockingByShield = isShield; + } + } } } - } - } - - spdlog::trace("isRemoteBowAttack={}, isBlockingByShield={}", - isRemoteBowAttack, isBlockingByShield); - if (!isRemoteBowAttack || isBlockingByShield) { - if (targetActor.IsBlockActive()) { - if (ShouldBeBlocked(*aggressor, targetActor)) { + if (!isRemoteBowAttack || isBlockingByShield) { hitData.isHitBlocked = true; } }