From 3c10fd8e32e87556bb9419559312e460c0c4e020 Mon Sep 17 00:00:00 2001 From: eos Date: Sat, 3 Nov 2012 02:11:41 +0000 Subject: [PATCH] - Fixed HalloweenPumpkin still appearing in the cursor after being deleted. - Added sounds and messages to HalloweenPumpkin lighting. - Corrected PlayerBones base class. - Fixed old JackOLantern component names. - Fixed core re-sending deleted items on lift rejection. --- .../Halloween/2006/Items/HalloweenPumpkin.cs | 60 ++++++++++--------- .../Halloween/2012/Engines/PlayerZombies.cs | 7 ++- Scripts/Items/Addons/JackOLantern.cs | 20 ++++++- Server/Mobile.cs | 3 + 4 files changed, 55 insertions(+), 35 deletions(-) diff --git a/Scripts/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs b/Scripts/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs index 5a0074998..d33fd1e3e 100644 --- a/Scripts/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs +++ b/Scripts/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs @@ -6,7 +6,7 @@ namespace Server.Items { public class HalloweenPumpkin : Item { - private readonly string[] staff = + private static readonly string[] m_Staff = { "Ryan", "Mark", "Eos", "Athena", "Xavier", "Krrios", "Zippy" }; @@ -16,51 +16,50 @@ namespace Server.Items : base() { Weight = Utility.RandomMinMax( 3, 20 ); - ItemID = ( Utility.RandomDouble() <= .02 ) ? 0x4694 + Utility.Random( 2 ) : Utility.RandomList( 0xc6a, 0xc6b, 0xc6c ); + ItemID = ( Utility.RandomDouble() <= .02 ) ? Utility.RandomList( 0x4694, 0x4698 ) : Utility.RandomList( 0xc6a, 0xc6b, 0xc6c ); } public override void OnDoubleClick( Mobile from ) { - this.ItemID = GetItemID( ItemID ); + if ( !from.InRange( this.GetWorldLocation(), 2 ) ) + return; - base.OnDoubleClick( from ); - } + bool douse = false; - private int GetItemID( int itemid ) - { - switch( ItemID ) + switch ( ItemID ) { - case 0x4694: itemid = 0x4691; break; - case 0x4691: itemid = 0x4694; break; - case 0x4698: itemid = 0x4695; break; - case 0x4695: itemid = 0x4698; break; + case 0x4694: ItemID = 0x4691; break; + case 0x4691: ItemID = 0x4694; douse = true; break; + case 0x4698: ItemID = 0x4695; break; + case 0x4695: ItemID = 0x4698; douse = true; break; + default: return; } - return itemid; + from.SendLocalizedMessage( douse ? 1113988 : 1113987 ); // You extinguish/light the Jack-O-Lantern + Effects.PlaySound( GetWorldLocation(), Map, douse ? 0x3be : 0x47 ); } - public override void OnItemLifted( Mobile from, Item item ) + private void AssignRandomName() { - base.OnItemLifted( from, item ); + Name = String.Format( "{0}'s Jack-O-Lantern", m_Staff[ Utility.Random( m_Staff.Length ) ] ); + } - if( item != null && !item.Deleted && item == this && Name == null ) + public override bool OnDragLift( Mobile from ) + { + if ( Name == null && ( ItemID == 0x4694 || ItemID == 0x4691 || ItemID == 0x4698 || ItemID == 0x4695 ) ) { - if( ItemID == 0x4694 || ItemID == 0x4691 || ItemID == 0x4695 || ItemID == 0x4698 ) + if ( Utility.RandomBool() ) { - if( Utility.RandomBool() ) - { - BaseCreature pumpkinhead = new PumpkinHead(); + new PumpkinHead().MoveToWorld( GetWorldLocation(), Map ); - pumpkinhead.MoveToWorld( Location, from.Map ); - - Delete(); - } - else - { - Name = String.Format( "{0}'s Jack-O-Lantern", staff[ Utility.Random( staff.Length ) ] ); - } + Delete(); + return false; } + + AssignRandomName(); } + + return true; } public HalloweenPumpkin( Serial serial ) @@ -72,7 +71,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( ( int )0 ); // version + writer.Write( (int)1 ); // version } public override void Deserialize( GenericReader reader ) @@ -80,6 +79,9 @@ namespace Server.Items base.Deserialize( reader ); int version = reader.ReadInt(); + + if ( version == 0 && Name == null && ItemID == 0x4698 ) + AssignRandomName(); } } } diff --git a/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs b/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs index 0ec7c94ff..ac232a4d9 100644 --- a/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs +++ b/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs @@ -144,12 +144,13 @@ namespace Server.Engines.Events } } - public class PlayerBones : Container + public class PlayerBones : BaseContainer { + [Constructable] public PlayerBones( String name ) : base( Utility.RandomMinMax( 0x0ECA, 0x0ED2 ) ) { - Name = String.Format( "{0}\'s bones", name ); + Name = String.Format( "{0}'s bones", name ); switch( Utility.Random( 10 ) ) { @@ -195,7 +196,7 @@ namespace Server.Engines.Events { m_DeadPlayer = player; - Name = ( player != null ) ? String.Format( "{0}\'s {1}", player.Name, m_Name ) : m_Name; + Name = ( player != null ) ? String.Format( "{0}'s {1}", player.Name, m_Name ) : m_Name; Body = 0x93; BaseSoundID = 0x1c3; diff --git a/Scripts/Items/Addons/JackOLantern.cs b/Scripts/Items/Addons/JackOLantern.cs index a0144cb95..d4d5ea761 100644 --- a/Scripts/Items/Addons/JackOLantern.cs +++ b/Scripts/Items/Addons/JackOLantern.cs @@ -19,7 +19,7 @@ namespace Server.Items AddonComponent ac = new AddonComponent( itemID ); ac.Hue = hue; - ac.Name = "jack-o-latern"; + ac.Name = "jack-o-lantern"; return ac; } @@ -61,7 +61,7 @@ namespace Server.Items { base.Serialize( writer ); - writer.Write( (byte) 1 ); // version + writer.Write( (byte) 2 ); // version } public override void Deserialize( GenericReader reader ) @@ -83,6 +83,20 @@ namespace Server.Items } } ); } + + if ( version <= 1 ) + { + Timer.DelayCall( TimeSpan.Zero, delegate() + { + for ( int i = 0; i < Components.Count; ++i ) + { + AddonComponent ac = Components[i] as AddonComponent; + + if ( ac != null ) + ac.Name = "jack-o-lantern"; + } + } ); + } } } -} \ No newline at end of file +} diff --git a/Server/Mobile.cs b/Server/Mobile.cs index 55be2af46..189b1103f 100644 --- a/Server/Mobile.cs +++ b/Server/Mobile.cs @@ -4417,6 +4417,9 @@ namespace Server { state.Send( new LiftRej( reject ) ); + if( item.Deleted ) + return; + if( item.Parent is Item ) { if ( state.ContainerGridLines ) state.Send( new ContainerContentUpdate6017( item ) );