I want to share this, Thanks to all users of this forum, I've gradually been getting ^ ^ (this is source of lazy bot, but i supposed the real source is from Shynd)
(after learn how works i copy & paste XD of course)
Code:
//4.3.4 offsets
public enum Reaction_offsets : uint
{
FactionStartIndex = 0x99911C,
FactionPointer = FactionStartIndex + 0xC,
FactionTotal = FactionStartIndex - 0x4,
HostileOffset1 = 0x14,
HostileOffset2 = 0x0C,
FriendlyOffset1 = 0x10,
FriendlyOffset2 = 0x0C,
}
Target.UnitFieldsAddress = Memory.Read<uint>(Target.BaseAddress + (uint)ObjectOffsets.ObjectFields); // Object fields for 4.3.4 is 0xC
Target.Faction = Memory.Read<uint>(Target.UnitFieldsAddress + (uint)UnitFields.UNIT_FIELD_FACTIONTEMPLATE); //Faction template for 4.3.4 is: (0x8 + 0x29)*4 or = 0xC4 is the same
Me.Faction = Memory.Read<uint>(Me.UnitFieldsAddress + (uint)UnitFields.UNIT_FIELD_FACTIONTEMPLATE);
var Reaction_result = GetReaction(Me.Faction, Target.Faction) + Environment.NewLine);
public Reaction GetReaction(WowObject localObj, WowObject mobObj) // < here you need send unit faction templetate, player + mob
{
try
{
if (localObj.Faction < 1 || mobObj.Faction < 1)
{
return Reaction.Missing;
}
return FindReactionFromFactions(localObj.Faction, mobObj.Faction);
}
catch (Exception)
{
return Reaction.Missing;
}
}
private Reaction FindReactionFromFactions(uint localFaction, uint mobFaction)
{
var startIndex = Memory.Read<uint>(BaseWoW + (uint)Reaction_offsets.FactionStartIndex); // the the alot post don't show BaseWoW + offsets remember it!
var totalFactions = Memory.Read<uint>(BaseWoW + (uint)Reaction_offsets.FactionTotal);
var factionStartPoint = Memory.Read<uint>(BaseWoW + (uint)Reaction_offsets.FactionPointer);
/* Remember BaseWow is:
processes = Process.GetProcessesByName("Wow");
Memory.OpenProcess(processes[0].Id);
//Hook.Apply(GetEndscene(), (uint)WowFunctions.ClntObjMgrGetActivePlayer, (uint)Device.Lua_DoString, (uint)Device.Lua_GetLocalizedText); // Inicializa entrada LUA
BaseWoW = Memory.BaseAddress;
*/
uint? localHash = null;
uint? mobHash = null;
Reaction reaction;
if (localFaction >= startIndex && localFaction <= totalFactions)
{
if (mobFaction >= startIndex && mobFaction < totalFactions)
{
localHash = factionStartPoint + ((localFaction - startIndex) * 4);
mobHash = factionStartPoint + ((mobFaction - startIndex) * 4);
}
}
if (localHash != null)
{
reaction = CompareFactionHash(localHash, mobHash);
}
else
{
reaction = Reaction.Unknown;
}
return reaction;
}
private bool TestBits(uint lBitAddr, uint rBitAddr)
{
var lBitParam = Memory.Read<uint>(lBitAddr);
var rBitParam = Memory.Read<uint>(rBitAddr);
if ((lBitParam & rBitParam) != 0) return true;
return false;
}
private bool HashCompare(int hashIndex, byte[] localBitHash, int mobHashCheck)
{
const int hashIndexInc = 4;
int hashCompare = BitConverter.ToInt32(localBitHash, hashIndex);
for (uint i = 0; i < 4; i++)
{
if (hashCompare == mobHashCheck)
return true;
hashIndex += hashIndexInc;
hashCompare = BitConverter.ToInt32(localBitHash, hashIndex);
if (hashCompare == 0)
break;
}
return false;
}
private Reaction CompareFactionHash(uint? hash1, uint? hash2)
{
if (hash1 != null && hash2 != null)
{
byte[] localBitHash = Memory.ReadBytes((uint)hash1, 64);
byte[] mobBitHash = Memory.ReadBytes((uint)hash2, 64);
int mobHashCheck = BitConverter.ToInt32(mobBitHash, 0x04);
if (TestBits((uint)BitConverter.ToInt32(localBitHash, 0) + (uint)Reaction_offsets.HostileOffset1,
(uint)BitConverter.ToInt32(mobBitHash, 0) + (uint)Reaction_offsets.HostileOffset2))
return Reaction.Hostile;
if (HashCompare(0x18, localBitHash, mobHashCheck))
return Reaction.Hostile;
if (TestBits((uint)BitConverter.ToInt32(localBitHash, 0) + (uint)Reaction_offsets.FriendlyOffset1,
(uint)BitConverter.ToInt32(mobBitHash, 0) + (uint)Reaction_offsets.FriendlyOffset2))
return Reaction.Friendly;
if (HashCompare(0x28, localBitHash, mobHashCheck))
return Reaction.Friendly;
}
return Reaction.Neutral;
}
public enum Reaction
{
Unknown = -1,
Hostile = 1,
Neutral = 3,
Friendly = 4,
Missing = -2
}
thanks to all
i will hope help you ^_^