Пример #1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Player == null)
            {
                return;
            }
            if (m_Vendor == null)
            {
                return;
            }

            if (m_Vendor.Deleted || !m_Vendor.Alive)
            {
                return;
            }

            if (!m_Player.Alive)
            {
                m_Player.SendMessage("You must be alive to do that.");
                return;
            }

            if (Utility.GetDistance(m_Vendor.Location, m_Player.Location) >= 15)
            {
                m_Player.SendMessage("You are too far away to continue that.");

                m_Player.CloseGump(typeof(StableGump));
                m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));

                return;
            }

            if (ArenaController.GetArenaAtLocation(m_Player.Location, m_Player.Map) != null)
            {
                m_Player.SendMessage("You cannot access stables while in that location.");

                return;
            }

            bool closeGump = true;

            int usedStableSlots = Stables.GetUsedStableSlots(m_Player);
            int maxStableSlots  = Stables.GetMaxStableSlots(m_Player);

            int totalFollowers = m_Player.Stabled.Count;
            int totalPages     = (int)(Math.Ceiling((double)totalFollowers / (double)FollowersPerPage));

            if (m_Page >= totalPages)
            {
                m_Page = 0;
            }

            if (m_Page < 0)
            {
                m_Page = 0;
            }

            int creatureStartIndex = m_Page * FollowersPerPage;
            int creatureEndIndex   = (m_Page * FollowersPerPage) + (FollowersPerPage - 1);

            if (creatureEndIndex >= totalFollowers)
            {
                creatureEndIndex = totalFollowers - 1;
            }

            switch (info.ButtonID)
            {
            //Guide
            case 1:
                closeGump = false;
                break;

            //Previous Page
            case 2:
                if (m_Page > 0)
                {
                    m_Page--;
                    m_Player.SendSound(changeGumpSound);
                }

                closeGump = false;
                break;

            //Stable New Follower
            case 3:
                Stables.StableNewFollower(m_Vendor, m_Player, m_Page);
                break;

            //Next Page
            case 4:
                if (m_Page < totalPages - 1)
                {
                    m_Page++;
                    m_Player.SendSound(changeGumpSound);
                }

                closeGump = false;
                break;

            //Retrieve Lost Followers
            case 5:
                int stableSlotsRemaining = Stables.GetMaxStableSlots(m_Player) - Stables.GetUsedStableSlots(m_Player);

                int stabledCreatures    = 0;
                int unableToStableCount = 0;
                int packsDropped        = 0;

                Queue m_Queue         = new Queue();
                Queue m_BackpackQueue = new Queue();

                for (int a = 0; a < m_Player.AllFollowers.Count; a++)
                {
                    BaseCreature bc_Follower = m_Player.AllFollowers[a] as BaseCreature;

                    if (bc_Follower == null)
                    {
                        continue;
                    }

                    if (bc_Follower.Summoned)
                    {
                        continue;
                    }
                    if (bc_Follower.IsStabled)
                    {
                        continue;
                    }
                    if (!(bc_Follower.Controlled && bc_Follower.ControlMaster == m_Player))
                    {
                        continue;
                    }
                    if (bc_Follower.GetDistanceToSqrt(m_Player.Location) < Stables.RetrieveFollowerMinimumDistance)
                    {
                        continue;
                    }

                    if (bc_Follower.ControlSlots <= stableSlotsRemaining)
                    {
                        stabledCreatures++;
                        stableSlotsRemaining -= bc_Follower.ControlSlots;

                        m_Queue.Enqueue(bc_Follower);
                    }

                    else
                    {
                        unableToStableCount++;
                    }
                }

                while (m_Queue.Count > 0)
                {
                    BaseCreature bc_Follower = (BaseCreature)m_Queue.Dequeue();

                    if (bc_Follower == null)
                    {
                        continue;
                    }

                    if (bc_Follower.Backpack is StrongBackpack)
                    {
                        if (bc_Follower.Backpack.TotalItems > 0)
                        {
                            packsDropped++;

                            DropBackpack dropBackpack = new DropBackpack();

                            foreach (Item item in bc_Follower.Backpack.Items)
                            {
                                m_BackpackQueue.Enqueue(item);
                            }

                            while (m_BackpackQueue.Count > 0)
                            {
                                Item item = (Item)m_BackpackQueue.Dequeue();

                                dropBackpack.DropItem(item);
                            }

                            dropBackpack.MoveToWorld(m_Player.Location, m_Player.Map);
                        }
                    }

                    Stables.StableFollower(m_Vendor, m_Player, bc_Follower, 0, false, true);
                }

                if (stabledCreatures > 0 && unableToStableCount == 0)
                {
                    m_Player.SendMessage("Your lost followers have been successfully stabled.");
                }

                else if (stabledCreatures == 0 && unableToStableCount > 0)
                {
                    m_Player.SendMessage("None of your lost followers were stabled as you have exceeded your maximum stable control slot allotment.");
                }

                else if (stabledCreatures > 0 && unableToStableCount > 0)
                {
                    m_Player.SendMessage("Some of your lost followers were unable to be stabled as you have exceeded your maximum stable control slot allotment.");
                }

                else if (stabledCreatures == 0 && unableToStableCount == 0)
                {
                    m_Player.SendMessage("You do not currently have any lost followers at the moment.");
                }

                if (packsDropped > 0)
                {
                    m_Player.SendMessage(2550, "One or more of your lost pack creatures have left their pack's contents at your feet.");
                }

                closeGump = false;
                break;
            }

            //Follower
            if (info.ButtonID >= 10)
            {
                int creatureIndex = (int)(Math.Floor((double)info.ButtonID / 10)) - 1;
                int buttonPressed = info.ButtonID % 10;

                if (creatureIndex < m_Player.Stabled.Count)
                {
                    BaseCreature bc_Creature = m_Player.Stabled[creatureIndex] as BaseCreature;

                    if (bc_Creature != null)
                    {
                        if (bc_Creature.IsStabled)
                        {
                            switch (buttonPressed)
                            {
                            //Claim Follower
                            case 0:
                                if (m_Player.RecentlyInCombat)
                                {
                                    m_Player.SendMessage("You have been in combat too recently to claim a follower.");
                                }

                                else if (m_Player.RecentlyInPlayerCombat)
                                {
                                    m_Player.SendMessage("You have been in combat with another player too recently claim a follower.");
                                }

                                else if (bc_Creature.ControlSlots + m_Player.Followers > m_Player.FollowersMax)
                                {
                                    m_Player.SendMessage("You do not have enough control slots available to claim that follower.");
                                }

                                else
                                {
                                    int goldCost = Stables.GetClaimCost(m_Vendor, m_Player, bc_Creature);

                                    if (Banker.GetBalance(m_Player) < goldCost)
                                    {
                                        m_Player.SendMessage("You do not have enough gold in your bank to claim that follower.");
                                    }

                                    else
                                    {
                                        Banker.Withdraw(m_Player, goldCost);
                                        Stables.ClaimFollower(m_Vendor, m_Player, bc_Creature, m_Page);

                                        m_Player.SendSound(0x2E6);
                                    }
                                }
                                break;

                            //Animal Lore
                            case 1:
                                m_Player.CloseGump(typeof(StableGump));
                                m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));

                                m_Player.SendGump(new AnimalLoreGump(m_Player, new AnimalLoreGumpObject(bc_Creature)));
                                m_Player.SendSound(openGumpSound);

                                return;

                                break;

                            //Dismiss Follower
                            case 2:

                                m_Player.CloseGump(typeof(StableDismissFollowerGump));
                                m_Player.SendGump(new StableDismissFollowerGump(m_Vendor, m_Player, bc_Creature, m_Page));

                                m_Player.SendSound(openGumpSound);

                                return;

                                break;
                            }
                        }

                        else
                        {
                            //If Somehow Still in Stabled List but Not Set as Stabled
                            if (m_Player.Stabled.Contains(bc_Creature))
                            {
                                m_Player.Stabled.Remove(bc_Creature);
                            }
                        }
                    }
                }

                closeGump = false;
            }

            if (!closeGump)
            {
                m_Player.CloseGump(typeof(StableGump));
                m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));
            }
        }
