Jump to content

Creature type of WoWUnit


Recommended Posts

Good day.

I've got a List of WoWUnits, and i need to check, is there any WoWUnit with a specific creature type (lets say, humanoind, for example) in that List. Is is possible?
Currently i can check the creature type of a target, but can't do the same for a WoWUnit from list.

Thank you.

Link to comment
Share on other sites

Yeah, but there is no WoWUnit method like CreatureType, that's the problem. And the only lua code i was able to find returns creature type of my target also ?

Im doing something like this:

var mobsList = new List<WoWUnit>();
mobsList.AddRange(ObjectManager.GetObjectWoWUnit().Where(u => u.Type != WoWObjectType.Player && u.blah-blah-blah).ToList());

 

Link to comment
Share on other sites

You must 'touch' the unit to get the info. For Development Tools:

Lua.LuaDoString("DEFAULT_CHAT_FRAME:AddMessage(\"" + "-------------Start------------------" + "\")");
foreach (WoWUnit mob in wManager.Wow.ObjectManager.ObjectManager.GetObjectWoWUnit())
{
    var name = mob.Name;        
    var baseAdress = mob.GetBaseAddress;
    wManager.Wow.Helpers.Interact.InteractGameObject(baseAdress,true,false);
    var type = mob.CreatureTypeTarget;
    Lua.LuaDoString("DEFAULT_CHAT_FRAME:AddMessage(\"" + name + " " + type + "\")");
}
Lua.LuaDoString("DEFAULT_CHAT_FRAME:AddMessage(\"" + "-------------Stop------------------" + "\")");

There is another way to touch the unit ( without visible changing targets - nasty ye? ) You must use lua , focus and write the guid from scanning under focus then request the value. 

Lua.LuaDoString("DEFAULT_CHAT_FRAME:AddMessage(\"" + "-------------Start------------------" + "\")");
foreach (WoWUnit mob in wManager.Wow.ObjectManager.ObjectManager.GetObjectWoWUnit())
{
	var name = mob.Name;        
	var tmp = wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid;
	wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid = mob.Guid;
	string type = Lua.LuaDoString<string>(@"creatureType = UnitCreatureType(""focus"")", "creatureType");
	wManager.Wow.ObjectManager.ObjectManager.Me.FocusGuid = tmp;
	Lua.LuaDoString("DEFAULT_CHAT_FRAME:AddMessage(\"" + name + " " + type + "\")");
}
Lua.LuaDoString("DEFAULT_CHAT_FRAME:AddMessage(\"" + "-------------Stop------------------" + "\")");

And this is working solution for that problem. Credits for @reapler for showing the method with guid replacement. Tested on 2.4.3 nightbane and works here.

Link to comment
Share on other sites

Thank you a lot guys for advice. Unfortunately my test accounts got banned, that i was going to use for that feature test at exact same day i've asked about this :). Will have to level new one first to continue with this idea.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...