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?
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?
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:
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 workCode:signed int __cdecl Script_UnitCanAttack(int luaStatePtr)
Another way to invoke this function would be by using FrameScript_Execute and FrameScript_Get(Localized)TextCode: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 } }
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
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.
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
oh damn, was abit more complicated than I thought. Thanx alot for your help tho, I look into it.