Пример #2
0
            protected override void OnTarget(Mobile from, object target)
            {
                if (m_Player == null)
                {
                    return;
                }
                if (m_Vendor == null)
                {
                    return;
                }
                if (m_Vendor.Deleted || !m_Vendor.Alive)
                {
                    return;
                }

                if (ArenaController.GetArenaAtLocation(m_Player.Location, m_Player.Map) != null)
                {
                    m_Player.SendMessage("You cannot access stables while at that location.");
                    return;
                }

                if (!m_Player.Alive)
                {
                    m_Player.SendMessage("You must be alive to do that.");

                    m_Player.CloseGump(typeof(StableGump));
                    m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));

                    return;
                }

                if (Utility.GetDistance(m_Vendor.Location, m_Player.Location) >= 15)
                {
                    m_Player.SendMessage("You are too far away to continue that.");

                    m_Player.CloseGump(typeof(StableGump));
                    m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));

                    return;
                }

                if (!(target is BaseCreature))
                {
                    m_Player.SendMessage("That is not a valid follower.");

                    m_Player.CloseGump(typeof(StableGump));
                    m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));

                    return;
                }

                BaseCreature bc_Target = target as BaseCreature;

                if (Utility.GetDistance(m_Player.Location, bc_Target.Location) >= 8)
                {
                    m_Player.SendMessage("That follower is too far away.");

                    m_Player.CloseGump(typeof(StableGump));
                    m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));

                    return;
                }

                if (!m_Player.InLOS(bc_Target) || bc_Target.Hidden)
                {
                    m_Player.SendMessage("That follower cannot be seen.");

                    m_Player.CloseGump(typeof(StableGump));
                    m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));

                    return;
                }

                if (bc_Target.Summoned)
                {
                    m_Player.SendMessage("That type of follower cannot be stabled.");

                    m_Player.CloseGump(typeof(StableGump));
                    m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));

                    return;
                }

                if (!(bc_Target.Controlled && bc_Target.ControlMaster is PlayerMobile))
                {
                    m_Player.SendMessage("That follower does not belong to you.");

                    m_Player.CloseGump(typeof(StableGump));
                    m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));

                    return;
                }

                if (bc_Target.RecentlyInCombat)
                {
                    m_Player.SendMessage("That follower has been in combat too recently to be stabled.");

                    m_Player.CloseGump(typeof(StableGump));
                    m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));

                    return;
                }

                if (bc_Target.RecentlyInPlayerCombat)
                {
                    m_Player.SendMessage("You have been in combat with another player too recently for that follower to be stabled.");

                    m_Player.CloseGump(typeof(StableGump));
                    m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));

                    return;
                }

                if (bc_Target.Backpack is StrongBackpack)
                {
                    if (bc_Target.Backpack.Items.Count > 0)
                    {
                        m_Player.SendMessage("You must clear that follower's backpack of items before it may be stabled.");

                        m_Player.CloseGump(typeof(StableGump));
                        m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));

                        return;
                    }
                }

                if (bc_Target.ControlSlots + Stables.GetUsedStableSlots(m_Player) > Stables.GetMaxStableSlots(m_Player))
                {
                    m_Player.SendMessage("You have exceeded your maximum stable control slot allotment.");

                    m_Player.CloseGump(typeof(StableGump));
                    m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));

                    return;
                }

                StableFollower(m_Vendor, m_Player, bc_Target, m_Page, true, false);
            }
