/// <summary>
        /// 
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        internal static void LoginServerConnectFromCharServer( NetState netState, PacketReader packetReader )
        {
            // 错误 不可能有创建
            if ( netState.ExtendData is CharServerExtendData == true )
                return;
            else
                netState.ExtendData = null;

            if ( packetReader.Size < 14/*6 + 8 + ?*/ )
                return;

            // 不检查网络是否活动
            netState.IsCheckActivity = false;

            long l_iCharGUID = packetReader.ReadUInt32();
            long l_iCharPort = packetReader.ReadUInt32();
            string l_strLoginPassword = packetReader.ReadStringSafe();

            if ( l_strLoginPassword == Program.ConfigInfo.LoginPassword )
            {
                CharServerExtendData l_ExtendData = new CharServerExtendData();

                l_ExtendData.IsLoggedIn = true;
                l_ExtendData.CharGUID = l_iCharGUID;
                l_ExtendData.CharHost = netState.NetAddress.ToString();
                l_ExtendData.CharPort = l_iCharPort;

                netState.ExtendData = l_ExtendData;

                Program.CharServerList.Add(l_ExtendData);

                l_ExtendData.ConnectToCharServer( l_ExtendData.CharHost, l_ExtendData.CharPort );
            }
        }
Example #2
0
    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 pos = observedRigidbody.position;
        Quaternion rot = observedRigidbody.rotation;
        float vel = observedRigidbody.velocity.magnitude;

        if(stream.isWriting)
        {
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
            stream.Serialize(ref vel);
        }
        else
        {
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
            stream.Serialize(ref vel);
            receiver.serverPosition = pos;
            receiver.serverRotation = rot;
            receiver.serverVelocity = vel;

            receiver.lerpToTarget();

            for(int i = serverStateBuffer.Length - 1; i >= 1; i--)
            {
                serverStateBuffer[i] = serverStateBuffer[i-1];
            }

            serverStateBuffer[0] = new NetState(info.timestamp, pos, rot);
        }
    }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        internal static void CharServerConnected( NetState netState, PacketReader packetReader )
        {
            // 错误 不可能有创建
            if ( netState.ExtendData is CharServerExtendData == true )
                return;
            else
                netState.ExtendData = null;

            if ( packetReader.Size < 6/*( 6 + 0 )*/ )
                return;

            // 不检查网络是否活动
            netState.IsCheckActivity = false;

            string l_strWorldPassword = packetReader.ReadStringSafe();

            if ( l_strWorldPassword == Program.ConfigInfo.WorldPassword )
            {
                CharServerExtendData l_ExtendData = new CharServerExtendData();

                l_ExtendData.IsLoggedIn = true;

                netState.ExtendData = l_ExtendData;
            }
        }
Example #4
0
    public void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        Vector3 pos = observedTransform.position;
        Quaternion rot = observedTransform.rotation;

        if(stream.isWriting) {
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
        }
        else{
            stream.Serialize(ref pos);
            stream.Serialize(ref rot);
            reciever.serverPos = pos;
            reciever.serverRot = rot;

            reciever.lerpToTarget();

            for( int i = serverStateBuffer.Length - 1; i >= 1;i--){
                serverStateBuffer[i] = serverStateBuffer[i-1];
            }

            serverStateBuffer[0] = new NetState();
            serverStateBuffer[0].setState((float)info.timestamp, pos, rot);
        }
    }
 public override void OnResponse( NetState state, RelayInfo info )
 {
     Mobile from = state.Mobile;
     switch ( info.ButtonID )
     {
         case 0:{ break; }
     }
 }
Example #6
0
    // Update is called once per frame
    void Update()
    {
        //		if((Network.player == reciever.getOwner()) || (Network.isServer)){
        //			return;
        //		}

        if(Network.isServer){
            clientPing = 0;
        }
        else{
            clientPing = (Network.GetAveragePing(Network.connections[0]) / 100) + pingMargin;
        }
        float interpolationTime = (float)Network.time - clientPing;

        if(serverStateBuffer[0] == null) {
            serverStateBuffer[0] = new NetState();
            serverStateBuffer[0].setState(0, transform.position, transform.rotation);
        }

        if(serverStateBuffer[0].timestamp > interpolationTime){
            for(int i = 0;i < serverStateBuffer.Length;i++){
                if(serverStateBuffer[i] == null){
                    continue;
                }

                if(serverStateBuffer[i].timestamp <= interpolationTime || i == serverStateBuffer.Length - 1){
                    NetState bestTarget = serverStateBuffer[Mathf.Max(i-1, 0)];

                    NetState bestStart = serverStateBuffer[i];

                    float timediff = bestTarget.timestamp - bestStart.timestamp;
                    float lerpTime = 0.0f;

                    if(timediff > 0.0001){
                        lerpTime = ((interpolationTime - bestStart.timestamp) / timediff);
                    }

                    transform.position = Vector3.Lerp(bestStart.pos,
                                                      bestTarget.pos,
                                                      lerpTime);
                    transform.rotation = Quaternion.Slerp(bestStart.rot,
                                                          bestTarget.rot,
                                                          lerpTime);

                    return;
                }
            }
        }
        else{
            NetState latest = serverStateBuffer[0];
            transform.position = Vector3.Lerp(transform.position, latest.pos, 0.5f);
            transform.rotation = Quaternion.Slerp(transform.rotation, latest.rot, 0.5f);
        }
    }
        public override void OnResponse( NetState state, RelayInfo info )
        {
            Mobile from = state.Mobile;

            if ( m_Stone.Deleted )
                return;

            string currency = "";
            string[] tr = new string[ 1 ];
            foreach( TextRelay t in info.TextEntries )
                tr[ t.EntryID ] = t.Text;
            if ( tr[ 0 ] != null )
                currency = tr[ 0 ];
            m_Stone.Currency = currency;

            if ( info.ButtonID == 0 )
            {
                from.SendMessage( "Closed." );
            }
            if ( info.ButtonID == 1 )
            {
                from.SendGump( new VendorGump( new VSShopper( from, m_Stone ), m_Stone ) );
            }
            if ( info.ButtonID == 2 )
            {
                from.SendGump( new TokenVendorStoneAddItemGump( from, m_Stone ) );
            }
            if ( info.ButtonID == 3 )
            {
                if ( m_Stone.AccessLevel == AccessLevel.Administrator )
                    m_Stone.AccessLevel = AccessLevel.Player;
                else if ( m_Stone.AccessLevel == AccessLevel.Seer )
                    m_Stone.AccessLevel = AccessLevel.Administrator;
                else if ( m_Stone.AccessLevel == AccessLevel.GameMaster )
                    m_Stone.AccessLevel = AccessLevel.Seer;
                else if ( m_Stone.AccessLevel == AccessLevel.Counselor )
                    m_Stone.AccessLevel = AccessLevel.GameMaster;
                else if ( m_Stone.AccessLevel == AccessLevel.Player )
                    m_Stone.AccessLevel = AccessLevel.Counselor;

                from.SendGump( new StaffVendorGump( from, m_Stone ) );
            }
            if ( info.ButtonID == 4 )
            {
                if ( m_Stone.EditMode )
                    m_Stone.EditMode = false;
                else
                    m_Stone.EditMode = true;

                from.SendGump( new StaffVendorGump( from, m_Stone ) );
            }
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="newNetState"></param>
 internal static void NetState_InitializeNetState( NetState newNetState )
 {
     if ( newNetState != null && newNetState.EncoderSeed == null && newNetState.ExtendData == null )
     {
         // 初始化客户端加密的数据种子
         newNetState.EncoderSeed = m_CryptTableBuffers.AcquireBuffer();
         Buffer.BlockCopy( ROSECrypt.Instance().CryptTableBuffer, 0, newNetState.EncoderSeed, 0, ROSECrypt.Instance().CryptTableBuffer.Length );
         
         LoginServerExtendData l_ExtendData = new LoginServerExtendData();
         newNetState.ExtendData = l_ExtendData;
     }
     else
         Debug.WriteLine( "ProcessNet.NetState_InitializeNetState(...) - newNetState != null && newNetState.Seed == null && newNetState.ExtendData == null error!" );
 }
Example #9
0
        public override void OnResponse( NetState sender, RelayInfo info )
        {
            int button = info.ButtonID;

            switch ( button )
            {
                case 1:
                {
                    if ( temp > m_Post.MinRange )
                        temp -= 1;
                    else
                        sender.Mobile.SendMessage( "You cant lower this value any further." );
                    m_Post.HomeRange = temp;
                    sender.Mobile.CloseGump( typeof( HitchGump ) );
                    sender.Mobile.SendGump( new HitchGump( m_Post ) );
                    break;
                }
                case 2:
                {
                    if ( temp < m_Post.MaxRange )
                        temp += 1;
                    else
                        sender.Mobile.SendMessage( "You cant raise this value any further." );
                    m_Post.HomeRange = temp;
                    sender.Mobile.CloseGump( typeof( HitchGump ) );
                    sender.Mobile.SendGump( new HitchGump( m_Post ) );
                    break;
                }
                case 3:
                {
                    if ( temp > 5 )
                        temp = 5;
                    if ( temp < 0 )
                        temp = 0;

                    m_Post.HomeRange = temp;
                    m_Post.Controlled.RangeHome = m_Post.HomeRange;
                    sender.Mobile.CloseGump( typeof( HitchGump ) );
                    break;
                }
            }
        }
Example #10
0
 public override void OnResponse( NetState sender, RelayInfo info )
 {
     switch ( info.ButtonID )
     {
         case 1: // #1 Site's Url
         {
             sender.LaunchBrowser( "http://11.freebb.com/?freebb=legends" );
             break;
         }
         case 2: // #2 Site's url
         {
             sender.LaunchBrowser( "http://www.gamesites200.com/ultimaonline/vote.php?id=4432" );
             break;
         }
         case 3: // #3 Site's url
         {
             sender.LaunchBrowser( "http://11.freebb.com/viewtopic.php?t=26&freebb=legends" );
             break;
         }
     }
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        internal static void CharServerAction( NetState netState, PacketReader packetReader )
        {
            CharServerExtendData l_ExtendData = netState.ExtendData as CharServerExtendData;
            if ( l_ExtendData == null )
            {
                Debug.WriteLine( "CharPacketHandlers.LoginAction(...) - l_ExtendData == null error!" );
                return;
            }

            if ( l_ExtendData.IsLoggedIn == false )
            {
                Debug.WriteLine( "CharPacketHandlers.LoginAction(...) - l_ExtendData.m_bIsLoggedIn == false error!" );
                return;
            }

            if ( packetReader.Size < 7/*6 + 1 + ?*/ )
            {
                Debug.WriteLine( "CharPacketHandlers.LoginAction(...) - packetReader.Size < 7 error!" );
                return;
            }

            byte l_Action = packetReader.ReadByte();

            switch ( l_Action )
            {
                case 1: // Disconnect Character

                    uint l_iAccountGuid = packetReader.ReadUInt32();

                    CharServer_Action01( netState, l_iAccountGuid );

                    break;
                default:

                    break;
            }
        }
Example #12
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            m_cycle = 0;
            from.CloseGump(typeof(GetPetGump));

            if (info.ButtonID == 1 || info.ButtonID == 2)
            {
                if (m_Price > 0)
                {
                    if (info.IsSwitched(1))
                    {
                        ArrayList pets = new ArrayList();

                        foreach (Mobile m in World.Mobiles.Values)
                        {
                            if (m is BaseCreature)
                            {
                                BaseCreature bc = (BaseCreature)m;

                                if ((bc.Controlled && bc.ControlMaster == from) || (bc.Summoned && bc.SummonMaster == from))
                                {
                                    pets.Add(bc);
                                }
                            }
                        }

                        if (pets.Count > 0)
                        {
                            m_Price = 500 * pets.Count;////Price per Pet 500

/*   To use Gold Ledger remove this line
*                                                          Item[] items = from.Backpack.FindItemsByType(typeof(GoldLedger));
*                                                          foreach (GoldLedger tl in items)
*                                                          {
*                                                              if (tl.Owner == from.Serial && tl.Gold - m_Price >= 0)
*                                                              {
*                                                                  tl.Gold = (tl.Gold - m_Price); //withdraw gold
*                                                                  //Delete();
*                                                                  from.SendMessage(1174, "{0} Gold to your Gold had been withdrawn from ledger.", m_Price); //send a message to the player gold was taken from ledger
*                                                                  m_cycle = 1;
*                                                                  for (int i = 0; i < pets.Count; ++i)
*                                                                  {
*                                                                      Mobile pet = (Mobile)pets[i];
*                                                                      if (pet is IMount)
*                                                                          ((IMount)pet).Rider = null; // make sure it's dismounted
*                                                                      pet.MoveToWorld(from.Location, from.Map);
*                                                                      Effects.SendLocationParticles(EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration), 0x3728, 10, 30, 5052);
*                                                                      Effects.PlaySound(from.Location, from.Map, 0x201);
*                                                                      //return;
*                                                                  }
*                                                              }
*                                                          }
*  To use Gold Ledger remove this line   */

                            if (m_cycle == 0)
                            {
                                if (Banker.Withdraw(from, m_Price))
                                {
                                    from.SendLocalizedMessage(1060398, m_Price.ToString());                 // Amount charged
                                    from.SendLocalizedMessage(1060022, Banker.GetBalance(from).ToString()); // Amount left, from bank

                                    for (int i = 0; i < pets.Count; ++i)
                                    {
                                        Mobile pet = (Mobile)pets[i];

                                        if (pet is IMount)
                                        {
                                            ((IMount)pet).Rider = null;     // make sure it's dismounted
                                        }
                                        pet.MoveToWorld(from.Location, from.Map);

                                        Effects.SendLocationParticles(EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration), 0x3728, 10, 30, 5052);
                                        Effects.PlaySound(from.Location, from.Map, 0x201);
                                    }
                                }
                                else
                                {
                                    from.SendMessage("Unfortunately, you do not have enough cash in your bank to summon your pets");
                                }
                                return;
                            }
                        }
                    }
                }
            }
        }
			public override void OnResponse( NetState state, RelayInfo info )
			{
				if ( info.ButtonID == 1 )
					m_Scroll.Use( m_Mobile );
			}
