public override void OnResponse(NetState sender, RelayInfo info)
        {
            BaseBoat  boat = BaseBoat.FindBoatAt(m_From, m_From.Map);
            Container pack = m_From.Backpack;

            if (boat == null)
            {
                return;
            }
            if (pack != null)               // && pack.ConsumeTotal( typeof( Gold ), 2 ) )
            {
                switch (info.ButtonID)
                {
                case 1:                 // Drop Anchor
                {
                    boat.LowerAnchor(true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 2:                 // Raise Anchor
                {
                    boat.RaiseAnchor(true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 3:                 // Forward
                {
                    boat.StartMove(Direction.North, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 4:                 // Back
                {
                    boat.StartMove(Direction.South, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 5:                 // Left
                {
                    boat.StartMove(Direction.West, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 6:                 // Right
                {
                    boat.StartMove(Direction.East, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 7:                 // Stop
                {
                    boat.StopMove(true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 8:                 // TurnLeft
                {
                    boat.StartTurn(-2, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 9:                 // TurnRight
                {
                    boat.StartTurn(2, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 10:                 // OneForward
                {
                    boat.OneMove(Direction.North);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 11:                 // OneBack
                {
                    boat.OneMove(Direction.South);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 12:                 // OneLeft
                {
                    boat.OneMove(Direction.West);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 13:                 // OneRight
                {
                    boat.OneMove(Direction.East);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 14:                 // LeftForward
                {
                    boat.StartMove(Direction.Up, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }

                case 15:                 // RightForward
                {
                    boat.StartMove(Direction.Right, true);
                    m_From.SendGump(new NavigationGump((PlayerMobile)m_From));
                    break;
                }
                }
            }
        }
Beispiel #2
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Boat == null || m_From == null)
            {
                return;
            }

            if (!m_Boat.Contains(m_From))
            {
                if (BaseBoat.isCarpet(m_Boat))
                {
                    m_From.SendMessage("You have to be on your carpet to do that!");
                }
                else
                {
                    m_From.SendMessage("You have to be on the boat to do that!");
                }
                m_From.CloseGump(typeof(TillerManGump));
                return;
            }

            switch (info.ButtonID)
            {
            case 100: m_Boat.StopMove(true); break;

            case 99: m_Boat.BeginRename(m_From); break;

            case 1:                     // N
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.North, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.North);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.South, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.South);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.West, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.West);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.East, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.East);
                    }
                }
                break;
            }

            case 2:                     // NE
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Right, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Right);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Left, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Left);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Up, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Up);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Down, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Down);
                    }
                }
                break;
            }

            case 3:                     // E
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.East, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.East);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.West, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.West);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.North, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.North);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.South, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.South);
                    }
                }
                break;
            }

            case 4:                     // SE
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Down, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Down);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Up, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Up);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Right, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Right);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Left, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Left);
                    }
                }
                break;
            }

            case 5:                     // S
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.South, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.South);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.North, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.North);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.East, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.East);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.West, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.West);
                    }
                }
                break;
            }

            case 6:                     // SW
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Left, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Left);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Right, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Right);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Down, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Down);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Up, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Up);
                    }
                }
                break;
            }

            case 7:                     // W
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.West, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.West);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.East, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.East);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.South, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.South);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.North, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.North);
                    }
                }
                break;
            }

            case 8:                     // NW
            {
                if (m_Boat.Facing == Direction.North)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Up, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Up);
                    }
                }
                else if (m_Boat.Facing == Direction.South)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Down, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Down);
                    }
                }
                else if (m_Boat.Facing == Direction.East)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Left, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Left);
                    }
                }
                else if (m_Boat.Facing == Direction.West)
                {
                    if (!ToggleOneStep)
                    {
                        m_Boat.StartMove(Direction.Right, true);
                    }
                    else
                    {
                        m_Boat.OneMove(Direction.Right);
                    }
                }
                break;
            }

            case 9:                     // TOGGLE ONE STEP
            {
                if (!ToggleOneStep)
                {
                    ToggleOneStep = true;
                }
                else
                {
                    ToggleOneStep = false;
                }
                break;
            }

            case 10:                            // RAISE / DROP ANCHOR
            {
                if (m_Boat.Anchored)
                {
                    m_Boat.RaiseAnchor(true);
                }
                else
                {
                    m_Boat.LowerAnchor(true);
                }
                break;
            }

            case 11:                            // TURN LEFT/RIGHT/AROUND
            {
                m_Boat.StartTurn(-2, true);     // LEFT
                break;
            }

            case 12:
            {
                m_Boat.StartTurn(2, true);                              // RIGHT
                break;
            }

            case 13:
            {
                m_Boat.StartTurn(-4, true);                             // AROUND
                break;
            }
            }

            m_From.CloseGump(typeof(TillerManGump));
            m_From.SendGump(new TillerManGump(m_From, m_Boat, ToggleOneStep));
        }
