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!

Mounted NPC

Mounted NPC

can someone point me into the direction for a mounted npc script (checked savage rider script but it doesn't show how to specify what mount to use). I found this part

Code:
public override bool OnBeforeDeath()
		{
			IMount mount = this.Mount;

			if ( mount != null )
				mount.Rider = null;

			if ( mount is Mobile )
				((Mobile)mount).Delete();

			return base.OnBeforeDeath();
		}

Now, if I'm correct all this does is deletes the mount when the rider is killed. What I'm trying to do is make it where the rider has to be killed in order to tame the mount, but I can't find how to specify what mount the rider is on. Now, as for having the mount remain, I'm guessing that I change

Code:
if ( mount is Mobile )
				((Mobile)mount).Delete();

to this

Code:
if ( mount is Mobile )
				((Mobile)mount).Delete(false);

and that will leave the mount behind.
 

Humpster

Wanderer
Code:
public override bool OnBeforeDeath()
		{
			IMount mount = this.Mount;

			if ( mount != null )
				mount.Rider = null;

			if ( mount is Mobile )
				((Mobile)mount).Dismount();

			return base.OnBeforeDeath();
		}
try this? or completyle remove the

if ( mount is Mobile )
((Mobile)mount).Delete();

part
 
Humpster;836551 said:
or completyle remove the

if ( mount is Mobile )
((Mobile)mount).Delete();

part


This worked, funny thing is before I even posted I was gonna just try this but wanted to be certain.
 

Hammerhand

Knight
To specify the mount in the script, just add
Code:
new HellSteed().Rider = this;
HellSteed just being an example. Use whichever mount you like.
 
Thanks. I saw that in another script after posting it, but at least with your response it can answer another person's curiousity on it later
 
Thought of another question with this script. How would I make it so that the npc could pick things up that were blocking it's path. i.e. you trap it with wood boxes and it picks one up to get through
 

[FoA]Void

Sorceror
It requires modifications to BaseCreature.cs and BaseAI.cs (or whatever AI you're editing).

In BaseCreature look for the part where corpses are looted and add a routine to check for unblocked lootable items.

Then in BaseAI, look where it's checking if the path is blocked and have him try repeatedly to lift items.

I'm still on part 1 of 2 of this process, and it looks like this (being beautifully imperfect)
From BaseCreature.cs
Code:
		public virtual bool Rummage()
		{
			Corpse toRummage = null;
			Container pack = this.Backpack;

			if ( pack == null )
				return false;			

			bool rejected;
			LRReason reason;

			foreach ( Item item in this.GetItemsInRange( 2 ) )
			{
				if ( item is Corpse && item.Items.Count > 0 )
				{
					toRummage = (Corpse)item;
					break;
				}
			}
			
			
			if ( toRummage == null )
			{
				ArrayList list = new ArrayList();

				foreach ( Item item in this.GetItemsInRange( 2 ) )
				{
					if ( item.Movable )
						list.Add( item );
				}

				for ( int i = 0; i < list.Count; ++i )
				{
					Item item = (Item)list[i];

					if ( item != null )
					{
						if ( !pack.CheckHold( this, item, false, true ) )
							return false;

						bool rejectedi;
						LRReason reject;

						Lift( item, item.Amount, out rejectedi, out reject );

						if ( !rejectedi )
						{						

							Drop( this, Point3D.Zero );
							Emote("*Afferra un oggetto*");
							return true;
						}
						else
							return false;
					}
					
				}
			}


			if ( toRummage == null )		
				return false;





			List<Item> items = toRummage.Items;



			for ( int i = 0; i < items.Count; ++i )
			{
				Item item = items[Utility.Random( items.Count )];

				Lift( item, item.Amount, out rejected, out reason );

				if ( !rejected && Drop( this, new Point3D( -1, -1, 0 ) ) )
				{
					// *rummages through a corpse and takes an item*
					PublicOverheadMessage( MessageType.Emote, 0x3B2, 1008086 );
					return true;
				}
			}

			return false;
		}
 
Top