Example #14
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            if (from.Deleted)
            {
                return;
            }

            switch (info.ButtonID)
            {
            case 1:
                if (!(m_From.MortEngine.MortCurrentState == MortState.MortVivant))
                {
                    m_From.MortEngine.AmeLastFed = DateTime.Now;

                    m_From.MortEngine.MortVivant       = true;
                    m_From.MortEngine.MortCurrentState = MortState.MortVivant;

                    MortVivantEvoTimer timer = new MortVivantEvoTimer(m_From);
                    m_From.MortEngine.MortVivantTimer = timer;
                    timer.Start();

                    m_From.Hits   = (m_From.HitsMax / 2) + Utility.RandomMinMax(-5, 5);
                    m_From.Frozen = true;
                    //if (Temrael.beta)
                    //    m_From.Map = Map.Ilshenar;
                    m_From.Location        = m_From.MortEngine.EndroitMort;
                    m_From.MortEngine.Mort = false;
                    m_From.Resurrect();
                    m_From.Frozen = false;

                    if (m_From.Corpse != null)
                    {
                        ArrayList list = new ArrayList();

                        foreach (Item item in m_From.Corpse.Items)
                        {
                            list.Add(item);
                        }

                        foreach (Item item in list)
                        {
                            if (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair)
                            {
                                item.Delete();
                            }

                            if (item is RaceSkin || (m_From.Corpse is Corpse && ((Corpse)m_From.Corpse).EquipItems.Contains(item)))
                            {
                                if (!m_From.EquipItem(item))
                                {
                                    m_From.AddToBackpack(item);
                                }
                            }
                            else
                            {
                                m_From.AddToBackpack(item);
                            }
                        }

                        m_From.Corpse.Delete();
                    }

                    m_From.CheckStatTimers();
                    m_From.CheckRaceSkin();
                }
                break;
            }
        }
        public override void OnResponse( NetState state, RelayInfo info )
        {
            Mobile from = state.Mobile;

            if ( from.Backpack == null || from.BankBox == null )
                return;

            if ( info.ButtonID == 0 )
            {
                from.SendGump( new VendorGump( m_Shopper, m_Stone ) );
            }
            if ( info.ButtonID == 1 )
            {
                if ( m_Stone.GetCurrency() == null && m_Shopper.TotalPrice() > 0 )
                    from.SendMessage( "There was no set currency to this stone." );
                else if ( m_Shopper.ItemList.Count <= 0 )
                {
                    from.SendMessage( "You did not select anything to buy." );
                    from.SendGump( new TokenVendorStoneBuyGump( m_Shopper, m_Stone ) );
                }
                else if ( m_Stone.Currency.ToLower() == "daat99tokens" )
                {
                    Item[] tls = from.Backpack.FindItemsByType( typeof( TokenLedger ) );

                    TokenLedger ledger = null;

                    foreach( TokenLedger tl in tls )
                    {
                        if ( tl.Owner == from.Serial )
                        {
                            if ( ledger != null && tl.Tokens > ledger.Tokens )
                                ledger = tl;
                            else if ( ledger == null )
                                ledger = tl;
                        }
                    }

                    if ( ledger == null )
                    {
                        from.SendMessage( "You do not have a token ledger." );
                        return;
                    }
                    else if ( ledger.Tokens < m_Shopper.TotalPrice() )
                    {
                        from.SendMessage( "Your ledger does not have enouh tokens in it to buy this." );
                        return;
                    }

                    ledger.Tokens -= m_Shopper.TotalPrice();

                    for( int i = 0; i < m_Shopper.ItemList.Count; ++i )
                    {
                        int n = (int)m_Shopper.ItemList[i];

                        VSItem vsi = (VSItem)m_Stone.ItemList[n];

                        Type type = vsi.GetItemType();

                        if ( type != null )
                        {
                            object o = Activator.CreateInstance( type );

                            if ( o is Mobile )
                            {
                                Mobile m = (Mobile)o;

                                ArrayList items = new ArrayList();

                                m.MoveToWorld( from.Location, from.Map );
                                if ( m is BaseCreature )
                                {
                                    BaseCreature c = (BaseCreature)m;
                                    c.ControlMaster = from;
                                    c.Controlled = true;
                                    c.ControlTarget = from;
                                    c.ControlOrder = OrderType.Follow;

                                    items.Add( c );

                                    if ( vsi.BlessBond )
                                        from.SendGump( new TokenVendorStoneBlessBondGump( from, vsi, m_Stone, items ) );
                                }
                                int total = 0;
                                while( vsi.Amount-1 > total )
                                {
                                    object o2 = Activator.CreateInstance( type );
                                    Mobile m2 = (Mobile)o2;

                                    m2.MoveToWorld( from.Location, from.Map );
                                    if ( m2 is BaseCreature )
                                    {
                                        BaseCreature c = (BaseCreature)m2;
                                        c.ControlMaster = from;
                                        c.Controlled = true;
                                        c.ControlTarget = from;
                                        c.ControlOrder = OrderType.Follow;

                                        items.Add( c );
                                    }
                                    total++;
                                }
                            }
                            if ( o is Item )
                            {
                                Item item = (Item)o;

                                ArrayList items = new ArrayList();

                                items.Add( item );

                                if ( item.Stackable )
                                {
                                    if ( vsi.Amount > 60000 )
                                    {
                                        item.Amount = 60000;

                                        int aleft = vsi.Amount-60000;

                                        while( aleft > 0 )
                                        {
                                            object o2 = Activator.CreateInstance( type );
                                            if ( o2 is Item )
                                            {
                                                Item item2 = (Item)o2;

                                                if ( aleft > 60000 )
                                                {
                                                    item2.Amount = 60000;
                                                    aleft -= 60000;
                                                }
                                                else
                                                {
                                                    item2.Amount = aleft;
                                                    aleft = 0;
                                                }
                                                from.AddToBackpack( item2 );
                                                items.Add( item2 );
                                            }
                                        }
                                    }
                                    else
                                        item.Amount = vsi.Amount;
                                }
                                else
                                {
                                    int total = 0;
                                    while( vsi.Amount-1 > total )
                                    {
                                        object o2 = Activator.CreateInstance( type );
                                        if ( o2 is Item )
                                        {
                                            Item item2 = (Item)o2;
                                            from.AddToBackpack( item2 );
                                            items.Add( item2 );
                                        }
                                        total++;
                                    }
                                }

                                if ( vsi.BlessBond )
                                    from.SendGump( new TokenVendorStoneBlessBondGump( from, vsi, m_Stone, items ) );
                                from.AddToBackpack( item );
                            }
                        }
                    }
                    if ( m_Stone.Currency != null && m_Stone.Currency != "" )
                        from.SendMessage( "You buy the items with the "+m_Stone.Currency+" in your backpack." );
                    else
                        from.SendMessage( "You buy the items with the currency in your backpack." );
                }
                else if ( m_Shopper.TotalPrice() == 0 || from.Backpack.ConsumeTotal( m_Stone.GetCurrency(), m_Shopper.TotalPrice(), true ) )
                {
                    for( int i = 0; i < m_Shopper.ItemList.Count; ++i )
                    {
                        int n = (int)m_Shopper.ItemList[i];

                        VSItem vsi = (VSItem)m_Stone.ItemList[n];

                        Type type = vsi.GetItemType();

                        if ( type != null )
                        {
                            object o = Activator.CreateInstance( type );

                            if ( o is Mobile )
                            {
                                Mobile m = (Mobile)o;

                                ArrayList items = new ArrayList();

                                m.MoveToWorld( from.Location, from.Map );
                                if ( m is BaseCreature )
                                {
                                    BaseCreature c = (BaseCreature)m;
                                    c.ControlMaster = from;
                                    c.Controlled = true;
                                    c.ControlTarget = from;
                                    c.ControlOrder = OrderType.Follow;

                                    items.Add( c );
                                }
                                int total = 0;
                                while( vsi.Amount-1 > total )
                                {
                                    object o2 = Activator.CreateInstance( type );
                                    Mobile m2 = (Mobile)o2;

                                    m2.MoveToWorld( from.Location, from.Map );
                                    if ( m2 is BaseCreature )
                                    {
                                        BaseCreature c = (BaseCreature)m2;
                                        c.ControlMaster = from;
                                        c.Controlled = true;
                                        c.ControlTarget = from;
                                        c.ControlOrder = OrderType.Follow;

                                        items.Add( c );
                                    }
                                    total++;
                                }

                                if ( vsi.BlessBond )
                                    from.SendGump( new TokenVendorStoneBlessBondGump( from, vsi, m_Stone, items ) );
                            }
                            if ( o is Item )
                            {
                                Item item = (Item)o;

                                ArrayList items = new ArrayList();

                                items.Add( item );

                                if ( item.Stackable )
                                {
                                    if ( vsi.Amount > 60000 )
                                    {
                                        item.Amount = 60000;

                                        int aleft = vsi.Amount-60000;

                                        while( aleft > 0 )
                                        {
                                            object o2 = Activator.CreateInstance( type );
                                            if ( o2 is Item )
                                            {
                                                Item item2 = (Item)o2;

                                                if ( aleft > 60000 )
                                                {
                                                    item2.Amount = 60000;
                                                    aleft -= 60000;
                                                }
                                                else
                                                {
                                                    item2.Amount = aleft;
                                                    aleft = 0;
                                                }
                                                from.AddToBackpack( item2 );
                                                items.Add( item2 );
                                            }
                                        }
                                    }
                                    else
                                        item.Amount = vsi.Amount;
                                }
                                else
                                {
                                    int total = 0;
                                    while( vsi.Amount-1 > total )
                                    {
                                        object o2 = Activator.CreateInstance( type );
                                        if ( o2 is Item )
                                        {
                                            Item item2 = (Item)o2;
                                            from.AddToBackpack( item2 );
                                            items.Add( item2 );
                                        }
                                        total++;
                                    }
                                }

                                if ( vsi.BlessBond )
                                    from.SendGump( new TokenVendorStoneBlessBondGump( from, vsi, m_Stone, items ) );
                                from.AddToBackpack( item );
                            }
                        }
                    }
                    if ( m_Shopper.TotalPrice() == 0 )
                        from.SendMessage( "You recieve the item for free." );
                    else if ( m_Stone.Currency != null && m_Stone.Currency != "" )
                        from.SendMessage( "You buy the items with the "+m_Stone.Currency+" in your backpack." );
                    else
                        from.SendMessage( "You buy the items with the currency in your backpack." );
                }
                else if ( from.BankBox.ConsumeTotal( m_Stone.GetCurrency(), m_Shopper.TotalPrice(), true ) )
                {
                    for( int i = 0; i < m_Shopper.ItemList.Count; ++i )
                    {
                        int n = (int)m_Shopper.ItemList[i];

                        VSItem vsi = (VSItem)m_Stone.ItemList[n];

                        Type type = vsi.GetItemType();

                        if ( type != null )
                        {
                            object o = Activator.CreateInstance( type );

                            if ( o is Mobile )
                            {
                                Mobile m = (Mobile)o;

                                ArrayList items = new ArrayList();

                                m.MoveToWorld( from.Location, from.Map );
                                if ( m is BaseCreature )
                                {
                                    BaseCreature c = (BaseCreature)m;
                                    c.ControlMaster = from;
                                    c.Controlled = true;
                                    c.ControlTarget = from;
                                    c.ControlOrder = OrderType.Follow;

                                    items.Add( c );

                                    if ( vsi.BlessBond )
                                        from.SendGump( new TokenVendorStoneBlessBondGump( from, vsi, m_Stone, items ) );
                                }
                                int total = 0;
                                while( vsi.Amount-1 > total )
                                {
                                    object o2 = Activator.CreateInstance( type );
                                    Mobile m2 = (Mobile)o2;

                                    m2.MoveToWorld( from.Location, from.Map );
                                    if ( m2 is BaseCreature )
                                    {
                                        BaseCreature c = (BaseCreature)m2;
                                        c.ControlMaster = from;
                                        c.Controlled = true;
                                        c.ControlTarget = from;
                                        c.ControlOrder = OrderType.Follow;

                                        items.Add( c );
                                    }
                                    total++;
                                }
                            }
                            if ( o is Item )
                            {
                                Item item = (Item)o;

                                ArrayList items = new ArrayList();

                                items.Add( item );

                                if ( item.Stackable )
                                {
                                    if ( vsi.Amount > 60000 )
                                    {
                                        item.Amount = 60000;

                                        int aleft = vsi.Amount-60000;

                                        while( aleft > 0 )
                                        {
                                            object o2 = Activator.CreateInstance( type );
                                            if ( o2 is Item )
                                            {
                                                Item item2 = (Item)o2;

                                                if ( aleft > 60000 )
                                                {
                                                    item2.Amount = 60000;
                                                    aleft -= 60000;
                                                }
                                                else
                                                {
                                                    item2.Amount = aleft;
                                                    aleft = 0;
                                                }
                                                from.AddToBackpack( item2 );
                                                items.Add( item2 );
                                            }
                                        }
                                    }
                                    else
                                        item.Amount = vsi.Amount;
                                }
                                else
                                {
                                    int total = 0;
                                    while( vsi.Amount-1 > total )
                                    {
                                        object o2 = Activator.CreateInstance( type );
                                        if ( o2 is Item )
                                        {
                                            Item item2 = (Item)o2;
                                            from.AddToBackpack( item2 );
                                            items.Add( item2 );
                                        }
                                        total++;
                                    }
                                }

                                if ( vsi.BlessBond )
                                    from.SendGump( new TokenVendorStoneBlessBondGump( from, vsi, m_Stone, items ) );
                                from.AddToBackpack( item );
                            }
                        }
                    }
                    if ( m_Stone.Currency != null && m_Stone.Currency != "" )
                        from.SendMessage( "You buy the items with the "+m_Stone.Currency+" in your bank box." );
                    else
                        from.SendMessage( "You buy the items with the currency in your bank box." );
                }
                else
                {
                    from.SendGump( new TokenVendorStoneBuyGump( m_Shopper, m_Stone ) );
                    from.SendMessage( "You cannot not afford the items on your list." );
                }
            }
            if ( info.ButtonID >= 2 )
            {
                if ( info.ButtonID-2 > m_Shopper.ItemList.Count-1 || info.ButtonID-2 < 0 )
                    return;
                m_Shopper.ItemList.Remove( m_Shopper.ItemList[info.ButtonID-2] );
                from.SendGump( new TokenVendorStoneBuyGump( m_Shopper, m_Stone ) );
            }
        }
