public static bool Convert(string path) { try { GrinderProfile flyingProfile = XmlSerializer.Deserialize <GrinderProfile>(path); GrinderProfile tempFlyingProfile = new GrinderProfile(); string flyingProfileName = Path.GetFileNameWithoutExtension(path); if (flyingProfile.GrinderZones.Count <= 0) { Logging.Write(string.Format("The file {0} is not a valid Grinder Profile.", flyingProfileName)); return(false); } foreach (GrinderZone zone in flyingProfile.GrinderZones) { if (zone.Points.Any(point => point.Type.ToLower() == "flying")) { MovementManager.FlyingToGroundProfilesConverter(zone.Points, out _points, out _result); if (_result) { zone.Points = _points; tempFlyingProfile.GrinderZones.Add(zone); continue; } Logging.Write(string.Format("The profile {0} contains at least one Flying Grinder Zone but the conversion has failed.", flyingProfileName)); return(false); } Logging.Write(string.Format("The profile {0} does not contains any Flying Grinder Zone.", flyingProfileName)); return(false); } flyingProfile.GrinderZones = tempFlyingProfile.GrinderZones; string pathDir = Application.StartupPath + "\\Profiles\\Grinder\\"; string fullPath = pathDir + "Ground_" + flyingProfileName + ".xml"; if (XmlSerializer.Serialize(fullPath, flyingProfile)) { Logging.Write(string.Format("The Flying profile {0} have been saved.", flyingProfileName)); Logging.Write("Path: " + fullPath); return(true); } Logging.Write(string.Format("The Flying profile {0} have not been saved correctly, make sure you have access right on the directory {1}.", flyingProfileName, pathDir)); return(false); } catch { Logging.Write("Conversion of the file failed."); return(false); } }
public static void UnloadCurrentProfile() { if (Bot.ProfileName != null) { Logger.Log($"Unloading profile {Bot.ProfileName}"); Bot.ProfileName = null; Bot.ProfileProfession = null; Profile = new GrinderProfile(); Bot.MovementLoop.PathLoop.Clear(); Bot.Grinding.FactionsTarget.Clear(); Bot.Grinding.EntryTarget.Clear(); Bot.Grinding.MaxTargetLevel = 0; Bot.Grinding.MinTargetLevel = 0; } }
public static void LoadNewProfile(string profession, string profileName) { Profile = new GrinderProfile(); string filePath = Application.StartupPath + "\\Profiles\\Wholesome Professions\\" + profileName; Bot.ProfileName = profileName; // If grinder School Load Profile if (!string.IsNullOrWhiteSpace(profileName) && File.Exists(filePath)) { Profile = XmlSerializer.Deserialize <GrinderProfile>(filePath); if (Profile.GrinderZones.Count <= 0) { Logger.Log($"Profile '{filePath}' seems incorrect. Please use a Grinder profile."); UnloadCurrentProfile(); return; } else { Logger.Log("Profile loaded"); } } else { Logger.LogLineBroadcastImportant($"Profile file '{filePath}' not found"); UnloadCurrentProfile(); return; } SelectZone(); // Black List: var blackListDic = Profile.GrinderZones.SelectMany(zone => zone.BlackListRadius).ToDictionary(b => b.Position, b => b.Radius); //wManager.wManagerSetting.AddRangeBlackListZone(blackListDic); // Add Npc foreach (var zone in Profile.GrinderZones) { NpcDB.AddNpcRange(zone.Npc); } // Go to first hotspot or travel if (Profile.GrinderZones.Count > 0) { string zoneName = Profile.GrinderZones[ZoneIdProfile].Name; int continentId = TravelHelper.GetContinentFromZoneName(zoneName); Logger.LogDebug($"Zone {zoneName} is on continent {continentId.ToString()}"); if (continentId == -1) { Logger.LogLineBroadcastImportant($"ERROR : The zone name {zoneName} from your profile is incorrect. Please use default zone names."); UnloadCurrentProfile(); return; } if (continentId != Usefuls.ContinentId) { Logger.Log($"{Profile.GrinderZones[ZoneIdProfile].Name} is on another continent ({continentId}). Launching traveler."); Bot.SetContinent((ContinentId)continentId); return; } Bot.ProfileProfession = profession; Logger.Log($"Heading to first spot {Profile.GrinderZones[ZoneIdProfile].Vectors3[0]} in {Profile.GrinderZones[ZoneIdProfile].Name}"); Broadcaster.autoBroadcast = false; Broadcaster.BroadCastSituation(); GoToTask.ToPosition(Profile.GrinderZones[ZoneIdProfile].Vectors3[0], 50); Broadcaster.autoBroadcast = true; } else { Logger.LogDebug("No grinder zone found"); UnloadCurrentProfile(); } }
public static bool Convert(string path) { try { if (IsHonorBuddyGrindProfile(path)) { GrinderProfile _profile = new GrinderProfile(); #region LoadProfileBuddy XElement xml = XElement.Load(path); bool subProfile = xml.Elements().Any(child => child.Name.ToString().ToLower() == "SubProfile".ToLower()); foreach (XElement child in xml.Elements()) { if (child.Name.ToString().ToLower() == "SubProfile".ToLower() || !subProfile) // SubProfile { if (subProfile || _profile.GrinderZones.Count <= 0) { _profile.GrinderZones.Add(new GrinderZone { Hotspots = true }); XElement child2 = subProfile ? new XElement(child) : new XElement(xml); foreach (XElement childSubProfile in child2.Elements()) { if (childSubProfile.Name == "Name" && _profile.GrinderZones.Any()) { _profile.GrinderZones[_profile.GrinderZones.Count() - 1].Name = childSubProfile.Value; } if (childSubProfile.Name == "MinLevel" && _profile.GrinderZones.Any()) { _profile.GrinderZones[_profile.GrinderZones.Count() - 1].MinLevel = Others.ToUInt32(childSubProfile.Value); } if (childSubProfile.Name == "MaxLevel" && _profile.GrinderZones.Any()) { _profile.GrinderZones[_profile.GrinderZones.Count() - 1].MaxLevel = Others.ToUInt32(childSubProfile.Value); } if (childSubProfile.Name == "TargetMinLevel" && _profile.GrinderZones.Any()) { _profile.GrinderZones[_profile.GrinderZones.Count() - 1].MinTargetLevel = Others.ToUInt32(childSubProfile.Value); } if (childSubProfile.Name == "TargetMaxLevel" && _profile.GrinderZones.Any()) { _profile.GrinderZones[_profile.GrinderZones.Count() - 1].MaxTargetLevel = Others.ToUInt32(childSubProfile.Value); } /* * if (childSubProfile.Name == "Mailboxes" && _profile.GrinderZones.Any()) * { * _profile.GrinderZones[_profile.GrinderZones.Count() - 1].Mailboxes = * new List<nManager.MiscStructs.Point>(); * * foreach (XElement childMailBoxs in childSubProfile.Elements()) * { * if (childMailBoxs.Name == "Mailbox") * { * XAttribute x = childMailBoxs.Attribute("X"); * if (x == null) * x = childMailBoxs.Attribute("x"); * XAttribute y = childMailBoxs.Attribute("Y"); * if (y == null) * y = childMailBoxs.Attribute("y"); * XAttribute z = childMailBoxs.Attribute("Z"); * if (z == null) * z = childMailBoxs.Attribute("z"); * * if (x != null) * { * if (y != null) * { * if (z != null) * { * var pT = * new nManager.MiscStructs.Point( * Others.ToSingle(x.Value), * Others.ToSingle(y.Value), * Others.ToSingle(z.Value)); * _profile.GrinderZones[ * _profile.GrinderZones.Count() - 1].Mailboxes.Add(pT); * } * } * } * } * } * } * * * if (childSubProfile.Name == "Vendors" && _profile.GrinderZones.Any()) * { * _profile.GrinderZones[_profile.GrinderZones.Count() - 1].Vendors = * new List<Point>(); * * foreach (XElement childVendors in childSubProfile.Elements()) * { * if (childVendors.Name == "Vendor") * { * XAttribute x = childVendors.Attribute("X"); * if (x == null) * x = childVendors.Attribute("x"); * XAttribute y = childVendors.Attribute("Y"); * if (y == null) * y = childVendors.Attribute("y"); * XAttribute z = childVendors.Attribute("Z"); * if (z == null) * z = childVendors.Attribute("z"); * * if (x != null) * { * if (y != null) * { * if (z != null) * { * var pT = * new nManager.MiscStructs.Point( * Others.ToSingle(x.Value), * Others.ToSingle(y.Value), * Others.ToSingle(z.Value)); * _profile.GrinderZones[ * _profile.GrinderZones.Count() - 1].Vendors.Add(pT); * } * } * } * } * } * } * */ if (childSubProfile.Name.ToString().ToLower() == "Blackspots".ToLower() && _profile.GrinderZones.Any()) { foreach (XElement childVendors in childSubProfile.Elements()) { if (childVendors.Name.ToString().ToLower() == "Blackspot".ToLower()) { XAttribute x = childVendors.Attribute("X") ?? childVendors.Attribute("x"); XAttribute y = childVendors.Attribute("Y") ?? childVendors.Attribute("y"); XAttribute z = childVendors.Attribute("Z") ?? childVendors.Attribute("z"); XAttribute r = childVendors.Attribute("Radius") ?? childVendors.Attribute("radius"); if (x != null) { if (y != null) { if (z != null) { if (r != null) { Point pT = new Point( Others.ToSingle(x.Value), Others.ToSingle(y.Value), Others.ToSingle(z.Value)); _profile.GrinderZones[ _profile.GrinderZones.Count() - 1].BlackListRadius. Add(new GrinderBlackListRadius { Position = pT, Radius = System .Convert .ToSingle ( r .Value .Replace (".", ",")) }); } } } } } } } if (childSubProfile.Name.ToString().ToLower() == "GrindArea".ToLower() && _profile.GrinderZones.Any()) { foreach (XElement childGrindArea in childSubProfile.Elements()) { if (childGrindArea.Name == "TargetMinLevel" && _profile.GrinderZones.Any()) { _profile.GrinderZones[_profile.GrinderZones.Count() - 1]. MinTargetLevel = Others.ToUInt32(childGrindArea.Value); } if (childGrindArea.Name == "TargetMaxLevel" && _profile.GrinderZones.Any()) { _profile.GrinderZones[_profile.GrinderZones.Count() - 1]. MaxTargetLevel = Others.ToUInt32(childGrindArea.Value); } if (childGrindArea.Name == "Factions" && _profile.GrinderZones.Any()) { _profile.GrinderZones[_profile.GrinderZones.Count() - 1].TargetFactions = new List <uint>(); string tempsfaction = childGrindArea.Value; if (tempsfaction.Replace(" ", "").Length > 0) { string[] factionTempsString = tempsfaction.Replace(" ", " ") .Split(' '); foreach (string t in factionTempsString) { try { if (t != "") { _profile.GrinderZones[ _profile.GrinderZones.Count() - 1].TargetFactions .Add( System.Convert .ToUInt32 (t)); } } catch { } } } } if (childGrindArea.Name == "Hotspots" && _profile.GrinderZones.Any()) { _profile.GrinderZones[_profile.GrinderZones.Count() - 1]. Points = new List <Point>(); foreach (XElement childHotspots in childGrindArea.Elements()) { if (childHotspots.Name == "Hotspot") { XAttribute x = childHotspots.Attribute("X") ?? childHotspots.Attribute("x"); XAttribute y = childHotspots.Attribute("Y") ?? childHotspots.Attribute("y"); XAttribute z = childHotspots.Attribute("Z") ?? childHotspots.Attribute("z"); if (x != null) { if (y != null) { if (z != null) { Point pT = new Point( Others.ToSingle(x.Value), Others.ToSingle(y.Value), Others.ToSingle(z.Value)); _profile.GrinderZones[ _profile.GrinderZones.Count() - 1].Points.Add (pT); } } } } } } } } } if (!subProfile) { break; } } } } #endregion LoadProfileBuddy string fileName = Path.GetFileNameWithoutExtension(path); if (XmlSerializer.Serialize(Application.StartupPath + "\\Profiles\\Grinder\\" + fileName + ".xml", _profile)) { Logging.Write("Conversion Success (HonorBuddy Grind to Grinder bot): " + fileName); return(true); } } } catch { } Logging.Write("Conversion Failled (HonorBuddy Grind to Grinder bot): " + path); return(false); }
internal static bool Pulse() { try { Profile = new GrinderProfile(); LoadProfile f = new LoadProfile(); f.ShowDialog(); // If grinder School Load Profile if (!string.IsNullOrWhiteSpace(GrinderSetting.CurrentSetting.ProfileName) && File.Exists(Application.StartupPath + "\\Profiles\\Grinder\\" + GrinderSetting.CurrentSetting.ProfileName)) { Profile = XmlSerializer.Deserialize <GrinderProfile>(Application.StartupPath + "\\Profiles\\Grinder\\" + GrinderSetting.CurrentSetting.ProfileName); if (Profile.GrinderZones.Count <= 0) { return(false); } } else { MessageBox.Show(Translate.Get(Translate.Id.Please_select_an_profile)); return(false); } SelectZone(); // Black List: foreach (GrinderZone zone in Profile.GrinderZones) { nManagerSetting.AddRangeBlackListZone(new List <nManagerSetting.BlackListZone>(zone.BlackListRadius)); } // Add Npc foreach (GrinderZone zone in Profile.GrinderZones) { NpcDB.AddNpcRange(zone.Npc); } // Load CC: CombatClass.LoadCombatClass(); // FSM Fsm.States.Clear(); Fsm.AddState(new Pause { Priority = 200 }); Fsm.AddState(new SelectProfileState { Priority = 150 }); Fsm.AddState(new Resurrect { Priority = 140 }); Fsm.AddState(new IsAttacked { Priority = 130 }); Fsm.AddState(new Regeneration { Priority = 120 }); Fsm.AddState(new ToTown { Priority = 110 }); Fsm.AddState(new Looting { Priority = 100 }); Fsm.AddState(new Travel { Priority = 90 }); Fsm.AddState(new SpecializationCheck { Priority = 80 }); Fsm.AddState(new LevelupCheck { Priority = 70 }); Fsm.AddState(new Trainers { Priority = 60 }); Fsm.AddState(new AutoItemCombiner { Priority = 52 }); Fsm.AddState(new MillingState { Priority = 51 }); Fsm.AddState(new ProspectingState { Priority = 50 }); Fsm.AddState(Grinding); Fsm.AddState(new Farming { Priority = 20 }); Fsm.AddState(MovementLoop); Fsm.AddState(new Idle { Priority = 0 }); foreach (var statePlugin in Plugins.ListLoadedStatePlugins) { Fsm.AddState(statePlugin); } Fsm.States.Sort(); Fsm.StartEngine(7, "FSM Grinder"); return(true); } catch (Exception e) { try { Dispose(); } catch { } Logging.WriteError("Grinder > Bot > Bot > Pulse(): " + e); return(false); } }