Skip to content

Commit

Permalink
feat: trigger mounting
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed Jan 3, 2022
1 parent be717b6 commit 6fe7d4a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
29 changes: 28 additions & 1 deletion Code/client/Games/Skyrim/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,14 @@ void Actor::RemoveFromAllFactions() noexcept
s_pRemoveFromAllFactions(this);
}

TP_THIS_FUNCTION(TInitiateMountPackage, bool, Actor, Actor* apMount);
static TInitiateMountPackage* RealInitiateMountPackage = nullptr;

bool Actor::InitiateMountPackage(Actor* apMount) noexcept
{
return ThisCall(RealInitiateMountPackage, this, apMount);
}

bool Actor::IsDead() noexcept
{
PAPYRUS_FUNCTION(bool, Actor, IsDead);
Expand Down Expand Up @@ -650,7 +658,7 @@ void TP_MAKE_THISCALL(HookUpdateDetectionState, ActorKnowledge, void* apState)

struct DialogueItem;

// This is an AIProcess function
// TODO: This is an AIProcess function
TP_THIS_FUNCTION(TProcessResponse, uint64_t, void, DialogueItem* apVoice, Actor* apTalkingActor, Actor* apTalkedToActor);
static TProcessResponse* RealProcessResponse = nullptr;

Expand All @@ -664,6 +672,22 @@ uint64_t TP_MAKE_THISCALL(HookProcessResponse, void, DialogueItem* apVoice, Acto
return ThisCall(RealProcessResponse, apThis, apVoice, apTalkingActor, apTalkedToActor);
}

bool TP_MAKE_THISCALL(HookInitiateMountPackage, Actor, Actor* apMount)
{
if (!apMount)
{
return ThisCall(RealInitiateMountPackage, apThis, apMount);
}

if (ActorExtension* pMountExt = apMount->GetExtension())
{
if (pMountExt->IsRemote())
return false;
}

return ThisCall(RealInitiateMountPackage, apThis, apMount);
}

static TiltedPhoques::Initializer s_actorHooks([]()
{
POINTER_SKYRIMSE(TCharacterConstructor, s_characterCtor, 0x1406BA280 - 0x140000000);
Expand All @@ -679,6 +703,7 @@ static TiltedPhoques::Initializer s_actorHooks([]()
POINTER_SKYRIMSE(TPickUpItem, s_pickUpItem, 0x14060C280 - 0x140000000);
POINTER_SKYRIMSE(TUpdateDetectionState, s_updateDetectionState, 0x140742FE0 - 0x140000000);
POINTER_SKYRIMSE(TProcessResponse, s_processResponse, 0x14068BC50 - 0x140000000);
POINTER_SKYRIMSE(TInitiateMountPackage, s_initiateMountPackage, 0x14062CF40 - 0x140000000);

FUNC_GetActorLocation = s_GetActorLocation.Get();
RealCharacterConstructor = s_characterCtor.Get();
Expand All @@ -692,6 +717,7 @@ static TiltedPhoques::Initializer s_actorHooks([]()
RealPickUpItem = s_pickUpItem.Get();
RealUpdateDetectionState = s_updateDetectionState.Get();
RealProcessResponse = s_processResponse.Get();
RealInitiateMountPackage = s_initiateMountPackage.Get();

TP_HOOK(&RealCharacterConstructor, HookCharacterConstructor);
TP_HOOK(&RealCharacterConstructor2, HookCharacterConstructor2);
Expand All @@ -704,4 +730,5 @@ static TiltedPhoques::Initializer s_actorHooks([]()
TP_HOOK(&RealPickUpItem, HookPickUpItem);
TP_HOOK(&RealUpdateDetectionState, HookUpdateDetectionState);
TP_HOOK(&RealProcessResponse, HookProcessResponse);
TP_HOOK(&RealInitiateMountPackage, HookInitiateMountPackage);
});
1 change: 1 addition & 0 deletions Code/client/Games/Skyrim/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ struct Actor : TESObjectREFR
void UnEquipAll() noexcept;
void RemoveFromAllFactions() noexcept;
void QueueUpdate() noexcept;
bool InitiateMountPackage(Actor* apMount) noexcept;

bool IsDead() noexcept;
void Kill() noexcept;
Expand Down
5 changes: 4 additions & 1 deletion Code/client/Services/Generic/TestService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,15 @@ void TestService::OnUpdate(const UpdateEvent& acUpdateEvent) noexcept
{
s_f8Pressed = true;

Actor* pActor = (Actor*)TESForm::GetById(0xFF0015AD);
PlayerCharacter::Get()->InitiateMountPackage(pActor);

/*
auto* pActor = (Actor*)TESForm::GetById(0xFF000DA5);
pActor->SetWeaponDrawnEx(true);
//PlaceActorInWorld();
/*
const auto pPlayerBaseForm = static_cast<TESNPC*>(PlayerCharacter::Get()->baseForm);
//const auto pNpc = TESNPC::Create(data, pPlayerBaseForm->GetChangeFlags());
Expand Down

0 comments on commit 6fe7d4a

Please sign in to comment.