Skip to content

CLEO 5 SDK

Seemann edited this page Oct 26, 2023 · 6 revisions

Opcode Registration

CLEO_RegisterOpcode

BOOL WINAPI CLEO_RegisterOpcode(WORD opcode, _pOpcodeHandler callback);

Registers a custom CLEO opcode with the specified opcode value and handler function.

Custom Script Handling

CLEO_CreateCustomScript

CRunningScript* WINAPI CLEO_CreateCustomScript(CRunningScript* fromThread, const char* script_name, int label);

Creates a custom script thread.

CLEO_GetLastCreatedCustomScript

CRunningScript* WINAPI CLEO_GetLastCreatedCustomScript();

Returns the last created custom script thread.

CLEO_AddScriptDeleteDelegate

void WINAPI CLEO_AddScriptDeleteDelegate(FuncScriptDeleteDelegateT func);

Adds a script deletion delegate function.

CLEO_RemoveScriptDeleteDelegate

void WINAPI CLEO_RemoveScriptDeleteDelegate(FuncScriptDeleteDelegateT func);

Removes a script deletion delegate function.

CLEO_GetScriptInfoStr

void WINAPI CLEO_GetScriptInfoStr(CRunningScript* thread, bool currLineInfo, char* buf, DWORD bufSize);

Retrieves information about the script for error and log messages.

CLEO_GetScriptVersion

eCLEO_Version WINAPI CLEO_GetScriptVersion(const CRunningScript* thread);

Returns the CLEO version used for a specific script, considering compatibility mode.

CLEO_SetThreadCondResult

void WINAPI CLEO_SetThreadCondResult(CRunningScript* thread, BOOL result);

Sets the condition result for a script thread.

CLEO_ThreadJumpAtLabelPtr

void WINAPI CLEO_ThreadJumpAtLabelPtr(CRunningScript* thread, int labelPtr);

Jumps to a specific label in a script thread.

Parameter Handling

External Variables

extern SCRIPT_VAR* opcodeParams;
extern SCRIPT_VAR* missionLocals;

External variables to access opcode parameters and mission-local variables.

CLEO_GetOperandType

eDataType WINAPI CLEO_GetOperandType(const CRunningScript* thread);

Peeks at the parameter data type in a script thread.

CLEO_GetVarArgCount

DWORD WINAPI CLEO_GetVarArgCount(CRunningScript* thread);

Peeks at the count of variable arguments in a script thread.

CLEO_GetPointerToScriptVariable

SCRIPT_VAR* WINAPI CLEO_GetPointerToScriptVariable(CRunningScript* thread);

Returns a pointer to the variable data in a script thread, advancing the script to the next parameter.

CLEO_RetrieveOpcodeParams

void WINAPI CLEO_RetrieveOpcodeParams(CRunningScript* thread, int count);

Reads and stores multiple parameters in the opcodeParams array.

CLEO_GetIntOpcodeParam

DWORD WINAPI CLEO_GetIntOpcodeParam(CRunningScript* thread);

Retrieves an integer parameter from a script thread.

CLEO_GetFloatOpcodeParam

float WINAPI CLEO_GetFloatOpcodeParam(CRunningScript* thread);

Retrieves a floating-point parameter from a script thread.

CLEO_ReadStringOpcodeParam

LPSTR WINAPI CLEO_ReadStringOpcodeParam(CRunningScript* thread, char* buf = nullptr, int bufSize = 0);

Reads a string parameter from a script thread.

CLEO_ReadStringPointerOpcodeParam

LPSTR WINAPI CLEO_ReadStringPointerOpcodeParam(CRunningScript* thread, char* buf = nullptr, int bufSize = 0);

Reads a string parameter from a script thread, exactly the same as CLEO_ReadStringOpcodeParam.

CLEO_ReadParamsFormatted

char* WINAPI CLEO_ReadParamsFormatted(CRunningScript* thread, const char* format, char* buf = nullptr, int bufSize = 0);

Consumes all variable-argument parameters in a script thread based on a format and stores them in a buffer.

CLEO_SkipOpcodeParams

void WINAPI CLEO_SkipOpcodeParams(CRunningScript* thread, int count);

Skips a specified number of parameters in a script thread without reading them.

CLEO_SkipUnusedVarArgs

void WINAPI CLEO_SkipUnusedVarArgs(CRunningScript* thread);

Skips any unused variable arguments for var-args opcodes.

CLEO_RecordOpcodeParams

void WINAPI CLEO_RecordOpcodeParams(CRunningScript* thread, int count);

Writes multiple parameters from the opcodeParams array.

CLEO_SetIntOpcodeParam

void WINAPI CLEO_SetIntOpcodeParam(CRunningScript* thread, DWORD value);

Sets an integer parameter.

CLEO_SetFloatOpcodeParam

void WINAPI CLEO_SetFloatOpcodeParam(CRunningScript* thread, float value);

Sets a floating-point parameter.

CLEO_WriteStringOpcodeParam

void WINAPI CLEO_WriteStringOpcodeParam(CRunningScript* thread, const char* str);

Writes a string parameter.

Debugging

CLEO_GetScriptDebugMode

BOOL WINAPI CLEO_GetScriptDebugMode(const CRunningScript* thread);

Checks if debug mode features are enabled for a script.

CLEO_SetScriptDebugMode

void WINAPI CLEO_SetScriptDebugMode(CRunningScript* thread, BOOL enabled);

Enables or disables debug mode for a script.

Other Functions

CLEO_GetVersion

DWORD WINAPI CLEO_GetVersion();

Returns the version of the CLEO plugin.

CLEO_GetGameVersion

eGameVersion WINAPI CLEO_GetGameVersion();

Returns the game version for which CLEO is configured.

CLEO_GetScriptTextureById

DWORD WINAPI CLEO_GetScriptTextureById(CRunningScript* thread, int id);

Retrieves a script texture by ID.

CLEO_GetInternalAudioStream

HSTREAM WINAPI CLEO_GetInternalAudioStream(CRunningScript* thread, DWORD stream);

Gets an internal audio stream.

CLEO_Log

void WINAPI CLEO_Log(eLogLevel level, const char* msg);

Adds a message to the log with the specified log level.

CLEO_RegisterCallback

void WINAPI CLEO_RegisterCallback(eCallbackId id, void* func);

Registers a callback function for a specific event identified by eCallbackId.

CLEO_ResolvePath

void WINAPI CLEO_ResolvePath(CRunningScript* thread, char* inOutPath, DWORD pathMaxLen);

Converts a path to an absolute file system path.