Script_UnitCanAttack how? menu

User Tag List

Results 1 to 5 of 5
  1. #1
    seasick's Avatar Sergeant
    Reputation
    16
    Join Date
    Aug 2013
    Posts
    49
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Script_UnitCanAttack how?

    can anyone help me out and explain how and what arguments to pass when using
    Script_UnitCanAttack = 0x4A0B0A
    and how to get the return value

    pleeease?

    Script_UnitCanAttack how?
  2. #2
    xalcon's Avatar Contributor ふたなり
    Authenticator enabled
    Reputation
    198
    Join Date
    Oct 2008
    Posts
    291
    Thanks G/R
    20/58
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Most (not all!) Script_XXXXXXX functions are registered to the lua vm. Script_UnitCanAttack is the ingame command for UnitCanAttack - World of Warcraft Programming: A Guide and Reference for Creating WoW Addons
    The functions expects 2 Unit Keywords (also known as "unitID", see API Meta-Types - World of Warcraft Programming: A Guide and Reference for Creating WoW Addons) and checks if unit 1 can attack unit 2.

    The function has (like most registered functions) the following signature:
    Code:
    signed int __cdecl Script_UnitCanAttack(int luaStatePtr)
    If you want to invoke this function yourself, you need to call some lua vm functions. I've not tested this, but something like this might work
    Code:
    lua_pushstring(luaStatePtr, "player");
    lua_pushstring(luaStatePtr, "boss1target");
    int valuesOnStack = Script_UnitCanAttack(luaStatePtr);
    if(valuesOnStack > 0)
    {
        if(lua_isnil(luaStatePtr, 1))
        {
            // the unit "player" cannot attack the target of the boss1 unit
        }
        else
        {
            // the unit player can attack the target of the boss1 unit
        }
    }
    Another way to invoke this function would be by using FrameScript_Execute and FrameScript_Get(Localized)Text

    But if you are injected (which would be the case if you want to invoke this function yourself) just call CGUnit_C::CanAttack @ 0x41A3DC in build 18291
    Last edited by xalcon; 05-31-2014 at 04:04 PM.
    "Threads should always commit suicide - they should never be murdered" - DirectX SDK

  3. #3
    seasick's Avatar Sergeant
    Reputation
    16
    Join Date
    Aug 2013
    Posts
    49
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanx alot for the answer

    so uh, lets say i inject. Do i push 2 strings, then call, and then grab the return value in eax, or do i pop the value?
    Last edited by seasick; 05-31-2014 at 04:33 PM.

  4. #4
    xalcon's Avatar Contributor ふたなり
    Authenticator enabled
    Reputation
    198
    Join Date
    Oct 2008
    Posts
    291
    Thanks G/R
    20/58
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    no,
    1.: the return value is not in eax. eax contains the amount of return values on the lua stack (lua functions can return more then 1 value!)
    2.: you cant just "push 2 strings", you need to use the according lua function to push onto the lua stack, not the thread stack!

    to get something on the lua stack, call the push functions:
    lua_pushstring
    lua_pushnumber
    lua_pushinteger
    lua_pushboolean
    lua_pushnil

    to get a value of the lua stack, you need to call the according read function:
    lua_tostring
    lua_tolstring
    lua_toboolean
    lua_tonumber
    lua_tointeger

    you can check the type for given offset with either lua_type (which returns the type id) or with lua_isstring/lua_isnumber/lua_isnil/etc which are normaly just some macros but it seems blizzard has made some changes to the lua code they are using (they use thiscall a lot, even when lua normally doesnt use thiscalls)... but for real, just use CGUnit_C::CanAttack :P Its way easier (no lua stuff needed) and more flexible (since you can use object pointers instead of unit keywords)
    "Threads should always commit suicide - they should never be murdered" - DirectX SDK

  5. #5
    seasick's Avatar Sergeant
    Reputation
    16
    Join Date
    Aug 2013
    Posts
    49
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh damn, was abit more complicated than I thought . Thanx alot for your help tho, I look into it.

Similar Threads

  1. How to Make a Character with Cool Letters
    By Cyboi in forum World of Warcraft Guides
    Replies: 62
    Last Post: 08-21-2007, 01:52 PM
  2. How to chain 2+ spells into a macro
    By Matt in forum World of Warcraft Exploits
    Replies: 22
    Last Post: 07-03-2007, 12:33 AM
  3. How to: Send Anonymous Mail Exploit
    By Matt in forum World of Warcraft Exploits
    Replies: 9
    Last Post: 04-05-2007, 10:51 PM
  4. How to win AV as alliance
    By Matt in forum World of Warcraft Guides
    Replies: 11
    Last Post: 12-16-2006, 08:25 PM
  5. How to get to the outlands on a live blizzard server
    By Matt in forum World of Warcraft Exploits
    Replies: 4
    Last Post: 06-16-2006, 05:27 PM
All times are GMT -5. The time now is 07:02 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