Exemplo n.º 1
0
        public static void EquipLastWeaponRequest(NetState state, IEntity e, EncodedReader reader)
        {
            PlayerMobile from = state.Mobile as PlayerMobile;

            if (from != null)
            {
                if (from.LastWeapon != null && from.LastWeapon.IsChildOf(from.Backpack))
                {
                    Item toEquip  = from.LastWeapon;
                    Item toDisarm = from.FindItemOnLayer(Layer.OneHanded);

                    if (toDisarm == null || !toDisarm.Movable)
                    {
                        toDisarm = from.FindItemOnLayer(Layer.TwoHanded);
                    }

                    if (toDisarm != null && toDisarm.Movable)
                    {
                        from.Backpack.DropItem(toDisarm);
                    }

                    from.EquipItem(toEquip);
                }
            }
        }
Exemplo n.º 2
0
        public static void EquipLastWeaponRequest(NetState state, IEntity e, EncodedReader reader)
        {
            if (!(state.Mobile is PlayerMobile from) || from.Backpack == null)
            {
                return;
            }

            if (from.IsStaff() || Core.TickCount - from.NextActionTime >= 0)
            {
                BaseWeapon toEquip = from.LastWeapon;

                if (!(from.FindItemOnLayer(Layer.OneHanded) is BaseWeapon toDisarm))
                {
                    toDisarm = from.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon;
                }

                if (toDisarm != null)
                {
                    from.Backpack.DropItem(toDisarm);
                    from.NextActionTime = Core.TickCount + Mobile.ActionDelay;
                }

                if (toEquip != toDisarm && toEquip != null && toEquip.Movable && toEquip.IsChildOf(from.Backpack))
                {
                    from.EquipItem(toEquip);
                    from.NextActionTime = Core.TickCount + Mobile.ActionDelay;
                }
            }
            else
            {
                from.SendActionMessage();
            }
        }
Exemplo n.º 3
0
        public static void QuestButton(NetState state, IEntity e, EncodedReader reader) 
        {
            if (state.Mobile is PlayerMobile)
            {
                PlayerMobile from = (PlayerMobile)state.Mobile;
				
                from.CloseGump(typeof(MondainQuestGump));
                from.SendGump(new MondainQuestGump(from));
            }
        }
Exemplo n.º 4
0
        public static void QuestButton( GameClient state, IEntity e, EncodedReader reader )
        {
            if ( state.Mobile is PlayerMobile )
            {
                PlayerMobile from = (PlayerMobile) state.Mobile;

                from.CloseGump( typeof( BaseQuestGump ) );
                from.SendGump( new MLQuestMainLogGump( from ) );
            }
        }
Exemplo n.º 5
0
		public static void SetAbility( NetState state, IEntity e, EncodedReader reader )
		{
			EventSink.InvokeSetAbility( new SetAbilityEventArgs( state.Mobile, reader.ReadInt32() ) );
		}
Exemplo n.º 6
0
 public void EquipLastWeaponMacro( GameClient state, IEntity e, EncodedReader reader )
 {
     EventSink.Instance.InvokeEquipLastWeaponMacroUsed( new EquipLastWeaponMacroEventArgs( state.Mobile ) );
 }
Exemplo n.º 7
0
        public static void Designer_Stairs( NetState state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                /* Client chose to add stairs
                 *  - Read data detailing stair type and location
                 *  - Validate stair multi ID
                 *  - Add the stairs
                 *     - Load data describing the stair components
                 *     - Insert described components
                 *  - Update revision
                 */

                // Read data detailing stair type and location
                int itemID = pvSrc.ReadInt32();
                int x = pvSrc.ReadInt32();
                int y = pvSrc.ReadInt32();

                // Validate stair multi ID
                DesignState design = context.Foundation.DesignState;

                if ( itemID < 0x1DB0 || itemID > 0x1DD7 )
                {
                    /* Specified multi ID is not a stair
                     *  - Resend design state
                     *  - Return without further processing
                     */

                    design.SendDetailedInfoTo( state );
                    return;
                }

                // Add the stairs
                MultiComponentList mcl = design.Components;

                // Add the stairs : Load data describing stair components
                MultiComponentList stairs = MultiData.GetComponents( itemID );

                // Add the stairs : Insert described components
                int z = GetLevelZ( context.Level );

                for ( int i = 0; i < stairs.List.Length; ++i )
                {
                    MultiTileEntry entry = stairs.List[i];

                    if ( (entry.m_ItemID & 0x3FFF) != 1 )
                        mcl.Add( entry.m_ItemID, x + entry.m_OffsetX, y + entry.m_OffsetY, z + entry.m_OffsetZ );
                }

                // Update revision
                design.OnRevised();
            }
        }
