iMod 99 Posted April 23, 2016 Share Posted April 23, 2016 protected WoWPlayer GetPartyTank() { WoWPlayer tank; var lua = new[] { "partyTank = \"\";", "for groupindex = 1,MAX_PARTY_MEMBERS do", " if (UnitInParty(\"party\" .. groupindex)) then", " local role = UnitGroupRolesAssigned(\"party\" .. groupindex);", " if role == \"TANK\" then", " local name, realm = UnitName(\"party\" .. groupindex);", " partyTank = name;", " return;", " end", " end", "end", }; // Get tank name string tankName = Lua.LuaDoString(lua, "partyTank"); if (string.IsNullOrEmpty(tankName)) { // Set us as tank tank = this.Me; } else { // Set tank tank = this.GetPartyMember().Single(p => p.Name == tankName); } return tank; } i'm looking for a way to get the tank object of a party or raid. it seems i'm something missing couz i get an empty string back. Link to comment Share on other sites More sharing options...
Droidz 2734 Posted April 26, 2016 Share Posted April 26, 2016 On WOTLK "UnitGroupRolesAssigned" change, try this (not tested): public WoWPlayer GetPartyTank() { WoWPlayer tank = new WoWPlayer(0); var lua = @" for groupindex = 1,MAX_PARTY_MEMBERS do if (UnitInParty('party' .. groupindex)) then local isTank, isHealer, isDamage = UnitGroupRolesAssigned('party' .. groupindex); if isTank then local name = UnitName('party' .. groupindex); return name; end end end return ''; "; // Get tank name string tankName = Lua.LuaDoString<string>(lua); if (!string.IsNullOrEmpty(tankName)) { tankName = tankName.Trim().ToLower(); //foreach (var p in Party.GetPartyHomeAndInstance()) foreach (var p in ObjectManager.GetObjectWoWPlayer()) { if (p != null && p.IsValid && p.Name.Trim().ToLower() == tankName) { tank = new WoWPlayer(p.GetBaseAddress); break; } } } return tank; } iMod 1 Link to comment Share on other sites More sharing options...
iMod 99 Posted April 26, 2016 Author Share Posted April 26, 2016 Thanks works. Where is the different between Party.GetParty() and Party.GetPartyHomeAndInstance() ? Link to comment Share on other sites More sharing options...
Droidz 2734 Posted April 27, 2016 Share Posted April 27, 2016 I have fixed code (I use ObjectManager.GetObjectWoWPlayer() instead Party.GetPartyHomeAndInstance() to be sure not to miss tank). Home is for normal group, Instance is for raid group (http://wow.gamepedia.com/API_GetNumPartyMembers and http://wow.gamepedia.com/API_GetNumRaidMembers ). Link to comment Share on other sites More sharing options...
iMod 99 Posted April 28, 2016 Author Share Posted April 28, 2016 I see, thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now