Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions gamedata/scripts/callbacks_gameobject.script
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,15 @@ _G.CAI_Stalker__PathBuildFailCallback = function(npc)
return flags.ret_value
end

--Intercepts any console call (from scripts and handwritten alike)
--setting ret_value to true will consume console command
AddScriptCallback("on_before_console_execute")
_G.CConsole__BeforeExecuteCallback = function(str)
local flags = {ret_value = false}
SendScriptCallback("on_before_console_execute",str,flags)
return flags.ret_value
end

-- Improve NPCs pathfinding by reducing actual anomaly damage radius
-- Works only when npc:get_enable_anomalies_pathfinding() == true or ai_die_in_anomalies cvar is 1
function is_outside_damage_radius(zone, obj)
Expand Down
19 changes: 19 additions & 0 deletions src/xrEngine/XR_IOConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@

#include "../Include/xrRender/UIRender.h"

//VodoXleb:export console execute callback
#include "../../xrServerEntities/script_engine.h"
#include "../../xrGame/ai_space.h"
#include <luabind/functor.hpp>
//end of VodoXleb

//#include "securom_api.h"

static float const UI_BASE_WIDTH = 1024.0f;
Expand All @@ -39,6 +45,10 @@ static u32 const tips_scroll_pos_color = color_rgba(70, 70, 70, 240);

ENGINE_API CConsole* Console = NULL;

//VodoXleb:export console execute callback
extern ENGINE_API BOOL g_bootComplete;
//--VodoXleb

extern char const* const ioc_prompt;
char const* const ioc_prompt = ">>> ";

Expand Down Expand Up @@ -584,6 +594,15 @@ void CConsole::ExecuteCommand(LPCSTR cmd_str, bool record_cmd)
xr_strcpy(edt, str_size + 1, cmd_str);
edt[str_size] = 0;

if (g_bootComplete)
{
::luabind::functor<bool> funct;
if (ai().script_engine().functor("_G.CConsole__BeforeExecuteCallback", funct))
{
if (funct(cmd_str))
return;
}
}
text_editor::remove_spaces(edt);
if (edt[0] == 0)
{
Expand Down
Loading