2022-07-31 18:55:11 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Util.h"
|
|
|
|
#include "PersistentFormManager.h"
|
|
|
|
|
|
|
|
namespace Papyrus::PapyrusFunctions
|
|
|
|
{
|
|
|
|
inline RE::AlchemyItem* CreatePotion(RE::StaticFunctionTag*, std::vector<RE::EffectSetting*> effects, std::vector<float> magnitudes, std::vector<uint32_t> areas, std::vector<uint32_t> durations, uint32_t arraySize)
|
|
|
|
{
|
|
|
|
RE::AlchemyItem* result = NULL;
|
|
|
|
|
|
|
|
if (effects.size() >= arraySize && magnitudes.size() >= arraySize && areas.size() >= arraySize && durations.size() >= arraySize) {
|
|
|
|
RE::tArray<RE::Effect> effectItems;
|
|
|
|
effectItems.Allocate(effects.size());
|
|
|
|
|
|
|
|
uint16_t count = 0;
|
|
|
|
for (uint16_t i = 0; i < effects.size(); ++i) {
|
|
|
|
if (effects[i]) {
|
|
|
|
effectItems[i].baseEffect = effects[i];
|
|
|
|
effectItems[i].effectItem.duration = durations[i];
|
|
|
|
effectItems[i].effectItem.magnitude = magnitudes[i];
|
|
|
|
effectItems[i].effectItem.area = areas[i];
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
effectItems.count = count;
|
|
|
|
|
|
|
|
RE::PersistentFormManager::GetSingleton()->CreatePotion(&result, &effectItems);
|
|
|
|
|
|
|
|
effectItems.Clear();
|
|
|
|
} else {
|
|
|
|
logger::warn("Illegal arrays for creating a potion");
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline uint8_t GetNewGameCount(RE::StaticFunctionTag*)
|
|
|
|
{
|
|
|
|
return NewGameCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline RE::TESObjectREFR* GetCurrentContainer(RE::StaticFunctionTag*)
|
|
|
|
{
|
|
|
|
const auto handle = RE::ContainerMenu::GetTargetRefHandle();
|
|
|
|
const auto refr = RE::TESObjectREFR::LookupByHandle(handle);
|
|
|
|
return refr ? refr.get() : nullptr;
|
|
|
|
}
|
|
|
|
|
2022-08-10 19:04:23 +00:00
|
|
|
inline std::vector<RE::Actor*> GetPlayerFollowers(RE::StaticFunctionTag*)
|
|
|
|
{
|
|
|
|
std::vector<RE::Actor*> result;
|
|
|
|
|
|
|
|
if (const auto processLists = RE::ProcessLists::GetSingleton(); processLists) {
|
|
|
|
for (auto& actorHandle : processLists->highActorHandles) {
|
|
|
|
if (auto actor = actorHandle.get(); actor && actor->IsPlayerTeammate() && !actor->IsDead() && !actor->IsDisabled()) {
|
|
|
|
result.push_back(actor.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2022-07-31 18:55:11 +00:00
|
|
|
inline void Bind(VM& a_vm)
|
|
|
|
{
|
|
|
|
BIND(CreatePotion);
|
2022-09-01 09:20:08 +00:00
|
|
|
logger::info("{}", "Registered CreatePotion"sv);
|
2022-07-31 18:55:11 +00:00
|
|
|
BIND(GetNewGameCount);
|
2022-09-01 09:20:08 +00:00
|
|
|
logger::info("{}", "Registered GetNewGameCount"sv);
|
2022-07-31 18:55:11 +00:00
|
|
|
BIND(GetCurrentContainer);
|
2022-09-01 09:20:08 +00:00
|
|
|
logger::info("{}", "Registered GetCurrentContainer"sv);
|
2022-08-10 19:04:23 +00:00
|
|
|
BIND(GetPlayerFollowers);
|
2022-09-01 09:20:08 +00:00
|
|
|
logger::info("{}", "Registered GetPlayerFollowers"sv);
|
2022-07-31 18:55:11 +00:00
|
|
|
}
|
|
|
|
}
|