private void btnSetLeader_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count == 0) { MessageBox.Show("Choose a Player before clicking Set Leader"); listView.Focus(); } else { // WoWPlayer chosenPlayer = (WoWPlayer)listView.SelectedItems[0].Tag; ulong guid = (ulong)listView.SelectedItems[0].Tag; try { Tank.Guid = guid; Tank.SetAsLeader(); LazyRaider.IamTheTank = (StyxWoW.Me.Guid == guid); LazyRaider.Log("User selected tank named {0}", LazyRaider.Safe_UnitName(Tank.Current)); TreeRoot.StatusText = String.Format("[lr] tank is {0}", LazyRaider.Safe_UnitName(Tank.Current)); } catch { listView.SelectedItems[0].Remove(); } this.Hide(); } }
private static bool SyncTankWithRaFLeader() { try { // check if Tank we saved is now in range if (Tank.Current != null && Tank.Current.ToPlayer() != null) { Dlog("SyncTankWithRaFLeader: Tank now in range, so setting RaFHelper"); Tank.SetAsLeader(); return(false); } // otherwise, tank out of range pointer for WoWPlayer so clear if (RaFHelper.Leader != null) { Dlog("SyncTankWithRaFLeader: Tank doesn't match RaFHelper so clearing"); RaFHelper.ClearLeader(); } // user wants to control choosing new when we lost tank if (!LazyRaiderSettings.Instance.AutoTankSelect) { if (haveFoundTankAtGroupForming) { return(false); } } // have Tank, so keep it until user changes if (Tank.Current != null && Tank.Current.IsOnline) { return(false); } WoWPartyMember tank = (from pm in GroupMemberInfos where GetGroupRoleAssigned(pm) == WoWPartyMember.GroupRole.Tank && pm.Guid != Me.Guid && pm.IsOnline && pm.ToPlayer() != null orderby pm.Location3D.Distance(Me.Location) ascending select pm).FirstOrDefault(); if (tank != null) { haveFoundTankAtGroupForming = true; Tank.Current = tank; Log("Tank set to {0} based upon role", LazyRaider.Safe_UnitName(Tank.Current)); TreeRoot.StatusText = String.Format("[lr] tank is {0}", Safe_UnitName(tank)); return(true); } #if DONT_SET_BY_MAX_HEALTH_FOR_NOW tank = (from pm in GroupMemberInfos where pm.Guid != Me.Guid && pm.IsOnline && pm.ToPlayer() != null orderby pm.HealthMax descending select pm).FirstOrDefault(); if (tank != null) { Log("Tank set to {0} based upon Max Health", tank.ToPlayer().Class); Tank.Current = tank; TreeRoot.StatusText = String.Format("[lr] tank is {0}", Safe_UnitName(tank)); return(true); } #endif return(false); } catch { return(true); } }