Пример #1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (sender == null ||
                sender.Mobile == null || sender.Mobile.Deleted ||
                info == null || info.ButtonID == 0)
            {
                return;
            }

            if (info.ButtonID < 0 &&
                sender.Mobile.AccessLevel < AccessLevel.GameMaster)
            {
                return;
            }

            Mobile pet;
            int    todo;
            int    petID;

            if (info.ButtonID < 51)
            {
                todo  = (info.ButtonID - 1) % 4;
                petID = (info.ButtonID - 1) / 4;

                if (petID < 0 || petID > m_Pets.Count - 1)
                {
                    sender.Mobile.SendMessage("The pets have changed after gump creation. Please try again.");
                    return;
                }
                pet = m_Pets[petID];

                if (pet == null || pet.Deleted)
                {
                    return;
                }

                switch (todo)
                {
                case 0:
                    //get
                    if (pet is BaseMount && ((BaseMount)pet).Rider != null)
                    {
                        var bm = (BaseMount)pet;
                        bm.Rider = null;
                        sender.Mobile.SendMessage("That creature was ridden. The rider has been dismounted.");
                    }

                    pet.MoveToWorld(sender.Mobile.Location, sender.Mobile.Map);
                    break;

                case 1:
                    //goto
                    if (pet is BaseMount && ((BaseMount)pet).Rider != null)
                    {
                        var bm = (BaseMount)pet;
                        if (bm.Rider != bm.ControlMaster)
                        {
                            sender.Mobile.SendMessage(
                                "The rider of the pet is not the owner of it. GM fun? Or something strange is going on here. Request cancelled.");
                            //return;
                        }
                        sender.Mobile.MoveToWorld(bm.Rider.Location, bm.Rider.Map);
                        sender.Mobile.SendMessage(
                            "The owner of this pet is riding it atm. You have been moved to the owner.");
                    }
                    else
                    {
                        sender.Mobile.MoveToWorld(pet.Location, pet.Map);
                    }
                    break;

                case 2:
                    //props
                    sender.Mobile.SendGump(new PropertiesGump(sender.Mobile, pet));
                    break;

                case 3:
                    //stable
                    Followers.StablePet(sender.Mobile, (BaseCreature)pet);
                    break;
                }
            }
            else
            {
                int tmp = info.ButtonID - 50;
                petID = (tmp - 1) / 2;
                todo  = (tmp - 1) % 2;

                if (petID < 0 || petID > m_StabledPets.Count - 1)
                {
                    sender.Mobile.SendMessage("The pets have changed after gump creation. Please try again.");
                    return;
                }
                pet = m_StabledPets[petID];

                if (pet == null || pet.Deleted)
                {
                    return;
                }

                switch (todo)
                {
                case 0:
                    // props
                    sender.Mobile.SendGump(new PropertiesGump(sender.Mobile, pet));
                    break;

                case 1:
                    // unstable
                    if (pet is BaseCreature)
                    {
                        Followers.UnStablePet(m_Master, (BaseCreature)pet, sender.Mobile);
                    }
                    break;
                }
            }
        }