Beispiel #1
0
        public void MoveToCell(short CellID)
        {
            List <CellWithOrientation> path = Fight.finder.GetPath((short)Player.PlayerBaseInformations.CellId, CellID);

            //if (path == null) {
            //    Fight.mHost.logger.Log ("Path null !", RaidBot.Common.Default.Loging.LogLevelEnum.Error);
            //    return;
            //}
            //if (path.Count - 1 > Player.PlayerFightInformations.Stats.movementPoints)
            //{
            //    path = path.GetRange(0, Player.PlayerFightInformations.Stats.movementPoints + 1);
            //}
            //for (int i = 0; i <= path.Count - 1 ; i++ )
            //{
            //    RaidBot.Data.IO.D2P.Map.CellData Cellule = Player.mWorld.Map.Data.Cells[path[i].Id];
            //    if (Fight.GetEnnemiesCells().Any(cell => cell == path[i].Id) || !Cellule.los)
            //    {
            //        if (path.Count < 3)
            //            return;
            //        path = path.GetRange(0, i );
            //          break;
            //    }
            //}
            //if (path.Count < 2) {
            //    Fight.mHost.logger.Log ("path count !", RaidBot.Common.Default.Loging.LogLevelEnum.Error);
            //    return;
            //}
            Player.mHost.SendMessage(new GameMapMovementRequestMessage(PathingUtils.GetCompressedPath(path), (int)Player.mWorld.Map.Data.Id));
        }
Beispiel #2
0
 private void AddCellIfValid(int x, int y, Pathfinder finder, IList <Cell> container)
 {
     if (!Cell.IsInMap(x, y) || !finder.matrix.Any(cell => cell.Key == PathingUtils.CoordToCellId(x, y)))
     {
         return;
     }
     container.Add(finder.matrix[PathingUtils.CoordToCellId(x, y)]);
 }
        private GeneratedDirections GenerateDirections(IEntity ent)
        {
            // generate directions
            var data = PathingUtils.WalkTo(
                ent.GetTransform(), Waypoints[_currentWaypointIndex])
                       .Take(2)
                       .ToArray();

            return(new GeneratedDirections(data[0], data[1]));
        }
Beispiel #4
0
    private double PointWeight(Point point)
    {
        double result = 1;
        int    cellId = PathingUtils.CoordToCellId(point.X, point.Y);
        int    speed  = currentMap.Data.Cells[cellId].Speed;

        if (speed >= 0)
        {
            result = result + (5 - speed);
        }
        else
        {
            result = result + (11 + Math.Abs(speed));
        }
        return(result);
    }
Beispiel #5
0
        public GeneratedDirections GetNextDirections(IEntity ent)
        {
            if (Target.IsDead())
            {
                return(GeneratedDirections.Noop);
            }

            var entityTranfrom  = ent.GetTransform();
            var targetTransform = Target.Get().GetTransform();

            var targetPosition = GetTargetPosition(targetTransform);

            // Use WalkTo pathing, then take two directions from it and conver it to an array.
            // Doing all of these skips us from dealing with enumerators.
            // Since WalkTo is guaranteed to return noops if we're on top of the target, we don't need to worry about going out of range.
            var data = PathingUtils.WalkTo(entityTranfrom, targetPosition).Take(2).ToArray();

            return(new GeneratedDirections(data[0], data[1]));
        }
Beispiel #6
0
    private void SortOpenList()
    {
        bool ok = false;

        while (!ok)
        {
            ok = true;
            Cell temp;
            for (int i = 0; i < openList.Count - 1; i++)
            {
                if (openList[i].F > openList[i + 1].F && PathingUtils.DistanceToPoint(openList[i].Location, destinationCell.Location) < PathingUtils.DistanceToPoint(openList[i + 1].Location, destinationCell.Location))
                {
                    temp            = openList[i];
                    openList[i]     = openList[i + 1];
                    openList[i + 1] = temp;
                    ok = false;
                }
            }
        }
    }
Beispiel #7
0
 public short[] GetCompressedPath(short startCellId, short destinationCellId)
 {
     return(PathingUtils.GetCompressedPath(Find(startCellId, destinationCellId)).ToArray());
 }
Beispiel #8
0
 public short[] GetCompressedPath(List <CellWithOrientation> cells)
 {
     return(PathingUtils.GetCompressedPath(cells));
 }