Exemplo n.º 8
0
        public static void Designer_Roof( NetState state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                // Read data detailing component graphic and location
                int itemID = pvSrc.ReadInt32();
                int x = pvSrc.ReadInt32();
                int y = pvSrc.ReadInt32();
                int z = pvSrc.ReadInt32();

                // Add component
                DesignState design = context.Foundation.DesignState;

                if ( (TileData.ItemTable[itemID & 0x3FFF].Flags & TileFlag.Roof) == 0 )
                {
                    design.SendDetailedInfoTo( state );
                    return;
                }

                MultiComponentList mcl = design.Components;

                if ( z < -3 || z > 12 || z % 3 > 0 )
                    z = 0;
                z += GetLevelZ( context.Level );

                MultiTileEntry[] list = mcl.List;
                for ( int i = 0; i < list.Length; i++ )
                {
                    MultiTileEntry mte = list[i];

                    if ( mte.m_OffsetX == x && mte.m_OffsetY == y && (TileData.ItemTable[mte.m_ItemID & 0x3FFF].Flags & TileFlag.Roof) != 0 )
                        mcl.Remove( mte.m_ItemID, x, y, mte.m_OffsetZ );
                }

                mcl.Add( itemID, x, y, z );

                // Update revision
                design.OnRevised();
            }
        }
Exemplo n.º 9
0
        public static void Designer_Restore( NetState state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                /* Client chose to restore design to the last backup state
                 *  - Restore backup
                 *     - Construct new design state from backup state
                 *     - Assign constructed state to foundation
                 *  - Update revision
                 *  - Update client with new state
                 */

                // Restore backup : Construct new design state from backup state
                DesignState backupDesign = new DesignState( context.Foundation.BackupState );

                // Restore backup : Assign constructed state to foundation
                context.Foundation.DesignState = backupDesign;

                // Update revision;
                backupDesign.OnRevised();

                // Update client with new state
                context.Foundation.SendInfoTo( state );
                backupDesign.SendDetailedInfoTo( state );
            }
        }
Exemplo n.º 10
0
        public static void Designer_Delete( NetState state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                /* Client chose to delete a component
                 *  - Read data detailing which component to delete
                 *  - Verify component is deletable
                 *  - Remove the component
                 *  - If needed, replace removed component with a dirt tile
                 *  - Update revision
                 */

                // Read data detailing which component to delete
                int itemID = pvSrc.ReadInt32();
                int x = pvSrc.ReadInt32();
                int y = pvSrc.ReadInt32();
                int z = pvSrc.ReadInt32();

                // Verify component is deletable
                DesignState design = context.Foundation.DesignState;
                MultiComponentList mcl = design.Components;

                int ax = x + mcl.Center.X;
                int ay = y + mcl.Center.Y;

                if ( IsSignHanger( itemID ) || (z == 0 && ax >= 0 && ax < mcl.Width && ay >= 0 && ay < (mcl.Height - 1)) )
                {
                    /* Component is not deletable
                     *  - Resend design state
                     *  - Return without further processing
                     */

                    design.SendDetailedInfoTo( state );
                    return;
                }

                // Remove the component
                if ( !DeleteStairs( mcl, itemID, x, y, z ) )
                    mcl.Remove( itemID, x, y, z );

                // If needed, replace removed component with a dirt tile
                if ( ax >= 1 && ax < mcl.Width && ay >= 1 && ay < mcl.Height - 1 )
                {
                    Tile[] tiles = mcl.Tiles[ax][ay];

                    bool hasBaseFloor = false;

                    for ( int i = 0; !hasBaseFloor && i < tiles.Length; ++i )
                        hasBaseFloor = ( tiles[i].Z == 7 && (tiles[i].ID & 0x3FFF) != 1 );

                    if ( !hasBaseFloor )
                    {
                        // Replace with a dirt tile
                        mcl.Add( 0x31F4, x, y, 7 );
                    }
                }

                // Update revision
                design.OnRevised();
            }
        }
Exemplo n.º 11
0
		public static void Designer_Commit(NetState state, IEntity e, EncodedReader pvSrc)
		{
			Mobile from = state.Mobile;
			DesignContext context = DesignContext.Find(from);

			if (context != null)
			{
				int oldPrice = context.Foundation.Price;
				int newPrice = oldPrice + context.Foundation.CustomizationCost +
							   ((context.Foundation.DesignState.Components.List.Length -
								 (context.Foundation.CurrentState.Components.List.Length + context.Foundation.Fixtures.Count)) * 500);

				Type cType = context.Foundation.Expansion == Expansion.T2A ? typeof(Silver) : typeof(Gold);

				int bankBalance = Banker.GetBalance(from, cType);

				from.SendGump(new ConfirmCommitGump(from, context.Foundation, bankBalance, oldPrice, newPrice));
			}
		}