Beispiel #3
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Player == null)
            {
                return;
            }

            BaseBoat m_Boat = m_Player.BoatOccupied;

            if (m_Boat != null)
            {
                if (m_Boat.Deleted || m_Boat.m_SinkTimer != null)
                {
                    m_Boat = null;
                }
            }

            bool closeGump = true;

            int minorActionCount = 0;
            int epicActionCount  = 0;

            int currentMovementMode;
            int movementModeCount = Enum.GetNames(typeof(MovementMode)).Length;

            int currentShipAction;
            int shipActionCount = Enum.GetNames(typeof(ShipAction)).Length;

            switch (info.ButtonID)
            {
            //Forward
            case 1:
                if (m_Boat != null)
                {
                    if (m_Player.m_ShipControlSettings.m_MovementMode == MovementMode.Full)
                    {
                        BaseBoat.StartMoveForward(m_Player);
                    }

                    else
                    {
                        BaseBoat.OneMoveForward(m_Player);
                    }
                }

                closeGump = false;
                break;

            //Forward Right
            case 2:
                if (m_Boat != null)
                {
                    if (m_Player.m_ShipControlSettings.m_MovementMode == MovementMode.Full)
                    {
                        BaseBoat.StartMoveForwardRight(m_Player);
                    }

                    else
                    {
                        BaseBoat.OneMoveForwardRight(m_Player);
                    }
                }

                closeGump = false;
                break;

            //Right
            case 3:
                if (m_Boat != null)
                {
                    if (m_Player.m_ShipControlSettings.m_MovementMode == MovementMode.Full)
                    {
                        BaseBoat.StartMoveRight(m_Player);
                    }

                    else
                    {
                        BaseBoat.OneMoveRight(m_Player);
                    }
                }

                closeGump = false;
                break;

            //Backwards Right
            case 4:
                if (m_Boat != null)
                {
                    if (m_Player.m_ShipControlSettings.m_MovementMode == MovementMode.Full)
                    {
                        BaseBoat.StartMoveBackwardRight(m_Player);
                    }

                    else
                    {
                        BaseBoat.OneMoveBackwardRight(m_Player);
                    }
                }

                closeGump = false;
                break;

            //Backward
            case 5:
                if (m_Boat != null)
                {
                    if (m_Player.m_ShipControlSettings.m_MovementMode == MovementMode.Full)
                    {
                        BaseBoat.StartMoveBackward(m_Player);
                    }

                    else
                    {
                        BaseBoat.OneMoveBackward(m_Player);
                    }
                }

                closeGump = false;
                break;

            //Backwards Left
            case 6:
                if (m_Boat != null)
                {
                    if (m_Player.m_ShipControlSettings.m_MovementMode == MovementMode.Full)
                    {
                        BaseBoat.StartMoveBackwardLeft(m_Player);
                    }

                    else
                    {
                        BaseBoat.OneMoveBackwardLeft(m_Player);
                    }
                }

                closeGump = false;
                break;

            //Left
            case 7:
                if (m_Boat != null)
                {
                    if (m_Player.m_ShipControlSettings.m_MovementMode == MovementMode.Full)
                    {
                        BaseBoat.StartMoveLeft(m_Player);
                    }

                    else
                    {
                        BaseBoat.OneMoveLeft(m_Player);
                    }
                }

                closeGump = false;
                break;

            //Forward Left
            case 8:
                if (m_Boat != null)
                {
                    if (m_Player.m_ShipControlSettings.m_MovementMode == MovementMode.Full)
                    {
                        BaseBoat.StartMoveForwardLeft(m_Player);
                    }

                    else
                    {
                        BaseBoat.OneMoveForwardLeft(m_Player);
                    }
                }

                closeGump = false;
                break;

            //Turn Left
            case 9:
                if (m_Boat != null)
                {
                    BaseBoat.StartTurnLeft(m_Player);
                }

                closeGump = false;
                break;

            //Stop
            case 10:
                if (m_Boat != null)
                {
                    BaseBoat.Stop(m_Player);
                }

                closeGump = false;
                break;

            //Turn Right
            case 11:
                if (m_Boat != null)
                {
                    BaseBoat.StartTurnRight(m_Player);
                }

                closeGump = false;
                break;

            //Previous Movement Mode
            case 12:
                currentMovementMode = (int)m_Player.m_ShipControlSettings.m_MovementMode;
                currentMovementMode--;

                if (currentMovementMode < 0)
                {
                    currentMovementMode = movementModeCount - 1;
                }

                m_Player.m_ShipControlSettings.m_MovementMode = (MovementMode)currentMovementMode;

                closeGump = false;
                break;

            //Next Movement Mode
            case 13:
                currentMovementMode = (int)m_Player.m_ShipControlSettings.m_MovementMode;
                currentMovementMode++;

                if (currentMovementMode > movementModeCount - 1)
                {
                    currentMovementMode = 0;
                }

                m_Player.m_ShipControlSettings.m_MovementMode = (MovementMode)currentMovementMode;

                closeGump = false;
                break;

            //Previous Ship Action
            case 14:
                currentShipAction = (int)m_Player.m_ShipControlSettings.m_ShipAction;
                currentShipAction--;

                if (currentShipAction < 0)
                {
                    currentShipAction = shipActionCount - 1;
                }

                m_Player.m_ShipControlSettings.m_ShipAction = (ShipAction)currentShipAction;

                closeGump = false;
                break;

            //Next Ship Action
            case 15:
                currentShipAction = (int)m_Player.m_ShipControlSettings.m_ShipAction;
                currentShipAction++;

                if (currentShipAction > shipActionCount - 1)
                {
                    currentShipAction = 0;
                }

                m_Player.m_ShipControlSettings.m_ShipAction = (ShipAction)currentShipAction;

                closeGump = false;
                break;

            //Activate Ship Action
            case 16:
                switch (m_Player.m_ShipControlSettings.m_ShipAction)
                {
                case ShipAction.RaiseAnchor:
                    if (m_Boat != null)
                    {
                        if (m_Boat.IsCoOwner(m_Player) || m_Boat.IsOwner(m_Player))
                        {
                            BaseBoat.RaiseAnchor(m_Player);
                        }
                    }
                    break;

                case ShipAction.LowerAnchor:
                    if (m_Boat != null)
                    {
                        if (m_Boat.IsCoOwner(m_Player) || m_Boat.IsOwner(m_Player))
                        {
                            BaseBoat.LowerAnchor(m_Player);
                        }
                    }
                    break;

                case ShipAction.Embark:
                    BaseBoat.TargetedEmbark(m_Player);
                    break;

                case ShipAction.EmbarkFollowers:
                    BaseBoat.TargetedEmbarkFollowers(m_Player);
                    break;

                case ShipAction.Disembark:
                    if (m_Boat != null)
                    {
                        m_Boat.Disembark(m_Player);
                    }
                    break;

                case ShipAction.DisembarkFollowers:
                    if (m_Boat != null)
                    {
                        m_Boat.DisembarkFollowers(m_Player);
                    }
                    break;

                case ShipAction.Dock:
                    if (m_Boat != null)
                    {
                        if (m_Boat.IsOwner(m_Player))
                        {
                            m_Boat.BeginDryDock(m_Player);
                        }
                    }
                    break;

                case ShipAction.ClearDeck:
                    //TEST: Finish
                    break;

                case ShipAction.DividePlunder:
                    if (m_Boat != null)
                    {
                        if (m_Boat.IsOwner(m_Player))
                        {
                            m_Boat.BeginDivideThePlunder(m_Player);
                        }
                    }
                    break;

                case ShipAction.AddFriend:
                    if (m_Boat != null)
                    {
                        m_Boat.AddFriendCommand(m_Player);
                    }
                    break;

                case ShipAction.AddCoOwner:
                    if (m_Boat != null)
                    {
                        m_Boat.AddCoOwnerCommand(m_Player);
                    }
                    break;

                case ShipAction.ThrowTargetOverboard:
                    if (m_Boat != null)
                    {
                        m_Boat.ThrowOverboardCommand(m_Player);
                    }
                    break;
                }

                closeGump = false;
                break;

            //Fire Left Cannons
            case 17:
                if (m_Boat != null)
                {
                    if (m_Boat.IsCoOwner(m_Player) || m_Boat.IsOwner(m_Player))
                    {
                        BaseBoat.FireCannons(m_Player, true);
                    }
                }

                closeGump = false;
                break;

            //Fire Right Cannons
            case 18:
                if (m_Boat != null)
                {
                    if (m_Boat.IsCoOwner(m_Player) || m_Boat.IsOwner(m_Player))
                    {
                        BaseBoat.FireCannons(m_Player, false);
                    }
                }

                closeGump = false;
                break;

            //Targeting Mode: Previous
            case 19:
                if (m_Boat != null)
                {
                    if (m_Boat.IsCoOwner(m_Player) || m_Boat.IsOwner(m_Player))
                    {
                        switch (m_Boat.TargetingMode)
                        {
                        case TargetingMode.Random: m_Boat.SetTargetingMode(TargetingMode.Guns); break;

                        case TargetingMode.Hull: m_Boat.SetTargetingMode(TargetingMode.Random); break;

                        case TargetingMode.Sails: m_Boat.SetTargetingMode(TargetingMode.Hull); break;

                        case TargetingMode.Guns: m_Boat.SetTargetingMode(TargetingMode.Sails); break;
                        }
                    }
                }

                closeGump = false;
                break;

            //Targeting Mode: Next
            case 20:
                if (m_Boat != null)
                {
                    if (m_Boat.IsCoOwner(m_Player) || m_Boat.IsOwner(m_Player))
                    {
                        switch (m_Boat.TargetingMode)
                        {
                        case TargetingMode.Random: m_Boat.SetTargetingMode(TargetingMode.Hull); break;

                        case TargetingMode.Hull: m_Boat.SetTargetingMode(TargetingMode.Sails); break;

                        case TargetingMode.Sails: m_Boat.SetTargetingMode(TargetingMode.Guns); break;

                        case TargetingMode.Guns: m_Boat.SetTargetingMode(TargetingMode.Random); break;
                        }
                    }
                }

                closeGump = false;
                break;

            //Minor Ability: Previous
            case 21:
                if (m_Boat != null)
                {
                }

                closeGump = false;
                break;

            //Minor Ability: Next
            case 22:
                if (m_Boat != null)
                {
                }

                closeGump = false;
                break;

            //Minor Ability: Activate
            case 23:
                if (m_Boat != null)
                {
                }

                closeGump = false;
                break;

            //Epic Ability: Previous
            case 24:
                if (m_Boat != null)
                {
                }

                closeGump = false;
                break;

            //Epic Ability: Next
            case 25:
                if (m_Boat != null)
                {
                }

                closeGump = false;
                break;

            //Epic Ability: Activate
            case 26:
                if (m_Boat != null)
                {
                }

                closeGump = false;
                break;

            //Collapse + Expand
            case 27:
                m_Player.m_ShipControlSettings.m_CollapseMode = !m_Player.m_ShipControlSettings.m_CollapseMode;

                closeGump = false;
                break;

            //Ship Selection
            case 28:
                BaseBoat.ShipSelection(m_Player);

                closeGump = false;
                break;
            }

            if (!closeGump)
            {
                m_Player.CloseGump(typeof(BoatHotbarGump));
                m_Player.SendGump(new BoatHotbarGump(m_Player));
            }
        }
        public static void SailBoat(Mobile from, BaseBoat boat)
        {
            bool newsail = true;

            if (m_SailTime.ContainsKey(from))
            {
                if (m_SailTime[from] >= DateTime.Now)
                {
                    newsail = false;
                }
                else
                {
                    m_SailTime.Remove(from);
                }
            }

            if (newsail)
            {
                int MinLevel = 10;
                int MaxLevel = 100;
                //if (Core.Debug) from.SendMessage("TEST: SAILING IN A BOAT");

                Mobile sailor = from;

                LokaiSkills skils = LokaiSkillUtilities.XMLGetSkills(sailor);

                List <Mobile> crew = GetMobilesOn(boat);

                SuccessRating rating = SuccessRating.LokaiSkillNotEnabled;

                foreach (Mobile seaman in crew)
                {
                    skils = LokaiSkillUtilities.XMLGetSkills(sailor);

                    LokaiSkills seamanAbs = LokaiSkillUtilities.XMLGetSkills(seaman);
                    if (seamanAbs.Sailing.Value > skils.Sailing.Value)
                    {
                        sailor = seaman;
                    }
                    MinLevel--;
                    MaxLevel--;
                    if ((MinLevel == 5 && (boat is SmallBoat || boat is SmallDragonBoat)) ||
                        (MinLevel == 0 && (boat is MediumBoat || boat is MediumDragonBoat)) ||
                        (MinLevel == -5 && (boat is LargeBoat || boat is LargeDragonBoat)))
                    {
                        break;
                    }
                }

                int count = 0;
                foreach (Mobile seaman in crew)
                {
                    if ((count == 5 && (boat is SmallBoat || boat is SmallDragonBoat)) ||
                        (count == 10 && (boat is MediumBoat || boat is MediumDragonBoat)) ||
                        (count == 15 && (boat is LargeBoat || boat is LargeDragonBoat)))
                    {
                        break;
                    }
                    else
                    {
                        count++;
                        skils = LokaiSkillUtilities.XMLGetSkills(seaman);
                        if (seaman != sailor)
                        {
                            rating = LokaiSkillUtilities.CheckLokaiSkill(seaman, skils.Sailing, MinLevel, MaxLevel);
                            if (rating >= SuccessRating.PartialSuccess)
                            {
                                seaman.SendMessage("You did your part.");
                            }
                            else
                            {
                                seaman.SendMessage("You could have been more helpful.");
                            }
                        }
                    }
                }

                skils = LokaiSkillUtilities.XMLGetSkills(sailor);

                rating = LokaiSkillUtilities.CheckLokaiSkill(sailor, skils.Sailing, MinLevel, MaxLevel);
                if (rating <= SuccessRating.Failure)
                {
                    int severity = 25;
                    if (rating == SuccessRating.HazzardousFailure)
                    {
                        severity += 4;
                    }
                    else if (rating == SuccessRating.CriticalFailure)
                    {
                        severity += 8;
                    }

                    bool crash = false;

                    foreach (Mobile seaman in crew)
                    {
                        if (!m_SailTime.ContainsKey(seaman))
                        {
                            m_SailTime.Add(seaman, DateTime.Now.AddSeconds(FAILSECONDS));
                        }
                    }

                    switch (Utility.Random(severity))
                    {
                    case 0:
                    case 1:
                    case 2: boat.StartMove(Direction.Down, true); goto case 24;

                    case 3:
                    case 4:
                    case 5: boat.StartMove(Direction.East, true); goto case 24;

                    case 6:
                    case 7:
                    case 8: boat.StartMove(Direction.Left, true); goto case 24;

                    case 9:
                    case 10:
                    case 11: boat.StartMove(Direction.North, true); goto case 24;

                    case 12:
                    case 13:
                    case 14: boat.StartMove(Direction.Right, true); goto case 24;

                    case 15:
                    case 16:
                    case 17: boat.StartMove(Direction.South, true); goto case 24;

                    case 18:
                    case 19:
                    case 20: boat.StartMove(Direction.Up, true); goto case 24;

                    case 21:
                    case 22:
                    case 23: boat.StartMove(Direction.West, true); goto case 24;

                    case 24: boat.StartTurn(Utility.RandomList(2, -2, -4), false); goto case 99;

                    case 99:
                    {
                        foreach (Mobile mobile in crew)
                        {
                            MightGetSick(mobile);
                        }
                        break;
                    }

                    default: crash = true; break;
                    }

                    if (crash)
                    {
                        boat.LowerAnchor(false);
                        List <Item> items = CheckForItems(boat);

                        BaseDockedBoat dboat = boat.DockedBoat;

                        foreach (Mobile seaman in crew)
                        {
                            seaman.SendMessage("The boat runs aground at some nearby land.");
                            boat.RemoveKeys(seaman);
                            if (seaman == boat.Owner)
                            {
                                if (dboat != null)
                                {
                                    seaman.AddToBackpack(dboat);
                                }
                            }
                        }

                        boat.Delete();

                        foreach (Mobile seaman in crew)
                        {
                            Strand(seaman);
                        }
                        if (items.Count > 0)
                        {
                            for (int v = 0; v < items.Count; v++)
                            {
                                int x = from.X + Utility.Random(7) - 3;
                                int y = from.Y + Utility.Random(7) - 3;
                                items[v].MoveToWorld(new Point3D(x, y, from.Z));
                            }
                        }
                    }
                    else
                    {
                        foreach (Mobile seaman in crew)
                        {
                            seaman.SendMessage("You go off course slightly.");
                        }
                    }
                }
                else
                {
                    //if (Core.Debug) from.SendMessage("TEST: SAILING SUCCESSFUL.");

                    foreach (Mobile seaman in crew)
                    {
                        seaman.SendMessage("You feel the gentle breeze of the open sea.");
                        if (!m_SailTime.ContainsKey(seaman))
                        {
                            m_SailTime.Add(seaman, DateTime.Now.AddSeconds(SAILSECONDS));
                        }
                    }
                }
            }
        }
