Skip to content

Instantly share code, notes, and snippets.

@reg2k
Last active April 18, 2020 14:23
Show Gist options
  • Save reg2k/c594dc126fdb87bc2911558c78d6e3c6 to your computer and use it in GitHub Desktop.
Save reg2k/c594dc126fdb87bc2911558c78d6e3c6 to your computer and use it in GitHub Desktop.
TESHitEvent
struct TESHitEvent
{
enum HitEventFlags {
kFlag_Unk0 = (1 << 0), // (Unk0 | Unk1) - blocked
kFlag_Unk1 = (1 << 1),
kFlag_CriticalHit = (1 << 3),
kFlag_SneakAttack = (1 << 11),
kFlag_Unk15 = (1 << 15), // (Unk15 | Unk16) - bash
kFlag_Unk16 = (1 << 16),
kFlag_PowerAttack = (1 << 17),
};
NiPoint3 position; // 00
UInt32 unk0C[(0x40-0x0C)/4]; // 0C
UInt32 attackerHandle; // 40
UInt32 targetHandle; // 44
UInt64 unk48; // 48
void* attackData; // 50 - BGSAttackData*
TESForm* source; // 58 - e.g. TESObjectWEAP*
void* sourceInstanceData; // 60
UInt64 unk68[(0x80-0x68)/8]; // 68
TESAmmo* ammo; // 80
UInt64 unk88; // 88
float effectiveDamage; // 90 - effectiveDamage = baseDamage + damage bonus (body part multiplier)
float incomingDamage; // 94
float baseDamage; // 98 - baseDamage = incomingDamage - negatedDamage
float unk9C; // 9C
float unkA0; // A0
float negatedDamage; // A4
UInt64 unkA8; // A8
float attackDamageMultiplier; // B0 - Sneak attack muliplier
UInt32 unkB4[(0xC4-0xB4)/4]; // B4
UInt32 flags; // C4
UInt64 unkC8[(0xE0-0xC8)/8]; // C8
TESObjectREFR* target; // E0 - If null, use handle
TESObjectREFR* attacker; // E8 - If null, use handle
UInt64 unkF0; // F0
UInt32 sourceFormID; // F8 - May be null
UInt32 projectileFormID; // FC - May be null
bool unk100; // 100
char pad101[7]; // 101
};
STATIC_ASSERT(offsetof(TESHitEvent, unk100) == 0x100);
DECLARE_EVENT_DISPATCHER(TESHitEvent, 0x004444D0); // v1.10.26
// Add event sink
auto eventDispatcher = GetEventDispatcher<TESHitEvent>();
eventDispatcher->lock.Lock();
for (int i = 0; i < eventDispatcher->eventSinks.count; i++) {
if (eventDispatcher->eventSinks[i] == &hitEventSink) {
eventDispatcher->lock.Release();
return false;
}
}
eventDispatcher->eventSinks.Push(&hitEventSink);
eventDispatcher->lock.Release();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment