Full Version : Got a small glitch on Guardian's Room
xmlspawner >>Scripting Support >>Got a small glitch on Guardian's Room


<< Prev | Next >>

Erica- 03-03-2008
Hi ok the issue im having is that on osi when you open the door and right away walk in and boom doors lock right away once you walk in my problem is you walk in and you can walk around for like a min or so the doors are closing like the normal doors that you open in your house and takes a few to close im wondering how can i make it where as soon as you open those 2 doors that once you walk right in should lock right away any way on how to do this and what would i add Thank You heres one of the scripts im assuming has to do with this script.

CODE
using System;
using System.Collections;
using Server;
using Server.Mobiles;
using Server.Network;

namespace Server.Items
{
public class GuardianController : Item
{
 public Rectangle2D Rect = new Rectangle2D( 356, 6, 19, 19 );

 private GuardianDoor m_Door;

 public PoisonTimer m_Timer;

 private bool m_CanActive;

 [CommandProperty( AccessLevel.GameMaster )]
 public bool CanActive { get { return m_CanActive; } set { m_CanActive = value; } }

 [CommandProperty( AccessLevel.GameMaster )]
 public GuardianDoor Door { get { return m_Door; } set { m_Door = value; } }

 private bool Check()
 {
  foreach ( Item item in World.Items.Values )
  {
   if ( item is GuardianController && !item.Deleted && item != this )
   {
    return true;
   }
  }

  return false;
 }

 [Constructable]
 public GuardianController() : base( 0xFEA )
 {
  if ( Check() )
  {
   World.Broadcast( 0x35, true, "Another guardian's room controller exists in the world!" );
   Delete();
   return;
  }

  Hue = 0x835;

  Movable = false;

  Setup();
 }

 public void Setup()
 {
  m_Door = new GuardianDoor( DoorFacing.SouthCW );

  m_Door.MoveToWorld( new Point3D( 355, 15, -1 ), Map.Malas );

  m_CanActive = true;

  for ( int i = 0; i < 3; i++ )
  {
   int x = Utility.Random( Rect.X, Rect.Width );
   int y = Utility.Random( Rect.Y, Rect.Height );

   GuardianTreasureChest chest = new GuardianTreasureChest( 0xE41 );

   int itemID = Utility.RandomList( chest.ItemIDs );

   chest.ItemID = itemID;

   chest.MoveToWorld( new Point3D( x, y, -1 ), Map.Malas );
  }
 }

 public override bool HandlesOnMovement { get { return true; } }

 public override void OnMovement( Mobile m, Point3D oldLocation )
 {
  if ( m != null && m_Door != null && !m_Door.Locked && !m_Door.Open && m.Player && m.Alive && m_CanActive )
  {
   IPooledEnumerable eable = Map.Malas.GetMobilesInBounds( Rect );

   foreach ( object obj in eable )
   {
    if ( obj is Mobile )
    {
     Mobile mobile = obj as Mobile;

     if ( mobile != null && !(mobile is DarkGuardian) )
     {
      if ( mobile.Player )
      {
       mobile.SendLocalizedMessage( 1050000, null, 0x41 ); // The locks on the door click loudly and you begin to hear a faint hissing near the walls.
      }

      for ( int j = 0; j < 2; j++ )
      {
       DarkGuardian guard = new DarkGuardian();

       guard.Map = Map.Malas;

       guard.Location = new Point3D( 365, 15, -1 );
      }
     }
    }
   }

   eable.Free();

   m_Door.Locked = true;
   m_Door.Link.Locked = true;

   if ( m_Timer != null )
   {
    m_Timer.Stop();
   }

   m_Timer = new PoisonTimer( this );

   m_Timer.Start();

   m_CanActive = false;
  }
 }

 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;