Beispiel #5
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            BaseBoat boat = BaseBoat.FindBoatAt(m_From, m_From.Map);

            if (boat == null)
            {
                return;
            }

            switch (info.ButtonID)
            {
            case 1:     // Drop Anchor
                boat.LowerAnchor(true);
                m_From.SendGump(new BoatGump((PlayerMobile)m_From));
                break;

            case 2:     // Raise Anchor
                boat.RaiseAnchor(true);
                m_From.SendGump(new BoatGump((PlayerMobile)m_From));
                break;

            case 3:     // Forward
                boat.StartMove(Direction.North, true);
                m_From.SendGump(new BoatGump((PlayerMobile)m_From));
                break;

            case 4:     // Back
                boat.StartMove(Direction.South, true);
                m_From.SendGump(new BoatGump((PlayerMobile)m_From));
                break;

            case 5:     // Left
                boat.StartMove(Direction.West, true);
                m_From.SendGump(new BoatGump((PlayerMobile)m_From));
                break;

            case 6:     // Right
                boat.StartMove(Direction.East, true);
                m_From.SendGump(new BoatGump((PlayerMobile)m_From));
                break;

            case 7:     // Stop
                boat.StopMove(true);
                m_From.SendGump(new BoatGump((PlayerMobile)m_From));
                break;

            case 8:     // TurnLeft
                boat.StartTurn(-2, true);
                m_From.SendGump(new BoatGump((PlayerMobile)m_From));
                break;

            case 9:     // TurnRight
                boat.StartTurn(2, true);
                m_From.SendGump(new BoatGump((PlayerMobile)m_From));
                break;

            case 10:     // OneForward
                boat.OneMove(Direction.North);
                m_From.SendGump(new BoatGump((PlayerMobile)m_From));
                break;

            case 11:     // OneBack
                boat.OneMove(Direction.South);
                m_From.SendGump(new BoatGump((PlayerMobile)m_From));
                break;

            case 12:     // OneLeft
                boat.OneMove(Direction.West);
                m_From.SendGump(new BoatGump((PlayerMobile)m_From));
                break;

            case 13:     // OneRight
                boat.OneMove(Direction.East);
                m_From.SendGump(new BoatGump((PlayerMobile)m_From));
                break;

            case 14:     // LeftForward
                boat.StartMove(Direction.Up, true);
                m_From.SendGump(new BoatGump((PlayerMobile)m_From));
                break;

            case 15:     // RightForward
                boat.StartMove(Direction.Right, true);
                m_From.SendGump(new BoatGump((PlayerMobile)m_From));
                break;
            }
        }