/// <summary> /// Move to the specified cell (Fight). /// </summary> private bool MoveToCell(int cellId) { if (cellId != m_Data.Fighter.CellId) { if (!(m_Data.IsCellWalkable(cellId))) { int num = -1; int num2 = 5000; MapPoint point = new MapPoint(m_Data.Fighter.CellId); MapPoint point2 = new MapPoint(cellId); int direction = 1; while (true) { MapPoint nearestCellInDirection = point2.GetNearestCellInDirection(direction, 1); if (m_Data.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(m_Account.MapData); pathfinder.SetFight(m_Data.Fighters, m_Data.Fighter.MovementPoints); MovementPath path = pathfinder.FindPath(m_Data.Fighter.CellId, cellId); if (path != null) { List<UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path); using (BigEndianWriter writer = new BigEndianWriter()) { GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.ToList().Select<uint, short>(ui => (short)ui).ToArray(), 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.ProtocolID); flag = 0; m_Account.SocketManager.Send(pack.Writer.Content); if (m_Account.DebugMode.Checked) m_Account.Log(new DebugTextInformation("[SND] 950 (GameMapMovementRequestMessage)"), 0); } return true; } } return false; }
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<uint, short>(ui => (short)ui).ToArray(), 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.ProtocolID); 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<uint, short>(ui => (short)ui).ToArray(), 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.ProtocolID); 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; }
public bool MoveToCellWithDistance(int cellId, int maxDistance, bool bool1) { m_Account.ModifBar(6, 0, 0, "Déplacement"); 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); } 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); //m_Account.Wait(3000, 4000); //if (m_Account.StatusLb.Text != "Combat") //{ // 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.ModifBar(6, 0, 0, "Connecté"); } return true; }
public bool MoveToCell(int cellId) { if (m_Account.StatusLb.Text == "Combat" || m_Account.StatusLb.Text == "Fighting") return false; m_Account.ModifBar(6, 0, 0, "Déplacement"); 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; } //if (AutoTimeout) // m_Account.Game.Character.State.SetTimeout(StateEnum.Moving, false, TimeoutMin, TimeoutMax); //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); } 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); //m_Account.Wait(3000, 4000); //if (m_Account.StatusLb.Text != "Combat") //{ // m_Account.Fight.SearchFight(); //} } else { m_Account.SocketManager.Send(pack.Writer.Content); } if (m_Account.Gather != null) m_Account.Gather.Moved = true; m_Account.ModifBar(6, 0, 0, "Connecté"); } return true; }
public 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); } return true; } } return false; }