mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added "set_unjam_locks_time" script function (from Mr.Stalin)
This commit is contained in:
@@ -54,6 +54,9 @@ WRAP_WATCOM_FUNC0(void, mouse_hide)
|
||||
WRAP_WATCOM_FUNC6(long, make_path_func, GameObject*, objectFrom, long, tileFrom, long, tileTo, char*, pathDataBuffer, long, arg5, void*, blockingFunc)
|
||||
// calculates bounding box (rectangle) for a given object
|
||||
WRAP_WATCOM_FUNC2(void, obj_bound, GameObject*, object, BoundRect*, boundRect)
|
||||
// checks/unjams jammed locks
|
||||
WRAP_WATCOM_FUNC1(long, obj_lock_is_jammed, GameObject*, object)
|
||||
WRAP_WATCOM_FUNC1(void, obj_unjam_lock, GameObject*, object)
|
||||
WRAP_WATCOM_FUNC3(long, register_object_animate, GameObject*, object, long, anim, long, delay)
|
||||
WRAP_WATCOM_FUNC3(long, register_object_animate_and_hide, GameObject*, object, long, anim, long, delay)
|
||||
// WRAP_WATCOM_FUNC3(long, register_object_animate_and_move_straight_, GameObject*, object;
|
||||
|
||||
@@ -49,6 +49,7 @@ void _stdcall HandleMapUpdateForScripts(DWORD procId);
|
||||
|
||||
// TODO: move to a better place
|
||||
static int idle;
|
||||
static int unjamTimeState;
|
||||
|
||||
struct GlobalScript {
|
||||
ScriptProgram prog;
|
||||
@@ -531,6 +532,14 @@ void ClearGlobalScripts() {
|
||||
hit_location_penalty[8] = static_cast<long>(GetConfigInt("Misc", "BodyHit_Torso_Uncalled", 0));
|
||||
//skillpoints per level mod
|
||||
SafeWrite8(0x43C27a, 5);
|
||||
//restore obj_unjam_all_locks_
|
||||
if (unjamTimeState) {
|
||||
SafeWrite8(0x4A364A, 0xE8);
|
||||
SafeWrite32(0x4A364B, 0xFFFF9E69);
|
||||
SafeWrite8(0x4831DA, 0x7C);
|
||||
SafeWrite8(0x4831D9, 24);
|
||||
unjamTimeState = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void RunScriptProc(ScriptProgram* prog, const char* procName) {
|
||||
@@ -675,6 +684,23 @@ void SetGlobals(GlobalVar* globals) {
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptExtender::SetAutoUnjamLockTime(DWORD time) {
|
||||
if (!unjamTimeState) {
|
||||
BlockCall(0x4A364A); // disable auto unjam at midnight
|
||||
}
|
||||
|
||||
if (time > 0) {
|
||||
SafeWrite8(0x4831D9, (BYTE)time);
|
||||
if (unjamTimeState == 2) {
|
||||
SafeWrite8(0x4831DA, 0x7C);
|
||||
}
|
||||
unjamTimeState = 1;
|
||||
} else {
|
||||
SafeWrite8(0x4831DA, 0xEB); // disable auto unjam
|
||||
unjamTimeState = 2;
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptExtender::init() {
|
||||
LoadGameHook::OnAfterGameStarted() += LoadGlobalScripts;
|
||||
LoadGameHook::OnGameReset() += [] () {
|
||||
|
||||
@@ -30,6 +30,8 @@ class ScriptExtender : public Module {
|
||||
public:
|
||||
const char* name() { return "ScriptExtender"; }
|
||||
void init();
|
||||
|
||||
static void SetAutoUnjamLockTime(DWORD time);
|
||||
};
|
||||
|
||||
#pragma pack(8)
|
||||
|
||||
@@ -100,6 +100,7 @@ static const SfallMetarule metarules[] = {
|
||||
{"set_flags", sf_set_flags, 2, 2, {ARG_OBJECT, ARG_INT}},
|
||||
{"set_ini_setting", sf_set_ini_setting, 2, 2, {ARG_STRING, ARG_INTSTR}},
|
||||
{"set_outline", sf_set_outline, 2, 2, {ARG_OBJECT, ARG_INT}},
|
||||
{"set_unjam_locks_time", sf_set_unjam_locks_time, 1, 1, {ARG_INT}},
|
||||
{"spatial_radius", sf_spatial_radius, 1, 1, {ARG_OBJECT}},
|
||||
{"tile_refresh_display", sf_tile_refresh_display, 0, 0},
|
||||
{"unjam_lock", sf_unjam_lock, 1, 1, {ARG_OBJECT}},
|
||||
|
||||
@@ -417,5 +417,14 @@ void sf_unjam_lock(OpcodeContext& ctx) {
|
||||
fo::func::obj_unjam_lock(ctx.arg(0).asObject());
|
||||
}
|
||||
|
||||
void sf_set_unjam_locks_time(OpcodeContext& ctx) {
|
||||
int time = ctx.arg(0).asInt();
|
||||
if (time < 0 || time > 255) {
|
||||
ctx.printOpcodeError("set_unjam_locks_time() - time argument must be in the range of 0 to 255.");
|
||||
} else {
|
||||
ScriptExtender::SetAutoUnjamLockTime(time);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,5 +89,7 @@ void sf_lock_is_jammed(OpcodeContext&);
|
||||
|
||||
void sf_unjam_lock(OpcodeContext&);
|
||||
|
||||
void sf_set_unjam_locks_time(OpcodeContext&);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user