Exemplo n.º 12
0
        public static void Designer_Build( NetState state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                /* Client chose to add a component
                 *  - Read data detailing component graphic and location
                 *  - Add component
                 *  - Update revision
                 */

                // Read data detailing component graphic and location
                int itemID = pvSrc.ReadInt32();
                int x = pvSrc.ReadInt32();
                int y = pvSrc.ReadInt32();

                // Add component
                DesignState design = context.Foundation.DesignState;
                MultiComponentList mcl = design.Components;

                int z = GetLevelZ( context.Level );

                if ( (y + mcl.Center.Y) == (mcl.Height - 1) )
                    z = 0; // Tiles placed on the far-south of the house are at 0 Z

                mcl.Add( itemID, x, y, z );

                // Update revision
                design.OnRevised();
            }
        }
Exemplo n.º 13
0
 public void QuestGumpRequest( GameClient state, IEntity e, EncodedReader reader )
 {
     EventSink.Instance.InvokeQuestGumpRequest( new QuestGumpRequestArgs( state.Mobile ) );
 }
Exemplo n.º 14
0
 public static void GuildGumpRequest(NetState state, IEntity e, EncodedReader reader)
 {
     EventSink.InvokeGuildGumpRequest(state.Mobile);
 }
Exemplo n.º 15
0
        public static void Designer_Build( GameClient state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                /* Client chose to add a component
                 *  - Read data detailing component graphic and location
                 *  - Add component
                 *  - Update revision
                 */

                // Read data detailing component graphic and location
                int itemID = pvSrc.ReadInt32();
                int x = pvSrc.ReadInt32();
                int y = pvSrc.ReadInt32();

                // Add component
                DesignState design = context.Foundation.DesignState;

                if ( from.AccessLevel < AccessLevel.GameMaster && !ValidPiece( itemID ) )
                {
                    TraceValidity( state, itemID );
                    design.SendDetailedInfoTo( state );
                    return;
                }

                MultiComponentList mcl = design.Components;

                int z = GetLevelZ( context.Level, context.Foundation );

                if ( ( y + mcl.Center.Y ) == ( mcl.Height - 1 ) )
                    z = 0; // Tiles placed on the far-south of the house are at 0 Z

                mcl.Add( itemID, x, y, z );

                // Update revision
                design.OnRevised();
            }
        }
Exemplo n.º 16
0
        public static void QuestButton(NetState state, IEntity e, EncodedReader reader)
        {
            if (state == null || state.Mobile == null) return;
            Mobile from = state.Mobile;

            from.CloseGump(typeof(QuestLogGump));
            // bring up the quest status gump
            from.SendGump(new QuestLogGump(from));
        }
Exemplo n.º 17
0
		public static void QuestGumpRequest( NetState state, IEntity e, EncodedReader reader )
		{
			EventSink.InvokeQuestGumpRequest( new QuestGumpRequestArgs( state.Mobile ) );
		}
Exemplo n.º 18
0
        public static void Designer_Close( NetState state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                /* Client closed his house design window
                 *  - Remove design context
                 *  - Notify the client that customization has ended
                 *  - Refresh client with current visable design state
                 *  - If a signpost is needed, add it
                 *  - Eject all from house
                 *  - Restore relocated entities
                 */

                // Remove design context
                DesignContext.Remove( from );

                // Notify the client that customization has ended
                from.Send( new EndHouseCustomization( context.Foundation ) );

                // Refresh client with current visible design state
                context.Foundation.SendInfoTo( state );
                context.Foundation.CurrentState.SendDetailedInfoTo( state );

                // If a signpost is needed, add it
                context.Foundation.CheckSignpost();

                // Eject all from house
                from.RevealingAction();

                foreach ( Item item in context.Foundation.GetItems() )
                    item.Location = context.Foundation.BanLocation;

                foreach ( Mobile mobile in context.Foundation.GetMobiles() )
                    mobile.Location = context.Foundation.BanLocation;

                // Restore relocated entities
                context.Foundation.RestoreRelocatedEntities();
            }
        }
