Example #1
0
        public async Task <bool> CanUseSpell()
        {
            Map mapa = Account.Character.Map;

            mapa.Pathmaker = new AivyDofus.Model.Maps.Pathmaker(mapa);
            var spell      = (Current as CharacterFighter).Spells.First(c => c.Key == 161).Value;
            var spellStats = spell.Stats.First(c => c.Key == spell.Level).Value;

            if (spellStats.LineOfSight && !Pathfinding.BresenhamLine(this, Current.Cell.CellId, Focus.Cell.CellId))
            {
                return(false);
            }
            if (spellStats.LineOnly && !Current.Cell.IsInLine(Focus.Cell, Map.Cells, (Focus as MonsterFighter).Distance))
            {
                return(false);
            }
            return(true);
        }
Example #2
0
        public void ProcessMove()
        {
            var fighter = Current as CharacterFighter;

            var spell = fighter.Spells.First(c => c.Key == 161).Value;

            Map mapa = Account.Character.Map;

            mapa.Pathmaker = new AivyDofus.Model.Maps.Pathmaker(mapa);

            var  possibleCells   = Current.Cell.GetAdjacents(mapa.Cells, Current.Pm);
            Cell cell            = null;
            var  accessibleCells = possibleCells.FirstOrDefault(cellule => Pathfinding.BresenhamLine(this, cellule.CellId, Focus.Cell.CellId) && cellule.IsWalkable);
            var  cellWidthPM     = possibleCells.Where(cellule => Pathfinding.BresenhamLine(this, cellule.CellId, Focus.Cell.CellId) && cellule.GetDistanceBetweenCells(Current.Cell) == Current.Pm && cellule.IsWalkable && isFarTo(cellule));

            if (accessibleCells != null)
            {
                if (cellWidthPM != null)
                {
                    var random = new Random().Next(0, cellWidthPM.Count());
                    cell = cellWidthPM.ToArray()[random];
                }
                else
                {
                    cell = accessibleCells;
                }
            }
            else
            {
                cell = possibleCells.LastOrDefault();
            }
            if (cell != null)
            {
                var nodes       = PathFinder.Instance.GetPath(Account.Character.Map, Current.Cell.CellId, cell.CellId, false);
                var stringnodes = PathFinderUtils.Instance.GetPathfindingString(nodes);
                var pathString  = mapa.Pathmaker.FindPathAsString(Current.Cell.CellId, cell.CellId, false, Current.Pm, Map.Cells.Where(c => (c.IsWalkable)).Select(c => (int)c.CellId).Concat(Fighters.Values.Where(c => c.IsAlive).Select(c => (int)c.Cell.CellId)));
                Current.Cell = cell;
                Account.Send("GA001" + stringnodes);
            }
        }
Example #3
0
        public bool CanTouch(AbstractFighter enemy)
        {
            var fighter = Current as CharacterFighter;

            var spell = fighter.Spells.First(c => c.Key == 161).Value;

            return((Focus as MonsterFighter).Distance <= spell.Stats.First(c => c.Key == spell.Level).Value.RangeMaximum + fighter.Stats.PO.Total && Pathfinding.BresenhamLine(this, Current.Cell.CellId, Focus.Cell.CellId));
        }