Esempio n. 1
0
        /**
         * Manage game map movement request
         */
        public async Task GameMapMovement(GameClient client,
                                          GameMapMovementRequestMessage gameMapMovementRequestMessage)
        {
            var map = await this.GetMapById(client.Character.MapId);

            if (map == null)
            {
                client.Send(new GameMapNoMovementMessage());
                return;
            }

            var decompressedKeyMovements =
                this._pathfinderManager.DecompressKeyMovements(map, gameMapMovementRequestMessage.keyMovements);

            if ((gameMapMovementRequestMessage.keyMovements.Length - 1) <= 0 ||
                decompressedKeyMovements.Find(x => !x.IsWalkable()) != null)
            {
                client.Send(new GameMapNoMovementMessage());
                return;
            }

            var paths = await this._pathfinderManager.GetPath(map,
                                                              decompressedKeyMovements[decompressedKeyMovements.Count - 1].Id,
                                                              client.Character.CellId,
                                                              new List <int>(), true, false);


            client.Send(new GameMapMovementMessage(paths, client.Character.Id));
            client.Send(new BasicNoOperationMessage());
            client.Character.CellId = paths[paths.Length - 1];


            //update
            this._characterRepository.UpdateEntity(client.Character.Id, client.Character);
        }
Esempio n. 2
0
        public void GameMapMovementRequestMessageFrame(WorldClient client, GameMapMovementRequestMessage gameMapMovementRequestMessage)
        {
            var map = MapManager.Instance.GetMap(client.ActiveCharacter.MapId);

            Pathfinder pathfinder = new Pathfinder(new int[] { });

            pathfinder.SetMap(map.MapData, true);

            int cellId = MapManager.Instance.GetCellIdFromKeyMovement((int)gameMapMovementRequestMessage.keyMovements[gameMapMovementRequestMessage.keyMovements.Count - 1]);

            if (!pathfinder.IsValidPathfinding(client.ActiveCharacter, gameMapMovementRequestMessage.keyMovements))
            {
                client.SendPacket(new GameMapMovementCancelMessage((uint)cellId));
                return;
            }

            var fight = client.ActiveCharacter.Fight;

            if (fight != null) //si le joueur est dans un fight
            {
                if (fight.ActualFighter is CharacterFighter && fight.ActualFighter.Id == client.ActiveCharacter.Id)
                {
                    fight.MovementRequestSequence(cellId);
                }
            }
            else
            {
                map.SendGameMapMovementMessage(gameMapMovementRequestMessage.keyMovements, client);

                client.ActiveCharacter.CellId = cellId;
                CharacterRepository.Instance.Update(client.ActiveCharacter);
            }
        }
Esempio n. 3
0
        //950 Move
        public static void HandleMove(BigEndianReader reader, WorldClient client, WorldServer server)
        {
            GameMapMovementRequestMessage message = new GameMapMovementRequestMessage();

            message.Unpack(reader);
            client.Send(new GameMapMovementMessage(message.keyMovements, 1));
        }
Esempio n. 4
0
 private bool MoveToCell(int cellId)
 {
     if (cellId != Fighter.CellId)
     {
         if (!(IsCellWalkable(cellId)))
         {
             int      num       = -1;
             int      num2      = 5000;
             MapPoint point     = new MapPoint(Fighter.CellId);
             MapPoint point2    = new MapPoint(cellId);
             int      direction = 1;
             while (true)
             {
                 MapPoint nearestCellInDirection = point2.GetNearestCellInDirection(direction, 1);
                 if (IsCellWalkable(nearestCellInDirection.CellId))
                 {
                     int num4 = point.DistanceToCell(nearestCellInDirection);
                     if (num4 < num2)
                     {
                         num2 = num4;
                         num  = nearestCellInDirection.CellId;
                     }
                 }
                 direction = (direction + 2);
                 if (direction > 7)
                 {
                     if (num == -1)
                     {
                         return(false);
                     }
                     cellId = num;
                     break;
                 }
             }
         }
         SimplePathfinder pathfinder = new SimplePathfinder((BlueSheep.Data.D2p.Map)m_Account.Map.Data);
         pathfinder.SetFight(Fighters, Fighter.MovementPoints);
         MovementPath path = pathfinder.FindPath(Fighter.CellId, cellId);
         if (path != null)
         {
             List <UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path);
             //Account.Network.SendToServer(new GameMapMovementRequestMessage(serverMovement.ToList().Select<uint, short>(ui => (short)ui).ToArray(), Account.Game.Map.Id));
             using (BigEndianWriter writer = new BigEndianWriter())
             {
                 GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.ToList().Select <uint, short>(ui => (short)ui).ToArray(), m_Account.Map.Id);
                 msg.Serialize(writer);
                 writer.Content = m_Account.HumanCheck.hash_function(writer.Content);
                 MessagePackaging pack = new MessagePackaging(writer);
                 pack.Pack((int)msg.ProtocolID);
                 m_Account.SocketManager.Send(pack.Writer.Content);
                 if (m_Account.DebugMode.Checked)
                 {
                     m_Account.Log(new BotTextInformation("[SND] 950 (GameMapMovementRequestMessage)"), 0);
                 }
             }
             return(true);
         }
     }
     return(false);
 }
