[Runuo 2.0 RC2] Public Moongate Reborn (With Item Check & Map Check) The bulk/original part of this script was created by aj9251. Big BIG BIG thanks to Lord_greywolf and ESPECLLY David for all the time and help. David spent about 3 days answering questions and helping me build this!! Thank you David!!!!!! I learned a lot! Description The idea was to add “Map Scrolls” to the loot that would randomly drop. When a player got a scroll they would open a gate (or in this case use a moongate) to go to a “lost dungeon” that they could not normally get to. The lost dungeons will end up being the many unused dungeons on the map or the dungeons in the other maps that are never used. More Specific Descripton Scripts\Items\Misc\PublicMoongate.cs When you click a moongate and open it there are a series of checks that take place. They can be customized. Right now there are two main checks. 1) A moongate map check that will check what map the player is on and return a cretin MapList. 2) A moongate item check. If a player is carrying a cretin item a another MapList will show up There is also a set of scroll (just normal items) that are used in the check. So there is a lot you could do with this - especially the item part. It could be used for quests or really anything. The scripts are very bare-bones. I have not developed the whole dungeon part of it yet. Installation 1) Replace Scripts\Items\Misc\PublicMoongate.cs with the new code. Edit as needed 2) MapDungeonScroll.cs must be added to your customs folder (or where ever you like). Unless you change what items are being called by the PublicMoongate.cs script. And lastly, if you want to learn about programming go read the original post! Else if (backpack) check??? Scripts\Items\Misc\PublicMoongate.cs Code: using System; using System.Collections.Generic; using Server; using Server.Commands; using Server.Gumps; using Server.Mobiles; using Server.Network; using Server.Spells; namespace Server.Items { public class PublicMoongate : Item { public override bool ForceShowProperties{ get{ return ObjectPropertyList.Enabled; } } [Constructable] public PublicMoongate() : base( 0xF6C ) { Movable = false; Light = LightType.Circle300; } public PublicMoongate( Serial serial ) : base( serial ) { } public override void OnDoubleClick( Mobile from ) { if ( !from.Player ) return; if ( from.InRange( GetWorldLocation(), 1 ) ) UseGate( from ); else from.SendLocalizedMessage( 500446 ); // That is too far away. } public override bool OnMoveOver( Mobile m ) { if ( m.Player ) { UseGate( m ); } return true; } public override bool HandlesOnMovement{ get{ return true; } } public override void OnMovement( Mobile m, Point3D oldLocation ) { if ( m is PlayerMobile ) { if ( !Utility.InRange( m.Location, this.Location, 1 ) && Utility.InRange( oldLocation, this.Location, 1 ) ) m.CloseGump( typeof( MoongateGump ) ); } } public bool UseGate( Mobile m ) { if ( m.Criminal ) { m.SendLocalizedMessage( 1005561, "", 0x22 ); // Thou'rt a criminal and cannot escape so easily. return false; } else if ( SpellHelper.CheckCombat( m ) ) { m.SendLocalizedMessage( 1005564, "", 0x22 ); // Wouldst thou flee during the heat of battle?? return false; } else if ( m.Spell != null ) { m.SendLocalizedMessage( 1049616 ); // You are too busy to do that at the moment. return false; } else { m.CloseGump( typeof( MoongateGump ) ); m.SendGump( new MoongateGump( m, this ) ); if ( !m.Hidden || m.AccessLevel == AccessLevel.Player ) Effects.PlaySound( m.Location, m.Map, 0x20E ); return true; } } 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(); } public static void Initialize() { CommandSystem.Register( "MoonGen", AccessLevel.Administrator, new CommandEventHandler( MoonGen_OnCommand ) ); } [Usage( "MoonGen" )] [Description( "Generates public moongates. Removes all old moongates." )] public static void MoonGen_OnCommand( CommandEventArgs e ) { DeleteAll(); int count = 0; count += MoonGen( PMList.Trammel ); count += MoonGen( PMList.Felucca ); count += MoonGen( PMList.Ilshenar ); count += MoonGen( PMList.Malas ); count += MoonGen( PMList.Tokuno ); World.Broadcast( 0x35, true, "{0} moongates generated.", count ); } private static void DeleteAll() { List list = new List(); foreach ( Item item in World.Items.Values ) { if ( item is PublicMoongate ) list.Add( item ); } foreach ( Item item in list ) item.Delete(); if ( list.Count > 0 ) World.Broadcast( 0x35, true, "{0} moongates removed.", list.Count ); } private static int MoonGen( PMList list ) { foreach ( PMEntry entry in list.Entries ) { Item item = new PublicMoongate(); item.MoveToWorld( entry.Location, list.Map ); if ( entry.DestName == "Umbra" ) // Umbra item.Hue = 0x497; } return list.Entries.Length; } } public class PMEntry { private Point3D m_Location; private string m_DestName; public Point3D Location { get { return m_Location; } } public string DestName { get { return m_DestName; } } public PMEntry( Point3D loc, string name ) { m_Location = loc; m_DestName = name; } } public class PMList { private string m_Name; private string m_DestName; private int m_NameHue, m_DestHue; private Map m_Map; private PMEntry[] m_Entries; public string DestName { get { return m_DestName; } } public string Name { get { return m_Name; } } public int NameHue { get { return m_NameHue; } } public int DestHue { get { return m_DestHue; } } public Map Map { get { return m_Map; } } public PMEntry[] Entries { get { return m_Entries; } } public PMList( string name, int namehue, int desthue, Map map, PMEntry[] entries ) { m_Map = map; m_Entries = entries; m_Name = name; m_NameHue = namehue; m_DestHue = desthue; } /* ** Maximum of: 15 characters(Including Spaces) per PMEntry, 12 PMEntrys per PMList, 9 PMLists. ** public static readonly PmList CATAGORY NAME = new PMList( "CATAGORY NAME AGAIN", CATAGORY NAME Hue, Destinations Hue, Map.DESTINATION MAP, new PMEntry[] { new PMEntry( new Point3D( X, Y, Z, ), "DESTINATION NAME" ), << After each PMEntry you put a , new PMEntry( new Point3D( X, Y, Z, ), "DESTINATION NAME" ) << Except for the final entry. } ); */ public static readonly PMList Trammel = new PMList( "Trammel", 3, 3, Map.Trammel, new PMEntry[] { new PMEntry( new Point3D( 4467, 1283, 5 ), "Moonglow" ), // Moonglow new PMEntry( new Point3D( 1336, 1997, 5 ), "Britain" ), // Britain new PMEntry( new Point3D( 1499, 3771, 5 ), "Jhelom" ), // Jhelom new PMEntry( new Point3D( 771, 752, 5 ), "Yew" ), // Yew new PMEntry( new Point3D( 2701, 692, 5 ), "Minoc" ), // Minoc new PMEntry( new Point3D( 1828, 2948,-20), "Trinsic" ), // Trinsic new PMEntry( new Point3D( 643, 2067, 5 ), "Skara Brae" ), // Skara Brae new PMEntry( new Point3D( 3563, 2139, 34), "Magincia" ), // Magincia new PMEntry( new Point3D( 3763, 2771, 50), "New Haven" ) // New Haven } ); public static readonly PMList Felucca = new PMList( "Felucca", 38, 38, Map.Felucca, new PMEntry[] { new PMEntry( new Point3D( 4467, 1283, 5 ), "Moonglow" ), // Moonglow new PMEntry( new Point3D( 1336, 1997, 5 ), "Britain" ), // Britain new PMEntry( new Point3D( 1499, 3771, 5 ), "Jhelom" ), // Jhelom new PMEntry( new Point3D( 771, 752, 5 ), "Yew" ), // Yew new PMEntry( new Point3D( 2701, 692, 5 ), "Minoc" ), // Minoc new PMEntry( new Point3D( 1828, 2948,-20), "Trinsic" ), // Trinsic new PMEntry( new Point3D( 643, 2067, 5 ), "Skara Brae" ), // Skara Brae new PMEntry( new Point3D( 3563, 2139, 34), "Magincia" ), // Magincia new PMEntry( new Point3D( 5258, 3931, 82 ), "Delucia" ), // Delucia new PMEntry( new Point3D( 2711, 2234, 0 ), "Buccaneer's Den" ) // Buccaneer's Den } ); public static readonly PMList Ilshenar = new PMList( "Ilshenar", 567, 567, Map.Ilshenar, new PMEntry[] { new PMEntry( new Point3D( 1215, 467, -13 ), "Compassion" ), // Compassion new PMEntry( new Point3D( 722, 1366, -60 ), "Honesty" ), // Honesty new PMEntry( new Point3D( 744, 724, -28 ), "Honor" ), // Honor new PMEntry( new Point3D( 281, 1016, 0 ), "Humility" ), // Humility new PMEntry( new Point3D( 987, 1011, -32 ), "Justice" ), // Justice new PMEntry( new Point3D( 1174, 1286, -30 ), "Sacrifice" ), // Sacrifice new PMEntry( new Point3D( 1532, 1340, - 3 ), "Spirituality" ), // Spirituality new PMEntry( new Point3D( 528, 216, -45 ), "Valor" ), // Valor new PMEntry( new Point3D( 1721, 218, 96 ), "Chaos" ) // Chaos } ); public static readonly PMList Malas = new PMList( "Malas", 507, 507, Map.Malas, new PMEntry[] { new PMEntry( new Point3D( 1015, 527, -65 ), "Luna" ), // Luna new PMEntry( new Point3D( 1997, 1386, -85 ), "Umbra" ) // Umbra } ); public static readonly PMList Staff = new PMList( "Staff", 1153, 1153, Map.Felucca, new PMEntry[] { } ); public static readonly PMList Tokuno = new PMList( "Tokuno", 453, 453, Map.Tokuno, new PMEntry[] { new PMEntry( new Point3D( 1169, 998, 41 ), "Isamu-Jima" ), // Isamu-Jima new PMEntry( new Point3D( 802, 1204, 25 ), "Makoto-Jima" ), // Makoto-Jima new PMEntry( new Point3D( 270, 628, 15 ), "Homare-Jima" ) // Homare-Jima } ); // Put the name of your catagory in one or more of the following lists dependant on who you wish access to your catagory. // For example if your catagory's name was SantaClaus and you wanted it accesable to red players // you would put SantaClaus into the RedList Like so: // public static readonly PMList[] RedLists = new PMList[] { Felucca, SantaClaus }; public static readonly PMList[] StaffLists = new PMList[] { Trammel, Felucca, Ilshenar, Malas, Tokuno, Staff }; public static readonly PMList[] UORLists = new PMList[] { Trammel }; public static readonly PMList[] UORListsYoung = new PMList[] { Trammel }; public static readonly PMList[] LBRLists = new PMList[] { Trammel }; public static readonly PMList[] LBRListsYoung = new PMList[] { Trammel }; public static readonly PMList[] AOSLists = new PMList[] { Trammel }; public static readonly PMList[] AOSListsYoung = new PMList[] { Trammel }; public static readonly PMList[] SELists = new PMList[] { Trammel }; public static readonly PMList[] SEListsYoung = new PMList[] { Trammel }; public static readonly PMList[] RedLists = new PMList[] { Trammel }; public static readonly PMList[] SigilLists = new PMList[] { Trammel }; public static readonly PMList[] TestList1 = new PMList[] { Trammel, Felucca }; public static readonly PMList[] TestList2 = new PMList[] { Trammel, Ilshenar }; public static readonly PMList[] MapList1 = new PMList[] { Trammel, Felucca }; public static readonly PMList[] MapList2 = new PMList[] { Trammel, Ilshenar }; public static readonly PMList[] MapList3 = new PMList[] { Trammel, Malas }; public static readonly PMList[] MapList4 = new PMList[] { Trammel, Tokuno }; //public static readonly PMList[] UORLists = new PMList[] { Trammel, Felucca }; //public static readonly PMList[] UORListsYoung = new PMList[] { Trammel }; //public static readonly PMList[] LBRLists = new PMList[] { Trammel, Felucca, Ilshenar }; //public static readonly PMList[] LBRListsYoung = new PMList[] { Trammel, Ilshenar }; //public static readonly PMList[] AOSLists = new PMList[] { Trammel, Felucca, Ilshenar, Malas }; //public static readonly PMList[] AOSListsYoung = new PMList[] { Trammel, Ilshenar, Malas }; //public static readonly PMList[] SELists = new PMList[] { Trammel, Felucca, Ilshenar, Malas, Tokuno }; //public static readonly PMList[] SEListsYoung = new PMList[] { Trammel, Ilshenar, Malas, Tokuno }; //public static readonly PMList[] RedLists = new PMList[] { Felucca }; //public static readonly PMList[] SigilLists = new PMList[] { Felucca }; } public class MoongateGump : Gump { private Mobile m_Mobile; private Item m_Moongate; private PMList[] m_Lists; public MoongateGump( Mobile mobile, Item moongate ) : base( 100, 100 ) { m_Mobile = mobile; m_Moongate = moongate; PMList[] checkLists = PMList.SELists; //PMList[] checkLists; bool hasMapScroll = false; Item myItem = mobile.Backpack.FindItemByType(typeof(baseMapScroll)); if (myItem != null) hasMapScroll = true; if ( mobile.Player ) { if ( mobile.AccessLevel >= AccessLevel.Counselor ) { checkLists = PMList.StaffLists; } else if ( Factions.Sigil.ExistsOn( mobile ) ) { checkLists = PMList.SigilLists; } else if ( mobile.Kills >= 1 ) // >= 5 { checkLists = PMList.RedLists; } // If you need to make sure they are on a specific map as well you could do something like this. // else if (hasMapScroll && myItem is MapScroll001 && mobile.Map == Map.Felucca) // Scroll Check else if (hasMapScroll && myItem is MapScroll001) { checkLists = PMList.TestList1; } else if (hasMapScroll && myItem is MapScroll002) { checkLists = PMList.TestList2; } // Map check else if ( mobile.Map == Map.Felucca ) { checkLists = PMList.MapList1; } else if ( mobile.Map == Map.Ilshenar ) { checkLists = PMList.MapList2; } else if ( mobile.Map == Map.Malas ) { checkLists = PMList.MapList3; } else if ( mobile.Map == Map.Tokuno ) { checkLists = PMList.MapList4; // END Map check } else { int flags = mobile.NetState == null ? 0 : mobile.NetState.Flags; bool young = mobile is PlayerMobile ? ((PlayerMobile)mobile).Young : false; if ( Core.SE && (flags & 0x10) != 0 ) checkLists = young ? PMList.SEListsYoung : PMList.SELists; else if ( Core.AOS && (flags & 0x8) != 0 ) checkLists = young ? PMList.AOSListsYoung : PMList.AOSLists; else if ( (flags & 0x4) != 0 ) checkLists = young ? PMList.LBRListsYoung : PMList.LBRLists; else checkLists = young ? PMList.UORListsYoung : PMList.UORLists; } } else { checkLists = PMList.SELists; } // *********** Advanced Programmers Only Past This Point --- EDIT AT OWN RISK!! ************* m_Lists = new PMList[checkLists.Length]; for ( int i = 0; i < m_Lists.Length; ++i ) m_Lists[i] = checkLists[i]; for ( int i = 0; i < m_Lists.Length; ++i ) { if ( m_Lists[i].Map == mobile.Map ) { PMList temp = m_Lists[i]; m_Lists[i] = m_Lists[0]; m_Lists[0] = temp; break; } } AddPage( 0 ); //AddBackground( 0, 0, 380, 280, 5054 ); AddBackground(0, 0, 335, 375, 2620); AddAlphaRegion( 5, 5, 330, 365 ); AddButton( 10, 275, 4005, 4007, 1, GumpButtonType.Reply, 0 ); //AddHtmlLocalized( 45, 210, 140, 25, 1011036, false, false ); // OKAY AddLabel( 45, 275, 38, "OKAY" ); AddButton( 10, 300, 4005, 4007, 0, GumpButtonType.Reply, 0 ); //AddHtmlLocalized( 45, 235, 140, 25, 1011012, false, false ); // CANCEL AddLabel( 45, 300, 38, "CANCEL" ); //AddHtmlLocalized( 5, 5, 200, 20, 1012011, false, false ); // Pick your destination: AddLabel( 190, 5, 1153, "Pick your destination:" ); AddLabel( 15, 5, 1153, "Facets:" ); //AddLabel( 15, 350, 1153, "Public Moongate Reborn: by Aj9251 (Disturbed)" ); for ( int i = 0; i < checkLists.Length; ++i ) { AddButton( 10, 35 + (i * 25), 2117, 2118, 0, GumpButtonType.Page, Array.IndexOf( m_Lists, checkLists[i] ) + 1 ); //AddHtmlLocalized( 30, 35 + (i * 25), 150, 20, checkLists[i].DestName, false, false ); //AddHtml( 30, 35 + (i * 25), 150, 20, checkLists[i].DestName, false, false ); AddLabel(30, 35 + (i * 25), checkLists[i].NameHue, checkLists[i].Name ); //Unselected Catagory's Name } for ( int i = 0; i < m_Lists.Length; ++i ) RenderPage( i, Array.IndexOf( checkLists, m_Lists[i] ) ); } private void RenderPage( int index, int offset ) { PMList list = m_Lists[index]; AddPage( index + 1 ); AddButton( 10, 35 + (offset * 25), 2117, 2118, 0, GumpButtonType.Page, index + 1 ); //AddHtmlLocalized( 30, 35 + (offset * 25), 150, 20, list.SelNumber, false, false ); AddLabel(30, 35 + (offset * 25), 1153, list.Name + " <--" ); // Selected Catagory's Name PMEntry[] entries = list.Entries; for ( int i = 0; i < entries.Length; ++i ) { AddRadio( 185, 35 + (i * 25), 210, 211, false, (index * 100) + i ); //AddHtmlLocalized( 225, 35 + (i * 25), 150, 20, entries[i].DestName, false, false ); AddLabel(210, 35 + (i * 25), list.DestHue, entries[i].DestName ); // Destination Names in Catagory } } public override void OnResponse( NetState state, RelayInfo info ) { if ( info.ButtonID == 0 ) // Cancel return; else if ( m_Mobile.Deleted || m_Moongate.Deleted || m_Mobile.Map == null ) return; int[] switches = info.Switches; if ( switches.Length == 0 ) return; int switchID = switches[0]; int listIndex = switchID / 100; int listEntry = switchID % 100; if ( listIndex < 0 || listIndex >= m_Lists.Length ) return; PMList list = m_Lists[listIndex]; if ( listEntry < 0 || listEntry >= list.Entries.Length ) return; PMEntry entry = list.Entries[listEntry]; if ( !m_Mobile.InRange( m_Moongate.GetWorldLocation(), 1 ) || m_Mobile.Map != m_Moongate.Map ) { m_Mobile.SendLocalizedMessage( 1019002 ); // You are too far away to use the gate. } else if ( m_Mobile.Player && m_Mobile.Kills >= 5 && list.Map != Map.Felucca ) { m_Mobile.SendLocalizedMessage( 1019004 ); // You are not allowed to travel there. } else if ( Factions.Sigil.ExistsOn( m_Mobile ) && list.Map != Factions.Faction.Facet ) { m_Mobile.SendLocalizedMessage( 1019004 ); // You are not allowed to travel there. } else if ( m_Mobile.Criminal ) { m_Mobile.SendLocalizedMessage( 1005561, "", 0x22 ); // Thou'rt a criminal and cannot escape so easily. } else if ( SpellHelper.CheckCombat( m_Mobile ) ) { m_Mobile.SendLocalizedMessage( 1005564, "", 0x22 ); // Wouldst thou flee during the heat of battle?? } else if ( m_Mobile.Spell != null ) { m_Mobile.SendLocalizedMessage( 1049616 ); // You are too busy to do that at the moment. } else if ( m_Mobile.Map == list.Map && m_Mobile.InRange( entry.Location, 1 ) ) { m_Mobile.SendLocalizedMessage( 1019003 ); // You are already there. } else { BaseCreature.TeleportPets( m_Mobile, entry.Location, list.Map ); m_Mobile.Combatant = null; m_Mobile.Warmode = false; m_Mobile.Hidden = true; m_Mobile.MoveToWorld( entry.Location, list.Map ); Effects.PlaySound( entry.Location, list.Map, 0x1FE ); } } } }MapDungeonScroll.cs Code: using System; namespace Server.Items { public class baseMapScroll : Item { //[Constructable] //public baseMapScroll() : base(0xEF3) public baseMapScroll( int itemID ) : base( itemID ) { Weight = 1.0; } public baseMapScroll(Serial serial) : base(serial) { } public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)0); } public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } } // ************************************************* // // ************************************************* public class MapScroll001 : baseMapScroll { [Constructable] public MapScroll001() : base(0xEF3) { Name = "A Map Scroll to a lost dungeon"; //Right Click to open a portal to a lost dungeon Hue = Utility.RandomNeutralHue(); //Weight = 1.0; } public MapScroll001(Serial serial) : base(serial) { } public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)0); } public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } } // ************************************************* // // ************************************************* public class MapScroll002 : baseMapScroll { [Constructable] public MapScroll002() : base(0xEF3) { Name = "A Map Scroll to a lost dungeon"; //Right Click to open a portal to a lost dungeon //Hue = 0000; //Weight = 1.0; } public MapScroll002(Serial serial) : base(serial) { } public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)0); } public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); } } }