RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Item/Gump Issue

unk

Traveler
Good day, I've been working on a "dungeon controller" to control entry into a dungeon that I have created based on a lockout system. The issue I'm running into is I'm not sure how to properly reference the DungeonController item that's being used once we're in the OnResponse from the DungeonGump. I'm trying to alter the controller's m_Active bool and be able to add to the ArrayList of active players, while in that OnResponse section

Note I'm at a beginner level in C# so I don't really understand a lot of the fundamentals, any help is appreciated :p

(RunUO 1.0)

C#:
using System;
using Server;
using Server.Gumps;
using Server.Targeting;
using Server.Mobiles;
using Server.Items;
using Teiravon;
using Server.Engines.PartySystem;
using System.Collections;
using Server.Network;

namespace Server.Gumps
{
    public class DungeonGump : Gump
    {
        Mobile m_Player;

        public DungeonController m_DungeonController;
       
        public DungeonGump( Mobile from ) : base( 0, 0 )
        {
            m_Player = from;
            m_Player.CloseGump( typeof( DungeonGump ) );      
           
            Closable=false;
            Disposable=false;
            Dragable=true;
            Resizable=false;
           
            AddPage(0);
            AddImageTiled(300, 125, 22, 180, 2625);
            AddImageTiled(173, 304, 130, 17, 2627);
            AddImage(302, 304, 2628);
            AddImage(171, 304, 2626);
            AddImageTiled(175, 114, 128, 17, 2621);
            AddImage(171, 114, 2620);
            AddImage(302, 114, 2622);
            AddImageTiled(171, 125, 21, 180, 2623);
            AddImageTiled(176, 119, 141, 198, 2624);
            AddAlphaRegion(176, 119, 141, 198 );
            AddLabel(225, 125, 1000, @"Regisfall");
            AddLabel(193, 140, 1000, @"Dungeon Controller");
            AddLabel(182, 170, 1000, @"Enter Scorched Halls?");
            AddLabel(210, 205, 1000, @"Enter");
            AddLabel(210, 240, 1000, @"Info");
            AddLabel(210, 275, 1000, @"Cancel");
            AddButton(270, 208, 1209, 1210, (int)Buttons.Enter, GumpButtonType.Reply, 0);  
            AddButton(270, 243, 1209, 1210, (int)Buttons.Info, GumpButtonType.Reply, 0);
            AddButton(270, 278, 1209, 1210, (int)Buttons.Cancel, GumpButtonType.Reply, 0);
        }
        public enum Buttons
        {

            Enter,
            Info,
            Cancel

        }

        public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
        {
            TeiravonMobile tav = (TeiravonMobile)sender.Mobile;

            switch ( info.ButtonID )
            {                      
                case (int)Buttons.Enter:

                    if (tav.PlayerLevel < 15)
                    {
                        tav.SendMessage("You need to reach level 15 to enter this dungeon.");  
                        return;
                    }

                    if (tav.SHLockout == true)
                    {
                        tav.SendMessage("You are currently locked out of The Scorched Halls. Resets are 5 days after your last run.");  
                        return;
                    }

                    //if (m_DungeonController.m_ActivePlayers.Count == 5)
                    //{
                        //tav.SendMessage("Dungeon is currently full.");  
                        //return;
                    //}

                    Engines.PartySystem.Party p = Engines.PartySystem.Party.Get(tav);

                    if (p != null && p.Contains(tav))
                    {
                        if (p.Members.Count == 5)
                        {
                            foreach (Mobile m in m_Player.GetMobilesInRange(20))
                            {
                                if ((m is TeiravonMobile) && p.Contains(m))
                                {
                                    TeiravonMobile pmember = (TeiravonMobile)m;
                                    if (pmember.PlayerLevel < 15)  
                                    {
                                        tav.SendMessage("One of your party members is not level 15.");  
                                        return;
                                    }

                                }      
                            }
                        }
                        else
                        {
                            tav.SendMessage("You need a party of 5 to enter this dungeon.");  
                            return;  
                        }
                        //TELE TO DUNG
                        Point3D loc = new Point3D(2822, 2084, 0); // TEST LOCATION
                        tav.MoveToWorld(loc, Map.Trammel);  
                        tav.SendMessage("You have been transported to The Scorched Halls.");
                        tav.Last_Lockout = DateTime.Now;
                        tav.SHLockout = true;

                        m_DungeonController.m_ActivePlayers.Add(tav);
                       
                        //SETUP KICK TIMER
                        if (m_DungeonController.m_Active == false)
                        {
                            new InternalTimer( m_DungeonController ).Start();
                            m_DungeonController.m_Active = true;
                        }
                    }

                    else
                    {
                        tav.SendMessage("You must be in a 5 player party to enter.");  
                        return;
                    }                                  
                    break;
                           
                case (int)Buttons.Info:
                    tav.SendMessage("The Scorched Halls is a five player dungeon. To enter, your party must meet the minimum level requirement of 15 and have five players. Once you complete this dungeon, you may not enter it again for another 5 days. This is considered one of the more difficult dungeons, but tales of the treasures inside make it worth the risk to many adventurers.");  
                    break;
                           
                case (int)Buttons.Cancel:
                    return;                              
                    break;
            }
        }
    }

    public class WaystoneGump : Gump
    {
        Mobile m_Player;
       
