From 6bb56b0f95ea64b8c83baad539862e7d33d89e60 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Tue, 19 May 2020 09:48:46 +0800 Subject: [PATCH 1/2] Minor code fixes in AI.cpp: * Fixed NPCs being unable to select a burst attack mode if the line of fire was blocked. * Changed the return point of combat_ai_hook_FleeFix to run ai_check_drugs_ first. Changed the debug message about missing art file for critters to be displayed in game only when in sfall debugging mode. --- sfall/FalloutEngine/EngineUtils.cpp | 3 ++- sfall/FalloutEngine/EngineUtils.h | 3 ++- sfall/Modules/AI.cpp | 5 +++-- sfall/Modules/DebugEditor.cpp | 7 ++++++- sfall/version.h | 4 ++-- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/sfall/FalloutEngine/EngineUtils.cpp b/sfall/FalloutEngine/EngineUtils.cpp index 90d1b2abe..1f55b4dd2 100644 --- a/sfall/FalloutEngine/EngineUtils.cpp +++ b/sfall/FalloutEngine/EngineUtils.cpp @@ -166,7 +166,7 @@ void ToggleNpcFlag(fo::GameObject* npc, long flag, bool set) { } } -// Returns the number of party members in the existing table (begins from 1) +// Returns the position of party member in the existing table (begins from 1) long IsPartyMemberByPid(long pid) { size_t patryCount = fo::var::partyMemberMaxCount; if (patryCount) { @@ -178,6 +178,7 @@ long IsPartyMemberByPid(long pid) { return 0; } +// Returns True if the NPC belongs to the player's potential (set in party.txt) party members (analog of broken isPotentialPartyMember_) bool IsPartyMember(fo::GameObject* critter) { if (critter->id < PLAYER_ID) return false; return (IsPartyMemberByPid(critter->protoId) > 0); diff --git a/sfall/FalloutEngine/EngineUtils.h b/sfall/FalloutEngine/EngineUtils.h index aee3fa45d..586252f83 100644 --- a/sfall/FalloutEngine/EngineUtils.h +++ b/sfall/FalloutEngine/EngineUtils.h @@ -72,9 +72,10 @@ long __fastcall IsRadInfluence(); void ToggleNpcFlag(fo::GameObject* npc, long flag, bool set); -// Returns the number of party members in the existing table (begins from 1) +// Returns the position of party member in the existing table (begins from 1) long IsPartyMemberByPid(long pid); +// Returns True if the NPC belongs to the player's potential (set in party.txt) party members (analog of broken isPotentialPartyMember_) bool IsPartyMember(fo::GameObject* critter); // Returns the number of local variables of the object script diff --git a/sfall/Modules/AI.cpp b/sfall/Modules/AI.cpp index 595660d76..0e6d2c382 100644 --- a/sfall/Modules/AI.cpp +++ b/sfall/Modules/AI.cpp @@ -48,7 +48,8 @@ fo::GameObject* AI::sf_check_critters_in_lof(fo::GameObject* object, DWORD check fo::GameObject* AI::CheckFriendlyFire(fo::GameObject* target, fo::GameObject* attacker) { fo::GameObject* object = nullptr; fo::func::make_straight_path_func(attacker, attacker->tile, target->tile, 0, (DWORD*)&object, 32, (void*)fo::funcoffs::obj_shoot_blocking_at_); - return sf_check_critters_in_lof(object, target->tile, attacker->critter.teamNum); // 0 if there are no friendly critters + object = sf_check_critters_in_lof(object, target->tile, attacker->critter.teamNum); + return (!object || object->TypeFid() == fo::ObjType::OBJ_TYPE_CRITTER) ? object : nullptr; // 0 if there are no friendly critters } static void __declspec(naked) ai_try_attack_hook_FleeFix() { @@ -59,7 +60,7 @@ static void __declspec(naked) ai_try_attack_hook_FleeFix() { } static void __declspec(naked) combat_ai_hook_FleeFix() { - static const DWORD combat_ai_hook_flee_Ret = 0x42B22F; + static const DWORD combat_ai_hook_flee_Ret = 0x42B206; __asm { test byte ptr [ebp], 8; // 'ReTarget' flag (critter.combat_state) jnz reTarget; diff --git a/sfall/Modules/DebugEditor.cpp b/sfall/Modules/DebugEditor.cpp index 977643bc3..30df38c6a 100644 --- a/sfall/Modules/DebugEditor.cpp +++ b/sfall/Modules/DebugEditor.cpp @@ -322,6 +322,11 @@ static void __declspec(naked) art_data_size_hook() { push edx; push artDbgMsg; call fo::funcoffs::debug_printf_; + cmp isDebug, 0; + jne display; + add esp, 8; + retn; +display: push edx; // filename push artDbgMsg; lea eax, [esp + 0x124 - 0x124 + 20]; // buf @@ -379,7 +384,7 @@ static void DebugModePatch() { if (iniGetInt("Debugging", "HideObjIsNullMsg", 0, ::sfall::ddrawIni)) { MakeJump(0x453FD2, dbg_error_hack); } - // prints a debug message about missing art file for critters to both debug.log and the message window + // prints a debug message about missing art file for critters to both debug.log and the message window in sfall debugging mode HookCall(0x419B65, art_data_size_hook); // Fix to prevent crashes when there is a '%' character in the printed message diff --git a/sfall/version.h b/sfall/version.h index d573c8920..7ba595813 100644 --- a/sfall/version.h +++ b/sfall/version.h @@ -25,6 +25,6 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 2 #define VERSION_BUILD 5 -#define VERSION_REV 0 +#define VERSION_REV 1 -#define VERSION_STRING "4.2.5" +#define VERSION_STRING "4.2.5.1" From b263b69fa3ee5b40cd13bc05af8e460ad07c4be9 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Wed, 20 May 2020 11:30:25 +0800 Subject: [PATCH 2/2] Renamed all script opcode handlers with op_ prefix Renamed all metarule functions with mf_ prefix. --- sfall/Modules/Scripting/Handlers/Anims.cpp | 20 +- sfall/Modules/Scripting/Handlers/Anims.h | 24 +- sfall/Modules/Scripting/Handlers/Arrays.cpp | 34 +- sfall/Modules/Scripting/Handlers/Arrays.h | 34 +- sfall/Modules/Scripting/Handlers/Core.cpp | 26 +- sfall/Modules/Scripting/Handlers/Core.h | 26 +- .../Modules/Scripting/Handlers/FileSystem.cpp | 34 +- sfall/Modules/Scripting/Handlers/FileSystem.h | 34 +- .../Modules/Scripting/Handlers/Interface.cpp | 54 +-- sfall/Modules/Scripting/Handlers/Interface.h | 54 +-- sfall/Modules/Scripting/Handlers/Math.cpp | 26 +- sfall/Modules/Scripting/Handlers/Math.h | 26 +- sfall/Modules/Scripting/Handlers/Metarule.cpp | 180 +++++----- sfall/Modules/Scripting/Handlers/Metarule.h | 6 +- sfall/Modules/Scripting/Handlers/Misc.cpp | 50 +-- sfall/Modules/Scripting/Handlers/Misc.h | 50 +-- sfall/Modules/Scripting/Handlers/Objects.cpp | 86 ++--- sfall/Modules/Scripting/Handlers/Objects.h | 86 ++--- sfall/Modules/Scripting/Handlers/Perks.cpp | 28 +- sfall/Modules/Scripting/Handlers/Perks.h | 28 +- sfall/Modules/Scripting/Handlers/Stats.cpp | 30 +- sfall/Modules/Scripting/Handlers/Stats.h | 30 +- sfall/Modules/Scripting/Handlers/Utils.cpp | 28 +- sfall/Modules/Scripting/Handlers/Utils.h | 28 +- sfall/Modules/Scripting/Handlers/Worldmap.cpp | 24 +- sfall/Modules/Scripting/Handlers/Worldmap.h | 24 +- sfall/Modules/Scripting/Opcodes.cpp | 310 +++++++++--------- 27 files changed, 690 insertions(+), 690 deletions(-) diff --git a/sfall/Modules/Scripting/Handlers/Anims.cpp b/sfall/Modules/Scripting/Handlers/Anims.cpp index f7badde9a..35191595b 100644 --- a/sfall/Modules/Scripting/Handlers/Anims.cpp +++ b/sfall/Modules/Scripting/Handlers/Anims.cpp @@ -51,18 +51,18 @@ bool checkCombatMode() { return (regAnimCombatCheck & fo::var::combat_state) != 0; } -void sf_reg_anim_combat_check(OpcodeContext& ctx) { +void op_reg_anim_combat_check(OpcodeContext& ctx) { RegAnimCombatCheck(ctx.arg(0).rawValue()); } -void sf_reg_anim_destroy(OpcodeContext& ctx) { +void op_reg_anim_destroy(OpcodeContext& ctx) { if (!checkCombatMode()) { auto obj = ctx.arg(0).object(); fo::func::register_object_must_erase(obj); } } -void sf_reg_anim_animate_and_hide(OpcodeContext& ctx) { +void op_reg_anim_animate_and_hide(OpcodeContext& ctx) { if (!checkCombatMode()) { auto obj = ctx.arg(0).object(); int animId = ctx.arg(1).rawValue(), @@ -72,7 +72,7 @@ void sf_reg_anim_animate_and_hide(OpcodeContext& ctx) { } } -void sf_reg_anim_light(OpcodeContext& ctx) { +void op_reg_anim_light(OpcodeContext& ctx) { if (!checkCombatMode()) { auto obj = ctx.arg(0).object(); int radius = ctx.arg(1).rawValue(), @@ -87,7 +87,7 @@ void sf_reg_anim_light(OpcodeContext& ctx) { } } -void sf_reg_anim_change_fid(OpcodeContext& ctx) { +void op_reg_anim_change_fid(OpcodeContext& ctx) { if (!checkCombatMode()) { auto obj = ctx.arg(0).object(); int fid = ctx.arg(1).rawValue(), @@ -97,7 +97,7 @@ void sf_reg_anim_change_fid(OpcodeContext& ctx) { } } -void sf_reg_anim_take_out(OpcodeContext& ctx) { +void op_reg_anim_take_out(OpcodeContext& ctx) { if (!checkCombatMode()) { auto obj = ctx.arg(0).object(); int holdFrame = ctx.arg(1).rawValue(), @@ -107,7 +107,7 @@ void sf_reg_anim_take_out(OpcodeContext& ctx) { } } -void sf_reg_anim_turn_towards(OpcodeContext& ctx) { +void op_reg_anim_turn_towards(OpcodeContext& ctx) { if (!checkCombatMode()) { auto obj = ctx.arg(0).object(); int tile = ctx.arg(1).rawValue(), @@ -124,7 +124,7 @@ static void __declspec(naked) ExecuteCallback() { } } -void sf_reg_anim_callback(OpcodeContext& ctx) { +void op_reg_anim_callback(OpcodeContext& ctx) { fo::func::register_object_call( reinterpret_cast(ctx.program()), reinterpret_cast(ctx.arg(0).rawValue()), // callback procedure @@ -133,7 +133,7 @@ void sf_reg_anim_callback(OpcodeContext& ctx) { ); } -void sf_explosions_metarule(OpcodeContext& ctx) { +void op_explosions_metarule(OpcodeContext& ctx) { int mode = ctx.arg(0).rawValue(), result = ExplosionsMetaruleFunc(mode, ctx.arg(1).rawValue(), ctx.arg(2).rawValue()); @@ -143,7 +143,7 @@ void sf_explosions_metarule(OpcodeContext& ctx) { ctx.setReturn(result); } -void sf_art_cache_flush(OpcodeContext& ctx) { +void mf_art_cache_flush(OpcodeContext& ctx) { __asm call fo::funcoffs::art_flush_; } diff --git a/sfall/Modules/Scripting/Handlers/Anims.h b/sfall/Modules/Scripting/Handlers/Anims.h index 4e494b3d0..da27ef87f 100644 --- a/sfall/Modules/Scripting/Handlers/Anims.h +++ b/sfall/Modules/Scripting/Handlers/Anims.h @@ -29,18 +29,18 @@ void RegAnimCombatCheck(DWORD newValue); class OpcodeContext; -void sf_reg_anim_combat_check(OpcodeContext&); -void sf_reg_anim_destroy(OpcodeContext&); -void sf_reg_anim_animate_and_hide(OpcodeContext&); -void sf_reg_anim_light(OpcodeContext&); -void sf_reg_anim_change_fid(OpcodeContext&); -void sf_reg_anim_take_out(OpcodeContext&); -void sf_reg_anim_turn_towards(OpcodeContext&); -void sf_reg_anim_callback(OpcodeContext&); - -void sf_explosions_metarule(OpcodeContext&); - -void sf_art_cache_flush(OpcodeContext&); +void op_reg_anim_combat_check(OpcodeContext&); +void op_reg_anim_destroy(OpcodeContext&); +void op_reg_anim_animate_and_hide(OpcodeContext&); +void op_reg_anim_light(OpcodeContext&); +void op_reg_anim_change_fid(OpcodeContext&); +void op_reg_anim_take_out(OpcodeContext&); +void op_reg_anim_turn_towards(OpcodeContext&); +void op_reg_anim_callback(OpcodeContext&); + +void op_explosions_metarule(OpcodeContext&); + +void mf_art_cache_flush(OpcodeContext&); } } diff --git a/sfall/Modules/Scripting/Handlers/Arrays.cpp b/sfall/Modules/Scripting/Handlers/Arrays.cpp index 68531f92c..8ff9324b0 100644 --- a/sfall/Modules/Scripting/Handlers/Arrays.cpp +++ b/sfall/Modules/Scripting/Handlers/Arrays.cpp @@ -28,12 +28,12 @@ namespace sfall namespace script { -void sf_create_array(OpcodeContext& ctx) { +void op_create_array(OpcodeContext& ctx) { auto arrayId = CreateArray(ctx.arg(0).rawValue(), ctx.arg(1).rawValue()); ctx.setReturn(arrayId); } -void sf_set_array(OpcodeContext& ctx) { +void op_set_array(OpcodeContext& ctx) { SetArray( ctx.arg(0).rawValue(), ctx.arg(1), @@ -47,7 +47,7 @@ void sf_set_array(OpcodeContext& ctx) { so it works as get_array if first argument is int and as substr(x, y, 1) if first argument is string example: vartext[5] */ -void sf_get_array(OpcodeContext& ctx) { +void op_get_array(OpcodeContext& ctx) { if (ctx.arg(0).isInt()) { ctx.setReturn( GetArray(ctx.arg(0).rawValue(), ctx.arg(1)) @@ -70,54 +70,54 @@ void sf_get_array(OpcodeContext& ctx) { } } -void sf_free_array(OpcodeContext& ctx) { +void op_free_array(OpcodeContext& ctx) { FreeArray(ctx.arg(0).rawValue()); } -void sf_len_array(OpcodeContext& ctx) { +void op_len_array(OpcodeContext& ctx) { ctx.setReturn( LenArray(ctx.arg(0).rawValue()) ); } -void sf_resize_array(OpcodeContext& ctx) { +void op_resize_array(OpcodeContext& ctx) { if (ResizeArray(ctx.arg(0).rawValue(), ctx.arg(1).rawValue())) { ctx.printOpcodeError("%s() - array sorting error.", ctx.getOpcodeName()); } } -void sf_temp_array(OpcodeContext& ctx) { +void op_temp_array(OpcodeContext& ctx) { auto arrayId = TempArray(ctx.arg(0).rawValue(), ctx.arg(1).rawValue()); ctx.setReturn(arrayId); } -void sf_fix_array(OpcodeContext& ctx) { +void op_fix_array(OpcodeContext& ctx) { FixArray(ctx.arg(0).rawValue()); } -void sf_scan_array(OpcodeContext& ctx) { +void op_scan_array(OpcodeContext& ctx) { ctx.setReturn( ScanArray(ctx.arg(0).rawValue(), ctx.arg(1)) ); } -void sf_save_array(OpcodeContext& ctx) { +void op_save_array(OpcodeContext& ctx) { SaveArray(ctx.arg(0), ctx.arg(1).rawValue()); } -void sf_load_array(OpcodeContext& ctx) { +void op_load_array(OpcodeContext& ctx) { ctx.setReturn( LoadArray(ctx.arg(0)) ); } -void sf_get_array_key(OpcodeContext& ctx) { +void op_get_array_key(OpcodeContext& ctx) { ctx.setReturn( GetArrayKey(ctx.arg(0).rawValue(), ctx.arg(1).rawValue()) ); } -void sf_stack_array(OpcodeContext& ctx) { +void op_stack_array(OpcodeContext& ctx) { ctx.setReturn( StackArray(ctx.arg(0), ctx.arg(1)) ); @@ -203,7 +203,7 @@ static DWORD ListAsArray(DWORD type) { return id; } -void sf_list_as_array(OpcodeContext& ctx) { +void op_list_as_array(OpcodeContext& ctx) { auto arrayId = ListAsArray(ctx.arg(0).rawValue()); ctx.setReturn(arrayId); } @@ -216,7 +216,7 @@ static DWORD ListBegin(DWORD type) { return listID; } -void sf_list_begin(OpcodeContext& ctx) { +void op_list_begin(OpcodeContext& ctx) { ctx.setReturn(ListBegin(ctx.arg(0).rawValue())); } @@ -224,7 +224,7 @@ static fo::GameObject* ListNext(sList* list) { return (!list || list->pos == list->len) ? 0 : list->obj[list->pos++]; } -void sf_list_next(OpcodeContext& ctx) { +void op_list_next(OpcodeContext& ctx) { fo::GameObject* obj = nullptr; auto id = ctx.arg(0).rawValue(); if (id != 0) { @@ -252,7 +252,7 @@ static void ListEnd(DWORD id) { } } -void sf_list_end(OpcodeContext& ctx) { +void op_list_end(OpcodeContext& ctx) { ListEnd(ctx.arg(0).rawValue()); } diff --git a/sfall/Modules/Scripting/Handlers/Arrays.h b/sfall/Modules/Scripting/Handlers/Arrays.h index b9cb8445b..cdb861cb4 100644 --- a/sfall/Modules/Scripting/Handlers/Arrays.h +++ b/sfall/Modules/Scripting/Handlers/Arrays.h @@ -23,43 +23,43 @@ namespace sfall namespace script { -void sf_create_array(OpcodeContext&); +void op_create_array(OpcodeContext&); -void sf_set_array(OpcodeContext&); +void op_set_array(OpcodeContext&); /* used in place of [] operator when compiling in sslc so it works as get_array if first argument is int and as substr(x, y, 1) if first argument is string */ -void sf_get_array(OpcodeContext&); +void op_get_array(OpcodeContext&); -void sf_free_array(OpcodeContext&); +void op_free_array(OpcodeContext&); -void sf_len_array(OpcodeContext&); +void op_len_array(OpcodeContext&); -void sf_resize_array(OpcodeContext&); +void op_resize_array(OpcodeContext&); -void sf_temp_array(OpcodeContext&); +void op_temp_array(OpcodeContext&); -void sf_fix_array(OpcodeContext&); +void op_fix_array(OpcodeContext&); -void sf_scan_array(OpcodeContext&); +void op_scan_array(OpcodeContext&); -void sf_save_array(OpcodeContext&); +void op_save_array(OpcodeContext&); -void sf_load_array(OpcodeContext&); +void op_load_array(OpcodeContext&); -void sf_get_array_key(OpcodeContext&); +void op_get_array_key(OpcodeContext&); -void sf_stack_array(OpcodeContext&); +void op_stack_array(OpcodeContext&); -void sf_list_begin(OpcodeContext&); +void op_list_begin(OpcodeContext&); -void sf_list_as_array(OpcodeContext&); +void op_list_as_array(OpcodeContext&); -void sf_list_next(OpcodeContext&); +void op_list_next(OpcodeContext&); -void sf_list_end(OpcodeContext&); +void op_list_end(OpcodeContext&); } } diff --git a/sfall/Modules/Scripting/Handlers/Core.cpp b/sfall/Modules/Scripting/Handlers/Core.cpp index 6a3c5d65d..4d39ec40e 100644 --- a/sfall/Modules/Scripting/Handlers/Core.cpp +++ b/sfall/Modules/Scripting/Handlers/Core.cpp @@ -32,7 +32,7 @@ namespace sfall namespace script { -void sf_typeof(OpcodeContext& ctx) { +void op_typeof(OpcodeContext& ctx) { ctx.setReturn(static_cast(ctx.arg(0).type())); } @@ -70,7 +70,7 @@ void __declspec(naked) op_available_global_script_types() { } } -void sf_set_sfall_global(OpcodeContext& ctx) { +void op_set_sfall_global(OpcodeContext& ctx) { if (ctx.arg(0).isString()) { if (SetGlobalVar(ctx.arg(0).strValue(), ctx.arg(1).rawValue())) { ctx.printOpcodeError("%s() - the name of the global variable must consist of 8 characters.", ctx.getOpcodeName()); @@ -99,11 +99,11 @@ static void GetGlobalVar(OpcodeContext& ctx, DataType type) { ctx.setReturn(result, type); } -void sf_get_sfall_global_int(OpcodeContext& ctx) { +void op_get_sfall_global_int(OpcodeContext& ctx) { GetGlobalVar(ctx, DataType::INT); } -void sf_get_sfall_global_float(OpcodeContext& ctx) { +void op_get_sfall_global_float(OpcodeContext& ctx) { GetGlobalVar(ctx, DataType::FLOAT); } @@ -119,7 +119,7 @@ void __declspec(naked) op_get_sfall_arg() { } } -void sf_get_sfall_arg_at(OpcodeContext& ctx) { +void mf_get_sfall_arg_at(OpcodeContext& ctx) { long argVal = 0; long id = ctx.arg(0).rawValue(); if (id >= static_cast(HookScripts::GetHSArgCount()) || id < 0) { @@ -130,7 +130,7 @@ void sf_get_sfall_arg_at(OpcodeContext& ctx) { ctx.setReturn(argVal); } -void sf_get_sfall_args(OpcodeContext& ctx) { +void op_get_sfall_args(OpcodeContext& ctx) { DWORD argCount = HookScripts::GetHSArgCount(); DWORD id = TempArray(argCount, 0); DWORD* args = HookScripts::GetHSArgs(); @@ -140,7 +140,7 @@ void sf_get_sfall_args(OpcodeContext& ctx) { ctx.setReturn(id); } -void sf_set_sfall_arg(OpcodeContext& ctx) { +void op_set_sfall_arg(OpcodeContext& ctx) { HookScripts::SetHSArg(ctx.arg(0).rawValue(), ctx.arg(1).rawValue()); } @@ -178,7 +178,7 @@ void __declspec(naked) op_set_self() { } // used for both register_hook and register_hook_proc -void sf_register_hook(OpcodeContext& ctx) { +void op_register_hook(OpcodeContext& ctx) { bool specReg = false; int proc; switch (ctx.opcode()) { @@ -194,11 +194,11 @@ void sf_register_hook(OpcodeContext& ctx) { RegisterHook(ctx.program(), ctx.arg(0).rawValue(), proc, specReg); } -void sf_add_g_timer_event(OpcodeContext& ctx) { +void mf_add_g_timer_event(OpcodeContext& ctx) { ScriptExtender::AddTimerEventScripts(ctx.program(), ctx.arg(0).rawValue(), ctx.arg(1).rawValue()); } -void sf_remove_timer_event(OpcodeContext& ctx) { +void mf_remove_timer_event(OpcodeContext& ctx) { if (ctx.numArgs() > 0) { ScriptExtender::RemoveTimerEventScripts(ctx.program(), ctx.arg(0).rawValue()); } else { @@ -206,15 +206,15 @@ void sf_remove_timer_event(OpcodeContext& ctx) { } } -void sf_sfall_ver_major(OpcodeContext& ctx) { +void op_sfall_ver_major(OpcodeContext& ctx) { ctx.setReturn(VERSION_MAJOR); } -void sf_sfall_ver_minor(OpcodeContext& ctx) { +void op_sfall_ver_minor(OpcodeContext& ctx) { ctx.setReturn(VERSION_MINOR); } -void sf_sfall_ver_build(OpcodeContext& ctx) { +void op_sfall_ver_build(OpcodeContext& ctx) { ctx.setReturn(VERSION_BUILD); } diff --git a/sfall/Modules/Scripting/Handlers/Core.h b/sfall/Modules/Scripting/Handlers/Core.h index 6e1615bea..e05fd78bb 100644 --- a/sfall/Modules/Scripting/Handlers/Core.h +++ b/sfall/Modules/Scripting/Handlers/Core.h @@ -25,7 +25,7 @@ namespace sfall namespace script { -void sf_typeof(OpcodeContext&); +void op_typeof(OpcodeContext&); void __declspec() op_set_global_script_repeat(); @@ -33,19 +33,19 @@ void __declspec() op_set_global_script_type(); void __declspec() op_available_global_script_types(); -void sf_set_sfall_global(OpcodeContext&); +void op_set_sfall_global(OpcodeContext&); -void sf_get_sfall_global_int(OpcodeContext&); +void op_get_sfall_global_int(OpcodeContext&); -void sf_get_sfall_global_float(OpcodeContext&); +void op_get_sfall_global_float(OpcodeContext&); void __declspec() op_get_sfall_arg(); -void sf_get_sfall_arg_at(OpcodeContext&); +void mf_get_sfall_arg_at(OpcodeContext&); -void sf_get_sfall_args(OpcodeContext&); +void op_get_sfall_args(OpcodeContext&); -void sf_set_sfall_arg(OpcodeContext&); +void op_set_sfall_arg(OpcodeContext&); void __declspec() op_set_sfall_return(); @@ -54,17 +54,17 @@ void __declspec() op_init_hook(); void __declspec() op_set_self(); // used for both register_hook and register_hook_proc -void sf_register_hook(OpcodeContext&); +void op_register_hook(OpcodeContext&); -void sf_add_g_timer_event(OpcodeContext&); +void mf_add_g_timer_event(OpcodeContext&); -void sf_remove_timer_event(OpcodeContext&); +void mf_remove_timer_event(OpcodeContext&); -void sf_sfall_ver_major(OpcodeContext&); +void op_sfall_ver_major(OpcodeContext&); -void sf_sfall_ver_minor(OpcodeContext&); +void op_sfall_ver_minor(OpcodeContext&); -void sf_sfall_ver_build(OpcodeContext&); +void op_sfall_ver_build(OpcodeContext&); } } diff --git a/sfall/Modules/Scripting/Handlers/FileSystem.cpp b/sfall/Modules/Scripting/Handlers/FileSystem.cpp index ebd773a48..aa49cbe51 100644 --- a/sfall/Modules/Scripting/Handlers/FileSystem.cpp +++ b/sfall/Modules/Scripting/Handlers/FileSystem.cpp @@ -28,71 +28,71 @@ namespace sfall namespace script { -void sf_fs_create(OpcodeContext& ctx) { +void op_fs_create(OpcodeContext& ctx) { ctx.setReturn(FScreate(ctx.arg(0).strValue(), ctx.arg(1).rawValue())); } -void sf_fs_copy(OpcodeContext& ctx) { +void op_fs_copy(OpcodeContext& ctx) { ctx.setReturn(FScopy(ctx.arg(0).strValue(), ctx.arg(1).strValue())); } -void sf_fs_find(OpcodeContext& ctx) { +void op_fs_find(OpcodeContext& ctx) { ctx.setReturn(FSfind(ctx.arg(0).strValue())); } -void sf_fs_write_byte(OpcodeContext& ctx) { +void op_fs_write_byte(OpcodeContext& ctx) { FSwrite_byte(ctx.arg(0).rawValue(), ctx.arg(1).rawValue()); } -void sf_fs_write_short(OpcodeContext& ctx) { +void op_fs_write_short(OpcodeContext& ctx) { FSwrite_short(ctx.arg(0).rawValue(), ctx.arg(1).rawValue()); } -void sf_fs_write_int(OpcodeContext& ctx) { +void op_fs_write_int(OpcodeContext& ctx) { FSwrite_int(ctx.arg(0).rawValue(), ctx.arg(1).rawValue()); } -void sf_fs_write_string(OpcodeContext& ctx) { +void op_fs_write_string(OpcodeContext& ctx) { FSwrite_string(ctx.arg(0).rawValue(), ctx.arg(1).strValue()); } -void sf_fs_write_bstring(OpcodeContext& ctx) { +void op_fs_write_bstring(OpcodeContext& ctx) { FSwrite_bstring(ctx.arg(0).rawValue(), ctx.arg(1).strValue()); } -void sf_fs_read_byte(OpcodeContext& ctx) { +void op_fs_read_byte(OpcodeContext& ctx) { ctx.setReturn(FSread_byte(ctx.arg(0).rawValue())); } -void sf_fs_read_short(OpcodeContext& ctx) { +void op_fs_read_short(OpcodeContext& ctx) { ctx.setReturn(FSread_short(ctx.arg(0).rawValue())); } -void sf_fs_read_int(OpcodeContext& ctx) { +void op_fs_read_int(OpcodeContext& ctx) { ctx.setReturn(FSread_int(ctx.arg(0).rawValue())); } -void sf_fs_read_float(OpcodeContext& ctx) { +void op_fs_read_float(OpcodeContext& ctx) { ctx.setReturn(FSread_int(ctx.arg(0).rawValue()), DataType::FLOAT); } -void sf_fs_delete(OpcodeContext& ctx) { +void op_fs_delete(OpcodeContext& ctx) { FSdelete(ctx.arg(0).rawValue()); } -void sf_fs_size(OpcodeContext& ctx) { +void op_fs_size(OpcodeContext& ctx) { ctx.setReturn(FSsize(ctx.arg(0).rawValue())); } -void sf_fs_pos(OpcodeContext& ctx) { +void op_fs_pos(OpcodeContext& ctx) { ctx.setReturn(FSpos(ctx.arg(0).rawValue())); } -void sf_fs_seek(OpcodeContext& ctx) { +void op_fs_seek(OpcodeContext& ctx) { FSseek(ctx.arg(0).rawValue(), ctx.arg(1).rawValue()); } -void sf_fs_resize(OpcodeContext& ctx) { +void op_fs_resize(OpcodeContext& ctx) { FSresize(ctx.arg(0).rawValue(), ctx.arg(1).rawValue()); } diff --git a/sfall/Modules/Scripting/Handlers/FileSystem.h b/sfall/Modules/Scripting/Handlers/FileSystem.h index d2d69594c..42a704ac0 100644 --- a/sfall/Modules/Scripting/Handlers/FileSystem.h +++ b/sfall/Modules/Scripting/Handlers/FileSystem.h @@ -27,39 +27,39 @@ namespace script class OpcodeContext; -void sf_fs_create(OpcodeContext&); +void op_fs_create(OpcodeContext&); -void sf_fs_copy(OpcodeContext&); +void op_fs_copy(OpcodeContext&); -void sf_fs_find(OpcodeContext&); +void op_fs_find(OpcodeContext&); -void sf_fs_write_byte(OpcodeContext&); +void op_fs_write_byte(OpcodeContext&); -void sf_fs_write_short(OpcodeContext&); +void op_fs_write_short(OpcodeContext&); -void sf_fs_write_int(OpcodeContext&); +void op_fs_write_int(OpcodeContext&); -void sf_fs_write_string(OpcodeContext&); +void op_fs_write_string(OpcodeContext&); -void sf_fs_write_bstring(OpcodeContext&); +void op_fs_write_bstring(OpcodeContext&); -void sf_fs_read_byte(OpcodeContext&); +void op_fs_read_byte(OpcodeContext&); -void sf_fs_read_short(OpcodeContext&); +void op_fs_read_short(OpcodeContext&); -void sf_fs_read_int(OpcodeContext&); +void op_fs_read_int(OpcodeContext&); -void sf_fs_read_float(OpcodeContext&); +void op_fs_read_float(OpcodeContext&); -void sf_fs_delete(OpcodeContext&); +void op_fs_delete(OpcodeContext&); -void sf_fs_size(OpcodeContext&); +void op_fs_size(OpcodeContext&); -void sf_fs_pos(OpcodeContext&); +void op_fs_pos(OpcodeContext&); -void sf_fs_seek(OpcodeContext&); +void op_fs_seek(OpcodeContext&); -void sf_fs_resize(OpcodeContext&); +void op_fs_resize(OpcodeContext&); } } diff --git a/sfall/Modules/Scripting/Handlers/Interface.cpp b/sfall/Modules/Scripting/Handlers/Interface.cpp index 90e90e6e2..60eb2d3d5 100644 --- a/sfall/Modules/Scripting/Handlers/Interface.cpp +++ b/sfall/Modules/Scripting/Handlers/Interface.cpp @@ -42,7 +42,7 @@ void __declspec(naked) op_input_funcs_available() { } } -void sf_key_pressed(OpcodeContext& ctx) { +void op_key_pressed(OpcodeContext& ctx) { ctx.setReturn(KeyDown(ctx.arg(0).rawValue())); } @@ -82,7 +82,7 @@ void __declspec(naked) op_get_mouse_y() { enum { MOUSE_MIDDLE_BTN = 4 }; -void sf_get_mouse_buttons(OpcodeContext& ctx) { +void op_get_mouse_buttons(OpcodeContext& ctx) { DWORD button = fo::var::last_buttons; if (button == 0 && middleMouseDown) { button = MOUSE_MIDDLE_BTN; @@ -144,7 +144,7 @@ static void SplitToBuffer(const char* str, const char** str_ptr, long &lines) { ScriptExtender::gTextBuffer[i] = '\0'; } -void sf_create_message_window(OpcodeContext &ctx) { +void op_create_message_window(OpcodeContext &ctx) { static bool dialogShow = false; if (dialogShow) return; @@ -160,7 +160,7 @@ void sf_create_message_window(OpcodeContext &ctx) { dialogShow = false; } -void sf_message_box(OpcodeContext &ctx) { +void mf_message_box(OpcodeContext &ctx) { static int dialogShowCount = 0; long lines = 0; @@ -219,13 +219,13 @@ void __declspec(naked) op_set_viewport_y() { } } -void sf_add_iface_tag(OpcodeContext &ctx) { +void mf_add_iface_tag(OpcodeContext &ctx) { int result = BarBoxes::AddExtraBox(); if (result == -1) ctx.printOpcodeError("%s() - cannot add new tag as the maximum limit of 126 tags has been reached.", ctx.getMetaruleName()); ctx.setReturn(result); } -void sf_show_iface_tag(OpcodeContext &ctx) { +void op_show_iface_tag(OpcodeContext &ctx) { int tag = ctx.arg(0).rawValue(); if (tag == 3 || tag == 4) { __asm mov eax, tag; @@ -235,7 +235,7 @@ void sf_show_iface_tag(OpcodeContext &ctx) { } } -void sf_hide_iface_tag(OpcodeContext &ctx) { +void op_hide_iface_tag(OpcodeContext &ctx) { int tag = ctx.arg(0).rawValue(); if (tag == 3 || tag == 4) { __asm mov eax, tag; @@ -245,7 +245,7 @@ void sf_hide_iface_tag(OpcodeContext &ctx) { } } -void sf_is_iface_tag_active(OpcodeContext &ctx) { +void op_is_iface_tag_active(OpcodeContext &ctx) { bool result = false; int tag = ctx.arg(0).rawValue(); if (tag >= 0 && tag < 5) { @@ -271,42 +271,42 @@ void sf_is_iface_tag_active(OpcodeContext &ctx) { ctx.setReturn(result); } -void sf_intface_redraw(OpcodeContext& ctx) { +void mf_intface_redraw(OpcodeContext& ctx) { fo::func::intface_redraw(); } -void sf_intface_show(OpcodeContext& ctx) { +void mf_intface_show(OpcodeContext& ctx) { __asm call fo::funcoffs::intface_show_; } -void sf_intface_hide(OpcodeContext& ctx) { +void mf_intface_hide(OpcodeContext& ctx) { __asm call fo::funcoffs::intface_hide_; } -void sf_intface_is_hidden(OpcodeContext& ctx) { +void mf_intface_is_hidden(OpcodeContext& ctx) { ctx.setReturn(fo::func::intface_is_hidden()); } -void sf_tile_refresh_display(OpcodeContext& ctx) { +void mf_tile_refresh_display(OpcodeContext& ctx) { fo::func::tile_refresh_display(); } -void sf_get_cursor_mode(OpcodeContext& ctx) { +void mf_get_cursor_mode(OpcodeContext& ctx) { ctx.setReturn(fo::func::gmouse_3d_get_mode()); } -void sf_set_cursor_mode(OpcodeContext& ctx) { +void mf_set_cursor_mode(OpcodeContext& ctx) { fo::func::gmouse_3d_set_mode(ctx.arg(0).rawValue()); } -void sf_display_stats(OpcodeContext& ctx) { +void mf_display_stats(OpcodeContext& ctx) { // calling the function outside of inventory screen will crash the game if (GetLoopFlags() & INVENTORY) { fo::func::display_stats(); } } -void sf_set_iface_tag_text(OpcodeContext& ctx) { +void mf_set_iface_tag_text(OpcodeContext& ctx) { int boxTag = ctx.arg(0).rawValue(); int maxBox = BarBoxes::MaxBox(); @@ -318,7 +318,7 @@ void sf_set_iface_tag_text(OpcodeContext& ctx) { } } -void sf_inventory_redraw(OpcodeContext& ctx) { +void mf_inventory_redraw(OpcodeContext& ctx) { int mode; DWORD loopFlag = GetLoopFlags() & (INVENTORY | INTFACEUSE | INTFACELOOT | BARTER); switch (loopFlag) { @@ -349,7 +349,7 @@ void sf_inventory_redraw(OpcodeContext& ctx) { } } -void sf_dialog_message(OpcodeContext& ctx) { +void mf_dialog_message(OpcodeContext& ctx) { DWORD loopFlag = GetLoopFlags(); if ((loopFlag & DIALOGVIEW) == 0 && (loopFlag & DIALOG)) { const char* message = ctx.arg(0).strValue(); @@ -357,7 +357,7 @@ void sf_dialog_message(OpcodeContext& ctx) { } } -void sf_create_win(OpcodeContext& ctx) { +void mf_create_win(OpcodeContext& ctx) { int flags = (ctx.numArgs() > 5) ? ctx.arg(5).rawValue() : fo::WinFlags::MoveOnTop; @@ -372,7 +372,7 @@ void sf_create_win(OpcodeContext& ctx) { } } -void sf_show_window(OpcodeContext& ctx) { +void mf_show_window(OpcodeContext& ctx) { if (ctx.numArgs() > 0) { const char* name = ctx.arg(0).strValue(); for (size_t i = 0; i < 16; i++) { @@ -387,7 +387,7 @@ void sf_show_window(OpcodeContext& ctx) { } } -void sf_hide_window(OpcodeContext& ctx) { +void mf_hide_window(OpcodeContext& ctx) { if (ctx.numArgs() > 0) { const char* name = ctx.arg(0).strValue(); for (size_t i = 0; i < 16; i++) { @@ -402,7 +402,7 @@ void sf_hide_window(OpcodeContext& ctx) { } } -void sf_set_window_flag(OpcodeContext& ctx) { +void mf_set_window_flag(OpcodeContext& ctx) { long bitFlag = ctx.arg(1).rawValue(); switch (bitFlag) { case fo::WinFlags::MoveOnTop: @@ -519,15 +519,15 @@ static long DrawImage(OpcodeContext& ctx, bool isScaled) { return 1; } -void sf_draw_image(OpcodeContext& ctx) { +void mf_draw_image(OpcodeContext& ctx) { ctx.setReturn(DrawImage(ctx, false)); } -void sf_draw_image_scaled(OpcodeContext& ctx) { +void mf_draw_image_scaled(OpcodeContext& ctx) { ctx.setReturn(DrawImage(ctx, true)); } -void sf_unwield_slot(OpcodeContext& ctx) { +void mf_unwield_slot(OpcodeContext& ctx) { fo::InvenType slot = static_cast(ctx.arg(1).rawValue()); if (slot < fo::INVEN_TYPE_WORN || slot > fo::INVEN_TYPE_LEFT_HAND) { ctx.printOpcodeError("%s() - incorrect slot number.", ctx.getMetaruleName()); @@ -589,7 +589,7 @@ void sf_unwield_slot(OpcodeContext& ctx) { if (update) fo::func::intface_update_items(0, -1, -1); } -void sf_get_window_attribute(OpcodeContext& ctx) { +void mf_get_window_attribute(OpcodeContext& ctx) { fo::Window* win = fo::GetWindow(ctx.arg(0).rawValue()); if (win == nullptr) { if (ctx.arg(1).rawValue() != 0) { diff --git a/sfall/Modules/Scripting/Handlers/Interface.h b/sfall/Modules/Scripting/Handlers/Interface.h index cbca21c3e..1c47e79f2 100644 --- a/sfall/Modules/Scripting/Handlers/Interface.h +++ b/sfall/Modules/Scripting/Handlers/Interface.h @@ -28,7 +28,7 @@ class OpcodeContext; // input_functions void __declspec() op_input_funcs_available(); -void sf_key_pressed(OpcodeContext& ctx); +void op_key_pressed(OpcodeContext& ctx); void __declspec() op_tap_key(); @@ -39,7 +39,7 @@ void __declspec() op_get_mouse_x(); void __declspec() op_get_mouse_y(); //Return pressed mouse button (1=left, 2=right, 3=left+right, 4=middle) -void sf_get_mouse_buttons(OpcodeContext&); +void op_get_mouse_buttons(OpcodeContext&); //Return the window number under the mous void __declspec() op_get_window_under_mouse(); @@ -57,9 +57,9 @@ void __declspec() op_stop_game(); void __declspec() op_resume_game(); //Create a message window with given string -void sf_create_message_window(OpcodeContext&); +void op_create_message_window(OpcodeContext&); -void sf_message_box(OpcodeContext&); +void mf_message_box(OpcodeContext&); void __declspec() op_get_viewport_x(); @@ -69,51 +69,51 @@ void __declspec() op_set_viewport_x(); void __declspec() op_set_viewport_y(); -void sf_add_iface_tag(OpcodeContext&); +void mf_add_iface_tag(OpcodeContext&); -void sf_show_iface_tag(OpcodeContext&); +void op_show_iface_tag(OpcodeContext&); -void sf_hide_iface_tag(OpcodeContext&); +void op_hide_iface_tag(OpcodeContext&); -void sf_is_iface_tag_active(OpcodeContext&); +void op_is_iface_tag_active(OpcodeContext&); -void sf_intface_redraw(OpcodeContext&); +void mf_intface_redraw(OpcodeContext&); -void sf_intface_show(OpcodeContext&); +void mf_intface_show(OpcodeContext&); -void sf_intface_hide(OpcodeContext&); +void mf_intface_hide(OpcodeContext&); -void sf_intface_is_hidden(OpcodeContext&); +void mf_intface_is_hidden(OpcodeContext&); -void sf_tile_refresh_display(OpcodeContext&); +void mf_tile_refresh_display(OpcodeContext&); -void sf_get_cursor_mode(OpcodeContext&); +void mf_get_cursor_mode(OpcodeContext&); -void sf_set_cursor_mode(OpcodeContext&); +void mf_set_cursor_mode(OpcodeContext&); -void sf_display_stats(OpcodeContext&); +void mf_display_stats(OpcodeContext&); -void sf_set_iface_tag_text(OpcodeContext&); +void mf_set_iface_tag_text(OpcodeContext&); -void sf_inventory_redraw(OpcodeContext&); +void mf_inventory_redraw(OpcodeContext&); -void sf_dialog_message(OpcodeContext&); +void mf_dialog_message(OpcodeContext&); -void sf_create_win(OpcodeContext&); +void mf_create_win(OpcodeContext&); -void sf_show_window(OpcodeContext&); +void mf_show_window(OpcodeContext&); -void sf_hide_window(OpcodeContext&); +void mf_hide_window(OpcodeContext&); -void sf_set_window_flag(OpcodeContext&); +void mf_set_window_flag(OpcodeContext&); -void sf_draw_image(OpcodeContext&); +void mf_draw_image(OpcodeContext&); -void sf_draw_image_scaled(OpcodeContext&); +void mf_draw_image_scaled(OpcodeContext&); -void sf_unwield_slot(OpcodeContext&); +void mf_unwield_slot(OpcodeContext&); -void sf_get_window_attribute(OpcodeContext&); +void mf_get_window_attribute(OpcodeContext&); } } diff --git a/sfall/Modules/Scripting/Handlers/Math.cpp b/sfall/Modules/Scripting/Handlers/Math.cpp index f76e8e0cc..ceca2d10a 100644 --- a/sfall/Modules/Scripting/Handlers/Math.cpp +++ b/sfall/Modules/Scripting/Handlers/Math.cpp @@ -27,7 +27,7 @@ namespace sfall namespace script { -void sf_div(OpcodeContext& ctx) { +void op_div(OpcodeContext& ctx) { if (ctx.arg(1).rawValue() == 0) { ctx.printOpcodeError("%s - division by zero.", ctx.getOpcodeName()); return; @@ -39,11 +39,11 @@ void sf_div(OpcodeContext& ctx) { } } -void sf_sqrt(OpcodeContext& ctx) { +void op_sqrt(OpcodeContext& ctx) { ctx.setReturn(sqrt(ctx.arg(0).asFloat())); } -void sf_abs(OpcodeContext& ctx) { +void op_abs(OpcodeContext& ctx) { if (ctx.arg(0).isInt()) { ctx.setReturn(abs(static_cast(ctx.arg(0).rawValue()))); } else { @@ -51,23 +51,23 @@ void sf_abs(OpcodeContext& ctx) { } } -void sf_sin(OpcodeContext& ctx) { +void op_sin(OpcodeContext& ctx) { ctx.setReturn(sin(ctx.arg(0).asFloat())); } -void sf_cos(OpcodeContext& ctx) { +void op_cos(OpcodeContext& ctx) { ctx.setReturn(cos(ctx.arg(0).asFloat())); } -void sf_tan(OpcodeContext& ctx) { +void op_tan(OpcodeContext& ctx) { ctx.setReturn(tan(ctx.arg(0).asFloat())); } -void sf_arctan(OpcodeContext& ctx) { +void op_arctan(OpcodeContext& ctx) { ctx.setReturn(atan2(ctx.arg(0).asFloat(), ctx.arg(1).asFloat())); } -void sf_power(OpcodeContext& ctx) { +void op_power(OpcodeContext& ctx) { const ScriptValue &base = ctx.arg(0), &power = ctx.arg(1); float result = 0.0; @@ -83,19 +83,19 @@ void sf_power(OpcodeContext& ctx) { } } -void sf_log(OpcodeContext& ctx) { +void op_log(OpcodeContext& ctx) { ctx.setReturn(log(ctx.arg(0).asFloat())); } -void sf_exponent(OpcodeContext& ctx) { +void op_exponent(OpcodeContext& ctx) { ctx.setReturn(exp(ctx.arg(0).asFloat())); } -void sf_ceil(OpcodeContext& ctx) { +void op_ceil(OpcodeContext& ctx) { ctx.setReturn(static_cast(ceil(ctx.arg(0).asFloat()))); } -void sf_round(OpcodeContext& ctx) { +void op_round(OpcodeContext& ctx) { float arg = ctx.arg(0).asFloat(); int argI = static_cast(arg); @@ -104,7 +104,7 @@ void sf_round(OpcodeContext& ctx) { ctx.setReturn(argI); } -void sf_floor2(OpcodeContext& ctx) { +void mf_floor2(OpcodeContext& ctx) { ctx.setReturn(static_cast(floor(ctx.arg(0).asFloat()))); } diff --git a/sfall/Modules/Scripting/Handlers/Math.h b/sfall/Modules/Scripting/Handlers/Math.h index 7beef79b7..00d562705 100644 --- a/sfall/Modules/Scripting/Handlers/Math.h +++ b/sfall/Modules/Scripting/Handlers/Math.h @@ -25,31 +25,31 @@ namespace script class OpcodeContext; -void sf_div(OpcodeContext&); +void op_div(OpcodeContext&); -void sf_sqrt(OpcodeContext&); +void op_sqrt(OpcodeContext&); -void sf_abs(OpcodeContext&); +void op_abs(OpcodeContext&); -void sf_sin(OpcodeContext&); +void op_sin(OpcodeContext&); -void sf_cos(OpcodeContext&); +void op_cos(OpcodeContext&); -void sf_tan(OpcodeContext&); +void op_tan(OpcodeContext&); -void sf_arctan(OpcodeContext&); +void op_arctan(OpcodeContext&); -void sf_power(OpcodeContext&); +void op_power(OpcodeContext&); -void sf_log(OpcodeContext&); +void op_log(OpcodeContext&); -void sf_exponent(OpcodeContext&); +void op_exponent(OpcodeContext&); -void sf_ceil(OpcodeContext&); +void op_ceil(OpcodeContext&); -void sf_round(OpcodeContext&); +void op_round(OpcodeContext&); -void sf_floor2(OpcodeContext&); +void mf_floor2(OpcodeContext&); } } diff --git a/sfall/Modules/Scripting/Handlers/Metarule.cpp b/sfall/Modules/Scripting/Handlers/Metarule.cpp index a84beca73..8aae02890 100644 --- a/sfall/Modules/Scripting/Handlers/Metarule.cpp +++ b/sfall/Modules/Scripting/Handlers/Metarule.cpp @@ -38,7 +38,7 @@ namespace script { // Metarule is a universal opcode(s) for all kinds of new sfall scripting functions. -// Prefix all function handlers with sf_ and add them to sfall_metarule_table. +// Prefix all function handlers with mf_ and add them to sfall_metarule_table. // DO NOT add arguments and/or return values to function handlers! // Use ctx.arg(i), inside handler function to access arguments. // Use ctx.setReturn(x) to set return value. @@ -62,95 +62,95 @@ static MetaruleTableType metaruleTable; - arg1, arg2, ... - argument types for automatic validation */ static const SfallMetarule metarules[] = { - {"add_extra_msg_file", sf_add_extra_msg_file, 1, 2, -1, {ARG_STRING, ARG_INT}}, - {"add_iface_tag", sf_add_iface_tag, 0, 0}, - {"add_g_timer_event", sf_add_g_timer_event, 2, 2, -1, {ARG_INT, ARG_INT}}, - {"add_trait", sf_add_trait, 1, 1, -1, {ARG_INT}}, - {"art_cache_clear", sf_art_cache_flush, 0, 0}, - {"attack_is_aimed", sf_attack_is_aimed, 0, 0}, - {"car_gas_amount", sf_car_gas_amount, 0, 0}, - {"create_win", sf_create_win, 5, 6, -1, {ARG_STRING, ARG_INT, ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, - {"critter_inven_obj2", sf_critter_inven_obj2, 2, 2, 0, {ARG_OBJECT, ARG_INT}}, - {"dialog_message", sf_dialog_message, 1, 1, -1, {ARG_STRING}}, - {"dialog_obj", sf_get_dialog_object, 0, 0}, - {"display_stats", sf_display_stats, 0, 0}, // refresh - {"draw_image", sf_draw_image, 1, 5, -1, {ARG_INTSTR, ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, - {"draw_image_scaled", sf_draw_image_scaled, 1, 6, -1, {ARG_INTSTR, ARG_INT, ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, - {"exec_map_update_scripts", sf_exec_map_update_scripts, 0, 0}, - {"floor2", sf_floor2, 1, 1, 0, {ARG_NUMBER}}, - {"get_can_rest_on_map", sf_get_rest_on_map, 2, 2, -1, {ARG_INT, ARG_INT}}, - {"get_current_inven_size", sf_get_current_inven_size, 1, 1, 0, {ARG_OBJECT}}, - {"get_cursor_mode", sf_get_cursor_mode, 0, 0}, - {"get_flags", sf_get_flags, 1, 1, 0, {ARG_OBJECT}}, - {"get_ini_section", sf_get_ini_section, 2, 2, -1, {ARG_STRING, ARG_STRING}}, - {"get_ini_sections", sf_get_ini_sections, 1, 1, -1, {ARG_STRING}}, - {"get_inven_ap_cost", sf_get_inven_ap_cost, 0, 0}, - {"get_map_enter_position", sf_get_map_enter_position, 0, 0}, - {"get_metarule_table", sf_get_metarule_table, 0, 0}, - {"get_object_ai_data", sf_get_object_ai_data, 2, 2, -1, {ARG_OBJECT, ARG_INT}}, - {"get_object_data", sf_get_object_data, 2, 2, 0, {ARG_OBJECT, ARG_INT}}, - {"get_outline", sf_get_outline, 1, 1, 0, {ARG_OBJECT}}, - {"get_sfall_arg_at", sf_get_sfall_arg_at, 1, 1, 0, {ARG_INT}}, - {"get_string_pointer", sf_get_string_pointer, 1, 1, 0, {ARG_STRING}}, - {"get_text_width", sf_get_text_width, 1, 1, 0, {ARG_STRING}}, - {"get_window_attribute", sf_get_window_attribute, 1, 2, -1, {ARG_INT, ARG_INT}}, - {"has_fake_perk_npc", sf_has_fake_perk_npc, 2, 2, 0, {ARG_OBJECT, ARG_STRING}}, - {"has_fake_trait_npc", sf_has_fake_trait_npc, 2, 2, 0, {ARG_OBJECT, ARG_STRING}}, - {"hide_window", sf_hide_window, 0, 1, -1, {ARG_STRING}}, - {"intface_hide", sf_intface_hide, 0, 0}, - {"intface_is_hidden", sf_intface_is_hidden, 0, 0}, - {"intface_redraw", sf_intface_redraw, 0, 0}, - {"intface_show", sf_intface_show, 0, 0}, - {"inventory_redraw", sf_inventory_redraw, 0, 1, -1, {ARG_INT}}, - {"item_make_explosive", sf_item_make_explosive, 3, 4, -1, {ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, - {"item_weight", sf_item_weight, 1, 1, 0, {ARG_OBJECT}}, - {"lock_is_jammed", sf_lock_is_jammed, 1, 1, 0, {ARG_OBJECT}}, - {"loot_obj", sf_get_loot_object, 0, 0}, - {"message_box", sf_message_box, 1, 4, -1, {ARG_STRING, ARG_INT, ARG_INT, ARG_INT}}, - {"metarule_exist", sf_metarule_exist, 1, 1}, // no arg check - {"npc_engine_level_up", sf_npc_engine_level_up, 1, 1}, - {"obj_under_cursor", sf_obj_under_cursor, 2, 2, 0, {ARG_INT, ARG_INT}}, - {"objects_in_radius", sf_objects_in_radius, 3, 4, 0, {ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, - {"outlined_object", sf_outlined_object, 0, 0}, - {"real_dude_obj", sf_real_dude_obj, 0, 0}, - {"remove_timer_event", sf_remove_timer_event, 0, 1, -1, {ARG_INT}}, - {"set_can_rest_on_map", sf_set_rest_on_map, 3, 3, -1, {ARG_INT, ARG_INT, ARG_INT}}, - {"set_car_intface_art", sf_set_car_intface_art, 1, 1, -1, {ARG_INT}}, - {"set_cursor_mode", sf_set_cursor_mode, 1, 1, -1, {ARG_INT}}, - {"set_drugs_data", sf_set_drugs_data, 3, 3, -1, {ARG_INT, ARG_INT, ARG_INT}}, - {"set_dude_obj", sf_set_dude_obj, 1, 1, -1, {ARG_INT}}, - {"set_fake_perk_npc", sf_set_fake_perk_npc, 5, 5, -1, {ARG_OBJECT, ARG_STRING, ARG_INT, ARG_INT, ARG_STRING}}, - {"set_fake_trait_npc", sf_set_fake_trait_npc, 5, 5, -1, {ARG_OBJECT, ARG_STRING, ARG_INT, ARG_INT, ARG_STRING}}, - {"set_flags", sf_set_flags, 2, 2, -1, {ARG_OBJECT, ARG_INT}}, - {"set_iface_tag_text", sf_set_iface_tag_text, 3, 3, -1, {ARG_INT, ARG_STRING, ARG_INT}}, - {"set_ini_setting", sf_set_ini_setting, 2, 2, -1, {ARG_STRING, ARG_INTSTR}}, - {"set_map_enter_position", sf_set_map_enter_position, 3, 3, -1, {ARG_INT, ARG_INT, ARG_INT}}, - {"set_object_data", sf_set_object_data, 3, 3, -1, {ARG_OBJECT, ARG_INT, ARG_INT}}, - {"set_outline", sf_set_outline, 2, 2, -1, {ARG_OBJECT, ARG_INT}}, - {"set_rest_heal_time", sf_set_rest_heal_time, 1, 1, -1, {ARG_INT}}, - {"set_rest_mode", sf_set_rest_mode, 1, 1, -1, {ARG_INT}}, - {"set_selectable_perk_npc", sf_set_selectable_perk_npc, 5, 5, -1, {ARG_OBJECT, ARG_STRING, ARG_INT, ARG_INT, ARG_STRING}}, - {"set_terrain_name", sf_set_terrain_name, 3, 3, -1, {ARG_INT, ARG_INT, ARG_STRING}}, - {"set_town_title", sf_set_town_title, 2, 2, -1, {ARG_INT, ARG_STRING}}, - {"set_unique_id", sf_set_unique_id, 1, 2, -1, {ARG_OBJECT, ARG_INT}}, - {"set_unjam_locks_time", sf_set_unjam_locks_time, 1, 1, -1, {ARG_INT}}, - {"set_window_flag", sf_set_window_flag, 3, 3, -1, {ARG_INTSTR, ARG_INT, ARG_INT}}, - {"show_window", sf_show_window, 0, 1, -1, {ARG_STRING}}, - {"spatial_radius", sf_spatial_radius, 1, 1, 0, {ARG_OBJECT}}, - {"string_compare", sf_string_compare, 2, 3, 0, {ARG_STRING, ARG_STRING, ARG_INT}}, - {"string_format", sf_string_format, 2, 5, 0, {ARG_STRING, ARG_ANY, ARG_ANY, ARG_ANY, ARG_ANY}}, - {"string_to_case", sf_string_to_case, 2, 2, -1, {ARG_STRING, ARG_INT}}, - {"tile_by_position", sf_tile_by_position, 2, 2, -1, {ARG_INT, ARG_INT}}, - {"tile_refresh_display", sf_tile_refresh_display, 0, 0}, - {"unjam_lock", sf_unjam_lock, 1, 1, -1, {ARG_OBJECT}}, - {"unwield_slot", sf_unwield_slot, 2, 2, -1, {ARG_OBJECT, ARG_INT}}, + {"add_extra_msg_file", mf_add_extra_msg_file, 1, 2, -1, {ARG_STRING, ARG_INT}}, + {"add_iface_tag", mf_add_iface_tag, 0, 0}, + {"add_g_timer_event", mf_add_g_timer_event, 2, 2, -1, {ARG_INT, ARG_INT}}, + {"add_trait", mf_add_trait, 1, 1, -1, {ARG_INT}}, + {"art_cache_clear", mf_art_cache_flush, 0, 0}, + {"attack_is_aimed", mf_attack_is_aimed, 0, 0}, + {"car_gas_amount", mf_car_gas_amount, 0, 0}, + {"create_win", mf_create_win, 5, 6, -1, {ARG_STRING, ARG_INT, ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, + {"critter_inven_obj2", mf_critter_inven_obj2, 2, 2, 0, {ARG_OBJECT, ARG_INT}}, + {"dialog_message", mf_dialog_message, 1, 1, -1, {ARG_STRING}}, + {"dialog_obj", mf_get_dialog_object, 0, 0}, + {"display_stats", mf_display_stats, 0, 0}, // refresh + {"draw_image", mf_draw_image, 1, 5, -1, {ARG_INTSTR, ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, + {"draw_image_scaled", mf_draw_image_scaled, 1, 6, -1, {ARG_INTSTR, ARG_INT, ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, + {"exec_map_update_scripts", mf_exec_map_update_scripts, 0, 0}, + {"floor2", mf_floor2, 1, 1, 0, {ARG_NUMBER}}, + {"get_can_rest_on_map", mf_get_rest_on_map, 2, 2, -1, {ARG_INT, ARG_INT}}, + {"get_current_inven_size", mf_get_current_inven_size, 1, 1, 0, {ARG_OBJECT}}, + {"get_cursor_mode", mf_get_cursor_mode, 0, 0}, + {"get_flags", mf_get_flags, 1, 1, 0, {ARG_OBJECT}}, + {"get_ini_section", mf_get_ini_section, 2, 2, -1, {ARG_STRING, ARG_STRING}}, + {"get_ini_sections", mf_get_ini_sections, 1, 1, -1, {ARG_STRING}}, + {"get_inven_ap_cost", mf_get_inven_ap_cost, 0, 0}, + {"get_map_enter_position", mf_get_map_enter_position, 0, 0}, + {"get_metarule_table", mf_get_metarule_table, 0, 0}, + {"get_object_ai_data", mf_get_object_ai_data, 2, 2, -1, {ARG_OBJECT, ARG_INT}}, + {"get_object_data", mf_get_object_data, 2, 2, 0, {ARG_OBJECT, ARG_INT}}, + {"get_outline", mf_get_outline, 1, 1, 0, {ARG_OBJECT}}, + {"get_sfall_arg_at", mf_get_sfall_arg_at, 1, 1, 0, {ARG_INT}}, + {"get_string_pointer", mf_get_string_pointer, 1, 1, 0, {ARG_STRING}}, + {"get_text_width", mf_get_text_width, 1, 1, 0, {ARG_STRING}}, + {"get_window_attribute", mf_get_window_attribute, 1, 2, -1, {ARG_INT, ARG_INT}}, + {"has_fake_perk_npc", mf_has_fake_perk_npc, 2, 2, 0, {ARG_OBJECT, ARG_STRING}}, + {"has_fake_trait_npc", mf_has_fake_trait_npc, 2, 2, 0, {ARG_OBJECT, ARG_STRING}}, + {"hide_window", mf_hide_window, 0, 1, -1, {ARG_STRING}}, + {"intface_hide", mf_intface_hide, 0, 0}, + {"intface_is_hidden", mf_intface_is_hidden, 0, 0}, + {"intface_redraw", mf_intface_redraw, 0, 0}, + {"intface_show", mf_intface_show, 0, 0}, + {"inventory_redraw", mf_inventory_redraw, 0, 1, -1, {ARG_INT}}, + {"item_make_explosive", mf_item_make_explosive, 3, 4, -1, {ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, + {"item_weight", mf_item_weight, 1, 1, 0, {ARG_OBJECT}}, + {"lock_is_jammed", mf_lock_is_jammed, 1, 1, 0, {ARG_OBJECT}}, + {"loot_obj", mf_get_loot_object, 0, 0}, + {"message_box", mf_message_box, 1, 4, -1, {ARG_STRING, ARG_INT, ARG_INT, ARG_INT}}, + {"metarule_exist", mf_metarule_exist, 1, 1}, // no arg check + {"npc_engine_level_up", mf_npc_engine_level_up, 1, 1}, + {"obj_under_cursor", mf_obj_under_cursor, 2, 2, 0, {ARG_INT, ARG_INT}}, + {"objects_in_radius", mf_objects_in_radius, 3, 4, 0, {ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, + {"outlined_object", mf_outlined_object, 0, 0}, + {"real_dude_obj", mf_real_dude_obj, 0, 0}, + {"remove_timer_event", mf_remove_timer_event, 0, 1, -1, {ARG_INT}}, + {"set_can_rest_on_map", mf_set_rest_on_map, 3, 3, -1, {ARG_INT, ARG_INT, ARG_INT}}, + {"set_car_intface_art", mf_set_car_intface_art, 1, 1, -1, {ARG_INT}}, + {"set_cursor_mode", mf_set_cursor_mode, 1, 1, -1, {ARG_INT}}, + {"set_drugs_data", mf_set_drugs_data, 3, 3, -1, {ARG_INT, ARG_INT, ARG_INT}}, + {"set_dude_obj", mf_set_dude_obj, 1, 1, -1, {ARG_INT}}, + {"set_fake_perk_npc", mf_set_fake_perk_npc, 5, 5, -1, {ARG_OBJECT, ARG_STRING, ARG_INT, ARG_INT, ARG_STRING}}, + {"set_fake_trait_npc", mf_set_fake_trait_npc, 5, 5, -1, {ARG_OBJECT, ARG_STRING, ARG_INT, ARG_INT, ARG_STRING}}, + {"set_flags", mf_set_flags, 2, 2, -1, {ARG_OBJECT, ARG_INT}}, + {"set_iface_tag_text", mf_set_iface_tag_text, 3, 3, -1, {ARG_INT, ARG_STRING, ARG_INT}}, + {"set_ini_setting", mf_set_ini_setting, 2, 2, -1, {ARG_STRING, ARG_INTSTR}}, + {"set_map_enter_position", mf_set_map_enter_position, 3, 3, -1, {ARG_INT, ARG_INT, ARG_INT}}, + {"set_object_data", mf_set_object_data, 3, 3, -1, {ARG_OBJECT, ARG_INT, ARG_INT}}, + {"set_outline", mf_set_outline, 2, 2, -1, {ARG_OBJECT, ARG_INT}}, + {"set_rest_heal_time", mf_set_rest_heal_time, 1, 1, -1, {ARG_INT}}, + {"set_rest_mode", mf_set_rest_mode, 1, 1, -1, {ARG_INT}}, + {"set_selectable_perk_npc", mf_set_selectable_perk_npc, 5, 5, -1, {ARG_OBJECT, ARG_STRING, ARG_INT, ARG_INT, ARG_STRING}}, + {"set_terrain_name", mf_set_terrain_name, 3, 3, -1, {ARG_INT, ARG_INT, ARG_STRING}}, + {"set_town_title", mf_set_town_title, 2, 2, -1, {ARG_INT, ARG_STRING}}, + {"set_unique_id", mf_set_unique_id, 1, 2, -1, {ARG_OBJECT, ARG_INT}}, + {"set_unjam_locks_time", mf_set_unjam_locks_time, 1, 1, -1, {ARG_INT}}, + {"set_window_flag", mf_set_window_flag, 3, 3, -1, {ARG_INTSTR, ARG_INT, ARG_INT}}, + {"show_window", mf_show_window, 0, 1, -1, {ARG_STRING}}, + {"spatial_radius", mf_spatial_radius, 1, 1, 0, {ARG_OBJECT}}, + {"string_compare", mf_string_compare, 2, 3, 0, {ARG_STRING, ARG_STRING, ARG_INT}}, + {"string_format", mf_string_format, 2, 5, 0, {ARG_STRING, ARG_ANY, ARG_ANY, ARG_ANY, ARG_ANY}}, + {"string_to_case", mf_string_to_case, 2, 2, -1, {ARG_STRING, ARG_INT}}, + {"tile_by_position", mf_tile_by_position, 2, 2, -1, {ARG_INT, ARG_INT}}, + {"tile_refresh_display", mf_tile_refresh_display, 0, 0}, + {"unjam_lock", mf_unjam_lock, 1, 1, -1, {ARG_OBJECT}}, + {"unwield_slot", mf_unwield_slot, 2, 2, -1, {ARG_OBJECT, ARG_INT}}, #ifndef NDEBUG - {"validate_test", sf_test, 2, 5, -1, {ARG_INT, ARG_NUMBER, ARG_STRING, ARG_OBJECT, ARG_ANY}}, + {"validate_test", mf_test, 2, 5, -1, {ARG_INT, ARG_NUMBER, ARG_STRING, ARG_OBJECT, ARG_ANY}}, #endif }; // returns current contents of metarule table -static void sf_get_metarule_table(OpcodeContext& ctx) { +static void mf_get_metarule_table(OpcodeContext& ctx) { DWORD arrId = TempArray(metaruleTable.size(), 0); int i = 0; for (auto it = metaruleTable.begin(); it != metaruleTable.end(); ++it) { @@ -160,7 +160,7 @@ static void sf_get_metarule_table(OpcodeContext& ctx) { ctx.setReturn(arrId, DataType::INT); } -static void sf_metarule_exist(OpcodeContext& ctx) { +static void mf_metarule_exist(OpcodeContext& ctx) { bool result = false; auto funcXName = ctx.arg(0).asString(); if (funcXName[0] != '\0') { @@ -220,8 +220,8 @@ void HandleMetarule(OpcodeContext& ctx) { } #ifndef NDEBUG -static std::string sf_test_stringBuf; -void sf_test(OpcodeContext& ctx) { +static std::string mf_test_stringBuf; +void mf_test(OpcodeContext& ctx) { std::ostringstream sstream; sstream << "sfall_funcX(\"test\""; for (int i = 0; i < ctx.numArgs(); i++) { @@ -244,8 +244,8 @@ void sf_test(OpcodeContext& ctx) { } sstream << ")"; - sf_test_stringBuf = sstream.str(); - ctx.setReturn(sf_test_stringBuf.c_str()); + mf_test_stringBuf = sstream.str(); + ctx.setReturn(mf_test_stringBuf.c_str()); } #endif diff --git a/sfall/Modules/Scripting/Handlers/Metarule.h b/sfall/Modules/Scripting/Handlers/Metarule.h index de7c86ee5..ded825b7c 100644 --- a/sfall/Modules/Scripting/Handlers/Metarule.h +++ b/sfall/Modules/Scripting/Handlers/Metarule.h @@ -32,13 +32,13 @@ namespace script // Example handler. Feel free to add handlers in other files. #ifndef NDEBUG -void sf_test(OpcodeContext&); +void mf_test(OpcodeContext&); #endif // returns current contents of metarule table -void sf_get_metarule_table(OpcodeContext&); +void mf_get_metarule_table(OpcodeContext&); -void sf_metarule_exist(OpcodeContext&); +void mf_metarule_exist(OpcodeContext&); void InitMetaruleTable(); diff --git a/sfall/Modules/Scripting/Handlers/Misc.cpp b/sfall/Modules/Scripting/Handlers/Misc.cpp index ed6f2e547..277549ce3 100644 --- a/sfall/Modules/Scripting/Handlers/Misc.cpp +++ b/sfall/Modules/Scripting/Handlers/Misc.cpp @@ -50,7 +50,7 @@ namespace script const char* stringTooLong = "%s() - the string exceeds maximum length of 64 characters."; -void sf_set_dm_model(OpcodeContext& ctx) { +void op_set_dm_model(OpcodeContext& ctx) { auto model = ctx.arg(0).strValue(); if (strlen(model) > 64) { ctx.printOpcodeError(stringTooLong, ctx.getOpcodeName()); @@ -59,7 +59,7 @@ void sf_set_dm_model(OpcodeContext& ctx) { strcpy(defaultMaleModelName, model); } -void sf_set_df_model(OpcodeContext& ctx) { +void op_set_df_model(OpcodeContext& ctx) { auto model = ctx.arg(0).strValue(); if (strlen(model) > 64) { ctx.printOpcodeError(stringTooLong, ctx.getOpcodeName()); @@ -68,7 +68,7 @@ void sf_set_df_model(OpcodeContext& ctx) { strcpy(defaultFemaleModelName, model); } -void sf_set_movie_path(OpcodeContext& ctx) { +void op_set_movie_path(OpcodeContext& ctx) { long movieID = ctx.arg(1).rawValue(); if (movieID < 0 || movieID >= MaxMovies) return; auto fileName = ctx.arg(0).strValue(); @@ -79,7 +79,7 @@ void sf_set_movie_path(OpcodeContext& ctx) { strcpy(&MoviePaths[movieID * 65], fileName); } -void sf_get_year(OpcodeContext& ctx) { +void op_get_year(OpcodeContext& ctx) { int year = 0; __asm { xor eax, eax; @@ -168,7 +168,7 @@ void __declspec(naked) op_mod_kill_counter() { } } -void sf_set_object_knockback(OpcodeContext& ctx) { +void op_set_object_knockback(OpcodeContext& ctx) { int mode = 0; switch (ctx.opcode()) { case 0x196: @@ -193,7 +193,7 @@ void sf_set_object_knockback(OpcodeContext& ctx) { KnockbackSetMod(object, ctx.arg(1).rawValue(), ctx.arg(2).asFloat(), mode); } -void sf_remove_object_knockback(OpcodeContext& ctx) { +void op_remove_object_knockback(OpcodeContext& ctx) { int mode = 0; switch (ctx.opcode()) { case 0x199: @@ -263,7 +263,7 @@ static void __cdecl IncNPCLevel(const char* fmt, const char* name) { __asm pop edx; } -void sf_inc_npc_level(OpcodeContext& ctx) { +void op_inc_npc_level(OpcodeContext& ctx) { nameNPCToInc = ctx.arg(0).asString(); pidNPCToInc = ctx.arg(0).asInt(); // set to 0 if passing npc name if (pidNPCToInc == 0 && nameNPCToInc[0] == 0) return; @@ -285,7 +285,7 @@ void sf_inc_npc_level(OpcodeContext& ctx) { } } -void sf_get_npc_level(OpcodeContext& ctx) { +void op_get_npc_level(OpcodeContext& ctx) { int level = -1; DWORD findPid = ctx.arg(0).asInt(); // set to 0 if passing npc name const char *critterName, *name = ctx.arg(0).asString(); @@ -386,11 +386,11 @@ static DWORD GetIniSetting(const char* str, bool isString) { } } -void sf_get_ini_setting(OpcodeContext& ctx) { +void op_get_ini_setting(OpcodeContext& ctx) { ctx.setReturn(GetIniSetting(ctx.arg(0).strValue(), false)); } -void sf_get_ini_string(OpcodeContext& ctx) { +void op_get_ini_string(OpcodeContext& ctx) { DWORD result = GetIniSetting(ctx.arg(0).strValue(), true); ctx.setReturn(result, (result != -1) ? DataType::STR : DataType::INT); } @@ -463,7 +463,7 @@ void __declspec(naked) op_set_bodypart_hit_modifier() { static const char* valueOutRange = "%s() - argument values out of range."; -void sf_set_critical_table(OpcodeContext& ctx) { +void op_set_critical_table(OpcodeContext& ctx) { DWORD critter = ctx.arg(0).rawValue(), bodypart = ctx.arg(1).rawValue(), slot = ctx.arg(2).rawValue(), @@ -476,7 +476,7 @@ void sf_set_critical_table(OpcodeContext& ctx) { } } -void sf_get_critical_table(OpcodeContext& ctx) { +void op_get_critical_table(OpcodeContext& ctx) { DWORD critter = ctx.arg(0).rawValue(), bodypart = ctx.arg(1).rawValue(), slot = ctx.arg(2).rawValue(), @@ -489,7 +489,7 @@ void sf_get_critical_table(OpcodeContext& ctx) { } } -void sf_reset_critical_table(OpcodeContext& ctx) { +void op_reset_critical_table(OpcodeContext& ctx) { DWORD critter = ctx.arg(0).rawValue(), bodypart = ctx.arg(1).rawValue(), slot = ctx.arg(2).rawValue(), @@ -536,7 +536,7 @@ void __declspec(naked) op_get_unspent_ap_perk_bonus() { } } -void sf_set_palette(OpcodeContext& ctx) { +void op_set_palette(OpcodeContext& ctx) { const char* palette = ctx.arg(0).strValue(); __asm { mov eax, palette; @@ -604,11 +604,11 @@ void __declspec(naked) op_refresh_pc_art() { } } -void sf_get_attack_type(OpcodeContext& ctx) { +void op_get_attack_type(OpcodeContext& ctx) { ctx.setReturn(fo::GetCurrentAttackMode()); } -void sf_play_sfall_sound(OpcodeContext& ctx) { +void op_play_sfall_sound(OpcodeContext& ctx) { DWORD soundID = 0; long mode = ctx.arg(1).rawValue(); if (mode >= 0) soundID = Sound::PlaySfallSound(ctx.arg(0).strValue(), mode); @@ -783,29 +783,29 @@ void __declspec(naked) op_set_inven_ap_cost() { } } -void sf_get_inven_ap_cost(OpcodeContext& ctx) { +void mf_get_inven_ap_cost(OpcodeContext& ctx) { ctx.setReturn(Inventory::GetInvenApCost()); } -void sf_attack_is_aimed(OpcodeContext& ctx) { +void mf_attack_is_aimed(OpcodeContext& ctx) { DWORD isAimed, unused; ctx.setReturn(!fo::func::intface_get_attack(&unused, &isAimed) ? isAimed : 0); } -void sf_sneak_success(OpcodeContext& ctx) { +void op_sneak_success(OpcodeContext& ctx) { ctx.setReturn(fo::func::is_pc_sneak_working()); } -void sf_tile_light(OpcodeContext& ctx) { +void op_tile_light(OpcodeContext& ctx) { int lightLevel = fo::func::light_get_tile(ctx.arg(0).rawValue(), ctx.arg(1).rawValue()); ctx.setReturn(lightLevel); } -void sf_exec_map_update_scripts(OpcodeContext& ctx) { +void mf_exec_map_update_scripts(OpcodeContext& ctx) { __asm call fo::funcoffs::scr_exec_map_update_scripts_ } -void sf_set_ini_setting(OpcodeContext& ctx) { +void mf_set_ini_setting(OpcodeContext& ctx) { const ScriptValue &argVal = ctx.arg(1); const char* saveValue; @@ -854,7 +854,7 @@ static std::string GetIniFilePath(const ScriptValue &arg) { return fileName; } -void sf_get_ini_sections(OpcodeContext& ctx) { +void mf_get_ini_sections(OpcodeContext& ctx) { if (!GetPrivateProfileSectionNamesA(ScriptExtender::gTextBuffer, ScriptExtender::TextBufferSize(), GetIniFilePath(ctx.arg(0)).c_str())) { ctx.setReturn(TempArray(0, 0)); return; @@ -877,7 +877,7 @@ void sf_get_ini_sections(OpcodeContext& ctx) { ctx.setReturn(arrayId); } -void sf_get_ini_section(OpcodeContext& ctx) { +void mf_get_ini_section(OpcodeContext& ctx) { auto section = ctx.arg(1).strValue(); int arrayId = TempArray(-1, 0); // associative @@ -901,7 +901,7 @@ void sf_get_ini_section(OpcodeContext& ctx) { ctx.setReturn(arrayId); } -void sf_npc_engine_level_up(OpcodeContext& ctx) { +void mf_npc_engine_level_up(OpcodeContext& ctx) { if (ctx.arg(0).asBool()) { if (!npcEngineLevelUp) SafeWrite16(0x4AFC1C, 0x840F); // enable npcEngineLevelUp = true; diff --git a/sfall/Modules/Scripting/Handlers/Misc.h b/sfall/Modules/Scripting/Handlers/Misc.h index cabcb3f52..e6da8a649 100644 --- a/sfall/Modules/Scripting/Handlers/Misc.h +++ b/sfall/Modules/Scripting/Handlers/Misc.h @@ -29,13 +29,13 @@ namespace script class OpcodeContext; -void sf_set_dm_model(OpcodeContext&); +void op_set_dm_model(OpcodeContext&); -void sf_set_df_model(OpcodeContext&); +void op_set_df_model(OpcodeContext&); -void sf_set_movie_path(OpcodeContext&); +void op_set_movie_path(OpcodeContext&); -void sf_get_year(OpcodeContext&); +void op_get_year(OpcodeContext&); void __declspec() op_game_loaded(); @@ -48,9 +48,9 @@ void __declspec() op_get_kill_counter(); void __declspec() op_mod_kill_counter(); -void sf_set_object_knockback(OpcodeContext&); +void op_set_object_knockback(OpcodeContext&); -void sf_remove_object_knockback(OpcodeContext&); +void op_remove_object_knockback(OpcodeContext&); void __declspec() op_active_hand(); @@ -58,13 +58,13 @@ void __declspec() op_toggle_active_hand(); void __declspec() op_eax_available(); -void sf_inc_npc_level(OpcodeContext&); +void op_inc_npc_level(OpcodeContext&); -void sf_get_npc_level(OpcodeContext&); +void op_get_npc_level(OpcodeContext&); -void sf_get_ini_setting(OpcodeContext&); +void op_get_ini_setting(OpcodeContext&); -void sf_get_ini_string(OpcodeContext&); +void op_get_ini_string(OpcodeContext&); void __declspec() op_get_uptime(); @@ -76,11 +76,11 @@ void __declspec() op_get_bodypart_hit_modifier(); void __declspec() op_set_bodypart_hit_modifier(); -void sf_set_critical_table(OpcodeContext&); +void op_set_critical_table(OpcodeContext&); -void sf_get_critical_table(OpcodeContext&); +void op_get_critical_table(OpcodeContext&); -void sf_reset_critical_table(OpcodeContext&); +void op_reset_critical_table(OpcodeContext&); void __declspec() op_set_unspent_ap_bonus(); @@ -90,7 +90,7 @@ void __declspec() op_set_unspent_ap_perk_bonus(); void __declspec() op_get_unspent_ap_perk_bonus(); -void sf_set_palette(OpcodeContext&); +void op_set_palette(OpcodeContext&); //numbers subgame functions void __declspec() op_nb_create_char(); @@ -105,9 +105,9 @@ void __declspec() op_get_light_level(); void __declspec() op_refresh_pc_art(); -void sf_get_attack_type(OpcodeContext&); +void op_get_attack_type(OpcodeContext&); -void sf_play_sfall_sound(OpcodeContext&); +void op_play_sfall_sound(OpcodeContext&); void __declspec() op_stop_sfall_sound(); @@ -133,23 +133,23 @@ void __declspec() op_gdialog_get_barter_mod(); void __declspec() op_set_inven_ap_cost(); -void sf_get_inven_ap_cost(OpcodeContext&); +void mf_get_inven_ap_cost(OpcodeContext&); -void sf_attack_is_aimed(OpcodeContext&); +void mf_attack_is_aimed(OpcodeContext&); -void sf_sneak_success(OpcodeContext&); +void op_sneak_success(OpcodeContext&); -void sf_tile_light(OpcodeContext&); +void op_tile_light(OpcodeContext&); -void sf_exec_map_update_scripts(OpcodeContext&); +void mf_exec_map_update_scripts(OpcodeContext&); -void sf_set_ini_setting(OpcodeContext&); +void mf_set_ini_setting(OpcodeContext&); -void sf_get_ini_sections(OpcodeContext&); +void mf_get_ini_sections(OpcodeContext&); -void sf_get_ini_section(OpcodeContext&); +void mf_get_ini_section(OpcodeContext&); -void sf_npc_engine_level_up(OpcodeContext&); +void mf_npc_engine_level_up(OpcodeContext&); } } diff --git a/sfall/Modules/Scripting/Handlers/Objects.cpp b/sfall/Modules/Scripting/Handlers/Objects.cpp index ce63401c3..5665c6880 100644 --- a/sfall/Modules/Scripting/Handlers/Objects.cpp +++ b/sfall/Modules/Scripting/Handlers/Objects.cpp @@ -42,7 +42,7 @@ namespace script __asm call fo::funcoffs::exec_script_proc_ \ } -void sf_remove_script(OpcodeContext& ctx) { +void op_remove_script(OpcodeContext& ctx) { auto object = ctx.arg(0).object(); if (object->scriptId != 0xFFFFFFFF) { fo::func::scr_remove(object->scriptId); @@ -50,7 +50,7 @@ void sf_remove_script(OpcodeContext& ctx) { } } -void sf_set_script(OpcodeContext& ctx) { +void op_set_script(OpcodeContext& ctx) { using fo::Scripts::start; using fo::Scripts::map_enter_p_proc; @@ -81,7 +81,7 @@ void sf_set_script(OpcodeContext& ctx) { if ((valArg & 0x80000000) == 0) exec_script_proc(scriptId, map_enter_p_proc); } -void sf_create_spatial(OpcodeContext& ctx) { +void op_create_spatial(OpcodeContext& ctx) { using fo::Scripts::start; DWORD scriptIndex = ctx.arg(0).rawValue(), @@ -104,7 +104,7 @@ void sf_create_spatial(OpcodeContext& ctx) { ctx.setReturn(fo::func::scr_find_obj_from_program(scriptPtr->program)); } -void sf_spatial_radius(OpcodeContext& ctx) { +void mf_spatial_radius(OpcodeContext& ctx) { auto spatialObj = ctx.arg(0).object(); fo::ScriptInstance* script; if (fo::func::scr_ptr(spatialObj->scriptId, &script) != -1) { @@ -112,31 +112,31 @@ void sf_spatial_radius(OpcodeContext& ctx) { } } -void sf_get_script(OpcodeContext& ctx) { +void op_get_script(OpcodeContext& ctx) { auto scriptIndex = ctx.arg(0).object()->scriptIndex; ctx.setReturn((scriptIndex >= 0) ? ++scriptIndex : 0); } -void sf_set_critter_burst_disable(OpcodeContext& ctx) { +void op_set_critter_burst_disable(OpcodeContext& ctx) { SetNoBurstMode(ctx.arg(0).object(), ctx.arg(1).asBool()); } -void sf_get_weapon_ammo_pid(OpcodeContext& ctx) { +void op_get_weapon_ammo_pid(OpcodeContext& ctx) { auto obj = ctx.arg(0).object(); ctx.setReturn(obj->item.ammoPid); } -void sf_set_weapon_ammo_pid(OpcodeContext& ctx) { +void op_set_weapon_ammo_pid(OpcodeContext& ctx) { auto obj = ctx.arg(0).object(); obj->item.ammoPid = ctx.arg(1).rawValue(); } -void sf_get_weapon_ammo_count(OpcodeContext& ctx) { +void op_get_weapon_ammo_count(OpcodeContext& ctx) { auto obj = ctx.arg(0).object(); ctx.setReturn(obj->item.charges); } -void sf_set_weapon_ammo_count(OpcodeContext& ctx) { +void op_set_weapon_ammo_count(OpcodeContext& ctx) { auto obj = ctx.arg(0).object(); obj->item.charges = ctx.arg(1).rawValue(); } @@ -164,7 +164,7 @@ static DWORD getBlockingFunc(DWORD type) { } } -void sf_make_straight_path(OpcodeContext& ctx) { +void op_make_straight_path(OpcodeContext& ctx) { auto objFrom = ctx.arg(0).object(); DWORD tileTo = ctx.arg(1).rawValue(), type = ctx.arg(2).rawValue(); @@ -175,7 +175,7 @@ void sf_make_straight_path(OpcodeContext& ctx) { ctx.setReturn(resultObj); } -void sf_make_path(OpcodeContext& ctx) { +void op_make_path(OpcodeContext& ctx) { auto objFrom = ctx.arg(0).object(); auto tileTo = ctx.arg(1).rawValue(), type = ctx.arg(2).rawValue(); @@ -193,7 +193,7 @@ void sf_make_path(OpcodeContext& ctx) { ctx.setReturn(arrayId); } -void sf_obj_blocking_at(OpcodeContext& ctx) { +void op_obj_blocking_at(OpcodeContext& ctx) { DWORD tile = ctx.arg(0).rawValue(), elevation = ctx.arg(1).rawValue(), type = ctx.arg(2).rawValue(); @@ -206,7 +206,7 @@ void sf_obj_blocking_at(OpcodeContext& ctx) { ctx.setReturn(resultObj); } -void sf_tile_get_objects(OpcodeContext& ctx) { +void op_tile_get_objects(OpcodeContext& ctx) { DWORD tile = ctx.arg(0).rawValue(), elevation = ctx.arg(1).rawValue(); DWORD arrayId = TempArray(0, 4); @@ -218,7 +218,7 @@ void sf_tile_get_objects(OpcodeContext& ctx) { ctx.setReturn(arrayId); } -void sf_get_party_members(OpcodeContext& ctx) { +void op_get_party_members(OpcodeContext& ctx) { auto includeHidden = ctx.arg(0).rawValue(); int actualCount = fo::var::partyMemberCount; DWORD arrayId = TempArray(0, 4); @@ -232,11 +232,11 @@ void sf_get_party_members(OpcodeContext& ctx) { ctx.setReturn(arrayId); } -void sf_art_exists(OpcodeContext& ctx) { +void op_art_exists(OpcodeContext& ctx) { ctx.setReturn(fo::func::art_exists(ctx.arg(0).rawValue())); } -void sf_obj_is_carrying_obj(OpcodeContext& ctx) { +void op_obj_is_carrying_obj(OpcodeContext& ctx) { int num = 0; const ScriptValue &invenObjArg = ctx.arg(0), &itemObjArg = ctx.arg(1); @@ -254,7 +254,7 @@ void sf_obj_is_carrying_obj(OpcodeContext& ctx) { ctx.setReturn(num); } -void sf_critter_inven_obj2(OpcodeContext& ctx) { +void mf_critter_inven_obj2(OpcodeContext& ctx) { fo::GameObject* critter = ctx.arg(0).object(); int slot = ctx.arg(1).rawValue(); switch (slot) { @@ -275,37 +275,37 @@ void sf_critter_inven_obj2(OpcodeContext& ctx) { } } -void sf_set_outline(OpcodeContext& ctx) { +void mf_set_outline(OpcodeContext& ctx) { auto obj = ctx.arg(0).object(); int color = ctx.arg(1).rawValue(); obj->outline = color; } -void sf_get_outline(OpcodeContext& ctx) { +void mf_get_outline(OpcodeContext& ctx) { auto obj = ctx.arg(0).object(); ctx.setReturn(obj->outline); } -void sf_set_flags(OpcodeContext& ctx) { +void mf_set_flags(OpcodeContext& ctx) { auto obj = ctx.arg(0).object(); int flags = ctx.arg(1).rawValue(); obj->flags = flags; } -void sf_get_flags(OpcodeContext& ctx) { +void mf_get_flags(OpcodeContext& ctx) { auto obj = ctx.arg(0).object(); ctx.setReturn(obj->flags); } -void sf_outlined_object(OpcodeContext& ctx) { +void mf_outlined_object(OpcodeContext& ctx) { ctx.setReturn(fo::var::outlined_object); } -void sf_item_weight(OpcodeContext& ctx) { +void mf_item_weight(OpcodeContext& ctx) { ctx.setReturn(fo::func::item_weight(ctx.arg(0).object())); } -void sf_set_dude_obj(OpcodeContext& ctx) { +void mf_set_dude_obj(OpcodeContext& ctx) { auto obj = ctx.arg(0).object(); if (obj == nullptr || obj->Type() == fo::ObjType::OBJ_TYPE_CRITTER) { //if (!InCombat && obj && obj != PartyControl::RealDudeObject()) { @@ -319,23 +319,23 @@ void sf_set_dude_obj(OpcodeContext& ctx) { } } -void sf_real_dude_obj(OpcodeContext& ctx) { +void mf_real_dude_obj(OpcodeContext& ctx) { ctx.setReturn(PartyControl::RealDudeObject()); } -void sf_car_gas_amount(OpcodeContext& ctx) { +void mf_car_gas_amount(OpcodeContext& ctx) { ctx.setReturn(fo::var::carGasAmount); } -void sf_lock_is_jammed(OpcodeContext& ctx) { +void mf_lock_is_jammed(OpcodeContext& ctx) { ctx.setReturn(fo::func::obj_lock_is_jammed(ctx.arg(0).object())); } -void sf_unjam_lock(OpcodeContext& ctx) { +void mf_unjam_lock(OpcodeContext& ctx) { fo::func::obj_unjam_lock(ctx.arg(0).object()); } -void sf_set_unjam_locks_time(OpcodeContext& ctx) { +void mf_set_unjam_locks_time(OpcodeContext& ctx) { int time = ctx.arg(0).rawValue(); if (time < 0 || time > 127) { ctx.printOpcodeError("%s() - time argument must be in the range of 0 to 127.", ctx.getMetaruleName()); @@ -345,7 +345,7 @@ void sf_set_unjam_locks_time(OpcodeContext& ctx) { } } -void sf_item_make_explosive(OpcodeContext& ctx) { +void mf_item_make_explosive(OpcodeContext& ctx) { DWORD pid = ctx.arg(0).rawValue(); DWORD pidActive = ctx.arg(1).rawValue(); DWORD min = ctx.arg(2).rawValue(); @@ -364,26 +364,26 @@ void sf_item_make_explosive(OpcodeContext& ctx) { } } -void sf_get_current_inven_size(OpcodeContext& ctx) { +void mf_get_current_inven_size(OpcodeContext& ctx) { ctx.setReturn(sf_item_total_size(ctx.arg(0).object())); } -void sf_get_dialog_object(OpcodeContext& ctx) { +void mf_get_dialog_object(OpcodeContext& ctx) { ctx.setReturn(InDialog() ? fo::var::dialog_target : 0); } -void sf_obj_under_cursor(OpcodeContext& ctx) { +void mf_obj_under_cursor(OpcodeContext& ctx) { ctx.setReturn(fo::func::object_under_mouse(ctx.arg(0).asBool() ? 1 : -1, ctx.arg(1).rawValue(), fo::var::map_elevation)); } -void sf_get_loot_object(OpcodeContext& ctx) { +void mf_get_loot_object(OpcodeContext& ctx) { ctx.setReturn((GetLoopFlags() & INTFACELOOT) ? fo::var::target_stack[fo::var::target_curr_stack] : 0); } static const char* failedLoad = "%s() - failed to load a prototype ID: %d"; static bool protoMaxLimitPatch = false; -void sf_get_proto_data(OpcodeContext& ctx) { +void op_get_proto_data(OpcodeContext& ctx) { fo::Proto* protoPtr; int pid = ctx.arg(0).rawValue(); int result = fo::func::proto_ptr(pid, &protoPtr); @@ -395,7 +395,7 @@ void sf_get_proto_data(OpcodeContext& ctx) { ctx.setReturn(result); } -void sf_set_proto_data(OpcodeContext& ctx) { +void op_set_proto_data(OpcodeContext& ctx) { int pid = ctx.arg(0).rawValue(); if (CritterStats::SetProtoData(pid, ctx.arg(1).rawValue(), ctx.arg(2).rawValue()) != -1) { if (!protoMaxLimitPatch) { @@ -407,7 +407,7 @@ void sf_set_proto_data(OpcodeContext& ctx) { } } -void sf_get_object_data(OpcodeContext& ctx) { +void mf_get_object_data(OpcodeContext& ctx) { DWORD result = 0; DWORD* object_ptr = (DWORD*)ctx.arg(0).rawValue(); if (*(object_ptr - 1) != 0xFEEDFACE) { @@ -418,7 +418,7 @@ void sf_get_object_data(OpcodeContext& ctx) { ctx.setReturn(result); } -void sf_set_object_data(OpcodeContext& ctx) { +void mf_set_object_data(OpcodeContext& ctx) { DWORD* object_ptr = (DWORD*)ctx.arg(0).rawValue(); if (*(object_ptr - 1) != 0xFEEDFACE) { ctx.printOpcodeError("%s() - invalid object pointer.", ctx.getMetaruleName()); @@ -428,7 +428,7 @@ void sf_set_object_data(OpcodeContext& ctx) { } } -void sf_get_object_ai_data(OpcodeContext& ctx) { +void mf_get_object_ai_data(OpcodeContext& ctx) { fo::AIcap* cap = fo::func::ai_cap(ctx.arg(0).object()); DWORD arrayId, value = -1; switch (ctx.arg(1).rawValue()) { @@ -487,7 +487,7 @@ void sf_get_object_ai_data(OpcodeContext& ctx) { ctx.setReturn(value); } -void sf_set_drugs_data(OpcodeContext& ctx) { +void mf_set_drugs_data(OpcodeContext& ctx) { int type = ctx.arg(0).rawValue(); int pid = ctx.arg(1).rawValue(); int val = ctx.arg(2).rawValue(); @@ -509,7 +509,7 @@ void sf_set_drugs_data(OpcodeContext& ctx) { } } -void sf_set_unique_id(OpcodeContext& ctx) { +void mf_set_unique_id(OpcodeContext& ctx) { fo::GameObject* obj = ctx.arg(0).object(); long id; if (ctx.arg(1).rawValue() == -1) { @@ -521,7 +521,7 @@ void sf_set_unique_id(OpcodeContext& ctx) { ctx.setReturn(id); } -void sf_objects_in_radius(OpcodeContext& ctx) { +void mf_objects_in_radius(OpcodeContext& ctx) { long radius = ctx.arg(1).rawValue(); if (radius <= 0) radius = 1; else if (radius > 50) radius = 50; long elev = ctx.arg(2).rawValue(); diff --git a/sfall/Modules/Scripting/Handlers/Objects.h b/sfall/Modules/Scripting/Handlers/Objects.h index 47b4f22cc..10c5f3cff 100644 --- a/sfall/Modules/Scripting/Handlers/Objects.h +++ b/sfall/Modules/Scripting/Handlers/Objects.h @@ -27,91 +27,91 @@ namespace sfall namespace script { -void sf_remove_script(OpcodeContext&); +void op_remove_script(OpcodeContext&); -void sf_set_script(OpcodeContext&); +void op_set_script(OpcodeContext&); -void sf_create_spatial(OpcodeContext&); +void op_create_spatial(OpcodeContext&); -void sf_spatial_radius(OpcodeContext&); +void mf_spatial_radius(OpcodeContext&); -void sf_get_script(OpcodeContext&); +void op_get_script(OpcodeContext&); -void sf_set_critter_burst_disable(OpcodeContext&); +void op_set_critter_burst_disable(OpcodeContext&); -void sf_get_weapon_ammo_pid(OpcodeContext&); +void op_get_weapon_ammo_pid(OpcodeContext&); -void sf_set_weapon_ammo_pid(OpcodeContext&); +void op_set_weapon_ammo_pid(OpcodeContext&); -void sf_get_weapon_ammo_count(OpcodeContext&); +void op_get_weapon_ammo_count(OpcodeContext&); -void sf_set_weapon_ammo_count(OpcodeContext&); +void op_set_weapon_ammo_count(OpcodeContext&); -void sf_make_straight_path(OpcodeContext&); +void op_make_straight_path(OpcodeContext&); -void sf_make_path(OpcodeContext&); +void op_make_path(OpcodeContext&); -void sf_obj_blocking_at(OpcodeContext&); +void op_obj_blocking_at(OpcodeContext&); -void sf_tile_get_objects(OpcodeContext&); +void op_tile_get_objects(OpcodeContext&); -void sf_get_party_members(OpcodeContext&); +void op_get_party_members(OpcodeContext&); -void sf_art_exists(OpcodeContext&); +void op_art_exists(OpcodeContext&); -void sf_obj_is_carrying_obj(OpcodeContext&); +void op_obj_is_carrying_obj(OpcodeContext&); -void sf_critter_inven_obj2(OpcodeContext&); +void mf_critter_inven_obj2(OpcodeContext&); -void sf_set_outline(OpcodeContext&); +void mf_set_outline(OpcodeContext&); -void sf_get_outline(OpcodeContext&); +void mf_get_outline(OpcodeContext&); -void sf_set_flags(OpcodeContext&); +void mf_set_flags(OpcodeContext&); -void sf_get_flags(OpcodeContext&); +void mf_get_flags(OpcodeContext&); -void sf_outlined_object(OpcodeContext&); +void mf_outlined_object(OpcodeContext&); -void sf_item_weight(OpcodeContext&); +void mf_item_weight(OpcodeContext&); -void sf_set_dude_obj(OpcodeContext&); +void mf_set_dude_obj(OpcodeContext&); -void sf_real_dude_obj(OpcodeContext&); +void mf_real_dude_obj(OpcodeContext&); -void sf_car_gas_amount(OpcodeContext&); +void mf_car_gas_amount(OpcodeContext&); -void sf_lock_is_jammed(OpcodeContext&); +void mf_lock_is_jammed(OpcodeContext&); -void sf_unjam_lock(OpcodeContext&); +void mf_unjam_lock(OpcodeContext&); -void sf_set_unjam_locks_time(OpcodeContext&); +void mf_set_unjam_locks_time(OpcodeContext&); -void sf_item_make_explosive(OpcodeContext&); +void mf_item_make_explosive(OpcodeContext&); -void sf_get_current_inven_size(OpcodeContext&); +void mf_get_current_inven_size(OpcodeContext&); -void sf_get_dialog_object(OpcodeContext&); +void mf_get_dialog_object(OpcodeContext&); -void sf_obj_under_cursor(OpcodeContext&); +void mf_obj_under_cursor(OpcodeContext&); -void sf_get_loot_object(OpcodeContext&); +void mf_get_loot_object(OpcodeContext&); -void sf_get_proto_data(OpcodeContext&); +void op_get_proto_data(OpcodeContext&); -void sf_set_proto_data(OpcodeContext&); +void op_set_proto_data(OpcodeContext&); -void sf_get_object_data(OpcodeContext&); +void mf_get_object_data(OpcodeContext&); -void sf_set_object_data(OpcodeContext&); +void mf_set_object_data(OpcodeContext&); -void sf_get_object_ai_data(OpcodeContext&); +void mf_get_object_ai_data(OpcodeContext&); -void sf_set_drugs_data(OpcodeContext&); +void mf_set_drugs_data(OpcodeContext&); -void sf_set_unique_id(OpcodeContext&); +void mf_set_unique_id(OpcodeContext&); -void sf_objects_in_radius(OpcodeContext&); +void mf_objects_in_radius(OpcodeContext&); } } diff --git a/sfall/Modules/Scripting/Handlers/Perks.cpp b/sfall/Modules/Scripting/Handlers/Perks.cpp index b2aa07376..bd746f11c 100644 --- a/sfall/Modules/Scripting/Handlers/Perks.cpp +++ b/sfall/Modules/Scripting/Handlers/Perks.cpp @@ -62,7 +62,7 @@ void __declspec(naked) op_set_perk_freq() { } } -void sf_get_perk_available(OpcodeContext& ctx) { +void op_get_perk_available(OpcodeContext& ctx) { int result = 0, perkId = ctx.arg(0).rawValue(); if (perkId >= 0 && perkId < 256) { // start fake id result = fo::func::perk_can_add(fo::var::obj_dude, perkId); @@ -70,11 +70,11 @@ void sf_get_perk_available(OpcodeContext& ctx) { ctx.setReturn(result); } -void sf_set_perk_name(OpcodeContext& ctx) { +void op_set_perk_name(OpcodeContext& ctx) { Perks::SetPerkName(ctx.arg(0).rawValue(), ctx.arg(1).strValue()); } -void sf_set_perk_desc(OpcodeContext& ctx) { +void op_set_perk_desc(OpcodeContext& ctx) { Perks::SetPerkDesc(ctx.arg(0).rawValue(), ctx.arg(1).strValue()); } @@ -100,21 +100,21 @@ void __declspec(naked) op_set_perk_value() { } } -void sf_set_selectable_perk(OpcodeContext& ctx) { +void op_set_selectable_perk(OpcodeContext& ctx) { Perks::SetSelectablePerk(ctx.arg(0).strValue(), ctx.arg(1).rawValue(), ctx.arg(2).rawValue(), ctx.arg(3).strValue()); } -void sf_set_fake_perk(OpcodeContext& ctx) { +void op_set_fake_perk(OpcodeContext& ctx) { Perks::SetFakePerk(ctx.arg(0).strValue(), ctx.arg(1).rawValue(), ctx.arg(2).rawValue(), ctx.arg(3).strValue()); } -void sf_set_fake_trait(OpcodeContext& ctx) { +void op_set_fake_trait(OpcodeContext& ctx) { Perks::SetFakeTrait(ctx.arg(0).strValue(), ctx.arg(1).rawValue(), ctx.arg(2).rawValue(), ctx.arg(3).strValue()); } const char* notPartyMemberErr = "%s() - the object is not a party member."; -void sf_set_selectable_perk_npc(OpcodeContext& ctx) { +void mf_set_selectable_perk_npc(OpcodeContext& ctx) { auto obj = ctx.arg(0).object(); if (obj->Type() == fo::ObjType::OBJ_TYPE_CRITTER && fo::func::isPartyMember(obj)) { Perks::SetSelectablePerk(ctx.arg(1).strValue(), ctx.arg(2).rawValue(), ctx.arg(3).rawValue(), ctx.arg(4).strValue(), (obj->id != fo::PLAYER_ID) ? obj->id : 0); @@ -124,7 +124,7 @@ void sf_set_selectable_perk_npc(OpcodeContext& ctx) { } } -void sf_set_fake_perk_npc(OpcodeContext& ctx) { +void mf_set_fake_perk_npc(OpcodeContext& ctx) { auto obj = ctx.arg(0).object(); if (obj->Type() == fo::ObjType::OBJ_TYPE_CRITTER && fo::func::isPartyMember(obj)) { Perks::SetFakePerk(ctx.arg(1).strValue(), ctx.arg(2).rawValue(), ctx.arg(3).rawValue(), ctx.arg(4).strValue(), (obj->id != fo::PLAYER_ID) ? obj->id : 0); @@ -134,7 +134,7 @@ void sf_set_fake_perk_npc(OpcodeContext& ctx) { } } -void sf_set_fake_trait_npc(OpcodeContext& ctx) { +void mf_set_fake_trait_npc(OpcodeContext& ctx) { auto obj = ctx.arg(0).object(); if (obj->Type() == fo::ObjType::OBJ_TYPE_CRITTER && fo::func::isPartyMember(obj)) { Perks::SetFakeTrait(ctx.arg(1).strValue(), ctx.arg(2).rawValue(), ctx.arg(3).rawValue(), ctx.arg(4).strValue(), (obj->id != fo::PLAYER_ID) ? obj->id : 0); @@ -193,15 +193,15 @@ void __declspec(naked) op_clear_selectable_perks() { } } -void sf_has_fake_perk(OpcodeContext& ctx) { +void op_has_fake_perk(OpcodeContext& ctx) { ctx.setReturn(Perks::HasFakePerk(ctx.arg(0).asString(), ctx.arg(0).asInt())); } -void sf_has_fake_trait(OpcodeContext& ctx) { +void op_has_fake_trait(OpcodeContext& ctx) { ctx.setReturn(Perks::HasFakeTrait(ctx.arg(0).strValue())); } -void sf_has_fake_perk_npc(OpcodeContext& ctx) { +void mf_has_fake_perk_npc(OpcodeContext& ctx) { long result = 0; auto obj = ctx.arg(0).object(); if (obj->Type() == fo::ObjType::OBJ_TYPE_CRITTER && fo::func::isPartyMember(obj)) { @@ -212,7 +212,7 @@ void sf_has_fake_perk_npc(OpcodeContext& ctx) { ctx.setReturn(result); } -void sf_has_fake_trait_npc(OpcodeContext& ctx) { +void mf_has_fake_trait_npc(OpcodeContext& ctx) { long result = 0; auto obj = ctx.arg(0).object(); if (obj->Type() == fo::ObjType::OBJ_TYPE_CRITTER && fo::func::isPartyMember(obj)) { @@ -325,7 +325,7 @@ void __declspec(naked) op_set_perk_level_mod() { } } -void sf_add_trait(OpcodeContext& ctx) { +void mf_add_trait(OpcodeContext& ctx) { if (fo::var::obj_dude->protoId != fo::PID_Player) { ctx.printOpcodeError("%s() - traits can be added only to the player.", ctx.getMetaruleName()); ctx.setReturn(-1); diff --git a/sfall/Modules/Scripting/Handlers/Perks.h b/sfall/Modules/Scripting/Handlers/Perks.h index 3aa8b08ca..43ba6c16c 100644 --- a/sfall/Modules/Scripting/Handlers/Perks.h +++ b/sfall/Modules/Scripting/Handlers/Perks.h @@ -29,25 +29,25 @@ void __declspec() op_set_perk_owed(); void __declspec() op_set_perk_freq(); -void sf_get_perk_available(OpcodeContext&); +void op_get_perk_available(OpcodeContext&); -void sf_set_perk_name(OpcodeContext&); +void op_set_perk_name(OpcodeContext&); -void sf_set_perk_desc(OpcodeContext&); +void op_set_perk_desc(OpcodeContext&); void __declspec() op_set_perk_value(); -void sf_set_selectable_perk(OpcodeContext&); +void op_set_selectable_perk(OpcodeContext&); -void sf_set_fake_perk(OpcodeContext&); +void op_set_fake_perk(OpcodeContext&); -void sf_set_fake_trait(OpcodeContext&); +void op_set_fake_trait(OpcodeContext&); -void sf_set_selectable_perk_npc(OpcodeContext&); +void mf_set_selectable_perk_npc(OpcodeContext&); -void sf_set_fake_perk_npc(OpcodeContext&); +void mf_set_fake_perk_npc(OpcodeContext&); -void sf_set_fake_trait_npc(OpcodeContext&); +void mf_set_fake_trait_npc(OpcodeContext&); void __declspec() op_set_perkbox_title(); @@ -57,13 +57,13 @@ void __declspec() op_show_real_perks(); void __declspec() op_clear_selectable_perks(); -void sf_has_fake_perk(OpcodeContext&); +void op_has_fake_perk(OpcodeContext&); -void sf_has_fake_trait(OpcodeContext&); +void op_has_fake_trait(OpcodeContext&); -void sf_has_fake_perk_npc(OpcodeContext&); +void mf_has_fake_perk_npc(OpcodeContext&); -void sf_has_fake_trait_npc(OpcodeContext&); +void mf_has_fake_trait_npc(OpcodeContext&); void __declspec() op_perk_add_mode(); @@ -77,7 +77,7 @@ void __declspec() op_set_swiftlearner_mod(); void __declspec() op_set_perk_level_mod(); -void sf_add_trait(OpcodeContext&); +void mf_add_trait(OpcodeContext&); } } diff --git a/sfall/Modules/Scripting/Handlers/Stats.cpp b/sfall/Modules/Scripting/Handlers/Stats.cpp index c4db319a9..ed5c9f0b0 100644 --- a/sfall/Modules/Scripting/Handlers/Stats.cpp +++ b/sfall/Modules/Scripting/Handlers/Stats.cpp @@ -37,7 +37,7 @@ namespace script const char* invalidStat = "%s() - stat number out of range."; const char* objNotCritter = "%s() - the object is not a critter."; -void sf_set_pc_base_stat(OpcodeContext& ctx) { +void op_set_pc_base_stat(OpcodeContext& ctx) { int stat = ctx.arg(0).rawValue(); if (stat >= 0 && stat < fo::STAT_max_stat) { ((long*)FO_VAR_pc_proto)[9 + stat] = ctx.arg(1).rawValue(); @@ -46,7 +46,7 @@ void sf_set_pc_base_stat(OpcodeContext& ctx) { } } -void sf_set_pc_extra_stat(OpcodeContext& ctx) { +void op_set_pc_extra_stat(OpcodeContext& ctx) { int stat = ctx.arg(0).rawValue(); if (stat >= 0 && stat < fo::STAT_max_stat) { ((long*)FO_VAR_pc_proto)[44 + stat] = ctx.arg(1).rawValue(); @@ -55,7 +55,7 @@ void sf_set_pc_extra_stat(OpcodeContext& ctx) { } } -void sf_get_pc_base_stat(OpcodeContext& ctx) { +void op_get_pc_base_stat(OpcodeContext& ctx) { int value = 0, stat = ctx.arg(0).rawValue(); if (stat >= 0 && stat < fo::STAT_max_stat) { @@ -66,7 +66,7 @@ void sf_get_pc_base_stat(OpcodeContext& ctx) { ctx.setReturn(value); } -void sf_get_pc_extra_stat(OpcodeContext& ctx) { +void op_get_pc_extra_stat(OpcodeContext& ctx) { int value = 0, stat = ctx.arg(0).rawValue(); if (stat >= 0 && stat < fo::STAT_max_stat) { @@ -77,7 +77,7 @@ void sf_get_pc_extra_stat(OpcodeContext& ctx) { ctx.setReturn(value); } -void sf_set_critter_base_stat(OpcodeContext& ctx) { +void op_set_critter_base_stat(OpcodeContext& ctx) { fo::GameObject* obj = ctx.arg(0).object(); if (obj && obj->Type() == fo::OBJ_TYPE_CRITTER) { int stat = ctx.arg(1).rawValue(); @@ -91,7 +91,7 @@ void sf_set_critter_base_stat(OpcodeContext& ctx) { } } -void sf_set_critter_extra_stat(OpcodeContext& ctx) { +void op_set_critter_extra_stat(OpcodeContext& ctx) { fo::GameObject* obj = ctx.arg(0).object(); if (obj && obj->Type() == fo::OBJ_TYPE_CRITTER) { int stat = ctx.arg(1).rawValue(); @@ -105,7 +105,7 @@ void sf_set_critter_extra_stat(OpcodeContext& ctx) { } } -void sf_get_critter_base_stat(OpcodeContext& ctx) { +void op_get_critter_base_stat(OpcodeContext& ctx) { int result = 0; fo::GameObject* obj = ctx.arg(0).object(); if (obj && obj->Type() == fo::OBJ_TYPE_CRITTER) { @@ -121,7 +121,7 @@ void sf_get_critter_base_stat(OpcodeContext& ctx) { ctx.setReturn(result); } -void sf_get_critter_extra_stat(OpcodeContext& ctx) { +void op_get_critter_extra_stat(OpcodeContext& ctx) { int result = 0; fo::GameObject* obj = ctx.arg(0).object(); if (obj && obj->Type() == fo::OBJ_TYPE_CRITTER) { @@ -137,7 +137,7 @@ void sf_get_critter_extra_stat(OpcodeContext& ctx) { ctx.setReturn(result); } -void sf_set_critter_skill_points(OpcodeContext& ctx) { +void op_set_critter_skill_points(OpcodeContext& ctx) { unsigned long skill = ctx.arg(1).rawValue(); if (skill > 17) { ctx.printOpcodeError("%s() - incorrect skill number.", ctx.getOpcodeName()); @@ -153,7 +153,7 @@ void sf_set_critter_skill_points(OpcodeContext& ctx) { } } -void sf_get_critter_skill_points(OpcodeContext& ctx) { +void op_get_critter_skill_points(OpcodeContext& ctx) { unsigned long skill = ctx.arg(1).rawValue(); if (skill > 17) { ctx.printOpcodeError("%s() - incorrect skill number.", ctx.getOpcodeName()); @@ -230,7 +230,7 @@ void __declspec(naked) op_get_critter_current_ap() { } } -void sf_set_critter_current_ap(OpcodeContext& ctx) { +void op_set_critter_current_ap(OpcodeContext& ctx) { fo::GameObject* obj = ctx.arg(0).object(); if (obj->Type() == fo::OBJ_TYPE_CRITTER) { long ap = ctx.arg(1).rawValue(); @@ -277,7 +277,7 @@ void __declspec(naked) op_set_hit_chance_max() { } } -void sf_set_critter_hit_chance_mod(OpcodeContext& ctx) { +void op_set_critter_hit_chance_mod(OpcodeContext& ctx) { fo::GameObject* obj = ctx.arg(0).object(); if (obj->Type() == fo::OBJ_TYPE_CRITTER) { SetHitChanceMax(obj, ctx.arg(1).rawValue(), ctx.arg(2).rawValue()); @@ -304,7 +304,7 @@ void __declspec(naked) op_set_base_hit_chance_mod() { } } -void sf_set_critter_pickpocket_mod(OpcodeContext& ctx) { +void op_set_critter_pickpocket_mod(OpcodeContext& ctx) { fo::GameObject* obj = ctx.arg(0).object(); if (obj->Type() == fo::OBJ_TYPE_CRITTER) { SetPickpocketMax(obj, ctx.arg(1).rawValue(), ctx.arg(2).rawValue()); @@ -331,7 +331,7 @@ void __declspec(naked) op_set_base_pickpocket_mod() { } } -void sf_set_critter_skill_mod(OpcodeContext& ctx) { +void op_set_critter_skill_mod(OpcodeContext& ctx) { fo::GameObject* obj = ctx.arg(0).object(); if (obj->Type() == fo::OBJ_TYPE_CRITTER) { SetSkillMax(obj, ctx.arg(1).rawValue()); @@ -492,7 +492,7 @@ static void __declspec(naked) statPCAddExperienceCheckPMs_hack() { } } -void sf_set_xp_mod(OpcodeContext& ctx) { +void op_set_xp_mod(OpcodeContext& ctx) { static bool xpModPatch = false; long percent = ctx.arg(0).rawValue() & 0xFFFF; Stats::experienceMod = percent / 100.0f; diff --git a/sfall/Modules/Scripting/Handlers/Stats.h b/sfall/Modules/Scripting/Handlers/Stats.h index 55c87bc93..207d87e47 100644 --- a/sfall/Modules/Scripting/Handlers/Stats.h +++ b/sfall/Modules/Scripting/Handlers/Stats.h @@ -24,25 +24,25 @@ namespace script { // stat_funcs -void sf_set_pc_base_stat(OpcodeContext&); +void op_set_pc_base_stat(OpcodeContext&); -void sf_set_pc_extra_stat(OpcodeContext&); +void op_set_pc_extra_stat(OpcodeContext&); -void sf_get_pc_base_stat(OpcodeContext&); +void op_get_pc_base_stat(OpcodeContext&); -void sf_get_pc_extra_stat(OpcodeContext&); +void op_get_pc_extra_stat(OpcodeContext&); -void sf_set_critter_base_stat(OpcodeContext&); +void op_set_critter_base_stat(OpcodeContext&); -void sf_set_critter_extra_stat(OpcodeContext&); +void op_set_critter_extra_stat(OpcodeContext&); -void sf_get_critter_base_stat(OpcodeContext&); +void op_get_critter_base_stat(OpcodeContext&); -void sf_get_critter_extra_stat(OpcodeContext&); +void op_get_critter_extra_stat(OpcodeContext&); -void sf_set_critter_skill_points(OpcodeContext&); +void op_set_critter_skill_points(OpcodeContext&); -void sf_get_critter_skill_points(OpcodeContext&); +void op_get_critter_skill_points(OpcodeContext&); void __declspec() op_set_available_skill_points(); @@ -52,21 +52,21 @@ void __declspec() op_mod_skill_points_per_level(); void __declspec() op_get_critter_current_ap(); -void sf_set_critter_current_ap(OpcodeContext&); +void op_set_critter_current_ap(OpcodeContext&); void __declspec() op_set_pickpocket_max(); void __declspec() op_set_hit_chance_max(); -void sf_set_critter_hit_chance_mod(OpcodeContext&); +void op_set_critter_hit_chance_mod(OpcodeContext&); void __declspec() op_set_base_hit_chance_mod(); -void sf_set_critter_pickpocket_mod(OpcodeContext&); +void op_set_critter_pickpocket_mod(OpcodeContext&); void __declspec() op_set_base_pickpocket_mod(); -void sf_set_critter_skill_mod(OpcodeContext&); +void op_set_critter_skill_mod(OpcodeContext&); void __declspec() op_set_base_skill_mod(); @@ -84,7 +84,7 @@ void __declspec() op_set_npc_stat_max(); void __declspec() op_set_npc_stat_min(); -void sf_set_xp_mod(OpcodeContext&); +void op_set_xp_mod(OpcodeContext&); } } diff --git a/sfall/Modules/Scripting/Handlers/Utils.cpp b/sfall/Modules/Scripting/Handlers/Utils.cpp index 9ec70fc1e..384c12162 100644 --- a/sfall/Modules/Scripting/Handlers/Utils.cpp +++ b/sfall/Modules/Scripting/Handlers/Utils.cpp @@ -95,27 +95,27 @@ static bool FalloutStringCompare(const char* str1, const char* str2, long codePa } } -void sf_strlen(OpcodeContext& ctx) { +void op_strlen(OpcodeContext& ctx) { ctx.setReturn( static_cast(strlen(ctx.arg(0).strValue())) ); } -void sf_atoi(OpcodeContext& ctx) { +void op_atoi(OpcodeContext& ctx) { auto str = ctx.arg(0).strValue(); ctx.setReturn( static_cast(strtol(str, (char**)nullptr, 0)) // auto-determine radix ); } -void sf_atof(OpcodeContext& ctx) { +void op_atof(OpcodeContext& ctx) { auto str = ctx.arg(0).strValue(); ctx.setReturn( static_cast(atof(str)) ); } -void sf_ord(OpcodeContext& ctx) { +void op_ord(OpcodeContext& ctx) { unsigned char firstChar = ctx.arg(0).strValue()[0]; ctx.setReturn(static_cast(firstChar)); } @@ -152,7 +152,7 @@ static int __stdcall StringSplit(const char* str, const char* split) { return id; } -void sf_string_split(OpcodeContext& ctx) { +void op_string_split(OpcodeContext& ctx) { ctx.setReturn(StringSplit(ctx.arg(0).strValue(), ctx.arg(1).strValue())); } @@ -182,13 +182,13 @@ static char* SubString(const char* str, int startPos, int length) { return ScriptExtender::gTextBuffer; } -void sf_substr(OpcodeContext& ctx) { +void op_substr(OpcodeContext& ctx) { const char* str = ctx.arg(0).strValue(); if (*str != '\0') str = SubString(str, ctx.arg(1).rawValue(), ctx.arg(2).rawValue()); ctx.setReturn(str); } -void sf_string_compare(OpcodeContext& ctx) { +void mf_string_compare(OpcodeContext& ctx) { if (ctx.numArgs() < 3) { ctx.setReturn( (_stricmp(ctx.arg(0).strValue(), ctx.arg(1).strValue()) ? 0 : 1) @@ -275,13 +275,13 @@ static char* sprintf_lite(const char* format, ScriptValue value) { return ScriptExtender::gTextBuffer; } -void sf_sprintf(OpcodeContext& ctx) { +void op_sprintf(OpcodeContext& ctx) { ctx.setReturn( sprintf_lite(ctx.arg(0).strValue(), ctx.arg(1)) ); } -void sf_string_format(OpcodeContext& ctx) { +void mf_string_format(OpcodeContext& ctx) { const char* format = ctx.arg(0).strValue(); int fmtLen = strlen(format); @@ -343,7 +343,7 @@ void sf_string_format(OpcodeContext& ctx) { } } -void sf_message_str_game(OpcodeContext& ctx) { +void op_message_str_game(OpcodeContext& ctx) { const char* msg = nullptr; int fileId = ctx.arg(0).rawValue(); @@ -364,7 +364,7 @@ void sf_message_str_game(OpcodeContext& ctx) { ctx.setReturn(msg); } -void sf_add_extra_msg_file(OpcodeContext& ctx) { +void mf_add_extra_msg_file(OpcodeContext& ctx) { long result = Message::AddExtraMsgFile(ctx.arg(0).strValue(), (ctx.numArgs() == 2) ? ctx.arg(1).rawValue() : 0); switch (result) { case -1 : @@ -379,17 +379,17 @@ void sf_add_extra_msg_file(OpcodeContext& ctx) { ctx.setReturn(result); } -void sf_get_string_pointer(OpcodeContext& ctx) { +void mf_get_string_pointer(OpcodeContext& ctx) { ctx.setReturn(reinterpret_cast(ctx.arg(0).strValue()), DataType::INT); } -void sf_get_text_width(OpcodeContext& ctx) { +void mf_get_text_width(OpcodeContext& ctx) { ctx.setReturn(fo::GetTextWidth(ctx.arg(0).strValue())); } static std::string strToCase; -void sf_string_to_case(OpcodeContext& ctx) { +void mf_string_to_case(OpcodeContext& ctx) { strToCase = ctx.arg(0).strValue(); std::transform(strToCase.begin(), strToCase.end(), strToCase.begin(), ctx.arg(1).rawValue() ? ::toupper : ::tolower); diff --git a/sfall/Modules/Scripting/Handlers/Utils.h b/sfall/Modules/Scripting/Handlers/Utils.h index 76b2853e0..7230af068 100644 --- a/sfall/Modules/Scripting/Handlers/Utils.h +++ b/sfall/Modules/Scripting/Handlers/Utils.h @@ -25,33 +25,33 @@ namespace script class OpcodeContext; -void sf_string_split(OpcodeContext&); +void op_string_split(OpcodeContext&); -void sf_atoi(OpcodeContext&); +void op_atoi(OpcodeContext&); -void sf_atof(OpcodeContext&); +void op_atof(OpcodeContext&); -void sf_substr(OpcodeContext&); +void op_substr(OpcodeContext&); -void sf_strlen(OpcodeContext&); +void op_strlen(OpcodeContext&); -void sf_string_compare(OpcodeContext&); +void mf_string_compare(OpcodeContext&); -void sf_sprintf(OpcodeContext&); +void op_sprintf(OpcodeContext&); -void sf_string_format(OpcodeContext&); +void mf_string_format(OpcodeContext&); -void sf_ord(OpcodeContext&); +void op_ord(OpcodeContext&); -void sf_message_str_game(OpcodeContext&); +void op_message_str_game(OpcodeContext&); -void sf_add_extra_msg_file(OpcodeContext&); +void mf_add_extra_msg_file(OpcodeContext&); -void sf_get_string_pointer(OpcodeContext&); +void mf_get_string_pointer(OpcodeContext&); -void sf_get_text_width(OpcodeContext&); +void mf_get_text_width(OpcodeContext&); -void sf_string_to_case(OpcodeContext&); +void mf_string_to_case(OpcodeContext&); } } diff --git a/sfall/Modules/Scripting/Handlers/Worldmap.cpp b/sfall/Modules/Scripting/Handlers/Worldmap.cpp index 64c837cee..6961f14c6 100644 --- a/sfall/Modules/Scripting/Handlers/Worldmap.cpp +++ b/sfall/Modules/Scripting/Handlers/Worldmap.cpp @@ -86,7 +86,7 @@ static void __declspec(naked) wmRndEncounterOccurred_hack() { } } -void sf_force_encounter(OpcodeContext& cxt) { +void op_force_encounter(OpcodeContext& cxt) { if (ForceEncounterFlags & (1 << 31)) return; // wait prev. encounter DWORD mapID = cxt.arg(0).rawValue(); @@ -166,15 +166,15 @@ void __declspec(naked) op_set_world_map_pos() { } } -void sf_set_map_time_multi(OpcodeContext& ctx) { +void op_set_map_time_multi(OpcodeContext& ctx) { Worldmap::SetMapMulti(ctx.arg(0).asFloat()); } -void sf_set_car_intface_art(OpcodeContext& ctx) { +void mf_set_car_intface_art(OpcodeContext& ctx) { Worldmap::SetCarInterfaceArt(ctx.arg(0).rawValue()); } -void sf_set_map_enter_position(OpcodeContext& ctx) { +void mf_set_map_enter_position(OpcodeContext& ctx) { int tile = ctx.arg(0).rawValue(); int elev = ctx.arg(1).rawValue(); int rot = ctx.arg(2).rawValue(); @@ -190,7 +190,7 @@ void sf_set_map_enter_position(OpcodeContext& ctx) { } } -void sf_get_map_enter_position(OpcodeContext& ctx) { +void mf_get_map_enter_position(OpcodeContext& ctx) { DWORD id = TempArray(3, 0); arrays[id].val[0].set((long)fo::var::tile); arrays[id].val[1].set((long)fo::var::elevation); @@ -198,15 +198,15 @@ void sf_get_map_enter_position(OpcodeContext& ctx) { ctx.setReturn(id); } -void sf_set_rest_heal_time(OpcodeContext& ctx) { +void mf_set_rest_heal_time(OpcodeContext& ctx) { Worldmap::SetRestHealTime(ctx.arg(0).rawValue()); } -void sf_set_rest_mode(OpcodeContext& ctx) { +void mf_set_rest_mode(OpcodeContext& ctx) { Worldmap::SetRestMode(ctx.arg(0).rawValue()); } -void sf_set_rest_on_map(OpcodeContext& ctx) { +void mf_set_rest_on_map(OpcodeContext& ctx) { long mapId = ctx.arg(0).rawValue(); if (mapId < 0) { ctx.printOpcodeError("%s() - invalid map number argument.", ctx.getMetaruleName()); @@ -222,7 +222,7 @@ void sf_set_rest_on_map(OpcodeContext& ctx) { } } -void sf_get_rest_on_map(OpcodeContext& ctx) { +void mf_get_rest_on_map(OpcodeContext& ctx) { long result = -1; long elev = ctx.arg(1).rawValue(); if (elev < 0 || elev > 2) { @@ -233,15 +233,15 @@ void sf_get_rest_on_map(OpcodeContext& ctx) { ctx.setReturn(result); } -void sf_tile_by_position(OpcodeContext& ctx) { +void mf_tile_by_position(OpcodeContext& ctx) { ctx.setReturn(fo::func::tile_num(ctx.arg(0).rawValue(), ctx.arg(1).rawValue())); } -void sf_set_terrain_name(OpcodeContext& ctx) { +void mf_set_terrain_name(OpcodeContext& ctx) { Worldmap::SetTerrainTypeName(ctx.arg(0).rawValue(), ctx.arg(1).rawValue(), ctx.arg(2).strValue()); } -void sf_set_town_title(OpcodeContext& ctx) { +void mf_set_town_title(OpcodeContext& ctx) { Worldmap::SetCustomAreaTitle(ctx.arg(0).rawValue(), ctx.arg(1).strValue()); } diff --git a/sfall/Modules/Scripting/Handlers/Worldmap.h b/sfall/Modules/Scripting/Handlers/Worldmap.h index 10795e9db..362e6e522 100644 --- a/sfall/Modules/Scripting/Handlers/Worldmap.h +++ b/sfall/Modules/Scripting/Handlers/Worldmap.h @@ -25,7 +25,7 @@ namespace script class OpcodeContext; -void sf_force_encounter(OpcodeContext&); +void op_force_encounter(OpcodeContext&); DWORD ForceEncounterRestore(); @@ -40,27 +40,27 @@ void __declspec() op_get_world_map_y_pos(); void __declspec() op_set_world_map_pos(); -void sf_set_map_time_multi(OpcodeContext&); +void op_set_map_time_multi(OpcodeContext&); -void sf_set_car_intface_art(OpcodeContext&); +void mf_set_car_intface_art(OpcodeContext&); -void sf_set_map_enter_position(OpcodeContext&); +void mf_set_map_enter_position(OpcodeContext&); -void sf_get_map_enter_position(OpcodeContext&); +void mf_get_map_enter_position(OpcodeContext&); -void sf_set_rest_heal_time(OpcodeContext&); +void mf_set_rest_heal_time(OpcodeContext&); -void sf_set_rest_mode(OpcodeContext&); +void mf_set_rest_mode(OpcodeContext&); -void sf_set_rest_on_map(OpcodeContext&); +void mf_set_rest_on_map(OpcodeContext&); -void sf_get_rest_on_map(OpcodeContext&); +void mf_get_rest_on_map(OpcodeContext&); -void sf_tile_by_position(OpcodeContext&); +void mf_tile_by_position(OpcodeContext&); -void sf_set_terrain_name(OpcodeContext&); +void mf_set_terrain_name(OpcodeContext&); -void sf_set_town_title(OpcodeContext&); +void mf_set_town_title(OpcodeContext&); } } diff --git a/sfall/Modules/Scripting/Opcodes.cpp b/sfall/Modules/Scripting/Opcodes.cpp index a83d1f848..230e2855b 100644 --- a/sfall/Modules/Scripting/Opcodes.cpp +++ b/sfall/Modules/Scripting/Opcodes.cpp @@ -63,163 +63,163 @@ static void* opcodes[opcodeCount]; // { argument 1 type, argument 2 type, ...} // } static SfallOpcodeInfo opcodeInfoArray[] = { - {0x15a, "set_pc_base_stat", sf_set_pc_base_stat, 2, false, 0, {ARG_INT, ARG_INT}}, - {0x15b, "set_pc_extra_stat", sf_set_pc_extra_stat, 2, false, 0, {ARG_INT, ARG_INT}}, - {0x15c, "get_pc_base_stat", sf_get_pc_base_stat, 1, true, 0, {ARG_INT}}, - {0x15d, "get_pc_extra_stat", sf_get_pc_extra_stat, 1, true, 0, {ARG_INT}}, - {0x15e, "set_critter_base_stat", sf_set_critter_base_stat, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, - {0x15f, "set_critter_extra_stat", sf_set_critter_extra_stat, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, - {0x160, "get_critter_base_stat", sf_get_critter_base_stat, 2, true, 0, {ARG_OBJECT, ARG_INT}}, - {0x161, "get_critter_extra_stat", sf_get_critter_extra_stat, 2, true, 0, {ARG_OBJECT, ARG_INT}}, - {0x163, "get_year", sf_get_year, 0, true}, - {0x16c, "key_pressed", sf_key_pressed, 1, true, 0, {ARG_INT}}, - {0x171, "force_encounter", sf_force_encounter, 1, false, 0, {ARG_INT}}, - {0x175, "set_dm_model", sf_set_dm_model, 1, false, 0, {ARG_STRING}}, - {0x176, "set_df_model", sf_set_df_model, 1, false, 0, {ARG_STRING}}, - {0x177, "set_movie_path", sf_set_movie_path, 2, false, 0, {ARG_STRING, ARG_INT}}, - - {0x189, "set_perk_name", sf_set_perk_name, 2, false, 0, {ARG_INT, ARG_STRING}}, - {0x18a, "set_perk_desc", sf_set_perk_desc, 2, false, 0, {ARG_INT, ARG_STRING}}, - - {0x190, "get_perk_available", sf_get_perk_available, 1, true, 0, {ARG_INT}}, - {0x192, "set_critter_current_ap", sf_set_critter_current_ap, 2, false, 0, {ARG_OBJECT, ARG_INT}}, - {0x195, "set_weapon_knockback", sf_set_object_knockback, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_NUMBER}}, - {0x196, "set_target_knockback", sf_set_object_knockback, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_NUMBER}}, - {0x197, "set_attacker_knockback", sf_set_object_knockback, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_NUMBER}}, - {0x198, "remove_weapon_knockback", sf_remove_object_knockback, 1, false, 0, {ARG_OBJECT}}, - {0x199, "remove_target_knockback", sf_remove_object_knockback, 1, false, 0, {ARG_OBJECT}}, - {0x19a, "remove_attacker_knockback", sf_remove_object_knockback, 1, false, 0, {ARG_OBJECT}}, - {0x19d, "set_sfall_global", sf_set_sfall_global, 2, false, 0, {ARG_INTSTR, ARG_NUMBER}}, - {0x19e, "get_sfall_global_int", sf_get_sfall_global_int, 1, true, 0, {ARG_INTSTR}}, - {0x19f, "get_sfall_global_float", sf_get_sfall_global_float, 1, true, 0, {ARG_INTSTR}}, - {0x1a5, "inc_npc_level", sf_inc_npc_level, 1, false, 0, {ARG_INTSTR}}, - {0x1aa, "set_xp_mod", sf_set_xp_mod, 1, false, 0, {ARG_INT}}, - {0x1ac, "get_ini_setting", sf_get_ini_setting, 1, true, -1, {ARG_STRING}}, - - {0x1bb, "set_fake_perk", sf_set_fake_perk, 4, false, 0, {ARG_STRING, ARG_INT, ARG_INT, ARG_STRING}}, - {0x1bc, "set_fake_trait", sf_set_fake_trait, 4, false, 0, {ARG_STRING, ARG_INT, ARG_INT, ARG_STRING}}, - {0x1bd, "set_selectable_perk", sf_set_selectable_perk, 4, false, 0, {ARG_STRING, ARG_INT, ARG_INT, ARG_STRING}}, - {0x1c1, "has_fake_perk", sf_has_fake_perk, 1, true, 0, {ARG_INTSTR}}, - {0x1c2, "has_fake_trait", sf_has_fake_trait, 1, true, 0, {ARG_STRING}}, - {0x1c5, "set_critter_hit_chance_mod", sf_set_critter_hit_chance_mod,3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, - {0x1c7, "set_critter_skill_mod", sf_set_critter_skill_mod, 2, false, 0, {ARG_OBJECT, ARG_INT}}, - {0x1c9, "set_critter_pickpocket_mod", sf_set_critter_pickpocket_mod,3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, - - {0x1dc, "show_iface_tag", sf_show_iface_tag, 1, false, 0, {ARG_INT}}, - {0x1dd, "hide_iface_tag", sf_hide_iface_tag, 1, false, 0, {ARG_INT}}, - {0x1de, "is_iface_tag_active", sf_is_iface_tag_active, 1, true, 0, {ARG_INT}}, - {0x1e1, "set_critical_table", sf_set_critical_table, 5, false, 0, {ARG_INT, ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, - {0x1e2, "get_critical_table", sf_get_critical_table, 4, true, 0, {ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, - {0x1e3, "reset_critical_table", sf_reset_critical_table, 4, false, 0, {ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, - {0x1eb, "get_ini_string", sf_get_ini_string, 1, true, -1, {ARG_STRING}}, - {0x1ec, "sqrt", sf_sqrt, 1, true, 0, {ARG_NUMBER}}, - {0x1ed, "abs", sf_abs, 1, true, 0, {ARG_NUMBER}}, - {0x1ee, "sin", sf_sin, 1, true, 0, {ARG_NUMBER}}, - {0x1ef, "cos", sf_cos, 1, true, 0, {ARG_NUMBER}}, - {0x1f0, "tan", sf_tan, 1, true, 0, {ARG_NUMBER}}, - {0x1f1, "arctan", sf_arctan, 2, true, 0, {ARG_NUMBER, ARG_NUMBER}}, - {0x1f2, "set_palette", sf_set_palette, 1, false, 0, {ARG_STRING}}, - {0x1f3, "remove_script", sf_remove_script, 1, false, 0, {ARG_OBJECT}}, - {0x1f4, "set_script", sf_set_script, 2, false, 0, {ARG_OBJECT, ARG_INT}}, - {0x1f5, "get_script", sf_get_script, 1, true, -1, {ARG_OBJECT}}, - - {0x1f7, "fs_create", sf_fs_create, 2, true, -1, {ARG_STRING, ARG_INT}}, - {0x1f8, "fs_copy", sf_fs_copy, 2, true, -1, {ARG_STRING, ARG_STRING}}, - {0x1f9, "fs_find", sf_fs_find, 1, true, -1, {ARG_STRING}}, - {0x1fa, "fs_write_byte", sf_fs_write_byte, 2, false, 0, {ARG_INT, ARG_INT}}, - {0x1fb, "fs_write_short", sf_fs_write_short, 2, false, 0, {ARG_INT, ARG_INT}}, - {0x1fc, "fs_write_int", sf_fs_write_int, 2, false, 0, {ARG_INT, ARG_INT}}, - {0x1fd, "fs_write_int", sf_fs_write_int, 2, false, 0, {ARG_INT, ARG_INT}}, - {0x1fe, "fs_write_string", sf_fs_write_string, 2, false, 0, {ARG_INT, ARG_STRING}}, - {0x1ff, "fs_delete", sf_fs_delete, 1, false, 0, {ARG_INT}}, - {0x200, "fs_size", sf_fs_size, 1, true, 0, {ARG_INT}}, - {0x201, "fs_pos", sf_fs_pos, 1, true, -1, {ARG_INT}}, - {0x202, "fs_seek", sf_fs_seek, 2, false, 0, {ARG_INT, ARG_INT}}, - {0x203, "fs_resize", sf_fs_resize, 2, false, 0, {ARG_INT, ARG_INT}}, - {0x204, "get_proto_data", sf_get_proto_data, 2, true, -1, {ARG_INT, ARG_INT}}, - {0x205, "set_proto_data", sf_set_proto_data, 3, false, 0, {ARG_INT, ARG_INT, ARG_INT}}, - {0x207, "register_hook", sf_register_hook, 1, false, 0, {ARG_INT}}, - {0x208, "fs_write_bstring", sf_fs_write_bstring, 2, false, 0, {ARG_INT, ARG_STRING}}, - {0x209, "fs_read_byte", sf_fs_read_byte, 1, true, 0, {ARG_INT}}, - {0x20a, "fs_read_short", sf_fs_read_short, 1, true, 0, {ARG_INT}}, - {0x20b, "fs_read_int", sf_fs_read_int, 1, true, 0, {ARG_INT}}, - {0x20c, "fs_read_float", sf_fs_read_float, 1, true, 0, {ARG_INT}}, - {0x20d, "list_begin", sf_list_begin, 1, true, 0, {ARG_INT}}, - {0x20e, "list_next", sf_list_next, 1, true, 0, {ARG_INT}}, - {0x20f, "list_end", sf_list_end, 1, false, 0, {ARG_INT}}, - {0x210, "sfall_ver_major", sf_sfall_ver_major, 0, true}, - {0x211, "sfall_ver_minor", sf_sfall_ver_minor, 0, true}, - {0x212, "sfall_ver_build", sf_sfall_ver_build, 0, true}, - {0x216, "set_critter_burst_disable", sf_set_critter_burst_disable, 2, false, 0, {ARG_OBJECT, ARG_INT}}, - {0x217, "get_weapon_ammo_pid", sf_get_weapon_ammo_pid, 1, true, -1, {ARG_OBJECT}}, - {0x218, "set_weapon_ammo_pid", sf_set_weapon_ammo_pid, 2, false, 0, {ARG_OBJECT, ARG_INT}}, - {0x219, "get_weapon_ammo_count", sf_get_weapon_ammo_count, 1, true, 0, {ARG_OBJECT}}, - {0x21a, "set_weapon_ammo_count", sf_set_weapon_ammo_count, 2, false, 0, {ARG_OBJECT, ARG_INT}}, - {0x21e, "get_mouse_buttons", sf_get_mouse_buttons, 0, true}, - - {0x224, "create_message_window", sf_create_message_window, 1, false, 0, {ARG_STRING}}, - {0x228, "get_attack_type", sf_get_attack_type, 0, true}, - {0x229, "force_encounter_with_flags", sf_force_encounter, 2, false, 0, {ARG_INT, ARG_INT}}, - {0x22a, "set_map_time_multi", sf_set_map_time_multi, 1, false, 0, {ARG_NUMBER}}, - {0x22b, "play_sfall_sound", sf_play_sfall_sound, 2, true, 0, {ARG_STRING, ARG_INT}}, - {0x22d, "create_array", sf_create_array, 2, true, -1, {ARG_INT, ARG_INT}}, - {0x22e, "set_array", sf_set_array, 3, false, 0, {ARG_OBJECT, ARG_ANY, ARG_ANY}}, - {0x22f, "get_array", sf_get_array, 2, true}, // can also be used on strings - {0x230, "free_array", sf_free_array, 1, false, 0, {ARG_OBJECT}}, - {0x231, "len_array", sf_len_array, 1, true, 0, {ARG_INT}}, - {0x232, "resize_array", sf_resize_array, 2, false, 0, {ARG_OBJECT, ARG_INT}}, - {0x233, "temp_array", sf_temp_array, 2, true, -1, {ARG_INT, ARG_INT}}, - {0x234, "fix_array", sf_fix_array, 1, false, 0, {ARG_OBJECT}}, - {0x235, "string_split", sf_string_split, 2, true, -1, {ARG_STRING, ARG_STRING}}, - {0x236, "list_as_array", sf_list_as_array, 1, true, -1, {ARG_INT}}, - {0x237, "atoi", sf_atoi, 1, true, 0, {ARG_STRING}}, - {0x238, "atof", sf_atof, 1, true, 0, {ARG_STRING}}, - {0x239, "scan_array", sf_scan_array, 2, true, -1, {ARG_OBJECT, ARG_ANY}}, - {0x23c, "get_sfall_args", sf_get_sfall_args, 0, true}, - {0x23d, "set_sfall_arg", sf_set_sfall_arg, 2, false, 0, {ARG_INT, ARG_INT}}, - {0x241, "get_npc_level", sf_get_npc_level, 1, true, -1, {ARG_INTSTR}}, - {0x242, "set_critter_skill_points", sf_set_critter_skill_points, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, - {0x243, "get_critter_skill_points", sf_get_critter_skill_points, 2, true, 0, {ARG_OBJECT, ARG_INT}}, - - {0x24e, "substr", sf_substr, 3, true, -1, {ARG_STRING, ARG_INT, ARG_INT}}, - {0x24f, "strlen", sf_strlen, 1, true, 0, {ARG_STRING}}, - {0x250, "sprintf", sf_sprintf, 2, true, 0, {ARG_STRING, ARG_ANY}}, - {0x251, "charcode", sf_ord, 1, true, 0, {ARG_STRING}}, + {0x15a, "set_pc_base_stat", op_set_pc_base_stat, 2, false, 0, {ARG_INT, ARG_INT}}, + {0x15b, "set_pc_extra_stat", op_set_pc_extra_stat, 2, false, 0, {ARG_INT, ARG_INT}}, + {0x15c, "get_pc_base_stat", op_get_pc_base_stat, 1, true, 0, {ARG_INT}}, + {0x15d, "get_pc_extra_stat", op_get_pc_extra_stat, 1, true, 0, {ARG_INT}}, + {0x15e, "set_critter_base_stat", op_set_critter_base_stat, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, + {0x15f, "set_critter_extra_stat", op_set_critter_extra_stat, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, + {0x160, "get_critter_base_stat", op_get_critter_base_stat, 2, true, 0, {ARG_OBJECT, ARG_INT}}, + {0x161, "get_critter_extra_stat", op_get_critter_extra_stat, 2, true, 0, {ARG_OBJECT, ARG_INT}}, + {0x163, "get_year", op_get_year, 0, true}, + {0x16c, "key_pressed", op_key_pressed, 1, true, 0, {ARG_INT}}, + {0x171, "force_encounter", op_force_encounter, 1, false, 0, {ARG_INT}}, + {0x175, "set_dm_model", op_set_dm_model, 1, false, 0, {ARG_STRING}}, + {0x176, "set_df_model", op_set_df_model, 1, false, 0, {ARG_STRING}}, + {0x177, "set_movie_path", op_set_movie_path, 2, false, 0, {ARG_STRING, ARG_INT}}, + + {0x189, "set_perk_name", op_set_perk_name, 2, false, 0, {ARG_INT, ARG_STRING}}, + {0x18a, "set_perk_desc", op_set_perk_desc, 2, false, 0, {ARG_INT, ARG_STRING}}, + + {0x190, "get_perk_available", op_get_perk_available, 1, true, 0, {ARG_INT}}, + {0x192, "set_critter_current_ap", op_set_critter_current_ap, 2, false, 0, {ARG_OBJECT, ARG_INT}}, + {0x195, "set_weapon_knockback", op_set_object_knockback, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_NUMBER}}, + {0x196, "set_target_knockback", op_set_object_knockback, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_NUMBER}}, + {0x197, "set_attacker_knockback", op_set_object_knockback, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_NUMBER}}, + {0x198, "remove_weapon_knockback", op_remove_object_knockback, 1, false, 0, {ARG_OBJECT}}, + {0x199, "remove_target_knockback", op_remove_object_knockback, 1, false, 0, {ARG_OBJECT}}, + {0x19a, "remove_attacker_knockback", op_remove_object_knockback, 1, false, 0, {ARG_OBJECT}}, + {0x19d, "set_sfall_global", op_set_sfall_global, 2, false, 0, {ARG_INTSTR, ARG_NUMBER}}, + {0x19e, "get_sfall_global_int", op_get_sfall_global_int, 1, true, 0, {ARG_INTSTR}}, + {0x19f, "get_sfall_global_float", op_get_sfall_global_float, 1, true, 0, {ARG_INTSTR}}, + {0x1a5, "inc_npc_level", op_inc_npc_level, 1, false, 0, {ARG_INTSTR}}, + {0x1aa, "set_xp_mod", op_set_xp_mod, 1, false, 0, {ARG_INT}}, + {0x1ac, "get_ini_setting", op_get_ini_setting, 1, true, -1, {ARG_STRING}}, + + {0x1bb, "set_fake_perk", op_set_fake_perk, 4, false, 0, {ARG_STRING, ARG_INT, ARG_INT, ARG_STRING}}, + {0x1bc, "set_fake_trait", op_set_fake_trait, 4, false, 0, {ARG_STRING, ARG_INT, ARG_INT, ARG_STRING}}, + {0x1bd, "set_selectable_perk", op_set_selectable_perk, 4, false, 0, {ARG_STRING, ARG_INT, ARG_INT, ARG_STRING}}, + {0x1c1, "has_fake_perk", op_has_fake_perk, 1, true, 0, {ARG_INTSTR}}, + {0x1c2, "has_fake_trait", op_has_fake_trait, 1, true, 0, {ARG_STRING}}, + {0x1c5, "set_critter_hit_chance_mod", op_set_critter_hit_chance_mod,3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, + {0x1c7, "set_critter_skill_mod", op_set_critter_skill_mod, 2, false, 0, {ARG_OBJECT, ARG_INT}}, + {0x1c9, "set_critter_pickpocket_mod", op_set_critter_pickpocket_mod,3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, + + {0x1dc, "show_iface_tag", op_show_iface_tag, 1, false, 0, {ARG_INT}}, + {0x1dd, "hide_iface_tag", op_hide_iface_tag, 1, false, 0, {ARG_INT}}, + {0x1de, "is_iface_tag_active", op_is_iface_tag_active, 1, true, 0, {ARG_INT}}, + {0x1e1, "set_critical_table", op_set_critical_table, 5, false, 0, {ARG_INT, ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, + {0x1e2, "get_critical_table", op_get_critical_table, 4, true, 0, {ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, + {0x1e3, "reset_critical_table", op_reset_critical_table, 4, false, 0, {ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, + {0x1eb, "get_ini_string", op_get_ini_string, 1, true, -1, {ARG_STRING}}, + {0x1ec, "sqrt", op_sqrt, 1, true, 0, {ARG_NUMBER}}, + {0x1ed, "abs", op_abs, 1, true, 0, {ARG_NUMBER}}, + {0x1ee, "sin", op_sin, 1, true, 0, {ARG_NUMBER}}, + {0x1ef, "cos", op_cos, 1, true, 0, {ARG_NUMBER}}, + {0x1f0, "tan", op_tan, 1, true, 0, {ARG_NUMBER}}, + {0x1f1, "arctan", op_arctan, 2, true, 0, {ARG_NUMBER, ARG_NUMBER}}, + {0x1f2, "set_palette", op_set_palette, 1, false, 0, {ARG_STRING}}, + {0x1f3, "remove_script", op_remove_script, 1, false, 0, {ARG_OBJECT}}, + {0x1f4, "set_script", op_set_script, 2, false, 0, {ARG_OBJECT, ARG_INT}}, + {0x1f5, "get_script", op_get_script, 1, true, -1, {ARG_OBJECT}}, + + {0x1f7, "fs_create", op_fs_create, 2, true, -1, {ARG_STRING, ARG_INT}}, + {0x1f8, "fs_copy", op_fs_copy, 2, true, -1, {ARG_STRING, ARG_STRING}}, + {0x1f9, "fs_find", op_fs_find, 1, true, -1, {ARG_STRING}}, + {0x1fa, "fs_write_byte", op_fs_write_byte, 2, false, 0, {ARG_INT, ARG_INT}}, + {0x1fb, "fs_write_short", op_fs_write_short, 2, false, 0, {ARG_INT, ARG_INT}}, + {0x1fc, "fs_write_int", op_fs_write_int, 2, false, 0, {ARG_INT, ARG_INT}}, + {0x1fd, "fs_write_int", op_fs_write_int, 2, false, 0, {ARG_INT, ARG_INT}}, + {0x1fe, "fs_write_string", op_fs_write_string, 2, false, 0, {ARG_INT, ARG_STRING}}, + {0x1ff, "fs_delete", op_fs_delete, 1, false, 0, {ARG_INT}}, + {0x200, "fs_size", op_fs_size, 1, true, 0, {ARG_INT}}, + {0x201, "fs_pos", op_fs_pos, 1, true, -1, {ARG_INT}}, + {0x202, "fs_seek", op_fs_seek, 2, false, 0, {ARG_INT, ARG_INT}}, + {0x203, "fs_resize", op_fs_resize, 2, false, 0, {ARG_INT, ARG_INT}}, + {0x204, "get_proto_data", op_get_proto_data, 2, true, -1, {ARG_INT, ARG_INT}}, + {0x205, "set_proto_data", op_set_proto_data, 3, false, 0, {ARG_INT, ARG_INT, ARG_INT}}, + {0x207, "register_hook", op_register_hook, 1, false, 0, {ARG_INT}}, + {0x208, "fs_write_bstring", op_fs_write_bstring, 2, false, 0, {ARG_INT, ARG_STRING}}, + {0x209, "fs_read_byte", op_fs_read_byte, 1, true, 0, {ARG_INT}}, + {0x20a, "fs_read_short", op_fs_read_short, 1, true, 0, {ARG_INT}}, + {0x20b, "fs_read_int", op_fs_read_int, 1, true, 0, {ARG_INT}}, + {0x20c, "fs_read_float", op_fs_read_float, 1, true, 0, {ARG_INT}}, + {0x20d, "list_begin", op_list_begin, 1, true, 0, {ARG_INT}}, + {0x20e, "list_next", op_list_next, 1, true, 0, {ARG_INT}}, + {0x20f, "list_end", op_list_end, 1, false, 0, {ARG_INT}}, + {0x210, "sfall_ver_major", op_sfall_ver_major, 0, true}, + {0x211, "sfall_ver_minor", op_sfall_ver_minor, 0, true}, + {0x212, "sfall_ver_build", op_sfall_ver_build, 0, true}, + {0x216, "set_critter_burst_disable", op_set_critter_burst_disable, 2, false, 0, {ARG_OBJECT, ARG_INT}}, + {0x217, "get_weapon_ammo_pid", op_get_weapon_ammo_pid, 1, true, -1, {ARG_OBJECT}}, + {0x218, "set_weapon_ammo_pid", op_set_weapon_ammo_pid, 2, false, 0, {ARG_OBJECT, ARG_INT}}, + {0x219, "get_weapon_ammo_count", op_get_weapon_ammo_count, 1, true, 0, {ARG_OBJECT}}, + {0x21a, "set_weapon_ammo_count", op_set_weapon_ammo_count, 2, false, 0, {ARG_OBJECT, ARG_INT}}, + {0x21e, "get_mouse_buttons", op_get_mouse_buttons, 0, true}, + + {0x224, "create_message_window", op_create_message_window, 1, false, 0, {ARG_STRING}}, + {0x228, "get_attack_type", op_get_attack_type, 0, true}, + {0x229, "force_encounter_with_flags", op_force_encounter, 2, false, 0, {ARG_INT, ARG_INT}}, + {0x22a, "set_map_time_multi", op_set_map_time_multi, 1, false, 0, {ARG_NUMBER}}, + {0x22b, "play_sfall_sound", op_play_sfall_sound, 2, true, 0, {ARG_STRING, ARG_INT}}, + {0x22d, "create_array", op_create_array, 2, true, -1, {ARG_INT, ARG_INT}}, + {0x22e, "set_array", op_set_array, 3, false, 0, {ARG_OBJECT, ARG_ANY, ARG_ANY}}, + {0x22f, "get_array", op_get_array, 2, true}, // can also be used on strings + {0x230, "free_array", op_free_array, 1, false, 0, {ARG_OBJECT}}, + {0x231, "len_array", op_len_array, 1, true, 0, {ARG_INT}}, + {0x232, "resize_array", op_resize_array, 2, false, 0, {ARG_OBJECT, ARG_INT}}, + {0x233, "temp_array", op_temp_array, 2, true, -1, {ARG_INT, ARG_INT}}, + {0x234, "fix_array", op_fix_array, 1, false, 0, {ARG_OBJECT}}, + {0x235, "string_split", op_string_split, 2, true, -1, {ARG_STRING, ARG_STRING}}, + {0x236, "list_as_array", op_list_as_array, 1, true, -1, {ARG_INT}}, + {0x237, "atoi", op_atoi, 1, true, 0, {ARG_STRING}}, + {0x238, "atof", op_atof, 1, true, 0, {ARG_STRING}}, + {0x239, "scan_array", op_scan_array, 2, true, -1, {ARG_OBJECT, ARG_ANY}}, + {0x23c, "get_sfall_args", op_get_sfall_args, 0, true}, + {0x23d, "set_sfall_arg", op_set_sfall_arg, 2, false, 0, {ARG_INT, ARG_INT}}, + {0x241, "get_npc_level", op_get_npc_level, 1, true, -1, {ARG_INTSTR}}, + {0x242, "set_critter_skill_points", op_set_critter_skill_points, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, + {0x243, "get_critter_skill_points", op_get_critter_skill_points, 2, true, 0, {ARG_OBJECT, ARG_INT}}, + + {0x24e, "substr", op_substr, 3, true, -1, {ARG_STRING, ARG_INT, ARG_INT}}, + {0x24f, "strlen", op_strlen, 1, true, 0, {ARG_STRING}}, + {0x250, "sprintf", op_sprintf, 2, true, 0, {ARG_STRING, ARG_ANY}}, + {0x251, "charcode", op_ord, 1, true, 0, {ARG_STRING}}, // 0x252 // RESERVED - {0x253, "typeof", sf_typeof, 1, true}, - {0x254, "save_array", sf_save_array, 2, false, 0, {ARG_ANY, ARG_OBJECT}}, - {0x255, "load_array", sf_load_array, 1, true, -1, {ARG_INTSTR}}, - {0x256, "array_key", sf_get_array_key, 2, true, 0, {ARG_INT, ARG_INT}}, - {0x257, "arrayexpr", sf_stack_array, 2, true}, + {0x253, "typeof", op_typeof, 1, true}, + {0x254, "save_array", op_save_array, 2, false, 0, {ARG_ANY, ARG_OBJECT}}, + {0x255, "load_array", op_load_array, 1, true, -1, {ARG_INTSTR}}, + {0x256, "array_key", op_get_array_key, 2, true, 0, {ARG_INT, ARG_INT}}, + {0x257, "arrayexpr", op_stack_array, 2, true}, // 0x258 // RESERVED for arrays // 0x259 // RESERVED for arrays - {0x25a, "reg_anim_destroy", sf_reg_anim_destroy, 1, false, 0, {ARG_OBJECT}}, - {0x25b, "reg_anim_animate_and_hide", sf_reg_anim_animate_and_hide, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, - {0x25c, "reg_anim_combat_check", sf_reg_anim_combat_check, 1, false, 0, {ARG_INT}}, - {0x25d, "reg_anim_light", sf_reg_anim_light, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, - {0x25e, "reg_anim_change_fid", sf_reg_anim_change_fid, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, - {0x25f, "reg_anim_take_out", sf_reg_anim_take_out, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, - {0x260, "reg_anim_turn_towards", sf_reg_anim_turn_towards, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, - {0x261, "metarule2_explosions", sf_explosions_metarule, 3, true, -1, {ARG_INT, ARG_INT, ARG_INT}}, - {0x262, "register_hook_proc", sf_register_hook, 2, false, 0, {ARG_INT, ARG_INT}}, - {0x263, "power", sf_power, 2, true, 0, {ARG_NUMBER, ARG_NUMBER}}, // '^' operator - {0x264, "log", sf_log, 1, true, 0, {ARG_NUMBER}}, - {0x265, "exponent", sf_exponent, 1, true, 0, {ARG_NUMBER}}, - {0x266, "ceil", sf_ceil, 1, true, 0, {ARG_NUMBER}}, - {0x267, "round", sf_round, 1, true, 0, {ARG_NUMBER}}, + {0x25a, "reg_anim_destroy", op_reg_anim_destroy, 1, false, 0, {ARG_OBJECT}}, + {0x25b, "reg_anim_animate_and_hide", op_reg_anim_animate_and_hide, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, + {0x25c, "reg_anim_combat_check", op_reg_anim_combat_check, 1, false, 0, {ARG_INT}}, + {0x25d, "reg_anim_light", op_reg_anim_light, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, + {0x25e, "reg_anim_change_fid", op_reg_anim_change_fid, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, + {0x25f, "reg_anim_take_out", op_reg_anim_take_out, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, + {0x260, "reg_anim_turn_towards", op_reg_anim_turn_towards, 3, false, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, + {0x261, "metarule2_explosions", op_explosions_metarule, 3, true, -1, {ARG_INT, ARG_INT, ARG_INT}}, + {0x262, "register_hook_proc", op_register_hook, 2, false, 0, {ARG_INT, ARG_INT}}, + {0x263, "power", op_power, 2, true, 0, {ARG_NUMBER, ARG_NUMBER}}, // '^' operator + {0x264, "log", op_log, 1, true, 0, {ARG_NUMBER}}, + {0x265, "exponent", op_exponent, 1, true, 0, {ARG_NUMBER}}, + {0x266, "ceil", op_ceil, 1, true, 0, {ARG_NUMBER}}, + {0x267, "round", op_round, 1, true, 0, {ARG_NUMBER}}, // 0x268 RESERVED // 0x269 RESERVED - {0x26b, "message_str_game", sf_message_str_game, 2, true, 0, {ARG_INT, ARG_INT}}, - {0x26c, "sneak_success", sf_sneak_success, 0, true}, - {0x26d, "tile_light", sf_tile_light, 2, true, -1, {ARG_INT, ARG_INT}}, - {0x26e, "obj_blocking_line", sf_make_straight_path, 3, true, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, - {0x26f, "obj_blocking_tile", sf_obj_blocking_at, 3, true, 0, {ARG_INT, ARG_INT, ARG_INT}}, - {0x270, "tile_get_objs", sf_tile_get_objects, 2, true, -1, {ARG_INT, ARG_INT}}, - {0x271, "party_member_list", sf_get_party_members, 1, true, -1, {ARG_INT}}, - {0x272, "path_find_to", sf_make_path, 3, true, -1, {ARG_OBJECT, ARG_INT, ARG_INT}}, - {0x273, "create_spatial", sf_create_spatial, 4, true, 0, {ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, - {0x274, "art_exists", sf_art_exists, 1, true, 0, {ARG_INT}}, - {0x275, "obj_is_carrying_obj", sf_obj_is_carrying_obj, 2, true, 0, {ARG_OBJECT, ARG_OBJECT}}, + {0x26b, "message_str_game", op_message_str_game, 2, true, 0, {ARG_INT, ARG_INT}}, + {0x26c, "sneak_success", op_sneak_success, 0, true}, + {0x26d, "tile_light", op_tile_light, 2, true, -1, {ARG_INT, ARG_INT}}, + {0x26e, "obj_blocking_line", op_make_straight_path, 3, true, 0, {ARG_OBJECT, ARG_INT, ARG_INT}}, + {0x26f, "obj_blocking_tile", op_obj_blocking_at, 3, true, 0, {ARG_INT, ARG_INT, ARG_INT}}, + {0x270, "tile_get_objs", op_tile_get_objects, 2, true, -1, {ARG_INT, ARG_INT}}, + {0x271, "party_member_list", op_get_party_members, 1, true, -1, {ARG_INT}}, + {0x272, "path_find_to", op_make_path, 3, true, -1, {ARG_OBJECT, ARG_INT, ARG_INT}}, + {0x273, "create_spatial", op_create_spatial, 4, true, 0, {ARG_INT, ARG_INT, ARG_INT, ARG_INT}}, + {0x274, "art_exists", op_art_exists, 1, true, 0, {ARG_INT}}, + {0x275, "obj_is_carrying_obj", op_obj_is_carrying_obj, 2, true, 0, {ARG_OBJECT, ARG_OBJECT}}, // universal opcodes: {0x276, "sfall_func0", HandleMetarule, 1, true}, @@ -230,9 +230,9 @@ static SfallOpcodeInfo opcodeInfoArray[] = { {0x27b, "sfall_func5", HandleMetarule, 6, true}, {0x27c, "sfall_func6", HandleMetarule, 7, true}, // if you need more arguments - use arrays - {0x27d, "register_hook_proc_spec", sf_register_hook, 2, false, 0, {ARG_INT, ARG_INT}}, - {0x27e, "reg_anim_callback", sf_reg_anim_callback, 1, false, 0, {ARG_INT}}, - {0x27f, "div", sf_div, 2, true, 0, {ARG_NUMBER, ARG_NUMBER}}, // div operator + {0x27d, "register_hook_proc_spec", op_register_hook, 2, false, 0, {ARG_INT, ARG_INT}}, + {0x27e, "reg_anim_callback", op_reg_anim_callback, 1, false, 0, {ARG_INT}}, + {0x27f, "div", op_div, 2, true, 0, {ARG_NUMBER, ARG_NUMBER}}, // div operator }; // An array for opcode info, indexed by opcode.