I created a plugin for managing a Party, you set the leader, and followers, and it will be sure that your party contains the members you selected, as well as only accepting invites from the selected leader. All finished, working and tested: Changelog: v0.0.1.0 - Made, buggy, poop, etc. v0.0.1.2 - Updated to use PartyMembersInfo ... still having issues... v0.0.1.5 - Working perfectly! Thanks to StormChasing for linking me to a better method of LUA for UnitName . v0.0.2.0 - Working Actually Perfectly. Added some extra checks for Party Sanity, and re-worked the logic a bit. PHP: using System;using System.Collections.Generic;using System.Drawing;using System.Linq;using Styx;using Styx.Helpers;using Styx.Plugins.PluginClass;using Styx.WoWInternals;using Styx.WoWInternals.WoWObjects;namespace RaFBuddy{ public class PartyBuddy : HBPlugin { private bool _firstPulse = true; private readonly LocalPlayer _me = StyxWoW.Me; private readonly WaitTimer _partyCheckTimer = WaitTimer.ThirtySeconds; private List<string> _followerList; private MemberType _memberType; private readonly List<string> _partyMembers = new List<string>(4); private string _leaderName; private readonly WaitTimer _createPartyTimer = WaitTimer.FiveSeconds; public override void Pulse() { if (_firstPulse) { // -- CONFIGURATION -----------------// _followerList = new List<string> {"player1", "player2", "player3", "player4"}; _leaderName = "leaderName"; _memberType = _me.Name == _leaderName ? MemberType.Leader : MemberType.Member; //EOF CONFIGURATION -----------------// Lua.Events.AttachEvent("PARTY_INVITE_REQUEST", HandlePartyInvite); Lua.Events.AttachEvent("PARTY_MEMBERS_CHANGED", HandlePartyMembersChanged); Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: Attached Events"); _firstPulse = false; } if (_partyCheckTimer.IsFinished) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: Party Check Timer Finished"); CheckForFollowers(); _partyCheckTimer.Reset(); } } private static bool IsPartyLeader() { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: IsPartyLeader()?"); return Lua.GetReturnVal<bool>("return IsPartyLeader();", 0); /* * isLeader = IsPartyLeader() * Returns: * isLeader - 1 if the player is the party leader; otherwise nil (1nil) */ } private void CheckForFollowers() { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers():"); if (!_me.IsInParty) // If i'm not in a Party { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers(): I am NOT in a Party"); if (_memberType == MemberType.Leader) //If i'm not in a Party AND i'm SUPPOSED to be the leader. { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers(): I AM supposed to be the Leader"); CreateParty(); return; } } if (!IsPartyLeader()) //If i'm in a Party, and I am NOT the Leader { if (_memberType == MemberType.Leader) //If i'm in a Party, and I am NOT the Leader, and I'm Supposed to be, GTFO!? { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers(): I am NOT the Leader, and i'm supposed to be! - Leaving Party"); Lua.DoString("LeaveParty()"); StyxWoW.SleepForLagDuration(); } else //If i'm in a Party, and I am NOT SUPPOSED to be the leader make sure leader is correct { var isLeaderCorrect = Lua.GetReturnVal<bool>("return UnitIsPartyLeader(\"" + _leaderName + "\");", 0); if (!isLeaderCorrect) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers(): The Party Leader is Incorrect (WTF?) - Leaving Party"); Lua.DoString("LeaveParty()"); StyxWoW.SleepForLagDuration(); } return; } } else { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers(): I AM the Party Leader"); } BuildPartyList(); foreach (var user in _followerList.Where(user => !_partyMembers.Contains(user))) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers(): Party Does NOT contain " + user + " attempting to correct"); if (_partyMembers.Count < 4) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers(): Party has room, attempting to invite " + user + " to the party"); Lua.DoString("InviteUnit(\"" + user + "\");"); StyxWoW.SleepForLagDuration(); } if (_partyMembers.Count == 4) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers(): Party is Full, Leaving Party"); Lua.DoString("LeaveParty()"); StyxWoW.SleepForLagDuration(); } } } private void CreateParty() { if (_createPartyTimer.IsFinished) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CreateParty(): Creating Party!"); foreach (var user in _followerList) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CreateParty(): Inviting " + user); Lua.DoString("InviteUnit(\"" + user + "\");"); StyxWoW.SleepForLagDuration(); } _createPartyTimer.Reset(); } } private void HandlePartyMembersChanged(object sender, LuaEventArgs args) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: PARTY_MEMBERS_CHANGED"); if (_me.IsInParty) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: PARTY_MEMBERS_CHANGED: I am IN a party."); Lua.DoString("StaticPopup_Hide(\"PARTY_INVITE\");"); StyxWoW.SleepForLagDuration(); BuildPartyList(); } } private void BuildPartyList() { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: BuildPartyList()"); using (new FrameLock()) { _partyMembers.Clear(); for (var i = 1; i <= Lua.GetReturnVal<int>("return GetNumPartyMembers();", 0); i++) { var unitNameRealm = Lua.GetReturnValues("return UnitName(\"party" + i + "\");"); Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: BuildPartyList(): Adding " + unitNameRealm[0]); _partyMembers.Add(unitNameRealm[0]); } } } private void HandlePartyInvite(object sender, LuaEventArgs args) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: PARTY_INVITE"); var inviteSender = args.Args[0].ToString(); Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: PARTY_INVITE: From - " + inviteSender); if (!_me.IsInParty && _memberType == MemberType.Member) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: PARTY_INVITE: I am NOT in a party && I am NOT supposed to be a leader"); if (inviteSender == _leaderName) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: PARTY_INVITE: Accepting Group Invite"); Lua.DoString("AcceptGroup()"); } } } public override string Name { get { return "PartyBuddy"; } } public override string Author { get { return "Smarter"; } } public override Version Version { get { return new Version(0,0,2,0);} } } public enum MemberType { Leader, Member }} Your welcome, Smarter
Awesome, now if someone picks it up and adds in the ability to use this in questing profiles (IE wait for party to complete quest/catch up/summon friends etc) that would be 1 step closer to a working RaF Bot.
Thanks man. I plan on testing this out later. Will update thread with results. Update: Code: Plugin from C:\Users\Public\Games\Honorbuddy\Plugins\PartyBuddy could not be compiled! Compiler errors: File: PartyBuddy.cs Line: 18 Error: Using the generic type 'System.Collections.Generic.List<T>' requires '1' type arguments File: PartyBuddy.cs Line: 20 Error: Using the generic type 'System.Collections.Generic.List<T>' requires '1' type arguments[\code] What am I doing wrong here? I modified the _followerList and _leaderName to reflect my party. But either way it won't compile for me. Am i using the wrong version of something?
I have changed the names to protect my privacy, but the names I'm using are the names of my toons. Code: using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using Styx; using Styx.Helpers; using Styx.Plugins.PluginClass; using Styx.WoWInternals; using Styx.WoWInternals.WoWObjects; namespace RaFBuddy { public class PartyBuddy : HBPlugin { private bool _firstPulse = true; private readonly LocalPlayer _me = StyxWoW.Me; private readonly WaitTimer _partyCheckTimer = WaitTimer.ThirtySeconds; private List _followerList; private MemberType _memberType; private readonly List _partyMembers = new List(4); private string _leaderName; public override void Pulse() { if (_firstPulse) { // -- CONFIGURATION -----------------// _followerList = new List {"Shifty", "Ismashurmum"}; _leaderName = "Ackk"; _memberType = _me.Name == _leaderName ? MemberType.Leader : MemberType.Member; //EOF CONFIGURATION -----------------// Lua.Events.AttachEvent("PARTY_INVITE_REQUEST", HandlePartyInvite); Lua.Events.AttachEvent("PARTY_MEMBERS_CHANGED", HandlePartyMembersChanged); Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: Attached Events"); _firstPulse = false; } if (_partyCheckTimer.IsFinished) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: Party Check Timer Finished"); CheckForFollowers(); _partyCheckTimer.Reset(); } } private static bool IsPartyLeader() { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: IsPartyLeader()?"); return Lua.GetReturnVal("return IsPartyLeader();", 0); /* * isLeader = IsPartyLeader() * Returns: * isLeader - 1 if the player is the party leader; otherwise nil (1nil) */ } private void CheckForFollowers() { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers():"); if (!_me.IsInParty) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers(): I am NOT in a Party"); if (_memberType == MemberType.Leader) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers(): I AM supposed to be the Leader"); CreateParty(); return; } } if (_memberType != MemberType.Leader) return; if (!IsPartyLeader()) return; Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers(): I AM the Party Leader"); BuildPartyList(); foreach (var user in _followerList.Where(user => !_partyMembers.Contains(user))) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers(): Party Does NOT contain " + user + " attempting to correct"); if (_partyMembers.Count < 4) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers(): Party has room, attempting to invite " + user + " to the party"); Lua.DoString("InviteUnit(\"" + user + "\");"); StyxWoW.SleepForLagDuration(); } else { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CheckForFollowers(): Party is Full, Leaving Party"); Lua.DoString("LeaveParty()"); StyxWoW.SleepForLagDuration(); } } } private void CreateParty() { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CreateParty(): Creating Party!"); foreach (var user in _followerList) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: CreateParty(): Inviting " + user); Lua.DoString("InviteUnit(\"" + user + "\");"); StyxWoW.SleepForLagDuration(); } } private void HandlePartyMembersChanged(object sender, LuaEventArgs args) { //Check Party Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: PARTY_MEMBERs_CHANGED"); if (_me.IsInParty) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: PARTY_MEMBERs_CHANGED: I am IN a party."); Lua.DoString("StaticPopup_Hide(\"PARTY_INVITE\");"); StyxWoW.SleepForLagDuration(); BuildPartyList(); } CheckForFollowers(); } private void BuildPartyList() { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: BuildPartyList()"); _partyMembers.Clear(); foreach (var user in _me.PartyMemberInfos) { if (user.Location3D.Distance(_me.Location) < 90) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: BuildPartyList(): Adding " + user.ToPlayer().Name); _partyMembers.Add(user.ToPlayer().Name); } } } private void HandlePartyInvite(object sender, LuaEventArgs args) { //sender - The name of the person who sent the invite. (string) Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: PARTY_INVITE"); var inviteSender = args.Args[0].ToString(); Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: PARTY_INVITE: From - " + inviteSender); if (!_me.IsInParty && _memberType == MemberType.Member) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: PARTY_INVITE: I am NOT in a party && I am NOT supposed to be a leader"); if (inviteSender == _leaderName) { Logging.WriteDebug(Color.AliceBlue, "[PartyBuddy]: PARTY_INVITE: Accepting Group Invite"); Lua.DoString("AcceptGroup()"); } } /* * Accepts an invitation to join a party or raid. Usable in response to the PARTY_INVITE_REQUEST event which fires when the player is invited to join a group. This function does not automatically hide the default UI's group invite dialog; doing such requires calling StaticPopup_Hide("PARTY_INVITE"), but only after the PARTY_MEMBERS_CHANGED event fires indicating the player has successfully joined the group. See also Party functions, Raid functions. Signature: AcceptGroup() */ } public override string Name { get { return "PartyBuddy"; } } public override string Author { get { return "Smarter"; } } public override Version Version { get { return new Version(0,0,1,0);} } } public enum MemberType { Leader, Member } }
just make Partymember1 (PM1) as yourself and then PM2 and so on and let the bot auto-find them if more than 2 people in party - assume group leader is the 'main' quester
It doesn't seem to matter what I have as my leader or party members, it always throws the same error when compiling. On 2 different machines. I am using the latest release of HB, in a new folder. Keeps telling me "Using the generic type 'System.Collections.Generic.List' requires '1' type arguments" on lines 18 and 20.
The Party Member list should not contain the Group Leader, only the people you wish to have in the party. The Leader should be listed seperately. On another note, I posted this in the Development section for the simple reason of laziness/lack of knowledge. I really have no intention to support it as I cannot make it work as I wish due to HB/WoW API Limitation. So, unless someone tells me how to get a Party Members Name, which is outside the ObjectManagers range, I have no intent on support it unfortunately .... :-\
I see the issue: _followerList = new List<string> {"player1", "player2", "player3", "player4"}; The forum is removing the < - >'s from my post .... stupid forum. Fixed OP.
That is what I use currently, and it does not contain a method for Name, and can only retrieve a WoWPlayer object within 100yds or less.
of course use lua for this part ... u can query the number of players in the party API GetNumPartyMembers - WoWWiki - Your guide to the World of Warcraft and after this u can do a for next loop and get your data with lua function UnitName("partyN") Where N is the number / index ... GetNumPartyMembers returns nil and 1 - 4 valid partyN: party1,party2,party3,party4 -> partyN excludes the player himself UnitName returns name, realm API UnitName - WoWWiki - Your guide to the World of Warcraft UnitId - WoWWiki - Your guide to the World of Warcraft
Thank you! I simply looked through the Party Functions Refrence, and never thought to look beyond. :-D Will post an update soon. Updated, and working Flawlessly now :-D.
Bah, still an issue of it leaving the Party before the other person accepts. Rewriting the party check logic.... Edit: There, that should do it, posted :-D.