Skip to content

Instantly share code, notes, and snippets.

@Scrivener07
Created October 9, 2017 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Scrivener07/dba55b83310554bd8e29666174b4d8ee to your computer and use it in GitHub Desktop.
Save Scrivener07/dba55b83310554bd8e29666174b4d8ee to your computer and use it in GitHub Desktop.
AVI decoded for F4SE plugin. (reg2k)
RelocAddr<uintptr_t> s_AVFunctorVtbl(0x02C98598);
bool ActorValueInfo::AddDependentAV(ActorValueInfo* avif)
{
if (numDependentAVs < sizeof(dependentAVs) / 8)
{
dependentAVs[numDependentAVs++] = avif;
return true;
}
return false;
}
void ActorValueInfo::RegisterDerivedBaseFunction(float(*f)(ActorValueOwner*, ActorValueInfo*))
{
derived_func_impl = reinterpret_cast<void*>(s_AVFunctorVtbl.GetUIntPtr());
derived_func_ptr = &derived_func_impl;
derived_func = f;
}
// 190
class ActorValueInfo : public TESForm
{
public:
enum { kTypeID = kFormType_AVIF };
TESFullName fullName; // 20
TESDescription description; // 30
void * func_impl; // 48
void * func; // 50
UInt64 unk58; // 58
void * func_ptr; // 60 - address of offset 48
const char * avName; // 68
UInt64 unk70; // 70
ActorValueInfo * dependentAVs[0xF]; // 78
void * derived_func_impl; // F0
void * derived_func; // F8
UInt64 unk100; // 100
void * derived_func_ptr; // 108 - address of offset F0
UInt32 unk110[(0x16C - 0x110) / 4]; // 110
UInt32 avFlags; // 16C
enum AVFlags
{
kFlag_DefaultBase_0 = (1 << 10), // 10 | Default Base: 0
kFlag_DefaultBase_1 = (1 << 11), // 11 | Default Base: 1
kFlag_DefaultBase_100 = (1 << 12), // 12 | Default Base: 100
kFlag_DefaultBase_UserDefined = (1 << 13), // 13 | Default Base: User Defined
kFlag_DefaultBase_Derived = (1 << 15), // 15 | Default Base: Derived (bits 10-13 must not be set)
kFlag_DamageIsPositive = (1 << 26), // 26 | Damage is Positive
kFlag_GodModeImmune = (1 << 27), // 27 | God Mode Immune
kFlag_Hardcoded = (1 << 31) // 31 | Hardcoded
};
UInt32 unk170; // 170
UInt32 numDependentAVs; // 174
UInt32 unk178; // 178
UInt32 unk17C; // 17C
UInt32 unk180; // 180
float defaultBase; // 184
UInt32 unk188; // 188
UInt32 unk18C; // 18C
bool AddDependentAV(ActorValueInfo* avif);
void RegisterDerivedBaseFunction(float(*f)(ActorValueOwner*, ActorValueInfo*));
};
float CalculateStat(ActorValueOwner* actorValueOwner, ActorValueInfo* actorValueInfo) {
// Do derived attribute calculation here
return 9999.99;
}
// Register derivation function
ActorValueInfo* derivedAV = DYNAMIC_CAST(LookupFormByID(0x2F000F99), TESForm, ActorValueInfo);
derivedAV->RegisterDerivedBaseFunction(CalculateStat);
// Add as dependent to agility
ActorValueInfo* agilityAV = DYNAMIC_CAST(LookupFormByID(0x2C7), TESForm, ActorValueInfo);
agilityAV->AddDependentAV(derivedAV);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment