diff --git a/Scripts/Commands/Add.cs b/Scripts/Commands/Add.cs index 2366b1f0e..2c652b776 100644 --- a/Scripts/Commands/Add.cs +++ b/Scripts/Commands/Add.cs @@ -157,7 +157,7 @@ namespace Server.Commands { ConstructorInfo ctor = ctors[i]; - if ( !IsConstructable( ctor ) ) + if ( !IsConstructable( ctor, from.AccessLevel ) ) continue; ParameterInfo[] paramList = ctor.GetParameters(); @@ -345,7 +345,7 @@ namespace Server.Commands { ConstructorInfo ctor = ctors[i]; - if ( !IsConstructable( ctor ) ) + if ( !IsConstructable( ctor, from.AccessLevel ) ) continue; if ( !foundCtor ) @@ -524,9 +524,14 @@ namespace Server.Commands private static Type m_ConstructableType = typeof( ConstructableAttribute ); - public static bool IsConstructable( ConstructorInfo ctor ) + public static bool IsConstructable( ConstructorInfo ctor, AccessLevel accessLevel ) { - return ctor.IsDefined( m_ConstructableType, false ); + object[] attrs = ctor.GetCustomAttributes( m_ConstructableType, false ); + + if ( attrs.Length == 0 ) + return false; + + return accessLevel >= ((ConstructableAttribute)attrs[0]).AccessLevel; } private static Type m_EnumType = typeof( Enum ); diff --git a/Scripts/Context Menus/AddToSpellbookEntry.cs b/Scripts/Context Menus/AddToSpellbookEntry.cs index 575a9c4b4..3ec24eccf 100644 --- a/Scripts/Context Menus/AddToSpellbookEntry.cs +++ b/Scripts/Context Menus/AddToSpellbookEntry.cs @@ -1,5 +1,6 @@ using System; using Server.Items; +using Server.Network; using Server.Targeting; namespace Server.ContextMenus @@ -29,7 +30,7 @@ namespace Server.ContextMenus { if ( targeted is Spellbook ) { - if ( from.CheckAlive() && !m_Scroll.Deleted && m_Scroll.Movable && m_Scroll.Amount >= 1 ) + if ( from.CheckAlive() && !m_Scroll.Deleted && m_Scroll.Movable && m_Scroll.Amount >= 1 && m_Scroll.CheckItemUse( from ) ) { Spellbook book = (Spellbook)targeted; diff --git a/Scripts/Context Menus/EatEntry.cs b/Scripts/Context Menus/EatEntry.cs index e3e3b53f0..83b21b9dd 100644 --- a/Scripts/Context Menus/EatEntry.cs +++ b/Scripts/Context Menus/EatEntry.cs @@ -16,7 +16,7 @@ namespace Server.ContextMenus public override void OnClick() { - if ( m_Food.Deleted || !m_Food.Movable || !m_From.CheckAlive() ) + if ( m_Food.Deleted || !m_Food.Movable || !m_From.CheckAlive() || !m_Food.CheckItemUse( m_From ) ) return; m_Food.Eat( m_From ); diff --git a/Scripts/Items/Skill Items/Magical/Scrolls/SpellScroll.cs b/Scripts/Items/Skill Items/Magical/Scrolls/SpellScroll.cs index a3567b1ee..c1f1c13b1 100644 --- a/Scripts/Items/Skill Items/Magical/Scrolls/SpellScroll.cs +++ b/Scripts/Items/Skill Items/Magical/Scrolls/SpellScroll.cs @@ -70,6 +70,7 @@ namespace Server.Items if ( from.Alive && this.Movable ) list.Add( new ContextMenus.AddToSpellbookEntry() ); } + public override void OnDoubleClick( Mobile from ) { diff --git a/Server/Attributes.cs b/Server/Attributes.cs index dbe937022..b402b98c4 100644 --- a/Server/Attributes.cs +++ b/Server/Attributes.cs @@ -19,8 +19,6 @@ ***************************************************************************/ using System; -using System.Collections; -using System.Collections.Generic; using System.Reflection; namespace Server @@ -158,8 +156,21 @@ namespace Server [AttributeUsage( AttributeTargets.Constructor )] public class ConstructableAttribute : Attribute { - public ConstructableAttribute() + private AccessLevel m_AccessLevel; + + public AccessLevel AccessLevel { + get { return m_AccessLevel; } + set { m_AccessLevel = value; } + } + + public ConstructableAttribute() : this( AccessLevel.Player ) //Lowest accesslevel for current functionality (Level determined by access to [add) + { + } + + public ConstructableAttribute( AccessLevel accessLevel ) + { + m_AccessLevel = accessLevel; } } diff --git a/Server/Item.cs b/Server/Item.cs index c4819fc26..73780b713 100644 --- a/Server/Item.cs +++ b/Server/Item.cs @@ -3346,8 +3346,8 @@ namespace Server } public virtual void OnAfterDuped( Item newItem ) - { - } + { + } public virtual bool OnDragLift( Mobile from ) { @@ -4289,6 +4289,11 @@ namespace Server ((Mobile)m_Parent).OnItemUsed( from, item ); } + public bool CheckItemUse( Mobile from ) + { + return CheckItemUse( from, this ); + } + public virtual bool CheckItemUse( Mobile from, Item item ) { if ( m_Parent is Item ) @@ -4307,6 +4312,13 @@ namespace Server ((Mobile)m_Parent).OnItemLifted( from, item ); } + public bool CheckLift( Mobile from ) + { + LRReason reject = LRReason.Inspecific; + + return CheckLift( from, this, ref reject ); + } + public virtual bool CheckLift( Mobile from, Item item, ref LRReason reject ) { if ( m_Parent is Item ) diff --git a/Server/Items/Container.cs b/Server/Items/Container.cs index f04a12fea..bd2b33af3 100644 --- a/Server/Items/Container.cs +++ b/Server/Items/Container.cs @@ -174,6 +174,17 @@ namespace Server.Items return base.CheckLift( from, item, ref reject ); } + public override bool CheckItemUse( Mobile from, Item item ) + { + if ( item != this && from.AccessLevel < AccessLevel.GameMaster && IsDecoContainer ) + { + from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that. + return false; + } + + return base.CheckItemUse( from, item ); + } + public bool CheckHold( Mobile m, Item item, bool message ) { return CheckHold( m, item, message, true, 0, 0 );