Exemplo n.º 19
0
        public static void Designer_Backup( NetState state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                /* Client chose to backup design state
                 *  - Construct a copy of the current design state
                 *  - Assign constructed state to backup state field
                 */

                // Construct a copy of the current design state
                DesignState copyState = new DesignState( context.Foundation.DesignState );

                // Assign constructed state to backup state field
                context.Foundation.BackupState = copyState;
            }
        }
Exemplo n.º 20
0
 public void SetAbility( GameClient state, IEntity e, EncodedReader reader )
 {
     EventSink.Instance.InvokeSetAbility( new SetAbilityEventArgs( state.Mobile, reader.ReadInt32() ) );
 }
Exemplo n.º 21
0
        public static void Designer_Clear( NetState state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                /* Client chose to clear the design
                 *  - Restore empty foundation
                 *     - Construct new design state from empty foundation
                 *     - Assign constructed state to foundation
                 *  - Update revision
                 *  - Update client with new state
                 */

                // Restore empty foundation : Construct new design state from empty foundation
                DesignState newDesign = new DesignState( context.Foundation, context.Foundation.GetEmptyFoundation() );

                // Restore empty foundation : Assign constructed state to foundation
                context.Foundation.DesignState = newDesign;

                // Update revision
                newDesign.OnRevised();

                // Update client with new state
                context.Foundation.SendInfoTo( state );
                newDesign.SendDetailedInfoTo( state );
            }
        }
Exemplo n.º 22
0
 public static void SetAbility(this NetState state, IEntity e, EncodedReader reader)
 {
     EventSink.InvokeSetAbility(state.Mobile, reader.ReadInt32());
 }
Exemplo n.º 23
0
        public static void Designer_Commit( NetState state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                int oldPrice = context.Foundation.Price;
                int newPrice = oldPrice + 10000 + ((context.Foundation.DesignState.Components.List.Length - context.Foundation.CurrentState.Components.List.Length) * 500);
                int bankBalance = Banker.GetBalance( from );

                from.SendGump( new ConfirmCommitGump( from, context.Foundation, bankBalance, oldPrice, newPrice ) );
            }
        }
Exemplo n.º 24
0
 public static void QuestGumpRequest(this NetState state, IEntity e, EncodedReader reader)
 {
     EventSink.InvokeQuestGumpRequest(state.Mobile);
 }
Exemplo n.º 25
0
        public static void Designer_Level( NetState state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                /* Client is moving to a new floor level
                 *  - Read data detailing the target level
                 *  - Validate target level
                 *  - Update design context with new level
                 *  - Teleport mobile to new level
                 *  - Update client
                 *
                 * TODO: Proper validation for two-story homes
                 */

                // Read data detailing the target level
                int newLevel = pvSrc.ReadInt32();

                // Validate target level
                if ( newLevel < 1 || newLevel > 4 )
                    newLevel = 1;

                // Update design context with new level
                context.Level = newLevel;

                // Teleport mobile to new level
                from.Location = new Point3D( from.X, from.Y, context.Foundation.Z + GetLevelZ( newLevel ) );

                // Update client
                context.Foundation.SendInfoTo( state );
            }
        }
Exemplo n.º 26
0
		public static void QuestButton(NetState state, IEntity e, EncodedReader reader)
		{
			if (state == null || state.Mobile == null) return;
			Mobile from = state.Mobile;

            from.CloseGump(typeof(XMLQuestLogGump));
			// bring up the quest status gump
            from.SendGump(new XMLQuestLogGump(from));

			// bring up the normal quest objectives gump
			//NormalQuestButton(from as PlayerMobile);
		}
Exemplo n.º 27
0
        public static void Designer_Revert( NetState state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                /* Client chose to revert design state to currently visible state
                 *  - Revert design state
                 *     - Construct a copy of the current visible state
                 *     - Freeze fixtures in constructed state
                 *     - Assign constructed state to foundation
                 *     - If a signpost is needed, add it
                 *  - Update revision
                 *  - Update client with new state
                 */

                // Revert design state : Construct a copy of the current visible state
                DesignState copyState = new DesignState( context.Foundation.CurrentState );

                // Revert design state : Freeze fixtures in constructed state
                copyState.FreezeFixtures();

                // Revert design state : Assign constructed state to foundation
                context.Foundation.DesignState = copyState;

                // Revert design state : If a signpost is needed, add it
                context.Foundation.CheckSignpost();

                // Update revision
                copyState.OnRevised();

                // Update client with new state
                context.Foundation.SendInfoTo( state );
                copyState.SendDetailedInfoTo( state );
            }
        }
