Add fallback_human() action to the Lua AI

Just like the FormulaAI fallback() function, this temporarily
transfers control of the side to a human player.
This commit is contained in:
Celtic Minstrel 2017-04-05 23:29:06 -04:00
parent 30447aa7f7
commit 3e5a5626f3
2 changed files with 8 additions and 1 deletions

View File

@ -344,6 +344,11 @@ static int cfun_ai_check_recall(lua_State *L)
return ai_recall(L, false);
}
static int cfun_ai_fallback_human(lua_State*)
{
throw fallback_ai_to_human_exception();
}
// Goals and targets
@ -971,6 +976,7 @@ static int impl_ai_get(lua_State* L)
{ "stopunit_attacks", &cfun_ai_execute_stopunit_attacks },
{ "stopunit_moves", &cfun_ai_execute_stopunit_moves },
{ "synced_command", &cfun_ai_execute_synced_command },
{ "fallback_human", &cfun_ai_fallback_human},
{ nullptr, nullptr } };
for (const luaL_Reg* p = mutating_callbacks; p->name; ++p) {
if(m == p->name) {

View File

@ -19,6 +19,7 @@
#include "chat_events.hpp"
#include "floating_textbox.hpp"
#include "units/map.hpp"
#include "lua_jailbreak_exception.hpp"
#include <vector>
@ -35,7 +36,7 @@ namespace events {
class mouse_handler;
}
struct fallback_ai_to_human_exception {};
struct fallback_ai_to_human_exception : public lua_jailbreak_exception {IMPLEMENT_LUA_JAILBREAK_EXCEPTION(fallback_ai_to_human_exception)};
namespace events {