Bonaccorso

Member
I tried to make a version of Brigands which don't attack player )and potentially attack other evil mobs), but didn't find a parameter which could be responsible for this. I thought that making Murderer=false could do, and (for stupid reasons) changed Karme to positive, but no change of course. I thought there might be soemthing in, for example, Brigand.cs, but as far as I compared with .cs of non-aggressive npcs, I found nothing relevant.
 
basecreature IsEnemy
Thank you!
Post automatically merged:

basecreature IsEnemy
Related question - how do I actually add a new mobile into game? For example, I created GoodBrigand.cs, based on the ordinary one, changed inside all "Brigand" on "GoodBrigand" (aside of other changes), added GoodBridand into Data/mobiles.cfg - but still I can't spawn them in game.
 
Last edited:
Did you add your .cs file to the scripts? if not you need to, most people make a new folder in the scripts folder and name it something like "customs" .

Then add any new scripts to that folder.
 
So, I reverted changes to mobiles.cfg, created Scripts/Custom folder, moved my new GoodBrigand.cs there, shutdown and started server - and nothing again :-(

Copied its code just in case - but so far I wonder what could be an issue there, so far only very minor changes:


GoodBrigand:
using Server.Items;

namespace Server.Mobiles
{
    [TypeAlias("Server.Mobiles.HumanGoodBrigand")]
    public class GoodBrigand : BaseCreature
    {
        [Constructable]
        public GoodBrigand()
            : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
        {
            SpeechHue = Utility.RandomDyedHue();
            Title = "the honest brigand";
            Hue = Utility.RandomSkinHue();

            {
                Body = 0x190;
                Name = NameList.RandomName("male");
                AddItem(new ShortPants(Utility.RandomNeutralHue()));
            }

            SetStr(86, 100);
            SetDex(81, 95);
            SetInt(61, 75);

            SetDamage(10, 23);

            SetSkill(SkillName.Fencing, 66.0, 97.5);
            SetSkill(SkillName.Macing, 65.0, 87.5);
            SetSkill(SkillName.MagicResist, 25.0, 47.5);
            SetSkill(SkillName.Swords, 65.0, 87.5);
            SetSkill(SkillName.Tactics, 65.0, 87.5);
            SetSkill(SkillName.Wrestling, 15.0, 37.5);

            Fame = 1000;
            Karma = -1000;

            AddItem(new Boots(Utility.RandomNeutralHue()));
            AddItem(new FancyShirt(0x263));
            AddItem(new Bandana(0x263));

            switch (Utility.Random(6))
            {
                case 0:
                    AddItem(new Longsword());
                    break;
                case 1:
                    AddItem(new Broadsword());
                    break;
                case 2:
                    AddItem(new Axe());
                    break;
                case 3:
                    AddItem(new Club());
                    break;
                case 4:
                    AddItem(new Dagger());
                    break;
                case 5:
                    AddItem(new Spear());
                    break;
            }

            Utility.AssignRandomHair(this);
        }

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

        public override bool ClickTitle => false;
        public override bool AlwaysMurderer => true;

        public override bool ShowFameTitle => false;

        public override void OnDeath(Container c)
        {
            base.OnDeath(c);

            if (Utility.RandomDouble() < 0.75)
                c.DropItem(new SeveredHumanEars());
        }

        public override void GenerateLoot()
        {
            AddLoot(LootPack.Average);
        }
        
        public override bool IsEnemy(Mobile m)
        {
            return false;

            return base.IsEnemy(m);
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);
            writer.Write(0); // version
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();
        }
    }
}
Post automatically merged:

It seems ServUO doesn't recognize this one as a mobile, because after I removed this file entirely from the ServUO folder, during launch after Verifying scripts, number of mobiles is not changed regardless.
Post automatically merged:

Ah, my bad - I didn't know I have to recompile after adding new script.

But - now there's error in the script, about topic, non-attacking mob.

I aded this:
C#:
public override bool IsEnemy(Mobile m)
        {
            return false;

            return base.IsEnemy(m);
        }

And complier says this is wrong code. What will be the right syntax?
 
Last edited:
What was the error exactly? And I see you have your "GoodBrigand" as alwaysmurderer => true.... not sure if that's causing a problem or not.

But the exact error would be good to know.
 
Error is "Unreachable code detected"

I'm now experimenting with a new way; same error about line 8 in this part:
C#:
public override bool IsEnemy(Mobile m)
        {
            if (m.Player && m.Body == 190 || m.Player && m.Body == 191)
            return false;
        else
            return true;

            return base.IsEnemy(m);
        }
Post automatically merged:

What was the error exactly? And I see you have your "GoodBrigand" as alwaysmurderer => true.... not sure if that's causing a problem or not.

But the exact error would be good to know.
And I commented the line about murderer, but now need to fix the code from the previous post before I can check the behavior.
 
You could just change it to alwaysmurderer=>false and see what it does instead of commenting it. I'm not sure whether the murderer thing just makes them have a red name or if it effects their actions.

as far as line 8.... I'm no expert and I could be totally wrong, but your returning true and returning false, I don't think it will ever read the return base because whether true or false it will have returned before it gets to that .
 
You could just change it to alwaysmurderer=>false and see what it does instead of commenting it. I'm not sure whether the murderer thing just makes them have a red name or if it effects their actions.

as far as line 8.... I'm no expert and I could be totally wrong, but your returning true and returning false, I don't think it will ever read the return base because whether true or false it will have returned before it gets to that .
Interesting results! Eventually I made it work with
C#:
public override bool IsEnemy(Mobile m)
        {
        if (m.Player)
            return false;

            return base.IsEnemy(m);
        }

I'll experiment with various body types later, I thought m.Player && something else should have worked always for player regardless is second part is right; as for alwaysmurderer - having it as true makes his name red, but he doesn't attack player when code above is present. At the same time, not having code above but having alwaysmurderer line commented still made him attack me.
 
You could just change it to alwaysmurderer=>false and see what it does instead of commenting it. I'm not sure whether the murderer thing just makes them have a red name or if it effects their actions.

as far as line 8.... I'm no expert and I could be totally wrong, but your returning true and returning false, I don't think it will ever read the return base because whether true or false it will have returned before it gets to that .
I experimentd, and alwaysmurderer=>false really makes them peaceful, regardless of other options set. But most of mobs aside of human ones, don't use it.

Instead, it's a combination of FightMode and bool IsEnemy:

FightMode.Closest makes them attack player (or maybe some npcs as well - but not all; many mosnters have it set like this), Aggressor likely seems to make them never to attack first; Evil - they will attack creatures with negative karma.

And to make mobs not attacking player while they are in FightMode.Closest, so far I use this:
C#:
public override bool IsEnemy(Mobile m)
        {
        if (m.Player)
            return false;

            return base.IsEnemy(m);
        }

True is a default value here, so return true is not necessary.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back