        public WaystoneGump( Mobile from ) : base( 0, 0 )
        {
            m_Player = from;
            m_Player.CloseGump( typeof( WaystoneGump ) );      
           
            Closable=false;
            Disposable=false;
            Dragable=true;
            Resizable=false;
           
            AddPage(0);
            AddImageTiled(300, 125, 22, 180, 2625);
            AddImageTiled(173, 304, 130, 17, 2627);
            AddImage(302, 304, 2628);
            AddImage(171, 304, 2626);
            AddImageTiled(175, 114, 128, 17, 2621);
            AddImage(171, 114, 2620);
            AddImage(302, 114, 2622);
            AddImageTiled(171, 125, 21, 180, 2623);
            AddImageTiled(176, 119, 141, 198, 2624);
            AddAlphaRegion(176, 119, 141, 198 );
            AddLabel(223, 125, 1000, @"Regisfall");
            AddLabel(193, 140, 1000, @"Dungeon Waystone");
            AddLabel(210, 170, 1000, @"Exit Dungeon?");
            AddLabel(210, 205, 1000, @"Exit ");
            AddLabel(210, 240, 1000, @"Info");
            AddLabel(210, 275, 1000, @"Cancel");
            AddButton(270, 208, 1209, 1210, (int)Buttons.Exit, GumpButtonType.Reply, 0);  
            AddButton(270, 243, 1209, 1210, (int)Buttons.Info, GumpButtonType.Reply, 0);
            AddButton(270, 278, 1209, 1210, (int)Buttons.Cancel, GumpButtonType.Reply, 0);
        }
        public enum Buttons
        {

            Exit,
            Info,
            Cancel

        }

        public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
        {
            TeiravonMobile tav = (TeiravonMobile)sender.Mobile;

            switch ( info.ButtonID )
            {                      
                case (int)Buttons.Exit:
                       
                        Point3D loc = new Point3D(2822, 2084, 0); // TEST SERVER LOCATION
                        tav.MoveToWorld(loc, Map.Trammel);  
                        tav.SendMessage("You have been transported out of the dungeon.");
                                                   
                    break;
                           
                case (int)Buttons.Info:
                    tav.SendMessage("This waystone will transport you safely out of The Scorched Halls. You may complete the dungeon again in another 5 days.");  
                    break;
                           
                case (int)Buttons.Cancel:
                    return;                              
                    break;
            }
        }
    }
}

namespace Server.Items
{
    public class DungeonController : Item
    {
        public bool m_Active;
        public ArrayList m_ActivePlayers;

        [CommandProperty(AccessLevel.GameMaster)]
        public bool Active
        {
            get { return m_Active; }
            set { m_Active = value; }
        }

        public ArrayList ActivePlayers
        {
            get { return m_ActivePlayers; }
        }

        [Constructable]
        public DungeonController() : base(3630)
        {
            Name = "Dungeon Controller";
            Weight = 0.0;
            LootType = LootType.Blessed;
            Hue = 1992;
            Movable = false;
        }
       
        public override void OnDoubleClick( Mobile from )
        {                  
            if (!(from.InRange( this.GetWorldLocation(), 3 )))
            {
                from.SendMessage("You are too far away to use that.");  
            }
            else
                {
                    TeiravonMobile m_Player = (TeiravonMobile)from;
                    DungeonController m_DungeonController = this as DungeonController;
                    m_Player.SendGump( new DungeonGump( m_Player ) );
                    m_Player.SendMessage("You place your hand on the orb.");
                }
        }
       
        public DungeonController( Serial serial ) : base( serial )
        {
        }

        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );

            writer.Write( (int) 0 ); // version

            writer.Write((bool)m_Active);

            writer.WriteMobileList(m_ActivePlayers);

        }

        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();

            m_Active = reader.ReadBool();

            m_ActivePlayers = reader.ReadMobileList();
            m_ActivePlayers = new ArrayList();
        }
    }

    public class DungeonWaystone : Item
    {
        [Constructable]
        public DungeonWaystone() : base(0x32F0)
        {
            Name = "Dungeon Waystone";
            Weight = 0.0;
            LootType = LootType.Blessed;
            Hue = 1992;
            Movable = false;
        }
       
        public override void OnDoubleClick( Mobile from )
        {                  
            if (!(from.InRange( this.GetWorldLocation(), 2 )))
            {
                from.SendMessage("You are too far away to use that.");  
            }
            else
                {
                    TeiravonMobile m_Player = (TeiravonMobile)from;
                    m_Player.SendGump( new WaystoneGump( m_Player ) );
                    m_Player.SendMessage("You place your hand on the waystone.");
                }
        }
       
        public DungeonWaystone( Serial serial ) : base( serial )
        {
        }

        public override void Serialize( GenericWriter writer )
        {
            base.Serialize( writer );

            writer.Write( (int) 0 ); // version

        }

        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();
        }
    }
        // KICK TIMER
        public class InternalTimer : Timer
        {
            private Item m_DungeonController;

            public InternalTimer( Item DungeonController ) : base( TimeSpan.FromSeconds( 10.0 ) )
            {
                Priority = TimerPriority.OneSecond;

                m_DungeonController = DungeonController;
            }

            protected override void OnTick()
            {
                DungeonController m_Dung = m_DungeonController as DungeonController;
                foreach (Mobile tav in m_Dung.m_ActivePlayers)
                {
                    Point3D loc = new Point3D(2822, 2084, 0); // TEST LOCATION
                    tav.MoveToWorld(loc, Map.Trammel);  
                    tav.SendMessage("Two hours have passed, you have been transported out of the dungeon. You may enter again in five days.");  
                }
            }
        }
}
 
Top