Esempio n. 5
0
 public static void HandleGameMapMovementRequestMessage(Client client, GameMapMovementRequestMessage message)
 {
     client.Character.CellId    = (short)(message.keyMovements.Last() & 4095);
     client.Character.Direction = (DirectionsEnum)(message.keyMovements.Last() >> 12);
     client.Character.CurrentMap.Send(new GameMapMovementMessage(client.Character.Id, message.keyMovements));
     client.Character.CurrentMap.Send(new GameContextRefreshEntityLookMessage(client.Character.Id, client.Character.EntityLook));
 }
Esempio n. 6
0
        public void Move(short[] keyMouvements, uint mapId)
        {
            mMoving = true;
            GameMapMovementRequestMessage mouvementRequest = new GameMapMovementRequestMessage(keyMouvements, (int)mapId);

            mHost.SendMessage(mouvementRequest);
        }
Esempio n. 7
0
File: Map.cs Progetto: Mixi59/Cookie
        public bool MoveToCell(int cellid, bool changemap = false)
        {
            var pathFinder = new Pathfinder();

            pathFinder.SetMap(_client.Account.Character.MapData, true);
            var timePath =
                pathFinder.GetPath((short)_client.Account.Character.CellId, (short)cellid);
            var path = pathFinder.GetCompressedPath(timePath);

            if (path == null || timePath == null)
            {
                return(false);
            }

            _time = VelocityHelper.GetPathVelocity(timePath,
                                                   path.Length < 4 ? MovementTypeEnum.Walking : MovementTypeEnum.Running);

            if (path[path.Length - 1] == _client.Account.Character.CellId)
            {
                _moving = false;
                _client.Account.Character.Status = CharacterStatus.None;
                ConfirmMove(changemap);
                return(true);
            }

            var msg = new GameMapMovementRequestMessage(path.ToList(), _client.Account.Character.MapId);

            _client.Send(msg);
            ConfirmMove(changemap);
            _client.Account.Character.Status = CharacterStatus.Moving;
            _moving = true;
            return(true);
        }
Esempio n. 8
0
        public static void HandleGameMapMovementRequestMessage(WorldClient client, GameMapMovementRequestMessage message)
        {
            if (!client.Character.CanMove())
            {
                ContextHandler.SendGameMapNoMovementMessage(client);
            }
            Path movementPath = Path.BuildFromCompressedPath(client.Character.Map, message.keyMovements);

            client.Character.StartMove(movementPath);
        }
