Example #1
0
        private static bool CheckMobs(PGameObject harvest)
        {
            int mobs =
                ObjectManager.GetUnits.Where(
                    unit => unit.Location.DistanceFrom(harvest.Location) < 25 && unit.Reaction == Reaction.Hostile).
                Count();

            if ((mobs > 0) && HasRessSickness())
            {
                ToldAboutNode.TellAbout("there are mobs close to the node and we have ress sickness", harvest);
                FlyingBlackList.Blacklist(harvest, 120, true);
                return(false);
            }
            if (FlyingSettings.AvoidElites &&
                ObjectManager.GetUnits.Where(
                    unit =>
                    unit.Location.DistanceFrom(harvest.Location) < 30 && unit.IsElite &&
                    unit.Reaction == Reaction.Hostile).Count() != 0)
            {
                Logging.Write("周围有精英怪,就不落地了");
                FlyingBlackList.Blacklist(harvest, 120, true);
                return(false);
            }
            if (Convert.ToInt32(FlyingSettings.MaxUnits) < mobs)
            {
                Logging.Write("周围怪太多,这个点被加入黑名单");
                FlyingBlackList.Blacklist(harvest, 120, true);
                return(false);
            }
            return(true);
        }
Example #2
0
        public void Click(RadarForm form, MouseEventArgs e)
        {
            Point cursorPosition = form.PointToClient(Cursor.Position);
            var   cursorRect     = new Rectangle(cursorPosition.X, cursorPosition.Y, 5, 5);

            try
            {
                foreach (PGameObject node in ObjectManager.GetGameObject)
                {
                    if (FindNode.IsHerb(node) || FindNode.IsMine(node))
                    {
                        float x       = form.OffsetX(node.Location.X, ObjectManager.MyPlayer.Location.X);
                        float y       = form.OffsetY(node.Location.Y, ObjectManager.MyPlayer.Location.Y);
                        var   objRect = new Rectangle((int)y, (int)x, 5, 5);
                        if (Rectangle.Intersect(objRect, cursorRect) != Rectangle.Empty)
                        {
                            if (FlyingBlackList.IsBlacklisted(node))
                            {
                                FlyingBlackList.Unblacklist(node);
                            }
                            else
                            {
                                Logging.Write("Added the node to the permanent blacklist");
                                FlyingBlackList.AddBadNode(node);
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }
Example #3
0
        public override void DoWork()
        {
            FlyingEngine.Navigator.Stop();
            if (ApproachPosFlying.Approach(_npc.Location, 12))
            {
                MoveHelper.MoveToLoc(_npc.Location, 3);
                //VendorManager.DoSell(_npc);

                while (!ObjectManager.MyPlayer.Target.Name.Equals(_npc.Name))
                {
                    // 目标选择NPC
                    KeyHelper.SendLuaOverChat("/target " + _npc.Name);
                    Thread.Sleep(500);
                }

                _npc.Interact();
                Thread.Sleep(500);

                // 卖东西
                SpyFrame.ExecSimpleLua("/script SellJunk:Sell()");
                Thread.Sleep(500);

                // 修理
                SpyFrame.ExecSimpleLua("/click MerchantRepairAllButton");
            }
            FlyingBlackList.Blacklist(_npc, 200, true);
            Logging.Write("[Vendor]Vendor done");
        }
Example #4
0
 public override void DoWork()
 {
     FlyingEngine.Navigator.Stop();
     if (ApproachPosFlying.Approach(_npc.Location, 12))
     {
         MoveHelper.MoveToLoc(_npc.Location, 5);
         VendorManager.DoSell(_npc);
     }
     FlyingBlackList.Blacklist(_npc, 200, true);
     Logging.Write("[Vendor]Vendor done");
 }
Example #5
0
 internal static bool CheckDruidFight(PGameObject gameObject)
 {
     if (ObjectManager.ShouldDefend && ObjectManager.MyPlayer.IsInFlightForm)
     {
         if (FlyingSettings.DruidAvoidCombat)
         {
             Logging.Write("Druid - avoiding combat - blacklisting node");
             FlyingBlackList.Blacklist(gameObject, 300, false);
             return(true);
         }
         Mount.Dismount();
         return(false);
     }
     return(false);
 }
Example #6
0
 internal static bool PlayerToClose(int distance, PGameObject gameObject)
 {
     if (!FlyingSettings.AvoidPlayers)
     {
         return(false);
     }
     if (
         ObjectManager.GetPlayers.Where(obj => !obj.Name.Equals(ObjectManager.MyPlayer.Name))
         .Any(obj => FindNode.GetLocation(gameObject).GetDistanceTo(obj.Location) < distance))
     {
         Logging.Write("Player to close to node");
         FlyingBlackList.Blacklist(gameObject, 300, false);
         return(true);
     }
     return(false);
 }
Example #7
0
 public static bool GatherNode(PGameObject harvest)
 {
     if (FindNode.IsSchool(harvest))
     {
         return(GatherFishNode(harvest));
     }
     if (ApprochNode(harvest))
     {
         Logging.Write("靠近[矿/草]点");
         HitTheNode(harvest);
         if (!CheckMobs(harvest))
         {
             return(false);
         }
         if (FlyingBlackList.IsBlacklisted(harvest))
         {
             ToldAboutNode.TellAbout("is blacklisted", harvest);
             return(false);
         }
         if (MoveHelper.NegativeValue(ObjectManager.MyPlayer.Location.Z - FindNode.GetLocation(harvest).Z) > 1)
         {
             Logging.Write("下降中......");
             DescentToNode(harvest);
         }
         if (FlyingBlackList.IsBlacklisted(harvest))
         {
             ToldAboutNode.TellAbout("is blacklisted", harvest);
             return(false);
         }
         if (FindNode.GetLocation(harvest).DistanceToSelf2D > 5)
         {
             ApproachPosFlying.Approach(harvest.Location, 4);
         }
         if (FindNode.GetLocation(harvest).DistanceToSelf > 10)
         {
             Logging.Write("距离矿/草太远,放弃");
             return(false);
         }
         if (!DismountAndHarvest(harvest, TimeOut))
         {
             return(false);
         }
         return(true);
     }
     ToldAboutNode.TellAbout("过不去啊!!!", harvest);
     return(false);
 }
Example #8
0
 public void Draw(RadarForm form)
 {
     foreach (PGameObject selectNode in ObjectManager.GetGameObject)
     {
         if (FindNode.IsHerb(selectNode) || FindNode.IsMine(selectNode))
         {
             if (FlyingBlackList.IsBlacklisted(selectNode))
             {
                 form.PrintCircle(_colorBadNodes,
                                  form.OffsetY(selectNode.Location.Y, ObjectManager.MyPlayer.Location.Y),
                                  form.OffsetX(selectNode.Location.X, ObjectManager.MyPlayer.Location.X),
                                  selectNode.Name);
             }
             else
             {
                 form.PrintCircle(_colorObjects,
                                  form.OffsetY(selectNode.Location.Y, ObjectManager.MyPlayer.Location.Y),
                                  form.OffsetX(selectNode.Location.X, ObjectManager.MyPlayer.Location.X),
                                  selectNode.Name);
             }
         }
     }
 }
Example #9
0
        //Ugly ugly ugly but we have to support vashir
        internal static void DescentToSchool(PGameObject nodeToHarvest)
        {
            var      ticker    = new Ticker(20 * 1000);
            var      timerDiff = new Ticker(500);
            float    diffSelf  = 3;
            Location oldPos    = ObjectManager.MyPlayer.Location;
            float    diffZ     = MoveHelper.NegativeValue(nodeToHarvest.Location.Z - ObjectManager.MyPlayer.Location.Z);

            while (ObjectManager.MyPlayer.IsFlying && diffZ > 2 && !ticker.IsReady && diffSelf > 0.3)
            {
                if (FlyingBlackList.IsBlacklisted(nodeToHarvest))
                {
                    return;
                }
                diffZ = MoveHelper.NegativeValue(ObjectManager.MyPlayer.Location.Z - nodeToHarvest.Location.Z);
                if (timerDiff.IsReady)
                {
                    diffSelf = MoveHelper.NegativeValue(oldPos.Z - ObjectManager.MyPlayer.Location.Z);
                    timerDiff.Reset();
                    oldPos = ObjectManager.MyPlayer.Location;
                }
                Thread.Sleep(10);
            }
        }
Example #10
0
        public bool EngineStart()
        {
            FindNode.LoadHarvest();
            FlyingSettings.LoadSettings();
            KeyHelper.AddKey("FMount", "None", FlyingSettings.FlyingMountBar, FlyingSettings.FlyingMountKey);
            KeyHelper.AddKey("Lure", "None", FlyingSettings.LureBar, FlyingSettings.LureKey);
            KeyHelper.AddKey("Waterwalk", "None", FlyingSettings.WaterwalkBar, FlyingSettings.WaterwalkKey);
            KeyHelper.AddKey("CombatStart", "None", FlyingSettings.ExtraBar, FlyingSettings.ExtraKey);
            if (!ObjectManager.InGame)
            {
                Logging.Write(LogType.Info, "Enter game before starting the bot");
                return(false);
            }
            if (ObjectManager.MyPlayer.IsGhost)
            {
                Logging.Write(LogType.Info, "Please ress before starting the bot");
                return(false);
            }
            if (CurrentProfile == null)
            {
                Logging.Write(LogType.Info, "Please load a profile");
                return(false);
            }
            if (CurrentProfile.WaypointsNormal.Count < 2)
            {
                Logging.Write(LogType.Info, "Profile should have more than 2 waypoints");
                return(false);
            }
            Navigation = new FlyingNavigation(CurrentProfile.WaypointsNormal, true, FlyingWaypointsType.Normal);
            Navigator  = new FlyingNavigator();
            ToTown.SetToTown(false);
            switch (CurrentMode)
            {
            case Mode.Normal:
                FlyingStates = new List <MainState>
                {
                    new StateMount(),
                    new StateMoving(),
                    new StateGather(),
                    new StateCombat(),
                    new StateRess(),
                    new StateResting(),
                    new StateMailbox(),
                    new StateToTown(),
                    new StateVendor(),
                    new StateFullBags(),
                };
                break;

            case Mode.TestNormal:
                Logging.Write(LogType.Warning,
                              "Starting flying engine in TestNormal mode, next start will be in normal mode");
                FlyingStates = new List <MainState>
                {
                    new StateMount(),
                    new StateMoving(),
                    new StateFullBags(),
                };
                break;

            case Mode.TestToTown:
                Logging.Write(LogType.Warning,
                              "Starting flying engine in TestToTown mode, next start will be in normal mode");
                FlyingStates = new List <MainState>
                {
                    new StateMount(),
                    new StateMoving(),
                    new StateCombat(),
                    new StateMailbox(),
                    new StateToTown(),
                    new StateVendor(),
                    new StateFullBags(),
                };
                ToTown.SetToTown(true);     //Set town mode to true
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            Stuck.Run();
            FlyingBlackList.Load();
            CloseWindows();
            CurrentMode = Mode.Normal;
            _harvest    = 0;
            _kills      = 0;
            _death      = 0;
            _startTime  = DateTime.Now;
            UpdateStats(0, 0, 0);
            return(true);
        }
Example #11
0
        private static bool ApprochNode(PGameObject harvest)
        {
            var harvestModified = new PGameObject(harvest.BaseAddress);
            int num             = Convert.ToInt32(FlyingSettings.ApproachModifier);
            var modifiedPos     = new Location(harvestModified.X, harvestModified.Y, (harvestModified.Z + num));

            if (!ObjectManager.MyPlayer.IsFlying)
            {
                modifiedPos = new Location(harvestModified.X, harvestModified.Y, harvestModified.Z);
            }
            var    timeout = new Ticker(8000);
            double num2    = modifiedPos.DistanceToSelf;
            bool   jumped  = false;

            StopASec.Reset();
            while (modifiedPos.DistanceToSelf2D > 10.0)
            {
                FlyingEngine.Navigator.SetDestination(modifiedPos);
                if (PlayerToClose(20, harvest))
                {
                    ToldAboutNode.TellAbout("Player to close", harvest);
                    return(false);
                }
                if (timeout.IsReady)
                {
                    if (FlyingSettings.AutoBlacklist)
                    {
                        Logging.Write("Blacklisting node for-ever");
                        FlyingBlackList.AddBadNode(harvest.Location);
                    }
                    FlyingEngine.Navigator.Stop();
                    ToldAboutNode.TellAbout("node blacklisted", harvest);
                    return(false);
                }
                if (StopASec.IsReady)
                {
                    Logging.Write("Check spin");
                    FlyingEngine.Navigator.Stop();
                    MoveHelper.ReleaseKeys();
                    harvest.Location.Face();
                    StopASec.Reset();
                    FlyingEngine.Navigator.Start();
                }
                if (FlyingBlackList.IsBlacklisted(harvest))
                {
                    ToldAboutNode.TellAbout("node blacklisted", harvest);
                    return(false);
                }
                if (modifiedPos.DistanceToSelf < num2)
                {
                    num2 = modifiedPos.DistanceToSelf;
                    timeout.Reset();
                }
                if (modifiedPos.DistanceToSelf > 2.0)
                {
                    FlyingEngine.Navigator.Start();
                }
                else
                {
                    FlyingEngine.Navigator.Stop();
                }
                if (Stuck.IsStuck)
                {
                    Unstuck.TryUnstuck(false);
                }
                if (!Mount.IsMounted())
                {
                    Logging.Write("We got dismounted, abort");
                    return(false);
                }
                if (!jumped && modifiedPos.DistanceToSelf2D > 20 && !ObjectManager.MyPlayer.IsFlying &&
                    ObjectManager.MyPlayer.IsMounted && !ObjectManager.MyPlayer.InVashjir)
                {
                    Logging.Write("正在地面上跑,飞起来");
                    FlyingEngine.Navigator.Stop();
                    MoveHelper.Jump(1000);
                    FlyingEngine.Navigator.Start();
                    jumped = true;
                }
                Thread.Sleep(100);
            }
            FlyingEngine.Navigator.Stop();
            return(harvestModified.Location.DistanceToSelf2D < 10.0);
        }
Example #12
0
        internal static bool GatherFishNode(PGameObject node)
        {
            if (_reLure == null)
            {
                _reLure = new Ticker(600000);
                _reLure.ForceReady();
            }
            FlyingEngine.Navigator.Stop();
            var combat = new StateCombat();
            int nearestIndexInPositionList =
                Location.GetClosestPositionInList(FlyingEngine.CurrentProfile.WaypointsNormal, node.Location);
            Location position = FlyingEngine.CurrentProfile.WaypointsNormal[nearestIndexInPositionList];

            if (!ApproachPosFlying.Approach(position, 5))
            {
                return(false);
            }
            node.Location.Face();
            if (Bobber() != null)
            {
                Logging.Write("Someone is fishing, break");
                return(false);
            }
            if (!CheckMobs(node))
            {
                return(false);
            }
            if (FlyingBlackList.IsBlacklisted(node))
            {
                ToldAboutNode.TellAbout("is blacklisted", node);
                return(false);
            }
            DescentToSchool(node);
            Mount.Dismount();
            var timeout      = new Ticker((FlyingSettings.MaxTimeAtSchool * 60) * 1000);
            var checkIfValid = new Ticker(8000);

            while (node.IsValid)
            {
                while (combat.NeedToRun)
                {
                    combat.DoWork();
                    timeout.Reset();
                }
                if (checkIfValid.IsReady)
                {
                    if (ObjectManager.GetObjects.FirstOrDefault(u => u.BaseAddress == node.BaseAddress) == null)
                    {
                        break;
                    }
                    checkIfValid.Reset();
                }
                if (FlyingSettings.Lure && _reLure.IsReady)
                {
                    KeyHelper.SendKey("Lure");
                    Thread.Sleep(3500);
                    _reLure.Reset();
                }
                if (timeout.IsReady)
                {
                    return(false);
                }
                if (ObjectManager.MyPlayer.IsSwimming)
                {
                    MoveHelper.Jump(1500);
                    Thread.Sleep(1000);
                    KeyHelper.SendKey("Waterwalk");
                    Thread.Sleep(2000);
                    MoveHelper.Jump(1500);
                    Thread.Sleep(1500);
                    if (ObjectManager.MyPlayer.IsSwimming)
                    {
                        return(false);
                    }
                }
                node.Location.Face();
                var timeout3 = new Ticker(4000);
                while (!timeout3.IsReady && (node.Location.DistanceToSelf2D < 14))
                {
                    MoveHelper.Backwards(true);
                    Thread.Sleep(20);
                }
                MoveHelper.ReleaseKeys();
                timeout3.Reset();
                node.Location.Face();
                while (!timeout3.IsReady && (node.Location.DistanceToSelf2D > 16))
                {
                    MoveHelper.Forwards(true);
                    Thread.Sleep(20);
                }
                MoveHelper.ReleaseKeys();
                KeyHelper.SendKey("Fishing");
                Thread.Sleep(1500);
                Fishing.FindBobberAndClick(FlyingSettings.WaitForLoot);
                Thread.Sleep(100);
            }
            return(true);
        }
Example #13
0
 public override void DoWork()
 {
     Logging.Debug("Approaching: " + _node.Location);
     if (_nodeLoc == _node.Location)
     {
         if (_approachTimes > 6)
         {
             Logging.Write("We tried to approach the same node more than 6 times... does not make sense abort");
             FlyingBlackList.Blacklist(_node, 120, true);
             return;
         }
         _approachTimes++;
     }
     else
     {
         _nodeLoc       = _node.Location;
         _approachTimes = 0;
     }
     if (Gather.GatherNode(_node))
     {
         FlyingEngine.UpdateStats(1, 0, 0);
         if (FlyingSettings.WaitForLoot)
         {
             while (ObjectManager.MyPlayer.LootWinOpen && !TimeOut.IsReady)
             {
                 Thread.Sleep(100);
             }
             Latency.Sleep(1300);
         }
         if (ObjectManager.MyPlayer.IsInFlightForm)
         {
             MoveHelper.Jump();
         }
     }
     else
     {
         if (ObjectManager.ShouldDefend && Mount.IsMounted())
         {
             Logging.Write("ShouldDefend while mounted? Odd");
             FlyingBlackList.Blacklist(_node, 120, true);
         }
     }
     if (!ObjectManager.MyPlayer.InVashjir && ObjectManager.MyPlayer.IsSwimming)
     {
         Logging.Write("We got into the water, blacklisting node");
         FlyingBlackList.AddBadNode(_node);
         KeyHelper.SendKey("Space");
         Thread.Sleep(3000);
         KeyHelper.ReleaseKey("Space");
     }
     if (!ObjectManager.ShouldDefend && !ObjectManager.MyPlayer.IsInCombat)
     {
         LootedBlacklist.Looted(_node);
         if (ObjectManager.MyPlayer.InVashjir)
         {
             KeyHelper.SendKey("Space");
             Thread.Sleep(1000);
             KeyHelper.ReleaseKey("Space");
         }
     }
     if (!Mount.IsMounted())
     {
         CombatHandler.RunningAction();
         CombatHandler.Rest();
     }
     Stuck.Reset();
     if (FlyingEngine.CurrentProfile.NaturalRun)
     {
         FlyingEngine.Navigation.UseNearestWaypoint();
     }
     else
     {
         FlyingEngine.Navigation.UseNearestWaypoint(10);
     }
 }