    if ( mobile != null )
    {
     if ( mobile.Player )
     {
      mobile.SendLocalizedMessage( 1050055, null, 0x41 ); // You hear the doors unlocking and the hissing stops.
     }

     if ( mobile is DarkGuardian )
     {
      list.Add( mobile );
     }
    }
   }
  }

  eable.Free();

  for ( int i = 0; i < list.Count; i++ )
  {
   DarkGuardian guardian = list[ i ] as DarkGuardian;

   if ( guardian != null )
   {
    guardian.Delete();
   }
  }

  if ( m_Door != null && m_Door.Link != null )
  {
   m_Door.Locked = false;

   m_Door.Link.Locked = false;
  }

  if ( m_Timer != null )
  {
   m_Timer.Stop();
  }

  InternalTimer timer = new InternalTimer( this ); // at OSI we have some delay for looting corpses;-)

  timer.Start();
 }

 public GuardianController( Serial serial ) : base( serial )
 {
 }

 public override void Serialize( GenericWriter writer )
 {
  base.Serialize( writer );

  writer.Write( (int) 0 ); // version

  writer.Write( m_Door );
 }

 public override void Deserialize( GenericReader reader )
 {
  base.Deserialize( reader );

  int version = reader.ReadInt();

  m_Door = reader.ReadItem() as GuardianDoor;

  ClearRoom();

  m_CanActive = true;
 }

 public class InternalTimer : Timer
 {
  public GuardianController m_Controller;

  public InternalTimer( GuardianController controller ) : base( TimeSpan.FromSeconds( 0.0 ) )
  {
   m_Controller = controller;
  }

  protected override void OnTick()
  {
   m_Controller.CanActive = true;
  }
 }

 public class PoisonTimer : Timer
 {
  public GuardianController m_Controller;
  public int count = 1;

  public PoisonTimer( GuardianController controller ) : base( TimeSpan.Zero, TimeSpan.FromSeconds( 1.0 ) )
  {
   m_Controller = controller;
  }

  public void CheckAlive()
  {
   bool AliveCreatures = false;

   bool AliveGuardians = 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 )
     {
      if ( mobile is DarkGuardian )
      {
       AliveGuardians = true;
      }
      else
      {
       AliveCreatures = true;
      }
     }
    }
   }

   eable.Free();

   if ( !(AliveCreatures && AliveGuardians) )
   {
    m_Controller.ClearRoom();

    Stop();
   }
  }

  private static Point3D[] m_FaceLocations = new Point3D[] {new Point3D( 356, 7, -1 ), new Point3D( 356, 13, -1 ), new Point3D( 356, 16, -1 ), new Point3D( 356, 22, -1 ), new Point3D( 358, 6, -1 ), new Point3D( 363, 6, -1 ), new Point3D( 368, 6, -1 ), new Point3D( 373, 6, -1 )};

  public static Point3D RandomFaceLocation()
  {
   int index = Utility.Random( m_FaceLocations.Length );

   return m_FaceLocations[ index ];
  }

  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 );

   Effects.SendLocationParticles( EffectItem.Create( RandomFaceLocation(), Map.Malas, EffectItem.DefaultDuration ), 0x1145, 1, 100, 0, 0x4, 0x1F7A, 0 );
   Effects.SendLocationParticles( EffectItem.Create( RandomFaceLocation(), Map.Malas, EffectItem.DefaultDuration ), 0x113A, 1, 100, 0, 0x4, 0x1F79, 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 DarkGuardian) )
     {
      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 GuardianController m_Controller;
  public int count = 1;

  public PainTimer( GuardianController 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 DarkGuardian) )
    {
     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
    }
   }
  }
 }
}
}

and just incase heres the other part of that script.

CODE
using System;
using Server;

namespace Server.Items
{
public class GuardianDoor : BaseDoor
{
 private InternalItem m_Item;
 private DoorFacing m_Face;

 [Constructable]
 public GuardianDoor( DoorFacing facing ) : base( 0x675 + (2*(int) facing), 0x676 + (2*(int) facing), 0xEC, 0xF3, BaseDoor.GetOffset( facing ) )
 {
  Movable = false;
  m_Face = facing;
  m_Item = new InternalItem( m_Face + 1, this );
  Link = m_Item;
 }

 public GuardianDoor( Serial serial ) : base( serial )
 {
 }

 public override void OnMapChange()
 {
  if ( m_Item != null )
  {
   m_Item.Map = Map;

   m_Item.Location = new Point3D( X, Y - 1, Z );
  }
 }

 public override void OnAfterDelete()
 {
  base.OnAfterDelete();

  if ( m_Item != null )
  {
   m_Item.Delete();
  }
 }

 public override void Serialize( GenericWriter writer )
 {
  base.Serialize( writer );

  writer.Write( (int) 0 ); // version

  writer.Write( m_Item );

  writer.Write( (int) m_Face );
 }