Example #16
0
        void RunTaskNetStateConnect(NetState netState)
        {
            //  通知业务逻辑有客户端连接上来可以做一些初始化
            //  或者判断是否允许本次连接
            var tempEV = NetStateConnect;
            if (tempEV != null)
            {
                var arg = new NetStateConnectEventArgs
                {
                    NetState = netState,
                    AllowConnect = true
                };
                tempEV(this, arg);
                if (arg.AllowConnect == false)
                {
                    netState.Dispose();
                    return;
                }
            }
            netState.Serial = netStateId++;

            m_netStateManager.InternalAddNetState(netState.Serial, netState);
            netState.Start();
        }
		public override void OnResponse( NetState sender, RelayInfo info )
		{
			PlayerMobile pm = sender.Mobile as PlayerMobile;

			if( pm == null || !IsMember( pm, guild ) || !IsMember( m_Member, guild ) )
				return;

			RankDefinition playerRank = pm.GuildRank;
            RankDefinition targetRank = m_Member.GuildRank;

			switch( info.ButtonID )
			{
				case 1:	//Promote
				{
					if( playerRank.GetFlag( RankFlags.CanPromoteDemote ) && ((playerRank.Rank -1 ) > targetRank.Rank || ( playerRank == RankDefinition.Leader && playerRank.Rank > targetRank.Rank )) )
					{
						targetRank = RankDefinition.Ranks[targetRank.Rank + 1];

						if( targetRank == RankDefinition.Leader )
						{
							if( m_ToLeader )
							{
								m_Member.GuildRank = targetRank;
								pm.SendLocalizedMessage( 1063156, m_Member.Name ); // The guild information for ~1_val~ has been updated.
								pm.SendLocalizedMessage( 1063156, pm.Name ); // The guild information for ~1_val~ has been updated.
								guild.Leader = m_Member;
							}
							else
							{
								pm.SendLocalizedMessage( 1063144 ); // Are you sure you wish to make this member the new guild leader?
								pm.SendGump( new GuildMemberInfoGump( player, guild, m_Member, false, true ) );
							}
						}
						else
						{
							m_Member.GuildRank = targetRank;
							pm.SendLocalizedMessage( 1063156, m_Member.Name ); // The guild information for ~1_val~ has been updated.
						}
					}
					else
						pm.SendLocalizedMessage( 1063143 ); // You don't have permission to promote this member.

					break;
				}
				case 2:	//Demote
				{
					if( playerRank.GetFlag( RankFlags.CanPromoteDemote ) && playerRank.Rank > targetRank.Rank )
					{
						if( targetRank == RankDefinition.Lowest )
						{
							if( RankDefinition.Lowest.Name.Number == 1062963 )
								pm.SendLocalizedMessage( 1063333 ); // You can't demote a ronin.
							else
								pm.SendMessage( "You can't demote a {0}.", RankDefinition.Lowest.Name );
						}
						else
						{
							m_Member.GuildRank = RankDefinition.Ranks[targetRank.Rank - 1];
							pm.SendLocalizedMessage( 1063156, m_Member.Name ); // The guild information for ~1_val~ has been updated.
						}
					}
					else
						pm.SendLocalizedMessage( 1063146 ); // You don't have permission to demote this member.
						

					break;
				}
				case 3:	//Set Guild title
				{
					if( playerRank.GetFlag( RankFlags.CanSetGuildTitle ) && ( playerRank.Rank > targetRank.Rank || m_Member == player))
					{
						pm.SendLocalizedMessage( 1011128 ); // Enter the new title for this guild member or 'none' to remove a title:

						pm.BeginPrompt( new PromptCallback( SetTitle_Callback ) );
					}
					else if( m_Member.GuildTitle == null || m_Member.GuildTitle.Length <= 0 )
					{
						pm.SendLocalizedMessage( 1070746 ); // You don't have the permission to set that member's guild title.
					}
					else
					{
						pm.SendLocalizedMessage( 1063148 ); // You don't have permission to change this member's guild title.
					}

					break;
				}
				case 4:	//Vote
				{
					if( m_Member == pm.GuildFealty && guild.Leader != m_Member )
						pm.SendLocalizedMessage( 1063158 ); // You have cleared your vote for guild leader.
					else if( guild.CanVote( m_Member ) )//( playerRank.GetFlag( RankFlags.CanVote ) )
					{
						if( m_Member == guild.Leader )
							pm.SendLocalizedMessage( 1063424 ); // You can't vote for the current guild leader.
						else if( !guild.CanBeVotedFor( m_Member ) )
							pm.SendLocalizedMessage( 1063425 ); // You can't vote for an inactive guild member.
						else
						{
							pm.GuildFealty = m_Member;
							pm.SendLocalizedMessage( 1063159, m_Member.Name ); // You cast your vote for ~1_val~ for guild leader.
						}
					}
					else
						pm.SendLocalizedMessage( 1063149 ); // You don't have permission to vote.

					break;
				}
				case 5:	//Kick
				{
					if( ( playerRank.GetFlag( RankFlags.RemovePlayers ) && playerRank.Rank > targetRank.Rank ) || ( playerRank.GetFlag( RankFlags.RemoveLowestRank ) && targetRank == RankDefinition.Lowest ) )
					{
						if( m_toKick )
						{
							guild.RemoveMember( m_Member );
							pm.SendLocalizedMessage( 1063157 ); // The member has been removed from your guild.
						}
						else
						{
							pm.SendLocalizedMessage( 1063152 ); // Are you sure you wish to kick this member from the guild?
							pm.SendGump( new GuildMemberInfoGump( player, guild, m_Member, true, false ) );
						}
					}
					else
						pm.SendLocalizedMessage( 1063151 ); // You don't have permission to remove this member.

					break;
				}
			}
		}
Example #18
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Player == null)
            {
                return;
            }
            if (!m_Player.Alive)
            {
                return;
            }
            if (m_Player.Backpack == null)
            {
                return;
            }

            bool closeGump = true;

            int totalCategories    = DonationShop.DonationCategories.Count;
            int totalCategoryPages = (int)(Math.Ceiling((double)totalCategories / (double)CategoriesPerPage));

            if (m_CategoryPage >= totalCategoryPages)
            {
                m_CategoryPage = 0;
            }

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

            int categoryStartIndex = m_CategoryPage * CategoriesPerPage;
            int categoryEndIndex   = (m_CategoryPage * CategoriesPerPage) + (CategoriesPerPage - 1);

            if (categoryEndIndex >= totalCategories)
            {
                categoryEndIndex = totalCategories - 1;
            }

            if (m_CategorySelected >= totalCategories)
            {
                m_CategorySelected = 0;
            }

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

            DonationCategory donationCategory = DonationShop.DonationCategories[m_CategorySelected];

            if (donationCategory == null)
            {
                return;
            }

            List <DonationItem> itemList = DonationShop.DonationShopList[donationCategory];

            int totalItems     = itemList.Count;
            int totalItemPages = (int)(Math.Ceiling((double)totalItems / (double)ItemsPerPage));

            if (m_ItemPage >= totalItemPages)
            {
                m_ItemPage = 0;
            }

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

            int itemStartIndex = m_ItemPage * ItemsPerPage;
            int itemEndIndex   = (m_ItemPage * ItemsPerPage) + (ItemsPerPage - 1);

            if (itemEndIndex >= totalItems)
            {
                itemEndIndex = totalItems - 1;
            }

            int donationCurrencyInBank = Banker.GetUniqueCurrencyBalance(m_Player, DonationShop.DonationCurrencyType);

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

            //Make Donation
            case 2:
                closeGump = false;
                break;

            //Previous Item Page
            case 3:
                if (m_ItemPage > 0)
                {
                    m_ItemPage--;
                }

                closeGump = false;
                break;

            //Next Item Page
            case 4:
                if (m_ItemPage < totalItemPages - 1)
                {
                    m_ItemPage++;
                }

                closeGump = false;
                break;

            //Previous Category Page
            case 5:
                if (m_CategoryPage > 0)
                {
                    m_CategoryPage++;
                }

                closeGump = false;
                break;

            //Next Category Page
            case 6:
                if (m_CategoryPage < totalCategoryPages - 1)
                {
                    m_CategoryPage++;
                }

                closeGump = false;
                break;
            }

            //Item Selection
            if (info.ButtonID >= 20 && info.ButtonID < 40)
            {
                int itemSelectionIndex = info.ButtonID - 20;
                int itemSelected       = (m_ItemPage * ItemsPerPage) + itemSelectionIndex;

                if (itemSelected >= totalItems)
                {
                    itemSelected = 0;
                }

                //Purchase Item
                DonationItem item = itemList[itemSelected];

                if (item == null)
                {
                    return;
                }

                bool purchaseAllowed = true;

                if (!purchaseAllowed)
                {
                    m_Player.SendMessage("Donation shop purchases are not allowed in this area.");

                    m_Player.CloseGump(typeof(DonationShopGump));
                    m_Player.SendGump(new DonationShopGump(m_Player, m_CategoryPage, m_CategorySelected, m_ItemPage));

                    return;
                }

                //TEST
                m_Player.Say("Cost: " + item.ItemCost.ToString() + " vs Bank: " + donationCurrencyInBank.ToString());

                if (item.ItemCost > donationCurrencyInBank)
                {
                    m_Player.SendMessage("You do not have enough " + DonationShop.DonationCurrencyName + " in your bank to purchase this item.");

                    m_Player.CloseGump(typeof(DonationShopGump));
                    m_Player.SendGump(new DonationShopGump(m_Player, m_CategoryPage, m_CategorySelected, m_ItemPage));

                    return;
                }

                Item donationItem = (Item)Activator.CreateInstance(item.ItemType);

                if (donationItem == null)
                {
                    m_Player.CloseGump(typeof(DonationShopGump));
                    m_Player.SendGump(new DonationShopGump(m_Player, m_CategoryPage, m_CategorySelected, m_ItemPage));

                    return;
                }

                if (m_Player.Backpack.TotalItems + donationItem.TotalItems > m_Player.Backpack.MaxItems)
                {
                    donationItem.Delete();

                    m_Player.SendMessage("Your backpack contains too many items to purchase this item. Please remove some items and try again.");

                    m_Player.CloseGump(typeof(DonationShopGump));
                    m_Player.SendGump(new DonationShopGump(m_Player, m_CategoryPage, m_CategorySelected, m_ItemPage));

                    return;
                }

                if (m_Player.Backpack.TotalWeight + donationItem.TotalWeight > m_Player.MaxWeight)
                {
                    donationItem.Delete();

                    m_Player.SendMessage("Your backpack is too heavy to purchase this item. Please remove some items and try again.");

                    m_Player.CloseGump(typeof(DonationShopGump));
                    m_Player.SendGump(new DonationShopGump(m_Player, m_CategoryPage, m_CategorySelected, m_ItemPage));

                    return;
                }

                m_Player.SendSound(0x2E6);
                m_Player.SendMessage("You purchase the donation item.");

                m_Player.Backpack.DropItem(donationItem);

                Banker.WithdrawUniqueCurrency(m_Player, DonationShop.DonationCurrencyType, item.ItemCost);

                closeGump = false;
            }

            //Category Selection
            if (info.ButtonID >= 40 && info.ButtonID < 60)
            {
                int categorySelectionIndex = info.ButtonID - 40;
                int categorySelected       = (m_CategoryPage * CategoriesPerPage) + categorySelectionIndex;

                if (categorySelected >= totalCategories)
                {
                    categorySelected = 0;
                }

                m_CategorySelected = categorySelected;
                m_ItemPage         = 0;

                closeGump = false;
            }

            if (!closeGump)
            {
                m_Player.CloseGump(typeof(DonationShopGump));
                m_Player.SendGump(new DonationShopGump(m_Player, m_CategoryPage, m_CategorySelected, m_ItemPage));
            }
        }
