diff --git a/Scripts/Engines/Doom/Lamp Room/LampController.cs b/Scripts/Engines/Doom/Lamp Room/LampController.cs deleted file mode 100644 index 72772cc23..000000000 --- a/Scripts/Engines/Doom/Lamp Room/LampController.cs +++ /dev/null @@ -1,743 +0,0 @@ -using System; -using System.Collections; -using Server.Commands; -using Server; -using Server.Mobiles; -using Server.Network; - -namespace Server.Items -{ - public class LampController : Item - { - public static void Initialize() - { - CommandSystem.Register( "GenLampPuzzle", AccessLevel.Administrator, new CommandEventHandler( GenLampPuzzle_OnCommand ) ); - } - - [Usage( "GenLampPuzzle" )] - [Description( "Generates lamp room puzzle in doom." )] - public static void GenLampPuzzle_OnCommand( CommandEventArgs e ) - { - e.Mobile.SendMessage( "Generating puzzle, please wait." ); - - Point3D loc = new Point3D( 324, 64, -1 ); - bool exists = false; - - foreach ( Item item in Map.Malas.GetItemsInRange( loc, 0 ) ) - { - if ( item is LampController ) - { - exists = true; - break; - } - } - - if ( !exists ) - { - LampController controller = new LampController(); - controller.MoveToWorld( loc, Map.Malas ); - e.Mobile.SendMessage( "Puzzle generating complete. Puzzle were generated." ); - } - else - e.Mobile.SendMessage( "Puzzle generating complete. Puzzle aleardy exists." ); - } - - public Rectangle2D Rect = new Rectangle2D( 464, 91, 10, 10 ); - public PoisonTimer m_Timer; - - private string m_Code; - private string m_PuzzleCode; - - [CommandProperty( AccessLevel.GameMaster )] - public string PuzzleCode { get { return m_PuzzleCode; } set { m_PuzzleCode = value; } } - - [CommandProperty( AccessLevel.GameMaster )] - public string Code - { - get { return m_Code; } - set - { - m_Code = value; - - if ( m_Code.Length == 4 ) - { - CheckCode(); - } - } - } - - private ArrayList m_Levers; - private ArrayList m_Statues; - private ArrayList m_Pads; - private PuzzleBox m_Box; - private bool m_CanActive; - - [CommandProperty( AccessLevel.GameMaster )] - public bool CanActive { get { return m_CanActive; } set { m_CanActive = value; } } - - private static LampController _Instance = null; - - // Should this even be constructable? - [Constructable] - public LampController() : base( 0x1BC3 ) - { - if ( _Instance != null ) - { - Delete(); - return; - } else { - _Instance = this; - } - - Visible = false; - Movable = false; - - Setup(); - } - - public override void Delete() - { - _Instance = null; - base.Delete(); - } - - public void Setup() - { - m_CanActive = true; - m_Code = ""; - m_PuzzleCode = ""; - - m_Levers = new ArrayList(); - m_Statues = new ArrayList(); - m_Pads = new ArrayList(); - - PuzzleLever lever1 = new PuzzleLever( 1 ); - lever1.Controller = this; - lever1.MoveToWorld( new Point3D( 316, 64, 5 ), Map.Malas ); - m_Levers.Add( lever1 ); - - PuzzleLever lever2 = new PuzzleLever( 2 ); - lever2.Controller = this; - lever2.MoveToWorld( new Point3D( 323, 58, 5 ), Map.Malas ); - m_Levers.Add( lever2 ); - - PuzzleLever lever3 = new PuzzleLever( 3 ); - lever3.Controller = this; - lever3.MoveToWorld( new Point3D( 332, 63, 5 ), Map.Malas ); - m_Levers.Add( lever3 ); - - PuzzleLever lever4 = new PuzzleLever( 4 ); - lever4.Controller = this; - lever4.MoveToWorld( new Point3D( 323, 71, 5 ), Map.Malas ); - m_Levers.Add( lever4 ); - - PuzzleStatue statue1 = new PuzzleStatue( 0x12D8 ); - statue1.MoveToWorld( new Point3D( 319, 70, 18 ), Map.Malas ); - m_Statues.Add( statue1 ); - - PuzzleStatue statue2 = new PuzzleStatue( 0x12D9 ); - statue2.MoveToWorld( new Point3D( 329, 60, 18 ), Map.Malas ); - m_Statues.Add( statue2 ); - - PuzzlePad pad1 = new PuzzlePad(); - pad1.MoveToWorld( new Point3D( 324, 58, -1 ), Map.Malas ); - pad1.Visible = false; - m_Pads.Add( pad1 ); - - PuzzlePad pad2 = new PuzzlePad(); - pad2.MoveToWorld( new Point3D( 332, 64, -1 ), Map.Malas ); - pad2.Visible = false; - m_Pads.Add( pad2 ); - - PuzzlePad pad3 = new PuzzlePad(); - pad3.MoveToWorld( new Point3D( 323, 72, -1 ), Map.Malas ); - pad3.Visible = false; - m_Pads.Add( pad3 ); - - PuzzlePad pad4 = new PuzzlePad(); - pad4.MoveToWorld( new Point3D( 316, 65, -1 ), Map.Malas ); - pad4.Visible = false; - m_Pads.Add( pad4 ); - - PuzzlePad pad5 = new PuzzlePad(); - pad5.MoveToWorld( new Point3D( 324, 64, -1 ), Map.Malas ); - m_Pads.Add( pad5 ); - - Teleporter teleporter1 = new Teleporter(); - teleporter1.MapDest = Map.Malas; - teleporter1.PointDest = new Point3D( 353, 172, -1 ); - teleporter1.MoveToWorld( new Point3D( 468, 92, -1 ), Map.Malas ); - - Teleporter teleporter2 = new Teleporter(); - teleporter2.MapDest = Map.Malas; - teleporter2.PointDest = new Point3D( 353, 172, -1 ); - teleporter2.MoveToWorld( new Point3D( 469, 92, -1 ), Map.Malas ); - - Teleporter teleporter3 = new Teleporter(); - teleporter3.MapDest = Map.Malas; - teleporter3.PointDest = new Point3D( 353, 172, -1 ); - teleporter3.MoveToWorld( new Point3D( 470, 92, -1 ), Map.Malas ); - - m_Box = new PuzzleBox(); - m_Box.CanSummon = true; - m_Box.MoveToWorld( new Point3D( 469, 96, 6 ), Map.Malas ); - - m_PuzzleCode = GenerateCode( m_PuzzleCode ); - } - - public void ClearRoom() - { - IPooledEnumerable eable = Map.Malas.GetMobilesInBounds( Rect ); - - ArrayList list = new ArrayList(); - - foreach ( object obj in eable ) - { - if ( obj is Mobile ) - { - Mobile mobile = obj as Mobile; - - list.Add( mobile ); - } - } - - for ( int i = 0; i < list.Count; i++ ) - { - Mobile m = list[ i ] as Mobile; - - if ( m is WandererOfTheVoid ) - { - m.Delete(); - } - else - { - Rectangle2D rect = new Rectangle2D( 342, 168, 16, 16 ); - - int x = Utility.Random( rect.X, rect.Width ); - int y = Utility.Random( rect.Y, rect.Height ); - - if ( x >= 345 && x <= 352 && y >= 173 && y <= 179 ) - { - x = 353; - y = 172; - } - - m.MoveToWorld( new Point3D( x, y, -1 ), Map.Malas ); - } - } - - if ( m_Timer != null ) - { - m_Timer.Stop(); - } - - m_CanActive = true; - m_Box.CanSummon = true; - m_PuzzleCode = ""; - m_PuzzleCode = GenerateCode( m_PuzzleCode ); - } - - public static string[] m_Combinations = new string[] { "1234", "1243", "1324", "1342", "1423", "1432", "2134", "2143", "2314", "2341", "2413", "2431", "3124", "3142", "3214", "3241", "3412", "3421", "4123", "4132", "4213", "4231", "4312", "4321" }; - - public void FreeLevers() - { - for ( int i = 0; i < m_Levers.Count; i++ ) - { - PuzzleLever lever = m_Levers[ i ] as PuzzleLever; - lever.ItemID = 0x108E; - } - - m_Code = ""; - - Timer.DelayCall( TimeSpan.FromSeconds( 30.0 ), new TimerCallback( SayQuitMessage ) ); - } - - public void SayQuitMessage() - { - SayStatues( 1062053, -1 ); // The sands of time have run their course. - - for ( int i = 0; i < m_Levers.Count; i++ ) - { - PuzzleLever lever = m_Levers[ i ] as PuzzleLever; - lever.ItemID = 0x108E; - } - } - - public static string GenerateCode( string puzzle ) - { - // at OSI code scheme is right order of pressed levers - // any press at any of 4 levers is one bit of code - // orientation of lever doesn't play any role - // code can't have equal numbers in it, only different, i.e: 1-4-2-3, no 1-1-1-1 - // so, we have 24 combinations for solving - - string old_code = puzzle; - string new_code = ""; - - while ( new_code == old_code ) - { - new_code = m_Combinations[ Utility.Random( m_Combinations.Length ) ]; - } - - return new_code; - } - - public int CompareCodes( string puzzle, string player ) - { - int result = 0; - - if ( puzzle.Length != player.Length || puzzle.Length > 4 || player.Length > 4 ) - { - return 0; - } - - for ( int i = 0; i < puzzle.Length; i++ ) - { - if ( puzzle[ i ] == player[ i ] ) - { - result++; - } - } - - return result; - } - - public void SayStatues( int message, int souls ) - { - string args = ""; - - if ( souls != -1 ) - { - args = souls.ToString(); - } - - for ( int i = 0; i < m_Statues.Count; i++ ) - { - PuzzleStatue statue = m_Statues[ i ] as PuzzleStatue; - - if ( statue != null ) - { - statue.PublicOverheadMessage( Network.MessageType.Regular, 0x3B2, message, args ); - } - } - } - - public void CheckCode() - { - bool incomplete = false; - - int correct_souls = 0; - - for ( int i = 0; i < m_Pads.Count; i++ ) - { - PuzzlePad pad = m_Pads[ i ] as PuzzlePad; - - if ( pad == null || !pad.Busy ) - { - incomplete = true; - } - } - - correct_souls = CompareCodes( m_PuzzleCode, m_Code ); - - if ( incomplete ) - { - SayStatues( 1050004, -1 ); // The circle is the key, the key is incomplete and so the gate remains closed. - } - else - { - // we don't guess code - if ( correct_souls >= 0 && correct_souls < 4 ) - { - ArrayList players = new ArrayList(); - - for ( int i = 0; i < m_Pads.Count; i++ ) - { - PuzzlePad pad = m_Pads[ i ] as PuzzlePad; - - if ( pad != null && pad.Stander != null && pad.Stander.Alive ) - { - players.Add( pad.Stander ); - } - } - - for ( int j = 0; j < players.Count; j++ ) - { - PlayerMobile player = players[ j ] as PlayerMobile; - - if ( player != null ) - { - Point3D location1 = player.Location; - location1.Z = 49; - - Point3D location2 = player.Location; - location2.Z = -1; - - Effects.SendPacket( player, player.Map, new HuedEffect( EffectType.Moving, Serial.Zero, player.Serial, 0x11B7, location1, location2, 20, 0, true, true, 0, 0 ) ); - Effects.PlaySound( new Point3D( 324, 64, -1 ), Map.Malas, 0x144 ); - Effects.PlaySound( new Point3D( player.X, player.Y, -1 ), Map.Malas, Utility.RandomList( 0x154, 0x14B ) ); - player.Send( new AsciiMessage( Serial.MinusOne, 0xFFFF, MessageType.Label, 0x66D, 3, "", "You are pinned down by the weight of the boulder!!!" ) ); - } - } - - switch ( correct_souls ) - { - case 0: - SayStatues( 1050009, correct_souls ); - break; // The circle of souls has failed to turn the key. The gate remains closed... - case 1: - SayStatues( 1050007, correct_souls ); - break; // ~1_NUM~ soul has turned the key correctly, but the rest have forsaken the circle... - default: - SayStatues( 1050008, correct_souls ); - break; // ~1_NUM~ souls have turned the key correctly, but the rest have forsaken the circle... - } - - for ( int j = 0; j < players.Count; j++ ) - { - PlayerMobile player = players[ j ] as PlayerMobile; - - if ( player != null ) - { - Effects.SendPacket( player, player.Map, new HuedEffect( EffectType.FixedXYZ, Serial.Zero, Serial.Zero, 0x36BD, new Point3D( player.X, player.Y, 0 ), new Point3D( player.X, player.Y, 0 ), 20, 10, true, false, 0, 0 ) ); - Effects.SendPacket( player, player.Map, new HuedEffect( EffectType.FixedFrom, player.Serial, Serial.Zero, 0x36BD, new Point3D( player.X, player.Y, -1 ), new Point3D( player.X, player.Y, -1 ), 20, 10, true, false, 0, 0 ) ); - Effects.PlaySound( new Point3D( player.X, player.Y, -1 ), player.Map, 0x307 ); - - for ( int k = 0; k < 5; k++ ) - { - Effects.SendPacket( player, player.Map, new HuedEffect( EffectType.Moving, Serial.Zero, Serial.Zero, 0x1363 + Utility.Random( 0, 11 ), new Point3D( player.X, player.Y, 0 ), new Point3D( player.X, player.Y, 0 ), 5, 0, false, false, 0, 0 ) ); - Effects.PlaySound( new Point3D( player.X, player.Y, -1 ), Map.Malas, 0x13F ); - Effects.PlaySound( new Point3D( player.X, player.Y, -1 ), Map.Malas, 0x154 ); - - player.Say( "OUCH!" ); - } - - player.Damage( 90, null ); - player.Send( new AsciiMessage( Serial.MinusOne, 0xFFFF, MessageType.Label, 0x66D, 3, "", "A speeding rock hits you in the head!" ) ); - player.SendLocalizedMessage( 502382 ); // You can move! - } - } - } - else - { - // we done it! - PlayerMobile center = ( (PuzzlePad) m_Pads[ 4 ] ).Stander; - - for ( int i = 0; i < m_Pads.Count; i++ ) - { - PuzzlePad pad = m_Pads[ i ] as PuzzlePad; - - if ( pad != null && pad.Stander != null && pad.Stander.Alive ) - { - Effects.SendPacket( pad.Stander, Map.Malas, new HuedEffect( EffectType.FixedXYZ, Serial.Zero, Serial.Zero, 0x1153, new Point3D( 325, 64, -1 ), new Point3D( 325, 64, -1 ), 1, 60, true, false, 0, 0 ) ); - Effects.SendPacket( pad.Stander, Map.Malas, new HuedEffect( EffectType.FixedXYZ, Serial.Zero, Serial.Zero, 0x1153, new Point3D( 325, 64, -1 ), new Point3D( 325, 64, -1 ), 1, 60, true, false, 0, 0 ) ); - Effects.PlaySound( new Point3D( 325, 64, -1 ), Map.Malas, 0x244 ); - - if ( center != null ) - { - Effects.SendPacket( pad.Stander, Map.Malas, new HuedEffect( EffectType.Lightning, center.Serial, Serial.Zero, 0x0, new Point3D( 324, 64, -1 ), new Point3D( 324, 64, -1 ), 0, 0, false, false, 0, 0 ) ); - Effects.SendPacket( pad.Stander, Map.Malas, new ParticleEffect( EffectType.FixedFrom, center.Serial, Serial.Zero, 0x0, new Point3D( 324, 64, -1 ), new Point3D( 324, 64, -1 ), 0, 0, false, false, 0, 0, 0x13A7, 0, 0, center.Serial, 3, 0 ) ); - } - } - } - - if ( center != null ) - { - center.MoveToWorld( new Point3D( 467, 96, -1 ), Map.Malas ); - - if ( m_Timer != null ) - { - m_Timer.Stop(); - } - - m_Timer = new PoisonTimer( this ); - m_Timer.Start(); - m_CanActive = false; - m_Box.CanSummon = true; - } - } - } - - FreeLevers(); - } - - public LampController( Serial serial ) : base( serial ) - { - } - - public override void Serialize( GenericWriter writer ) - { - base.Serialize( writer ); - - writer.Write( (int) 0 ); // version - - writer.WriteItemList( m_Levers, true ); - writer.WriteItemList( m_Statues, true ); - writer.WriteItemList( m_Pads, true ); - - writer.Write( m_Box ); - } - - public override void Deserialize( GenericReader reader ) - { - base.Deserialize( reader ); - - int version = reader.ReadInt(); - - m_Code = ""; - m_PuzzleCode = ""; - m_PuzzleCode = GenerateCode( m_PuzzleCode ); - - m_Levers = reader.ReadItemList(); - m_Statues = reader.ReadItemList(); - m_Pads = reader.ReadItemList(); - - m_Box = reader.ReadItem() as PuzzleBox; - - m_CanActive = true; - m_Box.CanSummon = true; - - _Instance = this; - } - - public class PoisonTimer : Timer - { - public LampController m_Controller; - public int count = 1; - - public PoisonTimer( LampController controller ) : base( TimeSpan.FromSeconds( 8.0 ), TimeSpan.FromSeconds( 1.0 ) ) - { - m_Controller = controller; - } - - public void CheckAlive() - { - bool AliveCreatures = false; - - IPooledEnumerable eable = Map.Malas.GetMobilesInBounds( m_Controller.Rect ); - - foreach ( object obj in eable ) - { - if ( obj is Mobile ) - { - Mobile mobile = obj as Mobile; - - if ( mobile != null && mobile.Alive && !( mobile is WandererOfTheVoid ) ) - { - AliveCreatures = true; - } - } - } - - eable.Free(); - - if ( !AliveCreatures ) - { - m_Controller.ClearRoom(); - - Stop(); - } - } - - public void Gas( int level ) - { - int[] x = new int[ 3 ], y = new int[ 3 ]; - - for ( int i = 0; i < x.Length; i++ ) - { - x[ i ] = Utility.Random( m_Controller.Rect.X, m_Controller.Rect.Width ); - y[ i ] = Utility.Random( m_Controller.Rect.Y, m_Controller.Rect.Height ); - } - - int hue = 0xAC; - - Poison poison = null; - - switch ( level ) - { - case 0: - hue = 0xA6; - poison = Poison.Lesser; - break; - case 1: - hue = 0xAA; - poison = Poison.Regular; - break; - case 2: - hue = 0xAC; - poison = Poison.Greater; - break; - case 3: - hue = 0xA8; - poison = Poison.Deadly; - break; - case 4: - hue = 0xA4; - poison = Poison.Lethal; - break; - case 5: - hue = 0xAC; - poison = Poison.Lethal; - break; - } - - Effects.SendLocationParticles( EffectItem.Create( new Point3D( x[ 0 ], y[ 0 ], -1 ), Map.Malas, EffectItem.DefaultDuration ), 0x36B0, 1, Utility.Random( 160, 200 ), hue, 0, 0x1F78, 0 ); - Effects.SendLocationParticles( EffectItem.Create( new Point3D( x[ 1 ], y[ 1 ], -1 ), Map.Malas, EffectItem.DefaultDuration ), 0x36CB, 1, Utility.Random( 160, 200 ), hue, 0, 0x1F78, 0 ); - Effects.SendLocationParticles( EffectItem.Create( new Point3D( x[ 2 ], y[ 2 ], -1 ), Map.Malas, EffectItem.DefaultDuration ), 0x36BD, 1, Utility.Random( 160, 200 ), hue, 0, 0x1F78, 0 ); - - IPooledEnumerable eable = Map.Malas.GetMobilesInBounds( m_Controller.Rect ); - - foreach ( object obj in eable ) - { - if ( obj is Mobile ) - { - Mobile mobile = obj as Mobile; - - if ( mobile != null && poison != null && mobile.Poison == null && !( mobile is WandererOfTheVoid ) ) - { - double chance = ( level + 1 ) * 0.3; - - if ( chance >= Utility.RandomDouble() ) - { - mobile.ApplyPoison( mobile, poison ); - } - } - } - } - - eable.Free(); - } - - protected override void OnTick() - { - CheckAlive(); - - count++; - - int level = (int) ( count / 60 ); - - if ( count % 60 == 0 ) // every minute we need send message to player about level's change - { - int number = 0; - int hue = 0x485; - - switch ( level ) - { - case 1: - number = 1050001; - break; // It is becoming more difficult for you to breathe as the poisons in the room become more concentrated. - case 2: - number = 1050003; - break; // You begin to panic as the poison clouds thicken. - case 3: - number = 1050056; - break; // Terror grips your spirit as you realize you may never leave this room alive. - case 4: - number = 1050057; - break; // The end is near. You feel hopeless and desolate. The poison is beginning to stiffen your muscles. - case 5: - number = 1062091; - hue = 0x23F3; - break; // The poison is becoming too much for you to bear. You fear that you may die at any moment. - } - - IPooledEnumerable eable = Map.Malas.GetMobilesInBounds( m_Controller.Rect ); - - foreach ( object obj in eable ) - { - if ( obj is Mobile ) - { - Mobile mobile = obj as Mobile; - - if ( mobile != null && mobile.Player ) - { - if ( number != 0 ) - { - mobile.SendLocalizedMessage( number, null, hue ); - } - } - } - } - - eable.Free(); - - if ( level == 5 ) - { - PainTimer timer = new PainTimer( m_Controller ); - - timer.Start(); - } - } - - if ( count % 5 == 0 ) // every 5 seconds we fill room with a gas - { - Gas( level ); - } - } - } - - public class PainTimer : Timer - { - public LampController m_Controller; - public int count = 1; - - public PainTimer( LampController controller ) : base( TimeSpan.FromSeconds( 10.0 ), TimeSpan.FromSeconds( 10.0 ) ) - { - m_Controller = controller; - } - - protected override void OnTick() - { - count++; - - IPooledEnumerable eable = Map.Malas.GetMobilesInBounds( m_Controller.Rect ); - - ArrayList targets = new ArrayList(); - - foreach ( Mobile mobile in eable ) - { - targets.Add( mobile ); - } - - for ( int i = 0; i < targets.Count; ++i ) - { - Mobile mobile = targets[ i ] as Mobile; - - if ( mobile != null && !( mobile is WandererOfTheVoid ) ) - { - if ( mobile.Player ) - { - mobile.Say( 1062092 ); // Your body reacts violently from the pain. - - mobile.Animate( 32, 5, 1, true, false, 0 ); - } - - mobile.Damage( Utility.Random( 15, 20 ) ); - - if ( count == 10 ) // at OSI at this second all mobiles is killed and room is cleared - { - mobile.Kill(); - } - } - } - - eable.Free(); - - if ( count == 10 ) - { - if ( m_Controller != null ) - { - m_Controller.ClearRoom(); // clear room - - if ( m_Controller.m_Timer != null ) - { - m_Controller.m_Timer.Stop(); // stop gas effects - } - - Stop(); // stop convulsions - } - } - } - } - } -} diff --git a/Scripts/Engines/Doom/Lamp Room/PuzzleBox.cs b/Scripts/Engines/Doom/Lamp Room/PuzzleBox.cs deleted file mode 100644 index 764835e70..000000000 --- a/Scripts/Engines/Doom/Lamp Room/PuzzleBox.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Collections; -using Server; -using Server.Mobiles; -using Server.Network; - -namespace Server.Items -{ - public class PuzzleBox : Item - { - private bool m_CanSummon; - - [CommandProperty( AccessLevel.GameMaster )] - public bool CanSummon { get { return m_CanSummon; } set { m_CanSummon = value; } } - - private WandererOfTheVoid m_Wanderer; - - [CommandProperty( AccessLevel.GameMaster )] - public WandererOfTheVoid Wanderer { get { return m_Wanderer; } set { m_Wanderer = value; } } - - public override bool ForceShowProperties { get { return true; } } - - [Constructable] - public PuzzleBox() : base( 0xE80 ) - { - Movable = false; - - m_Wanderer = null; - } - - public PuzzleBox( Serial serial ) : base( serial ) - { - } - - public override void OnDoubleClick( Mobile from ) - { - if ( !from.InRange( this.GetWorldLocation(), 3 ) ) - return; - - if ( m_CanSummon && ( m_Wanderer == null || !m_Wanderer.Alive ) ) - { - m_Wanderer = new WandererOfTheVoid(); - m_Wanderer.MoveToWorld( new Point3D( 467, 94, -1 ), Map.Malas ); - - // I am the guardian of the Tomb of Sektu. Suffer my wrath! - m_Wanderer.PublicOverheadMessage( Network.MessageType.Regular, 0x3B2, 1060002, "" ); - - Timer.DelayCall( TimeSpan.FromSeconds( 5.0 ), new TimerCallback( SayFakeMessage ) ); - - m_CanSummon = false; - } - } - - public void SayFakeMessage() - { - // You try to pry the box open, when you notice that there is no opening. It's a fake box. - PublicOverheadMessage( Network.MessageType.Regular, 0x3B2, 1060003, "" ); - } - - public override void Serialize( GenericWriter writer ) - { - base.Serialize( writer ); - - writer.Write( (int) 0 ); // version - - writer.Write( m_Wanderer ); - writer.Write( (bool) m_CanSummon ); - } - - public override void Deserialize( GenericReader reader ) - { - base.Deserialize( reader ); - - int version = reader.ReadInt(); - - m_Wanderer = reader.ReadMobile() as WandererOfTheVoid; - m_CanSummon = reader.ReadBool(); - } - } -} diff --git a/Scripts/Engines/Doom/Lamp Room/PuzzleLever.cs b/Scripts/Engines/Doom/Lamp Room/PuzzleLever.cs deleted file mode 100644 index f30fda386..000000000 --- a/Scripts/Engines/Doom/Lamp Room/PuzzleLever.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections; -using Server; -using Server.Mobiles; -using Server.Network; - -namespace Server.Items -{ - public class PuzzleLever : Item - { - private LampController m_Controller; - private int m_Code; - - [CommandProperty( AccessLevel.GameMaster )] - public LampController Controller - { - get { return m_Controller; } - set { m_Controller = value; } - } - - [CommandProperty( AccessLevel.GameMaster )] - public int Code - { - get { return m_Code; } - set { m_Code = value; } - } - - [Constructable] - public PuzzleLever( int code ) : base( 0x108E ) - { - m_Code = code; - - Hue = 0x66D; - Movable = false; - } - - public PuzzleLever( Serial serial ) : base( serial ) - { - } - - public override void OnDoubleClick( Mobile from ) - { - if ( m_Controller != null && m_Controller.CanActive ) - { - if ( m_Controller.Code.Length < 4 ) - { - m_Controller.Code += m_Code; - - if ( ItemID == 0x108E ) - { - ItemID = 0x108C; - } - else if ( ItemID == 0x108C ) - { - ItemID = 0x108E; - } - - Effects.PlaySound( Location, Map, 0x3E8 ); - } - } - else - { - from.SendLocalizedMessage( 1060001 ); // You throw the switch, but the mechanism cannot be engaged again so soon. - } - } - - public override void Serialize( GenericWriter writer ) - { - base.Serialize( writer ); - - writer.Write( (int) 0 ); // version - - writer.Write( (int) m_Code ); - writer.Write( m_Controller ); - } - - public override void Deserialize( GenericReader reader ) - { - base.Deserialize( reader ); - - int version = reader.ReadInt(); - - m_Code = reader.ReadInt(); - m_Controller = reader.ReadItem() as LampController; - } - } -} diff --git a/Scripts/Engines/Doom/Lamp Room/PuzzlePad.cs b/Scripts/Engines/Doom/Lamp Room/PuzzlePad.cs deleted file mode 100644 index 155e6e2f0..000000000 --- a/Scripts/Engines/Doom/Lamp Room/PuzzlePad.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System; -using System.Collections; -using Server; -using Server.Mobiles; -using Server.Network; - -namespace Server.Items -{ - public class PuzzlePad : Item - { - private PlayerMobile m_Stander; - private bool m_Busy; - - [CommandProperty( AccessLevel.GameMaster )] - public PlayerMobile Stander - { - get { return m_Stander; } - set { m_Stander = value; } - } - - [CommandProperty( AccessLevel.GameMaster )] - public bool Busy - { - get { return m_Busy; } - set { m_Busy = value; } - } - - private InternalStandTimer m_Timer; - - [Constructable] - public PuzzlePad() : base( 0x1822 ) - { - m_Busy = false; - m_Stander = null; - m_Timer = null; - - Hue = 0x4C; - Movable = false; - } - - public override bool HandlesOnMovement { get { return true; } } // Tell the core that we implement OnMovement - - public override bool OnMoveOver( Mobile m ) - { - if ( ( m != null ) && ( m is PlayerMobile ) ) - { - if ( m_Stander == null ) - { - m_Stander = (PlayerMobile) m; - - if ( m_Timer != null ) - { - m_Timer.Stop(); - } - - m_Timer = new InternalStandTimer( this ); - - m_Timer.Start(); - } - } - - return base.OnMoveOver( m ); - } - - public PuzzlePad( Serial serial ) : base( serial ) - { - } - - public override void Serialize( GenericWriter writer ) - { - base.Serialize( writer ); - - writer.Write( (int) 0 ); // version - } - - public override void Deserialize( GenericReader reader ) - { - base.Deserialize( reader ); - - int version = reader.ReadInt(); - } - - private class InternalStandTimer : Timer - { - private PuzzlePad m_Pad; - - public InternalStandTimer( PuzzlePad pad ) : base( TimeSpan.FromSeconds( 0.25 ), TimeSpan.FromSeconds( 0.25 ) ) - { - m_Pad = pad; - Priority = TimerPriority.FiftyMS; - } - - private void Vacance() - { - if ( m_Pad != null ) - { - m_Pad.Stander = null; - m_Pad.Busy = false; - } - - Stop(); - } - - protected override void OnTick() - { - if ( m_Pad != null && !m_Pad.Deleted && m_Pad.Stander != null ) - { - if ( !m_Pad.Stander.Deleted && m_Pad.Stander.Alive && m_Pad.Stander.Location == m_Pad.Location ) - { - m_Pad.Busy = true; - } - else - { - Vacance(); - } - } - else - { - Vacance(); - } - } - } - } -} diff --git a/Scripts/Engines/Doom/Lamp Room/PuzzleStatue.cs b/Scripts/Engines/Doom/Lamp Room/PuzzleStatue.cs deleted file mode 100644 index 4e7452117..000000000 --- a/Scripts/Engines/Doom/Lamp Room/PuzzleStatue.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections; -using Server; -using Server.Mobiles; -using Server.Network; - -namespace Server.Items -{ - public class PuzzleStatue : Item - { - [Constructable] - public PuzzleStatue( int itemID ) : base( itemID ) - { - Hue = 0x44E; - Movable = false; - } - - public PuzzleStatue( Serial serial ) : base( serial ) - { - } - - public override void Serialize( GenericWriter writer ) - { - base.Serialize( writer ); - - writer.Write( (int) 0 ); // version - } - - public override void Deserialize( GenericReader reader ) - { - base.Deserialize( reader ); - - int version = reader.ReadInt(); - } - } -} diff --git a/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs b/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs new file mode 100644 index 000000000..a4a8dd0ff --- /dev/null +++ b/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs @@ -0,0 +1,731 @@ +using System; +using Server.Spells; +using Server; +using Server.Network; +using Server.Mobiles; +using Server.Commands; +using System.Collections.Generic; +using System.Collections; + + /* + this is From me to you, Under no terms, Conditions... K? to apply you + just simply Unpatch/delete, Stick these in, Same location.. Restart + */ + +namespace Server.Engines.Doom +{ + public class LeverPuzzleController : Item + { + private bool m_Enabled; + private static bool installed; + + private UInt16 m_MyKey; + private UInt16 m_TheirKey; + + private ArrayList m_Levers; + private ArrayList m_Teles; + private ArrayList m_Statues; + private ArrayList m_Tiles; + private Mobile m_Successful; + private LampRoomBox m_Box; + private Region m_LampRoom; + + private Timer m_Timer; + private Timer l_Timer; + + public static void Initialize() + { + CommandSystem.Register( "GenLeverPuzzle", AccessLevel.Administrator, new CommandEventHandler( GenLampPuzzle_OnCommand ) ); + } + + [Usage( "GenLeverPuzzle" )] + [Description( "Generates lamp room and lever puzzle in doom." )] + public static void GenLampPuzzle_OnCommand( CommandEventArgs e ) + { + foreach ( Item item in Map.Malas.GetItemsInRange( lp_Center, 0 ) ) + { + if ( item is LeverPuzzleController ) + { + e.Mobile.SendMessage( "Lamp room puzzle already exists: please delete the existing controller first ..." ); + return; + } + } + e.Mobile.SendMessage( "Generating Lamp Room puzzle..." ); + new LeverPuzzleController().MoveToWorld( lp_Center, Map.Malas ); + + if ( !installed ) + e.Mobile.SendMessage( "There was a problem generating the puzzle." ); + else + e.Mobile.SendMessage( "Lamp room puzzle successfully generated." ); + } + + [CommandProperty( AccessLevel.GameMaster )] + public UInt16 MyKey { get{ return m_MyKey; } set{ m_MyKey = value; } } + + [CommandProperty( AccessLevel.GameMaster )] + public UInt16 TheirKey { get{ return m_TheirKey; } set{ m_TheirKey = value; } } + + [CommandProperty( AccessLevel.GameMaster )] + public bool Enabled { get{ return m_Enabled; } set{ m_Enabled = value; } } + + public Mobile Successful { get{ return m_Successful; } } + + public bool CircleComplete + { + get /* OSI: all 5 must be occupied */ + { + for (int i=0; i<5; i++) + { + if( GetOccupant( i ) == null) + { + return false; + } + } + return true; + } + } + + public LeverPuzzleController() : base( 0x1822 ) + { + Movable=false; + Hue=0x4c; + installed=true; + int i=0; + + m_Levers = new ArrayList(); /* codes are 0x1 shifted left x # of bits, easily handled here */ + for (; i<4; i++) + m_Levers.Add( AddLeverPuzzlePart( TA[i], new LeverPuzzleLever( (ushort)(1<>i)&1)==1)&&(((TheirKey>>i)&1)==1) ) + { + Correct++; + } + } + + PuzzleStatus( Statue_Msg[Correct], (Correct>0) ? Correct.ToString() : null ); + + for (int i=0; i<5; i++) + { + if(( m_Player=GetOccupant( i )) != null ) + { + Timer smash = new RockTimer( m_Player, this ); + smash.Start(); + } + } + } + } + ResetLevers(); + } + + public virtual void GenKey() /* Shuffle & build key */ + { + UInt16 tmp; int n, i; ushort[] CA = { 1,2,4,8 }; + for (i=0; i<4; i++) + { + n=(((n = Utility.Random(0,3))==i) ? n&~i : n ); /* if(i==n) { return pointless; } */ + tmp = CA[i]; + CA[i]=CA[n]; + CA[n]=tmp; + } + for(i=0; i<4; MyKey=(ushort)(CA[(i++)]|(MyKey<<=4))) {} + } + + public class RockTimer : Timer + { + private int Count; + private Mobile m_Player; + private LeverPuzzleController m_Controller; + + public RockTimer( Mobile player, LeverPuzzleController Controller ) + : base( TimeSpan.Zero, TimeSpan.FromSeconds( .25 ) ) + { + Count = 0; + m_Player=player; + m_Controller = Controller; + } + + private int Rock() + { + return 0x1363+Utility.Random( 0, 11 ); + } + + protected override void OnTick() + { + if( m_Player == null || !(m_Player.Map == Map.Malas) ) + { + Stop(); + } + else + { + Count++; + if ( Count == 1 ) /* TODO consolidate */ + { + m_Player.Paralyze( TimeSpan.FromSeconds(2) ); + Effects.SendTargetEffect( m_Player, 0x11B7, 20, 10 ); + PlayerSendASCII( m_Player, 0 ); // You are pinned down ... + + PlaySounds( m_Player.Location, ( !m_Player.Female ) ? fs : ms ); + PlayEffect( ZAdjustedIEFromMobile( m_Player, 50 ), m_Player, 0x11B7, 20, false ); + } + else if ( Count == 2 ) + { + DoDamage( m_Player, 80, 90, false ); + Effects.SendTargetEffect( m_Player, 0x36BD, 20, 10 ); + PlaySounds( m_Player.Location, exp ); + PlayerSendASCII( m_Player, 1 ); // A speeding rock ... + + if( AniSafe( m_Player )) + { + m_Player.Animate( 21, 10, 1, true, true, 0 ); + } + } + else if ( Count == 3 ) + { + Stop(); + + Effects.SendTargetEffect( m_Player, 0x36B0, 20, 10 ); + PlayerSendASCII( m_Player, 1 ); // A speeding rock ... + PlaySounds( m_Player.Location, ( !m_Player.Female ) ? fs2 : ms2 ); + + int j = Utility.Random(6,10); + for(int i=0; i mobiles = m_Controller.m_LampRoom.GetMobiles(); + + if ( ticks >= 71 || m_Controller.m_LampRoom.GetPlayerCount() == 0 ) + { + foreach ( Mobile mobile in mobiles ) + { + if( mobile != null && !mobile.Deleted && !mobile.IsDeadBondedPet ) + { + mobile.Kill(); + } + } + m_Controller.Enabled=true; + Stop(); + } + else + { + if ( ticks % 12 == 0 ) + { + level++; + } + foreach ( Mobile mobile in mobiles ) + { + if ( IsValidDamagable( mobile ) ) + { + if ( ticks % 2 == 0 && level == 5 ) + { + if ( mobile.Player ) + { + mobile.Say( 1062092 ); + if( AniSafe( mobile )) + { + mobile.Animate( 32, 5, 1, true, false, 0 ); + } + } + DoDamage( mobile, 15, 20, true ); + } + if ( Utility.Random( (int)(level & ~0xfffffffc), 3) == 3 ) + { + mobile.ApplyPoison( mobile, PA2[level] ); + } + if ( ticks % 12 == 0 && level > 0 && mobile.Player ) + { + mobile.SendLocalizedMessage( PA[level][0], null, PA[level][1] ); + } + } + } + for( int i=0; i<=level; i++ ) + { + SendLocationEffect( RandomPointIn( lr_Rect, -1 ), 0x36B0, Utility.Random( 150, 200 ), 0, PA[level][2] ); + } + } + } + } + + private static bool IsValidDamagable( Mobile m ) + { + if ( m != null && !m.Deleted ) + { + if( m.Player && m.Alive ) + { + return true; + } + +/* TODO: need to resolve lockup @ basecreature damage + + if( m is BaseCreature ) + { + BaseCreature bc=(BaseCreature)m; + if ( ( bc.Controlled || bc.Summoned ) && !bc.IsDeadBondedPet ) + { + return true; + } + } +*/ + } + return false; + } + + public static void MoveMobileOut( Mobile m ) + { + if ( m != null ) + { + BaseCreature.TeleportPets( m, lr_Exit, Map.Malas ); + m.Location = lr_Exit; + m.ProcessDelta(); + } + } + + public static bool AniSafe( Mobile m ) + { + return ( m != null && !TransformationSpellHelper.UnderTransformation( m ) && m.BodyMod == 0 && m.Alive ); + } + + public static IEntity ZAdjustedIEFromMobile( Mobile m, int ZDelta ) + { + return new Entity( Serial.Zero, new Point3D( m.X, m.Y, m.Z+ZDelta ), m.Map ); + } + + public static void DoDamage( Mobile m, int min, int max, bool poison ) + { + int damage = Utility.Random(min,max); + if ( Core.AOS ) + { + AOS.Damage( (m is BaseCreature) ? (BaseCreature)m : m, damage,(poison) ? 0 : 100 , 0, 0,(poison) ? 100 : 0, 0 ); + } + else + { + m.Damage( damage ); + } + } + + public static Point3D RandomPointIn( Point3D point, int range ) + { + return RandomPointIn( point.X-range, point.Y-range, range*2, range*2, point.Z ); + } + public static Point3D RandomPointIn( Rectangle2D rect, int z ) + { + return RandomPointIn( rect.X, rect.Y, rect.Height, rect.Width, z ); + } + public static Point3D RandomPointIn( int x, int y, int x2, int y2, int z ) + { + return new Point3D( Utility.Random( x, x2 ), Utility.Random( y, y2 ), z ); + } + + public static void PlaySounds( Point3D location, int[] sounds ) + { + foreach( int soundid in sounds ) + Effects.PlaySound( location, Map.Malas, soundid ); + } + + public static void PlayEffect( IEntity from, IEntity to, int itemid, int speed, bool explodes ) + { + Effects.SendMovingParticles( from, to, itemid, speed, 0, true, explodes, 2, 0, 0 ); + } + + public static void SendLocationEffect( IPoint3D p, int itemID, int speed, int duration, int hue ) + { + Effects.SendPacket( p, Map.Malas, new LocationEffect( p, itemID, speed, duration, hue, 0 ) ); + } + + public static void PlayerSendASCII( Mobile player, int index ) + { + player.Send( new AsciiMessage( Serial.MinusOne, 0xFFFF, MessageType.Label, MsgParams[index][0], MsgParams[index][1], null, Msgs[index] )); + } + + /* I cant find any better way to send "speech" using fonts other than default */ + public static void POHMessage( Mobile from, int index ) + { + Packet p = new AsciiMessage( from.Serial, from.Body, MessageType.Regular, MsgParams[index][0], MsgParams[index][1], from.Name, Msgs[index] ); + p.Acquire(); + foreach( NetState state in from.Map.GetClientsInRange( from.Location ) ) + state.Send( p ); + + Packet.Release( p ); + } + + public static string[] Msgs = + { + "You are pinned down by the weight of the boulder!!!", // 0 + "A speeding rock hits you in the head!", // 1 + "OUCH!" // 2 + }; + /* font&hue for above msgs. index matches */ + + public static int[][] MsgParams = + { + new int[]{ 0x66d, 3 }, + new int[]{ 0x66d, 3 }, + new int[]{ 0x34, 3 } + }; + /* World data for items */ + + public static int[][] TA = + { + + new int[]{316, 64, 5}, /* 3D Coords for levers */ + new int[]{323, 58, 5}, + new int[]{332, 63, 5}, + new int[]{323, 71, 5}, + + new int[]{324, 64}, /* 2D Coords for standing regions */ + new int[]{316, 65}, + new int[]{324, 58}, + new int[]{332, 64}, + new int[]{323, 72}, + + new int[]{468, 92, -1}, new int[]{0x181D, 0x482}, /* 3D coord, itemid+hue for L.R. teles */ + new int[]{469, 92, -1}, new int[]{0x1821, 0x3fd}, + new int[]{470, 92, -1}, new int[]{0x1825, 0x66d}, + + new int[]{319, 70, 18}, new int[]{0x12d8}, /* 3D coord, itemid for statues */ + new int[]{329, 60, 18}, new int[]{0x12d9}, + + new int[]{469, 96, 6} /* 3D Coords for Fake Box */ + }; + + /* CLILOC data for statue "correct souls" messages */ + + public static int[] Statue_Msg = { 1050009, 1050007, 1050008, 1050008 }; + + /* Exit & Enter locations for the lamp room */ + + public static Point3D lr_Exit = new Point3D( 353, 172, -1 ); + public static Point3D lr_Enter = new Point3D( 467, 96, -1 ); + + /* "Center" location in puzzle */ + + public static Point3D lp_Center = new Point3D( 324, 64, -1 ); + + /* Lamp Room Area */ + + public static Rectangle2D lr_Rect = new Rectangle2D( 465, 92, 10, 10 ); + + /* Lamp Room area Poison message data */ + + public static int[][] PA = + { + new int[]{ 0, 0, 0xA6 }, + new int[]{ 1050001, 0x485, 0xAA }, + new int[]{ 1050003, 0x485, 0xAC }, + new int[]{ 1050056, 0x485, 0xA8 }, + new int[]{ 1050057, 0x485, 0xA4 }, + new int[]{ 1062091, 0x23F3, 0xAC } + }; + public static Poison[] PA2 = + { + Poison.Lesser, + Poison.Regular, + Poison.Greater, + Poison.Deadly, + Poison.Lethal, + Poison.Lethal + }; + + /* SOUNDS */ + + private static int[] fs={0x144, 0x154}; + private static int[] ms={0x144, 0x14B}; + private static int[] fs2={0x13F, 0x154}; + private static int[] ms2={0x13F, 0x14B}; + private static int[] cs1={0x244}; + private static int[] exp={0x307}; + + public LeverPuzzleController( Serial serial ) : base( serial ) + { + } + + public override void Serialize( GenericWriter writer ) + { + base.Serialize( writer ); + writer.Write( (int) 0 ); // version + writer.WriteItemList( m_Levers, true ); + writer.WriteItemList( m_Statues, true ); + writer.WriteItemList( m_Teles, true ); + writer.Write( m_Box ); + } + + public override void Deserialize( GenericReader reader ) + { + base.Deserialize( reader ); + + int version = reader.ReadInt(); + + m_Levers = reader.ReadItemList(); + m_Statues = reader.ReadItemList(); + m_Teles = reader.ReadItemList(); + + m_Box = reader.ReadItem() as LampRoomBox; + + m_Tiles = new ArrayList(); + for (int i = 4; i<9; i++) + m_Tiles.Add( new LeverPuzzleRegion( this, TA[i] )); + + m_LampRoom = new LampRoomRegion( this ); + m_Enabled = true; + m_TheirKey = 0; + m_MyKey = 0; + GenKey(); + } + } +} + diff --git a/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs b/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs new file mode 100644 index 000000000..67b03a11a --- /dev/null +++ b/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs @@ -0,0 +1,199 @@ +using System; +using System.Collections; +using Server; +using Server.Spells; +using Server.Mobiles; +using Server.Network; + +namespace Server.Engines.Doom +{ + public class LampRoomBox : Item + { + private LeverPuzzleController m_Controller; + private Mobile m_Wanderer; + + public LampRoomBox( LeverPuzzleController controller ) : base( 0xe80 ) + { + m_Controller = controller; + ItemID = 0xe80; + Movable = false; + } + + public override void OnDoubleClick( Mobile m ) + { + if ( !m.InRange( this.GetWorldLocation(), 3 ) ) + return; + if ( m_Controller.Enabled ) + return; + + if ( (m_Wanderer == null || !m_Wanderer.Alive) ) + { + m_Wanderer = new WandererOfTheVoid(); + m_Wanderer.MoveToWorld( LeverPuzzleController.lr_Enter, Map.Malas ); + m_Wanderer.PublicOverheadMessage( MessageType.Regular, 0x3B2, 1060002, "" ); // I am the guardian of... + Timer.DelayCall( TimeSpan.FromSeconds( 5.0 ), new TimerCallback( CallBackMessage ) ); + } + } + + public void CallBackMessage() + { + PublicOverheadMessage( MessageType.Regular, 0x3B2, 1060003, "" ); // You try to pry the box open... + } + public override void OnAfterDelete() + { + if( m_Controller!=null && !m_Controller.Deleted ) + m_Controller.Delete(); + } + public LampRoomBox( Serial serial ) : base( serial ) + { + } + + public override void Serialize( GenericWriter writer ) + { + base.Serialize( writer ); + writer.Write( (int) 0 ); // version + writer.Write( m_Controller ); + } + + public override void Deserialize( GenericReader reader ) + { + base.Deserialize( reader ); + int version = reader.ReadInt(); + m_Controller = reader.ReadItem() as LeverPuzzleController; + } + } + + public class LeverPuzzleStatue : Item + { + private LeverPuzzleController m_Controller; + + public LeverPuzzleStatue( int[] dat, LeverPuzzleController controller ) : base( dat[0] ) + { + m_Controller=controller; + Hue = 0x44E; + Movable = false; + } + public override void OnAfterDelete() + { + if( m_Controller!=null && !m_Controller.Deleted ) + m_Controller.Delete(); + } + public LeverPuzzleStatue( Serial serial ) : base( serial ) + { + } + public override void Serialize( GenericWriter writer ) + { + base.Serialize( writer ); + writer.Write( (int) 0 ); // version + writer.Write( m_Controller ); + } + public override void Deserialize( GenericReader reader ) + { + base.Deserialize( reader ); + int version = reader.ReadInt(); + m_Controller = reader.ReadItem() as LeverPuzzleController; + } + } + + public class LeverPuzzleLever : Item + { + private UInt16 m_Code; + private LeverPuzzleController m_Controller; + + [CommandProperty( AccessLevel.GameMaster )] + public UInt16 Code + { + get{ return m_Code; } + } + + public LeverPuzzleLever( UInt16 code, LeverPuzzleController controller ) : base( 0x108E ) + { + m_Controller=controller; + m_Code = code; + Hue = 0x66D; + Movable = false; + } + + public override void OnDoubleClick( Mobile m ) + { + if ( m != null && m_Controller.Enabled ) + { + ItemID^=2; + Effects.PlaySound( Location, Map, 0x3E8 ); + m_Controller.LeverPulled( m_Code ); + } + else + { + m.SendLocalizedMessage( 1060001 ); // You throw the switch, but the mechanism cannot be engaged again so soon. + } + } + + public override void OnAfterDelete() + { + if( m_Controller != null && !m_Controller.Deleted ) + m_Controller.Delete(); + } + + public LeverPuzzleLever( Serial serial ) : base( serial ) + { + } + public override void Serialize( GenericWriter writer ) + { + base.Serialize( writer ); + writer.Write( (int) 0 ); // version + writer.Write( (ushort) m_Code ); + writer.Write( m_Controller ); + } + public override void Deserialize( GenericReader reader ) + { + base.Deserialize( reader ); + int version = reader.ReadInt(); + m_Code = reader.ReadUShort(); + m_Controller = reader.ReadItem() as LeverPuzzleController; + } + } + public class LampRoomTelePorter : Item + { + public LampRoomTelePorter( int[] dat ) + { + Hue = dat[1]; + ItemID = dat[0]; + Movable = false; + } + + public override bool HandlesOnMovement { get { return true; } } + public override bool OnMoveOver( Mobile m ) + { + if( m != null && m is PlayerMobile ) + { + if ( SpellHelper.CheckCombat( m ) ) + { + m.SendLocalizedMessage( 1005564, "", 0x22 ); // Wouldst thou flee during the heat of battle?? + } + else + { + Server.Mobiles.BaseCreature.TeleportPets( m, LeverPuzzleController.lr_Exit, Map.Malas ); + m.MoveToWorld( LeverPuzzleController.lr_Exit, Map.Malas ); + return false; + } + } + return true; + } + + public LampRoomTelePorter( Serial serial ) : base( serial ) + { + } + public override void Serialize( GenericWriter writer ) + { + base.Serialize( writer ); + writer.Write( (int) 0 ); // version + } + public override void Deserialize( GenericReader reader ) + { + base.Deserialize( reader ); + int version = reader.ReadInt(); + } + } +} + + diff --git a/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs b/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs new file mode 100644 index 000000000..796b7f0d3 --- /dev/null +++ b/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs @@ -0,0 +1,127 @@ +using System; +using Server; +using Server.Mobiles; +using Server.Regions; + +namespace Server.Engines.Doom +{ + public class LampRoomRegion : BaseRegion + { + private LeverPuzzleController Controller; + + public LampRoomRegion ( LeverPuzzleController controller ) + : base( null, Map.Malas, Region.Find( LeverPuzzleController.lr_Enter, Map.Malas ), LeverPuzzleController.lr_Rect ) + { + Controller = controller; + Register(); + } + + public static void Initialize() + { + EventSink.Login += new LoginEventHandler( OnLogin ); + } + + public static void OnLogin( LoginEventArgs e ) + { + Mobile m = e.Mobile; + Rectangle2D rect = LeverPuzzleController.lr_Rect; + if ( m.X >= rect.X && m.X <= (rect.X+10) && m.Y >= rect.Y && m.Y <= (rect.Y+10) && m.Map == Map.Internal ) + { + Timer kick = new LeverPuzzleController.LampRoomKickTimer( m ); + kick.Start(); + } + } + + public override void OnEnter( Mobile m ) + { + if ( m == null || m is WandererOfTheVoid ) + return; + + if ( m.AccessLevel > AccessLevel.Player ) + return; + + if ( Controller.Successful != null ) + { + if ( m is PlayerMobile ) + { + if ( m == Controller.Successful ) + { + return; + } + } + else if ( m is BaseCreature ) + { + BaseCreature bc = (BaseCreature)m; + if(( bc.Controlled && bc.ControlMaster == Controller.Successful ) || bc.Summoned ) + { + return; + } + } + } + Timer kick = new LeverPuzzleController.LampRoomKickTimer( m ); + kick.Start(); + } + + public override void OnExit( Mobile m ) + { + if( m != null && m == Controller.Successful ) + Controller.RemoveSuccessful(); + } + + public override void OnDeath( Mobile m ) + { + if( m != null && !m.Deleted && !(m is WandererOfTheVoid) ) + { + Timer kick = new LeverPuzzleController.LampRoomKickTimer( m ); + kick.Start();; + } + } + + public override bool OnSkillUse( Mobile m, int Skill ) /* just in case */ + { + if (( Controller.Successful == null ) || ( m.AccessLevel == AccessLevel.Player && m != Controller.Successful )) + { + return false; + } + return true; + } + } + + public class LeverPuzzleRegion : BaseRegion + { + private LeverPuzzleController Controller; + public Mobile m_Occupant; + + [CommandProperty( AccessLevel.GameMaster )] + public Mobile Occupant + { + get + { + if ( m_Occupant != null && m_Occupant.Alive ) + return m_Occupant; + return null; + } + } + + public LeverPuzzleRegion ( LeverPuzzleController controller, int[] loc ) + : base( null, Map.Malas, Region.Find( LeverPuzzleController.lr_Enter, Map.Malas ), new Rectangle2D(loc[0],loc[1],1,1) ) + { + Controller = controller; + Register(); + } + + public override void OnEnter( Mobile m ) + { + if( m != null && m_Occupant == null && m is PlayerMobile && m.Alive ) + m_Occupant = m; + } + + public override void OnExit( Mobile m ) + { + if( m != null && m == m_Occupant ) + m_Occupant = null; + } + } +} + +