 public override void Deserialize( GenericReader reader )
 {
  base.Deserialize( reader );

  int version = reader.ReadInt();

  m_Item = reader.ReadItem() as InternalItem;

  m_Face = (DoorFacing) (reader.ReadInt());
 }

 private class InternalItem : BaseDoor
 {
  private GuardianDoor m_Item;
  private DoorFacing m_Face;

  public InternalItem( DoorFacing facing, GuardianDoor item ) : base( 0x675 + (2*(int) facing), 0x676 + (2*(int) facing), 0xEC, 0xF3, BaseDoor.GetOffset( facing ) )
  {
   Movable = false;
   m_Face = facing;
   m_Item = item;
   Link = m_Item;
  }

  public InternalItem( Serial serial ) : base( serial )
  {
  }

  public override void OnAfterDelete()
  {
   base.OnAfterDelete();

   if ( m_Item != null )
   {
    m_Item.Delete();
   }
  }

  public override void Serialize( GenericWriter writer )
  {
   base.Serialize( writer );

   writer.Write( (int) 0 ); // version

   writer.Write( m_Item );

   writer.Write( (int) m_Face );
  }

  public override void Deserialize( GenericReader reader )
  {
   base.Deserialize( reader );

   int version = reader.ReadInt();

   m_Item = reader.ReadItem() as GuardianDoor;

   m_Face = (DoorFacing) (reader.ReadInt());
  }
 }
}
}


Erica- 03-04-2008
*PS* everything else works like it should its the doors that are not working right like i posted it on top Please if theres way to make it trigger theses doors to close as soon as they open the door and walk in for it too close tell me what i should add on the scripts Thank You sorry not trying to bump post.

noonehome- 03-04-2008
you could use a xmlspawner on a proximity trigger that once a mobile gets within that proximity it sets the doors to closed and locked

Erica- 03-04-2008
QUOTE (noonehome @ March 04, 2008 07:40 am)
you could use a xmlspawner on a proximity trigger that once a mobile gets within that proximity it sets the doors to closed and locked