Example #19
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            var index = info.ButtonID - 1;

            if (index == -1)
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
            }
            else if (index >= 0 && index < 4)
            {
                if (m_Monster == null)
                {
                    LoadLists();
                }

                ModelBodyType        type;
                List <InternalEntry> list;

                switch (index)
                {
                default:
                    type = ModelBodyType.Monsters;
                    list = m_Monster;
                    break;

                case 1:
                    type = ModelBodyType.Animals;
                    list = m_Animal;
                    break;

                case 2:
                    type = ModelBodyType.Sea;
                    list = m_Sea;
                    break;

                case 3:
                    type = ModelBodyType.Human;
                    list = m_Human;
                    break;
                }

                m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, 0, list, type));
            }
            else if (m_OurList != null)
            {
                index -= 4;

                if (index == 0 && m_OurPage > 0)
                {
                    m_Mobile.SendGump(
                        new SetBodyGump(
                            m_Property,
                            m_Mobile,
                            m_Object,
                            m_Stack,
                            m_Page,
                            m_List,
                            m_OurPage - 1,
                            m_OurList,
                            m_OurType
                            )
                        );
                }
                else if (index == 1 && (m_OurPage + 1) * 12 < m_OurList.Count)
                {
                    m_Mobile.SendGump(
                        new SetBodyGump(
                            m_Property,
                            m_Mobile,
                            m_Object,
                            m_Stack,
                            m_Page,
                            m_List,
                            m_OurPage + 1,
                            m_OurList,
                            m_OurType
                            )
                        );
                }
                else
                {
                    index -= 2;

                    if (index >= 0 && index < m_OurList.Count)
                    {
                        try
                        {
                            var entry = m_OurList[index];

                            CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, entry.Body.ToString());
                            m_Property.SetValue(m_Object, entry.Body, null);
                            PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
                        }
                        catch
                        {
                            m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                        }

                        m_Mobile.SendGump(
                            new SetBodyGump(
                                m_Property,
                                m_Mobile,
                                m_Object,
                                m_Stack,
                                m_Page,
                                m_List,
                                m_OurPage,
                                m_OurList,
                                m_OurType
                                )
                            );
                    }
                }
            }
        }
Example #20
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            switch (info.ButtonID)
            {
            case 1:                     // continue
            {
                Guild guild = m_From.Guild as Guild;

                if (guild == null)
                {
                    PlayerState pl = PlayerState.Find(m_From);

                    if (pl != null)
                    {
                        pl.Leaving = DateTime.UtcNow;

                        if (Faction.LeavePeriod == TimeSpan.FromDays(3.0))
                        {
                            m_From.SendLocalizedMessage(1005065);                                             // You will be removed from the faction in 3 days
                        }
                        else
                        {
                            m_From.SendMessage("You will be removed from the faction in {0} days.", Faction.LeavePeriod.TotalDays);
                        }
                    }
                }
                else if (guild.Leader != m_From)
                {
                    m_From.SendLocalizedMessage(1005061);                                     // You cannot quit the faction because you are not the guild master
                }
                else
                {
                    m_From.SendLocalizedMessage(1042285);                                     // Your guild is now quitting the faction.

                    for (int i = 0; i < guild.Members.Count; ++i)
                    {
                        Mobile      mob = guild.Members[i];
                        PlayerState pl  = PlayerState.Find(mob);

                        if (pl != null)
                        {
                            pl.Leaving = DateTime.UtcNow;

                            if (Faction.LeavePeriod == TimeSpan.FromDays(3.0))
                            {
                                mob.SendLocalizedMessage(1005060);                                                 // Your guild will quit the faction in 3 days
                            }
                            else
                            {
                                mob.SendMessage("Your guild will quit the faction in {0} days.", Faction.LeavePeriod.TotalDays);
                            }
                        }
                    }
                }

                break;
            }

            case 2:                                  // cancel
            {
                m_From.SendLocalizedMessage(500737); // Canceled resignation.
                break;
            }
            }
        }
Example #21
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            int buttonID = info.ButtonID - 1;

            int index = buttonID / 3;
            int type  = buttonID % 3;

            switch (type)
            {
            case 0:
            {
                if (index >= 0 && index < m_Groups.Length)
                {
                    SkillsGumpGroup newSelection = m_Groups[index];

                    if (m_Selected != newSelection)
                    {
                        m_From.SendGump(new SkillsGump(m_From, m_Target, newSelection));
                    }
                    else
                    {
                        m_From.SendGump(new SkillsGump(m_From, m_Target, null));
                    }
                }

                break;
            }

            case 1:
            {
                if (m_Selected != null && index >= 0 && index < m_Selected.Skills.Length)
                {
                    Skill sk = m_Target.Skills[m_Selected.Skills[index]];

                    if (sk != null)
                    {
                        if (m_From.AccessLevel >= AccessLevel.GameMaster)
                        {
                            m_From.SendGump(new EditSkillGump(m_From, m_Target, sk, m_Selected));
                        }
                        else
                        {
                            m_From.SendMessage("You may not change that.");
                            m_From.SendGump(new SkillsGump(m_From, m_Target, m_Selected));
                        }
                    }
                    else
                    {
                        m_From.SendGump(new SkillsGump(m_From, m_Target, m_Selected));
                    }
                }

                break;
            }

            case 2:
            {
                if (m_Selected != null && index >= 0 && index < m_Selected.Skills.Length)
                {
                    Skill sk = m_Target.Skills[m_Selected.Skills[index]];

                    if (sk != null)
                    {
                        if (m_From.AccessLevel >= AccessLevel.GameMaster)
                        {
                            switch (sk.Lock)
                            {
                            case SkillLock.Up: sk.SetLockNoRelay(SkillLock.Down); sk.Update(); break;

                            case SkillLock.Down: sk.SetLockNoRelay(SkillLock.Locked); sk.Update(); break;

                            case SkillLock.Locked: sk.SetLockNoRelay(SkillLock.Up); sk.Update(); break;
                            }
                        }
                        else
                        {
                            m_From.SendMessage("You may not change that.");
                        }

                        m_From.SendGump(new SkillsGump(m_From, m_Target, m_Selected));
                    }
                }

                break;
            }
            }
        }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            int m_Rank = (m_Mobile as PlayerMobile).GuildRank;

            if (m_Guild.BadMember(m_Mobile))
            {
                return;
            }

            switch (info.ButtonID)
            {
            case 0:
            {
                m_Mobile.CloseGump(typeof(DeclareWarGump));

                m_Mobile.SendGump(new DiplomacyMiscGump(m_Mobile, t_Guild));

                break;
            }

            case 1:
            {
                if (m_Rank != 4 && m_Rank != 5)
                {
                    m_Mobile.SendLocalizedMessage(1063440);                                       // You don't have permission to negotiate wars.

                    return;
                }
                if (t_Guild != null)
                {
                    int       text_int = 0;
                    TextRelay text;

                    try
                    {
                        text = info.GetTextEntry(2);

                        text_int = ((text.Text.Length == 0) ? (int)0 : Convert.ToInt32(text.Text.Trim()));
                    }
                    catch
                    {
                        text_int = 0;
                    }

                    if (text_int >= 999)
                    {
                        text_int = 999;
                    }

                    uint hour_int = 0;

                    try
                    {
                        text = info.GetTextEntry(1);

                        hour_int = ((text.Text.Length == 0) ? (uint)0 : Convert.ToUInt32(text.Text.Trim()));
                    }
                    catch
                    {
                        hour_int = 0;
                    }

                    if (hour_int > 0 || text_int > 0)
                    {
                        if (hour_int >= 999)
                        {
                            hour_int = 999;

                            text_int = 0;
                        }

                        t_Guild.DelWar(m_Guild);

                        m_Guild.WarDeclarations.Remove(t_Guild);

                        t_Guild.WarInvitations.Remove(m_Guild);

                        m_Guild.AddWar(t_Guild, 0, text_int, 60 * hour_int, 60 * hour_int);
                    }

                    if (!m_Guild.WarDeclarations.Contains(t_Guild))
                    {
                        m_Guild.WarDeclarations.Add(t_Guild);

                        m_Mobile.SendLocalizedMessage(1070751, t_Guild.Name);                                           // War proposal has been sent to ~1_val~.
                    }

                    if (!t_Guild.WarInvitations.Contains(m_Guild))
                    {
                        t_Guild.WarInvitations.Add(m_Guild);

                        t_Guild.Leader.SendLocalizedMessage(1070781, m_Guild.Name);                                           // ~1_val~ has proposed a war.
                    }
                }

                m_Mobile.CloseGump(typeof(DeclareWarGump));

                break;
            }
            }
        }
Example #23
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;


            if (info == null || sender == null || sender.Mobile == null)
            {
                return;
            }

            switch (info.ButtonID)
            {
            case ( int )Buttons.CloseBtn:
            {
                break;
            }

            case 12:
                // page up
                int nitems = 0;
                nitems = 5000;

                int page = viewpage + 1;
                if (page > nitems / maxItemsPerPage)
                {
                    page = nitems / maxItemsPerPage;
                }
                from.SendGump(new ViewHueGump(from, page));
                break;

            case 13:
                // page down
                page = viewpage - 1;
                if (page < 0)
                {
                    page = 0;
                }
                from.SendGump(new ViewHueGump(from, page));
                break;

            case 15:
            {
                // go to hue page
                int hueToFind = 0;

                string huestring = info.GetTextEntry(14).Text;

                try
                {
                    hueToFind = Convert.ToInt32(huestring, 10);
                }
                catch
                {
                    hueToFind = 1;
                }

                if (hueToFind < 1)
                {
                    hueToFind = 1;
                }

                if (hueToFind > TOTAL_HUES)
                {
                    hueToFind = TOTAL_HUES;
                }

                if (hueToFind == null)
                {
                    hueToFind = 1;
                }

                int pageHueFound = (hueToFind - 1) / maxItemsPerPage;

                from.SendGump(new ViewHueGump(from, pageHueFound));

                break;
            }

            case 99:
            {
                int hueselection = 0;
                int pageHueFound = 0;

                CommandSystem.Handle(from, String.Format("{0}Set Hue {1}", CommandSystem.Prefix, hueselection));

                from.SendGump(new ViewHueGump(from, viewpage));
                break;
            }

            default:
            {
                if (info.ButtonID >= 4000 && info.ButtonID < 7001)
                {
                    int hueselection = info.ButtonID - 3999;
                    int pageHueFound = (hueselection) / maxItemsPerPage;


                    CommandSystem.Handle(from, String.Format("{0}Set Hue {1}", CommandSystem.Prefix, hueselection));

                    from.SendGump(new ViewHueGump(from, viewpage));
                    break;
                }
                break;
            }
            }
        }
Example #24
0
    public override void OnCancel(NetState state)
    {
        base.OnCancel(state);

            if (m_From is PlayerMobile)
                ((PlayerMobile)m_From).HasMenu = false;
    }
Example #25
0
        private void RunTaskNetStateDisconnect(NetState netState)
        {
            m_netStateManager.InternalRemoveNetState(netState.Serial);

            //  通知业务逻辑有客户端连接上来可以做一些初始化
            //  或者判断是否允许本次连接
            var tempEV = NetStateDisconnect;
            if (tempEV != null)
            {
                var arg = new NetStateDisconnectEventArgs
                {
                    NetState = netState,
                };
                tempEV(this, arg);
            }

            netState.ExitWorld();
            netState.Dispose();
        }
Example #26
0
        public virtual void Weather_OnTick()
        {
            int  type             = 0xFE;
            int  density          = 0;
            int  temperature      = IsUnderZero ? -30 : 30;
            bool wasRaining       = IsRaining;
            bool seasonHasChanged = false;

            if (m_NextWeatherChange < DateTime.Now)
            {
                m_Temperature = GenerateTemperature();
                m_Cloud       = GenerateCloud();
                m_Wind        = GenerateWind();

                m_NextWeatherChange = DateTime.Now + Interval;
            }

            if (IsRaining)
            {
                if (!IsUnderZero)
                {
                    type = 0;
                }
                else
                {
                    type = 2;
                }

                if (m_Cloud == DensityOfCloud.FaiblePluie)
                {
                    density = 10;
                }
                else if (m_Cloud == DensityOfCloud.Pluie)
                {
                    density = 40;
                }
                else if (m_Cloud == DensityOfCloud.FortePluie)
                {
                    density = 70;
                }
            }

            int year, month, day;

            Time.GetDate(out year, out month, out day);

            Season season = Time.Months[month - 1].Season;

            if (Map.Felucca.Season != (int)season)
            {
                Map.Felucca.Season = (int)season;
                Time.OnSeasonChange(season);
                seasonHasChanged = true;
            }

            List <NetState> states = NetState.Instances;

            Packet weatherPacket = null;
            Packet seasonPacket  = null;

            for (int i = 0; i < states.Count; ++i)
            {
                NetState ns  = (NetState)states[i];
                Mobile   mob = ns.Mobile;

                if (mob == null || mob.Map != Map.Felucca)
                {
                    continue;
                }

                if (seasonHasChanged)
                {
                    if (seasonPacket == null)
                    {
                        seasonPacket = Packet.Acquire(new SeasonChange(Map.Felucca.Season, false));
                    }

                    ns.Send(seasonPacket);

                    mob.CheckLightLevels(false);
                }

                bool contains = (m_Area.Length == 0);

                for (int j = 0; !contains && j < m_Area.Length; ++j)
                {
                    contains = m_Area[j].Contains(mob.Location);
                }

                if (!contains)
                {
                    continue;
                }

                if (weatherPacket == null)
                {
                    weatherPacket = Packet.Acquire(new Server.Network.Weather(type, density, temperature));
                }

                ns.Send(weatherPacket);

                if (wasRaining && !IsRaining)
                {
                    ns.Send(new MobileUpdate(mob));
                    ns.Send(new MobileIncoming(mob, mob));
                }

                //ns.Mobile.ProcessDelta();
            }
        }
        public override void OnResponse( NetState state, RelayInfo info )
        {
            Mobile from = state.Mobile;

            if ( from == null )
                return;

            if ( info.ButtonID == 0 )
            {
                from.SendGump( new StaffVendorGump( from, m_Stone ) );
            }
            if ( info.ButtonID == 1 )
            {
                string item = "";
                string gumpname = "";
                int price = 0;
                int amount = 0;
                int bbprice = 0;
                bool blessbond = info.IsSwitched( 1 );
                string description = "";

                string[] tr = new string[ 6 ];
                foreach( TextRelay t in info.TextEntries )
                {
                    tr[ t.EntryID ] = t.Text;
                }

                try { price = (int) uint.Parse( tr[ 2 ] ); }
                catch {}
                try { amount = (int) uint.Parse( tr[ 3 ] ); }
                catch {}
                try { bbprice = (int) uint.Parse( tr[ 4 ] ); }
                catch {}
                if ( tr[ 0 ] != null )
                    item = tr[ 0 ];
                if ( tr[ 1 ] != null )
                    gumpname = tr[ 1 ];
                if ( tr[ 5 ] != null )
                    description = tr[ 5 ];

                if ( amount <= 0 )
                    amount = 1;

                if ( item != "" && gumpname != "" )
                {
                    VSItem vsi = new VSItem( item, gumpname, price, amount, blessbond, bbprice, description );
                    m_Stone.ItemList.Add( vsi );

                    from.SendMessage( "Item Added." );
                }
                else
                {
                    from.SendMessage( "You must set a property for each one." );
                }

                from.SendGump( new TokenVendorStoneAddItemGump( from, m_Stone ) );
            }
        }
