private void HandleGameMapMovementMessage(IAccount account, GameMapMovementMessage message) { lock (CheckLock) { var clientMovement = MapMovementAdapter.GetClientMovement(message.KeyMovements.Select(s => (uint)s).ToList()); if (Players.Find(x => x.Id == message.ActorId) != null) { Players.Find(x => x.Id == message.ActorId).CellId = clientMovement.CellEnd.CellId; } if (Entities.Find(x => x.Id == message.ActorId) != null) { Entities.Find(x => x.Id == message.ActorId).CellId = clientMovement.CellEnd.CellId; } if (Monsters.Find(x => x.Id == message.ActorId) != null) { Monsters.Find(x => x.Id == message.ActorId).CellId = clientMovement.CellEnd.CellId; } if (message.ActorId == account.Character.Id) { account.Character.CellId = clientMovement.CellEnd.CellId; } } UpdateMapControl(); OnMapMovement(message); }
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); }
private void HandleGameMapMovementMessage(IAccount account, GameMapMovementMessage message) { // The player has moved. Console.WriteLine($"GameMapMovementMessage[{message.ActorId}]CharacterId[{account.Character.Id}]"); lock (CheckLock) { var clientMovement = MapMovementAdapter.GetClientMovement(message.KeyMovements.Select(s => (uint)s).ToList()); if (message.ActorId == account.Character.Id) { account.Character.CellId = clientMovement.CellEnd.CellId; } else if (Players.Find(x => x.Id == message.ActorId) != null) { Players.Find(x => x.Id == message.ActorId).CellId = clientMovement.CellEnd.CellId; } else if (Entities.Find(x => x.Id == message.ActorId) != null) { Entities.Find(x => x.Id == message.ActorId).CellId = clientMovement.CellEnd.CellId; } else if (Monsters.Find(x => x.Id == message.ActorId) != null) { Monsters.Find(x => x.Id == message.ActorId).CellId = clientMovement.CellEnd.CellId; } //else //Logger.Default.Log($"ActorId[{message.ActorId}] not found"); //Monsters.Add(new MonsterGroup(new GroupMonsterStaticInformations(), message.ActorId, clientMovement.CellEnd.CellId)); } UpdateMapControl(); OnMapMovement(message); }
public static void GameMapMovementMessageTreatment(Message message, byte[] packetDatas, AccountUC account) { GameMapMovementMessage msg = (GameMapMovementMessage)message; using (BigEndianReader reader = new BigEndianReader(packetDatas)) { msg.Deserialize(reader); } List <uint> keys = new List <uint>(); foreach (short s in msg.keyMovements) { keys.Add((uint)s); } MovementPath clientMovement = MapMovementAdapter.GetClientMovement(keys); BlueSheep.Core.Fight.Entity entity = null; foreach (BlueSheep.Core.Fight.Entity en in account.Map.Entities) { if (en.Id == msg.actorId) { entity = en; } } if (entity != null) { (account.Map.Entities[account.Map.Entities.IndexOf(entity)]).CellId = clientMovement.CellEnd.CellId; } //GameRolePlayGroupMonsterInformations e = null; foreach (MonsterGroup en in account.Map.List) { if (en.m_contextualId == msg.actorId) { en.m_cellId = clientMovement.CellEnd.CellId; } } //if (e != null) //{ // account.Map.List.RemoveAt(i); // account.Map.List.Add(new GameRolePlayGroupMonsterInformations(msg.actorId, e.look, new EntityDispositionInformations((short)clientMovement.CellEnd.CellId, e.disposition.direction), e.keyRingBonus, e.hasHardcoreDrop, e.hasAVARewardToken, e.staticInfos, e.ageBonus, e.lootShare, e.alignmentSide)); //} //if (msg.actorId == account.Map.Character.Id) //{ // account.Wait(100, 200); // using (BigEndianWriter writer = new BigEndianWriter()) // { // GameMapMovementConfirmMessage newmsg = new GameMapMovementConfirmMessage(); // newmsg.Serialize(writer); // MessagePackaging pack = new MessagePackaging(writer); // pack.Pack((int)newmsg.ProtocolID); // account.SocketManager.Send(pack.Writer.Content); // } //} // if (account.Fight.flag != 0) // { // account.Fight.LaunchFight(account.Fight.flag); // } //} }
private void HandleGameMapMovementMessage(IAccount account, GameMapMovementMessage message) { if (Account.Character.Status != CharacterStatus.Fighting) { return; } var clientMovement = MapMovementAdapter.GetClientMovement(message.KeyMovements.Select(k => (uint)k).ToList()); var fighter = (Fighter)GetFighter(message.ActorId); if (fighter != null) { fighter.CellId = clientMovement.CellEnd.CellId; } }
public static void GameMapMovementMessageTreatment(Message message, byte[] packetDatas, AccountUC account) { GameMapMovementMessage msg = (GameMapMovementMessage)message; using (BigEndianReader reader = new BigEndianReader(packetDatas)) { msg.Deserialize(reader); } MovementPath clientMovement = MapMovementAdapter.GetClientMovement(msg.keyMovements.Select <short, uint>(k => (uint)k).ToList()); if (account.state == Enums.Status.Fighting) { account.FightData.UpdateFighterCell(msg.actorId, clientMovement.CellEnd.CellId); } }
public void PerformMovement() { if (_path == null || _path.Cells.Count == 0) { OnMovementFinished(false); return; } var keys = MapMovementAdapter.GetServerMovement(_path).Select(f => (short)f).ToList(); _account.Character.Map.MovementFailed += Map_MovementFailed; _account.Character.Map.MapMovement += Map_MapMovement; _account.Network.SendToServer(new GameMapMovementRequestMessage(keys, _account.Character.MapId)); _timeoutTimer.Start(); }
private void HandleGameMapMovementMessage(IAccount account, GameMapMovementMessage message) { lock (CheckLock) { var clientMovement = MapMovementAdapter.GetClientMovement(message.KeyMovements.Select(s => (uint)s).ToList()); var entity = Entities.FirstOrDefault(e => e.Id == message.ActorId); if (entity != null) { ((Entity.Entity)Entities[Entities.IndexOf(entity)]).CellId = clientMovement.CellEnd.CellId; } if (message.ActorId == account.Character.Id) { account.Character.CellId = clientMovement.CellEnd.CellId; } } OnMapMovement(message); }
public static void GameMapMovementMessageTreatment(Message message, byte[] packetDatas, AccountUC account) { GameMapMovementMessage msg = (GameMapMovementMessage)message; using (BigEndianReader reader = new BigEndianReader(packetDatas)) { msg.Deserialize(reader); } MovementPath clientMovement = MapMovementAdapter.GetClientMovement(msg.keyMovements.Select <short, uint>(k => (uint)k).ToList()); if (account.state == Enums.Status.Fighting) { BFighter fighter = account.Fight.GetFighter(msg.actorId); if (fighter != null) { //account.Log(new BotTextInformation("GameMap Ancienne cellid of " + fighter.Id + " = " + fighter.CellId)); fighter.CellId = clientMovement.CellEnd.CellId; //account.Log(new BotTextInformation("GameMap Nouvelle cellid of " + fighter.Id + " = " + fighter.CellId)); } } }
public static void GameMapMovementMessageTreatment(Message message, byte[] packetDatas, AccountUC account) { GameMapMovementMessage msg = (GameMapMovementMessage)message; using (BigEndianReader reader = new BigEndianReader(packetDatas)) { msg.Deserialize(reader); } List <uint> keys = new List <uint>(); foreach (short s in msg.keyMovements) { keys.Add((uint)s); } MovementPath clientMovement = MapMovementAdapter.GetClientMovement(keys); account.MapData.UpdateEntityCell(msg.actorId, clientMovement.CellEnd.CellId); if (account.Map.Moving && msg.actorId == account.MapData.Character.contextualId) { account.Map.ConfirmMove(); } }
public void PerformMovement() { if (_path == null || _path.Cells.Count == 0) { OnMovementFinished(false); return; } else if (StartCell == EndCell) { OnMovementFinished(true); } var keys = MapMovementAdapter.GetServerMovement(_path).Select(f => (short)f).ToList(); _account.Character.Map.MovementFailed += Map_MovementFailed; _account.Character.Map.MapMovement += Map_MapMovement;//it doesnt confirm unfortunatelly. _account.Network.SendToServer(new GameMapMovementRequestMessage(keys, _account.Character.MapId)); if (_timeoutTimer != null) //if null it means it timedout { _timeoutTimer.Start(); } }
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); }
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); }
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); }
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); }