Exemplo n.º 28
0
		public static void Designer_Roof( NetState state, IEntity e, EncodedReader pvSrc )
		{
			Mobile from = state.Mobile;
			DesignContext context = DesignContext.Find( from );

			if( context != null && (Core.SE || from.AccessLevel >= AccessLevel.GameMaster) )
			{
				// Read data detailing component graphic and location
				int itemID = pvSrc.ReadInt32();
				int x = pvSrc.ReadInt32();
				int y = pvSrc.ReadInt32();
				int z = pvSrc.ReadInt32();

				// Add component
				DesignState design = context.Foundation.DesignState;

				if( from.AccessLevel < AccessLevel.GameMaster && !ValidPiece( itemID, true ) )
				{
					TraceValidity( state, itemID );
					design.SendDetailedInfoTo( state );
					return;
				}

				MultiComponentList mcl = design.Components;

				if( z < -3 || z > 12 || z % 3 != 0 )
					z = -3;
				z += GetLevelZ( context.Level, context.Foundation );

				MultiTileEntry[] list = mcl.List;
				for( int i = 0; i < list.Length; i++ )
				{
					MultiTileEntry mte = list[i];

					if( mte.m_OffsetX == x && mte.m_OffsetY == y && GetZLevel( mte.m_OffsetZ, context.Foundation ) == context.Level  && (TileData.ItemTable[mte.m_ItemID & TileData.MaxItemValue].Flags & TileFlag.Roof) != 0 )
						mcl.Remove( mte.m_ItemID, x, y, mte.m_OffsetZ );
				}

				mcl.Add( itemID, x, y, z );

				// Update revision
				design.OnRevised();
			}
		}
Exemplo n.º 29
0
        public static void Designer_RoofDelete( NetState state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                // Read data detailing which component to delete
                int itemID = pvSrc.ReadInt32();
                int x = pvSrc.ReadInt32();
                int y = pvSrc.ReadInt32();
                int z = pvSrc.ReadInt32();

                // Verify component is deletable
                DesignState design = context.Foundation.DesignState;
                MultiComponentList mcl = design.Components;

                if ( (TileData.ItemTable[itemID & 0x3FFF].Flags & TileFlag.Roof) == 0 )
                {
                    design.SendDetailedInfoTo( state );
                    return;
                }

                mcl.Remove( itemID, x, y, z );

                design.OnRevised();
            }
        }
Exemplo n.º 30
0
		public static void Designer_RoofDelete( NetState state, IEntity e, EncodedReader pvSrc )
		{
			Mobile from = state.Mobile;
			DesignContext context = DesignContext.Find( from );

			if( context != null )	// No need to check for Core.SE if trying to remove something that shouldn't be able to be placed anyways
			{
				// Read data detailing which component to delete
				int itemID = pvSrc.ReadInt32();
				int x = pvSrc.ReadInt32();
				int y = pvSrc.ReadInt32();
				int z = pvSrc.ReadInt32();

				// Verify component is deletable
				DesignState design = context.Foundation.DesignState;
				MultiComponentList mcl = design.Components;

				if( (TileData.ItemTable[itemID & TileData.MaxItemValue].Flags & TileFlag.Roof) == 0 )
				{
					design.SendDetailedInfoTo( state );
					return;
				}

				mcl.Remove( itemID, x, y, z );

				design.OnRevised();
			}
		}
Exemplo n.º 31
0
        public static void Designer_Sync( NetState state, IEntity e, EncodedReader pvSrc )
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find( from );

            if ( context != null )
            {
                /* Client requested state synchronization
                 *  - Resend full house state
                 */

                DesignState design = context.Foundation.DesignState;

                // Resend full house state
                design.SendDetailedInfoTo( state );
            }
        }
Exemplo n.º 32
0
        public static void Designer_Close(NetState state, IEntity e, EncodedReader pvSrc)
        {
            Mobile from = state.Mobile;
            DesignContext context = DesignContext.Find(from);

            if (context != null)
            {
                /* Client closed his house design window
                 *  - Remove design context
                 *  - Notify the client that customization has ended
                 *  - Refresh client with current visable design state
                 *  - Eject client from house
                 *  - If a signpost is needed, add it
                 */

                // Remove design context
                DesignContext.Remove(from);

                // Notify the client that customization has ended
                from.Send(new EndHouseCustomization(context.Foundation));

                // Refresh client with current visible design state
                context.Foundation.SendInfoTo(state);
                context.Foundation.CurrentState.SendDetailedInfoTo(state);

                // Eject client from house
                from.RevealingAction();

                from.MoveToWorld(context.Foundation.BanLocation, context.Foundation.Map);

                // If a signpost is needed, add it
                context.Foundation.CheckSignpost();
            }
        }