Skip to content

Commit

Permalink
feat(magic): intercept SummonCreatureEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed Nov 3, 2021
1 parent d366018 commit 9fa92ac
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Code/client/Games/Skyrim/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
#include <World.h>
#include <Services/PapyrusService.h>

#include <Effects/ValueModifierEffect.h>
#include <Forms/ActorValueInfo.h>

#include <Effects/ValueModifierEffect.h>
#include <Effects/SummonCreatureEffect.h>

#ifdef SAVE_STUFF

#include <Games/Skyrim/SaveLoad.h>
Expand Down Expand Up @@ -499,6 +501,18 @@ static TApplyActorEffect* RealApplyActorEffect = nullptr;

void TP_MAKE_THISCALL(HookApplyActorEffect, ActiveEffect, Actor* apTarget, float aEffectValue, unsigned int unk1)
{
const auto* pSummonCreatureEffect = RTTI_CAST(apThis, ActiveEffect, SummonCreatureEffect);
if (pSummonCreatureEffect)
{
spdlog::warn("SummonCreatureEffect triggered, actor id: {:X}, effect value: {}", apTarget ? apTarget->formID : 0, aEffectValue);
if (apTarget)
{
const auto* pExtendedActor = apTarget->GetExtension();
if (pExtendedActor->IsLocal())
return;
}
}

const auto* pValueModEffect = RTTI_CAST(apThis, ActiveEffect, ValueModifierEffect);

if (pValueModEffect)
Expand Down
8 changes: 8 additions & 0 deletions Code/client/Games/Skyrim/Effects/SummonCreatureEffect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include "ActiveEffect.h"

struct SummonCreatureEffect : ActiveEffect
{

};
4 changes: 4 additions & 0 deletions Code/client/Services/Generic/CharacterService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@ void CharacterService::OnNotifyAttachArrow(const NotifyAttachArrow& acMessage) c

void CharacterService::OnInterruptCast(const InterruptCastEvent& acEvent) const noexcept
{
#if TP_SKYRIM64
auto formId = acEvent.CasterFormID;

auto view = m_world.view<FormIdComponent, LocalComponent>();
Expand All @@ -1149,10 +1150,12 @@ void CharacterService::OnInterruptCast(const InterruptCastEvent& acEvent) const
InterruptCastRequest request;
request.CasterId = localComponent.Id;
m_transport.Send(request);
#endif
}

void CharacterService::OnNotifyInterruptCast(const NotifyInterruptCast& acMessage) const noexcept
{
#if TP_SKYRIM64
auto remoteView = m_world.view<RemoteComponent, FormIdComponent>();
const auto remoteIt = std::find_if(std::begin(remoteView), std::end(remoteView), [remoteView, Id = acMessage.CasterId](auto entity)
{
Expand All @@ -1173,4 +1176,5 @@ void CharacterService::OnNotifyInterruptCast(const NotifyInterruptCast& acMessag
pActor->InterruptCast(false);

spdlog::info("Interrupt remote cast successful");
#endif
}

0 comments on commit 9fa92ac

Please sign in to comment.