public static T GetInstanceAI <T>(WorldObject obj, string scriptName) where T : class { InstanceMap instance = obj.GetMap().ToInstanceMap(); if (instance != null && instance.GetInstanceScript() != null) { if (instance.GetScriptId() == Global.ObjectMgr.GetScriptId(scriptName)) { return((T)Activator.CreateInstance(typeof(T), new object[] { obj })); } } return(null); }