Is there a way to find out of a unit is hostile or not?
Thanks,
Bapes.
Is there a way to find out of a unit is hostile or not?
Thanks,
Bapes.
You can use this: API UnitIsEnemy - WoWWiki - Your guide to the World of Warcraft
Is there a way without lua?
Compare unit x's "UNIT_FIELD_FACTIONTEMPLATE" with unit y's "UNIT_FIELD_FACTIONTEMPLATE".
If they match, they are friendly. If they are 14 (which I believe is friendly to all), they are also friendly. There are probably some other flags to check to make sure they are friendly/not attackable (like neutral), but I don't know what they are off the top of my head.
To check hostile, it is everything that friendly is not.
But, the lua function is better to use, imo. It will save you all the troubles of storing friendly and hostile faction id's of the player. Plus, depending on reputation, you may be friendly with a faction like Timbermaw Hold or not.
tl;dr Use the lua function.
Last edited by ddebug; 10-19-2010 at 06:02 PM.
Ofcourse there is, reverse the lua function, and find the internal function calls.
do like
int orcs = UNIT_FIELD_FACTIONTEMPLATE.GetInt();
then like
if(orcs || trolls || hellhound = 14)
or
for combat loop
combat()
{
if(orc)}
{
engage true;
}
i was telling you how to go about it, not copy and paste lol
It STILL makes no sense.
Each race of the Horde will have the same faction id. Each race of the Alliance will have the same faction id. So, I don't know why you include "orcs, trolls". And, also, what in the world is a hellhound faction? There is no such thing. Most NPC units fall under the same hostile faction (whether they are Deadly Chickens or Flying Boars or Hellhounds) [that is one reason why most don't go around attacking each other in game].
Theres a bunch of masks for hostility and friendliness in the faction templates. Then you have to take into account reputation effects on it, then you have to check the PLAYER_FLAGS of yourself against the flags of the faction template (for anti pvp guards).
Yeh.. use the lua
Did any of you ever bother to look at the UnitIsEnemy API in question? Its nothing more than a wrapper around CGUnit_C__UnitReaction, which you can safely call from your own code. No need to go through Lua for this one.
check this: http://www.mmowned.com/forums/world-...treaction.html
or this: GetUnitReaction « Shynd’s WoW Modification Journal
may have to be updated for 4.0.1 but i guess it'll work fine.
tried it myself, but no luck yet. (don't have enough time to look deeper into it)
modifyied shynd's code, but getting strange values. sometimes players appear as friendly, sometimes as hostile. (or even returns of 0 / -1).
if someone figures this out for 4.0.1 (or some other way to check if the target is hostile - out of process) and could give me / us some hints, i would be very thankful
if i find a way by my own, i will post it here.
when you look at the Shynd's code all you need to do is copy&paste. Then what you need to do is to update 3 offsets from what I remember. Keep in mind that now you need to calculate offset from WoW.exe module base.
Here's how to find these offsets using OllyDbg (still can't get used myself to IDA, though I like it's visualisation and pseudocode;])
PUSH EBP
MOV EBP,ESP
MOV EAX,ANY
MOV ECX,ANY <=factionIndex
CMP EAX,ECX
PUSH EBX
PUSH ESI
MOV ESI,ANY <=factionPointer
PUSH EDI
MOV EDI,ANY <=totalFactions
JL ANY
CMP EAX,EDI
JG ANY
SUB EAX,ECX
MOV EBX,ANY
JMP ANY
XOR EBX ,EBX
MOV EAX,ANY
MOV EDX,ANY
MOV EAX,ANY
CMP EAX,ECX
JL ANY
CMP EAX,EDI*/
use the search function in OllyDbg to find this function, it hasn't changed for long, the offsets are described which is which in here. How to calculate the offset to use in the 4.0.1. Read the offset it says, substract the current offset of main module, you are done.bye;]
and then..wrap the result of calculation in a nice enum
public enum eGCUnitReaction
{
Hostile =1,
Neutral = 3,
Friendly =4,
Unknown=0
}
lOL:P
Last edited by rafalsk; 10-21-2010 at 10:59 AM.
holy **** dude, go copy game deception and make pay cheats more k thanksEach race of the Horde will have the same faction id. Each race of the Alliance will have the same faction id. So, I don't know why you include "orcs, trolls". And, also, what in the world is a hellhound faction? There is no such thing. Most NPC units fall under the same hostile faction (whether they are Deadly Chickens or Flying Boars or Hellhounds) [that is one reason why most don't go around attacking each other in game].
its an example of what to do, not a tutorial.. if you cant figure out what im saying, go ragequit your wrists with a boxcutter...