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!

OSI style AI_Guard

sirens song

Wanderer
OSI style AI_Guard

Wow, first post in this forum section!

Enabling OSI style Guard AI

Suppose you do something silly in town, and get guard whacked. Well right after a friend ressurects you. You notice "Hey that guards grey to me" and you attack him only to find he just stands there like a moron taking the damage you deal out. Well here is a modified BaseGuard.cs that will solve this problem, It is only edited in 2 lines and is clearly tagged where it has been edited. I dont think attachments are functional here yet so ill post the code.

Replace your old BaseGuard.cs with this
BaseGuard.cs
Code:
using System;
using System.Collections;
using Server.Misc;
using Server.Items;
using Server.Mobiles;

namespace Server.Mobiles
{
	public abstract class BaseGuard : BaseCreature //EDIT:Changed inherited Class
	{
		public static void Spawn( Mobile caller, Mobile target )
		{
			Spawn( caller, target, 1, false );
		}

		public static void Spawn( Mobile caller, Mobile target, int amount, bool onlyAdditional )
		{
			if ( target == null || target.Deleted )
				return;

			foreach ( Mobile m in target.GetMobilesInRange( 15 ) )
			{
				if ( m is BaseGuard )
				{
					BaseGuard g = (BaseGuard)m;

					if ( g.Focus == null ) // idling
					{
						g.Focus = target;

						--amount;
					}
					else if ( g.Focus == target && !onlyAdditional )
					{
						--amount;
					}
				}
			}

			while ( amount-- > 0 )
				caller.Region.MakeGuard( target );
		}

		public BaseGuard( Mobile target ) : base( AIType.AI_Melee, FightMode.Agressor, 18, 1, 0.132, .4 ) //EDIT:Increase the ".4" to decrease guards moving speed.
		{
			if ( target != null )
			{
				Location = target.Location;
				Map = target.Map;

				Effects.SendLocationParticles( EffectItem.Create( Location, Map, EffectItem.DefaultDuration ), 0x3728, 10, 10, 5023 );
			}
		}

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

		public override bool OnBeforeDeath()
		{
			Effects.SendLocationParticles( EffectItem.Create( Location, Map, EffectItem.DefaultDuration ), 0x3728, 10, 10, 2023 );

			PlaySound( 0x1FE );

			Delete();

			return false;
		}

		public abstract Mobile Focus{ get; set; }

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

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

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

			int version = reader.ReadInt();
		}
	}
}

On the second edit-comment in the code your instructed how to speedup/slowdown the guards movement. You can also change the guards AItype if you want them to be mages, or whatever. Hope this helps someone out there.
-Jamie Nguyen
 
Top