Exemple #1
0
        public KinRansomChest(IOBAlignment IOBAlignment, bool bFill) : base(0xE41)
        {
            this.IOBAlignment  = IOBAlignment;
            this.Movable       = false;
            this.TrapType      = Utility.RandomBool() ? TrapType.PoisonTrap : TrapType.ExplosionTrap;
            this.TrapPower     = 100;
            this.Locked        = true;
            this.RequiredSkill = 100;
            this.LockLevel     = this.RequiredSkill - 10;
            this.MaxLockLevel  = this.RequiredSkill + 40;

            if (bFill == true)
            {
                KinRansomChest.Fill(this);
            }
        }
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();

			switch (version)
			{
				case 2:
				{
					int itemCount = reader.ReadInt32();

					m_spawners = new ArrayList(itemCount);

					for (int i = 0; i < itemCount; ++i)
					{
						Item item = reader.ReadItem();

						if (item != null)
							m_spawners.Add(item);
					}

					goto case 1;
				}

				case 1:
				{
					m_KinRansomChest = reader.ReadItem() as KinRansomChest;
					m_RegStone = reader.ReadItem() as RegionControl;
					m_OldGuardMode = reader.ReadBool();
					m_OldCountMode = reader.ReadBool();
					m_RegionName = reader.ReadString();
					m_IOBAlignment = (IOBAlignment)reader.ReadInt();
					m_ChestOpenTime = reader.ReadDateTime();
					m_bChestOpenInit = reader.ReadBool();
					m_PreEventTime = reader.ReadDateTime();
					m_bPreEventInit = reader.ReadBool();
					goto case 0;
				}

				case 0:
				{	// all done
					break;
				}
			}
		}
		/// <summary>
		/// Get and save all the all the quest variables.
		/// We will use this information for the pre event announcements, and the event setup
		///		when the event starts.
		/// </summary>
		public void OnPreEventInit()
		{
			// find the ransom chests
			ArrayList list = new ArrayList();
			foreach (Item ix in World.Items.Values)
				if (ix is KinRansomChest)
					list.Add(ix);					

			// process the list of chests
			if (list.Count > 0)
			{
				// select a chest at random
				m_KinRansomChest = list[Utility.Random(list.Count)] as KinRansomChest;

				if ( m_KinRansomChest != null )
				{
					// save the alignment
					m_IOBAlignment = m_KinRansomChest.IOBAlignment;

					// turn off alignment changing during event (and 24 hour warning)					
					CoreAI.SetDynamicFeature( CoreAI.FeatureBits.GuildKinChangeDisabled );

					// turn off guards from this custom regions
					CustomRegion reg = Region.Find( m_KinRansomChest.Location, m_KinRansomChest.Map ) as CustomRegion;
					if( reg != null ) 
					{
						try
						{
							// if a custom region does exsist find its controller
							m_RegStone = reg.GetRegionControler(); 
							if (m_RegStone != null )
							{	
								m_RegionName = m_RegStone.RegionName;
							}
						}
	
						catch(NullReferenceException e)
						{
                            LogHelper.LogException(e);
							Console.WriteLine("Caught exception: {0} ", e.Message); 
						}
						catch(Exception ex)
						{
                            LogHelper.LogException(ex);
							Console.WriteLine("Caught exception:", ex.Message); 
						}
					}

                    // 11/21/06 Pla:  Add the chest region to the no camp zones!
                    Rectangle2D rect = GetChestArea();                    
                    if (rect.X != 0 && rect.Y != 0 )
                        CampHelper.AddRestrictedArea(rect);

				}
			}
			else
			{
				Console.WriteLine("KinRansomAES: No Ransom chests found, aborting event..");
				// tell our base class to stop processing.
				//	the base will also begin cleanup
				ValidState = false;
			}

			Console.WriteLine("KinRansomAES: Pre Event setup.");
		}