[3.1.3] UnitReaction menu

User Tag List

Results 1 to 8 of 8
  1. #1
    lynxmind's Avatar Member
    Reputation
    1
    Join Date
    Jun 2009
    Posts
    1
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [3.1.3] UnitReaction

    I have been reading Synds post on UnitReaction and i have been updating all the offsets etc but i cannot get it working:

    It always returns hated (1).

    Code:
            public eUnitReaction Reaction
            {
                get
                {
                    uint startIndex = 0xA37330; //3.1.3
                    uint factionPointer = 0xA37340; //3.1.3
                    uint totalFactions = 0xA3732C; //3.1.3
                    UInt32 hash1, hash2;
                    if (GObjectList.LocalPlayer.Faction >= GObjectList.Memory.ReadUInt(startIndex) && GObjectList.LocalPlayer.Faction < GObjectList.Memory.ReadUInt(totalFactions) && Faction >= GObjectList.Memory.ReadUInt(startIndex) && Faction < GObjectList.Memory.ReadUInt(totalFactions))
                    {
                        hash1 = Convert.ToUInt32(GObjectList.Memory.ReadUInt(factionPointer) + ((GObjectList.LocalPlayer.Faction - GObjectList.Memory.ReadUInt(startIndex)) * 4));
                        hash2 = Convert.ToUInt32(GObjectList.Memory.ReadUInt(factionPointer) + ((Faction - GObjectList.Memory.ReadUInt(startIndex)) * 4));
                        int i = CompareFactionHash(hash1, hash2);
    
                        switch(i)
                        {
                            case (int)eUnitReaction.Exalted:
                                return eUnitReaction.Exalted;
                            case (int)eUnitReaction.Friendly:
                                return eUnitReaction.Friendly;
                            case (int)eUnitReaction.Hated:
                                return eUnitReaction.Hated;
                            case (int)eUnitReaction.Honored:
                                return eUnitReaction.Honored;
                            case (int)eUnitReaction.Hostile:
                                return eUnitReaction.Hostile;
                            case (int)eUnitReaction.Neutral:
                                return eUnitReaction.Neutral;
                            case (int)eUnitReaction.Revered:
                                return eUnitReaction.Revered;
                            case (int)eUnitReaction.Unfriendly:
                                return eUnitReaction.Unfriendly;
                            default:
                                return eUnitReaction.Unknown;
                        }
                   }
                    return eUnitReaction.Unknown;
                }
            }
    
            //The offsets from 2.4.2 is stil valid in 3.1.3
            private int CompareFactionHash(uint hash1, uint hash2)
            {
                if (hash1 == 0 || hash2 == 0)
                    return -1;
    
                int hashCheck1 = 0, hashCheck2 = 0;
                int hashCompare = 0;
                int hashIndex = 0;
                byte[] bHash1 = new byte[0x40];
                byte[] bHash2 = new byte[0x40];
    
               // Memory.ReadMemory(hProcess, hash1, ref bHash1); //The code Synd used to Read memory, i use black magic so i use the code below instead, is it the same?
               //  Memory.ReadMemory(hProcess, hash2, ref bHash2);  //The code Synd used to Read memory, i use black magic so i use the code below instead, is it the same?
                bHash1 = GObjectList.GetMemory().ReadBytes(hash1, 0x40);
                bHash2 = GObjectList.GetMemory().ReadBytes(hash2, 0x40);
    
                hashCheck1 = BitConverter.ToInt32(bHash1, 0x04);
                hashCheck2 = BitConverter.ToInt32(bHash2, 0x04);
    
                //bitwise compare of [bHash1+0x14] and [bHash2+0x0C]
                if ((BitConverter.ToInt32(bHash1, 0x14) & BitConverter.ToInt32(bHash2, 0x0C)) != 0)
                    return 1; //hostile
    
                hashIndex = 0x18;
                hashCompare = BitConverter.ToInt32(bHash1, hashIndex);
                if (hashCompare != 0)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if (hashCompare == hashCheck2)
                            return 1; //hostile
    
                        hashIndex += 4;
                        hashCompare = BitConverter.ToInt32(bHash1, hashIndex);
    
                        if (hashCompare == 0)
                            break;
                    }
                }
    
                //bitwise compare of [bHash1+0x10] and [bHash2+0x0C]
                if ((BitConverter.ToInt32(bHash1, 0x10) & BitConverter.ToInt32(bHash2, 0x0C)) != 0)
                    return 4; //friendly
    
                hashIndex = 0x28;
                hashCompare = BitConverter.ToInt32(bHash1, hashIndex);
                if (hashCompare != 0)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if (hashCompare == hashCheck2)
                            return 4; //friendly
    
                        hashIndex += 4;
                        hashCompare = BitConverter.ToInt32(bHash1, hashIndex);
    
                        if (hashCompare == 0)
                            break;
                    }
                }
    
                //bitwise compare of [bHash2+0x10] and [bHash1+0x0C]
                if ((BitConverter.ToInt32(bHash2, 0x10) & BitConverter.ToInt32(bHash1, 0x0C)) != 0)
                    return 4; //friendly
    
                hashIndex = 0x28;
                hashCompare = BitConverter.ToInt32(bHash2, hashIndex);
                if (hashCompare != 0)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if (hashCompare == hashCheck1)
                            return 4; //friendly
    
                        hashIndex += 4;
                        hashCompare = BitConverter.ToInt32(bHash2, hashIndex);
    
                        if (hashCompare == 0)
                            break;
                    }
                }
    
                return 3; //neutral
            }
    I think the "bug" may be because i use another method to read the bHash1 and bHash2.
    Any help appriciatet.
    Last edited by lynxmind; 06-19-2009 at 07:51 AM.

    [3.1.3] UnitReaction
  2. #2
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
            private int GetReaction(WoWUnit other)
            {
                if (_unitReaction == null)
                {
                    _unitReaction = Utilities.RegisterDelegate<GetUnitReactionDelegate>((uint) GlobalOffsets.GetUnitRelation);
                }
                return _unitReaction(this, other);
            }
    Seems to work fine for me.

  3. #3
    ramey's Avatar Member
    Reputation
    45
    Join Date
    Jan 2008
    Posts
    320
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Apoc View Post
    Code:
            private int GetReaction(WoWUnit other)
            {
                if (_unitReaction == null)
                {
                    _unitReaction = Utilities.RegisterDelegate<GetUnitReactionDelegate>((uint) GlobalOffsets.GetUnitRelation);
                }
                return _unitReaction(this, other);
            }
    Seems to work fine for me.
    Hm,

    Code:
    int CGUnit_C::UnitReaction( CGUnit_C * pUnit )
    {
    	typedef int ( __thiscall * tUnitReaction)(CGUnit_C * pThis, CGUnit_C * pOther);
    	tUnitReaction oUnitReaction = ( tUnitReaction )gpWoW->FindPattern()->Address( "UnitReaction" );
    
    	return oUnitReaction( this,  pUnit );
    }
    Works fine for me too, I can't imagine why it doesn't work for you lynxmind!

  4. #4
    maltikism's Avatar Member
    Reputation
    8
    Join Date
    Jun 2009
    Posts
    34
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your problem is here mate:

    Code:
    if ((BitConverter.ToInt32(bHash1, 0x14) & BitConverter.ToInt32(bHash2, 0x0C)) != 0)
                    return 1; //hostile
    You're using a conversion starting point instead of doing a read.

    Try:

    Code:
    if (((uint)(ReadInt((uint)BitConverter.ToInt32(bHash1, 0) + 0x14)) & (uint)(ReadInt((uint)BitConverter.ToInt32(bHash2, 0) + 0x0C))) != 0)
                    return 1; //hostile
    Hope this helps ^_^

  5. #5
    Shynd's Avatar Contributor
    Reputation
    97
    Join Date
    May 2008
    Posts
    393
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you notice, he's reading 0x40 bytes into bHash1 and bHash2 so that he doesn't have to read each one individually. Something may have changed or the addresses are wrong, I'm honestly not sure; I haven't used this method until a week or two after I originally reversed it.

  6. #6
    maltikism's Avatar Member
    Reputation
    8
    Join Date
    Jun 2009
    Posts
    34
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    //bitwise compare of [bHash1+0x14] and [bHash2+0x0C]
                if ((BitConverter.ToInt32(bHash1, 0x14) & BitConverter.ToInt32(bHash2, 0x0C)) != 0)
                    return 1; //hostile
    The comment says to read from bHash1 + 0x14 - instead he's using a toInt32 offset. I tried the exact same code, changed it to a readint and it worked perfectly.

  7. #7
    maltikism's Avatar Member
    Reputation
    8
    Join Date
    Jun 2009
    Posts
    34
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    namespace ..
    {
    
        class FactionInterpreter
        {
            private const uint FACTION_START_INDEX = 0xA37330;
            private const uint FACTION_POINTER = 0xA37340;
            private const uint FACTION_TOTAL = 0xA3732C;
    
            const uint HOSTILE_OFFSET_1 = 0x14;
            const uint HOSTILE_OFFSET_2 = 0x0C;
    
            const uint FRIENDLY_OFFSET_1 = 0x10;
            const uint FRIENDLY_OFFSET_2 = 0x0C;
    
            public static Reaction GetReaction(uint mobFaction)
            {
                //todo: fix
                 return FindReactionFromFactions(0, mobFaction);
            }
            public static Reaction GetReaction(uint localFaction, uint mobFaction)
            {
                if (localFaction < 1 || mobFaction < 1)
                {
                    return Reaction.Missing;
                }
                return FindReactionFromFactions(localFaction, mobFaction);
            }
            public static Reaction GetReaction(WoWObject localObj, WoWObject mobObj)
            {
                if (((Unit)localObj).Faction < 1 || ((Unit)mobObj).Faction < 1)
                {
                    return Reaction.Missing;
                }
    
                return FindReactionFromFactions(((Unit)localObj).Faction, ((Unit)mobObj).Faction);
            }
            private static Reaction FindReactionFromFactions(uint localFaction, uint mobFaction)
            {
                uint startIndex = (uint)ProcessIO.ReadInt(FACTION_START_INDEX);
                uint totalFactions = (uint)ProcessIO.ReadInt(FACTION_TOTAL);
                uint factionStartPoint = (uint)ProcessIO.ReadInt(FACTION_POINTER);
    
                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 && mobHash != null)
                {
                    reaction = CompareFactionHash(localHash, mobHash);
                }
                else
                {
                    reaction = Reaction.Unknown;
                }
    
                return reaction;
            }
    
            private static bool TestBits(uint lBitAddr, uint rBitAddr)
            {
                uint lBitParam = (uint)ProcessIO.ReadInt(lBitAddr);
                uint rBitParam = (uint)ProcessIO.ReadInt(rBitAddr);
    
                if ((lBitParam & rBitParam) != 0) return true;
    
                return false;
            }
            private static bool HashCompare(int hashIndex, int hashCompare, byte[] localBitHash, int mobHashCheck)
            {
                const int HASH_INDEX_INC = 4;
    
                hashCompare = BitConverter.ToInt32(localBitHash, hashIndex);
    
                for (uint i = 0; i < 4; i++)
                {
                    if (hashCompare == mobHashCheck)
                        return true;
    
                    hashIndex += HASH_INDEX_INC;
                    hashCompare = BitConverter.ToInt32(localBitHash, hashIndex);
    
                    if (hashCompare == 0)
                        break;
                }
                return false;
            }
            private static Reaction CompareFactionHash(uint? hash1, uint? hash2)
            {
    
    
                int localHashCheck = 0;
                int mobHashCheck = 0;
    
                int hashCompare = 0;
    
                byte[] localBitHash = ProcessIO.ReadBytes((uint)hash1, 64);
                byte[] mobBitHash = ProcessIO.ReadBytes((uint)hash2, 64);
    
    
    
                localHashCheck = BitConverter.ToInt32(localBitHash, 0x04);
                mobHashCheck = BitConverter.ToInt32(mobBitHash, 0x04);
    
    
    
                if (TestBits((uint)BitConverter.ToInt32(localBitHash, 0) + HOSTILE_OFFSET_1,
                                (uint)BitConverter.ToInt32(mobBitHash, 0) + HOSTILE_OFFSET_2))
                    return Reaction.Hostile;
    
    
    
                if (HashCompare(0x18, hashCompare, localBitHash, mobHashCheck))
                    return Reaction.Hostile;
    
    
    
                if (TestBits((uint)BitConverter.ToInt32(localBitHash, 0) + FRIENDLY_OFFSET_1,
                                (uint)BitConverter.ToInt32(mobBitHash, 0) + FRIENDLY_OFFSET_2))
                    return Reaction.Friendly;
    
    
    
                if (HashCompare(0x28, hashCompare, localBitHash, mobHashCheck))
                    return Reaction.Friendly;
    
    
                if (TestBits((uint)BitConverter.ToInt32(localBitHash, 0) + FRIENDLY_OFFSET_1,
                                 (uint)BitConverter.ToInt32(mobBitHash, 0) + FRIENDLY_OFFSET_2))
                    return Reaction.Friendly;
    
                if (HashCompare(0x28, hashCompare, localBitHash, mobHashCheck))
                    return Reaction.Friendly;
    
                return Reaction.Neutral;
            }
    
        }
    
        public enum Reaction
        {
            Unknown = -1,
            Hostile = 1,
            Neutral = 3,
            Friendly = 4,
            Missing = -2
    
        }
    }
    That's what I'm currently using.

  8. #8
    sefi89's Avatar Corporal
    Reputation
    9
    Join Date
    Apr 2012
    Posts
    16
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by maltikism View Post
    Code:
    namespace ..
    {
    
        class FactionInterpreter
        {
            private const uint FACTION_START_INDEX = 0xA37330;
            private const uint FACTION_POINTER = 0xA37340;
            private const uint FACTION_TOTAL = 0xA3732C;
    
            const uint HOSTILE_OFFSET_1 = 0x14;
            const uint HOSTILE_OFFSET_2 = 0x0C;
    
            const uint FRIENDLY_OFFSET_1 = 0x10;
            const uint FRIENDLY_OFFSET_2 = 0x0C;
    
            public static Reaction GetReaction(uint mobFaction)
            {
                //todo: fix
                 return FindReactionFromFactions(0, mobFaction);
            }
            public static Reaction GetReaction(uint localFaction, uint mobFaction)
            {
                if (localFaction < 1 || mobFaction < 1)
                {
                    return Reaction.Missing;
                }
                return FindReactionFromFactions(localFaction, mobFaction);
            }
            public static Reaction GetReaction(WoWObject localObj, WoWObject mobObj)
            {
                if (((Unit)localObj).Faction < 1 || ((Unit)mobObj).Faction < 1)
                {
                    return Reaction.Missing;
                }
    
                return FindReactionFromFactions(((Unit)localObj).Faction, ((Unit)mobObj).Faction);
            }
            private static Reaction FindReactionFromFactions(uint localFaction, uint mobFaction)
            {
                uint startIndex = (uint)ProcessIO.ReadInt(FACTION_START_INDEX);
                uint totalFactions = (uint)ProcessIO.ReadInt(FACTION_TOTAL);
                uint factionStartPoint = (uint)ProcessIO.ReadInt(FACTION_POINTER);
    
                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 && mobHash != null)
                {
                    reaction = CompareFactionHash(localHash, mobHash);
                }
                else
                {
                    reaction = Reaction.Unknown;
                }
    
                return reaction;
            }
    
            private static bool TestBits(uint lBitAddr, uint rBitAddr)
            {
                uint lBitParam = (uint)ProcessIO.ReadInt(lBitAddr);
                uint rBitParam = (uint)ProcessIO.ReadInt(rBitAddr);
    
                if ((lBitParam & rBitParam) != 0) return true;
    
                return false;
            }
            private static bool HashCompare(int hashIndex, int hashCompare, byte[] localBitHash, int mobHashCheck)
            {
                const int HASH_INDEX_INC = 4;
    
                hashCompare = BitConverter.ToInt32(localBitHash, hashIndex);
    
                for (uint i = 0; i < 4; i++)
                {
                    if (hashCompare == mobHashCheck)
                        return true;
    
                    hashIndex += HASH_INDEX_INC;
                    hashCompare = BitConverter.ToInt32(localBitHash, hashIndex);
    
                    if (hashCompare == 0)
                        break;
                }
                return false;
            }
            private static Reaction CompareFactionHash(uint? hash1, uint? hash2)
            {
    
    
                int localHashCheck = 0;
                int mobHashCheck = 0;
    
                int hashCompare = 0;
    
                byte[] localBitHash = ProcessIO.ReadBytes((uint)hash1, 64);
                byte[] mobBitHash = ProcessIO.ReadBytes((uint)hash2, 64);
    
    
    
                localHashCheck = BitConverter.ToInt32(localBitHash, 0x04);
                mobHashCheck = BitConverter.ToInt32(mobBitHash, 0x04);
    
    
    
                if (TestBits((uint)BitConverter.ToInt32(localBitHash, 0) + HOSTILE_OFFSET_1,
                                (uint)BitConverter.ToInt32(mobBitHash, 0) + HOSTILE_OFFSET_2))
                    return Reaction.Hostile;
    
    
    
                if (HashCompare(0x18, hashCompare, localBitHash, mobHashCheck))
                    return Reaction.Hostile;
    
    
    
                if (TestBits((uint)BitConverter.ToInt32(localBitHash, 0) + FRIENDLY_OFFSET_1,
                                (uint)BitConverter.ToInt32(mobBitHash, 0) + FRIENDLY_OFFSET_2))
                    return Reaction.Friendly;
    
    
    
                if (HashCompare(0x28, hashCompare, localBitHash, mobHashCheck))
                    return Reaction.Friendly;
    
    
                if (TestBits((uint)BitConverter.ToInt32(localBitHash, 0) + FRIENDLY_OFFSET_1,
                                 (uint)BitConverter.ToInt32(mobBitHash, 0) + FRIENDLY_OFFSET_2))
                    return Reaction.Friendly;
    
                if (HashCompare(0x28, hashCompare, localBitHash, mobHashCheck))
                    return Reaction.Friendly;
    
                return Reaction.Neutral;
            }
    
        }
    
        public enum Reaction
        {
            Unknown = -1,
            Hostile = 1,
            Neutral = 3,
            Friendly = 4,
            Missing = -2
    
        }
    }
    That's what I'm currently using.
    i tested and update offsets and don't works, returns missing :/

    public static Reaction GetReaction(uint localFaction, uint mobFaction)
    {
    if (localFaction < 1 || mobFaction < 1)
    {
    return Reaction.Missing;
    }
    return FindReactionFromFactions(localFaction, mobFaction);
    }


    uint localFaction and mob i supossed is BaseAddress, true?

    too i tested
    GetUnitReaction « Shynd’s WoW Modification Journal

    and updated the offsets and returns for all mobs -2

    :/ any idea?

Similar Threads

  1. [HELP] Reversing functions with IDA (unitReaction)
    By GrenadeFisher in forum WoW Memory Editing
    Replies: 5
    Last Post: 11-26-2012, 07:12 PM
  2. [wow][mac][3.3.0] Total number of factions? (UnitReaction)
    By Tanaris4 in forum WoW Memory Editing
    Replies: 10
    Last Post: 01-11-2010, 10:39 PM
All times are GMT -5. The time now is 09:33 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search