thisguy883

Member
ServUO Version
Publish 58
Ultima Expansion
Endless Journey
I've been at this for a few days now.

My goal: Create the Militia Fighter

Purpose:

Have this NPC do one thing, and one thing only: Fight mobs.
Specifically act the same as the previous Militia Fighter back in the runUO days during the AOS era.

What I did:
I managed to copy the militiacannoneer.cs file and edit it to make militiafighter.cs

Code:

C#:
using Server.Items;
using Server.Mobiles;

namespace Server.Engines.Quests.Haven
{
    public class MilitiaFighter : BaseQuester
    {
        private bool m_Active;
        [Constructable]
        public MilitiaFighter()
            : base("the Militia Fighter")
        {
            m_Active = true;
        }

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

        [CommandProperty(AccessLevel.GameMaster)]
        public bool Active
        {
            get
            {
                return m_Active;
            }
            set
            {
                m_Active = value;
            }
        }
        public override void InitBody()
        {
            InitStats(100, 125, 25);

            Hue = Utility.RandomSkinHue();

            Female = false;
            Body = 0x190;
            Name = NameList.RandomName("male");
        }

        public override void InitOutfit()
        {
            Utility.AssignRandomHair(this);
            Utility.AssignRandomFacialHair(this, HairHue);

            AddItem(new RingmailChest());
            AddItem(new PlateArms());
            AddItem(new RingmailGloves());
            AddItem(new RingmailLegs());
        AddItem(new Boots());
            AddItem(new Broadsword());
            AddItem(new BronzeShield());

        }

        public override bool CanTalkTo(PlayerMobile to)
        {
            return false;
        }

        public override void OnTalk(PlayerMobile player, bool contextMenu)
        {
        }

        public override bool IsEnemy(Mobile m)
        {
            if (m.Player || m is BaseVendor)
                return false;

            if (m is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)m;

                Mobile master = bc.GetMaster();
                if (master != null)
                    return IsEnemy(master);
            }

            return m.Karma < 0;
        }

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

            writer.Write(0); // version

            writer.Write(m_Active);
        }

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

            int version = reader.ReadInt();

            m_Active = reader.ReadBool();
        }
    }
}

While this new mob loads, it doesn't load with the behavior I want.

See attached image:

Not only is he immortal, but he doesnt move and he doesnt attack anything. I'm scratching my head with this one. Any ideas or suggestions will be MUCH appreciated.
 

Attachments

  • 1629135614398.jpg
    1629135614398.jpg
    101.9 KB · Views: 9
Well your main issue is that it is a BaseQuester.

Change that to BaseCreature, unless you also want that Fighter to be an actual quest npc (but quest npcs are usually uniquely placed)
 

The one from RunUO.

THANK YOU SO MUCH

Well your main issue is that it is a BaseQuester.

Change that to BaseCreature, unless you also want that Fighter to be an actual quest npc (but quest npcs are usually uniquely placed)

I tried this, but i get all sorts of errors. Thanks though. I'll probably mess around with another file and see what I can learn from it.
 
You can make creatures fight by giving one of them a non-zero Team value.

The one with the non-zero Team value will attempt to fight everything that doesn't have the same Team value.

If you want to limit what it sees as a friend or enemy, you can override IsFriend() and IsInemy() in the creature's script.
 
You can make creatures fight by giving one of them a non-zero Team value.

The one with the non-zero Team value will attempt to fight everything that doesn't have the same Team value.

If you want to limit what it sees as a friend or enemy, you can override IsFriend() and IsInemy() in the creature's script.
This is very useful information.

I was looking at another script and I remember seeing that. Definitely something i'll have to mess with when making new types of mobs.

I'm loving the militiafighter.cs script right now because I'm using it to make all sorts of town guards and custom battlefields between humans and orcs.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back