Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Code/client/Games/Skyrim/Magic/EffectItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ bool EffectItem::IsVampireLordEffect() const noexcept
return pEffectSetting->eArchetype == EffectArchetypes::ArchetypeID::kVampireLord;
}

bool EffectItem::IsDetectLifeEffect() const noexcept
{
return pEffectSetting->eArchetype == EffectArchetypes::ArchetypeID::kDetectLife;
}

bool EffectItem::IsNightVisionEffect() const noexcept
{
BGSKeyword* pMagicNightEye = Cast<BGSKeyword>(TESForm::GetById(0xad7c6));
Expand Down
1 change: 1 addition & 0 deletions Code/client/Games/Skyrim/Magic/EffectItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct EffectItem
bool IsWerewolfEffect() const noexcept;
bool IsVampireLordEffect() const noexcept;
bool IsNightVisionEffect() const noexcept;
bool IsDetectLifeEffect() const noexcept;

EffectItemData data;
uint32_t padC;
Expand Down
16 changes: 16 additions & 0 deletions Code/client/Games/Skyrim/Magic/MagicTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ bool MagicTarget::AddTarget(AddTargetData& arData, bool aApplyHealPerkBonus, boo

bool MagicTarget::AddTargetData::ShouldSync()
{
// Detect life is an area effect on every actor around the caster, syncing it would show them to other players too.
if (pEffectItem->IsDetectLifeEffect())
return false;

// Constant effect slow time is an ability each client's scripts add and remove on their own player, so a synced
// copy would stay on the other players for good. Fire and forget slow time (shouts) still syncs.
if (pEffectItem->IsSlowEffect())
Expand Down Expand Up @@ -102,6 +106,18 @@ bool TP_MAKE_THISCALL(HookAddTarget, MagicTarget, MagicTarget::AddTargetData& ar
if (arData.pEffectItem->IsVampireLordEffect())
pTargetActorEx->GraphDescriptorHash = AnimationGraphDescriptor_VampireLordBehavior::m_key;

if (arData.pEffectItem->IsDetectLifeEffect() && arData.pCaster)
{
const ActorExtension* pCasterExtension = arData.pCaster->GetExtension();

// The caster's copy repeats the cast on this client, but only the caster gets to see living targets.
if (pCasterExtension->IsRemotePlayer())
return false;

if (pCasterExtension->IsLocalPlayer() && pTargetActorEx->IsRemotePlayer() && World::Get().GetServerSettings().PvpEnabled)
return TiltedPhoques::ThisCall(RealAddTarget, apThis, arData);
}

if (ScopedSpellCastOverride::IsOverriden())
return TiltedPhoques::ThisCall(RealAddTarget, apThis, arData);

Expand Down