Пример #1
0
        public override void OnDoubleClick(Mobile from)
        {
            //wooo sanity!
            if (Deleted)
            {
                return;
            }

            //Has to be in backpack and on a boat!
            if (!this.IsChildOf(from.Backpack))
            {
                from.SendMessage("That must be in your backpack to use it.");
                return;
            }
            BaseBoat bt = BaseBoat.FindBoatAt(from);

            if (bt == null || !bt.IsOnDeck(from))
            {
                from.SendMessage("You must be on a boat to use this.");
                return;
            }
            //Begin tarzan!
            from.SendMessage("Target the boat you wish to grapple.");
            from.Target = new InternalTarget(this);
        }
Пример #2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                BaseBoat bt  = null;
                Point3D  loc = new Point3D();

                //Check we have a hook
                if (m_Hook == null)
                {
                    return;
                }

                //first do all our validation *again* to thwart sneaky players!
                //Has to be in backpack and on a boat
                if (!m_Hook.IsChildOf(from.Backpack))
                {
                    from.SendMessage("That must be in your backpack to use it.");
                    return;
                }
                bt = BaseBoat.FindBoatAt(from);
                if (bt == null || !bt.IsOnDeck(from))
                {
                    from.SendMessage("You must be on a boat to use this.");
                    return;
                }
                bt = null;

                //Disallow the targetting of movable Items
                if (targeted is Item)
                {
                    Item i = (Item)targeted;
                    if (i.Movable == true)
                    {
                        from.SendMessage("You must grapple onto something more sturdy!");
                        return;
                    }
                    //this item is immovable, see if there's a boat at its location
                    bt  = BaseBoat.FindBoatAt(i);
                    loc = i.Location;
                } // A static target is a good candidate
                else if (targeted is StaticTarget)
                {
                    //see if there's a boat at its location
                    StaticTarget st = (StaticTarget)targeted;

                    // Boats seem to have both TileFlag.Surface and TileFlag.Impassable flags on different parts of the deck
                    if ((st.Flags & TileFlag.Wet) == 0)
                    {
                        bt  = BaseBoat.FindBoatAt(st.Location, from.Map, 16);
                        loc = st.Location;
                    }
                }

                //If bt is still null, something was targeted not on a ship.
                if (bt != null)
                {
                    //Prevent targeting their own boat
                    if (bt.IsOnDeck(from))
                    {
                        from.SendMessage("You can't grapple the boat you are on!");
                        return;
                    }

                    if (bt.IsMoving)
                    {
                        //Play a "rope being thrown"  type sound effect (bellows :P)
                        Effects.PlaySound(from.Location, from.Map, 0x2B2);
                        from.SendMessage("You fail to get a good hook into the boat.");
                        return;
                    }

                    //If there any players who are alive then the hook gets pusehd back in ye olde water..
                    foreach (Mobile m in bt.GetMobilesOnDeck())
                    {
                        if (m is PlayerMobile && m.Alive && m.AccessLevel <= AccessLevel.Player)
                        {
                            from.SendMessage("You grapple the boat, but the hook is tossed back into the water.");
                            //Play a random water splashy sound effect!
                            Effects.PlaySound(from.Location, from.Map, 36 + Utility.Random(3) + 1);
                            return;
                        }
                    }

                    //Success!
                    from.SendMessage("You grapple the boat!");
                    //This is the bellows and double arrow hit played together :D
                    Effects.PlaySound(from.Location, from.Map, 0x2B2);
                    Effects.PlaySound(from.Location, from.Map, 0x523);
                    //Consume the grappling hook
                    m_Hook.Consume();
                    //Start the timer (approx the same time as the sound effects finish)
                    InternalTimer t = new InternalTimer(from, bt);
                    t.Start();
                }
                else
                {
                    from.SendMessage("That's not a boat!");
                }
            }