Esempio n. 9
0
        /**
         * Manage game map movement request
         */
        public async Task GameMapMovement(GameClient client,
                                          GameMapMovementRequestMessage gameMapMovementRequestMessage)
        {
            var map = await this.GetMapById(client.Character.MapId);

            if (map == null)
            {
                client.Send(new GameMapNoMovementMessage());
                return;
            }

            var decompressedKeyMovements =
                this._pathfinderManager.DecompressKeyMovements(map, gameMapMovementRequestMessage.keyMovements);

            if ((gameMapMovementRequestMessage.keyMovements.Length - 1) <= 0 || decompressedKeyMovements.Find(x => x != null && !x.IsWalkable()) != null || decompressedKeyMovements.Find(x => x != null) == null)
            {
                client.Send(new GameMapNoMovementMessage());
                return;
            }

            var paths = await this._pathfinderManager.GetPath(map,
                                                              decompressedKeyMovements[decompressedKeyMovements.Count - 1].Id,
                                                              client.Character.CellId,
                                                              new List <int>(), true, false);


            client.Send(new GameMapMovementMessage(paths, client.Character.Id));
            client.Send(new BasicNoOperationMessage());
            client.Character.CellId = paths[paths.Length - 1];


            //update
            this._characterRepository.UpdateEntity(client.Character.Id, client.Character);
            //if (walk)
            //foreach (var othersClients in Container.Instance().Resolve<IWorldManager>().GetNearestClientsFromCharacter(client.Character))
            //{
            //othersClients.Send(new GameCautiousMapMovementMessage(paths, 0, client.Character.Id));
            //othersClients.Send(new BasicNoOperationMessage());
            //}
            //else
            {
                foreach (var othersClients in Container.Instance().Resolve <IWorldManager>().GetNearestClientsFromCharacter(client.Character))
                {
                    othersClients.Send(new GameMapMovementMessage(paths, client.Character.Id));
                    othersClients.Send(new BasicNoOperationMessage());
                }
            }
            client.Send(new BasicNoOperationMessage());
        }
        public static void HandleGameMapMovementRequestMessage(Bot bot, GameMapMovementRequestMessage message)
        {
            if (!AllowComparer)
            {
                return;
            }

            bot.SendToClient(new DebugClearHighlightCellsMessage());

            var clientPath = Path.BuildFromClientCompressedPath(bot.Character.Map, message.keyMovements);


            var pathfinder = new Pathfinder(bot.Character.Map, bot.Character.Map);
            var botPath    = pathfinder.FindPath(bot.Character.Position.Cell, clientPath.End, true);

            // if you see red cells it means the pathfinder is wrong and don't get the same path as the client
            //bot.SendToClient(new DebugHighlightCellsMessage(Color.Red.ToArgb(), botPath.Cells.Select(entry => entry.Id).ToArray()));
            //bot.SendToClient(new DebugHighlightCellsMessage(Color.Blue.ToArgb(), clientPath.Cells.Select(entry => entry.Id).ToArray()));
        }
Esempio n. 11
0
        public static void HandleGameMapMovementRequestMessage(WorldClient client, GameMapMovementRequestMessage message)
        {
            if (!client.Character.CanMove())
            {
                SendGameMapNoMovementMessage(client, (short)client.Character.Position.Point.X, (short)client.Character.Position.Point.Y);
                return;
            }

            var movementPath = Path.BuildFromCompressedPath(client.Character.Map, message.keyMovements);

            if (message is GameCautiousMapMovementRequestMessage)
            {
                movementPath.SetWalk();
            }

            if (!client.Character.StartMove(movementPath))
            {
                SendGameMapNoMovementMessage(client, (short)client.Character.Position.Point.X, (short)client.Character.Position.Point.Y);
            }
        }
        public void HandleGameMapMovementRequestMessage(Bot bot, GameMapMovementRequestMessage message)
        {
            bot.SendToClient(new DebugClearHighlightCellsMessage());

            var clientPath = Path.BuildFromClientCompressedPath(bot.Character.Map, message.keyMovements);


            var pathfinder   = new Pathfinder(bot.Character.Map, bot.Character.Map);
            var FFpathfinder = new PathFinder(bot.Character.Map, false);
            var stopwatch    = new Stopwatch();

            Path botPath1 = null, botPath2 = null;

            stopwatch.Start();
            for (int i = 0; i < 100; i++)
            {
                botPath1 = pathfinder.FindPath(bot.Character.Cell, clientPath.End, true);
            }
            stopwatch.Stop();

            bot.Character.SendWarning("Dofus-like PathFinder x 100 = {0}", stopwatch.Elapsed.ToString("ss\\.fff"));

            stopwatch.Reset();
            stopwatch.Start();
            for (int i = 0; i < 100; i++)
            {
                botPath2 = ((ISimplePathFinder)FFpathfinder).FindPath(bot.Character.Cell, clientPath.End, true);
            }
            stopwatch.Stop();

            bot.Character.SendWarning("FF PathFinder x 100 = {0}", stopwatch.Elapsed.ToString("ss\\.fff"));
            //botPath2 = new Path(bot.Character.Map, FFpathfinder.GetLastPathUnpacked(0).Select(id => bot.Character.Map.Cells[id]));
            // if you see red cells it means the pathfinder is wrong and don't get the same path as the client

            bot.Character.HighlightCells(botPath1.Cells, Color.Red);
            bot.Character.HighlightCells(clientPath.Cells, Color.Blue);
            bot.Character.HighlightCells(botPath2.Cells, Color.Green);


            message.keyMovements = botPath1.GetClientPathKeys();
        }
