Hi all,
I have found some C# code and adapted it to C++. It will tell you target reaction to you, hostile, friendly, etc...
Reaction WOWFactionInterpreter::FindReactionFromFactions(UINT localFaction, UINT mobFaction)
{
Reaction reaction = Unknown;
UINT32 startIndex = m_wowBase->GetRebaseUINT32(m_wowBase->m_wowOffsets.FACTION_START_INDEX);
UINT32 totalFactions = m_wowBase->GetRebaseUINT32(m_wowBase->m_wowOffsets.FACTION_TOTAL);
UINT32 factionStartPoint = m_wowBase->GetRebaseUINT32(m_wowBase->m_wowOffsets.FACTION_POINTER);
UINT32 localHash = 0;
UINT32 mobHash = 0;
if (localFaction >= startIndex && localFaction < totalFactions)
{
if (mobFaction >= startIndex && mobFaction < totalFactions)
{
localHash = factionStartPoint + ((localFaction - startIndex) * 4);
mobHash = factionStartPoint + ((mobFaction - startIndex) * 4);
}
}
if (localHash != 0 && mobHash != 0)
reaction = CompareFactionHash(localHash, mobHash);
return reaction;
}
bool WOWFactionInterpreter::TestBits(UINT32 lBitAddr, UINT32 rBitAddr)
{
UINT32 lBitParam = m_wowBase->GetUINT32(lBitAddr);
UINT32 rBitParam = m_wowBase->GetUINT32(rBitAddr);
if ((lBitParam & rBitParam) != 0) return true;
return false;
}
bool WOWFactionInterpreter::HashCompare(UINT32 hashIndex, UINT32 hashCompare, char* localBitHash, UINT32 mobHashCheck)
{
const int HASH_INDEX_INC = 4;
hashCompare = *( (UINT32*) &localBitHash[hashIndex] );
for (int i = 0; i < 4; i++)
{
if (hashCompare == mobHashCheck)
return true;
hashIndex += HASH_INDEX_INC;
hashCompare = *( (UINT32*) &localBitHash[hashIndex] );
if (hashCompare == 0)
break;
}
return false;
}
Reaction WOWFactionInterpreter::CompareFactionHash(UINT32 hash1, UINT32 hash2)
{
UINT32 localHashCheck = 0;
UINT32 mobHashCheck = 0;
UINT32 hashCompare = 0;
char localBitHash[100];
m_wowBase->m_wowMem.ReadBytes( hash1, localBitHash, 64);
char mobBitHash[100];
m_wowBase->m_wowMem.ReadBytes( hash2, mobBitHash, 64);
localHashCheck = *( (UINT32*) &localBitHash[0x04] );
mobHashCheck = *( (UINT32*) &mobBitHash[0x04] );
if( TestBits( *( (UINT32*) &localBitHash[0x00] ) + m_wowBase->m_wowOffsets.HOSTILE_OFFSET_1, *( (UINT32*) &mobBitHash[0x00] ) + m_wowBase->m_wowOffsets.HOSTILE_OFFSET_2) )
return Hostile;
if (HashCompare(0x18, hashCompare, localBitHash, mobHashCheck))
return Hostile;
if( TestBits( *( (UINT32*) &localBitHash[0x00] ) + m_wowBase->m_wowOffsets.FRIENDLY_OFFSET_1, *( (UINT32*) &mobBitHash[0x00] ) + m_wowBase->m_wowOffsets.FRIENDLY_OFFSET_2) )
return Friendly;
if (HashCompare(0x28, hashCompare, localBitHash, mobHashCheck))
return Friendly;
return Neutral;
}
The problem I have is this: the code will tell me is target friendly or hostile, but not neutral (like kodo in barens, for example). All neutral (yellow) mobs are reported as friendly.
Question is how do I get it to report yellow as neutral, if any1 knows ?
Kajko