Example #28
0
        public void DisplayTo(Mobile to)
        {
            // The client must know about the spellbook or it will crash!
            NetState ns = to.NetState;

            if (ns == null)
            {
                return;
            }

            if (Parent == null)
            {
                to.Send(WorldPacket);
            }
            else if (Parent is Item)
            {
                // What will happen if the client doesn't know about our parent?
                if (ns.ContainerGridLines)
                {
                    to.Send(new ContainerContentUpdate6017(this));
                }
                else
                {
                    to.Send(new ContainerContentUpdate(this));
                }
            }
            else if (Parent is Mobile)
            {
                // What will happen if the client doesn't know about our parent?
                to.Send(new EquipUpdate(this));
            }

            if (ns.HighSeas)
            {
                to.Send(new DisplaySpellbookHS(this));
            }
            else
            {
                to.Send(new DisplaySpellbook(this));
            }

            if (ObjectPropertyList.Enabled)
            {
                if (ns.NewSpellbook)
                {
                    to.Send(new NewSpellbookContent(this, ItemID, BookOffset + 1, m_Content));
                }
                else
                {
                    if (ns.ContainerGridLines)
                    {
                        to.Send(new SpellbookContent6017(m_Count, BookOffset + 1, m_Content, this));
                    }
                    else
                    {
                        to.Send(new SpellbookContent(m_Count, BookOffset + 1, m_Content, this));
                    }
                }
            }
            else
            {
                if (ns.ContainerGridLines)
                {
                    to.Send(new SpellbookContent6017(m_Count, BookOffset + 1, m_Content, this));
                }
                else
                {
                    to.Send(new SpellbookContent(m_Count, BookOffset + 1, m_Content, this));
                }
            }
        }
Example #29
0
        private static void AccountSearch(NetState state, PacketReader pvSrc)
        {
            AcctSearchType type = (AcctSearchType)pvSrc.ReadByte();
            string         term = pvSrc.ReadString();

            if (type == AcctSearchType.IP && !Utility.IsValidIP(term))
            {
                state.Send(new MessageBoxMessage("Invalid search term.\nThe IP sent was not valid.", "Invalid IP"));
                return;
            }
            else
            {
                term = term.ToUpper();
            }

            ArrayList list = new ArrayList();

            foreach (Account a in Accounts.GetAccounts())
            {
                if (!CanAccessAccount(state.Account, a))
                {
                    continue;
                }

                switch (type)
                {
                case AcctSearchType.Username:
                {
                    if (a.Username.ToUpper().IndexOf(term) != -1)
                    {
                        list.Add(a);
                    }
                    break;
                }

                case AcctSearchType.IP:
                {
                    for (int i = 0; i < a.LoginIPs.Length; i++)
                    {
                        if (Utility.IPMatch(term, a.LoginIPs[i]))
                        {
                            list.Add(a);
                            break;
                        }
                    }
                    break;
                }
                }
            }

            if (list.Count > 0)
            {
                if (list.Count <= 25)
                {
                    state.Send(AdminNetwork.Compress(new AccountSearchResults(list)));
                }
                else
                {
                    state.Send(new MessageBoxMessage("There were more than 25 matches to your search.\nNarrow the search parameters and try again.", "Too Many Results"));
                }
            }
            else
            {
                state.Send(new MessageBoxMessage("There were no results to your search.\nPlease try again.", "No Matches"));
            }
        }
Example #30
0
 public override string Compile(NetState ns) => $"{{ gumppic {X} {Y} {GumpID} hue={Hue} class=VirtueGumpItem }}";
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            if (info.ButtonID == 0 || m_hive.Deleted || !from.InRange(m_hive.GetWorldLocation(), 3))
            {
                return;
            }

            if (!m_hive.IsAccessibleTo(from))
            {
                m_hive.LabelTo(from, "You cannot use that.");
                return;
            }

            switch (info.ButtonID)
            {
            case (int)Buttons.butExit:                     //Exit back to main gump
            {
                from.SendGump(new apiBeeHiveMainGump(from, m_hive));
                break;
            }

            case (int)Buttons.butHoney:                     //Honey
            {
                //ToDo: get hurt or poisoned when harvesting

                Item hivetool = GetHiveTool(from);

                if (NeedHiveTool)
                {
                    if (hivetool == null || !(hivetool is HiveTool))
                    {
                        m_hive.LabelTo(from, "You need a hive tool to extract the excess honey!");
                        from.SendGump(new apiBeeHiveProductionGump(from, m_hive));
                        return;
                    }
                }

                if (m_hive.Honey < 3)
                {
                    m_hive.LabelTo(from, "There isn't enough honey in the hive to fill a bottle!");
                    from.SendGump(new apiBeeHiveProductionGump(from, m_hive));
                    break;
                }

                Container pack = from.Backpack;

                if (pack != null && pack.ConsumeTotal(typeof(Bottle), 1))
                {
                    JarHoney honey = new JarHoney();

                    if (!from.PlaceInBackpack(honey))
                    {
                        honey.Delete();
                        from.PlaceInBackpack(new Bottle());                                   //add the consumed bottle
                        m_hive.LabelTo(from, "There is not enough room in your backpack for the honey!");
                        from.SendGump(new apiBeeHiveProductionGump(from, m_hive));
                        break;
                    }

                    if (NeedHiveTool)
                    {
                        ((HiveTool)hivetool).UsesRemaining--;
                        if (((HiveTool)hivetool).UsesRemaining < 1)
                        {
                            from.SendMessage("You wear out the hive tool.");
                            hivetool.Delete();
                        }
                    }

                    m_hive.Honey -= 3;
                    m_hive.LabelTo(from, "You fill a bottle with golden honey and place it in your pack.");
                    from.SendGump(new apiBeeHiveProductionGump(from, m_hive));
                    break;
                }
                else
                {
                    m_hive.LabelTo(from, "You need a bottle to fill with honey!");
                    from.SendGump(new apiBeeHiveProductionGump(from, m_hive));
                    break;
                }
            }

            case (int)Buttons.butWax:                     //Wax
            {
                //ToDo: get hurt or poisoned when harvesting

                Item hivetool = GetHiveTool(from);

                if (NeedHiveTool)
                {
                    if (hivetool == null || !(hivetool is HiveTool))
                    {
                        m_hive.LabelTo(from, "You need a hive tool to scrape the excess beeswax!");
                        from.SendGump(new apiBeeHiveProductionGump(from, m_hive));
                        return;
                    }
                }

                if (m_hive.Wax < 1)
                {
                    m_hive.LabelTo(from, "There isn't enough excess wax in the hive to harvest!");
                    return;
                }

                Item wax;

                if (PureWax)
                {
                    wax = new Beeswax(m_hive.Wax);
                }
                else
                {
                    wax = new RawBeeswax(m_hive.Wax);
                }

                if (!from.PlaceInBackpack(wax))
                {
                    wax.Delete();

                    m_hive.LabelTo(from, "There is not enough room in your backpack for the wax!");
                    from.SendGump(new apiBeeHiveProductionGump(from, m_hive));
                    break;
                }

                if (NeedHiveTool)
                {
                    ((HiveTool)hivetool).UsesRemaining--;
                    if (((HiveTool)hivetool).UsesRemaining < 1)
                    {
                        from.SendMessage("You wear out the hive tool.");
                        hivetool.Delete();
                    }
                }

                m_hive.Wax = 0;
                m_hive.LabelTo(from, "You collect the excess beeswax and place it in your pack.");
                from.SendGump(new apiBeeHiveProductionGump(from, m_hive));
                break;
            }
            }
        }
Example #32
0
            public override void AppendTo(NetState ns, IGumpWriter disp)
            {
                base.AppendTo(ns, disp);

                disp.AppendLayout(m_Class);
            }
Example #33
0
 public override void OnResponse(NetState state, RelayInfo info, ACCGumpParams subParams)
 {
 }
Example #34
0
        public static void Start(bool repair)
        {
            if (!ScriptCompiler.Compile(true))
            {
                return;
            }

            m_ItemCount   = 0;
            m_MobileCount = 0;
            foreach (Library l in ScriptCompiler.Libraries)
            {
                int itemCount = 0, mobileCount = 0;
                l.Verify(ref itemCount, ref mobileCount);
                log.InfoFormat("Library {0} verified: {1} items, {2} mobiles",
                               l.Name, itemCount, mobileCount);
                m_ItemCount   += itemCount;
                m_MobileCount += mobileCount;
            }
            log.InfoFormat("All libraries verified: {0} items, {1} mobiles)",
                           m_ItemCount, m_MobileCount);

            try {
                TileData.Configure();

                ScriptCompiler.Configure();
            } catch (TargetInvocationException e) {
                log.Fatal("Configure exception: {0}", e.InnerException);
                return;
            }

            if (!config.Exists)
            {
                config.Save();
            }

            World.Load();
            if (World.LoadErrors > 0)
            {
                log.ErrorFormat("There were {0} errors during world load.", World.LoadErrors);
                if (repair)
                {
                    log.Error("The world load errors are being ignored for now, and will not reappear once you save this world.");
                }
                else
                {
                    log.Error("Try 'SunUO --repair' to repair this world save, or restore an older non-corrupt save.");
                    return;
                }
            }

            try {
                ScriptCompiler.Initialize();
            } catch (TargetInvocationException e) {
                log.Fatal("Initialize exception: {0}", e.InnerException);
                return;
            }

            Region.Load();

            m_MessagePump = new MessagePump();
            foreach (IPEndPoint ipep in Config.Network.Bind)
            {
                m_MessagePump.AddListener(new Listener(ipep));
            }

            Timer.TimerThread ttObj = new Timer.TimerThread();
            timerThread      = new Thread(new ThreadStart(ttObj.TimerMain));
            timerThread.Name = "Timer Thread";
            timerThread.Start();

            NetState.Initialize();
            Encryption.Initialize();

            EventSink.InvokeServerStarted();

            log.Info("SunUO initialized, entering main loop");

            try
            {
                Run();
            }
            catch (Exception e)
            {
                CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true));
            }

            if (timerThread.IsAlive)
            {
                timerThread.Abort();
            }
        }
