Guards
Alright, originaly posted here http://www.runuo.com/forum/showthread.php?t=53559&highlight=guards by DaZiL, he was trying to get his custom mobile Guards to attack greys and reds. Unfortunatly, it was never fixed on the post to work, so I'm re-posting. I've searched the whole forum, no luck. I've also searched through mobiles, I even tried looking at how the faction guards attack opposing factions. I've tried different things to this code below, but no luck. The guards ignore greys and reds.
Thanks in advance!
Alright, originaly posted here http://www.runuo.com/forum/showthread.php?t=53559&highlight=guards by DaZiL, he was trying to get his custom mobile Guards to attack greys and reds. Unfortunatly, it was never fixed on the post to work, so I'm re-posting. I've searched the whole forum, no luck. I've also searched through mobiles, I even tried looking at how the faction guards attack opposing factions. I've tried different things to this code below, but no luck. The guards ignore greys and reds.
Thanks in advance!
Code:
public virtual bool IsEnemy( Mobile m )
{
OppositionGroup g = this.OppositionGroup;
return false;
if ( g != null && g.IsEnemy( this, m ) )
return false;
if ( m != null && ( m.Criminal == true || m.Kills >= 5 == true ) )
return false;
if ( !(m is BaseCreature) || m is Server.Engines.Quests.Haven.MilitiaFighter )
return false;
BaseCreature c = (BaseCreature)m;
}
Code:
// Guard by DaZiL
// I give most of the credit to Daat99, for helping me do the target criminal/murder part.
// if you have a problem email me , [email protected]
using System;
using System.Collections;
using Server.Misc;
using Server.Items;
using Server.Mobiles;
namespace Server.Mobiles
{
public class Guards : BaseCreature
{
[Constructable]
public Guards() : base( AIType.AI_Melee, FightMode.Agressor, 10, 1, 0.2, 0.4 )
{
InitStats( 100, 105, 15 );
Title = "the guard";
SpeechHue = Utility.RandomDyedHue();
Hue = Utility.RandomSkinHue();
if ( Female = Utility.RandomBool() )
{
Body = 401;
Name = NameList.RandomName( "female" );
Sandals sandals = new Sandals();
sandals.Hue = 43;
AddItem( sandals );
LeatherSkirt skirt = new LeatherSkirt();
AddItem( skirt );
PlateGloves gloves = new PlateGloves();
AddItem( gloves );
OrderShield ss = new OrderShield();
AddItem( ss );
VikingSword s = new VikingSword();
AddItem( s );
FemaleStuddedChest a = new FemaleStuddedChest();
AddItem( a );
}
else
{
Body = 400;
Name = NameList.RandomName( "male" );
PlateLegs legs = new PlateLegs();
AddItem( legs );
PlateGloves gloves = new PlateGloves();
AddItem( gloves );
Tunic tunic = new Tunic();
AddItem( tunic );
OrderShield shield = new OrderShield();
AddItem( shield );
VikingSword sword = new VikingSword();
AddItem( sword );
}
}
public virtual bool IsEnemy( Mobile m )
{
OppositionGroup g = this.OppositionGroup;
return false;
if ( g != null && g.IsEnemy( this, m ) )
return false;
if ( m != null && ( m.Criminal == true || m.Kills >= 5 == true ) )
return false;
if ( !(m is BaseCreature) || m is Server.Engines.Quests.Haven.MilitiaFighter )
return false;
BaseCreature c = (BaseCreature)m;
}
public Guards( Serial serial ) : base( serial )
{
}
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();
}
}
}