Ryandor.com
https://ryandor.com/forum/

looking for custom moongate help
https://ryandor.com/forum/viewtopic.php?f=2&t=1641
Page 1 of 1

Author:  gawin [ Mon Mar 22, 2004 10:41 am ]
Post subject:  looking for custom moongate help

I am down to my last couple problems with my new map.

The biggest is adding custom names to the moongates in malas. as with the new map thier is now 6 locations rather than 2. i have added the gates and they work quite well. using the moongate.cs but i cant change the names. does anyone have a custom moongate script that uses strings rather than the numbers that refer to hard coded mesages for the town names???

or at least point me in the rite direction of how to change the existing script

thanks
gawin

Oh and i did check runuo for this and i got the usual FLAME FEST its realy to bad that more peeps over thier would rather flame than help.

Author:  Dian [ Mon Mar 22, 2004 12:36 pm ]
Post subject: 

I dont really have time to explain it, but here is a 'ready to go' string script for RunUO, as of Beta 36. Just change the town/facet names to fit your shard.

PublicMoongate.cs

Code:
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;

namespace Server.Items
{
   public class PublicMoongate : Item
   {
      [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 )
      {
         return !m.Player || UseGate( m );
      }

      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 ( Server.Spells.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 ) );

            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()
      {
         Server.Commands.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 );

         World.Broadcast( 0x35, true, "{0} moongates generated.", count );
      }

      private static void DeleteAll()
      {
         ArrayList list = new ArrayList();

         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.Text == "Umbra" ) // Umbra
               item.Hue = 0x497;
         }

         return list.Entries.Length;
      }
   }

   public class PMEntry
   {
      private Point3D m_Location;
      private string m_Text;

      public Point3D Location
      {
         get
         {
            return m_Location;
         }
      }

      public string Text
      {
         get
         {
            return m_Text;
         }
      }

      public PMEntry( Point3D loc, string text )
      {
         m_Location = loc;
         m_Text = text;
      }
   }

   public class PMList
   {
      private string m_Text, m_SelText;
      private Map m_Map;
      private PMEntry[] m_Entries;

      public string Text
      {
         get
         {
            return m_Text;
         }
      }

      public string SelText
      {
         get
         {
            return m_SelText;
         }
      }

      public Map Map
      {
         get
         {
            return m_Map;
         }
      }

      public PMEntry[] Entries
      {
         get
         {
            return m_Entries;
         }
      }

      public PMList( string text, string selText, Map map, PMEntry[] entries )
      {
         m_Text = text;
         m_SelText = selText;
         m_Map = map;
         m_Entries = entries;
      }

      public static readonly PMList Trammel =
         new PMList( "Tram Facet", "Tram Facet", 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), "Haven" )  // Haven
            } );

      public static readonly PMList Felucca =
         new PMList( "Felucca", "Felucca", 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( 2711, 2234, 0 ), "Buc's Den" )  // Buccaneer's Den
            } );

      public static readonly PMList Ilshenar =
         new PMList( "Ilshenar", "Ilshenar", 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", "Malas", Map.Malas, new PMEntry[]
            {
               new PMEntry( new Point3D( 1015,  527, -65 ), "Luna" ), // Luna
               new PMEntry( new Point3D( 1997, 1386, -85 ), "Umbra" )  // Umbra
            } );
      
      /*Here you can edit what facets to show on the moongates...*/

      public static readonly PMList[] UORLists = new PMList[]{ Trammel, Felucca };
      public static readonly PMList[] LBRLists = new PMList[]{ Trammel, Felucca, Ilshenar };
      public static readonly PMList[] AOSLists = new PMList[]{ Trammel, Felucca, Ilshenar, Malas };
      public static readonly PMList[] RedLists = 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;

         if ( mobile.Player )
         {
            if ( mobile.Kills >= 5 )
            {
               checkLists = PMList.RedLists;
            }
            else
            {
               int flags = mobile.NetState == null ? 0 : mobile.NetState.Flags;

               if ( Core.AOS && (flags & 0x8) != 0 )
                  checkLists = PMList.AOSLists;
               else if ( (flags & 0x4) != 0 )
                  checkLists = PMList.LBRLists;
               else
                  checkLists = PMList.UORLists;
            }
         }
         else
         {
            checkLists = PMList.AOSLists;
         }

         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 );

         AddButton( 10, 210, 4005, 4007, 1, GumpButtonType.Reply, 0 );
         AddHtmlLocalized( 45, 210, 140, 25, 1011036, false, false ); // OKAY

         AddButton( 10, 235, 4005, 4007, 0, GumpButtonType.Reply, 0 );
         AddHtmlLocalized( 45, 235, 140, 25, 1011012, false, false ); // CANCEL

         AddHtmlLocalized( 5, 5, 200, 20, 1012011, false, false ); // Pick your destination:

         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 );
            AddHtml( 30, 35 + (i * 25), 150, 20, checkLists[i].Text, false, false );
         }

         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 );
         AddHtml( 30, 35 + (offset * 25), 150, 20, list.SelText, false, false );

         PMEntry[] entries = list.Entries;

         for ( int i = 0; i < entries.Length; ++i )
         {
            AddRadio( 200, 35 + (i * 25), 210, 211, false, (index * 100) + i );
            AddHtml( 225, 35 + (i * 25), 150, 20, entries[i].Text, false, false );
         }
      }

      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 ( m_Mobile.Criminal )
         {
            m_Mobile.SendLocalizedMessage( 1005561, "", 0x22 ); // Thou'rt a criminal and cannot escape so easily.
         }
         else if ( Server.Spells.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.Map = list.Map;
            m_Mobile.Location = entry.Location;

            Effects.PlaySound( entry.Location, list.Map, 0x1FE );
         }
      }
   }
}

Author:  gawin [ Mon Mar 22, 2004 1:24 pm ]
Post subject:  Thank you

Thanks a million now i see how the script is written

once again thanks to Ryandor peeps to actualy help rather than flame :]

Author:  Dian [ Mon Mar 22, 2004 3:47 pm ]
Post subject: 

Your welcome. A good program like WinDiff.. or WinMerge will let you see the changes made.. another great file comparing program is CSDiff.. has a neat unique layout on the diferences in files.

Page 1 of 1 All times are UTC - 7 hours [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/