(svn r16113) -Feature [NoAI]: Add UseAsRandomAI as function in info.nut. When an AI returns false, it'll never be chosen as random AI.

This commit is contained in:
yexo
2009-04-21 19:13:32 +00:00
parent d4d163e127
commit 3949050714
5 changed files with 43 additions and 5 deletions

View File

@@ -66,6 +66,12 @@ AILibrary::~AILibrary()
} else {
info->min_loadable_version = info->GetVersion();
}
/* When there is an UseAsRandomAI function, call it. */
if (info->engine->MethodExists(*info->SQ_instance, "UseAsRandomAI")) {
if (!info->engine->CallBoolMethod(*info->SQ_instance, "UseAsRandomAI", &info->use_as_random)) return SQ_ERROR;
} else {
info->use_as_random = true;
}
/* Remove the link to the real instance, else it might get deleted by RegisterAI() */
sq_setinstanceup(vm, 2, NULL);