def CreateNPC( self, ident, parent ): tmp = FindModule( Ai, ident ) if not tmp: GEUtil.DevWarning( "Failed to find npc %s!\n" % ident ) return None else: ident = tmp module = "Ai.%s" % ident npc = None try: # Try to load immediately, fallback to import if new class npc = getattr( sys.modules[module], ident )( parent ) print( "Loading NPC %s from cache" % ident ) except KeyError: try: __import__( module, globals(), locals() ) npc = getattr( sys.modules[module], ident )( parent ) print( "Loading NPC %s from disk" % ident ) except ImportError: PrintError( "Failed to load NPC %s\n" % ident ) if npc: # Make sure we are using the proper API! if not CheckAPI( sys.modules[module], GEGlobal.API_AI_VERSION ): GEUtil.Warning( "Ai load FAILED due to API mismatch.\n" ) return None # Load any custom schedules defined by the npc self.LoadSchedules( npc ) return npc