| | WoW Memory Editing WoW Memory Editing for learning purposes only.
This section is more advanced than others on MMOwned Read the section specific rules, infractions will be given out if u break them!That is including the expectations! - If you don't meet them then don't post |  | | 
09-24-2009
|  | Master Sergeant | | | Join Date: May 2008
Posts: 88
Reputation: 17 Level up: 32%, 342 Points needed |   | | | Who is attacking me? Hi everyone,
how do you detect whether a mob is attacking you? When I just read the mob's target, sometimes mobs are targeting me without attacking and sometimes players do target me without attacking either.
Is there some flag like isInFightWithGuid?
__________________ Viano
http://www.mmowned.com/forums/bots-programs/171327-wow-toons-name-generator.html | Donate to remove ads, get your "DONATOR title, and get access to the MMOwned community's elite Shoutbawx. 
09-24-2009
|  | New User | | | Join Date: Sep 2009
Posts: 4
Reputation: 1 Level up: 13%, 349 Points needed | | | There's probably a better way to do it, but what I do is monitoring my Health all the time. Then, in a Timer, I got a procedure that looks like this: Code: if myHealth < myMaxHealth then
//I lost some health, is someone attacking me or a priest buffed me ?
tempHealth = myHealth
if myHealth < tempHealth then //there's definitly something wrong
attack()
End if
End if
It's not the real code, but it's pretty self explanary and it's the way I do it. It's working, but you have to take some damage before to fight back, wich is obviously, not the best method... | 
09-24-2009
|  | Master Sergeant | | | Join Date: May 2008
Posts: 88
Reputation: 17 Level up: 32%, 342 Points needed |   | | Quote:
Originally Posted by Kandyman There's probably a better way to do it, but what I do is monitoring my Health all the time. Then, in a Timer, I got a procedure that looks like this: Code: if myHealth < myMaxHealth then
//I lost some health, is someone attacking me or a priest buffed me ?
tempHealth = myHealth
if myHealth < tempHealth then //there's definitly something wrong
attack()
End if
End if
It's not the real code, but it's pretty self explanary and it's the way I do it. It's working, but you have to take some damage before to fight back, wich is obviously, not the best method... | So if a debuff taking your health is on your toon after a fight you think you are beeing attacked?
__________________ Viano
http://www.mmowned.com/forums/bots-programs/171327-wow-toons-name-generator.html | 
09-24-2009
|  | New User | | | Join Date: Sep 2009
Posts: 4
Reputation: 1 Level up: 13%, 349 Points needed | | | Quote: |
So if a debuff taking your health is on your toon after a fight you think you are beeing attacked?
| That would explain a lot of things ...  lol
You are right, I even didn't think about it. | 
09-24-2009
| | Sergeant | | | Join Date: Nov 2008
Posts: 67
Reputation: 32 Level up: 16%, 423 Points needed |   | | Quote:
Originally Posted by Viano Hi everyone,
how do you detect whether a mob is attacking you? When I just read the mob's target, sometimes mobs are targeting me without attacking and sometimes players do target me without attacking either.
Is there some flag like isInFightWithGuid? | here is lua code, the one i am using
function _validEnemy(u)
local rc
rc = UnitExists(u) ;
rc = rc and not UnitIsDeadOrGhost(u) ;
rc = rc and UnitCanAttack("player", u) ;
rc = rc and not UnitIsPlayer(u) ;
rc = rc and (not UnitIsTapped(u) or (UnitIsTapped(u) and UnitIsTappedByPlayer(u)))
rc = rc and ( UnitAffectingCombat(u) or ( not UnitAffectingCombat(u) and UnitName(u .. "target") == UnitName("player")))
return rc
end | 
09-24-2009
| | New User | | | Join Date: Dec 2007
Posts: 48
Reputation: 3 Level up: 16%, 424 Points needed | | | | Hi
One simple solution would be to check if you are in combat.
if you are in combat scan nearby mobs. If any mob is targeting you ..
you can be fairly sure he is attacking you. :P
Last edited by xzidez; 09-24-2009 at 12:22 PM.
| 
09-24-2009
|  | Master Sergeant | | | Join Date: May 2008
Posts: 88
Reputation: 17 Level up: 32%, 342 Points needed |   | | Quote:
Originally Posted by ostapus here is lua code, the one i am using
function _validEnemy(u)
local rc
rc = UnitExists(u) ;
rc = rc and not UnitIsDeadOrGhost(u) ;
rc = rc and UnitCanAttack("player", u) ;
rc = rc and not UnitIsPlayer(u) ;
rc = rc and (not UnitIsTapped(u) or (UnitIsTapped(u) and UnitIsTappedByPlayer(u)))
rc = rc and ( UnitAffectingCombat(u) or ( not UnitAffectingCombat(u) and UnitName(u .. "target") == UnitName("player")))
return rc
end | Ok, that would probably work but looks like an overkill. Thank you.
What parameter is u? Is it the Guid? Quote:
Originally Posted by xzidez ...
One simple solution would be to check if you are in combat.
if you are in combat scan nearby mobs. If any mob is targeting you ..
you can be fairly sure he is attacking you. :P | That is not a solution because players and mobs are sometimes targeting me without fighting with me.
__________________ Viano
http://www.mmowned.com/forums/bots-programs/171327-wow-toons-name-generator.html
Last edited by Viano; 09-24-2009 at 12:47 PM.
| 
09-24-2009
| | Sergeant | | | Join Date: Nov 2008
Posts: 67
Reputation: 32 Level up: 16%, 423 Points needed |   | | Quote:
Originally Posted by Viano Ok, that would probably work but looks like an overkill. Thank you.
What parameter is u? Is it the Guid?
That is not a solution because players and mobs are sometimes targeting me without fighting with me. | u - is standard wow unit, like "target", "focus" etc....
in that case i am using "EnumVisibleObjects" with calllback like this one
function enumCallback(hguid, lguid)
_SetFocus(hguid, lguid)
if ( _validEnemy("focus") ) then <we found enemy who is attacking us or we can attack>; SetTarget(hguid, lguid); end
end | 
09-24-2009
| | Sergeant Major | | | Join Date: Oct 2008
Posts: 146
Reputation: 12 Level up: 54%, 231 Points needed |  | | Quote:
Originally Posted by ostapus u - is standard wow unit, like "target", "focus" etc....
in that case i am using "EnumVisibleObjects" with calllback like this one
function enumCallback(hguid, lguid)
_SetFocus(hguid, lguid)
if ( _validEnemy("focus") ) then <we found enemy who is attacking us or we can attack>; SetTarget(hguid, lguid); end
end | I take it EnumVisibleObjects is a function you are calling via injection? Do you think this is available as a flag for those who only do memory reading? | 
09-24-2009
| | Sergeant | | | Join Date: Nov 2008
Posts: 67
Reputation: 32 Level up: 16%, 423 Points needed |   | | Quote:
Originally Posted by Tanaris4 I take it EnumVisibleObjects is a function you are calling via injection? Do you think this is available as a flag for those who only do memory reading? | why not ? there are tons of examples on this forum how to iterate over object list out of proc and execute lua string
pseudo code
notfound = true ;
object = ObjectList ;
targetguid = 0 ;
while (object && targetguid == 0)
{
guid = object.guid
setfocus(guid)
rc = lua_doString("IsEnemy(\"focus\")") ;
if ( rc ) targetguid = guid ;
object = getnextobject ;
}
if ( targetguid )
here is our enemy
something like that... | 
09-24-2009
| | Sergeant Major | | | Join Date: Oct 2008
Posts: 146
Reputation: 12 Level up: 54%, 231 Points needed |  | | | How do you use lua_doString out of process? | 
09-24-2009
|  | Master Sergeant | | | Join Date: May 2008
Posts: 88
Reputation: 17 Level up: 32%, 342 Points needed |   | | Quote:
Originally Posted by Tanaris4 How do you use lua_doString out of process? | Asm. Lots of my noobish posts in this forum
__________________ Viano
http://www.mmowned.com/forums/bots-programs/171327-wow-toons-name-generator.html | 
09-25-2009
| | Contributor | | | Join Date: Sep 2006 Location: Jaedenar O.o
Posts: 569
Reputation: 162 Level up: 58%, 336 Points needed |     | | Quote:
Originally Posted by Viano Asm. Lots of my noobish posts in this forum  | Well, fasm_managed uses CreateRemoteThread to execute the ASM, so it's not completely out of process.
Might be the only possible way to use the ASM though
__________________ http://www.main-dev.com/
I was here. ~Dragon[Sky] I was here too. ~Kuiren | 
09-25-2009
|  | Master Sergeant | | | Join Date: May 2008
Posts: 88
Reputation: 17 Level up: 32%, 342 Points needed |   | | Ok, the easiest way to achieve this is comparing whether a mob is in combat and has me as target. Quote:
// IsAttackingMe ripped of from BabBot
Convert.ToBoolean((ReadDescriptor<uint>(Constants.UnitFields.UNIT_FIELD_FLAGS) >> 0x13) & 1);
|
__________________ Viano
http://www.mmowned.com/forums/bots-programs/171327-wow-toons-name-generator.html | 
09-25-2009
| | Sergeant | | | Join Date: Nov 2008
Posts: 67
Reputation: 32 Level up: 16%, 423 Points needed |   | | Quote:
Originally Posted by Viano Ok, the easiest way to achieve this is comparing whether a mob is in combat and has me as target. | if you solo - yes (there are some exception though, rare one). if you in group - mob may not attack you ) |  | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -4. The time now is 07:41 AM. |