C++ API (SKSE plugins)¶
The C++ query interface is the native mirror of the Query API: the same reads, answered by the same core inside BodyInflationNG.dll, so C++ and Papyrus can never disagree. It is read-only. Writes go through the Papyrus surface (SLIF_Main.inflate / SLIF_Morph.morph, see the Write API).
Quick start¶
- Copy
SLIFNG_API.hinto your project, from the integration kit (cpp/inSLIFNG-API-<version>+.zip) or fromsrc/API/in the repository. It needs nothing but<cstdint>, and there is no library to link. - Once every SKSE DLL has loaded, look up the
SLIFNG_GetQueryInterfaceexport and keep the pointer it returns:
#include "SLIFNG_API.h"
SLIFNG_API::IQueryInterface1* g_slif = nullptr;
void OnSKSEMessage(SKSE::MessagingInterface::Message* a_msg)
{
if (a_msg->type != SKSE::MessagingInterface::kPostLoad) {
return;
}
if (auto* dll = GetModuleHandleA(SLIFNG_API::kModuleName)) {
auto get = reinterpret_cast<SLIFNG_API::GetQueryInterfaceFn>(
GetProcAddress(dll, SLIFNG_API::kGetQueryInterfaceExport));
if (get) {
g_slif = get();
}
}
// g_slif stays nullptr when SLIF NG is not installed
}
SKSEPluginLoad(const SKSE::LoadInterface* a_skse)
{
SKSE::Init(a_skse);
SKSE::GetMessagingInterface()->RegisterListener(OnSKSEMessage);
return true;
}
- When:
kPostLoador any later message (kPostPostLoadandkDataLoadedwork too). Not from your ownSKSEPlugin_Load: SKSE loads DLLs in file-name order, so if yours sorts first, SLIF NG is not loaded yet. - Absent:
GetModuleHandleAreturns null when SLIF NG is not installed or failed to load. Nothing else happens. - Lifetime: call once and keep the pointer. It is valid for the whole process, and there is nothing to release.
To check it worked, look for this line in SLIFNG.log, in the SKSE log folder next to your own plugin's log:
The export exists since SLIF NG 0.4.18. For older builds, see SLIF NG 0.4.17 and older.
Reading values¶
| Call | Returns |
|---|---|
GetValue(actor, mod, target, default) |
That mod's stored row for the target, or the aggregate for "All Mods" |
GetMinValue / GetMaxValue(actor, mod, target, default) |
The stored bounds behind that row |
GetApplied(actor, target) |
The value currently shown for the target, without the user's magnitude |
GetCombinedMorph(actor, slider) |
Cross-mod total of direct morph writes to one slider (the legacy slif_<slider> number) |
IsTracked(actor) / TrackedActorCount() |
Whether SLIF NG holds anything for this actor / how many actors it holds |
GetCalculationType() |
SLIF's calculation_type: 0 Top X, 1 Highest wins, 2 Subtract and add one, 3 Square root, 4 Average, 5 Additive |
IsIncrementalInflation() |
Whether ramped inflation is switched on |
Version() |
The newest interface this build serves, see Newer calls |
The semantics are the Papyrus ones (Query API). Two matter most:
- An absent row returns your default, never an invented neutral. Use
1.0ffor node targets and0.0ffor morphs, or a sentinel such as-1.0fto tell "nothing stored" from "stored at neutral". - Targets can be spelled
"slif_belly","NPC Belly","morph:PregnancyBelly"or"region:weight". The first two are the same target. Spelling and mod names are case-insensitive.
A specific mod's row¶
Read with the name the mod writes under. The row is raw: no clamping, no user magnitude.
| Mod | modName |
Targets it writes |
|---|---|---|
| Fill Her Up (Baka edition) | "Fill Her Up" |
"NPC Belly" (node scaling) or "morph:PregnancyBelly" (its default InflateMorph, plus up to three more sliders), depending on its MCM |
| Beeing Female NG | "Beeing Female" |
slif_* node keys and morph:<slider> |
| Sexlab Survival | "Sexlab Survival" |
"slif_belly" |
For any other mod, SLIFNG.log names both strings on every write it receives:
Fill Her Up drives one of two targets, so read both, with a sentinel default:
const float node = g_slif->GetValue(actor, "Fill Her Up", "NPC Belly", -1.0f); // scale, 1.0 = neutral
const float morph = g_slif->GetValue(actor, "Fill Her Up", "morph:PregnancyBelly", -1.0f); // slider, 0.0 = neutral
const bool fhuDrivesBone = node >= 0.0f;
const bool fhuDrivesSlider = morph >= 0.0f;
The aggregate¶
To ask "how big does this actor look, counting every mod", read the pseudo-mod "All Mods":
const float belly = g_slif->GetValue(actor, "All Mods", "NPC Belly", 1.0f); // with the user's magnitude
const float raw = g_slif->GetApplied(actor, "NPC Belly"); // without it
GetValue on "All Mods" includes the user's MCM magnitude, so it agrees with what the player sees. GetApplied is the same total without it. Mid-ramp both are the in-flight value (which getter do I want).
Newer calls¶
Interfaces grow by addition: IQueryInterface2 derives from IQueryInterface1 and adds calls, and so on. Ask the pointer for its version, then cast:
if (g_slif && g_slif->Version() >= 2) {
auto* q2 = static_cast<SLIFNG_API::IQueryInterface2*>(g_slif);
const bool hasWeight = q2->HasTarget(actor, "region:weight");
}
Version() |
Since | Adds |
|---|---|---|
| 1 | SLIF NG 0.3.0 | Everything under Reading values |
| 2 | SLIF NG 0.4.0 | HasTarget(actor, target): would a write to this target do anything on this actor? (ask before you write) |
Gate on >=, never on ==: the number only grows, and Version() == 1 would lock you out of every later build.
The SLIFNG_Settled event¶
SLIFNG_Settled fires once per target when that target stops changing on an actor. It is an ordinary ModCallbackEvent, so a C++ plugin can sink it directly:
class SettledSink final : public RE::BSTEventSink<SKSE::ModCallbackEvent>
{
public:
RE::BSEventNotifyControl ProcessEvent(const SKSE::ModCallbackEvent* a_event,
RE::BSTEventSource<SKSE::ModCallbackEvent>*) override
{
if (a_event && a_event->eventName == "SLIFNG_Settled") {
auto* actor = a_event->sender ? a_event->sender->As<RE::Actor>() : nullptr;
// a_event->strArg = the target ("slif_breast", "morph:PregnancyBelly", ...)
// a_event->numArg = the settled value, identical to GetApplied(actor, target)
}
return RE::BSEventNotifyControl::kContinue;
}
};
// at kDataLoaded:
static SettledSink g_settledSink;
SKSE::GetModCallbackEventSource()->AddEventSink(&g_settledSink);
Filter on strArg. Sent since SLIF NG 0.4.1.
Threading¶
- Every call is thread-safe and cheap: a locked lookup, no geometry work, nothing posted to the main thread.
- The
RE::Actor*you pass must be valid at that moment. Resolve it from a handle each time instead of caching a raw pointer.
Not in C++¶
- Enumeration ("which mods drive this target", "which targets does this actor have", "which actors are tracked") and
DrivenByare Papyrus only (SLIFNG.GetModsDriving,GetNodeTargets,GetMorphTargets,GetTrackedActors,DrivenBy). From C++ you need the mod name and target up front. - Writes, by design: send them through the Papyrus surface, so every consumer shares one entry point.
Need one of these natively? Open an issue with the shape you want. A new call costs nothing in compatibility.
Troubleshooting¶
| Symptom | Cause |
|---|---|
GetModuleHandleA returns null, SLIFNG.log exists |
Called too early: from your own SKSEPlugin_Load, with your DLL sorting before BodyInflationNG.dll. Move it to kPostLoad or later |
GetModuleHandleA returns null, no SLIFNG.log |
SLIF NG's DLL is not running (plain SLIF SE, or it failed to load) |
GetProcAddress returns null |
SLIF NG 0.4.17 or older, see below |
GetValue always returns your default |
The mod name or target is spelled differently from what the writer sent (check the [API] Inflate(...) lines), the actor is not tracked, or the key is dead (slif_breast01 style) |
Crash calling HasTarget |
Cast to IQueryInterface2 without checking Version() >= 2 |
Value differs from Papyrus GetValue |
It cannot, both run the same core. A mod's own row and "All Mods" differ by design |
SLIF NG 0.4.17 and older¶
These builds have no export. They hand out the same interface over SKSE messaging instead: dispatch an InterfaceExchangeMessage to "SLIFNG" at kPostPostLoad or later, and if msg.query stays null, dispatch it again with no receiver (the header shows the code). SKSE does not always deliver that message, which is why the export replaced it, so on 0.4.18 and later use the export.