public override bool Run() { if (TimeCondition) { Logger.Info("We hit the time limit."); StopBot(); return(true); } if (BagsCondition) { Logger.Info("Bags are full."); StopBot(); return(true); } if (LureCondition) { Logger.Info("We ran out of lures."); StopBot(); return(true); } WoWPlayerMe me = ObjectManager.Me; if (me != null && me.Dead) { Logger.Info("We died :("); StopBot(); return(true); } return(false); }
public void OnStart(GameInterface game) { this.game = game; SettingsInstance = this.LoadSettingsJSON <Settings>(); WoWPlayerMe locaPlayer = game.GetGameObjects(null, players, npcs); WowPlayer myTargetPlayer = players.FirstOrDefault(i => i.Health > 0 && i.GUID == locaPlayer.TargetGUID); WowNpc myTargetNpc = npcs.FirstOrDefault(i => i.Health > 0 && i.GUID == locaPlayer.TargetGUID); if (myTargetPlayer != null) { guid = myTargetPlayer.GUID; } else if (myTargetNpc != null) { guid = myTargetNpc.GUID; } else { this.LogPrint("Unit isn't found!"); } libNavigator = Utilities.GetReferenceOfPlugin("LibNavigator"); if (libNavigator == null) { this.ShowNotify("LibNavigator isn't found! Plugin will not work.", true, true); this.LogPrint("LibNavigator isn't found! Plugin will not work."); return; } (timer = this.CreateTimer(500, game, OnPulse)).Start(); }
private bool DoMargossRepIfNeeded(WoWPlayerMe me) { if (LEGION_REP_ZONES.TryGetValue(game.ZoneID, out LegionRepPoint value)) { var timeout = 5000; while (timeout > 0 && me.Location.Distance2D(value.StartingPlayerPoint) > 3) { game.Move2D(value.StartingPlayerPoint, 3f, 1000, true, false); timeout -= 1000; } game.Face(value.StartingFacingPoint); } foreach (var itemID in LEGION_REP_SUMMON_ITEMS) { if (me.ItemsInBags.Any(l => l.EntryID == itemID)) { this.ShowNotify($"Click this message to use your {Wowhead.GetItemInfo(itemID).Name}", false, false, 2, (obj, args) => { game.UseItemByID(itemID); }); break; } } foreach (var itemID in LEGION_REP_CURRENCY_ITEMS) { if (me.ItemsInBags.Where(l => l.EntryID == itemID).Sum(l => l.StackSize) >= 100) { this.ShowNotify($"You cannot get more {Wowhead.GetItemInfo(itemID).Name}", false, true); Thread.Sleep(Utilities.Rnd.Next(1000, 2000)); return(true); } } return(false); }
public void TimerElapsed() { WoWPlayerMe me = game.GetGameObjects(objects, null, npcs); if (me != null) { WowNpc npc = npcs.FirstOrDefault(l => l.Alive && POI.Contains(l.Name)); WowObject wowObject = objects.FirstOrDefault(l => POI.Contains(l.Name)); if (npc != null || wowObject != null) { string name = npc != null ? npc.Name : wowObject.Name; this.LogPrint("Found new POI: " + name); if ((DateTime.UtcNow - lastTimeSmsSent).TotalSeconds >= timeout) { lastTimeSmsSent = DateTime.UtcNow; this.LogPrint("Timing is OK"); dynamic libSMS = Utilities.GetReferenceOfPlugin("LibSMS"); if (libSMS != null) { libSMS.SendSMS($"Rare spawned: {name}\r\nTime: {DateTime.Now}"); Utilities.ShowNotify(this, $"Rare spawned: {name}\r\nTime: {DateTime.Now}", true, true, int.MaxValue); // $"Rare spawned: {name}" // string.Format("Rare spawned: {0}", name) this.LogPrint($"Rare spawned: {name}; message is sent"); } } } } }
private void Redraw() { Action refreshRadar = pictureBoxMain.Invalidate; var soundAlarmPrevState = false; var stopwatch = new Stopwatch(); while (isRunning) { stopwatch.Restart(); if (!info.IsInGame || info.IsLoadingScreen) { try { shouldDrawObjects = false; BeginInvoke(refreshRadar); } catch (Exception ex) { this.LogError($"OOG drawing error: {ex.Message}"); } Thread.Sleep(100); continue; } try { localPlayer = info.GetGameObjects(wowObjects, wowPlayers, wowNpcs); } catch (Exception ex) { if (ex is Win32Exception win32ex && win32ex.NativeErrorCode == (int)Win32Error.ERROR_PARTIAL_COPY) // it's rarely happening, dunno why { this.LogPrint($"Pulsing error: {ex.Message}"); }
public void OnPulse() { WoWPlayerMe localPlayer = game.GetGameObjects(null, null, wowNpcs); if (localPlayer != null && localPlayer.CastingSpellID == 0 && localPlayer.ChannelSpellID == 0 && !game.IsLooting) { foreach (WowNpc npc in wowNpcs.Where(l => l.Health == 0 && l.Location.Distance2D(localPlayer.Location) < 40 && !unlootableNpcs.Contains(l.GUID)).OrderBy(l => l.Location.Distance(localPlayer.Location))) { if (game.LuaIsTrue($"CanLootUnit('{npc.GetGameGUID()}')==true")) // game.LuaIsTrue($"select(2,CanLootUnit('{npc.GetGameGUID()}'))==true") && { if (npc.Location.Distance(localPlayer.Location) > 3f) { game.Move2D(npc.Location, 2.5f, 1000, true, false); } else { npc.Interact(); } break; } else { unlootableNpcs.Add(npc.GUID); } } } }
private void ComboboxNPCs_Click(object sender, EventArgs e) { comboboxNPCs.Items.Clear(); try { List <WowNpc> npcList = new List <WowNpc>(); WoWPlayerMe localPlayer = info.GetGameObjects(npcs: npcList); if (localPlayer != null) { List <WowNpc> npcsWithUniqueNames = npcList.DistinctBy(i => i.Name).ToList(); npcsWithUniqueNames.Sort(delegate(WowNpc o1, WowNpc o2) { double distance1 = o1.Location.Distance(localPlayer.Location); double distance2 = o2.Location.Distance(localPlayer.Location); return(distance1.CompareTo(distance2)); }); comboboxNPCs.Items.AddRange(npcsWithUniqueNames.Select(i => i.Name).Cast <object>().ToArray()); } else { radar.LogPrint("ComboboxNPCs_Click: local player is null"); } } catch (Exception ex) { radar.LogError($"Error: {ex.Message}"); } }
private void OnPulse() { WoWPlayerMe me = game.GetGameObjects(null, null, npcs); if (me != null && me.InCombat) { if (specialization == 0) { specialization = int.Parse(game.LuaGetValue("GetSpecialization()")); } WowNpc nearestNpc = npcs.FirstOrDefault(l => l.GUID == me.TargetGUID); if (nearestNpc == null) { game.SendToChat("/targetenemy"); } me = game.GetGameObjects(null, null, npcs); nearestNpc = npcs.FirstOrDefault(l => l.GUID == me.TargetGUID); if (nearestNpc != null) { game.Face(nearestNpc.Location); if (me.Class == WowPlayerClass.Sha) { ShamanRoutine(me); } } } else { specialization = 0; } }
internal static float AngleHorizontal(WowProcess process, WowPoint point) { WoWPlayerMe me = ObjectMgr.Pulse(process); var angle = Convert.ToSingle(Math.Atan2(Convert.ToDouble(point.Y) - Convert.ToDouble(me.Location.Y), Convert.ToDouble(point.X) - Convert.ToDouble(me.Location.X))); angle = NegativeAngle(angle); return(angle); }
private void OnPulse() { WoWPlayerMe me = game.GetGameObjects(); if (me != null) { mainForm.labelLocation.Text = "[" + me.Location + "]"; } }
public void GoWait(WowPoint dest, float precision, GameInterface game, int timeoutMs = 30000) { Stopwatch stopwatch = new Stopwatch(); WoWPlayerMe me = game.GetGameObjects(); while (me != null && me.Location.Distance(dest) > precision && timeoutMs > 0) { stopwatch.Restart(); Go(dest, precision, game); timeoutMs -= (int)stopwatch.ElapsedMilliseconds; } }
public void StartLoadedScript(GameInterface game) { if (isRunning) { throw new InvalidOperationException("Script is already running"); } else { this.game = game; unstuckDictionary = new Dictionary <DateTime, WowPoint>(); isRunning = true; precision2D = 3f; loopPath = false; startFromNearestPoint = false; int tCounter = 0; DoActionType[] predefinedSettings = new[] { DoActionType.SetLoopPath, DoActionType.SetStartFromNearestPoint }; while (predefinedSettings.Contains(actionsList[tCounter].ActionType)) { switch (actionsList[tCounter].ActionType) { case DoActionType.SetLoopPath: loopPath = bool.Parse(actionsList[tCounter].Data); break; case DoActionType.SetStartFromNearestPoint: startFromNearestPoint = bool.Parse(actionsList[tCounter].Data); break; } tCounter++; } this.LogPrint($"<Loop path> is set to {loopPath}"); this.LogPrint($"<StartFromNearestPoint> is set to {startFromNearestPoint}"); if (startFromNearestPoint) { WoWPlayerMe localPlayer = game.GetGameObjects(); if (localPlayer != null) { DoAction nearestPoint = actionsList.Aggregate((minItem, nextItem) => localPlayer.Location.Distance(minItem.WowPoint) < localPlayer.Location.Distance(nextItem.WowPoint) ? minItem : nextItem); counter = actionsList.IndexOf(nearestPoint); } else { counter = 0; } } else { counter = 0; } (timer = this.CreateTimer(RESOLUTION_INTERVAL, game, DoAction)).Start(); } }
private void ButtonDumpInventory_Click(object sender, EventArgs e) { Log("Dump START (buttonDumpInventory_Click)"); WoWPlayerMe me = null; try { me = game.GetGameObjects(); Log("Dump OK"); } catch (Exception ex) { Log("ERROR(0): " + ex.Message); return; } try { Log("----Inventory slots----"); int counter = 0; foreach (WoWItem item in me.Inventory) { Log($"\t{counter}:"); Log($"\t\tAddress: 0x{item.Address.ToInt64().ToString("X")}"); Log($"\t\tEntryID: {item.EntryID}"); Log($"\t\tName: {item.Name}"); Log($"\t\tStackSize: {item.StackSize}"); Log($"\t\tContainedIn: {item.ContainedIn}"); Log($"\t\tWeaponEnchant: {item.WeaponEnchant}"); Log($"\t\tSlot: {counter}"); counter++; } } catch (Exception ex) { Log(ex.Message); } try { Log("----Items in bags----"); foreach (WoWItem item in me.ItemsInBags) { Log(string.Format("\tID: {0}; GUID: {7}; Name: {1}; StackCount: {2}; Contained in: {3}; Enchant: {4}; BagID, SlotID: {5} {6}", item.EntryID, item.Name, item.StackSize, item.ContainedIn, item.WeaponEnchant, item.BagID, item.SlotID, item.GUID)); } } catch (Exception ex) { Log(ex.Message); } MessageBox.Show("Completed"); }
private void OnElapsed() { WoWPlayerMe localPlayer = game.GetGameObjects(); if (localPlayer != null && localPlayer.CastingSpellID == 0 && localPlayer.ChannelSpellID == 0 && DateTime.UtcNow - spellLastUsed > cooldown) { spellLastUsed = DateTime.UtcNow; game.CastSpellByName(spellName); Thread.Sleep(250); WinAPI.SetCursorPosition(clickPoint); WinAPI.MouseEvent(WinAPI.MouseEventFlags.LeftDown | WinAPI.MouseEventFlags.LeftUp); Thread.Sleep(1000); } }
public void OnPulse() { WoWPlayerMe locaPlayer = game.GetGameObjects(null, players, npcs); if (locaPlayer.Alive) { WowPlayer unitPlayer = players.FirstOrDefault(i => i.Alive && i.GUID == guid); WowNpc unitNpc = npcs.FirstOrDefault(i => i.Alive && i.GUID == guid); WowPoint? POILocation = unitPlayer != null ? unitPlayer.Location : unitNpc?.Location; if (POILocation.HasValue && POILocation.Value.Distance(locaPlayer.Location) > SettingsInstance.MaxDistance) { // game.Move2D(WowPoint.GetNearestPoint(locaPlayer.Location, POILocation.Value, 1f), SettingsInstance.Precision, 1000, true, false); libNavigator.Go(WowPoint.GetNearestPoint(locaPlayer.Location, POILocation.Value, 1f), (float)SettingsInstance.Precision, game); } } }
private void buttonCreateWaypoint_Click(object sender, EventArgs e) { WoWPlayerMe me = game.GetGameObjects(); if (me != null) { list.Add(new DoAction { ActionType = DoActionType.Move, WowPoint = me.Location }); WriteJSON(); } else { MessageBox.Show("Player isn't online"); } }
private bool ApplySpecialLureIfNeeded(WoWPlayerMe me) { if (settings.UseSpecialBait) { uint baitID = 0; try { if (me.Auras.All(l => l.Name != settings.SpecialBait)) { var item = me.ItemsInBags.FirstOrDefault(l => l.Name == settings.SpecialBait); if (item == null) { if (settings.GetSpecialBaitFromNatPagle) { GetSpecialBaitBuffFromNatPagle(); } else if (settings.UseAnySpecialBaitIfPreferredIsNotAvailable) { var haveBuff = me.Auras.Any(aura => SPECIAL_BAITS.Keys.Select(l => Wowhead.GetItemInfo(l).Name).Contains(aura.Name)); if (!haveBuff) { baitID = SPECIAL_BAITS.Keys.FirstOrDefault(itemID => me.ItemsInBags.Select(itemInBag => itemInBag.EntryID).Contains(itemID)); } } } baitID = item?.EntryID ?? 0; } } catch (Exception ex) { this.LogPrint(ex.Message + "\r\n" + ex.StackTrace); baitID = 0; } if (baitID != 0) { this.LogPrint($"Applying special lure --> ({Wowhead.GetItemInfo(baitID).Name})"); game.UseItemByID(baitID); Thread.Sleep(Utilities.Rnd.Next(250, 750)); return(true); } } return(false); }
public void OnPulse() { WoWPlayerMe me = game.GetGameObjects(); if (me != null && me.CastingSpellID == 0 && me.ChannelSpellID == 0) { game.SendToChat($"/run {tableSkills}={{}}"); string prepare = $"/run local s=C_TradeSkillUI.GetFilteredRecipeIDs();local t={{}};if(#s>0) then for i=1,#s do C_TradeSkillUI.GetRecipeInfo(s[i], t);{tableSkills}[t.name]={{t.recipeID,t.numAvailable}}; end end"; game.SendToChat(prepare); string craft = string.Format("/run for n,i in pairs({0}) do if({1}[n] and i[2]>{2}[n])then C_TradeSkillUI.CraftRecipe(i[1],i[2]-{2}[n]);return; end end", tableSkills, tableNames, tableRemain); game.SendToChat(craft); //game.SendToChat(string.Format("/run local o=GetNumTradeSkills();if(o>0)then for i=1,o do local n,_,a=GetTradeSkillInfo(i);if({0}[n])then {1}[n]=a;{2}[n]=i;end end end", tableNames, tableAvailable, tableIndexes)); //game.SendToChat(string.Format("/run for i in pairs({0})do if({1}[i])then local a={1}[i]-{2}[i];if(a>0)then DoTradeSkill({3}[i],a);return;end end end", tableNames, tableAvailable, tableRemain, tableIndexes)); } else { Thread.Sleep(500); } }
private void OnPulse() { WoWPlayerMe me = game.GetGameObjects(null, null, npcs); if (me != null) { WowNpc npc = npcs.FirstOrDefault(l => l.Name == mobName && l.Location.Distance(me.Location) < 40); if (npc != null) { this.LogPrint("Found mob -->> " + npc.GUID); stopwatch.Restart(); //npc.Location.Face(); npc.Target(); game.CastSpellByName(spell); this.LogPrint("It took " + stopwatch.ElapsedMilliseconds + "ms to hit mob"); //SendMessage(Utilities.WoWWindowHandle, WM_KEYDOWN, (IntPtr)keyCode, IntPtr.Zero); //SendMessage(Utilities.WoWWindowHandle, WM_KEYUP, (IntPtr)keyCode, IntPtr.Zero); } } }
private bool ApplyBestLureIfNeeded(WoWPlayerMe me) { if (settings.UseBestBait) { uint baitID = 0; if (me.Inventory.Length > 15 && me.Inventory.Any(l => FISHING_RODS.Contains(l.EntryID)) && (DateTime.UtcNow - lastTimeLureApplied).TotalMinutes > 10) { baitID = BAITS.FirstOrDefault(l => me.ItemsInBags.Any(k => k.EntryID == l)); } if (baitID != 0) { this.LogPrint($"Applying lure --> ({Wowhead.GetItemInfo(baitID).Name})"); game.UseItemByID(baitID); lastTimeLureApplied = DateTime.UtcNow; Thread.Sleep(Utilities.Rnd.Next(250, 750)); return(true); } } return(false); }
private bool DoDalaranAchievementIfNeeded(WoWPlayerMe me) { if (settings.DalaranAchievement) { uint itemID = 0; if (me.Auras.All(l => !DALARAN_ACHIVEMENT_TRADE_ITEMS.Select(k => k.AuraID).Contains(l.SpellId) || l.TimeLeftInMs < 20000)) { var lureInBags = me.ItemsInBags.FirstOrDefault(l => DALARAN_ACHIVEMENT_TRADE_ITEMS.Select(k => k.ItemID).Contains(l.EntryID)); if (lureInBags != null) { itemID = lureInBags.EntryID; } this.LogPrint("Searching for Marcia Chase, id:95844"); var npcs = new List <WowNpc>(); game.GetGameObjects(null, null, npcs); var marciaChase = npcs.FirstOrDefault(npc => npc.EntryID == 95844); if (marciaChase != null) { this.LogPrint($"Marcia Chase is found, guid: {marciaChase.GUID}, interacting..."); marciaChase.Interact(); Thread.Sleep(Utilities.Rnd.Next(750, 1250)); this.LogPrint("I: I wish to buy something..."); game.SelectDialogOption("Мне бы хотелось купить что-нибудь у вас."); // todo: is it possible to localize it? Thread.Sleep(Utilities.Rnd.Next(750, 1250)); var newLure = DALARAN_ACHIVEMENT_TRADE_ITEMS[Utilities.Rnd.Next(0, DALARAN_ACHIVEMENT_TRADE_ITEMS.Count)]; this.LogPrint("Buying lure " + Wowhead.GetItemInfo(newLure.ItemID).Name + "..."); game.BuyMerchantItem(newLure.ItemID, 1); Thread.Sleep(Utilities.Rnd.Next(750, 1250)); this.LogPrint("Closing dialog window..."); game.SendToChat("/run CloseMerchant()"); itemID = newLure.ItemID; this.LogPrint($"Applying lure for Dalaran achievement --> ({Wowhead.GetItemInfo(itemID).Name})"); game.UseItemByID(itemID); Thread.Sleep(Utilities.Rnd.Next(250, 750)); return(true); } } } return(false); }
private bool ApplyWaterWalkingIfNeeded(WoWPlayerMe activePlayer) { if (settings.UseWaterWalking) { if (activePlayer.Class == WowPlayerClass.Sha) { var wowAura = activePlayer.Auras.FirstOrDefault(l => l.Name == WATER_WALKING_NAME); if (wowAura == default(WoWAura) || wowAura.TimeLeftInMs < 30 * 1000) // 30 sec { this.LogPrint($"Getting water walking buff"); var wowNpcs = new List <WowNpc>(); var wowPlayers = new List <WowPlayer>(); var me = game.GetGameObjects(npcs: wowNpcs, players: wowPlayers); var myTarget = me.TargetGUID; me.Target(); game.CastSpellByName(WATER_WALKING_NAME); if (myTarget != WoWGUID.Zero) { var npc = wowNpcs.FirstOrDefault(l => l.GUID == myTarget); if (npc != null) { npc.Target(); } else { var player = wowPlayers.FirstOrDefault(l => l.GUID == myTarget); if (player != null) { player.Target(); } } } Thread.Sleep(Utilities.Rnd.Next(500, 1000)); return(true); } } } return(false); }
private void ComboboxObjects_Click(object sender, EventArgs e) { comboboxObjects.Items.Clear(); try { List <WowObject> objectList = new List <WowObject>(); WoWPlayerMe localPlayer = info.GetGameObjects(objectList); List <WowObject> objectsWithUniqueNames = objectList.DistinctBy(i => i.Name).ToList(); objectsWithUniqueNames.Sort(delegate(WowObject wo1, WowObject wo2) { // ReSharper disable ImpureMethodCallOnReadonlyValueField double distance1 = wo1.Location.Distance(localPlayer.Location); double distance2 = wo2.Location.Distance(localPlayer.Location); // ReSharper restore ImpureMethodCallOnReadonlyValueField return(distance1.CompareTo(distance2)); }); comboboxObjects.Items.AddRange(objectsWithUniqueNames.Select(i => i.Name).Cast <object>().ToArray()); } catch (Exception ex) { radar.LogError($"Error: {ex.Message}"); } }
private bool ApplyLegionSpecialLureIfNeeded(WoWPlayerMe me) { if (settings.LegionUseSpecialLure) { uint baitID = 0; try { var zone = game.ZoneID; var allBuffNames = LEGION_SPECIAL_LURES_BY_ZONE.SelectMany(l => l.Lures).Select(l => Wowhead.GetItemInfo(l).Name).ToArray(); if (me.Auras.All(k => !allBuffNames.Contains(k.Name))) { var info = LEGION_SPECIAL_LURES_BY_ZONE.FirstOrDefault(l => l.ZoneID == zone); if (info != null) { var item = me.ItemsInBags.FirstOrDefault(l => info.Lures.Contains(l.EntryID)); if (item != null) { baitID = item.EntryID; } } } } catch (Exception ex) { this.LogPrint(ex.Message + "\r\n" + ex.StackTrace); baitID = 0; } if (baitID != 0) { this.LogPrint($"Applying Legion special lure --> ({Wowhead.GetItemInfo(baitID).Name})"); game.UseItemByID(baitID); Thread.Sleep(Utilities.Rnd.Next(250, 750)); return(true); } } return(false); }
private bool ApplyArcaneLureIfNeeded(WoWPlayerMe me) { if (settings.UseArcaneLure) { uint itemID = 0; var arcaneLureSpellName = Wowhead.GetSpellInfo(218861).Name; if (me.Auras.All(l => l.Name != arcaneLureSpellName)) { var item = me.ItemsInBags.FirstOrDefault(l => l.Name == arcaneLureSpellName); if (item != null) { itemID = item.EntryID; } } if (itemID != 0) { this.LogPrint($"Applying arcane lure --> ({Wowhead.GetItemInfo(itemID).Name})"); game.UseItemByID(itemID); Thread.Sleep(Utilities.Rnd.Next(250, 750)); return(true); } } return(false); }
private void OnElapsed() { WoWPlayerMe me = game.GetGameObjects(null, null, wowNpcs); if (me != null) { if (!me.InCombat) { WowNpc lootableCorpse = wowNpcs.FirstOrDefault(k => (k.Name == "Обитатель пещер Зашедшей Луны" || k.Name == "Обитатель ледяных пещер") && !k.Alive && k.IsLootable_Lua()); if (lootableCorpse != null) { if (!game.IsLooting) { lootableCorpse.Interact(); this.LogPrint("Looting --> " + lootableCorpse.GUID); } } else if (me.ItemsInBags.FirstOrDefault(l => l.EntryID == 116158) != null) { if (me.CastingSpellID == 0 && me.ChannelSpellID == 0) { Utilities.RemovePluginFromRunning("Fishing"); this.LogPrint("Fishing is paused"); Thread.Sleep(rnd.Next(2000, 3000)); game.UseItemByID(116158); this.LogPrint("Green fish is throwed"); Thread.Sleep(rnd.Next(1000, 2000)); _isworking = true; } } else { Thread.Sleep(rnd.Next(500, 1500)); Utilities.AddPluginToRunning(this, "Fishing"); if (_isworking) { this.LogPrint("Fishing is resumed"); } _isworking = false; } } else { WowNpc enemy = wowNpcs.FirstOrDefault(k => (k.Name == "Обитатель пещер Зашедшей Луны" || k.Name == "Обитатель ледяных пещер") && k.Alive); if (enemy != null) { if (enemy.GUID != me.TargetGUID) { enemy.Target(); this.LogPrint("Target enemy --> " + enemy.GUID); } else { //game.CastSpellByName(killingSpellName); CombatRotation(); this.LogPrint("Killing enemy --> " + enemy.GUID); } } } } }
internal static float AngleVertical(WoWPlayerMe me, WowPoint point) { return(-(float)Math.Round(Math.Atan2(me.Location.Distance2D(point), point.Z - me.Location.Z) - Math.PI / 2, 2)); }
private void DoAction() { List <WowObject> wowObjects = new List <WowObject>(); List <WowNpc> wowNpcs = new List <WowNpc>(); WoWPlayerMe me = game.GetGameObjects(wowObjects, null, wowNpcs); if (me != null) { DoAction action = actionsList[counter]; if (action.ActionType != DoActionType.Move) { unstuckDictionary.Clear(); } switch (action.ActionType) { case DoActionType.Move: double distance2D = me.Location.Distance2D(action.WowPoint); double distance3D = me.Location.Distance(action.WowPoint); if (me.IsFlying && (distance3D > precision3D || (distance3D <= precision3D && GetNextAction().ActionType != DoActionType.Move && me.IsMoving))) { UnstuckIfNeeded(me.Location, action.ActionType); this.LogPrint($"Flying to point --> [{action.WowPoint}]; distance: {distance3D}"); game.Move3D(action.WowPoint, precision3D, precision3D, 1000, true, GetNextAction().ActionType == DoActionType.Move); } else if (!me.IsFlying && (distance2D > precision2D || (distance2D <= precision2D && GetNextAction().ActionType != DoActionType.Move && me.IsMoving))) { UnstuckIfNeeded(me.Location, action.ActionType); this.LogPrint(string.Format("Moving to point --> [{0}]; my loc: [{3}]; distance2D: {1}; speed: {2}", action.WowPoint, distance2D, me.Speed, me.Location)); game.Move2D(action.WowPoint, precision2D, 1000, true, GetNextAction().ActionType == DoActionType.Move); } else { IncreaseCounterAndDoAction(); } break; case DoActionType.StopProfile: if (loopPath) { IncreaseCounterAndDoAction(); } break; case DoActionType.RunLua: Thread.Sleep(500); // player should be stopped before interact game.SendToChat("/run " + string.Concat(action.Data.TakeWhile(l => l != '\r' && l != '\n'))); IncreaseCounterAndDoAction(); break; case DoActionType.SendChat: Thread.Sleep(500); // player should be stopped before interact game.SendToChat(action.Data); IncreaseCounterAndDoAction(); break; case DoActionType.SelectGossipOption: Thread.Sleep(1000); // player should be stopped before interact game.SelectDialogOption(action.Data); IncreaseCounterAndDoAction(); break; case DoActionType.Interact: WowObject[] objectsWithCorrectName = wowObjects.Where(l => l.Name == action.Data).ToArray(); if (objectsWithCorrectName.Length > 0) { WowObject nearestObject = objectsWithCorrectName.Aggregate((minItem, nextItem) => me.Location.Distance(minItem.Location) < me.Location.Distance(nextItem.Location) ? minItem : nextItem); Thread.Sleep(500); // player should be stopped before interact nearestObject.Interact(); } WowNpc[] npcsWithCorrectName = wowNpcs.Where(l => l.Name == action.Data).ToArray(); if (npcsWithCorrectName.Length > 0) { WowNpc nearestNpc = npcsWithCorrectName.Aggregate((minItem, nextItem) => me.Location.Distance(minItem.Location) < me.Location.Distance(nextItem.Location) ? minItem : nextItem); Thread.Sleep(500); // player should be stopped before interact nearestNpc.Interact(); } IncreaseCounterAndDoAction(); break; case DoActionType.Wait: int timeToWait = int.Parse(action.Data); while (timeToWait > 0 && timer.IsRunning) { Thread.Sleep(100); timeToWait -= 100; } IncreaseCounterAndDoAction(); break; case DoActionType.SetPrecision2D: if (!float.TryParse(action.Data, out precision2D)) { precision2D = 3f; } IncreaseCounterAndDoAction(); break; case DoActionType.SetPrecision3D: if (!float.TryParse(action.Data, out precision3D)) { precision3D = 8f; } IncreaseCounterAndDoAction(); break; case DoActionType.WaitWhile: if (!game.LuaIsTrue(action.Data)) { IncreaseCounterAndDoAction(); } else if (!string.IsNullOrWhiteSpace(action.AdditionalData) && int.TryParse(action.AdditionalData, out int lag)) { Thread.Sleep(lag); } break; case DoActionType.SendToChatWhile: string[] p = action.Data.Split(new[] { "##@##" }, StringSplitOptions.RemoveEmptyEntries); string _action = p[0]; string condition = p[1]; if (game.LuaIsTrue(condition)) { game.SendToChat(_action); } else { IncreaseCounterAndDoAction(); } break; case DoActionType.StopProfileIf: if (game.LuaIsTrue(action.Data)) { counter = actionsList.Count - 1; } IncreaseCounterAndDoAction(); break; case DoActionType.NotifyUser: this.ShowNotify(action.Data, false, false); IncreaseCounterAndDoAction(); break; case DoActionType.NotifyUserIf: if (game.LuaIsTrue(action.AdditionalData)) { this.ShowNotify(action.Data, false, false); } IncreaseCounterAndDoAction(); break; default: IncreaseCounterAndDoAction(); break; } } else { this.LogPrint("Local player is null"); } }
private void ShamanRoutine(WoWPlayerMe me) { var myEditbox = WoWUIFrame.GetFrameByName(game, frameName); //if (myEditbox == null) //{ // var funcName = Utilities.GetRandomString(6, true); // var commands = new string[] { // $"/run if(not {frameName})then CreateFrame(\"EditBox\", \"{frameName}\", UIParent);{frameName}:SetAutoFocus(false);{frameName}:ClearFocus(); end", // $"/run {funcName}=\"{frameName}:SetText(tostring(GetSpellCooldown(\\\"Удар бури\\\"))..\\\"#\\\"..tostring(GetSpellCooldown(\\\"Камнедробитель\\\"))\"", // $"/run {funcName}={funcName}..\"..\\\"#\\\"..tostring(GetSpellCooldown(\\\"Язык пламени\\\"))..\\\"#\\\"..tostring(UnitPower(\\\"player\\\", 11)))\"", // $"/run C_Timer.NewTicker(.25, function() loadstring({funcName}); end)" // }; // foreach (var command in commands) // game.SendToChat(command); //} if (specialization == 1) { if (game.LuaGetValue("tostring(UnitDebuff(\"target\", \"Огненный шок\") or \"nil\")") == "nil") { game.CastSpellByName("Огненный шок"); } else if (float.Parse(game.LuaGetValue("tostring(select(2, GetSpellCooldown(\"Выброс лавы\")))"), CultureInfo.InvariantCulture) <= 1.5) { game.CastSpellByName("Выброс лавы"); } else { game.CastSpellByName("Молния"); } } else if (specialization == 2) { myEditbox = WoWUIFrame.GetFrameByName(game, frameName); var regex = new Regex("(\\d+)#(\\d+)#(\\d+)#(\\d+)"); this.LogPrint(myEditbox.EditboxText); var match = regex.Match(myEditbox.EditboxText); var stormstrikeHasCd = match.Groups[1].Value != "0"; var maelstrom = int.Parse(match.Groups[4].Value); var rockbiterHasCd = match.Groups[2].Value != "0"; var flameTongueHasCd = match.Groups[3].Value != "0"; if (!stormstrikeHasCd && maelstrom >= 30) { game.CastSpellByName("Удар бури"); return; } if (!rockbiterHasCd) { game.CastSpellByName("Камнедробитель"); return; } if (!flameTongueHasCd) { game.CastSpellByName("Язык пламени"); return; } if (maelstrom >= 40) { game.CastSpellByName("Вскипание лавы"); } } }