public bool Move( Direction dir, int speed, BoatMovementSpeed clientSpeed, bool message ) { Map map = Map; if ( map == null || Deleted || CheckDecay() ) return false; int rx = 0, ry = 0; Direction d = (Direction) ( ( (int) m_Facing + (int) dir ) & 0x7 ); Movement.Movement.Offset( d, ref rx, ref ry ); for ( int i = 1; i <= speed; ++i ) { if ( !CanFit( new Point3D( X + ( i * rx ), Y + ( i * ry ), Z ), Map, ItemID ) ) { if ( i == 1 ) { if ( message && m_TillerMan != null ) m_TillerMan.Say( 501424 ); // Ar, we've stopped sir. return false; } speed = i - 1; break; } } int xOffset = speed * rx; int yOffset = speed * ry; int newX = X + xOffset; int newY = Y + yOffset; Rectangle2D[] wrap = ( map == Map.Ilshenar ? m_IlshWrap : m_BritWrap ); for ( int i = 0; i < wrap.Length; ++i ) { Rectangle2D rect = wrap[i]; if ( rect.Contains( new Point2D( X, Y ) ) && !rect.Contains( new Point2D( newX, newY ) ) ) { if ( newX < rect.X ) newX = rect.X + rect.Width - 1; else if ( newX >= rect.X + rect.Width ) newX = rect.X; if ( newY < rect.Y ) newY = rect.Y + rect.Height - 1; else if ( newY >= rect.Y + rect.Height ) newY = rect.Y; for ( int j = 1; j <= speed; ++j ) { if ( !CanFit( new Point3D( newX + ( j * rx ), newY + ( j * ry ), Z ), Map, ItemID ) ) { if ( message && m_TillerMan != null ) m_TillerMan.Say( 501424 ); // Ar, we've stopped sir. return false; } } xOffset = newX - X; yOffset = newY - Y; } } if ( !NewBoatMovement || Math.Abs( xOffset ) > 1 || Math.Abs( yOffset ) > 1 ) Teleport( xOffset, yOffset, 0 ); else TeleportHS( xOffset, yOffset, 0, d, clientSpeed ); return true; }
public void TeleportHS( int xOffset, int yOffset, int zOffset, Direction d, BoatMovementSpeed clientSpeed ) { List<IEntity> toMove = GetMovingEntities(); SafeAdd( m_TillerMan, toMove ); SafeAdd( m_Hold, toMove ); SafeAdd( m_PPlank, toMove ); SafeAdd( m_SPlank, toMove ); // Packet must be sent before actual locations are changed foreach ( GameClient ns in Map.GetClientsInRange( Location, GetMaxUpdateRange() ) ) { Mobile m = ns.Mobile; if ( m.CanSee( this ) && m.InRange( Location, GetUpdateRange( m ) ) ) ns.Send( new SmoothBoatMove( this, toMove, new Point3D( xOffset, yOffset, zOffset ), d, clientSpeed ) ); } foreach ( IEntity e in toMove ) { if ( e is Item ) { Item item = (Item) e; if ( !( item is TillerMan || item is Hold || item is Plank ) ) item.SetLocation( new Point3D( item.X + xOffset, item.Y + yOffset, item.Z ), false ); } else if ( e is Mobile ) { Mobile m = (Mobile) e; m.SetLocation( new Point3D( m.X + xOffset, m.Y + yOffset, m.Z ), false ); } } SetLocation( new Point3D( X + xOffset, Y + yOffset, Z ), false ); }
public bool StartMove( Direction dir, int speed, BoatMovementSpeed clientSpeed, TimeSpan interval, bool single, bool message ) { if ( CheckDecay() ) return false; m_Moving = dir; m_Speed = speed; m_ClientSpeed = clientSpeed; m_Order = BoatOrder.Move; if ( m_MoveTimer != null ) m_MoveTimer.Stop(); m_MoveTimer = new MoveTimer( this, interval, single ); m_MoveTimer.Start(); return true; }
public bool StopMove( bool message ) { if ( CheckDecay() ) return false; if ( m_MoveTimer == null ) { if ( message && m_TillerMan != null ) m_TillerMan.Say( 501443 ); // Er, the ship is not moving sir. return false; } m_Moving = Direction.North; m_Speed = 0; m_ClientSpeed = 0; m_MoveTimer.Stop(); m_MoveTimer = null; if ( message && m_TillerMan != null ) m_TillerMan.Say( 501429 ); // Aye aye sir. return true; }
public SmoothBoatMove( IBoat boat, List<IEntity> entities, Point3D offset, Direction d, BoatMovementSpeed speed ) : base(0xF6) { EnsureCapacity( 18 + entities.Count * 10 ); m_Stream.Write( (int) boat.Serial ); m_Stream.Write( (byte) speed ); m_Stream.Write( (byte) d ); m_Stream.Write( (byte) boat.Facing ); m_Stream.Write( (short) ( boat.X + offset.X ) ); m_Stream.Write( (short) ( boat.Y + offset.Y ) ); m_Stream.Write( (byte) 0xFF ); m_Stream.Write( (sbyte) ( boat.Z + offset.Z ) ); m_Stream.Write( (byte) 0 ); m_Stream.Write( (byte) entities.Count ); for ( int i = 0; i < entities.Count; i++ ) { IEntity entity = entities[i]; m_Stream.Write( (int) entity.Serial ); m_Stream.Write( (short) ( entity.X + offset.X ) ); m_Stream.Write( (short) ( entity.Y + offset.Y ) ); m_Stream.Write( (byte) 0xFF ); m_Stream.Write( (sbyte) ( entity.Z + offset.Z ) ); } }