Find if mob are hostile / neutral / friendly menu

User Tag List

Results 1 to 11 of 11
  1. #1
    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)

    Find if mob are hostile / neutral / friendly

    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 ^_^

    Find if mob are hostile / neutral / friendly
  2. #2
    yossarian87's Avatar Corporal
    Reputation
    10
    Join Date
    Jan 2012
    Posts
    19
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    FYI, I've been looking into this same problem and the LazyBot source doesnt seem to be exactly right. It works for most units but I've found units for which it gives the wrong result. I haven't been able to spend enough time to track down the problem as of yet.

  3. #3
    Edder's Avatar Active Member
    Reputation
    22
    Join Date
    Dec 2008
    Posts
    77
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried UnitReaction?

    Code:
           
            /// <summary>
            /// Gets the unit reaction to the player with the units baseaddress.
            /// If return is smaller than 4 the unit is neutral or hated (I guess)
            /// </summary>
            public static uint UnitReaction(uint baseaddress)
            {
                uint pReaction = Memory.AllocateMemory(0x4);
    
                string[] asm = new string[]
                {
                    "push " + baseaddress,
                    "mov ecx, " + ObjectManager.LocalPlayer.BaseAddress,
                    "call " + (uint)Offsets.Injection.CGUnit_C__UnitReaction, // 0x7251C0
                    "mov [" + pReaction + "], eax",
                    "retn",
                };
    
                Hook.InjectAndExecute(asm);
    
                uint reaction = Memory.Read<uint>(pReaction);
    
                Memory.FreeMemory(pReaction);
    
                return reaction;
            }
    Its for 3.3.5a though...

  4. #4
    yossarian87's Avatar Corporal
    Reputation
    10
    Join Date
    Jan 2012
    Posts
    19
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay I found the bug in the code. Here is my (Java, sorry) implementation of finding the reaction between two units. Note that the 2 arguments to compute() are the "faction template" values from the unit descriptors. Also note that this only figures out the default reaction between 2 factions. It does NOT consider reputation (most factions you can gain reputation with will be reported as neutral even if you are actually hated or exhalted). Also hostiles may not be attackable because of stuff like pvp sanctuary regions or just because they're flagged to not be attackable (such as Therazane faction before you do their quests).

    Code:
    public enum Reaction {
    
        UNKNOWN,
        HOSTILE,
        NEUTRAL,
        FRIENDLY,
    
        ;
    
        private static final int FACTION_START_OFFSET = 0x99911C; // 4.3.4.15595
        private static final int FACTION_POINTER_OFFSET = FACTION_START_OFFSET + 0xC;
        private static final int FACTION_TOTAL_OFFSET = FACTION_START_OFFSET - 0x4;
        private static final int HOSTILE_OFFSET1 = 0x14;
        private static final int HOSTILE_OFFSET2 = 0x0C;
        private static final int HOSTILE_OFFSET3 = 0x18;
        private static final int FRIENDLY_OFFSET1 = 0x10;
        private static final int FRIENDLY_OFFSET2 = 0x0C;
        private static final int FRIENDLY_OFFSET3 = 0x28;
    
        private static boolean testBits(int lBitsAddr, int rBitsAddr) {
    
            MemoryReader r = MemoryReader.getMemoryReader();
            int lBits = r.readInt(lBitsAddr);
            int rBits = r.readInt(rBitsAddr);
            return 0 != (lBits & rBits);
        }
    
        private static boolean testPointers(int myPointer, int targetCheckPointer) {
    
            MemoryReader r = MemoryReader.getMemoryReader();
            int[] myPointerArray = new int[4];
            r.readArray(myPointer, myPointerArray);
            for (int i = 0; i < 4; i++) {
                int comparePointer = myPointerArray[i];
                if (0 == comparePointer) {
                    break;
                }
                if (comparePointer == targetCheckPointer) {
                    return true;
                }
            }
            return false;
        }
    
        public static Reaction compute(int myFaction, int targetFaction) {
    
            MemoryReader r = MemoryReader.getMemoryReader();
            int startIndex = r.readInt(r.getBaseAddress() + FACTION_START_OFFSET);
            int totalFactions = r.readInt(r.getBaseAddress() + FACTION_TOTAL_OFFSET);
            int factionStartPointer = r.readInt(r.getBaseAddress() + FACTION_POINTER_OFFSET);
            if (myFaction < startIndex && myFaction > totalFactions) {
                return UNKNOWN;
            }
            if (targetFaction < startIndex && targetFaction > totalFactions) {
                return UNKNOWN;
            }
            int myPointer = factionStartPointer + (myFaction - startIndex) * 4;
            int targetPointer = factionStartPointer + (targetFaction - startIndex) * 4;
            int myBitPointer = r.readInt(myPointer);
            int targetBitPointer = r.readInt(targetPointer);
            int targetCheckPointer = r.readInt(targetPointer + 4);
            if (testBits(myBitPointer + HOSTILE_OFFSET1, targetBitPointer + HOSTILE_OFFSET2)) {
                return HOSTILE;
            }
            if (testPointers(myPointer + HOSTILE_OFFSET3, targetCheckPointer)) {
                return HOSTILE;
            }
            if (testBits(myBitPointer + FRIENDLY_OFFSET1, targetBitPointer + FRIENDLY_OFFSET2)) {
                return FRIENDLY;
            }
            if (testPointers(myPointer + FRIENDLY_OFFSET3, targetCheckPointer)) {
                return FRIENDLY;
            }
            return NEUTRAL;
        }
    }
    Credit to LazyBot and Shynd for the original implementation. I just fixed a few bugs and cleaned up the code for readability.

  5. #5
    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)
    i see ty! only i teste for normal mobs (low lvl) ^_^ i will test you code yossarian thanks!

  6. #6
    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)
    i tested, dont work fine on me, this is my code (copy & paste and littles changes =P)


    Code:
    public Reaction compute(int myFaction, int targetFaction) 
            {
                int startIndex = Memory.Read<int>(BaseWoW + (uint)Reaction_offsets.FactionStartIndex);
                int totalFactions = Memory.Read<int>(BaseWoW + (uint)Reaction_offsets.FactionTotal);
                int factionStartPointer = Memory.Read<int>(BaseWoW + (uint)Reaction_offsets.FactionPointer);
                if (myFaction < startIndex && myFaction > totalFactions)
                {
                    return Reaction.Unknown;
                }
                if (targetFaction < startIndex && targetFaction > totalFactions)
                {
                    return Reaction.Unknown;
                }
                int myPointer = factionStartPointer + (myFaction - startIndex) * 4;
                int targetPointer = factionStartPointer + (targetFaction - startIndex) * 4;
                int myBitPointer = Memory.Read<int>((uint)myPointer);
                int targetBitPointer = Memory.Read<int>((uint)targetPointer);
                int targetCheckPointer = Memory.Read<int>((uint)(targetPointer + 4)); // revisar
                if (testBits(myBitPointer + (int)Reaction_offsets.HostileOffset1, targetBitPointer + (int)Reaction_offsets.HostileOffset2))
                {
                    return Reaction.Hostile;
                }
                if (testPointers(myPointer + (int)Reaction_offsets.HostileOffset3, targetCheckPointer))
                {
                    return Reaction.Hostile;
                }
                if (testBits(myBitPointer + (int)Reaction_offsets.FriendlyOffset1, targetBitPointer + (int)Reaction_offsets.FriendlyOffset2))
                {
                    return Reaction.Friendly;
                }
                if (testPointers(myPointer + (int)Reaction_offsets.FriendlyOffset3, targetCheckPointer))
                {
                    return Reaction.Friendly;
                }
                return Reaction.Neutral;
            }
    
            private static bool testBits(int lBitsAddr, int rBitsAddr)
            {
                int lBits = Memory.Read<int>((uint)lBitsAddr);
                int rBits = Memory.Read<int>((uint)rBitsAddr);
                return 0 != (lBits & rBits);
            }
    
            private static bool testPointers(int myPointer, int targetCheckPointer)
            {
    
                byte[] myPointerArray = new byte[4];
                myPointerArray = Memory.ReadBytes((uint)myPointer, 64);
                for (int i = 0; i < 4; i++)
                {
                    int comparePointer = myPointerArray[i];
                    if (0 == comparePointer)
                    {
                        break;
                    }
                    if (comparePointer == targetCheckPointer)
                    {
                        return true;
                    }
                }
                return false;
            }
    i think the part of :

    byte[] myPointerArray = new byte[4];
    myPointerArray = Memory.ReadBytes((uint)myPointer, 64);

    is wrong (for me)

  7. #7
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by sefi89 View Post
    i tested, dont work fine on me, this is my code (copy & paste and littles changes =P)

    [CODE]

    i think the part of :

    byte[] myPointerArray = new byte[4];
    myPointerArray = Memory.ReadBytes((uint)myPointer, 64);

    is wrong (for me)
    That very last part is so horribly wrong translated that I ... -.-
    Code:
            private static bool testPointers(uint myPointer, uint targetCheckPointer)
            {
                // byte[] myPointerArray = new byte[4]; dafuq.. feeding the gc?
                for (int i = 0; i < 4; i++)
                {
                    uint comparePointer = Memory.Read<uint>(myPointer + 4*i);
                    if (0 == comparePointer)
                    {
                        break;
                    }
                    if (comparePointer == targetCheckPointer)
                    {
                        return true;
                    }
                }
                return false;
            }
    Changes made in epic ownedcore editor ofc.
    Get your stuff right and before that, learn what you are doing there. You can't just copy and paste code and expect the community to fill in the gaps for you, just because you are too lazy to learn beginner level C# (you can sufficiently learn those concepts in as little as 3 months). If I was you, posting that pile of shit and admitting to not being able to correct such basic conversion errors would embarrass the hell out of me. Programming does not mean to get rid of the red underlining in your code. It's horrible how you turn that well written piece of Java into such rubbish.

  8. #8
    yossarian87's Avatar Corporal
    Reputation
    10
    Join Date
    Jan 2012
    Posts
    19
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by sefi89 View Post
    i think the part of :

    byte[] myPointerArray = new byte[4];
    myPointerArray = Memory.ReadBytes((uint)myPointer, 64);

    is wrong (for me)
    In Java, an int is 32 bits. So that array represents 4 32-bit integers, or 16 bytes total.
    Last edited by yossarian87; 05-03-2012 at 07:00 PM.

  9. #9
    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)
    Thanks you again!!

    1 bytes = 8 bits
    (then 4 = 32 )

    then i changed my code, and now works perfectly!!

    myPointerArray = Memory.ReadBytes((uint)myPointer, 4);

    rep+

  10. #10
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by sefi89 View Post
    myPointerArray = Memory.ReadBytes((uint)myPointer, 4);
    The message you have entered is too short. Please lengthen your message to at least 10 characters.

  11. #11
    TOM_RUS's Avatar Legendary
    Reputation
    914
    Join Date
    May 2008
    Posts
    699
    Thanks G/R
    0/52
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It seems same thing as above, but in more readable form: Paste2 - Viewing Paste 2009400
    Basically, you just need lookup FactionTemplate.dbc pointers for both units using UNIT_FIELD_FACTIONTEMPLATE id's...
    Last edited by TOM_RUS; 05-07-2012 at 06:46 AM.

Similar Threads

  1. A very useful target macro/trying to find a mob
    By Insomniaco in forum WoW UI, Macros and Talent Specs
    Replies: 4
    Last Post: 08-08-2016, 05:45 PM
  2. A tip for when you are exploring with friends!
    By Dante in forum World of Warcraft Exploration
    Replies: 0
    Last Post: 09-17-2012, 01:52 PM
  3. Trinity ICC mobs are friendly?
    By Flushie in forum WoW EMU Questions & Requests
    Replies: 3
    Last Post: 06-07-2010, 09:02 PM
  4. THANKS! and another question! hostile/friendly/neutral
    By ShoniShilent in forum WoW Memory Editing
    Replies: 26
    Last Post: 12-02-2008, 03:17 AM
  5. Friendly to the Scourge while normal form / all mobs neutral
    By Enraged in forum World of Warcraft Exploits
    Replies: 8
    Last Post: 10-26-2008, 08:08 PM
All times are GMT -5. The time now is 01:14 PM. 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