RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Trying access and act remotely on a mobile's death.

Waverian

Wanderer
Trying access and act remotely on a mobile's death.

Trying to revamp a submission of mine and running into problems.

Code:
using System;
using Server;
using Server.Mobiles;

namespace Server.Items
{
	public class GuardianActivator : Item
	{
		public bool m_Inactive;
		
		[CommandProperty( AccessLevel.GameMaster )]
		public bool Inactive
		{
			get{ return m_Inactive; }
			set{ m_Inactive = value; }
		}

		[Constructable]
		public GuardianActivator() : base( 0x1BC3 )
		{
			Name = "guardian activator";
			Visible = false;
			Movable = false;
			Inactive = false;
		}

		public override bool OnMoveOver( Mobile m )
		{
			Mobile guardianone = new DarkGuardian();
			Mobile guardiantwo = new DarkGuardian();
			
			if( m is PlayerMobile )
			{
				if( m.Alive )
				{
					guardianone.MoveToWorld( new Point3D( 365, 12, -1 ), Map.Malas );
					guardiantwo.MoveToWorld( new Point3D( 357, 18, -1 ), Map.Malas );
					
					return true;
				}
				else
				{
					m.SendMessage( "Your spirit is carried out of the room, magically bound to your corpse." );
					m.Location = new Point3D( 276, 229, -1 ); 
					m.Corpse.Location = new Point3D( 276, 229, -1 );
				}
			}
			return false;
		}
		
		public GuardianActivator( Serial serial ) : base( serial )
		{
		}
		
		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			writer.Write( (int) 0 ); 
		}

		public override void Deserialize( GenericReader reader ) 
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();
		}
	}
}

Now what I want the script to do, is notice when darkguardianone and darkguardiantwo ( defined in the script, as you'll see ) die, and then act accordingly by changing the Inactive property to true.

I tried to steal a line from the Summoning Altar of the Victoria/Chyloth quest, and ended up with this:

Code:
using System;
using Server;
using Server.Mobiles;

namespace Server.Items
{
	public class GuardianActivator : Item
	{
		public bool m_Inactive;
		
		[CommandProperty( AccessLevel.GameMaster )]
		public bool Inactive
		{
			get{ return m_Inactive; }
			set{ m_Inactive = value; }
		}
		
		private DarkGuardian m_Guardian;
		
		public DarkGuardian Guardian
		{
			get{ return m_Guardian; }
			set
			{
				m_Guardian = value;
				CheckGuardian();
			}
		}
		
		public void CheckGuardian()
		{
			if ( !m_Guardian.Alive )
			{
				m_Guardian = null;
				Inactive = true;
			}
			else
			{
				Inactive = false;
			}
		}

		[Constructable]
		public GuardianActivator() : base( 0x1BC3 )
		{
			Name = "guardian activator";
			Visible = false;
			Movable = false;
			Inactive = false;
		}

		public override bool OnMoveOver( Mobile m )
		{
			Mobile guardianone = new DarkGuardian();
			Mobile guardiantwo = new DarkGuardian();
			
			if( m is PlayerMobile )
			{
				if( m.Alive )
				{
					guardianone.MoveToWorld( new Point3D( 365, 12, -1 ), Map.Malas );
					guardiantwo.MoveToWorld( new Point3D( 357, 18, -1 ), Map.Malas );
					
					return true;
				}
				else
				{
					m.SendMessage( "Your spirit is carried out of the room, magically bound to your corpse." );
					m.Location = new Point3D( 276, 229, -1 ); 
					m.Corpse.Location = new Point3D( 276, 229, -1 );
				}
			}
			return false;
		}
		
		public GuardianActivator( Serial serial ) : base( serial )
		{
		}
		
		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			writer.Write( (int) 0 ); 
			
			writer.Write( (Mobile) m_Guardian );
		}

		public override void Deserialize( GenericReader reader ) 
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();
			
			m_Guardian = reader.ReadMobile() as DarkGuardian;

			CheckGuardian();
		}
	}
}

But . . . It didn't do much of anything in the way of changing the Inactive property.

Is there something I'm missing, or am I just going about this completely improperly?

Cheers,
Waverian.
 
Top