While playing with Squire System, I noticed scripted AI doesn't change itself on the fly when giving a ranged weapon to the squire.
The code in squire.cs reads,
C#:
namespace Server.Mobiles
{
    [CorpseName("a squire's corpse")]
    public class Squire : BaseCreature
    {
        ...
        public override void OnItemAdded(Item item)
        {
            base.OnItemAdded(item);
            if (item is BaseRanged)
            {
                ChangeAIType(AIType.AI_Archer);
            }
        }
    }
}
Code in line 12 doesn't seem to change its AI to AI_Archer on the fly. I had to manually [props and change its AI. Is there any way to change AI in game?
 
Just declare it directly.

Code:
AI = AIType.AI_Archer;

I don't know how that particular script refers to the mobile so you may have to use this.AI = AIType.AI_Archer or whatever other variable is assigned to the mobile in question.
 
Just declare it directly.

Code:
AI = AIType.AI_Archer;

I don't know how that particular script refers to the mobile so you may have to use this.AI = AIType.AI_Archer or whatever other variable is assigned to the mobile in question.
Worked like a charm! Thanks
 
Just note that if the mobile has never used that skill before it'll be terrible with the weapon until it gains (like a player does). Or you can add a check for whatever minimum skill you want them to have and declare that value at the same time you change the AI type.
 
Just note that if the mobile has never used that skill before it'll be terrible with the weapon until it gains (like a player does). Or you can add a check for whatever minimum skill you want them to have and declare that value at the same time you change the AI type.
I just did [setallskills 120 lol
 
Back