Calling ChangeAIType method doesn't change AI type on the fly?

unblest

Citizen
May 20, 2016
32
8
8
40
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?
 

Falkor

Squire
Apr 11, 2018
298
105
43
wpshard.com
Shard Name
Whispering Pines
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.
 
  • Like
Reactions: unblest

unblest

Citizen
May 20, 2016
32
8
8
40
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
 

Falkor

Squire
Apr 11, 2018
298
105
43
wpshard.com
Shard Name
Whispering Pines
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.
 

unblest

Citizen
May 20, 2016
32
8
8
40
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