ServUO Version
Publish 58
Ultima Expansion
Endless Journey
I used ChatAI to make a rat horde, and it is near perfect, the only problem I am getting is from this bit of code when I want it to add a pack of rats, instead it only adds one.
 
Small Rat Horde:
using System;
using Server;
using Server.Mobiles;

namespace Server.Mobiles
{
    public class RatHorde : BaseCreature
    {
        public override bool AlwaysMurderer => true;

        [Constructable]
        public RatHorde()
            : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
        {
            Name = "Rat Horde";
            Body = 238; // Set the body type of the rat, replace with appropriate body ID
            Hue = 0; // Set the hue/color of the rat, replace with appropriate hue

            SetStr(50);
            SetDex(50);
            SetInt(25);

            SetHits(100);
            SetStam(50);
            SetMana(0);

            SetDamage(5, 10);

            SetSkill(SkillName.Wrestling, 50);
            SetSkill(SkillName.Tactics, 50);

            Fame = 500;
            Karma = -500;

            VirtualArmor = 10;

            // Uncomment the line below if you want the rats to spawn in large numbers
            PackItem(new RatHorde());

            // Set the number of rats in the horde
            for (int i = 0; i < 10; i++)
            {
                Rat rat = new Rat();
                rat.MoveToWorld(Location, Map);
            }
        }

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

I did attach it the first time, then had to set server version and stuff, and that's where I think I lost the attached code.
 
What is the purpose of
C#:
PackItem(new RatHorde());
and what happens if you comment that one out?
Feels like that one does not belong there
 
You need to move the for loop to a separate method
Then call that method from the constructor with zero delay

The code, as is, is trying to create the horde before the "parent" mobile is fully initialized (before it actually exists)

And yes, remove the PackItem one too as @MrRiots mentioned. That's used more like adding loot or equipment.
 
Tested and working
Code is basic enough that it should work with any version of SevUO and seems like it should be compatible all the way back to C#/.Net 2.0 so that's pretty old RunUO


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

namespace Server.Mobiles
{
    public class RatHorde : BaseCreature
    {
        public override bool AlwaysMurderer => true;

        [Constructable]
        public RatHorde()
            : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
        {
            Name = "Rat Horde";
            Body = 238; // Set the body type of the rat, replace with appropriate body ID
            Hue = 0; // Set the hue/color of the rat, replace with appropriate hue

            SetStr(50);
            SetDex(50);
            SetInt(25);

            SetHits(100);
            SetStam(50);
            SetMana(0);

            SetDamage(5, 10);

            SetSkill(SkillName.Wrestling, 50);
            SetSkill(SkillName.Tactics, 50);

            Fame = 500;
            Karma = -500;

            VirtualArmor = 10;

            Timer.DelayCall(TimeSpan.Zero, SummonRatHorde);
        }

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

        private void SummonRatHorde()
        {
            // Set the number of rats in the horde
            for (int i = 0; i < 10; i++)
            {
                if (!Alive || Deleted)
                    return;

                Rat rat = new Rat();
                rat.MoveToWorld(this.Location, this.Map);
            }
        }

        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();
        }
    }
}
Note:

if you what to make each individual Rat "AlwaysMurderer" then add

Code:
rat.AlwaysMurderer = true;

inbetween the intialize and MoveToWorld lines
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back