context: using System;
  
  namespace Server.Items
  {
      public class AnkhPendant : BaseNecklace
      {
          private static bool AllowIlshenarShrines = false;
          private bool m_IsUseful;
  
          public override int LabelNumber { get { return 1079525; } } // Ankh Pendant
          private DateTime m_LastUse;
          public int VirtueEffect;
          private Timer m_Timer;
  
          [CommandProperty(AccessLevel.GameMaster)]
          public bool IsUseful
          {
              get { return m_IsUseful; }
              set { m_IsUseful = value; }
          }
  
          [Constructable]
          public AnkhPendant() : base(0x3BB5) //15285
          {
              Weight = 0.1;
              VirtueEffect = 0;
              m_IsUseful = false;
          }
  
          public override bool HandlesOnSpeech { get { return (Parent is Mobile); } }
  
          public override void OnSpeech(SpeechEventArgs e)
          {
              if (!e.Handled && Parent is Mobile)
              {
                  Mobile m = Parent as Mobile;
  
                  if (e.Mobile.Serial != m.Serial)
                  {
                      return;
                  }
  
                  string theirwords = e.Speech;
                  theirwords.ToLower();
                  int chant = 99;
  
                  for (int i = 0; i < m_ShrineMantra.Length; i++)
                  {
                      if (theirwords == m_ShrineMantra[i])
                      {
                          chant = i;
                      }
                  }
  
                  if (chant >= m_ShrineMantra.Length)
                  {
                      return;
                  }
  
                  bool disabled = false;
                  Point3D[] place = m_BritanniaShrines;
  
                  if (e.Mobile.Map == Map.Ilshenar)
                  {
                      if (!AllowIlshenarShrines)
                      {
                          disabled = true;
                      }
                      //else
                      //place = m_IllshShrines;
                  }
                  else if (e.Mobile.Map != Map.Felucca && e.Mobile.Map != Map.Trammel)
                  {
                      disabled = true;
                  }
  
                  if (disabled == true)
                  {
                      return;
                  }
  
                  bool rightplace = false;
  
                  foreach (Mobile mobile in e.Mobile.Map.GetMobilesInRange(place[chant], 5))
                  {
                      if (mobile != null)
                      {
                          if (mobile.Serial == e.Mobile.Serial)
                          {
                              rightplace = true;
                          }
                      }
                  }
  
                  if (rightplace == true)
                  {
                      GiveBonus(chant, e.Mobile);
                      e.Handled = true;
                  }
              }
          }
  
          public void GiveBonus(int chant, Mobile from)
          {
              if (VirtueEffect == chant)
              {
                  from.SendLocalizedMessage(1079544, String.Format("{0}", m_ShrineWords[chant])); // You already feel ~1_VIRTUE~ from your earlier contemplation of the virtues.
              }
  
              TimeSpan delay = m_LastUse - DateTime.UtcNow;
  
              if (delay < TimeSpan.Zero)
              {
                  delay = TimeSpan.Zero;
              }
  
              if (delay > TimeSpan.Zero)
              {
                  int seconds = (int)delay.TotalSeconds;
                  int minutes = 0;
                  int hours = 0;
  
                  if (seconds >= 60)
                  {
                      minutes = (seconds + 59) / 60;
                  }
  
                  if (minutes >= 60)
                  {
                      hours = (seconds + 3599) / 3600;
                  }
  
                  if (hours > 1)
                  {
                      from.SendLocalizedMessage(1079566, String.Format("{0}", hours)); // You feel as if you should contemplate what you've learned for another ~1_TIME~ hours.
                  }
                  else if (hours == 1)
                  {
                      from.SendLocalizedMessage(1079565); // You feel as if you should contemplate what you've learned for another hour or so.
                  }
                  else if (minutes > 0)
                  {
                      from.SendLocalizedMessage(1079568, String.Format("{0}", minutes)); // You feel as if you should contemplate what you've learned for another ~1_TIME~ minutes.
                  }
                  else if (seconds > 0)
                  {
                      from.SendLocalizedMessage(1079567, String.Format("{0}", seconds)); // You feel almost ready to learn more about the virtue again.
                  }
  
                  return;
              }
  
              double chance = Utility.RandomDouble();
  
              switch (chant)
              {
                  case 0: //Compassion
                      {
                          Attributes.RegenHits = 2;
                          break;
                      }
                  case 1: //Honesty
                      {
                          Attributes.RegenMana = 2;
                          break;
                      }
                  case 2: //Honor
                      {
                          Attributes.RegenStam = (chance >= 0.75) ? 2 : 1;
                          Attributes.RegenMana = (chance <= 0.25) ? 2 : 1;
                          break;
                      }
                  case 3: //Humility
                      {
                          if (chance >= 0.66)
                          {
                              Attributes.RegenHits = 3;
                          }
                          else if (chance >= 0.33)
                          {
                              Attributes.RegenStam = 3;
                          }
                          else
                          {
                              Attributes.RegenMana = 3;
                          }
  
                          break;
                      }
                  case 4: //Justice
                      {
                          Attributes.RegenHits = (chance >= 0.75) ? 2 : 1;
                          Attributes.RegenMana = (chance <= 0.25) ? 2 : 1;
                          break;
                      }
                  case 5: //Sacrifice
                      {
                          Attributes.RegenHits = (chance >= 0.75) ? 2 : 1;
                          Attributes.RegenStam = (chance <= 0.25) ? 2 : 1;
                          break;
                      }
                  case 6: //Spirituality
                      {
                          Attributes.RegenHits = (chance >= 0.25) ? 2 : 1;
                          chance = Utility.RandomDouble();
                          Attributes.RegenStam = (chance >= 0.25) ? 2 : 1;
                          chance = Utility.RandomDouble();
                          Attributes.RegenMana = (chance >= 0.25) ? 2 : 1;
                          break;
                      }
                  case 7: //Valor
                      {
                          Attributes.RegenStam = 2;
                          break;
                      }
              }
  
              if (IsUseful)
              {
                  Attributes.RegenHits *= 3;
                  Attributes.RegenStam *= 3;
                  Attributes.RegenMana *= 3;
              }
  
  
gt:             m_LastUse = DateTime.UtcNow + TimeSpan.FromMinutes(61);