Esempio n. 13
0
        public static void HandleMapMovement(GameMapMovementRequestMessage message, WorldClient client)
        {
            sbyte direction = PathParser.GetDirection(message.keyMovements.Last());
            short cellid    = PathParser.ReadCell(message.keyMovements.Last());

            if (client.Character.IsFighting)
            {
                client.Character.FighterInstance.Move(message.keyMovements.ToList(), cellid, direction);
            }
            else
            {
                if (client.Character.Busy)
                {
                    return;
                }
                client.Character.Look.UnsetAura();
                client.Character.RefreshOnMapInstance();
                client.Character.Record.Direction = direction;
                client.Character.MovedCell        = cellid;
                client.Character.SendMap(new GameMapMovementMessage(message.keyMovements, client.Character.Id));
            }
        }
Esempio n. 14
0
        //test tchat
        private void SendTest()
        {
            //  Thread.Sleep(500);
            // bot.Game.World.Tchat.SendMessage("sa m'enerve", Optimus.Common.Enums.ChannelTchatEnum.CHANNEL_GLOBAL);
            Thread.Sleep(500);
            MapManager map        = new MapManager(@"C:\Program Files (x86)\Dofus2\app\content\maps");
            Map        currentMap = map.GetMap(bot.Game.World.MapID);

            Pathfinding.Pathfinding       pathfinder = new Pathfinding.Pathfinding(bot.Game.Character.CellId, 326, currentMap);
            GameMapMovementRequestMessage gmmrm      = new GameMapMovementRequestMessage(pathfinder.GetPath().ToArray(), bot.Game.World.MapID);

            bot.Network.Send(gmmrm);
            if (pathfinder.LenghtPath <= 2)
            {
                Thread.Sleep(450 * pathfinder.LenghtPath);
            }
            else
            {
                Thread.Sleep(200 * pathfinder.LenghtPath);
            }
            bot.Network.Send(new GameMapMovementConfirmMessage());
        }
Esempio n. 15
0
 public static void HandleMapMovementRequest(GameMapMovementRequestMessage message, WorldClient client)
 {
     if (client.Character.Fighting)
     {
         if (client.Character.Fighter.Fight.Started && client.Character.Fighter.IsFighterTurn)
         {
             List <short> path = PathParser.FightMove(PathParser.ReturnDispatchedCells(message.keyMovements)).Keys.ToList();
             path.Insert(0, client.Character.Fighter.CellId);
             client.Character.Fighter.Move(path);
         }
     }
     else
     {
         if (!client.Character.ChangeMap && client.Character.Map.Id == message.mapId && !client.Character.Collecting)
         {
             client.Character.MoveOnMap(message.keyMovements);
         }
         else
         {
             client.Character.NoMove();
         }
     }
 }
Esempio n. 16
0
 public static void HandleMapMovementRequest(GameMapMovementRequestMessage message, WorldClient client)
 {
 }