Yea was thinking of that but the GuardianController is part of the door so when i add [GuardianController it puts the doors so theres gotta be a way to fix the glitch thanks tho.

Erica- 03-04-2008
Hi ok i got it to close now when you open doors and walk in the problem now is this line.

CODE
public class InternalTimer : Timer
 {
  public GuardianController m_Controller;

  public InternalTimer( GuardianController controller ) : base( TimeSpan.FromSeconds( 30.0 ) )
  {
   m_Controller = controller;
  }

  protected override void OnTick()
  {
   m_Controller.CanActive = true;
  }
 }

whats happenning here is that for entrance when opening door takes 30 seconds to close and lock door which i tryed 1.0 and that makes door shut lock right away when go in but theres this problem that when you kill the guardians you hear the click on door open but since seconds are 30 will give you that time to get out before it locks again itself 30 sec now i tryed 1.0 sec door close locked right away but then when you kill the guardians as soon as you hear door click to open try to walk to door or run and it locks right away so im needing a code for it to not close for a mintue or so so it dont use the 1.0 second when going in any way of me getting that part fixed heres the new fix so far.


CODE
using System;
using System.Collections;
using Server;
using Server.Mobiles;
using Server.Network;

namespace Server.Items
{
public class GuardianController : Item
{
 public Rectangle2D Rect = new Rectangle2D( 356, 6, 19, 19 );

 private GuardianDoor m_Door;

 public PoisonTimer m_Timer;

 private bool m_CanActive;

 [CommandProperty( AccessLevel.GameMaster )]
 public bool CanActive { get { return m_CanActive; } set { m_CanActive = value; } }

 [CommandProperty( AccessLevel.GameMaster )]
 public GuardianDoor Door { get { return m_Door; } set { m_Door = value; } }

 private bool Check()
 {
  foreach ( Item item in World.Items.Values )
  {
   if ( item is GuardianController && !item.Deleted && item != this )
   {
    return true;
   }
  }

  return false;
 }

 [Constructable]
 public GuardianController() : base( 0xFEA )
 {
  if ( Check() )
  {
   World.Broadcast( 0x35, true, "Another guardian's room controller exists in the world!" );
   Delete();
   return;
  }

  Hue = 0x835;

  Movable = false;

  Setup();
 }

 public void Setup()
 {
  m_Door = new GuardianDoor( DoorFacing.SouthCW );

  m_Door.MoveToWorld( new Point3D( 355, 15, -1 ), Map.Malas );

  m_CanActive = true;

  for ( int i = 0; i < 3; i++ )
  {
   int x = Utility.Random( Rect.X, Rect.Width );
   int y = Utility.Random( Rect.Y, Rect.Height );

   GuardianTreasureChest chest = new GuardianTreasureChest( 0xE41 );

   int itemID = Utility.RandomList( chest.ItemIDs );

   chest.ItemID = itemID;

   chest.MoveToWorld( new Point3D( x, y, -1 ), Map.Malas );
  }
 }

 public override bool HandlesOnMovement { get { return true; } }

 public override void OnMovement( Mobile m, Point3D oldLocation )
 {
  if ( m_Door != null && !m_Door.Deleted && m_Door.Open && !m_Door.Locked && m != null && m.Player && m.Alive && m_CanActive && m.AccessLevel == AccessLevel.Player )
  {
   m_Door.Open = false;
   if ( m_Door.Link != null && !m_Door.Link.Deleted )
    m_Door.Link.Open = false;
  }
  if ( m != null && m_Door != null && !m_Door.Deleted && !m_Door.Locked && !m_Door.Open && m.Player && m.Alive && m_CanActive && m.AccessLevel == AccessLevel.Player )
  {
   IPooledEnumerable eable = Map.Malas.GetMobilesInBounds( Rect );

   foreach ( object obj in eable )
   {
    if ( obj is Mobile )
    {
     Mobile mobile = obj as Mobile;

     if ( mobile != null && !(mobile is DarkGuardian) )
     {
      if ( mobile.Player )
      {
       mobile.SendLocalizedMessage( 1050000, null, 0x41 ); // The locks on the door click loudly and you begin to hear a faint hissing near the walls.
            mobile.PlaySound( 500 );
                                         }

      for ( int j = 0; j < 2; j++ )
      {
       DarkGuardian guard = new DarkGuardian();

       guard.Map = Map.Malas;

       guard.Location = new Point3D( 365, 15, -1 );
      }
     }
    }
   }

   eable.Free();

   m_Door.Locked = true;
   m_Door.Link.Locked = true;

   if ( m_Timer != null )
   {
    m_Timer.Stop();
   }

   m_Timer = new PoisonTimer( this );

   m_Timer.Start();

   m_CanActive = false;
  }
 }

 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;

    if ( mobile != null )
    {
     if ( mobile.Player )
     {
      mobile.SendLocalizedMessage( 1050055, null, 0x41 ); // You hear the doors unlocking and the hissing stops.
           mobile.PlaySound( 500 );

                                   }

     if ( mobile is DarkGuardian )
     {
      list.Add( mobile );
     }
    }
   }
  }

  eable.Free();

  for ( int i = 0; i < list.Count; i++ )
  {
   DarkGuardian guardian = list[ i ] as DarkGuardian;

   if ( guardian != null )
   {
    guardian.Delete();
   }
  }

  if ( m_Door != null && !m_Door.Deleted && m_Door.Link != null )
  {
   m_Door.Locked = false;

   m_Door.Link.Locked = false;
  }

  if ( m_Timer != null )
  {
   m_Timer.Stop();
  }

  InternalTimer timer = new InternalTimer( this ); // at OSI we have some delay for looting corpses;-)

  timer.Start();
 }

 public GuardianController( Serial serial ) : base( serial )
 {
 }

 public override void Serialize( GenericWriter writer )
 {
  base.Serialize( writer );

  writer.Write( (int) 0 ); // version

  writer.Write( m_Door );
 }

 public override void Deserialize( GenericReader reader )
 {
  base.Deserialize( reader );

  int version = reader.ReadInt();

  m_Door = reader.ReadItem() as GuardianDoor;

  ClearRoom();

  m_CanActive = true;
 }

 public class InternalTimer : Timer
 {
  public GuardianController m_Controller;

  public InternalTimer( GuardianController controller ) : base( TimeSpan.FromSeconds( 30.0 ) )
  {
   m_Controller = controller;
  }

  protected override void OnTick()
  {
   m_Controller.CanActive = true;
  }
 }

 public class PoisonTimer : Timer
 {
  public GuardianController m_Controller;
  public int count = 1;

  public PoisonTimer( GuardianController controller ) : base( TimeSpan.Zero, TimeSpan.FromSeconds( 1.0 ) )
  {
   m_Controller = controller;
  }

  public void CheckAlive()
  {
   bool AliveCreatures = false;

   bool AliveGuardians = 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 )
     {
      if ( mobile is DarkGuardian )
      {
       AliveGuardians = true;
      }
      else
      {
       AliveCreatures = true;
      }
     }
    }
   }

   eable.Free();

   if ( !(AliveCreatures && AliveGuardians) )
   {
    m_Controller.ClearRoom();

    Stop();
   }
  }

  private static Point3D[] m_FaceLocations = new Point3D[] {new Point3D( 356, 7, -1 ), new Point3D( 356, 13, -1 ), new Point3D( 356, 16, -1 ), new Point3D( 356, 22, -1 ), new Point3D( 358, 6, -1 ), new Point3D( 363, 6, -1 ), new Point3D( 368, 6, -1 ), new Point3D( 373, 6, -1 )};

  public static Point3D RandomFaceLocation()
  {
   int index = Utility.Random( m_FaceLocations.Length );

   return m_FaceLocations[ index ];
  }

  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 );

   Effects.SendLocationParticles( EffectItem.Create( RandomFaceLocation(), Map.Malas, EffectItem.DefaultDuration ), 0x1145, 1, 100, 0, 0x4, 0x1F7A, 0 );
   Effects.SendLocationParticles( EffectItem.Create( RandomFaceLocation(), Map.Malas, EffectItem.DefaultDuration ), 0x113A, 1, 100, 0, 0x4, 0x1F79, 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 DarkGuardian) )
     {
      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 GuardianController m_Controller;
  public int count = 1;

  public PainTimer( GuardianController 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 DarkGuardian) )
    {
     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
    }
   }
  }
 }
}
}