Пример #3
0
        public StableGump(Mobile vendor, PlayerMobile player, int page) : base(10, 10)
        {
            if (vendor == null)
            {
                return;
            }
            if (player == null)
            {
                return;
            }

            m_Vendor = vendor;
            m_Player = player;

            m_Page = page;

            Closable   = true;
            Disposable = true;
            Dragable   = true;
            Resizable  = false;

            #region Images

            AddPage(0);

            AddImage(3, 369, 103);
            AddImage(2, 262, 103);
            AddImage(2, 3, 103);
            AddImage(131, 3, 103);
            AddImage(2, 97, 103);
            AddImage(134, 97, 103);
            AddImage(264, 288, 103);
            AddImage(133, 368, 103);
            AddImage(265, 3, 103);
            AddImage(265, 98, 103);
            AddImage(265, 193, 103);
            AddImage(2, 194, 103);
            AddImage(265, 368, 103);
            AddImage(394, 288, 103);
            AddImage(395, 3, 103);
            AddImage(395, 98, 103);
            AddImage(395, 193, 103);
            AddImage(395, 368, 103);
            AddImage(527, 288, 103);
            AddImage(528, 3, 103);
            AddImage(528, 98, 103);
            AddImage(528, 193, 103);
            AddImage(528, 368, 103);

            AddBackground(11, 106, 647, 352, 3000);
            AddBackground(11, 14, 647, 84, 3000);

            AddItem(133, 10, 3892);
            AddItem(142, 43, 3892);
            AddItem(142, 43, 3892);
            AddItem(113, 49, 3892);
            AddItem(101, 15, 3892);
            AddItem(71, 47, 3892);
            AddItem(71, 47, 3892);
            AddItem(96, 29, 3892);
            AddItem(177, 60, 3899);
            AddItem(114, 12, 3896);
            AddItem(177, 19, 3894);
            AddItem(120, 15, 3898);
            AddItem(100, 84, 3899);
            AddItem(77, 32, 3894);
            AddItem(139, 28, 5368);
            AddItem(580, 30, 2604);
            AddItem(586, 29, 4030);
            AddItem(599, 36, 4031);
            AddItem(479, 48, 2602);
            AddItem(550, 15, 2651);
            AddItem(534, 42, 2650);
            AddItem(537, 35, 2707, 2118);
            AddItem(496, 17, 2868);
            AddItem(499, 21, 2479);
            AddItem(485, 24, 2542);
            AddItem(493, 28, 2575);

            #endregion

            int usedStableSlots = Stables.GetUsedStableSlots(m_Player);
            int maxStableSlots  = Stables.GetMaxStableSlots(m_Player);

            int totalFollowers = m_Player.Stabled.Count;
            int totalPages     = (int)(Math.Ceiling((double)totalFollowers / (double)FollowersPerPage));

            if (m_Page >= totalPages)
            {
                m_Page = 0;
            }

            if (m_Page < 0)
            {
                m_Page = 0;
            }

            int creatureStartIndex = m_Page * FollowersPerPage;
            int creatureEndIndex   = (m_Page * FollowersPerPage) + (FollowersPerPage - 1);

            if (creatureEndIndex >= totalFollowers)
            {
                creatureEndIndex = totalFollowers - 1;
            }

            int WhiteTextHue = 2655; //2036

            AddLabel(24, 112, 2599, "Claim");
            AddLabel(75, 112, 2599, "Slots");
            AddLabel(126, 112, 2599, "Claim Cost");
            AddLabel(310, 112, 2599, "Follower");
            AddLabel(455, 112, 2599, "Lore");
            AddLabel(498, 112, 2599, "Level");
            AddLabel(556, 112, 2599, "Exp");
            AddLabel(602, 112, 2599, "Dismiss");

            //Guide
            AddButton(10, 11, 2094, 2095, 1, GumpButtonType.Reply, 0);
            AddLabel(7, 0, 149, "Guide");

            AddLabel(304, 27, 2201, "Claim Followers");
            AddLabel(282, 62, 2610, "Stable Slots Used:");
            AddLabel(402, 62, WhiteTextHue, usedStableSlots.ToString() + " / " + maxStableSlots.ToString());

            int startY      = 142;
            int itemSpacing = 40;

            int creatureCount = creatureEndIndex - creatureStartIndex;

            for (int a = 0; a < creatureCount + 1; a++)
            {
                int creatureIndex       = creatureStartIndex + a;
                int creatureButtonIndex = (10 * (creatureIndex + 1));

                if (creatureIndex >= m_Player.Stabled.Count)
                {
                    continue;
                }

                BaseCreature bc_Creature = m_Player.Stabled[creatureIndex] as BaseCreature;

                if (bc_Creature == null)
                {
                    continue;
                }

                string controlSlots = bc_Creature.ControlSlots.ToString();
                string claimCost    = Stables.GetClaimCost(m_Vendor, m_Player, bc_Creature).ToString();
                string followerName = bc_Creature.GetTamedDisplayName();

                int aliveTextHue     = WhiteTextHue;
                int claimCostTextHue = WhiteTextHue;

                string experienceLevel = bc_Creature.ExperienceLevel.ToString();
                string experience      = bc_Creature.Experience.ToString() + "/" + BaseCreature.GetMaxLevelExperience(bc_Creature.ExperienceLevel);

                AddButton(24, startY - 5, 2151, 2152, creatureButtonIndex, GumpButtonType.Reply, 0);        //Claim Button
                AddLabel(Utility.CenteredTextOffset(90, controlSlots), startY, WhiteTextHue, controlSlots); //Slots
                AddItem(117, startY - 5, 3823);                                                             //Gold Image
                AddLabel(160, startY, claimCostTextHue, claimCost.ToString());                              //Claim Cost
                AddLabel(Utility.CenteredTextOffset(335, followerName), startY, 2603, followerName);        //Follower Name

                AddButton(455, startY - 5, 9721, 9724, creatureButtonIndex + 1, GumpButtonType.Reply, 0);

                AddLabel(Utility.CenteredTextOffset(515, experienceLevel), startY, WhiteTextHue, experienceLevel);
                AddLabel(Utility.CenteredTextOffset(565, experience), startY, WhiteTextHue, experience);
                AddButton(611, startY - 5, 2472, 2473, creatureButtonIndex + 2, GumpButtonType.Reply, 0);

                startY += itemSpacing;
            }

            //Previous Page
            if (m_Page > 0)
            {
                AddButton(24, 408, 4014, 4016, 2, GumpButtonType.Reply, 0);
                AddLabel(61, 409, WhiteTextHue, "Previous Page");
            }

            //Stable Follower
            AddButton(180, 408, 4002, 4004, 3, GumpButtonType.Reply, 0);
            AddLabel(217, 409, 63, "Stable Follower");

            //Retrieve Lost Followers
            AddButton(343, 408, 4029, 4031, 5, GumpButtonType.Reply, 0);
            AddLabel(380, 409, 2606, "Retrieve Lost Followers");

            //Next Page
            if (m_Page < totalPages - 1)
            {
                AddLabel(547, 408, WhiteTextHue, "Next Page");
                AddButton(616, 409, 4005, 4007, 4, GumpButtonType.Reply, 0);
            }

            AddLabel(19, 433, 149, "Claim Cost:");
            AddLabel(96, 433, 2550, "Days Housed X Control Slots X " + Stables.GoldCostPerControlSlotPerDay.ToString());

            AddLabel(358, 433, 149, "Retrieval Cost:");
            AddLabel(457, 433, 2550, "Adds " + Stables.RetireveFollowerDaysAdded.ToString() + " Days Worth of Housing");
        }
