private static void LoadCharacterSettings(string path) { lock (CharacterSettingsLock) { LoadingCharacterSettings = true; JObject root; // Load or create config root = path == "" ? new JObject() : JObject.Parse(File.ReadAllText(path)); Window w = Window.Get; #region (Character Tab) JObject Character = root.ContainsKey("Character") ? (JObject)root["Character"] : new JObject(); { JObject Inf = Character.ContainsKey("Info") ? (JObject)Character["Info"] : new JObject(); w.Character_cbxMessageExp.Checked = Inf.ContainsKey("ShowExp") ? (bool)Inf["ShowExp"] : false; w.Character_cbxMessageUniques.Checked = Inf.ContainsKey("ShowUniques") ? (bool)Inf["ShowUniques"] : false; w.Character_cbxMessageEvents.Checked = Inf.ContainsKey("ShowEvents") ? (bool)Inf["ShowEvents"] : false; w.Character_cbxMessagePicks.Checked = Inf.ContainsKey("ShowPicks") ? (bool)Inf["ShowPicks"] : false; JObject Potions = Character.ContainsKey("Potions") ? (JObject)Character["Potions"] : new JObject(); w.Character_cbxUseHP.Checked = Potions.ContainsKey("UseHP") ? (bool)Potions["UseHP"] : false; w.Character_tbxUseHP.Text = Potions.ContainsKey("UseHPPercent") ? (string)Potions["UseHPPercent"] : "50"; w.Character_cbxUseHPGrain.Checked = Potions.ContainsKey("UseHPGrain") ? (bool)Potions["UseHPGrain"] : false; w.Character_cbxUseHPVigor.Checked = Potions.ContainsKey("UseHPVigor") ? (bool)Potions["UseHPVigor"] : false; w.Character_cbxUseMP.Checked = Potions.ContainsKey("UseMP") ? (bool)Potions["UseMP"] : false; w.Character_tbxUseMP.Text = Potions.ContainsKey("UseMPPercent") ? (string)Potions["UseMPPercent"] : "50"; w.Character_cbxUseMPGrain.Checked = Potions.ContainsKey("UseMPGrain") ? (bool)Potions["UseMPGrain"] : false; w.Character_cbxUseMPVigor.Checked = Potions.ContainsKey("UseMPVigor") ? (bool)Potions["UseMPVigor"] : false; w.Character_cbxUsePillUniversal.Checked = Potions.ContainsKey("UseUniversalPills") ? (bool)Potions["UseUniversalPills"] : false; w.Character_cbxUsePillPurification.Checked = Potions.ContainsKey("UsePurificationPills") ? (bool)Potions["UsePurificationPills"] : false; w.Character_cbxUsePetHP.Checked = Potions.ContainsKey("UsePetHP") ? (bool)Potions["UsePetHP"] : false; w.Character_tbxUsePetHP.Text = Potions.ContainsKey("UsePetHPPercent") ? (string)Potions["UsePetHPPercent"] : "50"; w.Character_cbxUseTransportHP.Checked = Potions.ContainsKey("UseTransportHP") ? (bool)Potions["UseTransportHP"] : false; w.Character_tbxUseTransportHP.Text = Potions.ContainsKey("UseTransportHPPercent") ? (string)Potions["UseTransportHPPercent"] : "50"; w.Character_cbxUsePetsPill.Checked = Potions.ContainsKey("UsePetsPill") ? (bool)Potions["UsePetsPill"] : false; w.Character_cbxUsePetHGP.Checked = Potions.ContainsKey("UsePetHGP") ? (bool)Potions["UsePetHGP"] : false; w.Character_tbxUsePetHGP.Text = Potions.ContainsKey("UsePetHGPPercent") ? (string)Potions["UsePetHGPPercent"] : "50"; JObject Misc = Character.ContainsKey("Misc") ? (JObject)Character["Misc"] : new JObject(); w.Character_cbxAcceptRess.Checked = Misc.ContainsKey("AcceptRess") ? (bool)Misc["AcceptRess"] : false; w.Character_cbxAcceptRessPartyOnly.Checked = Misc.ContainsKey("AcceptRessPartyOnly") ? (bool)Misc["AcceptRessPartyOnly"] : false; w.Character_cbxRefuseExchange.Checked = Misc.ContainsKey("RefuseExchange") ? (bool)Misc["RefuseExchange"] : false; w.Character_cbxAcceptExchange.Checked = Misc.ContainsKey("AcceptExchange") ? (bool)Misc["AcceptExchange"] : false; w.Character_cbxAcceptExchangeLeaderOnly.Checked = Misc.ContainsKey("AcceptExchangePartyOnly") ? (bool)Misc["AcceptExchangePartyOnly"] : false; w.Character_cbxConfirmExchange.Checked = Misc.ContainsKey("ConfirmExchange") ? (bool)Misc["ConfirmExchange"] : false; w.Character_cbxApproveExchange.Checked = Misc.ContainsKey("ApproveExchange") ? (bool)Misc["ApproveExchange"] : false; } #endregion #region (Party Tab) JObject Party = root.ContainsKey("Party") ? (JObject)root["Party"] : new JObject(); { JObject Options = Party.ContainsKey("Options") ? (JObject)Party["Options"] : new JObject(); w.Party_rbnSetupExpFree.Checked = Options.ContainsKey("ExpFree") ? (bool)Options["ExpFree"] : true; w.Party_rbnSetupExpShared.Checked = !w.Party_rbnSetupExpFree.Checked; w.Party_rbnSetupItemFree.Checked = Options.ContainsKey("ItemFree") ? (bool)Options["ItemFree"] : true; w.Party_rbnSetupItemShared.Checked = !w.Party_rbnSetupItemFree.Checked; w.Party_cbxSetupMasterInvite.Checked = Options.ContainsKey("OnlyMasterInvite") ? (bool)Options["OnlyMasterInvite"] : false; w.Party_cbxAcceptOnlyPartySetup.Checked = Options.ContainsKey("AcceptOnlyPartySetup") ? (bool)Options["AcceptOnlyPartySetup"] : false; w.Party_cbxAcceptAll.Checked = Options.ContainsKey("AcceptAll") ? (bool)Options["AcceptAll"] : false; w.Party_cbxAcceptPartyList.Checked = Options.ContainsKey("AcceptPartyList") ? (bool)Options["AcceptPartyList"] : false; w.Party_cbxAcceptLeaderList.Checked = Options.ContainsKey("AcceptLeaderList") ? (bool)Options["AcceptLeaderList"] : false; w.Party_cbxLeavePartyNoneLeader.Checked = Options.ContainsKey("LeavePartyLeaderNotFound") ? (bool)Options["LeavePartyLeaderNotFound"] : false; w.Party_cbxRefuseInvitations.Checked = Options.ContainsKey("RefuseInvitations") ? (bool)Options["RefuseInvitations"] : false; w.Party_cbxActivateLeaderCommands.Checked = Options.ContainsKey("ActivateLeaderCommands") ? (bool)Options["ActivateLeaderCommands"] : false; w.Party_cbxInviteOnlyPartySetup.Checked = Options.ContainsKey("InviteOnlyPartySetup") ? (bool)Options["InviteOnlyPartySetup"] : false; w.Party_cbxInviteAll.Checked = Options.ContainsKey("InviteAll") ? (bool)Options["InviteAll"] : false; w.Party_cbxInvitePartyList.Checked = Options.ContainsKey("InvitePartyList") ? (bool)Options["InvitePartyList"] : false; w.Party_lstvPartyList.Items.Clear(); if (Options.ContainsKey("PartyList")) { foreach (JToken player in (JArray)Options["PartyList"]) { ListViewItem item = new ListViewItem((string)player); item.Name = item.Text.ToUpper(); w.Party_lstvPartyList.Items.Add(item); } } w.Party_lstvLeaderList.Items.Clear(); if (Options.ContainsKey("LeaderList")) { foreach (JToken leader in (JArray)Options["LeaderList"]) { ListViewItem item = new ListViewItem((string)leader); item.Name = item.Text.ToUpper(); w.Party_lstvLeaderList.Items.Add(item); } } JObject Match = Party.ContainsKey("Match") ? (JObject)Party["Match"] : new JObject(); w.Party_tbxMatchTitle.Text = Match.ContainsKey("Title") ? (string)Match["Title"] : "[xBot] When you play Silkroad you win or you die.."; w.Party_tbxMatchFrom.Text = Match.ContainsKey("From") ? (string)Match["From"] : "0"; w.Party_tbxMatchTo.Text = Match.ContainsKey("To") ? (string)Match["To"] : "255"; w.Party_cbxMatchAutoReform.Checked = Match.ContainsKey("AutoReform") ? (bool)Match["AutoReform"] : false; w.Party_cbxMatchAcceptAll.Checked = Match.ContainsKey("AcceptAll") ? (bool)Match["AcceptAll"] : true; w.Party_cbxMatchAcceptPartyList.Checked = Match.ContainsKey("AcceptPartyList") ? (bool)Match["AcceptPartyList"] : false; w.Party_cbxMatchAcceptLeaderList.Checked = Match.ContainsKey("AcceptLeaderList") ? (bool)Match["AcceptLeaderList"] : false; w.Party_cbxMatchRefuse.Checked = Match.ContainsKey("Refuse") ? (bool)Match["Refuse"] : false; } #endregion #region (Skills Tab) JObject Skills = root.ContainsKey("Skills") ? (JObject)root["Skills"] : new JObject(); { xDictionary <uint, SRSkill> mySkills = InfoManager.Character.Skills; JObject Attack = Skills.ContainsKey("Attack") ? (JObject)Skills["Attack"] : new JObject(); w.Skills_lstvAttackMobType_General.Items.Clear(); if (Attack.ContainsKey("General")) { foreach (JToken token in (JArray)Attack["General"]) { string skillName = (string)token; SRSkill skill = mySkills.Find(s => s.Name == skillName); if (skill != null) { ListViewItem item = new ListViewItem(skillName); item.Name = skill.ID.ToString(); item.Tag = skill; w.Skills_lstvAttackMobType_General.Items.Add(item); } } } w.Skills_lstvAttackMobType_Champion.Items.Clear(); if (Attack.ContainsKey("Champion")) { foreach (JToken token in (JArray)Attack["Champion"]) { string skillName = (string)token; SRSkill skill = mySkills.Find(s => s.Name == skillName); if (skill != null) { ListViewItem item = new ListViewItem(skillName); item.Name = skill.ID.ToString(); item.Tag = skill; w.Skills_lstvAttackMobType_Champion.Items.Add(item); } } } w.Skills_lstvAttackMobType_Giant.Items.Clear(); if (Attack.ContainsKey("Giant")) { foreach (JToken token in (JArray)Attack["Giant"]) { string skillName = (string)token; SRSkill skill = mySkills.Find(s => s.Name == skillName); if (skill != null) { ListViewItem item = new ListViewItem(skillName); item.Name = skill.ID.ToString(); item.Tag = skill; w.Skills_lstvAttackMobType_Giant.Items.Add(item); } } } w.Skills_lstvAttackMobType_PartyGeneral.Items.Clear(); if (Attack.ContainsKey("PartyGeneral")) { foreach (JToken token in (JArray)Attack["PartyGeneral"]) { string skillName = (string)token; SRSkill skill = mySkills.Find(s => s.Name == skillName); if (skill != null) { ListViewItem item = new ListViewItem(skillName); item.Name = skill.ID.ToString(); item.Tag = skill; w.Skills_lstvAttackMobType_PartyGeneral.Items.Add(item); } } } w.Skills_lstvAttackMobType_PartyChampion.Items.Clear(); if (Attack.ContainsKey("PartyChampion")) { foreach (JToken token in (JArray)Attack["PartyChampion"]) { string skillName = (string)token; SRSkill skill = mySkills.Find(s => s.Name == skillName); if (skill != null) { ListViewItem item = new ListViewItem(skillName); item.Name = skill.ID.ToString(); item.Tag = skill; w.Skills_lstvAttackMobType_PartyChampion.Items.Add(item); } } } w.Skills_lstvAttackMobType_PartyGiant.Items.Clear(); if (Attack.ContainsKey("PartyGiant")) { foreach (JToken token in (JArray)Attack["PartyGiant"]) { string skillName = (string)token; SRSkill skill = mySkills.Find(s => s.Name == skillName); if (skill != null) { ListViewItem item = new ListViewItem(skillName); item.Name = skill.ID.ToString(); item.Tag = skill; w.Skills_lstvAttackMobType_PartyGiant.Items.Add(item); } } } w.Skills_lstvAttackMobType_Unique.Items.Clear(); if (Attack.ContainsKey("Unique")) { foreach (JToken token in (JArray)Attack["Unique"]) { string skillName = (string)token; SRSkill skill = mySkills.Find(s => s.Name == skillName); if (skill != null) { ListViewItem item = new ListViewItem(skillName); item.Name = skill.ID.ToString(); item.Tag = skill; w.Skills_lstvAttackMobType_Unique.Items.Add(item); } } } w.Skills_lstvAttackMobType_Elite.Items.Clear(); if (Attack.ContainsKey("Elite")) { foreach (JToken token in (JArray)Attack["Elite"]) { string skillName = (string)token; SRSkill skill = mySkills.Find(s => s.Name == skillName); if (skill != null) { ListViewItem item = new ListViewItem(skillName); item.Name = skill.ID.ToString(); item.Tag = skill; w.Skills_lstvAttackMobType_Elite.Items.Add(item); } } } w.Skills_lstvAttackMobType_Event.Items.Clear(); if (Attack.ContainsKey("Event")) { foreach (JToken token in (JArray)Attack["Event"]) { string skillName = (string)token; SRSkill skill = mySkills.Find(s => s.Name == skillName); if (skill != null) { ListViewItem item = new ListViewItem(skillName); item.Name = skill.ID.ToString(); item.Tag = skill; w.Skills_lstvAttackMobType_Event.Items.Add(item); } } } w.Training_cbxWalkToCenter.Checked = Attack.ContainsKey("WalkToCenter") ? (bool)Attack["WalkToCenter"] : false; } #endregion #region (Training Tab) JObject Training = root.ContainsKey("Training") ? (JObject)root["Training"] : new JObject(); { JObject Area = Training.ContainsKey("Area") ? (JObject)Training["Area"] : new JObject(); string AreaActivated = Training.ContainsKey("AreaActivated") ? (string)Training["AreaActivated"] : ""; foreach (JProperty key in Area.Properties()) { JObject area = (JObject)Area[key.Name]; ListViewItem item = new ListViewItem(key.Name); item.Name = key.Name; ListViewItem.ListViewSubItem subitem = new ListViewItem.ListViewSubItem(); subitem.Tag = area.ContainsKey("Region") ? (ushort)area["Region"] : (ushort)0; item.SubItems.Add(subitem); subitem = new ListViewItem.ListViewSubItem(); subitem.Tag = area.ContainsKey("X") ? (int)area["X"] : 0; item.SubItems.Add(subitem); subitem = new ListViewItem.ListViewSubItem(); subitem.Tag = area.ContainsKey("Y") ? (int)area["Y"] : 0; item.SubItems.Add(subitem); subitem = new ListViewItem.ListViewSubItem(); subitem.Tag = area.ContainsKey("Z") ? (int)area["Z"] : 0; item.SubItems.Add(subitem); subitem = new ListViewItem.ListViewSubItem(); subitem.Tag = area.ContainsKey("Radius") ? (int)area["Radius"] : 0; item.SubItems.Add(subitem); item.SubItems.Add(area.ContainsKey("Path") ? (string)area["Path"] : ""); // Check if this area is activated if (AreaActivated != "" && AreaActivated == item.Name) { item.ForeColor = System.Drawing.Color.FromArgb(0, 180, 255); w.Training_lstvAreas.Tag = item; AreaActivated = ""; } w.Training_lstvAreas.Items.Add(item); } JObject Trace = Training.ContainsKey("Trace") ? (JObject)Training["Trace"] : new JObject(); w.Training_cbxTraceMaster.Checked = Trace.ContainsKey("TracePartyMaster") ? (bool)Trace["TracePartyMaster"] : false; w.Training_cbxTraceDistance.Checked = Trace.ContainsKey("UseTraceDistance") ? (bool)Trace["UseTraceDistance"] : false; w.Training_tbxTraceDistance.Text = Trace.ContainsKey("TraceDistance") ? (string)Trace["TraceDistance"] : "5"; } #endregion #region (Stall Tab) JObject Stall = root.ContainsKey("Stall") ? (JObject)root["Stall"] : new JObject(); { JObject Options = Stall.ContainsKey("Options") ? (JObject)Stall["Options"] : new JObject(); w.Stall_tbxStallTitle.Text = Options.ContainsKey("Title") ? (string)Options["Title"] : "[xBot] The things I do for love.."; w.Stall_tbxStallNote.Text = Options.ContainsKey("Note") ? (string)Options["Note"] : "[xBot] Fear cuts deeper than swords.."; } #endregion LoadingCharacterSettings = false; } }
public SRGuild() { Members = new xDictionary <uint, SRGuildMember>(); }
public SRParty() { Members = new xDictionary <uint, SRPartyMember>(); }
private void CheckAutoParty(object sender, ElapsedEventArgs e) { Window w = Window.Get; if (w.Party_cbxInviteAll.Checked) { // Check players around if (InfoManager.Players.Count > 0) { if (InfoManager.inParty) { xDictionary <string, SRPlayer> PlayersNearWithNoParty = new xDictionary <string, SRPlayer>(InfoManager.Players); // Remove players nears with party for (byte j = 0; j < InfoManager.Party.Members.Count; j++) { string PlayerName = InfoManager.Party.Members.GetAt(j).Name.ToUpper(); if (PlayersNearWithNoParty.ContainsKey(PlayerName)) { PlayersNearWithNoParty.RemoveKey(PlayerName); } } if (PlayersNearWithNoParty.Count == 0) { return; } // Check invitations setup if (!w.Party_cbxInviteOnlyPartySetup.Checked || InfoManager.Party.SetupFlags == w.GetPartySetup()) { if (!InfoManager.Party.isFull) { PacketBuilder.InviteToParty(PlayersNearWithNoParty.GetAt(rand.Next(PlayersNearWithNoParty.Count)).UniqueID); tCycleAutoParty.Start(); } } } else { PacketBuilder.CreateParty(InfoManager.Players.GetAt(rand.Next(InfoManager.Players.Count)).UniqueID, InfoManager.Party.SetupFlags); tCycleAutoParty.Start(); } } else { tCycleAutoParty.Start(); } } else if (w.Party_cbxInvitePartyList.Checked) { if (InfoManager.Players.Count > 0) { List <string> PlayersToInvite = new List <string>(); w.Party_lstvPartyList.InvokeIfRequired(() => { for (int j = 0; j < w.Party_lstvPartyList.Items.Count; j++) { PlayersToInvite.Add(w.Party_lstvPartyList.Items[j].Name); } }); // Remove if are in party already for (int j = 0; j < PlayersToInvite.Count; j++) { for (byte k = 0; k < InfoManager.Party.Members.Count; k++) { if (PlayersToInvite[j].Equals(InfoManager.Party.Members.GetAt(k).Name, StringComparison.OrdinalIgnoreCase)) { PlayersToInvite.RemoveAt(j--); break; } } } if (PlayersToInvite.Count > 0) { // Shuffle and check the party list with near players PlayersToInvite.Shuffle(); SRPlayer PlayerToInvite = null; for (int j = 0; j < PlayersToInvite.Count; j++) { if ((PlayerToInvite = InfoManager.Players[PlayersToInvite[j]]) != null) { break; } } if (PlayerToInvite != null) { if (InfoManager.inParty) { if (!w.Party_cbxInviteOnlyPartySetup.Checked || InfoManager.Party.SetupFlags == w.GetPartySetup()) { if (!InfoManager.Party.isFull) { PacketBuilder.InviteToParty(PlayerToInvite.UniqueID); tCycleAutoParty.Start(); } } } else { PacketBuilder.CreateParty(PlayerToInvite.UniqueID, w.GetPartySetup()); tCycleAutoParty.Start(); } } else { // No players to invite, try later tCycleAutoParty.Start(); } } } else { // No players near to invite, try later tCycleAutoParty.Start(); } } }