コード例 #1
0
		private bool LoadUses( Mobile m )
		{
			OmniEntry[] oe = new OmniEntry[m_Entries.Length];
			
			try {
				for ( int x=0; x<m_Entries.Length; x++ )
				{
					oe = (OmniEntry[])WorldOmniporter.GlobalEntries[m_Entries[x]];
					
					for ( int y=0; y<oe.Length; y++ )
					{
						OmniEntry entry = oe[y];
						try {
							entry.ToCount = loadTo[x][y];
							entry.FromCount = loadFrom[x][y];
						}
						catch (Exception e)
						{
							if (InitializeCounts()) 
							{
								entry.ToCount = loadTo[x][y];
								entry.FromCount = loadFrom[x][y];
							}
							else
							{
								entry.ToCount = 0;
								entry.FromCount = 0;
							}
						}
					}
				}
			}
			catch ( Exception e )
			{
				//This is a legacy catch - should never happen...
				m.SendMessage( "Omniporters have not been initialized. Please restart server." );
				Console.WriteLine(e.ToString());
				return false;
			}
			
			loaded = true;
			return true;
		}
コード例 #2
0
		public override void OnResponse( NetState state, RelayInfo info )
		{
			pets = false;
			go = 1;
			Mobile from = state.Mobile;
			string msg = "You may use the Omniporter now.";

			foreach ( Mobile mob in from.GetMobilesInRange( 2 ) )
			{
				if ( mob is BaseCreature )
				{
					BaseCreature pet = (BaseCreature)mob;

					if ( pet.Controlled && pet.ControlMaster == from )
					{
						if ( pet.ControlOrder == OrderType.Guard || pet.ControlOrder == OrderType.Follow || pet.ControlOrder == OrderType.Come )
						{
							move.Add( pet );
							go++;
						}
					}
				}
			}
			if ( go > 1 ) pets = true;
			
			string message = m_WO.NextUseMessage( from, go, pets );

			if ( info.ButtonID <= 0 || from == null || from.Deleted || m_WO == null || m_WO.Deleted )
				return;

			int id = info.ButtonID / 100;
			int count = info.ButtonID % 100;

			if ( id == 0 && count < 13 )
			{
				from.SendGump( new WorldOmniporterGump( from, m_WO, count ) );
				return;
			}

			//Invalid checks
			if ( id < 1 || id > 13 || (id == 12 && !m_Staff) )
				id = 1;

			string name = m_Entries[id-1];

			m_Entry = GetEntry( name, count );

			bool gates = name == "Public Moongates";

			if ( m_Entry == null )
				from.SendMessage( "Error: Invalid Button Response - No Map Entries" );
			else if ( ( (gates || name == "Felucca") && m_Entry.Map == Map.Felucca && !m_WO.Felucca) )
				from.SendMessage( "Error: Invalid Button Response - Felucca Disabled" );
			else if ( (gates || name == "Trammel") && m_Entry.Map == Map.Trammel && (!m_WO.Trammel || !m_Reds))
				from.SendMessage( "Error: Invalid Button Response - Trammel Disabled" );
			else if ( (name == "Ilshenar" ) && m_Entry.Map == Map.Ilshenar && (!m_WO.Ilshenar || !m_HasLBR || !m_Reds))
				from.SendMessage( "Error: Invalid Button Response - Ilshenar Disabled" );
			else if (m_Entry.Map == Map.Malas && (!Core.AOS || !m_HasAOS || !m_WO.Malas || !m_Reds))
				from.SendMessage( "Error: Invalid Button Response - Malas Disabled" );
			else if (m_Entry.Map == Map.Tokuno && (!Core.SE || !m_HasSE || !m_WO.Tokuno || !m_Reds))
				from.SendMessage( "Error: Invalid Button Response - Tokuno Disabled" );
			else if (m_Entry.Map == Map.TerMur && (!Core.SA || !m_HasSA || !m_WO.TerMur || !m_Reds))
				from.SendMessage( "Error: Invalid Button Response - TerMur Disabled" );
			else if ( !from.InRange( m_WO.GetWorldLocation(), 1 ) || from.Map != m_WO.Map )
				from.SendLocalizedMessage( 1019002 ); 				// You are too far away to use the gate.
			else if ( from.Criminal )
				from.SendLocalizedMessage( 1005561, "", 0x22 ); 	// Thou'rt a criminal and cannot escape so easily.
			else if ( Server.Spells.SpellHelper.CheckCombat( from ) )
				from.SendLocalizedMessage( 1005564, "", 0x22 ); 	// Wouldst thou flee during the heat of battle??
			else if ( from.Spell != null )
				from.SendLocalizedMessage( 1049616 ); 				// You are too busy to do that at the moment.
			else if ( from.Map == m_Entry.Map && from.InRange( m_Entry.Destination, 1 ) )
				from.SendLocalizedMessage( 1019003 ); 				// You are already there.
			else if ( message == msg )
				DoTravel( from );									// --- Travel ---
			else if ( m_WO.MustWait( from ) )
				from.SendMessage( message );						// Have to wait for some reason...
			else if ( !m_WO.CanUse( from, pets ) )
				from.SendMessage( message );						// You may not use the Omniporter...
			else if ( m_WO.MustPay( from, pets ) )					// Have to pay to use the Omniporter...
				from.SendGump( new ConfirmGump( "Confirm!", 32767, message,
					32767, 300, 300, new ConfirmGumpCallback( PaymentConfirm_Callback ) ) );
			else
				from.SendMessage( message );						// You may not use the Omniporter...
		}