Пример #4
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Player == null)
            {
                return;
            }
            if (m_Vendor == null)
            {
                return;
            }

            if (m_Vendor.Deleted || !m_Vendor.Alive)
            {
                return;
            }

            if (!m_Player.Alive)
            {
                m_Player.SendMessage("You must be alive to do that.");
                return;
            }

            if (Utility.GetDistance(m_Vendor.Location, m_Player.Location) >= 15)
            {
                m_Player.SendMessage("You are too far away to continue that.");

                m_Player.CloseGump(typeof(StableGump));
                m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));

                return;
            }

            bool closeGump = true;

            int usedStableSlots = Stables.GetUsedStableSlots(m_Player);
            int maxStableSlots  = Stables.GetMaxStableSlots(m_Player);

            int totalFollowers = m_Player.Stabled.Count;
            int totalPages     = (int)(Math.Ceiling((double)totalFollowers / (double)FollowersPerPage));

            if (m_Page >= totalPages)
            {
                m_Page = 0;
            }

            if (m_Page < 0)
            {
                m_Page = 0;
            }

            int creatureStartIndex = m_Page * FollowersPerPage;
            int creatureEndIndex   = (m_Page * FollowersPerPage) + (FollowersPerPage - 1);

            if (creatureEndIndex >= totalFollowers)
            {
                creatureEndIndex = totalFollowers - 1;
            }

            switch (info.ButtonID)
            {
            //Guide
            case 1:
                closeGump = false;
                break;

            //Previous Page
            case 2:
                if (m_Page > 0)
                {
                    m_Page--;
                    m_Player.SendSound(changeGumpSound);
                }

                closeGump = false;
                break;

            //Stable New Follower
            case 3:
                Stables.StableNewFollower(m_Vendor, m_Player, m_Page);
                break;

            //Next Page
            case 4:
                if (m_Page < totalPages - 1)
                {
                    m_Page++;
                    m_Player.SendSound(changeGumpSound);
                }

                closeGump = false;
                break;
            }

            //Follower
            if (info.ButtonID >= 10)
            {
                int creatureIndex = (int)(Math.Floor((double)info.ButtonID / 10)) - 1;
                int buttonPressed = info.ButtonID % 10;

                if (creatureIndex < m_Player.Stabled.Count)
                {
                    BaseCreature bc_Creature = m_Player.Stabled[creatureIndex] as BaseCreature;

                    if (bc_Creature != null)
                    {
                        if (bc_Creature.IsStabled)
                        {
                            switch (buttonPressed)
                            {
                            //Claim Follower
                            case 0:
                                if (m_Player.RecentlyInCombat)
                                {
                                    m_Player.SendMessage("You have been in combat too recently to claim a follower.");
                                }

                                else if (m_Player.RecentlyInPlayerCombat)
                                {
                                    m_Player.SendMessage("You have been in combat with another player too recently claim a follower.");
                                }

                                else if (bc_Creature.ControlSlots + m_Player.Followers > m_Player.FollowersMax)
                                {
                                    m_Player.SendMessage("You do not have enough control slots available to claim that follower.");
                                }

                                else
                                {
                                    int goldCost = Stables.GetClaimCost(m_Vendor, m_Player, bc_Creature);

                                    if (Banker.GetBalance(m_Player) < goldCost)
                                    {
                                        m_Player.SendMessage("You do not have enough gold in your bank to claim that follower.");
                                    }

                                    else
                                    {
                                        Banker.Withdraw(m_Player, goldCost);
                                        Stables.ClaimFollower(m_Vendor, m_Player, bc_Creature, m_Page);

                                        m_Player.SendSound(0x2E6);
                                    }
                                }
                                break;

                            //Dismiss Follower
                            case 1:

                                m_Player.CloseGump(typeof(StableDismissFollowerGump));
                                m_Player.SendGump(new StableDismissFollowerGump(m_Vendor, m_Player, bc_Creature, m_Page));

                                m_Player.SendSound(openGumpSound);

                                return;

                                break;
                            }
                        }

                        else
                        {
                            //If Somehow Still in Stabled List but Not Set as Stabled
                            if (m_Player.Stabled.Contains(bc_Creature))
                            {
                                m_Player.Stabled.Remove(bc_Creature);
                            }
                        }
                    }
                }

                closeGump = false;
            }

            if (!closeGump)
            {
                m_Player.CloseGump(typeof(StableGump));
                m_Player.SendGump(new StableGump(m_Vendor, m_Player, m_Page));
            }
        }