diff --git a/L2BotCore/Domain/Entities/Hero.h b/L2BotCore/Domain/Entities/Hero.h index 2eecbd2..c69a971 100644 --- a/L2BotCore/Domain/Entities/Hero.h +++ b/L2BotCore/Domain/Entities/Hero.h @@ -93,10 +93,6 @@ namespace L2Bot::Domain::Entities { m_AttackerIds.clear(); } - void MarkAsDead() - { - m_VitalStats.MarkAsDead(); - } const std::vector BuildSerializationNodes() const override { diff --git a/L2BotCore/Domain/Entities/Player.h b/L2BotCore/Domain/Entities/Player.h index 87e8849..d9d5c42 100644 --- a/L2BotCore/Domain/Entities/Player.h +++ b/L2BotCore/Domain/Entities/Player.h @@ -34,10 +34,6 @@ namespace L2Bot::Domain::Entities { return "player"; } - void MarkAsDead() - { - m_VitalStats.MarkAsDead(); - } const std::vector BuildSerializationNodes() const override { diff --git a/L2BotCore/Domain/ValueObjects/VitalStats.h b/L2BotCore/Domain/ValueObjects/VitalStats.h index e58e93e..c2392a2 100644 --- a/L2BotCore/Domain/ValueObjects/VitalStats.h +++ b/L2BotCore/Domain/ValueObjects/VitalStats.h @@ -12,7 +12,7 @@ namespace L2Bot::Domain::ValueObjects public: const bool IsDead() const { - return m_IsDead || (m_MaxHp > 0 && m_Hp < 0); + return m_IsDead || (m_MaxHp > 0 && m_Hp <= 0); } const uint32_t GetMaxHp() const { @@ -70,7 +70,7 @@ namespace L2Bot::Domain::ValueObjects { L"mp", std::to_wstring(m_Mp) }, { L"maxCp", std::to_wstring(m_MaxCp) }, { L"cp", std::to_wstring(m_Cp) }, - { L"isDead", std::to_wstring(m_IsDead) } + { L"isDead", std::to_wstring(IsDead()) } }; } void MarkAsDead() diff --git a/L2BotDll/Versions/Interlude/Repositories/HeroRepository.h b/L2BotDll/Versions/Interlude/Repositories/HeroRepository.h index 9baa4a0..ee9d5ca 100644 --- a/L2BotDll/Versions/Interlude/Repositories/HeroRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/HeroRepository.h @@ -83,7 +83,6 @@ namespace Interlude { Services::ServiceLocator::GetInstance().GetLogger()->App(L"{} died", m_Hero->GetFullName().GetNickname()); m_Hero->ClearAttackers(); - m_Hero->MarkAsDead(); } else { diff --git a/L2BotDll/Versions/Interlude/Repositories/PlayerRepository.h b/L2BotDll/Versions/Interlude/Repositories/PlayerRepository.h index d21bae5..8452b56 100644 --- a/L2BotDll/Versions/Interlude/Repositories/PlayerRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/PlayerRepository.h @@ -46,13 +46,6 @@ namespace Interlude m_Players.clear(); } - void Init() override - { - Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::CreatureDiedEvent::name, [this](const Events::Event& evt) { - OnCreatureDied(evt); - }); - } - PlayerRepository(const NetworkHandlerWrapper& networkHandler, const PlayerFactory& factory, const uint16_t radius) : m_NetworkHandler(networkHandler), m_Factory(factory), @@ -64,18 +57,6 @@ namespace Interlude PlayerRepository() = delete; virtual ~PlayerRepository() = default; - void OnCreatureDied(const Events::Event& evt) - { - std::shared_lock(m_Mutex); - if (evt.GetName() == Events::CreatureDiedEvent::name) - { - const auto casted = static_cast(evt); - if (m_Players.find(casted.GetCreatureId()) != m_Players.end()) { - m_Players[casted.GetCreatureId()]->MarkAsDead(); - } - } - } - private: const PlayerFactory& m_Factory; const NetworkHandlerWrapper& m_NetworkHandler;