Esempio n. 17
0
        public bool MoveToCell(int cellId)
        {
            if (m_Account.state == Engine.Enums.Status.Fighting)
            {
                return(false);
            }
            m_Account.SetStatus(Status.Moving);
            MovementPath path = (new Pathfinder(m_Account.MapData)).FindPath(m_Account.MapData.Character.Disposition.CellId, cellId);

            if (path == null)
            {
                return(false);
            }
            List <UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path);

            if (serverMovement[serverMovement.Count - 1] == m_Account.MapData.Character.Disposition.CellId)
            {
                Moving = false;
                ConfirmMove();
                return(true);
            }
            int timetowait;

            if (serverMovement.Count() < 3)
            {
                timetowait = serverMovement.Count() * 500;
            }
            else
            {
                timetowait = serverMovement.Count() * 300;
            }
            m_time = timetowait;
            using (BigEndianWriter writer = new BigEndianWriter())
            {
                GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.Select(ui => (short)ui).ToList(), m_Account.MapData.Id);
                msg.Serialize(writer);
                writer.Content = m_Account.HumanCheck.hash_function(writer.Content);
                MessagePackaging pack = new MessagePackaging(writer);
                pack.Pack((int)msg.MessageID);
                m_Account.SocketManager.Send(pack.Writer.Content);
                Moving = true;
                if (m_Account.DebugMode.Checked)
                {
                    m_Account.Log(new DebugTextInformation("[SND] 950 (GameMapMovementRequestMessage)"), 0);
                }
            }

            //m_Account.Wait(timetowait, timetowait + 100);
            //using (BigEndianWriter writer = new BigEndianWriter())
            //{
            //    GameMapMovementConfirmMessage newmsg = new GameMapMovementConfirmMessage();
            //    newmsg.Serialize(writer);
            //    MessagePackaging pack = new MessagePackaging(writer);
            //    pack.Pack((int)newmsg.ProtocolID);
            //    if (m_Account.Fight != null && m_Account.FightData.IsFollowingGroup && m_Account.FightData.followingGroup.m_cellId == cellId)
            //    {
            //        m_Account.SocketManager.Send(pack.Writer.Content);
            //        if (m_Account.DebugMode.Checked)
            //            m_Account.Log(new DebugTextInformation("[SND] 952 (GameMapMovementConfirmMessage)"), 0);
            //        m_Account.Fight.LaunchFight(m_Account.FightData.followingGroup.m_contextualId);
            //        Thread t = new Thread(new ThreadStart(CheckFight));
            //        t.Start();
            //    }
            //    else if (m_Account.Fight != null && m_Account.FightData.IsFollowingGroup)
            //    {
            //        m_Account.Fight.SearchFight();
            //    }
            //    else if (m_Account.Gather.Id != -1)
            //    {
            //        m_Account.SocketManager.Send(pack.Writer.Content);
            //        if (m_Account.DebugMode.Checked)
            //            m_Account.Log(new DebugTextInformation("[SND] 952 (GameMapMovementConfirmMessage)"), 0);
            //        //UseElement(m_Account.Gather.Id, m_Account.Gather.SkillInstanceUid);
            //        int distance = m_Account.Gather.GetRessourceDistance(m_Account.Gather.Id);
            //        m_Account.Log(new DebugTextInformation("[Gather] New distance from element " + m_Account.Gather.Id + " = " + distance), 0);
            //        if (distance <= m_Account.Inventory.WeaponRange)
            //        {
            //            UseElement(m_Account.Gather.Id, m_Account.Gather.SkillInstanceUid);
            //            m_Account.SetStatus(Status.Gathering);
            //        }
            //        else if (m_Account.Path != null)
            //            m_Account.Path.PerformFlag();
            //        else
            //            m_Account.PerformGather();
            //    }
            //    else
            //    {
            //        m_Account.SocketManager.Send(pack.Writer.Content);
            //        if (m_Account.DebugMode.Checked)
            //            m_Account.Log(new DebugTextInformation("[SND] 952 (GameMapMovementConfirmMessage)"), 0);
            //    }
            //    m_Account.SetStatus(Status.None);
            //}

            return(true);
        }
