From c81e6da7d3646df45ce126de6c5e46d51665126c Mon Sep 17 00:00:00 2001 From: otsffs <141402668+otsffs@users.noreply.github.com> Date: Tue, 25 Jun 2024 05:11:22 +0800 Subject: [PATCH] fix bound weapon spell (#691) * fix bound weapon * Add nullptr checks --- Code/client/Games/Skyrim/Forms/MagicItem.cpp | 11 +++++++++++ Code/client/Games/Skyrim/Forms/MagicItem.h | 1 + Code/client/Services/Generic/MagicService.cpp | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Code/client/Games/Skyrim/Forms/MagicItem.cpp b/Code/client/Games/Skyrim/Forms/MagicItem.cpp index 4dcf67669..a91e33121 100644 --- a/Code/client/Games/Skyrim/Forms/MagicItem.cpp +++ b/Code/client/Games/Skyrim/Forms/MagicItem.cpp @@ -31,6 +31,17 @@ bool MagicItem::IsBuffSpell() const noexcept } } +bool MagicItem::IsBoundWeaponSpell() noexcept +{ + for (EffectItem* pEffect : listOfEffects) + { + if (pEffect->pEffectSetting && pEffect->pEffectSetting->eArchetype == EffectArchetypes::ArchetypeID::kBoundWeapon) + return true; + } + + return false; +} + EffectItem* MagicItem::GetEffect(const uint32_t aEffectId) noexcept { for (EffectItem* pEffect : listOfEffects) diff --git a/Code/client/Games/Skyrim/Forms/MagicItem.h b/Code/client/Games/Skyrim/Forms/MagicItem.h index ae86b2947..8428bd739 100644 --- a/Code/client/Games/Skyrim/Forms/MagicItem.h +++ b/Code/client/Games/Skyrim/Forms/MagicItem.h @@ -13,6 +13,7 @@ struct MagicItem : TESBoundObject bool IsInvisibilitySpell() const noexcept; bool IsHealingSpell() const noexcept; bool IsBuffSpell() const noexcept; + bool IsBoundWeaponSpell() noexcept; EffectItem* GetEffect(const uint32_t aEffectId) noexcept; diff --git a/Code/client/Services/Generic/MagicService.cpp b/Code/client/Services/Generic/MagicService.cpp index 3f1f500a0..d8f3e62a4 100644 --- a/Code/client/Services/Generic/MagicService.cpp +++ b/Code/client/Services/Generic/MagicService.cpp @@ -298,7 +298,7 @@ void MagicService::OnAddTargetEvent(const AddTargetEvent& acEvent) noexcept // These effects are applied through spell cast sync if (SpellItem* pSpellItem = Cast(TESForm::GetById(acEvent.SpellID))) { - if ((pSpellItem->eCastingType == MagicSystem::CastingType::CONCENTRATION && !pSpellItem->IsHealingSpell()) || pSpellItem->IsWardSpell() || pSpellItem->IsInvisibilitySpell()) + if ((pSpellItem->eCastingType == MagicSystem::CastingType::CONCENTRATION && !pSpellItem->IsHealingSpell()) || pSpellItem->IsWardSpell() || pSpellItem->IsInvisibilitySpell() || pSpellItem->IsBoundWeaponSpell()) { return; }