From 06ed6387c22c6998954af05a0df7100136c64f8d Mon Sep 17 00:00:00 2001 From: shad0wshayd3 Date: Mon, 1 Jan 2024 15:40:39 -0700 Subject: [PATCH] Misc Blood Magic Defs I forgot to submit a PR for these a year ago --- include/RE/A/AIProcess.h | 3 +++ include/RE/A/Actor.h | 2 ++ include/RE/G/GFxValue.h | 2 ++ include/RE/H/HUDMenu.h | 7 +++++++ include/RE/M/MagicCaster.h | 1 + include/RE/M/MagicTarget.h | 13 ++++++------ include/RE/P/PlayerCharacter.h | 1 + include/RE/T/TESObjectREFR.h | 1 + include/RE/T/TutorialMenu.h | 7 +++++++ src/RE/A/AIProcess.cpp | 36 ++++++++++++++++++++++++++++++++++ src/RE/A/Actor.cpp | 15 ++++++++++++++ src/RE/G/GFxValue.cpp | 13 ++++++++++++ src/RE/M/MagicCaster.cpp | 9 ++++++++- src/RE/M/MagicSystem.cpp | 35 ++++++++++++++++++--------------- src/RE/M/MagicTarget.cpp | 10 ++++++++++ src/RE/P/PlayerCharacter.cpp | 7 +++++++ src/RE/T/TESObjectREFR.cpp | 7 +++++++ 17 files changed, 146 insertions(+), 23 deletions(-) diff --git a/include/RE/A/AIProcess.h b/include/RE/A/AIProcess.h index d7581313a..0d1c6b537 100644 --- a/include/RE/A/AIProcess.h +++ b/include/RE/A/AIProcess.h @@ -1,6 +1,7 @@ #pragma once #include "RE/A/ActorPackage.h" +#include "RE/A/ActorValues.h" #include "RE/B/BGSDefaultObjectManager.h" #include "RE/B/BSTArray.h" #include "RE/B/BSTList.h" @@ -161,6 +162,7 @@ namespace RE [[nodiscard]] bool GetIsSummonedCreature() const noexcept; NiAVObject* GetMagicNode(const BSTSmartPointer& a_biped) const; ObjectRefHandle GetOccupiedFurniture() const; + float GetRegenDelay(ActorValue a_actorvalue) const; TESPackage* GetRunningPackage() const; Actor* GetUserData() const; float GetVoiceRecoveryTime() const; @@ -181,6 +183,7 @@ namespace RE bool SetupSpecialIdle(Actor* a_actor, DEFAULT_OBJECT a_action, TESIdleForm* a_idle, bool a_arg5, bool a_arg6, TESObjectREFR* a_target); void StopCurrentIdle(Actor* a_actor, bool a_forceIdleStop); void Update3DModel(Actor* a_actor); + void UpdateRegenDelay(ActorValue a_actorValue, float a_regenDelay); // members MiddleLowProcessData* middleLow; // 000 diff --git a/include/RE/A/Actor.h b/include/RE/A/Actor.h index 38017deb7..656bc0e73 100644 --- a/include/RE/A/Actor.h +++ b/include/RE/A/Actor.h @@ -543,6 +543,7 @@ namespace RE double GetMoveDirectionRelativeToFacing(); ObjectRefHandle GetOccupiedFurniture() const; TESRace* GetRace() const; + float GetRegenDelay(ActorValue a_actorValue) const; bool GetRider(NiPointer& a_outRider); [[nodiscard]] TESObjectARMO* GetSkin() const; [[nodiscard]] TESObjectARMO* GetSkin(BGSBipedObjectForm::BipedObjectSlot a_slot, bool a_noInit = false); @@ -616,6 +617,7 @@ namespace RE void UpdateAwakeSound(NiAVObject* a_obj3D); void Update3DModel(); void UpdateHairColor(); + void UpdateRegenDelay(ActorValue a_actorValue, float a_regenDelay); void UpdateSkinColor(); void UpdateWeaponAbility(TESForm* a_weapon, ExtraDataList* a_extraData, bool a_leftHand); void VisitArmorAddon(TESObjectARMO* a_armor, TESObjectARMA* a_arma, std::function a_visitor); diff --git a/include/RE/G/GFxValue.h b/include/RE/G/GFxValue.h index fde0dd501..e9965649b 100644 --- a/include/RE/G/GFxValue.h +++ b/include/RE/G/GFxValue.h @@ -260,6 +260,7 @@ namespace RE bool SetText(void* a_data, const char* a_text, bool a_isHTML); bool AttachMovie(void* a_data, GFxValue* a_movieClip, const char* a_symbolName, const char* a_instanceName, std::int32_t a_depth, const GFxValue* a_initObj); + bool CreateEmptyMovieClip(void* a_data, GFxValue* a_movieClip, const char* a_instanceName, std::int32_t a_depth); bool GotoAndPlay(void* a_data, const char* a_frame, bool a_stop); bool IsSameContext(const ObjectInterface* a_rhs) const; @@ -399,6 +400,7 @@ namespace RE // AS MovieClip support. Valid for MovieClips. bool AttachMovie(GFxValue* a_movieClip, const char* a_symbolName, const char* a_instanceName, std::int32_t a_depth = -1, const GFxValue* a_initObj = nullptr); + bool CreateEmptyMovieClip(GFxValue* a_movieClip, const char* a_instanceName, std::int32_t a_depth = -1); bool GotoAndPlay(const char* a_frame); bool GotoAndStop(const char* a_frame); diff --git a/include/RE/H/HUDMenu.h b/include/RE/H/HUDMenu.h index 21d676b58..edfceee1f 100644 --- a/include/RE/H/HUDMenu.h +++ b/include/RE/H/HUDMenu.h @@ -40,6 +40,13 @@ namespace RE // override (BSTEventSink) BSEventNotifyControl ProcessEvent(const BSRemoteGamepadEvent* a_event, BSTEventSource* a_eventSource) override; // 01 + static void FlashMeter(ActorValue a_actorValue) + { + using func_t = decltype(&HUDMenu::FlashMeter); + REL::Relocation func{ RELOCATION_ID(51907, 52845) }; + return func(a_actorValue); + } + static void UpdateCrosshairMagicTarget(bool a_valid) { using func_t = decltype(&HUDMenu::UpdateCrosshairMagicTarget); diff --git a/include/RE/M/MagicCaster.h b/include/RE/M/MagicCaster.h index 619e73c7a..63df5cca6 100644 --- a/include/RE/M/MagicCaster.h +++ b/include/RE/M/MagicCaster.h @@ -78,6 +78,7 @@ namespace RE float GetCurrentSpellCost(); void InterruptCast(bool a_refund); void PlayReleaseSound(MagicItem* a_item); + void SetCurrentSpell(MagicItem* a_item); bool TestProjectilePlacement(const Effect& a_effect, const bhkPickData& a_pickData); void UpdateImpl(float a_delta); diff --git a/include/RE/M/MagicTarget.h b/include/RE/M/MagicTarget.h index f36dd9277..45bb4009b 100644 --- a/include/RE/M/MagicTarget.h +++ b/include/RE/M/MagicTarget.h @@ -86,12 +86,13 @@ namespace RE virtual float CheckResistance(MagicItem* a_magicItem, Effect* a_effect, TESBoundObject* a_object); // 0A - { return 1.0; } virtual bool CheckAbsorb(Actor* a_actor, MagicItem* a_magicItem, const Effect* a_effect); // 0B - { return false; } - bool DispelEffect(MagicItem* a_spell, BSPointerHandle& a_caster, ActiveEffect* a_effect = nullptr); - void DispelEffectsWithArchetype(Archetype a_type, bool a_force); - bool HasEffectWithArchetype(Archetype a_type); - bool HasMagicEffect(EffectSetting* a_effect); - bool HasMagicEffectWithKeyword(BGSKeyword* a_keyword, std::uint64_t a_arg2); - void VisitEffects(ForEachActiveEffectVisitor& visitor); + bool DispelEffect(MagicItem* a_spell, BSPointerHandle& a_caster, ActiveEffect* a_effect = nullptr); + void DispelEffectsWithArchetype(Archetype a_type, bool a_force); + Actor* GetTargetAsActor(); + bool HasEffectWithArchetype(Archetype a_type); + bool HasMagicEffect(EffectSetting* a_effect); + bool HasMagicEffectWithKeyword(BGSKeyword* a_keyword, std::uint64_t a_arg2); + void VisitEffects(ForEachActiveEffectVisitor& visitor); // members SpellDispelData* postUpdateDispelList; // 08 diff --git a/include/RE/P/PlayerCharacter.h b/include/RE/P/PlayerCharacter.h index 267d362a1..2bd604d56 100644 --- a/include/RE/P/PlayerCharacter.h +++ b/include/RE/P/PlayerCharacter.h @@ -367,6 +367,7 @@ namespace RE TintMask* GetTintMask(std::uint32_t a_tintType, std::uint32_t a_index); bool HasActorDoingCommand() const; bool IsGrabbing() const; + void PlayMagicFailureSound(MagicSystem::SpellType a_spellType); void PlayPickupEvent(TESForm* a_item, TESForm* a_containerOwner, TESObjectREFR* a_containerRef, EventType a_eventType); void SetAIDriven(bool a_enable); void SetEscaping(bool a_flag, bool a_escaped); diff --git a/include/RE/T/TESObjectREFR.h b/include/RE/T/TESObjectREFR.h index f711cf017..a26df60ae 100644 --- a/include/RE/T/TESObjectREFR.h +++ b/include/RE/T/TESObjectREFR.h @@ -366,6 +366,7 @@ namespace RE ObjectRefHandle CreateRefHandle(); void DoTrap(TrapData& a_data); void DoTrap(TrapEntry* a_trap, TargetEntry* a_target); + void Enable(bool a_resetInventory); NiAVObject* Get3D() const; NiAVObject* Get3D(bool a_firstPerson) const; TESNPC* GetActorOwner(); diff --git a/include/RE/T/TutorialMenu.h b/include/RE/T/TutorialMenu.h index 6720e4a33..6d41bd8c7 100644 --- a/include/RE/T/TutorialMenu.h +++ b/include/RE/T/TutorialMenu.h @@ -20,6 +20,13 @@ namespace RE void Accept(CallbackProcessor* a_processor) override; // 01 UI_MESSAGE_RESULTS ProcessMessage(UIMessage& a_message) override; // 04 + static void OpenTutorialMenu(DEFAULT_OBJECT a_tutorial) + { + using func_t = decltype(&TutorialMenu::OpenTutorialMenu); + REL::Relocation func{ RELOCATION_ID(51818, 52692) }; + return func(a_tutorial); + } + // members GFxValue root; // 30 - "Menu_mc" }; diff --git a/src/RE/A/AIProcess.cpp b/src/RE/A/AIProcess.cpp index 74ebd89d0..39e0f1d09 100644 --- a/src/RE/A/AIProcess.cpp +++ b/src/RE/A/AIProcess.cpp @@ -96,6 +96,23 @@ namespace RE } } + float AIProcess::GetRegenDelay(ActorValue a_actorValue) const + { + if (high) { + switch (a_actorValue) { + case ActorValue::kHealth: + return high->healthRegenDelay; + case ActorValue::kMagicka: + return high->magickaRegenDelay; + case ActorValue::kStamina: + return high->staminaRegenDelay; + default: + break; + } + } + return 0.0f; + } + TESPackage* AIProcess::GetRunningPackage() const { TESPackage* package = nullptr; @@ -254,4 +271,23 @@ namespace RE REL::Relocation func{ Offset::AIProcess::Update3DModel }; return func(this, a_actor); } + + void AIProcess::UpdateRegenDelay(ActorValue a_actorValue, float a_regenDelay) + { + if (high) { + switch (a_actorValue) { + case ActorValue::kHealth: + high->healthRegenDelay = a_regenDelay; + break; + case ActorValue::kMagicka: + high->magickaRegenDelay = a_regenDelay; + break; + case ActorValue::kStamina: + high->staminaRegenDelay = a_regenDelay; + break; + default: + break; + } + } + } } diff --git a/src/RE/A/Actor.cpp b/src/RE/A/Actor.cpp index 858bb1176..cfc81a100 100644 --- a/src/RE/A/Actor.cpp +++ b/src/RE/A/Actor.cpp @@ -527,6 +527,14 @@ namespace RE return base ? base->race : nullptr; } + float Actor::GetRegenDelay(ActorValue a_actorValue) const + { + if (currentProcess) { + return currentProcess->GetRegenDelay(a_actorValue); + } + return 0.0f; + } + bool Actor::GetRider(NiPointer& a_outRider) { using func_t = decltype(&Actor::GetRider); @@ -1088,6 +1096,13 @@ namespace RE } } + void Actor::UpdateRegenDelay(ActorValue a_actorValue, float a_regenDelay) + { + if (currentProcess) { + currentProcess->UpdateRegenDelay(a_actorValue, a_regenDelay); + } + } + void Actor::UpdateSkinColor() { const auto* npc = GetActorBase(); diff --git a/src/RE/G/GFxValue.cpp b/src/RE/G/GFxValue.cpp index 2b1ef15d9..d6970606d 100644 --- a/src/RE/G/GFxValue.cpp +++ b/src/RE/G/GFxValue.cpp @@ -424,6 +424,13 @@ namespace RE return func(this, a_data, a_movieClip, a_symbolName, a_instanceName, a_depth, a_initObj); } + bool GFxValue::ObjectInterface::CreateEmptyMovieClip(void* a_data, GFxValue* a_movieClip, const char* a_instanceName, std::int32_t a_depth) + { + using func_t = decltype(&GFxValue::ObjectInterface::CreateEmptyMovieClip); + REL::Relocation func{ RELOCATION_ID(80201, 82224) }; + return func(this, a_data, a_movieClip, a_instanceName, a_depth); + } + bool GFxValue::ObjectInterface::GotoAndPlay(void* a_data, const char* a_frame, bool a_stop) { using func_t = decltype(&GFxValue::ObjectInterface::GotoAndPlay); @@ -967,6 +974,12 @@ namespace RE return _objectInterface->AttachMovie(_value.obj, a_movieClip, a_symbolName, a_instanceName, a_depth, a_initObj); } + bool GFxValue::CreateEmptyMovieClip(GFxValue* a_movieClip, const char* a_instanceName, std::int32_t a_depth) + { + assert(IsDisplayObject()); + return _objectInterface->CreateEmptyMovieClip(_value.obj, a_movieClip, a_instanceName, a_depth); + } + bool GFxValue::GotoAndPlay(const char* a_frame) { assert(IsDisplayObject()); diff --git a/src/RE/M/MagicCaster.cpp b/src/RE/M/MagicCaster.cpp index f2c557539..b80f16ec4 100644 --- a/src/RE/M/MagicCaster.cpp +++ b/src/RE/M/MagicCaster.cpp @@ -16,7 +16,7 @@ namespace RE bool MagicCaster::FindTargets(float a_effectivenessMult, std::uint32_t& a_targetCount, TESBoundObject* a_source, bool a_loadCast, bool a_adjustOnlyHostileEffectiveness) { using func_t = decltype(&MagicCaster::FindTargets); - REL::Relocation func{ RELOCATION_ID(33676, 34456) }; + REL::Relocation func{ RELOCATION_ID(33632, 34410) }; return func(this, a_effectivenessMult, a_targetCount, a_source, a_loadCast, a_adjustOnlyHostileEffectiveness); } @@ -48,6 +48,13 @@ namespace RE return func(this, a_item); } + void MagicCaster::SetCurrentSpell(MagicItem* a_item) + { + using func_t = decltype(&MagicCaster::SetCurrentSpell); + REL::Relocation func{ RELOCATION_ID(33644, 34422) }; + return func(this, a_item); + } + bool MagicCaster::TestProjectilePlacement(const Effect& a_effect, const bhkPickData& a_pickData) { if (auto baseEffect = a_effect.baseEffect) { diff --git a/src/RE/M/MagicSystem.cpp b/src/RE/M/MagicSystem.cpp index 2d942435f..49bd0d358 100644 --- a/src/RE/M/MagicSystem.cpp +++ b/src/RE/M/MagicSystem.cpp @@ -2,24 +2,27 @@ namespace RE { - const char* GetCannotCastString(MagicSystem::CannotCastReason a_reason) + namespace MagicSystem { - using func_t = decltype(&MagicSystem::GetCannotCastString); - REL::Relocation func{ RELOCATION_ID(11295, 11423) }; - return func(a_reason); - } + const char* GetCannotCastString(MagicSystem::CannotCastReason a_reason) + { + using func_t = decltype(&MagicSystem::GetCannotCastString); + REL::Relocation func{ RELOCATION_ID(11295, 11423) }; + return func(a_reason); + } - float GetMagicCasterTargetUpdateInterval() - { - using func_t = decltype(&MagicSystem::GetMagicCasterTargetUpdateInterval); - REL::Relocation func{ RELOCATION_ID(11294, 11422) }; - return func(); - } + float GetMagicCasterTargetUpdateInterval() + { + using func_t = decltype(&MagicSystem::GetMagicCasterTargetUpdateInterval); + REL::Relocation func{ RELOCATION_ID(11294, 11422) }; + return func(); + } - BGSSoundDescriptorForm* GetMagicFailureSound(MagicSystem::SpellType a_type) - { - using func_t = decltype(&MagicSystem::GetMagicFailureSound); - REL::Relocation func{ RELOCATION_ID(11286, 11411) }; - return func(a_type); + BGSSoundDescriptorForm* GetMagicFailureSound(MagicSystem::SpellType a_type) + { + using func_t = decltype(&MagicSystem::GetMagicFailureSound); + REL::Relocation func{ RELOCATION_ID(11286, 11411) }; + return func(a_type); + } } } diff --git a/src/RE/M/MagicTarget.cpp b/src/RE/M/MagicTarget.cpp index e8939d719..e26df0608 100644 --- a/src/RE/M/MagicTarget.cpp +++ b/src/RE/M/MagicTarget.cpp @@ -1,6 +1,7 @@ #include "RE/M/MagicTarget.h" #include "RE/A/ActiveEffect.h" +#include "RE/A/Actor.h" #include "RE/B/BSTList.h" #include "RE/E/EffectSetting.h" @@ -33,6 +34,15 @@ namespace RE } } + Actor* MagicTarget::GetTargetAsActor() + { + if (MagicTargetIsActor()) { + return static_cast(this); + } + + return nullptr; + } + bool MagicTarget::HasEffectWithArchetype(Archetype a_type) { auto effects = GetActiveEffectList(); diff --git a/src/RE/P/PlayerCharacter.cpp b/src/RE/P/PlayerCharacter.cpp index 0b8e18750..bb901f52c 100644 --- a/src/RE/P/PlayerCharacter.cpp +++ b/src/RE/P/PlayerCharacter.cpp @@ -150,6 +150,13 @@ namespace RE return static_cast(grabbedObject); } + void PlayerCharacter::PlayMagicFailureSound(MagicSystem::SpellType a_spellType) + { + using func_t = decltype(&PlayerCharacter::PlayMagicFailureSound); + REL::Relocation func{ RELOCATION_ID(39486, 40565) }; + return func(this, a_spellType); + } + void PlayerCharacter::PlayPickupEvent(TESForm* a_item, TESForm* a_containerOwner, TESObjectREFR* a_containerRef, EventType a_eventType) { using func_t = decltype(&PlayerCharacter::PlayPickupEvent); diff --git a/src/RE/T/TESObjectREFR.cpp b/src/RE/T/TESObjectREFR.cpp index 0ec42cd9d..f7a782f8d 100644 --- a/src/RE/T/TESObjectREFR.cpp +++ b/src/RE/T/TESObjectREFR.cpp @@ -92,6 +92,13 @@ namespace RE return DoTrap2(a_trap, a_target); } + void TESObjectREFR::Enable(bool a_resetInventory) + { + using func_t = decltype(&TESObjectREFR::Enable); + REL::Relocation func{ RELOCATION_ID(19373, 19800) }; + return func(this, a_resetInventory); + } + NiAVObject* TESObjectREFR::Get3D() const { return Get3D2();