Example #35
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID <= 0)
            {
                return; // Canceled
            }
            int buttonID = info.ButtonID - 1;
            int type     = buttonID % 7;
            int index    = buttonID / 7;

            CraftSystem   system  = m_CraftSystem;
            CraftGroupCol groups  = system.CraftGroups;
            CraftContext  context = system.GetContext(m_From);

            switch (type)
            {
            case 0:     // Show group
            {
                if (context == null)
                {
                    break;
                }

                if (index >= 0 && index < groups.Count)
                {
                    context.LastGroupIndex = index;
                    m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                }

                break;
            }

            case 1:     // Create item
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        CraftItem(group.CraftItems.GetAt(index));
                    }
                }

                break;
            }

            case 2:     // Item details
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems.GetAt(index), m_Tool));
                    }
                }

                break;
            }

            case 3:     // Create item (last 10)
            {
                if (context == null)
                {
                    break;
                }

                List <CraftItem> lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    CraftItem(lastTen[index]);
                }

                break;
            }

            case 4:     // Item details (last 10)
            {
                if (context == null)
                {
                    break;
                }

                List <CraftItem> lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    m_From.SendGump(new CraftGumpItem(m_From, system, lastTen[index], m_Tool));
                }

                break;
            }

            case 5:     // Resource selected
            {
                if (m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    CraftSubRes res = system.CraftSubRes.GetAt(index);

                    if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex = index;
                        }

                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                    }
                }
                else if (m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    CraftSubRes res = system.CraftSubRes2.GetAt(index);

                    if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex2 = index;
                        }

                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                    }
                }

                break;
            }

            case 6:     // Misc. buttons
            {
                switch (index)
                {
                case 0:             // Resource selection
                {
                    if (system.CraftSubRes.Init)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource));
                    }

                    break;
                }

                case 1:             // Smelt item
                {
                    if (system.Resmelt)
                    {
                        Resmelt.Do(m_From, system, m_Tool);
                    }

                    break;
                }

                case 2:             // Make last
                {
                    if (context == null)
                    {
                        break;
                    }

                    CraftItem item = context.LastMade;

                    if (item != null)
                    {
                        CraftItem(item);
                    }
                    else
                    {
                        m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, 1044165, m_Page));                 // You haven't made anything yet.
                    }
                    break;
                }

                case 3:             // Last 10
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.LastGroupIndex = 501;
                    m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));

                    break;
                }

                case 4:             // Toggle use resource hue
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.DoNotColor = !context.DoNotColor;

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 5:             // Repair item
                {
                    if (system.Repair)
                    {
                        Repair.Do(m_From, system, m_Tool);
                    }

                    break;
                }

                case 6:             // Toggle mark option
                {
                    if (context == null || !system.MarkOption)
                    {
                        break;
                    }

                    switch (context.MarkOption)
                    {
                    case CraftMarkOption.MarkItem: context.MarkOption = CraftMarkOption.DoNotMark; break;

                    case CraftMarkOption.DoNotMark: context.MarkOption = CraftMarkOption.PromptForMark; break;

                    case CraftMarkOption.PromptForMark: context.MarkOption = CraftMarkOption.MarkItem; break;
                    }

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 7:             // Resource selection 2
                {
                    if (system.CraftSubRes2.Init)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource2));
                    }

                    break;
                }

                case 8:             // Enhance item
                {
                    if (system.CanEnhance)
                    {
                        Enhance.BeginTarget(m_From, system, m_Tool);
                    }

                    break;
                }
                }

                break;
            }
            }
        }
Example #36
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Town.Owner != m_Faction || !m_Faction.IsCommander(m_From))
            {
                m_From.SendLocalizedMessage(1010339); // You no longer control this city
                return;
            }

            switch (info.ButtonID)
            {
            case 1:     // hire sheriff
            {
                if (m_Town.Sheriff != null)
                {
                    m_From.SendLocalizedMessage(
                        1010342
                        );     // You must fire your Sheriff before you can elect a new one
                }
                else
                {
                    m_From.SendLocalizedMessage(1010347);         // Who shall be your new sheriff
                    m_From.BeginTarget(12, false, TargetFlags.None, HireSheriff_OnTarget);
                }

                break;
            }

            case 2:     // hire finance minister
            {
                if (m_Town.Finance != null)
                {
                    m_From.SendLocalizedMessage(
                        1010345
                        );     // You must fire your finance minister before you can elect a new one
                }
                else
                {
                    m_From.SendLocalizedMessage(1010348);         // Who shall be your new Minister of Finances?
                    m_From.BeginTarget(12, false, TargetFlags.None, HireFinanceMinister_OnTarget);
                }

                break;
            }

            case 3:     // fire sheriff
            {
                if (m_Town.Sheriff == null)
                {
                    m_From.SendLocalizedMessage(1010350);         // You need to elect a sheriff before you can fire one
                }
                else
                {
                    m_From.SendLocalizedMessage(1010349);                 // You have fired your sheriff
                    m_Town.Sheriff.SendLocalizedMessage(1010270);         // You have been fired as Sheriff
                    m_Town.Sheriff = null;
                }

                break;
            }

            case 4:     // fire finance minister
            {
                if (m_Town.Finance == null)
                {
                    m_From.SendLocalizedMessage(
                        1010352
                        );     // You need to elect a financial minister before you can fire one
                }
                else
                {
                    m_From.SendLocalizedMessage(1010351);                 // You have fired your financial Minister
                    m_Town.Finance.SendLocalizedMessage(1010151);         // You have been fired as Finance Minister
                    m_Town.Finance = null;
                }

                break;
            }
            }
        }
Example #37
0
        public static void Save(bool message, bool permitBackgroundWrite)
        {
            if (m_Saving)
            {
                return;
            }

            ++m_Saves;

            NetState.FlushAll();
            NetState.Pause();

            World.WaitForWriteCompletion();            //Blocks Save until current disk flush is done.

            m_Saving = true;

            m_DiskWriteHandle.Reset();

            if (message)
            {
                Broadcast(0x35, true, "The world is saving, please wait.");
            }

            SaveStrategy strategy = SaveStrategy.Acquire();

            Console.WriteLine("Core: Using {0} save strategy", strategy.Name.ToLowerInvariant());

            Console.Write("World: Saving...");

            Stopwatch watch = Stopwatch.StartNew();

            if (!Directory.Exists("Saves/Mobiles/"))
            {
                Directory.CreateDirectory("Saves/Mobiles/");
            }
            if (!Directory.Exists("Saves/Items/"))
            {
                Directory.CreateDirectory("Saves/Items/");
            }
            if (!Directory.Exists("Saves/Guilds/"))
            {
                Directory.CreateDirectory("Saves/Guilds/");
            }


            /*using ( SaveMetrics metrics = new SaveMetrics() ) {*/
            strategy.Save(null, permitBackgroundWrite);
            /*}*/

            try {
                EventSink.InvokeWorldSave(new WorldSaveEventArgs(message));
            } catch (Exception e) {
                throw new Exception("World Save event threw an exception.  Save failed!", e);
            }

            watch.Stop();

            m_Saving = false;

            if (!permitBackgroundWrite)
            {
                World.NotifyDiskWriteComplete();                        //Sets the DiskWriteHandle.  If we allow background writes, we leave this upto the individual save strategies.
            }
            ProcessSafetyQueues();

            strategy.ProcessDecay();

            Console.WriteLine("Save done in {0:F2} seconds.", watch.Elapsed.TotalSeconds);

            if (message)
            {
                Broadcast(0x35, true, "World save complete. The entire process took {0:F1} seconds.", watch.Elapsed.TotalSeconds);
            }

            NetState.Resume();
        }
Example #38
0
        public override void SendSuccessTo(Mobile from, Item item, HarvestResource resource)
        {
            if (item is BigFish)
            {
                from.SendLocalizedMessage(1042635);                   // Your fishing pole bends as you pull a big fish from the depths!

                ((BigFish)item).Fisher = from;
            }
            else if (item is WoodenChest || item is MetalGoldenChest)
            {
                from.SendLocalizedMessage(503175);                   // You pull up a heavy chest from the depths of the ocean!
            }
            else
            {
                int    number;
                string name;

                if (item is BaseMagicFish)
                {
                    number = 1008124;
                    name   = "a mess of small fish";
                }
                else if (item is Fish)
                {
                    number = 1008124;
                    name   = item.ItemData.Name;
                }
                else if (item is BaseShoes)
                {
                    number = 1008124;
                    name   = item.ItemData.Name;
                }
                else if (item is TreasureMap)
                {
                    number = 1008125;
                    name   = "a sodden piece of parchment";
                }
                else if (item is MessageInABottle)
                {
                    number = 1008125;
                    name   = "a bottle, with a message in it";
                }
                else if (item is SpecialFishingNet)
                {
                    number = 1008125;
                    name   = "a special fishing net";                   // TODO: this is just a guess--what should it really be named?
                }
                else
                {
                    number = 1043297;

                    if ((item.ItemData.Flags & TileFlag.ArticleA) != 0)
                    {
                        name = "a " + item.ItemData.Name;
                    }
                    else if ((item.ItemData.Flags & TileFlag.ArticleAn) != 0)
                    {
                        name = "an " + item.ItemData.Name;
                    }
                    else
                    {
                        name = item.ItemData.Name;
                    }
                }

                NetState ns = from.NetState;

                if (ns == null)
                {
                    return;
                }

                if (number == 1043297 || ns.HighSeas)
                {
                    from.SendLocalizedMessage(number, name);
                }
                else
                {
                    from.SendLocalizedMessage(number, true, name);
                }
            }
        }
Example #39
0
 public override void OnResponse( NetState state, RelayInfo info )
 {
     if ( info.ButtonID == 1 )
             m_Gate.EndConfirmation( m_From );
 }
        public override void OnResponse( NetState state, RelayInfo info )
        {
            Mobile from = state.Mobile;

            if ( info.ButtonID == 0 )
                from.SendMessage( "Closed." );
        }
Example #41
0
    public override void OnResponse(NetState state, int index)
    {
        if (index == 0)
                m_Gate.EndConfirmation(m_From);

            if (m_From is PlayerMobile)
                ((PlayerMobile)m_From).HasMenu = false;
    }
Example #42
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;
            BaseCreature creature = null;
            TextRelay trMessageText = info.GetTextEntry((int)Buttons.MessageEntry);

            if (info.ButtonID == (int)Buttons.Close)
                return;

            if (info.ButtonID != (int)Buttons.SetCreature && !CheckCreature(from))
            {
                from.SendMessage("No Mobile Assigned");
                from.SendGump(new BCCGump(from, trMessageText.Text));
                return;
            }
            else if (info.ButtonID != (int)Buttons.SetCreature)
                creature = BCC.CreatureList[from];

            switch (info.ButtonID)
            {
                default: return;
                case (int)Buttons.SendMessage:
                    if (trMessageText.Text.Length >= 1)
                        creature.Say(trMessageText.Text);
                    from.SendGump(new BCCGump(from, ""));
                    return;
                case (int)Buttons.ToggleFrozen:
                    creature.Frozen = !creature.Frozen;
                    break;
                case (int)Buttons.ToggleHidden:
                    creature.Hidden = !creature.Hidden;
                    break;
                case (int)Buttons.SetCreature:
                    from.SendMessage("Click on the BaseCreature to Assign.");
                    from.Target = new BCC.CMAssignTarget();
                    return;
                case (int)Buttons.Teleport:
                    creature.PublicOverheadMessage(MessageType.Spell, creature.SpeechHue, true, "Rel Por", false);
                    from.Target = new BCC.TeleportTarget();
                    break;
                case (int)Buttons.GoTo:
                    from.MoveToWorld(creature.Location, creature.Map);
                    break;
            }

            from.SendGump(new BCCGump(from, trMessageText.Text));
        }
Example #43
0
        /// <summary>
        /// 触发Socket的连接事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnSocketConnect(object sender, SocketConnectEventArgs<NetState> e)
        {
            if (WhiteList.IsEnable)
            {
                var ip = e.Session.RemoteOnlyIP;
                if (!WhiteList.Contains(ip))
                {
                    e.AllowConnection = false;
                    return;
                }
            }
            var netState = new NetState(e.Session, this);
            e.Session.Data = netState;

            //  网络连接会涉及到一些业务逻辑操作,因此需要把它加到任务队列里进行处理
            //  如果不考虑业务逻辑的处理,则可以不放到任务队列,节约一下处理时间
            mainTask.AppentdTask(RunTaskNetStateConnect, netState);
        }
        public override void OnResponse( NetState sender, RelayInfo info )
        {
            Mobile from = sender.Mobile;

            switch ( info.ButtonID )
            {
                case 0: //Case uses the ActionIDs defined above. Case 0 defines the actions for the button with the action id 0
                {
                    //Cancel
                    from.SendMessage( "Enjoy your new vinyard." );
                    break;
                }

            }
        }
        public override void OnResponse( NetState state, RelayInfo info )
        {
            Mobile from = state.Mobile;

            if ( m_Stone.Deleted )
                return;

            if ( info.ButtonID == 0 )
            {
                from.SendMessage( "You decide not to buy anything." );
            }

            if ( info.ButtonID == 1 )
            {
                from.SendGump( new TokenVendorStoneBuyGump( m_Shopper, m_Stone ) );
            }

            if ( info.ButtonID >= 3 && info.ButtonID-2 > m_Stone.ItemList.Count )
            {
                from.SendGump( new VendorGump( m_Shopper, m_Stone ) );
                from.SendGump( new TokenVendorStoneDescriptionGump( from, ((VSItem)m_Stone.ItemList[info.ButtonID-m_Stone.ItemList.Count-3]).Description, ((VSItem)m_Stone.ItemList[info.ButtonID-m_Stone.ItemList.Count-3]).Name ) );
            }
            else if ( info.ButtonID >= 2 )
            {
                if ( !m_Stone.EditMode )
                {
                    m_Shopper.AddItem( info.ButtonID-2 );
                    from.SendMessage( "You add it to your list." );
                    from.SendGump( new VendorGump( m_Shopper, m_Stone ) );
                }
                else
                {
                    if ( info.ButtonID-2 > m_Stone.ItemList.Count-1 || info.ButtonID-2 < 0 )
                        return;

                    m_Stone.CloseGumps( from );
                    from.SendGump( new TokenVendorStoneEditGump( from, (VSItem)m_Stone.ItemList[info.ButtonID-2], m_Stone ) );
                }
            }
        }
