From 1db46822220668f56b003cfb9c1531fea6914dc4 Mon Sep 17 00:00:00 2001 From: mark Date: Sat, 13 Jan 2007 05:31:20 +0000 Subject: [PATCH] rewrote unlock spell tchests respawn on magic unlock --- Scripts/Items/Containers/BaseTreasureChest.cs | 24 +++-- Scripts/Spells/Third/Unlock.cs | 97 ++++++++----------- 2 files changed, 59 insertions(+), 62 deletions(-) diff --git a/Scripts/Items/Containers/BaseTreasureChest.cs b/Scripts/Items/Containers/BaseTreasureChest.cs index 10d9affc3..bca9c872e 100644 --- a/Scripts/Items/Containers/BaseTreasureChest.cs +++ b/Scripts/Items/Containers/BaseTreasureChest.cs @@ -52,6 +52,23 @@ namespace Server.Items } } + [CommandProperty( AccessLevel.GameMaster )] + public override bool Locked { + get { return m_Locked; } + set { + if ( m_Locked != value ) { + m_Locked = value; + + if ( !m_Locked ) + StartResetTimer(); + else + m_Picker = null; + + InvalidateProperties(); + } + } + } + public override bool IsDecoContainer { get{ return false; } @@ -191,13 +208,6 @@ namespace Server.Items DropItem( new Gold( MinGold, MaxGold ) ); } - public override void LockPick( Mobile from ) - { - base.LockPick( from ); - - StartResetTimer(); - } - public void ClearContents() { for ( int i = Items.Count - 1; i >= 0; --i ) diff --git a/Scripts/Spells/Third/Unlock.cs b/Scripts/Spells/Third/Unlock.cs index 8b0c7dc14..274fe5ca0 100644 --- a/Scripts/Spells/Third/Unlock.cs +++ b/Scripts/Spells/Third/Unlock.cs @@ -25,56 +25,6 @@ namespace Server.Spells.Third Caster.Target = new InternalTarget( this ); } - public void Target( LockableContainer targ ) - { - if ( Multis.BaseHouse.CheckSecured( targ ) ) - { - // You cannot cast this on a secure item. - Caster.SendLocalizedMessage( 503098 ); - } - else if ( CheckSequence() ) - { - SpellHelper.Turn( Caster, targ ); - - Point3D loc = targ.GetWorldLocation(); - - Effects.SendLocationParticles( - EffectItem.Create( loc, targ.Map, EffectItem.DefaultDuration ), - 0x376A, 9, 32, 5024 ); - - Effects.PlaySound( loc, targ.Map, 0x1FF ); - - if ( targ.Locked && targ.LockLevel != 0 ) - { - double magery = Caster.Skills[SkillName.Magery].Value; - int level = (int)(magery * 0.8) - 4; - - if ( level >= targ.RequiredSkill && !(targ is TreasureMapChest && ((TreasureMapChest)targ).Level > 2) ) - { - targ.Locked = false; - - if ( targ.LockLevel == -255 ) - targ.LockLevel = targ.RequiredSkill - 10; - - if ( targ.LockLevel == 0 ) - targ.LockLevel = -1; - } - else - { - // My spell does not seem to have an effect on that lock. - Caster.LocalOverheadMessage( MessageType.Regular, 0x3B2, 503099 ); - } - } - else - { - // That did not need to be unlocked. - Caster.LocalOverheadMessage( MessageType.Regular, 0x3B2, 503101 ); - } - } - - FinishSequence(); - } - private class InternalTarget : Target { private UnlockSpell m_Owner; @@ -86,12 +36,49 @@ namespace Server.Spells.Third protected override void OnTarget( Mobile from, object o ) { - if ( o is LockableContainer ) - m_Owner.Target( (LockableContainer)o ); - else - from.SendLocalizedMessage( 501666 ); // You can't unlock that! + IPoint3D loc = o as IPoint3D; - // TODO: Really we can cast on anything, even mobiles, but it will effect and say 'That did not need to be unlocked' + if ( loc == null ) + return; + + if ( m_Owner.CheckSequence() ) { + SpellHelper.Turn( from, o ); + + Effects.SendLocationParticles( EffectItem.Create( loc, from.Map, EffectItem.DefaultDuration ), 0x376A, 9, 32, 5024 ); + + Effects.PlaySound( loc, from.Map, 0x1FF ); + + if ( o is Mobile ) + from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 503101 ); // That did not need to be unlocked. + else if ( !( o is LockableContainer ) ) + from.SendLocalizedMessage( 501666 ); // You can't unlock that! + else { + LockableContainer cont = (LockableContainer)o; + + if ( Multis.BaseHouse.CheckSecured( cont ) ) + from.SendLocalizedMessage( 503098 ); // You cannot cast this on a secure item. + else if ( !cont.Locked ) + from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 503101 ); // That did not need to be unlocked. + else if ( cont.LockLevel == 0 ) + from.SendLocalizedMessage( 501666 ); // You can't unlock that! + else { + int level = (int)(from.Skills[SkillName.Magery].Value * 0.8) - 4; + + if ( level >= cont.RequiredSkill && !(cont is TreasureMapChest && ((TreasureMapChest)cont).Level > 2) ) { + cont.Locked = false; + + if ( cont.LockLevel == -255 ) + cont.LockLevel = cont.RequiredSkill - 10; + } + else + from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 503099 ); // My spell does not seem to have an effect on that lock. + } + else + + } + } + + m_Owner.FinishSequence(); } protected override void OnTargetFinish( Mobile from )