Esempio n. 18
0
        public bool MoveToCellWithDistance(int cellId, int maxDistance, bool bool1)
        {
            MovementPath path           = null;
            int          savDistance    = -1;
            MapPoint     characterPoint = new MapPoint(m_Account.MapData.Character.Disposition.CellId);
            MapPoint     targetPoint    = new MapPoint(cellId);

            foreach (MapPoint point in m_Account.MapData.GetListPointAtGoodDistance(characterPoint, targetPoint, maxDistance))
            {
                Pathfinder pathFinding = null;
                if ((targetPoint.DistanceToCell(point) > maxDistance) || ((targetPoint.X != point.X) && (targetPoint.Y != point.Y)))
                {
                    continue;
                }
                int distance = characterPoint.DistanceTo(point);
                if ((savDistance != -1) && (distance >= savDistance))
                {
                    continue;
                }
                if (bool1)
                {
                    if (m_Account.MapData.Data.IsWalkable(point.CellId))
                    {
                        goto Label_00A8;
                    }
                    continue;
                }
                if (!(m_Account.MapData.NothingOnCell(point.CellId)))
                {
                    continue;
                }
Label_00A8:
                pathFinding = new Pathfinder(m_Account.MapData);
                MovementPath path2 = pathFinding.FindPath(m_Account.MapData.Character.Disposition.CellId, point.CellId);
                if (path2 != null)
                {
                    path        = path2;
                    savDistance = distance;
                }
            }
            if (path == null)
            {
                return(false);
            }
            List <UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path);

            if (serverMovement[serverMovement.Count - 1] == m_Account.MapData.Character.Disposition.CellId)
            {
                Moving = false;
                ConfirmMove();
                return(true);
            }
            int timetowait;

            if (serverMovement.Count() < 3)
            {
                timetowait = serverMovement.Count() * 514;
            }
            else
            {
                timetowait = serverMovement.Count() * 320;
            }
            m_time = timetowait;
            using (BigEndianWriter writer = new BigEndianWriter())
            {
                GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.Select(ui => (short)ui).ToList(), m_Account.MapData.Id);
                msg.Serialize(writer);
                writer.Content = m_Account.HumanCheck.hash_function(writer.Content);
                MessagePackaging pack = new MessagePackaging(writer);
                pack.Pack((int)msg.MessageID);
                m_Account.SocketManager.Send(pack.Writer.Content);
                m_Account.SetStatus(Status.Moving);
                Moving = true;
                if (m_Account.DebugMode.Checked)
                {
                    m_Account.Log(new DebugTextInformation("[SND] 950 (GameMapMovementRequestMessage)"), 0);
                }
            }
            return(true);
        }
Esempio n. 19
0
 public void GameMapMovementRequestMessage(GameClient client, GameMapMovementRequestMessage gameMapMovementRequestMessage)
 {
     Container.Instance().Resolve <IMapManager>().GameMapMovement(client, gameMapMovementRequestMessage);
 }
Esempio n. 20
0
        public bool MoveToCellWithDistance(int cellId, int maxDistance, bool bool1)
        {
            m_Account.SetStatus(Status.Moving);
            MovementPath path           = null;
            int          savDistance    = -1;
            MapPoint     characterPoint = new MapPoint(Character.CellId);
            MapPoint     targetPoint    = new MapPoint(cellId);

            foreach (MapPoint point in GetListPointAtGoodDistance(characterPoint, targetPoint, maxDistance))
            {
                Pathfinder pathFinding = null;
                if ((targetPoint.DistanceToCell(point) > maxDistance) || ((targetPoint.X != point.X) && (targetPoint.Y != point.Y)))
                {
                    continue;
                }
                int distance = characterPoint.DistanceTo(point);
                if ((savDistance != -1) && (distance >= savDistance))
                {
                    continue;
                }
                if (bool1)
                {
                    if (Data.IsWalkable(point.CellId))
                    {
                        goto Label_00A8;
                    }
                    continue;
                }
                if (!(NothingOnCell(point.CellId)))
                {
                    continue;
                }
Label_00A8:
                pathFinding = new Pathfinder(m_Account.Map.Data, m_Account.Map);
                MovementPath path2 = pathFinding.FindPath(Character.CellId, point.CellId);
                if (path2 != null)
                {
                    path        = path2;
                    savDistance = distance;
                }
            }
            if (path == null)
            {
                return(false);
            }
            //if (AutoTimeout)
            //    m_Account.Game.Character.State.SetTimeout(StateEnum.Moving, false, TimeoutMin, TimeoutMax);
            List <UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path);
            int           timetowait;

            if (serverMovement.Count() < 3)
            {
                timetowait = serverMovement.Count() * 500;
            }
            else
            {
                timetowait = serverMovement.Count() * 300;
            }
            //m_Account.Network.SendToServer(new GameMapMovementRequestMessage(serverMovement.Select<uint, short>(ui => (short)ui).ToArray(), Id));
            using (BigEndianWriter writer = new BigEndianWriter())
            {
                GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.Select <uint, short>(ui => (short)ui).ToArray(), Id);
                msg.Serialize(writer);
                writer.Content = m_Account.HumanCheck.hash_function(writer.Content);
                MessagePackaging pack = new MessagePackaging(writer);
                pack.Pack((int)msg.ProtocolID);
                m_Account.SocketManager.Send(pack.Writer.Content);
                if (m_Account.DebugMode.Checked)
                {
                    m_Account.Log(new BotTextInformation("[SND] 950 (GameMapMovementRequestMessage)"), 0);
                }
            }
            m_Account.Wait(timetowait, timetowait + 100);
            using (BigEndianWriter writer = new BigEndianWriter())
            {
                GameMapMovementConfirmMessage newmsg = new GameMapMovementConfirmMessage();
                newmsg.Serialize(writer);
                MessagePackaging pack = new MessagePackaging(writer);
                pack.Pack((int)newmsg.ProtocolID);
                if (m_Account.Fight != null && m_Account.Fight.IsFollowingGroup() && m_Account.Fight.followinggroup.m_cellId == cellId)
                {
                    m_Account.SocketManager.Send(pack.Writer.Content);
                    m_Account.Fight.LaunchFight(m_Account.Fight.followinggroup.m_contextualId);
                    //m_Account.Wait(3000, 4000);
                    //if (m_Account.StatusLb.Text != "Combat")
                    //{
                    //    m_Account.Fight.SearchFight();
                    //}
                }
                else if (m_Account.Fight != null && m_Account.Fight.IsFollowingGroup())
                {
                    m_Account.Fight.SearchFight();
                }
                else if (m_Account.Gather.Id != -1)
                {
                    m_Account.SocketManager.Send(pack.Writer.Content);
                    UseElement(m_Account.Gather.Id, m_Account.Gather.SkillInstanceUid);
                }
                else
                {
                    m_Account.SocketManager.Send(pack.Writer.Content);
                }
                m_Account.SetStatus(Status.None);
            }
            return(true);
        }
