public void SetAi(string name)
{
if (this.NPC == null)
throw new InvalidOperationException("NPC's race has to be set first.");
if (this.NPC.AI != null)
this.NPC.AI.Dispose();
this.NPC.AI = ChannelServer.Instance.ScriptManager.AiScripts.CreateAi(name, this.NPC);
if (this.NPC.AI == null)
Log.Error("NpcScript.SetAi: AI '{0}' not found ({1})", name, this.GetType().Name);
}