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; } }
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"); } } } } }
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(); }
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 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 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 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); } } } } }