Esempio n. 21
0
 private void HandleCharacterCharacteristicsInformations(GameMapMovementRequestMessage message, ConnectedHost source)
 {
     //  source.logger.Log("moving");
     source.Bot.BotState = Enums.BotStatsEnum.MOVING;
 }
Esempio n. 22
0
        public bool MoveToCell(int cellId)
        {
            if (m_Account.state == Engine.Enums.Status.Fighting)
            {
                return(false);
            }
            m_Account.SetStatus(Status.Moving);
            MovementPath path = (new Pathfinder(m_Account.Map.Data, m_Account.Map)).FindPath(Character.CellId, cellId);

            if (path == null)
            {
                return(false);
            }
            List <UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path);
            int           timetowait;

            if (serverMovement.Count() < 3)
            {
                timetowait = serverMovement.Count() * 500;
            }
            else
            {
                timetowait = serverMovement.Count() * 300;
            }
            using (BigEndianWriter writer = new BigEndianWriter())
            {
                GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.Select <uint, short>(ui => (short)ui).ToArray(), Id);
                msg.Serialize(writer);
                writer.Content = m_Account.HumanCheck.hash_function(writer.Content);
                MessagePackaging pack = new MessagePackaging(writer);
                pack.Pack((int)msg.ProtocolID);
                m_Account.SocketManager.Send(pack.Writer.Content);
                if (m_Account.DebugMode.Checked)
                {
                    m_Account.Log(new BotTextInformation("[SND] 950 (GameMapMovementRequestMessage)"), 0);
                }
            }
            m_Account.Wait(timetowait, timetowait + 100);
            using (BigEndianWriter writer = new BigEndianWriter())
            {
                GameMapMovementConfirmMessage newmsg = new GameMapMovementConfirmMessage();
                newmsg.Serialize(writer);
                MessagePackaging pack = new MessagePackaging(writer);
                pack.Pack((int)newmsg.ProtocolID);
                if (m_Account.Fight != null && m_Account.Fight.IsFollowingGroup())
                {
                    m_Account.SocketManager.Send(pack.Writer.Content);
                    m_Account.Fight.LaunchFight(m_Account.Fight.followinggroup.m_contextualId);
                }
                else
                {
                    m_Account.SocketManager.Send(pack.Writer.Content);
                }
                if (m_Account.Gather != null)
                {
                    m_Account.Gather.Moved = true;
                }
                m_Account.SetStatus(Status.None);
            }

            return(true);
        }