ArteGordon- 03-04-2008
Given the code you posted, door closing when you first start should be immediate. It is not controlled by that timer.
That timer only controls how long the door will remain unlocked after the room is cleared.

What you might be seeing is the condition where someone clears the room and then leaves.
The door will remain unlocked for 30 seconds (that's what the timer does) and other people will be able to open them and go in during that time.

Erica- 03-04-2008
QUOTE (ArteGordon @ March 04, 2008 06:20 pm)
Given the code you posted, door closing when you first start should be immediate. It is not controlled by that timer.
That timer only controls how long the door will remain unlocked after the room is cleared.

What you might be seeing is the condition where someone clears the room and then leaves.
The door will remain unlocked for 30 seconds (that's what the timer does) and other people will be able to open them and go in during that time.

Hmm weird ok so what can i do for those door so when player from outside decides to open it and walks in to shut right away so the timer that you say gives them 30 sec or what ever seconds i give them to get out after killing the guardian all im trying to do is they go to doom decide to open those doors walks in and right away when they walk in should close on them so im not sure what else to do Thanks ArteGordon.

Erica- 03-04-2008
Maybe not have a timer for it to stay unlocked and just make it where once you go in and door shuts with locked =true to be where once you kill them door unlocks and stays on lock till you go out then come back in and lock over not sure what would you suggest thought Thanks.

ArteGordon- 03-04-2008
It isnt really an issue of door lock timing. The issue is that if you are going to give people 30 seconds of unlocked door access after the room is cleared, then anyone is free to walk in and out during that period.
To prevent people from just walking in, you would have to control exactly who is allowed to go in and out during that time.

You could maintain a list of the people that were in the room when it was cleared and only allow access to those people during that 30 seconds.

Erica- 03-04-2008
QUOTE (ArteGordon @ March 04, 2008 06:44 pm)
It isnt really an issue of door lock timing. The issue is that if you are going to give people 30 seconds of unlocked door access after the room is cleared, then anyone is free to walk in and out during that period.
To prevent people from just walking in, you would have to control exactly who is allowed to go in and out during that time.

You could maintain a list of the people that were in the room when it was cleared and only allow access to those people during that 30 seconds.

Hmm i see so now gotta try a different code for that hehe ok i'll try too see what i can come up with hehe been working on this issue for 2 days lol Thanks ArteGordon

Erica- 03-05-2008
Question ArteGordon let say i decided to add 2 doors with xmlspawner is there a way where to add that in xml spawner so when someone open Metaldoors an goes in that room it triggers and locks till they kill the creature in that room