Ejemplo n.º 1
0
        private bool PerFormWaypoint(Objects.Bot.Waypoint w)
        {
            if(!Core.IsLoggedIn)
            {
                return false;
            }
            bool WaypointReached = false;
            if (Core.WaitForLoot > DateTime.Now)
            {
                if(Core.Looter.CorpseList.Count() > 0 && Core.Global.LootWhenAllIsDead == false)
                {
                    return OpenCorpses();
                }
                else
                {
                    return false;
                }
            }
            else
            {
                if (Core.Looter.CorpseList.Count() > 0 && Core.Global.LootWhenAllIsDead == false)
                {
                    return OpenCorpses();
                }
            }
            if(Core.Attacker.TargetsAround > 0  || Core.client.Player.RedSquare > 0 || Core.client.MiniMap.IsWalking)
            {
                return false;
            }
            if(w.Location.Z != Core.client.PlayerLocation.Z)
            {
                NextWaypoint();
                Core.SleepRandom();
                return false;
            }
            if (Core.Global.LootWhenAllIsDead && Core.Looter.CorpseList.Count() > 0)
            {
                return OpenCorpses();
            }
            if(Core.Global.Waypoints.Count() == 0)
            {
                return false;
            }
            switch(w.Type)
            {
                case Constants.WaypointType.Walk:
                    if(Core.client.PlayerLocation == w.Location || Core.client.PlayerLocation.Z != w.Location.Z)
                    {
                        WaypointReached = true;
                        break;
                    }
                    else
                    {

                        // Core.client.Player.GoTo = w.Location;
                        PreformWalk(w.Location);
                        break;
                    }                
                case Constants.WaypointType.UpUse:
                    if(Core.client.PlayerLocation.Z <w.Location.Z)
                    {
                        WaypointReached = true;
                        break;
                    }
                    else
                    {
                        if(Core.client.PlayerLocation == w.Location)
                        {
                            Tile t = Core.client.Map.GetTile(w.Location);
                            foreach (Item i in t.Items)
                            {
                                if(Constants.TileList.UpUse.Contains((uint)i.Id))
                                {
                                    i.Use();
                                    Core.SleepRandom();
                                    WaypointReached = false;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            // Core.client.Player.GoTo = w.Location;
                            PreformWalk(w.Location);
                            WaypointReached = false;
                            break;
                        }
                        break;
                    }
                    
                case Constants.WaypointType.DownUse:
                    if (Core.client.PlayerLocation.Z > w.Location.Z)
                    {
                        WaypointReached = true;
                        break;
                    }
                    else
                    {
                        if (Core.client.PlayerLocation == w.Location)
                        {
                            Tile t = Core.client.Map.GetTile(w.Location);
                            foreach (Item i in t.Items)
                            {
                                if (Constants.TileList.DownUse.Contains((uint)i.Id))
                                {
                                    i.Use();
                                    Core.SleepRandom();
                                    WaypointReached = false;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            //  Core.client.Player.GoTo = w.Location;
                            PreformWalk(w.Location);
                            WaypointReached = false;
                            break;
                        }
                        break;
                    }
                  
                case Constants.WaypointType.Rope:
                    if (Core.client.PlayerLocation.Z < w.Location.Z)
                    {
                        WaypointReached = true;
                        break;
                    }
                    else
                    {
                        if(Core.client.PlayerLocation != w.Location && w.Location.IsAdjacentTo(Core.client.PlayerLocation) == false)
                        {
                            //   Core.client.Player.GoTo = w.Location;
                            PreformWalk(w.Location);
                            WaypointReached = false;
                            break;
                        }
                        else
                        {
                            // we must be on the spot
                            Core.client.Inventory.UseItemOnTile(3003, Core.client.Map.GetTile(w.Location));
                            Core.SleepRandom();
                            WaypointReached = false;
                            break;
                        }
                        
                    }
                    
                case Constants.WaypointType.Shovel:
         
                    if (Core.client.PlayerLocation.Z > w.Location.Z)
                    {
                        WaypointReached = true;
                        break;
                    }
                    else
                    {
                        if (Core.client.PlayerLocation != w.Location && w.Location.IsAdjacentTo(Core.client.PlayerLocation) == false)
                        {
                            //  Core.client.Player.GoTo = w.Location;
                            PreformWalk(w.Location);
                            WaypointReached = false;
                            break;
                        }
                        else
                        {
                          if(Core.client.PlayerLocation == w.Location)
                          {
                              List<Tile> tlist = Core.client.Map.GetTilesSameFloor().Where(t => t.Location.IsAdjacentTo(Core.client.PlayerLocation) && t.Location != Core.client.PlayerLocation && t.IsBlocking() ==false).ToList();
                                // Core.client.Player.GoTo = tlist[0].Location;
                                PreformWalk(tlist[0].Location);
                                WaypointReached = false;
                              break;
                          }
                          else if (Core.client.PlayerLocation.IsAdjacentTo(w.Location))
                          {
                              Tile t = Core.client.Map.GetTile(w.Location);
                              Core.client.Inventory.UseItemOnTile(3457, t);
                              Core.SleepRandom();
                              Core.client.Player.GoTo = w.Location;
                              WaypointReached = false;
                              break;
                          }
                         

                        }
                    }
                    break;
                case  Constants.WaypointType.Door:
                    if(Core.client.PlayerLocation == w.Location)
                    {
                        WaypointReached = true;
                        break;

                    }
                    else if(Core.client.PlayerLocation.IsAdjacentTo(w.Location) == false)
                    {
                        List<Tile> tiles = Core.client.Map.GetTilesSameFloor().Where(t => t.Location.IsAdjacentTo(w.Location)).ToList();
                        List<Tile> tList = tiles.Where(t => t.IsReachable()).ToList();
                        if(tList.Count() > 0)
                        {
                            //Core.client.Player.GoTo = tList[0].Location;
                            PreformWalk( tList[0].Location);
                            WaypointReached = false;
                            break;
                        }
                        else
                        {
                          //  Core.client.Player.GoTo = w.Location;
                            PreformWalk(w.Location);
                            WaypointReached = false;
                            break;
                        }
                    }
                    else if(Core.client.PlayerLocation.IsAdjacentTo(w.Location))
                    {
                        Tile t = Core.client.Map.GetTile(w.Location);
                        if(t.IsBlocking())
                        {
                            foreach (Item i in Core.client.Map.GetTile(w.Location).Items)
                            {
                                if (i.ItemData.LensHelp == 1104)// dooor
                                {
                                    i.Use();
                                    Core.SleepRandom();
                                    Core.client.Player.GoTo = w.Location;
                                    WaypointReached = false;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            //Core.client.Player.GoTo = w.Location;
                            PreformWalk(w.Location);
                            WaypointReached = false;
                            break;
                        }
                       
                    }
                    break;
                case Constants.WaypointType.Machete:
                    if (Core.client.PlayerLocation == w.Location)
                    {
                        WaypointReached = true;
                        break;
                    }
                    else if (Core.client.PlayerLocation.IsAdjacentTo(w.Location) == false)
                    {
                        List<Tile> tiles = Core.client.Map.GetTilesSameFloor().Where(t => t.Location.IsAdjacentTo(w.Location)).ToList();
                        List<Tile> tList = tiles.Where(t => t.IsReachable()).ToList();
                        if (tList.Count() > 0)
                        {
                            //Core.client.Player.GoTo = tList[0].Location;
                            PreformWalk(tList[0].Location);
                            WaypointReached = false;
                            break;
                        }
                        else
                        {
                         //   Core.client.Player.GoTo = w.Location;
                            PreformWalk(w.Location);
                            WaypointReached = false;
                            break;
                        }
                    }
                    else if (Core.client.PlayerLocation.IsAdjacentTo(w.Location))
                    {
                        Tile t = Core.client.Map.GetTile(w.Location);
                        if (t.IsBlocking())
                        {
                            Item i = t.TopItem();
                            Packets.OutGoing.ItemUseOn.Send(Core.client, ItemLocation.FromHotkey().ToLocation(), 3308, 0, w.Location, (ushort)i.Id, i.Location.StackOrder);
                        }
                        else
                        {
                            //Core.client.Player.GoTo = w.Location;
                            PreformWalk(w.Location);
                            WaypointReached = false;
                            break;
                        }

                    }

                    break;
            }

            return WaypointReached;
        }