A question to CanAttack memory menu

User Tag List

Results 1 to 5 of 5
  1. #1
    NightlyBlooD's Avatar Member
    Reputation
    2
    Join Date
    Sep 2012
    Posts
    26
    Thanks G/R
    6/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A question to CanAttack memory

    Hello, friends.
    Tell me, please, what am I doing wrong?
    When the delegate is called, the CanAttack returns true | false
    Code:
    _BOOL1 __thiscall CGUnit_C::CanAttack(int this, _DWORD *a2)
    But when I use it for non-strategic or hostile units (which I cannot attack), Tru returns.
    Tried to swap units - still returns true
    Code:
    [UnmanagedFunctionPointer(CallingConvention.ThisCall)]
    private delegate bool IsCanAttackDelegate(IntPtr Player, IntPtr Unit);
    ...
    bool IsCanAttack()
    {
    CanAttack = Memory.RegisterDelegate<IsCanAttackDelegate>((IntPtr)IsCanAttack); // 3.3.5a 00729740
    return CanAttack(Player.Ptr, Unit.Ptr);
    }
    At the same time, Lua_UnitCanAttack () returns true and false depending on the sequence of the specified units.
    On these screenshots are indicated the units whose CanAttack returns true



    here's a dump from the IDA function Lua_UnitCanAttack
    Code:
    signed int __cdecl Lua_UnitCanAttack(int a1)
    {
        char *v1; // eax
        void *v2; // edi
        char *v3; // eax
        _DWORD *v4; // eax
        signed int result; // eax
    
        if ( FrameScript::IsString(a1, 1) && FrameScript::IsString(a1, 2) )
        {
            v1 = (char *)FrameScript::ToLString(a1, 1, 0);
            v2 = GetUnitFromName(v1);
            v3 = (char *)FrameScript::ToLString(a1, 2, 0);
            v4 = GetUnitFromName(v3);
            if ( v2 && v4 && CGUnit_C::CanAttack((int)v2, v4) )
            {
                FrameScript::PushNumber(a1, 1.0);
                result = 1;
            }
            else
            {
                FrameScript::pushnil(a1);
                result = 1;
            }
        }
        else
        {
            FrameScript::DisplayError(a1, "Usage: UnitCanAttack(\"unit\", \"otherUnit\")");
            result = 0;
        }
        return result;
    }

    A question to CanAttack memory
  2. #2
    Alex__'s Avatar Member
    Reputation
    8
    Join Date
    Dec 2018
    Posts
    12
    Thanks G/R
    1/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see caller and callee use al register, low word. Maybe c# bool read whole eax and gets wrong result?
    What if you change delegate return type to uint and then print returned value?

  3. #3
    NightlyBlooD's Avatar Member
    Reputation
    2
    Join Date
    Sep 2012
    Posts
    26
    Thanks G/R
    6/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Alex__ View Post
    What if you change delegate return type to uint and then print returned value?
    Checked uint, int, byte, bool - returns 1 value of all netral and enemy units
    for neutral units it always shows the truth regardless of whether it is attacked or not
    Code:
    
    --UInt
    [18:51:56] Кабестанский костолом (57 lvl)
    IsHostile: False
    IsNetral: True
    IsFriendly: False
    IsCanAttack: 1 Type: System.UInt32
    
    [18:52:03] Мупси Пупси (20 lvl)
    IsHostile: False
    IsNetral: False
    IsFriendly: True
    IsCanAttack: 0 Type: System.UInt32
    
    
    
    --Int
    [18:47:10] Кабестанский костолом (57 lvl)
    IsHostile: False
    IsNetral: True
    IsFriendly: False
    IsCanAttack: 1 Type: System.Int32
    
    [18:47:19] Мупси Пупси (20 lvl)
    IsHostile: False
    IsNetral: False
    IsFriendly: True
    IsCanAttack: 0 Type: System.Int32
    
    
    
    --Byte
    [18:49:00] Кабестанский костолом (57 lvl)
    IsHostile: False
    IsNetral: True
    IsFriendly: False
    IsCanAttack: 1 Type: System.Byte
    
    [18:49:06] Мупси Пупси (20 lvl)
    IsHostile: False
    IsNetral: False
    IsFriendly: True
    IsCanAttack: 0 Type: System.Byte
    
    
    --Boolean
    [18:54:35] Кабестанский костолом (57 lvl)
    IsHostile: False
    IsNetral: True
    IsFriendly: False
    IsCanAttack: True Type: System.Boolean
    
    [18:54:48] Мупси Пупси (20 lvl)
    IsHostile: False
    IsNetral: False
    IsFriendly: True
    IsCanAttack: False Type: System.Boolean
    Last edited by NightlyBlooD; 06-17-2019 at 01:41 PM.

  4. #4
    Alex__'s Avatar Member
    Reputation
    8
    Join Date
    Dec 2018
    Posts
    12
    Thanks G/R
    1/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont know, have not checked myself.
    Try read descriptor unit flags, test if it has NotAttackable flag

  5. #5
    Alex__'s Avatar Member
    Reputation
    8
    Join Date
    Dec 2018
    Posts
    12
    Thanks G/R
    1/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I confirm that Lua: UnitCanAttack might return results different from CGUnit_C::CanAttack
    npcs with NotAttackable (0x100) flag make it happen and enemy players in sanctuary zone.
    Looks like If you want to use CGUnit_C::CanAttack, additional checks are required (at least for this flag presence).
    Players do not have this flag though.
    But UnitReaction gives me expected results (Lua = CGUnit_C::UnitReaction+1)
    Last edited by Alex__; 06-17-2019 at 08:44 PM.

  6. Thanks Corthezz (1 members gave Thanks to Alex__ for this useful post)

Similar Threads

  1. Replies: 5
    Last Post: 12-17-2014, 10:13 AM
  2. Question to WoW 4.0.3 Memory Adresses
    By Nextlive in forum WoW Bots Questions & Requests
    Replies: 0
    Last Post: 12-31-2010, 06:54 AM
  3. Question: TOS and Model Changing
    By Sergioz in forum WoW ME Questions and Requests
    Replies: 1
    Last Post: 07-22-2007, 05:25 PM
  4. Question to all you exploiters!
    By Ðeception in forum World of Warcraft General
    Replies: 1
    Last Post: 01-04-2007, 06:35 PM
  5. question to all pro editors
    By XPZaIN in forum WoW ME Questions and Requests
    Replies: 1
    Last Post: 11-07-2006, 08:56 AM
All times are GMT -5. The time now is 06:08 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search