/
erlang.spawn
/
fallout2-ce
Обзор
Документация
Войти
/
erlang.spawn
/
fallout2-ce
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
sfall_testing/gl_test_script_manipulation.ssl
59 строк
2 KB
Mike Klaas
`set/remove_script` and `HOOK_STDPROCEDURE{_END}` (#392)
20 апр 2026, 22:56
Не верифицирован
20 апр 2026, 22:56
4070d29
Код
Авторство
О чём код?
#include "sfall.h" #include "test_utils.h" #define TEST_SCRIPT_INDEX (2) // Depends on Test0.int, which provides a controllable object script helper. // Put the compiled helper at mods/test_script_override/scripts/Test0.int, // and add "test_script_override" to mod_order.txt. The helper must live there // (and not scripts/) because patch000.dat already contains a stock Test0.int and // scripts/ load before it. // Without Test0, these 2 tests will fail: // - "set_script normal hp" // - "set_script no map_enter hp" variable testScriptObj := 0; procedure create_test_object begin if (testScriptObj != 0) then return; testScriptObj := create_object_sid(obj_pid(dude_obj), tile_num_in_direction(tile_num(dude_obj), has_trait(TRAIT_OBJECT, dude_obj, OBJECT_CUR_ROT), 3), elevation(dude_obj), -1); end procedure stdprocedure_hook begin if (get_sfall_arg_at(0) != 15) then return; if (get_sfall_arg_at(3)) then begin set_sfall_global("T0HAFTR1", 1); end else begin set_sfall_global("T0HBEFO1", 1); end end procedure exercise_set_script(variable scriptId, variable expectedHp, variable expectedBeforeHook, variable expectedAfterHook, variable desc) begin set_sfall_global("T0MAPEN1", 0); set_sfall_global("T0HBEFO1", 0); set_sfall_global("T0HAFTR1", 0); set_script(testScriptObj, scriptId); call assertEquals(desc + " get_script", get_script(testScriptObj), TEST_SCRIPT_INDEX); call assertEquals(desc + " map_enter global", get_sfall_global_int("T0MAPEN1"), expectedHp); call assertEquals(desc + " stdprocedure hook before", get_sfall_global_int("T0HBEFO1"), expectedBeforeHook); call assertEquals(desc + " stdprocedure hook after", get_sfall_global_int("T0HAFTR1"), expectedAfterHook); remove_script(testScriptObj); call assertEquals(desc + " remove_script clears get_script", get_script(testScriptObj), 0); end procedure start begin if (not game_loaded) then return; display_msg("Testing set_script/remove_script/get_script..."); register_hook_proc(HOOK_STDPROCEDURE, stdprocedure_hook); register_hook_proc(HOOK_STDPROCEDURE_END, stdprocedure_hook); call create_test_object; call exercise_set_script(TEST_SCRIPT_INDEX, 22, 1, 1, "set_script normal"); call exercise_set_script(TEST_SCRIPT_INDEX bwor 0x80000000, 11, 0, 0, "set_script no map_enter"); destroy_object(testScriptObj); testScriptObj := 0; call report_test_results("script_manipulation"); end