Example #46
0
        private static void UpdateAccount(NetState state, PacketReader pvSrc)
        {
            if (state.Account.AccessLevel < AccessLevel.Administrator)
            {
                state.Send(new MessageBoxMessage("You do not have permission to edit accounts.", "Account Access Exception"));
                return;
            }

            string username = pvSrc.ReadString();
            string pass     = pvSrc.ReadString();

            Account a = Accounts.GetAccount(username) as Account;

            if (a != null && !CanAccessAccount(state.Account, a))
            {
                state.Send(new MessageBoxMessage("You cannot edit an account with an access level greater than or equal to your own.", "Account Access Exception"));
            }
            else
            {
                bool        CreatedAccount = false;
                bool        UpdatedPass    = false;
                bool        oldbanned      = a == null ? false : a.Banned;
                AccessLevel oldAcessLevel  = a == null ? 0 : a.AccessLevel;

                if (a == null)
                {
                    a = new Account(username, pass);
                    CreatedAccount = true;
                }
                else if (pass != "(hidden)")
                {
                    a.SetPassword(pass);
                    UpdatedPass = true;
                }

                if (a != state.Account)
                {
                    AccessLevel newAccessLevel = (AccessLevel)pvSrc.ReadByte();
                    if (a.AccessLevel != newAccessLevel)
                    {
                        if (newAccessLevel >= state.Account.AccessLevel)
                        {
                            state.Send(new MessageBoxMessage("Warning: You may not set an access level greater than or equal to your own.", "Account Access Level update denied."));
                        }
                        else
                        {
                            a.AccessLevel = newAccessLevel;
                        }
                    }
                    bool newBanned = pvSrc.ReadBoolean();
                    if (newBanned != a.Banned)
                    {
                        oldbanned = a.Banned;
                        a.Banned  = newBanned;
                        a.Comments.Add(new AccountComment(state.Account.Username, newBanned ? "Banned via Remote Admin" : "Unbanned via Remote Admin"));
                    }
                }
                else
                {
                    pvSrc.ReadInt16();                    //skip both
                    state.Send(new MessageBoxMessage("Warning: When editing your own account, Account Status and Access Level cannot be changed.", "Editing Own Account"));
                }

                ArrayList list    = new ArrayList();
                ushort    length  = pvSrc.ReadUInt16();
                bool      invalid = false;
                for (int i = 0; i < length; i++)
                {
                    string add = pvSrc.ReadString();
                    if (Utility.IsValidIP(add))
                    {
                        list.Add(add);
                    }
                    else
                    {
                        invalid = true;
                    }
                }

                if (list.Count > 0)
                {
                    a.IPRestrictions = (string[])list.ToArray(typeof(string));
                }
                else
                {
                    a.IPRestrictions = new string[0];
                }

                if (invalid)
                {
                    state.Send(new MessageBoxMessage("Warning: one or more of the IP Restrictions you specified was not valid.", "Invalid IP Restriction"));
                }

                if (CreatedAccount)
                {
                    RemoteAdminLogging.WriteLine(state, "Created account {0} with Access Level {1}", a.Username, a.AccessLevel);
                }
                else
                {
                    string changes = string.Empty;
                    if (UpdatedPass)
                    {
                        changes += " Password Changed.";
                    }
                    if (oldAcessLevel != a.AccessLevel)
                    {
                        changes = string.Format("{0} Access level changed from {1} to {2}.", changes, oldAcessLevel, a.AccessLevel);
                    }
                    if (oldbanned != a.Banned)
                    {
                        changes += a.Banned ? " Banned." : " Unbanned.";
                    }
                    RemoteAdminLogging.WriteLine(state, "Updated account {0}:{1}", a.Username, changes);
                }

                state.Send(new MessageBoxMessage("Account updated successfully.", "Account Updated"));
            }
        }
        public override void OnResponse( NetState state, RelayInfo info )
        {
            Mobile from = state.Mobile;

            if ( m_Stone.Deleted )
                return;

            if ( info.ButtonID == 0 )
            {
                if ( m_Objects.Count > 0 && m_Objects[0] is Item )
                    from.SendMessage( "You decide not to bless this item." );
                else if ( m_Objects.Count > 0 && m_Objects[0] is Mobile )
                    from.SendMessage( "You decide not to bond this pet." );
            }
            if ( info.ButtonID == 1 )
            {
                if ( m_Stone.Currency.ToLower() == "daat99tokens" )
                {
                    Item[] tls = from.Backpack.FindItemsByType( typeof( TokenLedger ) );

                    TokenLedger ledger = null;

                    foreach( TokenLedger tl in tls )
                    {
                        if ( tl.Owner == from.Serial )
                        {
                            if ( ledger != null && tl.Tokens > ledger.Tokens )
                                ledger = tl;
                            else if ( ledger == null )
                                ledger = tl;
                        }
                    }

                    if ( ledger == null )
                    {
                        from.SendMessage( "You do not have a token ledger." );
                        return;
                    }
                    else if ( ledger.Tokens < m_VSI.BBPrice )
                    {
                        from.SendMessage( "Your ledger does not have enouh tokens in it to do this." );
                        return;
                    }

                    ledger.Tokens -= m_VSI.BBPrice;

                    for( int i = 0; i < m_Objects.Count; i++ )
                    {
                        object o = m_Objects[i];

                        if ( o is Item )
                            ((Item)o).LootType = LootType.Blessed;
                        if ( o is Mobile && (Mobile)o is BaseCreature )
                            ((BaseCreature)o).IsBonded = true;
                    }
                }
                else if ( from.Backpack.ConsumeTotal( m_Stone.GetCurrency(), m_VSI.BBPrice, true ) || m_VSI.BBPrice == 0 )
                {
                    for( int i = 0; i < m_Objects.Count; i++ )
                    {
                        object o = m_Objects[i];

                        if ( o is Item )
                            ((Item)o).LootType = LootType.Blessed;
                        if ( o is Mobile && (Mobile)o is BaseCreature )
                            ((BaseCreature)o).IsBonded = true;
                    }
                }
                else if ( from.BankBox.ConsumeTotal( m_Stone.GetCurrency(), m_VSI.BBPrice, true ) )
                {
                    for( int i = 0; i < m_Objects.Count; i++ )
                    {
                        object o = m_Objects[i];

                        if ( o is Item )
                            ((Item)o).LootType = LootType.Blessed;
                        if ( o is Mobile && (Mobile)o is BaseCreature )
                            ((BaseCreature)o).IsBonded = true;
                    }
                }
                else
                    from.SendMessage( "You cannot not afford to do this." );
            }
        }
Example #48
0
 public void OnReadTest2(NetState netstate, TestPackageReader pakcage)
 {
     if (pakcage.IsTouchRead)
         IsTouchPackageReader = true;
 }
Example #49
0
 public override void OnCancel(NetState state)
 {
     state.Mobile.SendMenu(new EquipMenu(state.Mobile, m_Mobile, ViewEqTarget.GetEquip(m_Mobile)));
 }
Example #50
0
 private static void ServerInfoRequest(NetState state, PacketReader pvSrc)
 {
     state.Send(AdminNetwork.Compress(new ServerInfo()));
 }
        public override void OnResponse( NetState state, RelayInfo info )
        {
            Mobile from = state.Mobile;

            if ( m_Stone.Deleted )
                return;

            if ( info.ButtonID == 0 )
            {
                from.SendMessage( "Back." );
                from.SendGump( new VendorGump( new VSShopper( from, m_Stone ), m_Stone ) );
            }
            if ( info.ButtonID == 1 )
            {
                string item = "";
                string gumpname = "";
                int price = 0;
                int amount = 0;
                int bbprice = 0;
                bool blessbond = info.IsSwitched( 1 );
                string description = "";

                string[] tr = new string[ 6 ];
                foreach( TextRelay t in info.TextEntries )
                {
                    tr[ t.EntryID ] = t.Text;
                }

                try { price = (int) uint.Parse( tr[ 2 ] ); }
                catch {}
                try { amount = (int) uint.Parse( tr[ 3 ] ); }
                catch {}
                try { bbprice = (int) uint.Parse( tr[ 4 ] ); }
                catch {}
                if ( tr[ 0 ] != null )
                    item = tr[ 0 ];
                if ( tr[ 0 ] != null )
                    gumpname = tr[ 1 ];
                if ( tr[ 5 ] != null )
                    description = tr[ 5 ];

                m_VSI.Item = item;
                m_VSI.Name = gumpname;
                m_VSI.Price = price;
                m_VSI.Amount = amount;
                m_VSI.BBPrice = bbprice;
                m_VSI.BlessBond = blessbond;
                m_VSI.Description = description;

                from.SendGump( new VendorGump( new VSShopper( from, m_Stone ), m_Stone ) );
            }
            if ( info.ButtonID == 2 )
            {
                if ( m_Stone.ItemList.Contains( m_VSI ) )
                    m_Stone.ItemList.Remove( m_VSI );

                from.SendGump( new VendorGump( new VSShopper( from, m_Stone ), m_Stone ) );
            }
        }
