mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-04 16:01:17 +00:00
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:
parent
30447aa7f7
commit
3e5a5626f3
@ -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) {
|
||||
|
@ -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 {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user