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!

My NPC ShardCleaner attacks playres Help!

sirbum69

Wanderer
My NPC ShardCleaner attacks playres Help!

Ok i got a script off of here that is a shard cleaner...It works fine, except that it keeps attacking my players....Matter of fact it even attacked another NPC until i changed him from base mobile to BaseCreature...

here is the code
Code:
using System; 
using System.Collections; 
using Server.Items; 
using Server.ContextMenus; 
using Server.Misc; 
using Server.Network; 

namespace Server.Mobiles 
	{ 
   	[CorpseName( "a Janito corpse" )] 
   	public class ShardCleaner : BaseCreature 
   		{ 
      		[Constructable] 
      		public ShardCleaner() : base( AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4 ) 
         		{  
         		Hue = 33770; 
	 		{
				Body = 0x190;
				Title = "The Janitor";
				Name = NameList.RandomName( "male" );
				new Horse().Rider = this;
				AddItem( new LongHair() );
				AddItem( new Pitchfork() );
				AddItem( new Doublet() );
				AddItem( new Boots() );
				AddItem( new LongPants() );
				AddItem( new FancyShirt() );
				
			}
                        Blessed = false;
         

         		SetStr( 186, 300 ); 
         		SetDex( 181, 295 ); 
         		SetInt( 61, 75 ); 

         		SetDamage( 13, 28 );

	 		SetDamageType( ResistanceType.Physical, 60 );
	 		SetDamageType( ResistanceType.Poison, 40 );

	 		SetResistance( ResistanceType.Physical, 45, 55 );
	 		SetResistance( ResistanceType.Fire, 40, 50 );
	 		SetResistance( ResistanceType.Cold, 25, 35 );
	 		SetResistance( ResistanceType.Poison, 65, 75 );
	 		SetResistance( ResistanceType.Energy, 25, 35 ); 

          
         		SetSkill( SkillName.MagicResist, 105.0, 107.5 );  
         		SetSkill( SkillName.Tactics, 100.0, 125.5 ); 
         		SetSkill( SkillName.Healing,100.0, 115.0 ); 
				SetSkill( SkillName.Lumberjacking,100.0, 115.0 );
				SetSkill( SkillName.Fencing,100.0, 115.0 );
				SetSkill( SkillName.Anatomy,100.0, 115.0 );
				SetSkill( SkillName.Hiding,100.0, 115.0 );
         		
				Fame = 13000; 
         		Karma = 13000; 

         		VirtualArmor = 50;
 
         		}

      		public override void GenerateLoot()
	 		{
	 		AddLoot( LootPack.FilthyRich );
	 		AddLoot( LootPack.Gems, Utility.Random( 1, 2 ) );
	 		}

      		private DateTime m_NextPickup; 

      		public override void OnThink() 
         		{ 
         		base.OnThink(); 

         		if ( DateTime.Now < m_NextPickup ) 
            			return; 

         		m_NextPickup = DateTime.Now + TimeSpan.FromSeconds( 2.5 + (2.5 * Utility.RandomDouble()) ); 

         		ArrayList Trash = new ArrayList(); 
         		foreach ( Item item in this.GetItemsInRange( 2 ) ) 
            		{ 
            		if ( item.Movable ) 
               		Trash.Add(item); 
            		} 
         		Type[] exemptlist = new Type[]{ typeof(MandrakeRoot), typeof(Ginseng), typeof(AxeOfTheHeavens)}; //Short example list 
         		bool TrashIt = true; 
         		for (int i = 0; i < Trash.Count; i++) 
            		{ 
            		for (int j = 0; j < exemptlist.Length; j++) 
               		{ 
               		if ( (Trash[i]).GetType() == exemptlist[j] ) 
                  		TrashIt = false; 
               		} 
            		if (TrashIt) 
               		((Item)Trash[i]).Delete(); 
            			TrashIt = true; 
            		} 
         	} 

      		public ShardCleaner( 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(); 
      		} 
   	} 
}

I thought maybe by just changing his karma from -13000 to 13000 would do it but he still attacks....why would he attack....
 

daat99

Moderator
Staff member
Code:
FightMode.Closest
This tell it to fight anything that is close by.
Take a look at creatures that doesn't attack players and npcs and see how it should look like.
Once you got something try it and let us know what you tried and what other problems you got with it.
 

sirbum69

Wanderer
Thanks Daat for pointing that out, I see what im missing now...

it should read fightmode.aggresser.....instead of .closest

thanks again
 

daat99

Moderator
Staff member
sirbum69 said:
Thanks Daat for pointing that out, I see what im missing now...

it should read fightmode.aggresser.....instead of .closest

thanks again
Glad I can help ;)
 

Jambone

Wanderer
but i think he can still take area dmg from players and maybe get attacked by pets but maybe you want that. just make him blessed and nobody will mess with him.
 

Vorspire

Knight
No :)

But anyhow, you can override various methods of Mobile for these needs...

OnActionCombat() being one of them...

[FTW, good necro ;)]
 
Top