Example #52
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Box.Deleted)
            {
                return;
            }

            if (info.ButtonID == 1)
            {
                m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                m_Box.BeginCombine(m_From);
            }

            if (info.ButtonID == 3)
            {
                if (m_Box.Board > m_Box.WithdrawIncrement)
                {
                    m_From.AddToBackpack(new Board(m_Box.WithdrawIncrement));
                    m_Box.Board = m_Box.Board - m_Box.WithdrawIncrement;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else if (m_Box.Board > 0)
                {
                    m_From.AddToBackpack(new Board(m_Box.Board));                                                       //Sends all stored ingots of whichever type to players backpack
                    m_Box.Board = 0;                                                                                    //Sets the count in the key back to 0
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));                                                    //Resets the gump with the new info
                }
                else
                {
                    m_From.SendMessage("You do not have any of that wood!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }

            if (info.ButtonID == 4)
            {
                if (m_Box.Pine > m_Box.WithdrawIncrement)
                {
                    m_From.AddToBackpack(new PineBoard(m_Box.WithdrawIncrement));
                    m_Box.Pine = m_Box.Pine - m_Box.WithdrawIncrement;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else if (m_Box.Pine > 0)
                {
                    m_From.AddToBackpack(new PineBoard(m_Box.Pine));
                    m_Box.Pine = 0;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that wood!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 5)
            {
                if (m_Box.Cedar > m_Box.WithdrawIncrement)
                {
                    m_From.AddToBackpack(new CedarBoard(m_Box.WithdrawIncrement));
                    m_Box.Cedar = m_Box.Cedar - m_Box.WithdrawIncrement;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else if (m_Box.Cedar > 0)
                {
                    m_From.AddToBackpack(new CedarBoard(m_Box.Cedar));
                    m_Box.Cedar = 0;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that wood!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 6)
            {
                if (m_Box.Cherry > m_Box.WithdrawIncrement)
                {
                    m_From.AddToBackpack(new CherryBoard(m_Box.WithdrawIncrement));
                    m_Box.Cherry = m_Box.Cherry - m_Box.WithdrawIncrement;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else if (m_Box.Cherry > 0)
                {
                    m_From.AddToBackpack(new CherryBoard(m_Box.Cherry));
                    m_Box.Cherry = 0;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that wood!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 7)
            {
                if (m_Box.Mahogany > m_Box.WithdrawIncrement)
                {
                    m_From.AddToBackpack(new MahoganyBoard(m_Box.WithdrawIncrement));
                    m_Box.Mahogany = m_Box.Mahogany - m_Box.WithdrawIncrement;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else if (m_Box.Mahogany > 0)
                {
                    m_From.AddToBackpack(new MahoganyBoard(m_Box.Mahogany));
                    m_Box.Mahogany = 0;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that wood!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 8)
            {
                if (m_Box.Oak > m_Box.WithdrawIncrement)
                {
                    m_From.AddToBackpack(new OakBoard(m_Box.WithdrawIncrement));
                    m_Box.Oak = m_Box.Oak - m_Box.WithdrawIncrement;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else if (m_Box.Oak > 0)
                {
                    m_From.AddToBackpack(new OakBoard(m_Box.Oak));
                    m_Box.Oak = 0;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that wood!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 9)
            {
                if (m_Box.Ash > m_Box.WithdrawIncrement)
                {
                    m_From.AddToBackpack(new AshBoard(m_Box.WithdrawIncrement));
                    m_Box.Ash = m_Box.Ash - m_Box.WithdrawIncrement;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else if (m_Box.Ash > 0)
                {
                    m_From.AddToBackpack(new AshBoard(m_Box.Ash));
                    m_Box.Ash = 0;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that wood!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 10)
            {
                if (m_Box.Yew > m_Box.WithdrawIncrement)
                {
                    m_From.AddToBackpack(new YewBoard(m_Box.WithdrawIncrement));
                    m_Box.Yew = m_Box.Yew - m_Box.WithdrawIncrement;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else if (m_Box.Yew > 0)
                {
                    m_From.AddToBackpack(new YewBoard(m_Box.Yew));
                    m_Box.Yew = 0;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that wood!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 11)
            {
                if (m_Box.Bloodwood > m_Box.WithdrawIncrement)
                {
                    m_From.AddToBackpack(new BloodwoodBoard(m_Box.WithdrawIncrement));
                    m_Box.Bloodwood = m_Box.Bloodwood - m_Box.WithdrawIncrement;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else if (m_Box.Bloodwood > 0)
                {
                    m_From.AddToBackpack(new BloodwoodBoard(m_Box.Bloodwood));
                    m_Box.Bloodwood = 0;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that wood!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 12)
            {
                if (m_Box.Heartwood > m_Box.WithdrawIncrement)
                {
                    m_From.AddToBackpack(new HeartwoodBoard(m_Box.WithdrawIncrement));
                    m_Box.Heartwood = m_Box.Heartwood - m_Box.WithdrawIncrement;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else if (m_Box.Heartwood > 0)
                {
                    m_From.AddToBackpack(new HeartwoodBoard(m_Box.Heartwood));
                    m_Box.Heartwood = 0;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that wood!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 13)
            {
                if (m_Box.Frostwood > m_Box.WithdrawIncrement)
                {
                    m_From.AddToBackpack(new FrostwoodBoard(m_Box.WithdrawIncrement));
                    m_Box.Frostwood = m_Box.Frostwood - m_Box.WithdrawIncrement;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else if (m_Box.Frostwood > 0)
                {
                    m_From.AddToBackpack(new FrostwoodBoard(m_Box.Frostwood));
                    m_Box.Frostwood = 0;
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that wood!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 14)
            {
                if (m_Box.Saw > 0)
                {
                    m_From.AddToBackpack(new Saw(m_Box.Saw));
                    m_Box.Saw = (0);
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that item!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 15)
            {
                if (m_Box.Fletcher > 0)
                {
                    m_From.AddToBackpack(new FletcherTools(m_Box.Fletcher));
                    m_Box.Fletcher = (0);
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that item!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 16)
            {
                if (m_Box.RunicPine > 0)
                {
                    m_From.AddToBackpack(new RunicPi(m_Box.RunicPine));
                    m_Box.RunicPine = (0);
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that item!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 17)
            {
                if (m_Box.RunicCedar > 0)
                {
                    m_From.AddToBackpack(new RunicCe(m_Box.RunicCedar));
                    m_Box.RunicCedar = (0);
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that item!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 18)
            {
                if (m_Box.RunicCherry > 0)
                {
                    m_From.AddToBackpack(new RunicCh(m_Box.RunicCherry));
                    m_Box.RunicCherry = (0);
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that item!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 19)
            {
                if (m_Box.RunicMahogany > 0)
                {
                    m_From.AddToBackpack(new RunicMa(m_Box.RunicMahogany));
                    m_Box.RunicMahogany = (0);
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that item!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 20)
            {
                if (m_Box.RunicOak > 0)
                {
                    m_From.AddToBackpack(new RunicOa(m_Box.RunicOak));
                    m_Box.RunicOak = (0);
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that item!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
            if (info.ButtonID == 21)
            {
                if (m_Box.Hammer > 0)
                {
                    m_From.AddToBackpack(new Hammer(m_Box.Hammer));
                    m_Box.Hammer = (0);
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                }
                else
                {
                    m_From.SendMessage("You do not have any of that item!");
                    m_From.SendGump(new WoodBoxGump(m_From, m_Box));
                    m_Box.BeginCombine(m_From);
                }
            }
        }
        public override void OnResponse( NetState state, RelayInfo info )
        {
            base.OnResponse( state, info );

            if( info.ButtonID >= 1 && info.ButtonID <= 8 )
                state.Mobile.SendGump( new WeaponStoneGump(state.Mobile, m_Stone, info.ButtonID ) );
            else if( info.ButtonID != 0 )
            {
                if( m_Stone.UseLimit )
                {
                    bool foundName = false;
                    foreach( WeaponStone.WeaponStoneEntry nameEntry in m_Stone.m_alNameList )
                    {
                        if( nameEntry.m_sName == state.Mobile.Account.ToString() )
                        {
                            foundName = true;
                            if( nameEntry.m_iCount < m_iAmountToGive )
                                nameEntry.m_iCount++;
                            else
                            {
                                state.Mobile.SendMessage( "You may not take anymore items from this stone." );
                                return;
                            }
                        }
                    }

                    if( !foundName )
                        m_Stone.m_alNameList.Add( new WeaponStone.WeaponStoneEntry( state.Mobile.Account.ToString(), 1 ) );
                }

                ItemEntry entry = (ItemEntry)m_MainTable[info.ButtonID-999];

                Item item = (Item) Activator.CreateInstance( entry.m_Type );
                if( item.Stackable )
                    item.Amount = m_iStackableAmount;

                state.Mobile.AddToBackpack( item );

                state.Mobile.SendMessage( "The {0} has been placed into your packpack.", entry.m_sName );
                state.Mobile.SendGump( new WeaponStoneGump(state.Mobile, m_Stone, m_iPos ) );
            }
        }
Example #54
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                var switches = info.Switches;

                if (switches.Length > 0)
                {
                    int index  = switches[0] % m_Entries.Length;
                    int offset = switches[0] / m_Entries.Length;

                    if (index >= 0 && index < m_Entries.Length)
                    {
                        if (offset >= 0 && offset < m_Entries[index].Hues.Length)
                        {
                            if (m_Hair && m_From.HairItemID > 0 || m_FacialHair && m_From.FacialHairItemID > 0)
                            {
                                if (m_Price > 0 && !Banker.Withdraw(m_From, m_Price))
                                {
                                    if (m_Vendor != null)
                                    {
                                        m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1042293, m_From.NetState);
                                    }
                                    // You cannot afford my services for that style.

                                    return;
                                }

                                int hue = m_Entries[index].Hues[offset];

                                if (m_Hair)
                                {
                                    m_From.HairHue = hue;
                                }

                                if (m_FacialHair)
                                {
                                    m_From.FacialHairHue = hue;
                                }
                            }
                            else
                            {
                                if (m_Vendor != null)
                                {
                                    m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502623, m_From.NetState); // You have no hair to dye and you cannot use this.
                                }
                                else
                                {
                                    m_From.SendLocalizedMessage(502623);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (m_Vendor != null)
                    {
                        m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1013009, m_From.NetState); // You decide not to change your hairstyle.
                    }
                    else
                    {
                        m_From.SendLocalizedMessage(1013009);
                    }
                }
            }
            else
            {
                // You decide not to change your hairstyle.
                m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1013009, m_From.NetState);
            }
        }
        public override void OnResponse( NetState sender, RelayInfo info )
        {
            Mobile from  = sender.Mobile;

            if ( info.ButtonID >= 1 )
            {
                BaseAddon addon = new VinyardGroundAddon( info.ButtonID-1, m_Width, m_Height );

                Server.Spells.SpellHelper.GetSurfaceTop( ref m_P3D );

                ArrayList houses = null;

                AddonFitResult res = addon.CouldFit( m_P3D, m_Map, from, ref houses );

                if ( res == AddonFitResult.Valid )
                    addon.MoveToWorld( new Point3D( m_P3D ), m_Map );
                else if ( res == AddonFitResult.Blocked )
                    from.SendLocalizedMessage( 500269 ); // You cannot build that there.
                else if ( res == AddonFitResult.NotInHouse )
                    from.SendLocalizedMessage( 500274 ); // You can only place this in a house that you own!
                else if ( res == AddonFitResult.DoorsNotClosed )
                    from.SendMessage( "You must close all house doors before placing this." );

                if ( res == AddonFitResult.Valid )
                {
                    m_Deed.Delete();

                    if ( houses != null )
                    {
                        foreach ( Server.Multis.BaseHouse h in houses )
                            h.Addons.Add( addon );

                        from.SendGump( new VinyardGroundPlacedGump( m_Deed ) );
                    }
                }
                else
                {
                    addon.Delete();
                }
            }
        }
Example #56
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (!m_FacialHair || !m_Female)
            {
                if (info.ButtonID == 1)
                {
                    var switches = info.Switches;

                    if (switches.Length > 0)
                    {
                        int  index  = switches[0];
                        bool female = m_Female;

                        if (index >= 0 && index < m_Entries.Length)
                        {
                            ChangeHairstyleEntry entry = m_Entries[index];

                            if (m_From is PlayerMobile)
                            {
                                ((PlayerMobile)m_From).SetHairMods(-1, -1);
                            }

                            int hairID       = m_From.HairItemID;
                            int facialHairID = m_From.FacialHairItemID;
                            int itemID       = female ? entry.ItemID_Female : entry.ItemID_Male;

                            if (itemID == 0)
                            {
                                bool invalid = m_FacialHair ? (facialHairID == 0) : (hairID == 0);

                                if (!invalid)
                                {
                                    if (m_Token != null)
                                    {
                                        m_Token.OnChangeHairstyle(m_From, m_FacialHair, 0);
                                        return;
                                    }

                                    if (Banker.Withdraw(m_From, m_Price, true))
                                    {
                                        if (m_FacialHair)
                                        {
                                            m_From.FacialHairItemID = 0;
                                        }
                                        else
                                        {
                                            m_From.HairItemID = 0;
                                        }
                                    }
                                    else
                                    {
                                        if (m_Vendor != null)
                                        {
                                            m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1042293, m_From.NetState);
                                            // You cannot afford my services for that style.
                                        }
                                        else
                                        {
                                            m_From.SendLocalizedMessage(1042293);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                bool invalid = m_FacialHair ? facialHairID > 0 && facialHairID == itemID : hairID > 0 && hairID == itemID;

                                if (!invalid)
                                {
                                    if (m_Price <= 0 || Banker.Withdraw(m_From, m_Price))
                                    {
                                        if (m_Token != null)
                                        {
                                            m_Token.OnChangeHairstyle(m_From, m_FacialHair, itemID);
                                            return;
                                        }

                                        if (m_FacialHair)
                                        {
                                            m_From.FacialHairItemID = itemID;

                                            if (itemID != 0)
                                            {
                                                m_From.FacialHairHue = m_From.HairHue;
                                            }
                                        }
                                        else
                                        {
                                            m_From.HairItemID = itemID;
                                        }
                                    }
                                    else
                                    {
                                        if (m_Vendor != null)
                                        {
                                            m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1042293, m_From.NetState);
                                            // You cannot afford my services for that style.
                                        }
                                        else
                                        {
                                            m_From.SendLocalizedMessage(1042293);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (m_Vendor != null)
                        {
                            // You decide not to change your hairstyle.
                            m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1013009, m_From.NetState);
                        }
                        else
                        {
                            m_From.SendLocalizedMessage(1013009); // You decide not to change your hairstyle.
                        }
                    }
                }
                else
                {
                    if (m_Vendor != null)
                    {
                        // You decide not to change your hairstyle.
                        m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1013009, m_From.NetState);
                    }
                    else
                    {
                        m_From.SendLocalizedMessage(1013009); // You decide not to change your hairstyle.
                    }
                }
            }

            if (m_Token != null)
            {
                m_Token.OnFailedHairstyle(m_From, m_FacialHair);
            }
        }
Example #57
0
 public void OnReadTest(NetState netstate, PacketReader reader)
 {
     IsTouchOnReadTest = true;
 }
Example #58
0
            public override void OnResponse(NetState sender, RelayInfo info)
            {
                if (m_Chest.Deleted || info.ButtonID == 0 || !m_From.CheckAlive())
                {
                    return;
                }

                if (m_From.IsPlayer() && (m_From.Map != m_Chest.Map || !m_From.InRange(m_Chest.GetWorldLocation(), 2)))
                {
                    m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500446); // That is too far away.
                    return;
                }

                if (info.ButtonID == 1)
                {
                    m_Chest.SubmitSolution(m_From, m_Solution);
                }
                else
                {
                    if (info.Switches.Length == 0)
                    {
                        return;
                    }

                    int pedestal = info.Switches[0];
                    if (pedestal < 0 || pedestal >= m_Solution.Cylinders.Length)
                    {
                        return;
                    }

                    PuzzleChestCylinder cylinder;
                    switch (info.ButtonID)
                    {
                    case 10:
                        cylinder = PuzzleChestCylinder.LightBlue;
                        break;

                    case 11:
                        cylinder = PuzzleChestCylinder.Blue;
                        break;

                    case 12:
                        cylinder = PuzzleChestCylinder.Green;
                        break;

                    case 13:
                        cylinder = PuzzleChestCylinder.Orange;
                        break;

                    case 14:
                        cylinder = PuzzleChestCylinder.Purple;
                        break;

                    case 15:
                        cylinder = PuzzleChestCylinder.Red;
                        break;

                    case 16:
                        cylinder = PuzzleChestCylinder.DarkBlue;
                        break;

                    case 17:
                        cylinder = PuzzleChestCylinder.Yellow;
                        break;

                    default:
                        return;
                    }

                    m_Solution.Cylinders[pedestal] = cylinder;

                    m_From.SendGump(new PuzzleGump(m_From, m_Chest, m_Solution, pedestal));
                }
            }
Example #59
0
 public void OnReadTest3(NetState netstate, int i, string s, double d, bool b)
 {
     IsTouchSimpleMethod = true;
 }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            if (info.ButtonID == 0 || m_hive.Deleted || !from.InRange(m_hive.GetWorldLocation(), 3))
            {
                return;
            }

            if (!m_hive.IsAccessibleTo(from))
            {
                m_hive.LabelTo(from, "You cannot use that.");
                return;
            }

            switch (info.ButtonID)
            {
            case 1:                     //Resources
            {
                from.SendGump(new apiBeeHiveProductionGump(from, m_hive));
                break;
            }

            case 2:                     //Destroy
            {
                from.SendGump(new apiBeeHiveDestroyGump(from, m_hive));
                break;
            }

            case 3:                     //Help
            {
                from.SendGump(new apiBeeHiveMainGump(from, m_hive));
                from.SendGump(new apiBeeHiveHelpGump(from, 0));
                break;
            }

            case 4:                     //Agility Potion
            {
                AddPotion(from, PotionEffect.AgilityGreater);

                break;
            }

            case 5:                     //Poison Potion
            {
                AddPotion(from, PotionEffect.PoisonGreater, PotionEffect.PoisonDeadly);

                break;
            }

            case 6:                     //Cure Potion
            {
                AddPotion(from, PotionEffect.CureGreater);

                break;
            }

            case 7:                     //Heal Potion
            {
                AddPotion(from, PotionEffect.HealGreater);

                break;
            }

            case 8:                     //Strength Potion
            {
                AddPotion(from, PotionEffect.StrengthGreater);

                break;
            }

            case 9:     // switch dormant
            {
                if (m_hive.HiveStage != HiveStatus.Empty)
                {
                    from.SendGump(new SwitchDormantGump(from, m_hive));
                }
                else
                {
                    from.SendMessage("The hive is already empty.");
                }
                break;
            }
            }
        }