From c1c7a39b07348aaacfae5c3e25afbb69d1e3f347 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 30 May 2022 13:00:21 +0000 Subject: [PATCH] deploy: 6b97ad4bcf6a2c57488a78d30e15a2e87074e50c --- assets/js/search-data.json | 30 ++++++++++----------- audio/index.html | 6 ++--- feed.xml | 2 +- index.html | 2 +- math/index.html | 2 +- optimization/index.html | 33 ++++++++++++----------- other/index.html | 4 +-- sslc/index.html | 54 ++++++++++++++++++++------------------ 8 files changed, 68 insertions(+), 65 deletions(-) diff --git a/assets/js/search-data.json b/assets/js/search-data.json index 35c2e652..e15e932f 100644 --- a/assets/js/search-data.json +++ b/assets/js/search-data.json @@ -97,7 +97,7 @@ },"16": { "doc": "Audio", "title": "Functions", - "content": ". | eax_available | play_sfall_sound | set_eax_environment | stop_sfall_sound | . eax_available . int eax_available . play_sfall_sound . int play_sfall_sound(string file, int mode) . Used to play mp3/wav/wma files. The path given is relative to the Fallout folder. Specify mode as 1 to loop the file continuously, 2 to replace the current background game music with playing the specified file in loop mode, or 0 to play the file once. If you don’t wish to loop, play_sfall_sound returns 0. If you do loop, it returns an id which can be passed back to stop_sfall_sound when you want to stop the effect. All sounds effects will be stopped on game reload, looping or not. Does not require AllowDShowSound to be set to 1 in ddraw.ini. Starting from sfall 4.2.8/3.8.28, you can pass a value in the mode argument for a reduced sound volume. To set the volume, You need to convert the number to hexadecimal and use the argument format 0xZZZZ000Y, where ZZZZ is the volume reduction value in range from 0 to 32767 (the value 32767 is mute), and Y is the playback mode. set_eax_environment . void set_eax_environment(int environment) . stop_sfall_sound . void stop_sfall_sound(int soundID) . Stops looping mp3/wav/wma files previously launched by play_sfall_sound. All sounds effects will be stopped on game reload, looping or not. Does not require AllowDShowSound to be set to 1 in ddraw.ini. ", + "content": ". | eax_available | play_sfall_sound | set_eax_environment | stop_sfall_sound | . eax_available . int eax_available() . Obsolete since sfall 2.1a. Always returns 0. play_sfall_sound . int play_sfall_sound(string file, int mode) . Used to play mp3/wav/wma files. The path given is relative to the Fallout folder. Specify mode as 1 to loop the file continuously, 2 to replace the current background game music with playing the specified file in loop mode, or 0 to play the file once. If you don’t wish to loop, play_sfall_sound returns 0. If you do loop, it returns an id which can be passed back to stop_sfall_sound when you want to stop the effect. All sounds effects will be stopped on game reload, looping or not. Does not require AllowDShowSound to be set to 1 in ddraw.ini. Starting from sfall 4.2.8/3.8.28, you can pass a value in the mode argument for a reduced sound volume. To set the volume, You need to convert the number to hexadecimal and use the argument format 0xZZZZ000Y, where ZZZZ is the volume reduction value in range from 0 to 32767 (the value 32767 is mute), and Y is the playback mode. set_eax_environment . void set_eax_environment(int environment) . Obsolete since sfall 2.1a. Has no effect. stop_sfall_sound . void stop_sfall_sound(int soundID) . Stops looping mp3/wav/wma files previously launched by play_sfall_sound. All sounds effects will be stopped on game reload, looping or not. Does not require AllowDShowSound to be set to 1 in ddraw.ini. ", "url": "/sfall/audio/#functions", "relUrl": "/audio/#functions" },"17": { @@ -709,7 +709,7 @@ },"118": { "doc": "Math", "title": "Functions", - "content": ". | ^ | abs | arctan | ceil | cos | div | exponent | floor2 | log | round | sin | sqrt | tan | . ^ . x^y . Exponentiation. Use as any other arithmetic operator, like 5^(1/3). If exponent is an integer, you can use a negative base, otherwise you will get “NaN” with a negative base. If both arguments are integers, the result will be an integer. abs . int/float abs(int/float x) . Absolute (positive) value of x. arctan . float arctan(float x, float y) . Arctangent of x. Pass 1 as y (don’t ask…). ceil . int ceil(float) . Round x to the nearest integer that is not less than x. cos . float cos(float x) . Cosine of x . div . div(x, y) . Unsigned integer division. Use as a division operator, like 3 + (20 div 5). If both dividend and divisor are integers, they will be treated as unsigned integers. If one of them is a float, div will perform the signed division just like vanilla division operator. exponent . float exponent(float x) . E^X . floor2 . sfall.h . int floor2(int/float value) . Works just like vanilla floor function, but returns correct integers for negative values (vanilla floor function works exactly the same as ceil for negative values, much like trunc in C/C++). log . float log(float x) . Natural logarithm of x. round . int round(float x) . Round x to the nearest integer. sin . float sin(float x) . Sine of x . sqrt . float sqrt(float x) . Square root of x. tan . float tan(float x) . Tangent of x . ", + "content": ". | ^ | abs | arctan | ceil | cos | div | exponent | floor2 | log | round | sin | sqrt | tan | . ^ . x^y . Exponentiation. Use as any other arithmetic operator, like 5^(1/3). If exponent is an integer, you can use a negative base, otherwise you will get “NaN” with a negative base. If both arguments are integers, the result will be an integer. abs . int/float abs(int/float x) . Absolute (positive) value of x. arctan . float arctan(float x, float y) . Arctangent of x. Pass 1 as y (don’t ask…). ceil . int ceil(float x) . Round x to the nearest integer that is not less than x. cos . float cos(float x) . Cosine of x . div . div(x, y) . Unsigned integer division. Use as a division operator, like 3 + (20 div 5). If both dividend and divisor are integers, they will be treated as unsigned integers. If one of them is a float, div will perform the signed division just like vanilla division operator. exponent . float exponent(float x) . E^X . floor2 . sfall.h . int floor2(int/float value) . Works just like vanilla floor function, but returns correct integers for negative values (vanilla floor function works exactly the same as ceil for negative values, much like trunc in C/C++). log . float log(float x) . Natural logarithm of x. round . int round(float x) . Round x to the nearest integer. sin . float sin(float x) . Sine of x . sqrt . float sqrt(float x) . Square root of x. tan . float tan(float x) . Tangent of x . ", "url": "/sfall/math/#functions", "relUrl": "/math/#functions" },"119": { @@ -745,13 +745,13 @@ },"124": { "doc": "Optimization", "title": "sslc -O option", - "content": "The sfall build of sslc supports a -O command line option to perform an optimization pass over the generated code. This isn’t a magic make-my-code-go-faster bullet; most of what it does is very limited in scope. It’s primary purpose was to strip out the procedures and variables which get automatically pulled into every script that includes define.h, whether you use them or not, and to do something about the additional variables that get created by foreach loops. There are several levels of optimization available: . | -O1 - Basic, only removes unreferenced globals variables and procedures, code itself remains untouched. | -O2 - Full, most code optimizations are on, but only those that were tested on complex scripts. | -O3 - Experimental, provides most efficiency, but tend to break some complex code due to bugs. | . The following optimizations are performed: . | constant expression folding: if an expression depends only on values which are known at compile time, then the expression is replaced by its result. a:=2+2; -> a:=4; | constant variable initialization: All variables are initialised to some value, (‘0’, if you don’t specify anything else,) so sslc attempts to make use of that fact to remove the first assignment to a variable if the first assignment is a constant expression. variable a; -> variable a:=4; a:=4; -> . | constant propagation: checks for values assigned to variables which can be computed at compile time, and replaces relevent references to the symbol by the constant. The original store is not removed by this optimization. Global variables are considered for this optimization only if they are not marked import or export, and are not assigned to anywhere in the script. a:=4 -> a:=4 foo(a); -> foo(4); . | dead code removal: Checks for and removes code which cannot be reached, either because it is hidden behind a return or because the argument to an if statement can be computed at compile time. if 1 then begin -> display_msg(\"foo\"); display_msg(\"foo\"); -> end else begin -> display_msg(\"bar\"); -> end -> . | unreferenced variable elimination: Checks for variables which are never referenced, and removes them. Also applies to global variables, as long as they are not marked for export. variable i, j, k; -> variable i; i:=1; -> i:=1; return; -> return; . | unreferenced procedure elimination: Checks for any procedures which are never called, and removes them. procedure foo begin return \"foo\"; end -> procedure foo begin return \"foo\"; end procedure bar begin return \"bar\"; end -> procedure start begin procedure start begin -> display_msg(foo); display_msg(foo); -> end end -> . | dead store removal: Removes variable assignments if the result of the variable is unused, and if the expression used to compute the value of the variable is provably free of side effects. (See ‘pure’ keyword) a:=\"moo\"; -> a:=\"foo\"; a:=\"foo\"; -> display_msg(a); display_msg(a); -> a:=\"bar\"; -> . | store combination: Where there are two stores in a row to the same variable, the two expressions are combined. var1 := var2; -> var1 := var2 + var3; var1 += var3; -> . | variable combination: Where usage regions of variables do not overlap, combine the variables to provide additional candidates for unreferenced variable elimination. Very useful for scripts containing multiple foreach loops, which generate 2 or 3 hidden variables each. a:=\"foo\"; -> a:=\"foo\"; display_msg(a); -> display_msg(a); b:=\"bar\"; -> a:=\"bar\"; display_msg(b); -> display_msg(a); . | namelist compression: Fallout stores the names of all file scope variables and procedures in a namelist which is saved into the .int. Any of these that are unreferenced can be removed, and the names of global variables can be modified to make them shorter. | . ", + "content": "The sfall build of sslc supports a -O command line option to perform an optimization pass over the generated code. This isn’t a magic make-my-code-go-faster bullet; most of what it does is very limited in scope. It’s primary purpose was to strip out the procedures and variables which get automatically pulled into every script that includes define.h, whether you use them or not, and to do something about the additional variables that get created by foreach loops. There are several levels of optimization available: . | -O1 - Basic, only removes unreferenced globals variables and procedures, code itself remains untouched. | -O2 - Full, most code optimizations are on, but only those that were tested on complex scripts. | -O3 - Experimental, provides most efficiency, but tend to break some complex code due to bugs. | . The following optimizations are performed: . | constant expression folding: if an expression depends only on values which are known at compile time, then the expression is replaced by its result. a := 2 + 2; -> a := 4; . | constant variable initialization: All variables are initialised to some value, (‘0’, if you don’t specify anything else,) so sslc attempts to make use of that fact to remove the first assignment to a variable if the first assignment is a constant expression. variable a; -> variable a := 4; a := 4; -> . | constant propagation: checks for values assigned to variables which can be computed at compile time, and replaces relevent references to the symbol by the constant. The original store is not removed by this optimization. Global variables are considered for this optimization only if they are not marked import or export, and are not assigned to anywhere in the script. a := 4; -> a := 4; foo(a); -> foo(4); . | dead code removal: Checks for and removes code which cannot be reached, either because it is hidden behind a return or because the argument to an if statement can be computed at compile time. if (True) then begin -> display_msg(\"foo\"); display_msg(\"foo\"); -> end else begin -> display_msg(\"bar\"); -> end -> . | unreferenced variable elimination: Checks for variables which are never referenced, and removes them. Also applies to global variables, as long as they are not marked for export. variable i, j, k; -> variable i; i := 1; -> i := 1; return; -> return; . | unreferenced procedure elimination: Checks for any procedures which are never called, and removes them. procedure foo begin return \"foo\"; end -> procedure foo begin return \"foo\"; end procedure bar begin return \"bar\"; end -> procedure start begin procedure start begin -> display_msg(foo); display_msg(foo); -> end end -> . | dead store removal: Removes variable assignments if the result of the variable is unused, and if the expression used to compute the value of the variable is provably free of side effects. (See pure keyword) a := \"moo\"; -> a := \"foo\"; a := \"foo\"; -> display_msg(a); display_msg(a); -> a := \"bar\"; -> . | store combination: Where there are two stores in a row to the same variable, the two expressions are combined. var1 := var2; -> var1 := var2 + var3; var1 += var3; -> . | variable combination: Where usage regions of variables do not overlap, combine the variables to provide additional candidates for unreferenced variable elimination. Very useful for scripts containing multiple foreach loops, which generate 2 or 3 hidden variables each. a := \"foo\"; -> a := \"foo\"; display_msg(a); -> display_msg(a); b := \"bar\"; -> a := \"bar\"; display_msg(b); -> display_msg(a); . | namelist compression: Fallout stores the names of all file scope variables and procedures in a namelist which is saved into the .int. Any of these that are unreferenced can be removed, and the names of global variables can be modified to make them shorter. | . ", "url": "/sfall/optimization/#sslc--o-option", "relUrl": "/optimization/#sslc--o-option" },"125": { "doc": "Optimization", "title": "Writing your own code", - "content": ". | Don’t have global scripts running any more often that you need them to. Not everything needs to be run every single frame. | Never concat constant strings with the ‘+’ operator, as it forces the operation to be done at runtime. The compiler can cope with constant strings being placed next to each other without the need for a +, which results in far more efficient code as the combination is done at lex time. #define GLOB_PREFIX \"ts__\" -> #define GLOB_PREFIX \"ts__\" procedure start begin -> procedure start begin set_sfall_global(GLOB_PREFIX + \"foo1\", 0); -> set_sfall_global(GLOB_PREFIX \"foo1\", 0); end -> end . | Avoid function calls in while loops. function calls are expensive in comparison to variable lookups, so it’s more efficient to move the function call out of the loop and store the result in a variable while i < len_array(array) do begin -> tmp:= len_array(array); ... -> while i < tmp do begin end -> ... -> end . | Mark functions with pure or inline where relevent. ‘pure’ is a hint to the optimizer that a procedure has no side effects. (i.e. there’s no way to tell that it’s been called aside from its return value.) Pure procedures cannot modify global variables, or call any other procedure that isn’t itself pure. Functions marked with pure can only be used in expressions (i.e. you cannot use the call <procedure> syntax to call them.) If there are non-pure terms in an expression, it prevents that expression being considered for dead store removal. Where no such optimizations can be performed, or if optimization is disabled, marking a procedure with pure will have no effect on the compiled code. ‘inline’ is an instruction to the compiler to replace calls to the marked procedure with a copy of the procedures code instead of having a seperate call. inlined procedures cannot use the ‘return’ command, cannot be predefined, and cannot be used as part of an expression. inlining if a procedure is only going to be called once is always a win, but if there are multiple calls to a procedure you will end up bloating the size of the generated code. | . ", + "content": ". | Don’t have global scripts running any more often that you need them to. Not everything needs to be run every single frame. | Never concat constant strings with the + operator, as it forces the operation to be done at runtime. The compiler can cope with constant strings being placed next to each other without the need for a +, which results in far more efficient code as the combination is done at lex time. #define GLOB_PREFIX \"ts__\" -> #define GLOB_PREFIX \"ts__\" procedure start begin -> procedure start begin set_sfall_global(GLOB_PREFIX + \"foo1\", 0); -> set_sfall_global(GLOB_PREFIX \"foo1\", 0); end -> end . | Avoid function calls in while loops. Function calls are expensive in comparison to variable lookups, so it’s more efficient to move the function call out of the loop and store the result in a variable. while i < len_array(array) do begin -> tmp := len_array(array); ... -> while i < tmp do begin end -> ... -> end . | Mark functions with pure or inline where relevent. | pure is a hint to the optimizer that a procedure has no side effects. (i.e. there’s no way to tell that it’s been called aside from its return value.) Pure procedures cannot modify global variables, or call any other procedure that isn’t itself pure. Functions marked with pure can only be used in expressions (i.e. you cannot use the call <procedure> syntax to call them.) If there are non-pure terms in an expression, it prevents that expression being considered for dead store removal. Where no such optimizations can be performed, or if optimization is disabled, marking a procedure with pure will have no effect on the compiled code. | inline is an instruction to the compiler to replace calls to the marked procedure with a copy of the procedures code instead of having a seperate call. Inlined procedures cannot use the return command, cannot be predefined, and cannot be used as part of an expression. Inlining if a procedure is only going to be called once is always a win, but if there are multiple calls to a procedure you will end up bloating the size of the generated code. | . | . ", "url": "/sfall/optimization/#writing-your-own-code", "relUrl": "/optimization/#writing-your-own-code" },"126": { @@ -763,7 +763,7 @@ },"127": { "doc": "Other", "title": "Functions", - "content": ". | active_hand | add_g_timer_event | add_trait | create_message_window | create_spatial | game_loaded | gdialog_get_barter_mod | get_game_mode | get_inven_ap_cost | get_kill_counter | get_light_level | get_npc_level | get_proto_data | get_unspent_ap_bonus | get_unspent_ap_perk_bonus | get_uptime | get_viewport_x | get_viewport_y | get_year | hero_select_win | inc_npc_level | input_funcs_available | mark_movie_played | message_str_game | mod_kill_counter | nb_create_char | resume_game | set_base_hit_chance_mod | set_base_pickpocket_mod | set_critter_hit_chance_mod | set_critter_pickpocket_mod | set_df_model | set_dm_model | set_hit_chance_max | set_hp_per_level_mod | set_inven_ap_cost | set_movie_path | set_pickpocket_max | set_pipboy_available | set_proto_data | set_unspent_ap_bonus | set_unspent_ap_perk_bonus | set_viewport_x | set_viewport_y | set_xp_mod | sneak_success | stop_game | toggle_active_hand | unwield_slot | . active_hand . int active_hand . add_g_timer_event . sfall.h . void add_g_timer_event(int time, int fixedParam) . Adds a timer event that calls the timed_event_p_proc procedure in the current global script time: the number of ticks after which the event timer is triggered fixedParam: the value that is passed to the timed_event_p_proc procedure for the fixed_param function . add_trait . sfall.h . void add_trait(int traitID) . adds the specified trait to the player . create_message_window . void create_message_window(string message) . create_spatial . ObjectPtr create_spatial(int scriptID, int tile, int elevation, int radius) . Creates new spatial script with given SID, at given tile, and radius. game_loaded . int game_loaded() . Returns 1 the first time it is called after a new game or game load, and 0 any time after. It works on an individual basis for each script, so one script wont interfere with others. Its primary use is for global scripts, so that they know when to call set_global_script_repeat, but it can be called from normal scripts too. gdialog_get_barter_mod . int gdialog_get_barter_mod . get_game_mode . int get_game_mode() . A more flexible version of in_world_map. It will return a set of flags indicating which mode the game is currently in. These flags are the same as those used in the set_shader_mode function. get_inven_ap_cost . int get_inven_ap_cost . Returns the current AP cost to access the inventory in combat . get_kill_counter . int get_kill_counter(int critterType) . get_light_level . int get_light_level() . Returns ambient light level in range 0..65536. The value returned by get_light_level may not exactly match that set by set_light_level, as set_light_level applies modifiers from the Night Vision perk. get_npc_level . int get_npc_level(string npc) . get_proto_data . int get_proto_data(int pid, int offset) . Used to read the in-memory copies of the .pro files Fallout makes when they are loaded. The offset refers to the offset in memory from the start of the proto to the element you are reading. get_unspent_ap_bonus . int get_unspent_ap_bonus() . Gets the AC bonus you receive per unused action point at the end of your turn in combat. To allow for fractional values, the value given if divided by 4. (Hence the default value is 4 and not 1.) . get_unspent_ap_perk_bonus . int get_unspent_ap_perk_bonus() . Similar to get_unspent_ap_bonus, but accounts for the extra AC granted by the H2H Evade perk. (The default value of this is also 4, equivalent to doubling the original bonus. get_uptime . int get_uptime() . Just a wrapper around the windows GetTickCount() function. It’s useful for making time fade effects in shaders, since they already have access to the current tick count. get_viewport_x . int get_viewport_x() . get_viewport_y . int get_viewport_y() . get_year . int get_year . hero_select_win . void hero_select_win(int) . inc_npc_level . void inc_npc_level(int party_member_pid) . Takes a party member PID or an NPC name (deprecated, for compatibility with sfall 4.1.5/3.8.15 or earlier) as an argument. The NPC must be in your party. This function ignores player level requirements and the minimum 3 player level delay between NPC level gains. It also ignores the random element, regardless of sfall’s NPCAutoLevel setting. input_funcs_available . int input_funcs_available() . The input functions are only available if the user has the input hook turned on in ddraw.ini. Use input_funcs_available to check. mark_movie_played . void mark_movie_played(int id) . message_str_game . string message_str_game(int fileId, int messageId) . Works exactly the same as message_str, except you get messages from files in text/english/game folder. Use GAME_MSG_* defines or mstr_* macros from sfall.h to use specific msg file . | Additional game msg files added by ExtraGameMsgFileList setting will have consecutive fileIds assigned beginning from 0x2000 to 0x2FFF. (e.g. if you set ExtraGameMsgFileList=foo,bar in ddraw.ini, foo.msg will be associated with 0x2000 and bar.msg with 0x2001.). | If a file has a specific number assigned in ExtraGameMsgFileList, its fileId will be (0x2000 + assigned number). (e.g. with ExtraGameMsgFileList=foo,bar:2,foobar in ddraw.ini, bar.msg will be associated with 0x2002 and foobar.msg with 0x2003.) | . mod_kill_counter . void mod_kill_counter(int critterType, int amount) . nb_create_char . int nb_create_char() . nb_* functions are reserved for the brotherhood tactical training mod, and should be avoided. resume_game . void resume_game() . set_base_hit_chance_mod . void set_base_hit_chance_mod(int max, int mod) . set_base_pickpocket_mod . void set_base_pickpocket_mod(int max, int mod) . Changes maximum chance of success and chance mod for each steal attempt. max will replace 95% success chance cap (so you can set 100% maximum chance, for instance). mod will add this much percent to each success chance. for example if your chance is 50% and mod is 20, you will get 70% actual success rate . set_critter_hit_chance_mod . void set_critter_hit_chance_mod(CritterPtr, int max, int mod) . set_critter_pickpocket_mod . void set_critter_pickpocket_mod(CritterPtr, int max, int mod) . The same as set_base_pickpocket, but applies only to specific critter. set_df_model . void set_df_model(string name) . set_dm_model . void set_dm_model(string name) . set_hit_chance_max . void set_hit_chance_max(int percentage) . Effects all critters rather than just the player and can set the maximum in range from 0 to 999. set_hp_per_level_mod . void set_hp_per_level_mod(int mod) . set_inven_ap_cost . void set_inven_ap_cost . set_movie_path . void set_movie_path(string filename, int movieid) . set_pickpocket_max . void set_pickpocket_max(int percentage) . Effects all critters rather than just the player and can set the maximum in range from 0 to 999. set_pipboy_available . void set_pipboy_available(int available) . Will only accept 0 or 1 as an argument. Using any other value will cause the function to have no effect. Use 0 to disable the pipboy, and 1 to enable it. set_proto_data . void set_proto_data(int pid, int offset, int value) . Used to alter the in-memory copies of the .pro files Fallout makes when they are loaded. The offset refers to the offset in memory from the start of the proto to the element you are reading. Changes are not stored on disc, and are not permanent. If you modify the protos, and then Fallout subsequently reloads the file your changes will be lost. set_unspent_ap_bonus . void set_unspent_ap_bonus(int multiplier) . Alters the AC bonus you receive per unused action point at the end of your turn in combat. To allow for fractional values, the value given if divided by 4. (Hence the default value is 4 and not 1.) . set_unspent_ap_perk_bonus . void set_unspent_ap_perk_bonus(int multiplier) . Similar to set_unspent_ap_bonus, but effects the extra AC granted by the H2H Evade perk. (The default value of this is also 4, equivalent to doubling the original bonus. set_viewport_x . void set_viewport_x(int view_x) . set_viewport_y . void set_viewport_y(int view_y) . set_xp_mod . void set_xp_mod(int percentage) . sneak_success . int sneak_success . Returns 1 if last sneak attempt (roll against skill) was successful, 0 otherwise. This calls an internal engine function which is used to determine the perception range of critters (which you can override using HOOK_WITHINPERCEPTION). stop_game . void stop_game() . toggle_active_hand . void toggle_active_hand . unwield_slot . void sfall_func2(\"unwield_slot\", object critter, int slot) . unequips an item from the specified slot for a critter or the player can take off player’s equipped item when the inventory is opened, or the player is in the barter screen slot: 0 - armor slot, 1 - right slot, 2 - left slot (see INVEN_TYPE_* in define.h) . ", + "content": ". | active_hand | add_g_timer_event | add_trait | create_message_window | create_spatial | game_loaded | gdialog_get_barter_mod | get_game_mode | get_inven_ap_cost | get_kill_counter | get_light_level | get_npc_level | get_proto_data | get_unspent_ap_bonus | get_unspent_ap_perk_bonus | get_uptime | get_viewport_x | get_viewport_y | get_year | hero_select_win | inc_npc_level | input_funcs_available | mark_movie_played | message_str_game | mod_kill_counter | nb_create_char | resume_game | set_base_hit_chance_mod | set_base_pickpocket_mod | set_critter_hit_chance_mod | set_critter_pickpocket_mod | set_df_model | set_dm_model | set_hit_chance_max | set_hp_per_level_mod | set_inven_ap_cost | set_movie_path | set_pickpocket_max | set_pipboy_available | set_proto_data | set_unspent_ap_bonus | set_unspent_ap_perk_bonus | set_viewport_x | set_viewport_y | set_xp_mod | sneak_success | stop_game | toggle_active_hand | unwield_slot | . active_hand . int active_hand . add_g_timer_event . sfall.h . void add_g_timer_event(int time, int fixedParam) . Adds a timer event that calls the timed_event_p_proc procedure in the current global script time: the number of ticks after which the event timer is triggered fixedParam: the value that is passed to the timed_event_p_proc procedure for the fixed_param function . add_trait . sfall.h . void add_trait(int traitID) . adds the specified trait to the player . create_message_window . void create_message_window(string message) . create_spatial . ObjectPtr create_spatial(int scriptID, int tile, int elevation, int radius) . Creates new spatial script with given SID, at given tile, and radius. game_loaded . int game_loaded() . Returns 1 the first time it is called after a new game or game load, and 0 any time after. It works on an individual basis for each script, so one script wont interfere with others. Its primary use is for global scripts, so that they know when to call set_global_script_repeat, but it can be called from normal scripts too. gdialog_get_barter_mod . int gdialog_get_barter_mod . get_game_mode . int get_game_mode() . A more flexible version of in_world_map. It will return a set of flags indicating which mode the game is currently in. These flags are the same as those used in the set_shader_mode function. get_inven_ap_cost . int get_inven_ap_cost . Returns the current AP cost to access the inventory in combat . get_kill_counter . int get_kill_counter(int critterType) . get_light_level . int get_light_level() . Returns ambient light level in range 0..65536. The value returned by get_light_level may not exactly match that set by set_light_level, as set_light_level applies modifiers from the Night Vision perk. get_npc_level . int get_npc_level(string npc) . get_proto_data . int get_proto_data(int pid, int offset) . Used to read the in-memory copies of the .pro files Fallout makes when they are loaded. The offset refers to the offset in memory from the start of the proto to the element you are reading. get_unspent_ap_bonus . int get_unspent_ap_bonus() . Gets the AC bonus you receive per unused action point at the end of your turn in combat. To allow for fractional values, the value given if divided by 4. (Hence the default value is 4 and not 1.) . get_unspent_ap_perk_bonus . int get_unspent_ap_perk_bonus() . Similar to get_unspent_ap_bonus, but accounts for the extra AC granted by the H2H Evade perk. (The default value of this is also 4, equivalent to doubling the original bonus. get_uptime . int get_uptime() . Just a wrapper around the windows GetTickCount() function. It’s useful for making time fade effects in shaders, since they already have access to the current tick count. get_viewport_x . int get_viewport_x() . get_viewport_y . int get_viewport_y() . get_year . int get_year . hero_select_win . void hero_select_win(int) . inc_npc_level . void inc_npc_level(int party_member_pid) . Takes a party member PID or an NPC name (deprecated, for compatibility with sfall 4.1.5/3.8.15 or earlier) as an argument. The NPC must be in your party. This function ignores player level requirements and the minimum 3 player level delay between NPC level gains. It also ignores the random element, regardless of sfall’s NPCAutoLevel setting. input_funcs_available . int input_funcs_available() . The input functions are only available if the user has the input hook turned on in ddraw.ini. Use input_funcs_available to check. mark_movie_played . void mark_movie_played(int id) . message_str_game . string message_str_game(int fileId, int messageId) . Works exactly the same as message_str, except you get messages from files in text/english/game folder. Use GAME_MSG_* defines or mstr_* macros from sfall.h to use specific msg file . | Additional game msg files added by ExtraGameMsgFileList setting will have consecutive fileIds assigned beginning from 0x2000 to 0x2FFF. (e.g. if you set ExtraGameMsgFileList=foo,bar in ddraw.ini, foo.msg will be associated with 0x2000 and bar.msg with 0x2001.). | If a file has a specific number assigned in ExtraGameMsgFileList, its fileId will be (0x2000 + assigned number). (e.g. with ExtraGameMsgFileList=foo,bar:2,foobar in ddraw.ini, bar.msg will be associated with 0x2002 and foobar.msg with 0x2003.) | . mod_kill_counter . void mod_kill_counter(int critterType, int amount) . nb_create_char . int nb_create_char() . nb_* functions are reserved for the brotherhood tactical training mod, and should be avoided. Not implemented, always returns 0. resume_game . void resume_game() . set_base_hit_chance_mod . void set_base_hit_chance_mod(int max, int mod) . set_base_pickpocket_mod . void set_base_pickpocket_mod(int max, int mod) . Changes maximum chance of success and chance mod for each steal attempt. max will replace 95% success chance cap (so you can set 100% maximum chance, for instance). mod will add this much percent to each success chance. for example if your chance is 50% and mod is 20, you will get 70% actual success rate . set_critter_hit_chance_mod . void set_critter_hit_chance_mod(CritterPtr, int max, int mod) . set_critter_pickpocket_mod . void set_critter_pickpocket_mod(CritterPtr, int max, int mod) . The same as set_base_pickpocket, but applies only to specific critter. set_df_model . void set_df_model(string name) . set_dm_model . void set_dm_model(string name) . set_hit_chance_max . void set_hit_chance_max(int percentage) . Effects all critters rather than just the player and can set the maximum in range from 0 to 999. set_hp_per_level_mod . void set_hp_per_level_mod(int mod) . set_inven_ap_cost . void set_inven_ap_cost(int cost) . set_movie_path . void set_movie_path(string filename, int movieid) . set_pickpocket_max . void set_pickpocket_max(int percentage) . Effects all critters rather than just the player and can set the maximum in range from 0 to 999. set_pipboy_available . void set_pipboy_available(int available) . Will only accept 0 or 1 as an argument. Using any other value will cause the function to have no effect. Use 0 to disable the pipboy, and 1 to enable it. set_proto_data . void set_proto_data(int pid, int offset, int value) . Used to alter the in-memory copies of the .pro files Fallout makes when they are loaded. The offset refers to the offset in memory from the start of the proto to the element you are reading. Changes are not stored on disc, and are not permanent. If you modify the protos, and then Fallout subsequently reloads the file your changes will be lost. set_unspent_ap_bonus . void set_unspent_ap_bonus(int multiplier) . Alters the AC bonus you receive per unused action point at the end of your turn in combat. To allow for fractional values, the value given if divided by 4. (Hence the default value is 4 and not 1.) . set_unspent_ap_perk_bonus . void set_unspent_ap_perk_bonus(int multiplier) . Similar to set_unspent_ap_bonus, but effects the extra AC granted by the H2H Evade perk. (The default value of this is also 4, equivalent to doubling the original bonus. set_viewport_x . void set_viewport_x(int view_x) . set_viewport_y . void set_viewport_y(int view_y) . set_xp_mod . void set_xp_mod(int percentage) . sneak_success . int sneak_success . Returns 1 if last sneak attempt (roll against skill) was successful, 0 otherwise. This calls an internal engine function which is used to determine the perception range of critters (which you can override using HOOK_WITHINPERCEPTION). stop_game . void stop_game() . toggle_active_hand . void toggle_active_hand . unwield_slot . void sfall_func2(\"unwield_slot\", object critter, int slot) . unequips an item from the specified slot for a critter or the player can take off player’s equipped item when the inventory is opened, or the player is in the barter screen slot: 0 - armor slot, 1 - right slot, 2 - left slot (see INVEN_TYPE_* in define.h) . ", "url": "/sfall/other/#functions", "relUrl": "/other/#functions" },"128": { @@ -871,39 +871,39 @@ },"145": { "doc": "SSLC", "title": "SSLC", - "content": ". | Command line options | Additional supported syntax | int2ssl note | Fixes | Backward compatibility | . This is a modified copy of sslc, that has a few bugfixes from the original, that will recognise and compile the additional script functions provided by sfall, that can also understand some additional syntax, and that has an integrated preprocessor and optimizer. Unlike the original script compiler, this has not been compiled as a dos program. When using this in place of the original compile.exe but still using p.bat, you need to either get rid of the dos4gw.exe reference from p.bat or replace the original dos4gw.exe with the one in this archive. If you use fallout script editor, you can extract compile.exe and dos4gw.exe to its \\binary folder, or extract them somewhere else and change your preferences in FSE to point there. FSE doesn’t seem to be able to tell when errors occur when using this compiler though, so I’d recommend either using sfall’s script editor instead or compiling by hand if possible. When compiling global or hook scripts for sfall 3.4 or below, you must include the line procedure start; before any #includes that define procedures to avoid a few weird problems. (this is no longer required starting from 3.5) . This version of compiler was designed primarily for new sfall functions, but it can safely (and is recommended) to be used with non-sfall scripts as well, as long as you don’t use any of the arrays syntax and any sfall script functions. The original unmodified sslc source is over here: http://www.teamx.ru/eng/files/srcs/index.shtml. ", + "content": ". | Command line options | Additional supported syntax | Fixes | Backward compatibility | int2ssl note | . This is a modified copy of sslc, that has a few bugfixes from the original, that will recognise and compile the additional script functions provided by sfall, that can also understand some additional syntax, and that has an integrated preprocessor and optimizer. Unlike the original script compiler, this has not been compiled as a dos program. When using this in place of the original compile.exe but still using p.bat, you need to either get rid of the dos4gw.exe reference from p.bat or replace the original dos4gw.exe with the one in this archive. If you use Fallout Script Editor, you can extract compile.exe and dos4gw.exe to its \\binary folder, or extract them somewhere else and change your preferences in FSE to point there. FSE doesn’t seem to be able to tell when errors occur when using this compiler though, so I’d recommend either using sfall’s script editor instead or compiling by hand if possible. When compiling global or hook scripts for sfall 3.4 or below, you must include the line procedure start; before any #include files that define procedures to avoid a few weird problems. (this is no longer required starting from 3.5) . This version of compiler was designed primarily for new sfall functions, but it can safely (and is recommended) to be used with non-sfall scripts as well, as long as you don’t use any of the arrays syntax and any sfall script functions. The original unmodified sslc source is over here: https://teamx.ru/site_arc/utils/index.html . ", "url": "/sfall/sslc/", "relUrl": "/sslc/" },"146": { "doc": "SSLC", "title": "Command line options", - "content": "-q don't wait for input on error -n no warnings -b backward compatibility mode -l no logo -p preprocess source -O optimize code (full, see optimization.txt) -O<N> set specific level of optimization (0 - off, 1 - basic, 2 - full, 3 - experimental) -d print debug messages -D output an abstract syntax tree of the program -o set output path (follows the input file name) -s enable short-circuit evaluation for all AND, OR operators -m<macro[=val]> define a macro named \"macro\" for conditional compilation -I<path> specify an additional directory to search for include files . The original command line option -w to turn on warnings no longer has an effect, since warnings are now on by default . ", + "content": "-q don't wait for input on error -n no warnings -b backward compatibility mode -l no logo -p preprocess source -P preprocess only (don't generate .int) -F write full file paths in \"#line\" directives -O optimize code (full by default, see \"Optimization\" page) -O<N> set specific level of optimization (0 - off, 1 - basic, 2 - full, 3 - experimental) -d print debug messages -D output an abstract syntax tree of the program -o set output path (follows the input file name) -s enable short-circuit evaluation for all AND, OR operators -m<macro[=val]> define a macro named \"macro\" for conditional compilation -I<path> specify an additional directory to search for include files . The original command line option -w to turn on warnings no longer has an effect, since warnings are now on by default . ", "url": "/sfall/sslc/#command-line-options", "relUrl": "/sslc/#command-line-options" },"147": { "doc": "SSLC", "title": "Additional supported syntax", - "content": "Syntax which requires sfall for compiled scripts to be interpreted, is marked by asterix (*). | Optional arguments in user-defined procedures. You can only use constants for default values. It basically puts those constants in place of omitted arguments. | new: procedure test(variable x, variable y := 0, variable z := -1) begin ... end ... call test(\"value\"); . | old: procedure test(variable x, variable y, variable z) begin ... end ... call test(\"value\", 0, -1); . | . | New logical operators AndAlso, OrElse for short-circuit evaluation of logical expressions. Using these operators allow the right part of logical expressions not to be evaluated (executed, computed) if the result is already known. This can improve the performance of running scripts. Example: if (obj andAlso obj_pid(obj) == PID_STIMPAK) then ... If obj is null, the second condition will not be checked and your script won’t fail with “obj is null” error in debug.log . This also has an effect that a value of last computed argument is returned as a result of whole expressions, instead of always 0 (false) or 1 (true): . obj := false; display_msg(obj orElse \"something\"); // will print \"something\" . You can also use the -s option to enable short-circuit evaluation for all the AND, OR operators in the script. NOTE: Be aware that it may break some old scripts because operators behavior is changed slightly. | Conditional expressions (Python-inspired), also known as ternary operator: . | new: X := value1 if condition else value2 . | old: if (condition) then X := value1; else X := value2; . | . | To assign values, you can use the alternative assignment operator from C/Java instead of Pascal syntax. | new: x = 5; . | old: x := 5; . | . | Multiple variable declaration: Multiple variables can be declared on one line, seperated by commas. This is an alterative to the ugly begin/end block, or the bulky single variable per line style. | new: variable a, b, c; . | old: variable begin a; b; c; end . | Variable initialization with expressions: You can now initialize local variables with complex expressions instead of constants. | new: variable tile := tile_num(dude_obj); . | old: variable tile; tile := tile_num(dude_obj); . NOTE: if your expression starts with a constant (eg. 2+2), enclose it in parentheses, otherwise compiler will be confused and give you errors. | . | Hexadecimal numerical constants: Simply prefix a number with 0x to create a hexadecimal. The numbers 0 to 9 and a-f are allowed in the number. The number may not have a decimal point. | new: a := 0x1000; . | old: a := 4096; . | . | Increment/decrement operators: ++ and -- can be used as shorthand for +=1 and -=1 respectively. They are mearly a syntactic shorthand to improve readability, and so their use is only allowed where +=1 would normally be allowed. | new: a++; . | old: a += 1; . | . | break & continue statements: they work just like in most high-level languages. break jumps out of the loop. continue jumps right to the beginning of the next iteration (see for and foreach sections for additional details). | new: while (i < N) begin // ... if (/* some condition */) then break; // ... end . | old: while (i < N and not(breakFlag)) begin // ... if (/* condition */) then breakFlag := true; // ... end . | new: for (i := 0; i < N; i++) begin // ... if (/* condition */) then begin // action continue; end // else actions end . | old: for (i := 0; i < N; i++) begin // ... if (/* condition */) then begin // action end else begin // else actions end end . | . | for loops: Another piece of syntactic shorthand, to shorten while loops in many cases. Parentheses around the loop statements are recommended but not required (when not using parentheses, a semicolon is required after the 3rd loop statement). | new: for (i := 0; i < 5; i++) begin display_msg(\"i = \"+i); end . | old: i := 0; while (i < 5) do begin display_msg(\"i = \"+i); i++; end . NOTE: continue statement in a for loop will recognize increment statement (third statement in parentheses) and will execute it before jumping back to the beginning of loop. This way you will not get an endless loop. | . | switch statements: A shorthand way of writing big if then else if... blocks . | new: switch get_attack_type begin case ATKTYPE_PUNCH: display_msg(\"punch\"); case ATKTYPE_KICK: display_msg(\"kick\"); default: display_msg(\"something else\"); end . | old: variable tmp; tmp := get_attack_type; if tmp == ATKTYPE_PUNCH then begin display_msg(\"punch\"); end else if tmp == ATKTYPE_KICK then begin display_msg(\"kick\"); end else begin display_msg(\"something else\"); end . | . | empty statements in blocks are allowed: This is just a convenience to save scripters a bit of memory. Some of the macros in the fallout headers include their own semicolons while others do not. With the original compiler you had to remember which was which, and if you got it wrong the script would not compile. Now it’s always safe to include your own semicolon, even if the macro already had its own. For example, this would not compile with the original sslc, but will with the sfall edition: #define my_macro diplay_msg(\"foo\"); procedure start begin my_macro; end . | Procedure stringify operator @: designed to make callback-procedures a better option and allow for basic functional programming. Basically it replaces procedure names preceeded by @ by a string constant. Not many people know that since vanilla Fallout you can call procedures by “calling a variable” containing it’s name as a string value. There was a couple of problems using this: . | optimizer wasn’t aware that you are referencing a procedure, and could remove it, if you don’t call it explicitly (can be solved by adding making procedure “critical”) | you couldn’t see all references of a procedure from a Script Editor | it was completely not obvious that you could do such a thing, it was a confusing syntax | old: callbackVar := \"Node000\"; callbackVar(); . | new: callbackVar := @Node000; callbackVar(); . | . | *arrays: In vanilla fallout arrays had to be constructed by reserving a block of global/map variables. Since sfall 2.7, specific array targeted functions have been available, but they are fairly messy and long winded to use. The compiler provides additional syntactic shorthand for accessing and setting array variables, as well as for array creation. When declaring an array variable, put a constant integer in []’s to give the number of elements in the array. (before sfall 3.4 you had to specify size in bytes for array elements, now it’s not required, see “arrays.txt” for more information) . | new: procedure bingle begin variable a[2]; a[0] := 5; a[a[0] - 4] := a[0] + 4; display_msg(\"a[0]=\" + a[0] + \", a[1]=\" + a[1]); end . | old: procedure bingle begin variable a; a := temp_array(2, 4); set_array(a, 0, 5); set_array(a, get_array(a, 0) - 4, get_array(a, 0) + 4); display_msg(\"a[0]=\" + get_array(a, 0) + \", a[1]=\" + get_array(a, 1)); end . | . | *array expressions: sometimes you need to construct an array of elements and you will probably want to do it in just one expression. This is now possible: . | new: list := [\"A\", \"B\", \"C\", \"D\"]; . | old: list := temp_array(4, 2); list[0] := \"A\"; list[1] := \"B\"; list[2] := \"C\"; list[3] := \"D\"; . Syntax specific for associative arrays is also available. (see “arrays.txt” for full introduction to this type of arrays). | . | *map array expressions: map := {5: \"five\", 10: \"ten\", 15: \"fifteen\", 20: \"twelve\"}; . | . | “dot” syntax to access elements of associative arrays. “dot” syntax allows to work with arrays like objects: trap.radius := 3; trap.tile := tile_num(dude_obj); . You can chain dot and bracket syntax to access elements of multi-dimensional arrays: . collectionList[5].objectList[5].name += \" foo\"; . | . NOTE: when using incremental operators like +=, *=, ++, -- compiler will use additional temp variable to get an array at penultimate level in order to avoid making the same chain of “get_array” calls twice. | . | foreach loops: A shorthand method of looping over all elements in an array. Syntax is foreach (<symbol> in <expression>). | new: procedure bingle begin variable critter; foreach (critter in list_as_array(LIST_CRITTERS)) begin display_msg(\"\"+critter); end end . | old: procedure bingle begin variable begin critter; array; len; count; end array := list_as_array(LIST_CRITTERS); len := len_array(array); count := 0; while count < len do begin critter := array[count]; display_msg(\"\" + critter); end end . If you want an index array element (or key for “maps”) at each iteration, use syntax: foreach (<symbol>: <symbol> in <expression>) . foreach (pid: price in itemPriceMap) begin if (itemPid == pid) then itemPrice := price; end . If you want to add additional condition for continuing the loop, use syntax: foreach (<symbol> in <expression> while <expression>). In this case loop will iterate over elements of an array until last element or until “while” expression is true (whatever comes first). | . NOTE: just like for loop, “continue” statement will respect increments of a hidden counter variable, so you can safely use it inside foreach. | . ", + "content": "Syntax which requires sfall for compiled scripts to be interpreted is marked by asterisk (*). | Optional arguments in user-defined procedures. You can only use constants for default values. It basically puts those constants in place of omitted arguments. | new: procedure test(variable x, variable y := 0, variable z := -1) begin ... end ... call test(\"value\"); . | old: procedure test(variable x, variable y, variable z) begin ... end ... call test(\"value\", 0, -1); . | . | New logical operators AndAlso, OrElse for short-circuit evaluation of logical expressions. Using these operators allow the right part of logical expressions not to be evaluated (executed, computed) if the result is already known. This can improve the performance of running scripts. Example: if (obj andAlso obj_pid(obj) == PID_STIMPAK) then ... If obj is null, the second condition will not be checked and your script won’t fail with “obj is null” error in debug.log . This also has an effect that a value of last computed argument is returned as a result of whole expressions, instead of always false (0) or true (1): . obj := false; display_msg(obj orElse \"something\"); // will print \"something\" . You can also use the -s option to enable short-circuit evaluation for all the AND, OR operators in the script. NOTE: Be aware that it may break some old scripts because operators behavior is changed slightly. | Conditional expressions (Python-inspired), also known as ternary operator: . | new: X := value1 if condition else value2 . | old: if (condition) then X := value1; else X := value2; . | . | To assign values, you can use the alternative assignment operator from C/Java instead of Pascal syntax. | new: x = 5; . | old: x := 5; . | . | Multiple variable declaration: Multiple variables can be declared on one line, seperated by commas. This is an alterative to the ugly begin/end block, or the bulky single variable per line style. | new: variable a, b, c; . | old: variable begin a; b; c; end . | . | Variable initialization with expressions: You can now initialize local variables with complex expressions instead of constants. | new: variable tile := tile_num(dude_obj); . | old: variable tile; tile := tile_num(dude_obj); . NOTE: If your expression starts with a constant (eg. 2 + 2), enclose it in parentheses, otherwise compiler will be confused and give you errors. | . | Hexadecimal numerical constants: Simply prefix a number with 0x to create a hexadecimal. The numbers 0 to 9 and letters A to F are allowed in the number. The number may not have a decimal point. | new: a := 0x1000; . | old: a := 4096; . | . | Increment/decrement operators: ++ and -- can be used as shorthand for += 1 and -= 1 respectively. They are mearly a syntactic shorthand to improve readability, and so their use is only allowed where += 1 would normally be allowed. | new: a++; . | old: a += 1; . | . | break & continue statements: They work just like in most high-level languages. break jumps out of the loop. continue jumps right to the beginning of the next iteration (see for and foreach sections for additional details). | new: while (i < N) begin // ... if (/* some condition */) then break; // ... end . | old: while (i < N and not(breakFlag)) begin // ... if (/* condition */) then breakFlag := true; // ... end . | new: for (i := 0; i < N; i++) begin // ... if (/* condition */) then begin // action continue; end // else actions end . | old: for (i := 0; i < N; i++) begin // ... if (/* condition */) then begin // action end else begin // else actions end end . | . | for loops: Another piece of syntactic shorthand, to shorten while loops in many cases. Parentheses around the loop statements are recommended but not required (when not using parentheses, a semicolon is required after the 3rd loop statement). | new: for (i := 0; i < 5; i++) begin display_msg(\"i = \" + i); end . | old: i := 0; while (i < 5) do begin display_msg(\"i = \" + i); i++; end . NOTE: continue statement in a for loop will recognize increment statement (third statement in parentheses) and will execute it before jumping back to the beginning of loop. This way you will not get an endless loop. | . | switch statements: A shorthand way of writing big if then else if... blocks . | new: switch get_attack_type begin case ATKTYPE_PUNCH: display_msg(\"punch\"); case ATKTYPE_KICK: display_msg(\"kick\"); default: display_msg(\"something else\"); end . | old: variable tmp; tmp := get_attack_type; if tmp == ATKTYPE_PUNCH then begin display_msg(\"punch\"); end else if tmp == ATKTYPE_KICK then begin display_msg(\"kick\"); end else begin display_msg(\"something else\"); end . | . | Empty statements in blocks are allowed: This is just a convenience to save scripters a bit of memory. Some of the macros in the Fallout headers include their own semicolons while others do not. With the original compiler you had to remember which was which, and if you got it wrong the script would not compile. Now it’s always safe to include your own semicolon, even if the macro already had its own. For example, this would not compile with the original sslc, but will with the sfall edition: #define my_macro diplay_msg(\"foo\"); procedure start begin my_macro; end . NOTE: Does not work currently. | Procedure stringify operator @: Designed to make callback-procedures a better option and allow for basic functional programming. Basically it replaces procedure names preceeded by @ by a string constant. | old: callbackVar := \"Node000\"; callbackVar(); . | new: callbackVar := @Node000; callbackVar(); . Not many people know that since vanilla Fallout you can call procedures by “calling a variable” containing it’s name as a string value. There was a couple of problems using this: . | optimizer wasn’t aware that you are referencing a procedure, and could remove it, if you don’t call it explicitly (can be solved by adding making procedure critical) | you couldn’t see all references of a procedure from a Script Editor | it was completely not obvious that you could do such a thing, it was a confusing syntax | . | (*) Arrays: In vanilla Fallout, arrays had to be constructed by reserving a block of global/map variables. Since sfall 2.7, specific array targeted functions have been available, but they are fairly messy and long winded to use. The compiler provides additional syntactic shorthand for accessing and setting array variables, as well as for array creation. When declaring an array variable, put a constant integer in []` to give the number of elements in the array. (before sfall 3.4 you had to specify size in bytes for array elements, now it’s not required, see “Arrays” page for more information) . | new: procedure bingle begin variable a[2]; a[0] := 5; a[a[0] - 4] := a[0] + 4; display_msg(\"a[0]=\" + a[0] + \", a[1]=\" + a[1]); end . | old: procedure bingle begin variable a; a := temp_array(2, 4); set_array(a, 0, 5); set_array(a, get_array(a, 0) - 4, get_array(a, 0) + 4); display_msg(\"a[0]=\" + get_array(a, 0) + \", a[1]=\" + get_array(a, 1)); end . | . | (*) Array expressions: Sometimes you need to construct an array of elements and you will probably want to do it in just one expression. This is now possible: . | new: list := [\"A\", \"B\", \"C\", \"D\"]; . | old: list := temp_array(4, 2); list[0] := \"A\"; list[1] := \"B\"; list[2] := \"C\"; list[3] := \"D\"; . Syntax specific for associative arrays is also available. (see “Arrays” page for full introduction to this type of arrays). | . | (*) Map array expressions: map := {5: \"five\", 10: \"ten\", 15: \"fifteen\", 20: \"twelve\"}; . | (*) The dot . syntax to access elements of associative arrays and allow to work with arrays like objects: trap.radius := 3; trap.tile := tile_num(dude_obj); . You can chain dot and bracket syntax to access elements of multi-dimensional arrays: . collectionList[5].objectList[5].name += \" foo\"; . NOTE: When using incremental operators like +=, *=, ++, -- compiler will use additional temp variable to get an array at penultimate level in order to avoid making the same chain of get_array calls twice. | (*) foreach loops: A shorthand method of looping over all elements in an array. Syntax is foreach (<symbol> in <expression>). | new: procedure bingle begin variable critter; foreach (critter in list_as_array(LIST_CRITTERS)) begin display_msg(\"\" + critter); end end . | old: procedure bingle begin variable begin critter; array; len; count; end array := list_as_array(LIST_CRITTERS); len := len_array(array); count := 0; while count < len do begin critter := array[count]; display_msg(\"\" + critter); end end . | . If you want an index array element (or key for “maps”) at each iteration, use syntax: foreach (<symbol>: <symbol> in <expression>) . foreach (pid: price in itemPriceMap) begin if (itemPid == pid) then itemPrice := price; end . If you want to add additional condition for continuing the loop, use syntax: foreach (<symbol> in <expression> while <expression>). In this case loop will iterate over elements of an array until last element or until “while” expression is true (whatever comes first). NOTE: Just like for loop, continue statement will respect increments of a hidden counter variable, so you can safely use it inside foreach. | . ", "url": "/sfall/sslc/#additional-supported-syntax", "relUrl": "/sslc/#additional-supported-syntax" },"148": { - "doc": "SSLC", - "title": "int2ssl note", - "content": "int2ssl by Anchorite (TeamX) is included in sfall modderspack package. It was updated to support all additional opcodes of sfall, along with some syntax features. You can use it to decompile any sfall or non-sfall script. ", - "url": "/sfall/sslc/#int2ssl-note", - "relUrl": "/sslc/#int2ssl-note" - },"149": { "doc": "SSLC", "title": "Fixes", "content": ". | playmoviealpharect was using the token for playmoviealpha, breaking both functions in the process. | addbuttonflag had an entry in the token table, and could be parsed, but was missing an entry in the emit list. This resulted in the compiler accepting it as a valid function, but not outputting any code for it into the compiled script. | The function tokenize was missing an entry in the token table, and so would not be recognised by the compiler. | Fixed the check for the call \"foo\" syntax so that non-string constants will no longer be accepted. | . ", "url": "/sfall/sslc/#fixes", "relUrl": "/sslc/#fixes" - },"150": { + },"149": { "doc": "SSLC", "title": "Backward compatibility", "content": "There are several changes in this version of sslc which may result in problems for previously working scripts. A new command line option -b is available, which will turn off all new fixes and features which have the possibility of causing a previously compiling script to change its behaviour. (And only those features; anything which would not compile under the old sslc is not affected.) This includes the following: . | Since for, foreach, break, continue, in and tokenize are now hardcoded names, existing scripts that use any of them as a variable or procedure name will no longer compile. | Missing a semicolon after a variable declaration is now a hard error. (Originally sslc would check for the semicolon, but would not complain if it was missing.) | The function addbuttonflag used to be recognised by the compiler, but would not emit any code into the int file. | The function playmoviealpharect compiled as playmoviealpha. | . ", "url": "/sfall/sslc/#backward-compatibility", "relUrl": "/sslc/#backward-compatibility" + },"150": { + "doc": "SSLC", + "title": "int2ssl note", + "content": "int2ssl by Anchorite (TeamX) is included in sfall modderspack package. It was updated to support all additional opcodes of sfall, along with some syntax features. You can use it to decompile any sfall or non-sfall script. ", + "url": "/sfall/sslc/#int2ssl-note", + "relUrl": "/sslc/#int2ssl-note" },"151": { "doc": "Stats", "title": "Stats", diff --git a/audio/index.html b/audio/index.html index b86e1d8b..80b3e4d8 100644 --- a/audio/index.html +++ b/audio/index.html @@ -1,5 +1,5 @@ - Audio - sfall Audio | sfall Link Search Menu Expand Document

Audio

Functions


eax_available

int eax_available
-

play_sfall_sound

int play_sfall_sound(string file, int mode)
+     Audio - sfall       Audio | sfall                          Link      Search      Menu      Expand      Document       

Audio

Functions


eax_available

int eax_available()
+

Obsolete since sfall 2.1a. Always returns 0.


play_sfall_sound

int play_sfall_sound(string file, int mode)
 

Used to play mp3/wav/wma files. The path given is relative to the Fallout folder. Specify mode as 1 to loop the file continuously, 2 to replace the current background game music with playing the specified file in loop mode, or 0 to play the file once. If you don’t wish to loop, play_sfall_sound returns 0. If you do loop, it returns an id which can be passed back to stop_sfall_sound when you want to stop the effect. All sounds effects will be stopped on game reload, looping or not. Does not require AllowDShowSound to be set to 1 in ddraw.ini.

Starting from sfall 4.2.8/3.8.28, you can pass a value in the mode argument for a reduced sound volume. To set the volume, You need to convert the number to hexadecimal and use the argument format 0xZZZZ000Y, where ZZZZ is the volume reduction value in range from 0 to 32767 (the value 32767 is mute), and Y is the playback mode.


set_eax_environment

void set_eax_environment(int environment)
-

stop_sfall_sound

void stop_sfall_sound(int soundID)
+

Obsolete since sfall 2.1a. Has no effect.


stop_sfall_sound

void stop_sfall_sound(int soundID)
 

Stops looping mp3/wav/wma files previously launched by play_sfall_sound. All sounds effects will be stopped on game reload, looping or not. Does not require AllowDShowSound to be set to 1 in ddraw.ini.

diff --git a/feed.xml b/feed.xml index cf7dc332..b707dee5 100644 --- a/feed.xml +++ b/feed.xml @@ -1 +1 @@ -Jekyll2022-05-19T03:42:40+00:00/sfall/feed.xmlsfallSfall documentation \ No newline at end of file +Jekyll2022-05-30T13:00:13+00:00/sfall/feed.xmlsfallSfall documentation \ No newline at end of file diff --git a/index.html b/index.html index 01f8729f..cc2b174c 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ - Home - sfall Home | sfall Link Search Menu Expand Document

sfall

sfall is a set of engine modifications for the classic game Fallout 2 in the form of a DLL, which modifies executable in memory without changing anything in EXE file itself.

Engine modifications include:

  • Better support for modern operating systems
  • Externalizing many settings like starting map and game time, skills, perks, critical hit tables, books, etc.
  • Bug fixes
  • Many additional features for users, such as item highlight button, party member control, etc.
  • Extended scripting capabilities for modders (many new opcodes to control sfall features as well as previously unavailable vanilla engine functions)

Note that this is documentation for sfall specifically, not Fallout scripting in general. For vanilla function reference, refer to the wiki.

Getting started

To get started with sfall, first familiarize yourself with new concepts:

Pay special attention to the best practices page. Also, take a look at SSLC features and optimization guide.

Next, proceed to discover new functions. They are categorized, use the menu to find the one you need. If you can’t, check uncategorized functions list and sfall macros. Also, there’s search at the top of the page.

Questions and problems

  • Report bugs and suggest features on Github.
  • Ask questions and discuss on the forum.
+ Home - sfall Home | sfall Link Search Menu Expand Document

sfall

sfall is a set of engine modifications for the classic game Fallout 2 in the form of a DLL, which modifies executable in memory without changing anything in EXE file itself.

Engine modifications include:

  • Better support for modern operating systems
  • Externalizing many settings like starting map and game time, skills, perks, critical hit tables, books, etc.
  • Bug fixes
  • Many additional features for users, such as item highlight button, party member control, etc.
  • Extended scripting capabilities for modders (many new opcodes to control sfall features as well as previously unavailable vanilla engine functions)

Note that this is documentation for sfall specifically, not Fallout scripting in general. For vanilla function reference, refer to the wiki.

Getting started

To get started with sfall, first familiarize yourself with new concepts:

Pay special attention to the best practices page. Also, take a look at SSLC features and optimization guide.

Next, proceed to discover new functions. They are categorized, use the menu to find the one you need. If you can’t, check uncategorized functions list and sfall macros. Also, there’s search at the top of the page.

Questions and problems

  • Report bugs and suggest features on Github.
  • Ask questions and discuss on the forum.
diff --git a/math/index.html b/math/index.html index 4db344f3..0e50b32b 100644 --- a/math/index.html +++ b/math/index.html @@ -1,7 +1,7 @@ Math - sfall Math | sfall Link Search Menu Expand Document

Math

Functions


^

x^y
 

Exponentiation. Use as any other arithmetic operator, like 5^(1/3). If exponent is an integer, you can use a negative base, otherwise you will get “NaN” with a negative base. If both arguments are integers, the result will be an integer.


abs

int/float abs(int/float x)
 

Absolute (positive) value of x.


arctan

float arctan(float x, float y)
-

Arctangent of x. Pass 1 as y (don’t ask…).


ceil

int ceil(float)
+

Arctangent of x. Pass 1 as y (don’t ask…).


ceil

int ceil(float x)
 

Round x to the nearest integer that is not less than x.


cos

float cos(float x)
 

Cosine of x


div

div(x, y)
 

Unsigned integer division. Use as a division operator, like 3 + (20 div 5). If both dividend and divisor are integers, they will be treated as unsigned integers. If one of them is a float, div will perform the signed division just like vanilla division operator.


exponent

float exponent(float x)
diff --git a/optimization/index.html b/optimization/index.html
index f7ae9180..90b4f02e 100644
--- a/optimization/index.html
+++ b/optimization/index.html
@@ -1,37 +1,38 @@
-     Optimization - sfall       Optimization | sfall                          Link      Search      Menu      Expand      Document       

Optimization

The executation speed of scripts is not typically important in an unmodded game, given the difference in performance between a modern computer and what Fallout was designed for. When you start adding mods to the mix there’s the potential for problems again, since sfall’s global script system means that you can have a large amount of scripts being run every single frame.

sslc -O option

The sfall build of sslc supports a -O command line option to perform an optimization pass over the generated code. This isn’t a magic make-my-code-go-faster bullet; most of what it does is very limited in scope. It’s primary purpose was to strip out the procedures and variables which get automatically pulled into every script that includes define.h, whether you use them or not, and to do something about the additional variables that get created by foreach loops.

There are several levels of optimization available:

  • -O1 - Basic, only removes unreferenced globals variables and procedures, code itself remains untouched.
  • -O2 - Full, most code optimizations are on, but only those that were tested on complex scripts.
  • -O3 - Experimental, provides most efficiency, but tend to break some complex code due to bugs.

The following optimizations are performed:

  • constant expression folding: if an expression depends only on values which are known at compile time, then the expression is replaced by its result. a:=2+2; -> a:=4;
  • constant variable initialization: All variables are initialised to some value, (‘0’, if you don’t specify anything else,) so sslc attempts to make use of that fact to remove the first assignment to a variable if the first assignment is a constant expression.
    variable a;  -> variable a:=4;
    -a:=4;        -> 
    -
  • constant propagation: checks for values assigned to variables which can be computed at compile time, and replaces relevent references to the symbol by the constant. The original store is not removed by this optimization. Global variables are considered for this optimization only if they are not marked import or export, and are not assigned to anywhere in the script.
    a:=4     -> a:=4
    +     Optimization - sfall       Optimization | sfall                          Link      Search      Menu      Expand      Document       

    Optimization

    The executation speed of scripts is not typically important in an unmodded game, given the difference in performance between a modern computer and what Fallout was designed for. When you start adding mods to the mix there’s the potential for problems again, since sfall’s global script system means that you can have a large amount of scripts being run every single frame.

    sslc -O option

    The sfall build of sslc supports a -O command line option to perform an optimization pass over the generated code. This isn’t a magic make-my-code-go-faster bullet; most of what it does is very limited in scope. It’s primary purpose was to strip out the procedures and variables which get automatically pulled into every script that includes define.h, whether you use them or not, and to do something about the additional variables that get created by foreach loops.

    There are several levels of optimization available:

    • -O1 - Basic, only removes unreferenced globals variables and procedures, code itself remains untouched.
    • -O2 - Full, most code optimizations are on, but only those that were tested on complex scripts.
    • -O3 - Experimental, provides most efficiency, but tend to break some complex code due to bugs.

    The following optimizations are performed:

    • constant expression folding: if an expression depends only on values which are known at compile time, then the expression is replaced by its result.
      a := 2 + 2;  -> a := 4;
      +
    • constant variable initialization: All variables are initialised to some value, (‘0’, if you don’t specify anything else,) so sslc attempts to make use of that fact to remove the first assignment to a variable if the first assignment is a constant expression.
      variable a;  -> variable a := 4;
      +a := 4;      ->
      +
    • constant propagation: checks for values assigned to variables which can be computed at compile time, and replaces relevent references to the symbol by the constant. The original store is not removed by this optimization. Global variables are considered for this optimization only if they are not marked import or export, and are not assigned to anywhere in the script.
      a := 4;  -> a := 4;
       foo(a);  -> foo(4);
      -
    • dead code removal: Checks for and removes code which cannot be reached, either because it is hidden behind a return or because the argument to an if statement can be computed at compile time.
      if 1 then begin        -> display_msg("foo");
      +
    • dead code removal: Checks for and removes code which cannot be reached, either because it is hidden behind a return or because the argument to an if statement can be computed at compile time.
      if (True) then begin   -> display_msg("foo");
         display_msg("foo");  ->
       end else begin         ->
         display_msg("bar");  ->
       end                    ->
      -
    • unreferenced variable elimination: Checks for variables which are never referenced, and removes them. Also applies to global variables, as long as they are not marked for export.
        variable i, j, k;  -> variable i;
      -  i:=1;              -> i:=1;
      -  return;            -> return;
      +
    • unreferenced variable elimination: Checks for variables which are never referenced, and removes them. Also applies to global variables, as long as they are not marked for export.
      variable i, j, k;  -> variable i;
      +i := 1;            -> i := 1;
      +return;            -> return;
       
    • unreferenced procedure elimination: Checks for any procedures which are never called, and removes them.
      procedure foo begin return "foo"; end   -> procedure foo begin return "foo"; end
       procedure bar begin return "bar"; end   -> procedure start begin
       procedure start begin                   ->   display_msg(foo);
         display_msg(foo);                     -> end
       end                                     ->
      -
    • dead store removal: Removes variable assignments if the result of the variable is unused, and if the expression used to compute the value of the variable is provably free of side effects. (See ‘pure’ keyword)
      a:="moo";         -> a:="foo";
      -a:="foo";         -> display_msg(a);
      +
    • dead store removal: Removes variable assignments if the result of the variable is unused, and if the expression used to compute the value of the variable is provably free of side effects. (See pure keyword)
      a := "moo";       -> a := "foo";
      +a := "foo";       -> display_msg(a);
       display_msg(a);   ->
      -a:="bar";         ->
      +a := "bar";       ->
       
    • store combination: Where there are two stores in a row to the same variable, the two expressions are combined.
      var1 := var2; -> var1 := var2 + var3;
      -var1 += var3; -> 
      -
    • variable combination: Where usage regions of variables do not overlap, combine the variables to provide additional candidates for unreferenced variable elimination. Very useful for scripts containing multiple foreach loops, which generate 2 or 3 hidden variables each.
      a:="foo";         -> a:="foo";
      +var1 += var3; ->
      +
    • variable combination: Where usage regions of variables do not overlap, combine the variables to provide additional candidates for unreferenced variable elimination. Very useful for scripts containing multiple foreach loops, which generate 2 or 3 hidden variables each.
      a := "foo";       -> a := "foo";
       display_msg(a);   -> display_msg(a);
      -b:="bar";         -> a:="bar";
      +b := "bar";       -> a := "bar";
       display_msg(b);   -> display_msg(a);
      -
    • namelist compression: Fallout stores the names of all file scope variables and procedures in a namelist which is saved into the .int. Any of these that are unreferenced can be removed, and the names of global variables can be modified to make them shorter.

    Writing your own code

    • Don’t have global scripts running any more often that you need them to. Not everything needs to be run every single frame.
    • Never concat constant strings with the ‘+’ operator, as it forces the operation to be done at runtime. The compiler can cope with constant strings being placed next to each other without the need for a +, which results in far more efficient code as the combination is done at lex time.
      #define GLOB_PREFIX "ts__"                    -> #define GLOB_PREFIX "ts__"
      +
    • namelist compression: Fallout stores the names of all file scope variables and procedures in a namelist which is saved into the .int. Any of these that are unreferenced can be removed, and the names of global variables can be modified to make them shorter.

    Writing your own code

    • Don’t have global scripts running any more often that you need them to. Not everything needs to be run every single frame.

    • Never concat constant strings with the + operator, as it forces the operation to be done at runtime. The compiler can cope with constant strings being placed next to each other without the need for a +, which results in far more efficient code as the combination is done at lex time.
      #define GLOB_PREFIX "ts__"                    -> #define GLOB_PREFIX "ts__"
       
       procedure start begin                         -> procedure start begin
         set_sfall_global(GLOB_PREFIX + "foo1", 0);  ->   set_sfall_global(GLOB_PREFIX "foo1", 0);
       end                                           -> end
      -
    • Avoid function calls in while loops. function calls are expensive in comparison to variable lookups, so it’s more efficient to move the function call out of the loop and store the result in a variable
      while i < len_array(array) do begin           -> tmp:= len_array(array);
      +
    • Avoid function calls in while loops. Function calls are expensive in comparison to variable lookups, so it’s more efficient to move the function call out of the loop and store the result in a variable.
      while i < len_array(array) do begin           -> tmp := len_array(array);
         ...                                         -> while i < tmp do begin
       end                                           ->   ...
                                                     -> end
      -
    • Mark functions with pure or inline where relevent.

      ‘pure’ is a hint to the optimizer that a procedure has no side effects. (i.e. there’s no way to tell that it’s been called aside from its return value.) Pure procedures cannot modify global variables, or call any other procedure that isn’t itself pure. Functions marked with pure can only be used in expressions (i.e. you cannot use the call <procedure> syntax to call them.) If there are non-pure terms in an expression, it prevents that expression being considered for dead store removal. Where no such optimizations can be performed, or if optimization is disabled, marking a procedure with pure will have no effect on the compiled code.

      ‘inline’ is an instruction to the compiler to replace calls to the marked procedure with a copy of the procedures code instead of having a seperate call. inlined procedures cannot use the ‘return’ command, cannot be predefined, and cannot be used as part of an expression. inlining if a procedure is only going to be called once is always a win, but if there are multiple calls to a procedure you will end up bloating the size of the generated code.

    +
  • Mark functions with pure or inline where relevent.

    • pure is a hint to the optimizer that a procedure has no side effects. (i.e. there’s no way to tell that it’s been called aside from its return value.) Pure procedures cannot modify global variables, or call any other procedure that isn’t itself pure. Functions marked with pure can only be used in expressions (i.e. you cannot use the call <procedure> syntax to call them.) If there are non-pure terms in an expression, it prevents that expression being considered for dead store removal. Where no such optimizations can be performed, or if optimization is disabled, marking a procedure with pure will have no effect on the compiled code.

    • inline is an instruction to the compiler to replace calls to the marked procedure with a copy of the procedures code instead of having a seperate call. Inlined procedures cannot use the return command, cannot be predefined, and cannot be used as part of an expression. Inlining if a procedure is only going to be called once is always a win, but if there are multiple calls to a procedure you will end up bloating the size of the generated code.

diff --git a/other/index.html b/other/index.html index e7c1fb6c..fb72192d 100644 --- a/other/index.html +++ b/other/index.html @@ -24,7 +24,7 @@

message_str_game

string message_str_game(int fileId, int messageId)
 

Works exactly the same as message_str, except you get messages from files in text/english/game folder. Use GAME_MSG_* defines or mstr_* macros from sfall.h to use specific msg file

  • Additional game msg files added by ExtraGameMsgFileList setting will have consecutive fileIds assigned beginning from 0x2000 to 0x2FFF. (e.g. if you set ExtraGameMsgFileList=foo,bar in ddraw.ini, foo.msg will be associated with 0x2000 and bar.msg with 0x2001.).
  • If a file has a specific number assigned in ExtraGameMsgFileList, its fileId will be (0x2000 + assigned number). (e.g. with ExtraGameMsgFileList=foo,bar:2,foobar in ddraw.ini, bar.msg will be associated with 0x2002 and foobar.msg with 0x2003.)

mod_kill_counter

void mod_kill_counter(int critterType, int amount)
 

nb_create_char

int nb_create_char()
-

nb_* functions are reserved for the brotherhood tactical training mod, and should be avoided.


resume_game

void resume_game()
+

nb_* functions are reserved for the brotherhood tactical training mod, and should be avoided. Not implemented, always returns 0.


resume_game

void resume_game()
 

set_base_hit_chance_mod

void set_base_hit_chance_mod(int max, int mod)
 

set_base_pickpocket_mod

void set_base_pickpocket_mod(int max, int mod)
 

Changes maximum chance of success and chance mod for each steal attempt. max will replace 95% success chance cap (so you can set 100% maximum chance, for instance). mod will add this much percent to each success chance. for example if your chance is 50% and mod is 20, you will get 70% actual success rate


set_critter_hit_chance_mod

void set_critter_hit_chance_mod(CritterPtr, int max, int mod)
@@ -33,7 +33,7 @@
 

set_dm_model

void set_dm_model(string name)
 

set_hit_chance_max

void set_hit_chance_max(int percentage)
 

Effects all critters rather than just the player and can set the maximum in range from 0 to 999.


set_hp_per_level_mod

void set_hp_per_level_mod(int mod)
-

set_inven_ap_cost

void set_inven_ap_cost
+

set_inven_ap_cost

void set_inven_ap_cost(int cost)
 

set_movie_path

void set_movie_path(string filename, int movieid)
 

set_pickpocket_max

void set_pickpocket_max(int percentage)
 

Effects all critters rather than just the player and can set the maximum in range from 0 to 999.


set_pipboy_available

void set_pipboy_available(int available)
diff --git a/sslc/index.html b/sslc/index.html
index f2483acb..c7eeafcf 100644
--- a/sslc/index.html
+++ b/sslc/index.html
@@ -1,9 +1,11 @@
-     SSLC - sfall       SSLC | sfall                          Link      Search      Menu      Expand      Document       

SSLC

This is a modified copy of sslc, that has a few bugfixes from the original, that will recognise and compile the additional script functions provided by sfall, that can also understand some additional syntax, and that has an integrated preprocessor and optimizer.

Unlike the original script compiler, this has not been compiled as a dos program. When using this in place of the original compile.exe but still using p.bat, you need to either get rid of the dos4gw.exe reference from p.bat or replace the original dos4gw.exe with the one in this archive.

If you use fallout script editor, you can extract compile.exe and dos4gw.exe to its \binary folder, or extract them somewhere else and change your preferences in FSE to point there. FSE doesn’t seem to be able to tell when errors occur when using this compiler though, so I’d recommend either using sfall’s script editor instead or compiling by hand if possible.

When compiling global or hook scripts for sfall 3.4 or below, you must include the line procedure start; before any #includes that define procedures to avoid a few weird problems. (this is no longer required starting from 3.5)

This version of compiler was designed primarily for new sfall functions, but it can safely (and is recommended) to be used with non-sfall scripts as well, as long as you don’t use any of the arrays syntax and any sfall script functions.

The original unmodified sslc source is over here: http://www.teamx.ru/eng/files/srcs/index.shtml.

Command line options

-q  don't wait for input on error
+     SSLC - sfall       SSLC | sfall                          Link      Search      Menu      Expand      Document       

SSLC

This is a modified copy of sslc, that has a few bugfixes from the original, that will recognise and compile the additional script functions provided by sfall, that can also understand some additional syntax, and that has an integrated preprocessor and optimizer.

Unlike the original script compiler, this has not been compiled as a dos program. When using this in place of the original compile.exe but still using p.bat, you need to either get rid of the dos4gw.exe reference from p.bat or replace the original dos4gw.exe with the one in this archive.

If you use Fallout Script Editor, you can extract compile.exe and dos4gw.exe to its \binary folder, or extract them somewhere else and change your preferences in FSE to point there. FSE doesn’t seem to be able to tell when errors occur when using this compiler though, so I’d recommend either using sfall’s script editor instead or compiling by hand if possible.

When compiling global or hook scripts for sfall 3.4 or below, you must include the line procedure start; before any #include files that define procedures to avoid a few weird problems. (this is no longer required starting from 3.5)

This version of compiler was designed primarily for new sfall functions, but it can safely (and is recommended) to be used with non-sfall scripts as well, as long as you don’t use any of the arrays syntax and any sfall script functions.

The original unmodified sslc source is over here: https://teamx.ru/site_arc/utils/index.html

Command line options

-q  don't wait for input on error
 -n  no warnings
 -b  backward compatibility mode
 -l  no logo
 -p  preprocess source
--O  optimize code (full, see optimization.txt)
+-P  preprocess only (don't generate .int)
+-F  write full file paths in "#line" directives
+-O  optimize code (full by default, see "Optimization" page)
 -O<N> set specific level of optimization (0 - off, 1 - basic, 2 - full, 3 - experimental)
 -d  print debug messages
 -D  output an abstract syntax tree of the program
@@ -11,7 +13,7 @@
 -s  enable short-circuit evaluation for all AND, OR operators
 -m<macro[=val]> define a macro named "macro" for conditional compilation
 -I<path> specify an additional directory to search for include files
-

The original command line option -w to turn on warnings no longer has an effect, since warnings are now on by default

Additional supported syntax

Syntax which requires sfall for compiled scripts to be interpreted, is marked by asterix (*).

  • Optional arguments in user-defined procedures. You can only use constants for default values. It basically puts those constants in place of omitted arguments.

    • new:
      procedure test(variable x, variable y := 0, variable z := -1) begin
      +

      The original command line option -w to turn on warnings no longer has an effect, since warnings are now on by default

      Additional supported syntax

      Syntax which requires sfall for compiled scripts to be interpreted is marked by asterisk (*).

      • Optional arguments in user-defined procedures. You can only use constants for default values. It basically puts those constants in place of omitted arguments.

        • new:
          procedure test(variable x, variable y := 0, variable z := -1) begin
           ...
           end
           ...
          @@ -21,25 +23,25 @@ call test("value");
           end
           ...
           call test("value", 0, -1);
          -
      • New logical operators AndAlso, OrElse for short-circuit evaluation of logical expressions. Using these operators allow the right part of logical expressions not to be evaluated (executed, computed) if the result is already known. This can improve the performance of running scripts.

        Example: if (obj andAlso obj_pid(obj) == PID_STIMPAK) then ...

        If obj is null, the second condition will not be checked and your script won’t fail with “obj is null” error in debug.log

        This also has an effect that a value of last computed argument is returned as a result of whole expressions, instead of always 0 (false) or 1 (true):

        obj := false;
        +
    • New logical operators AndAlso, OrElse for short-circuit evaluation of logical expressions. Using these operators allow the right part of logical expressions not to be evaluated (executed, computed) if the result is already known. This can improve the performance of running scripts.

      Example: if (obj andAlso obj_pid(obj) == PID_STIMPAK) then ...

      If obj is null, the second condition will not be checked and your script won’t fail with “obj is null” error in debug.log

      This also has an effect that a value of last computed argument is returned as a result of whole expressions, instead of always false (0) or true (1):

      obj := false;
       display_msg(obj orElse "something");  // will print "something"
      -

      You can also use the -s option to enable short-circuit evaluation for all the AND, OR operators in the script.

      NOTE: Be aware that it may break some old scripts because operators behavior is changed slightly.

    • Conditional expressions (Python-inspired), also known as ternary operator:
      • new:
        X := value1 if condition else value2
        +

        You can also use the -s option to enable short-circuit evaluation for all the AND, OR operators in the script.

        NOTE: Be aware that it may break some old scripts because operators behavior is changed slightly.

      • Conditional expressions (Python-inspired), also known as ternary operator:
        • new:
          X := value1 if condition else value2
           
        • old:
          if (condition) then
             X := value1;
           else
             X := value2;
          -
      • To assign values, you can use the alternative assignment operator from C/Java instead of Pascal syntax.
        • new:
          x = 5;
          +
      • To assign values, you can use the alternative assignment operator from C/Java instead of Pascal syntax.
        • new:
          x = 5;
           
        • old:
          x := 5;
          -
      • Multiple variable declaration: Multiple variables can be declared on one line, seperated by commas. This is an alterative to the ugly begin/end block, or the bulky single variable per line style.
      • new:
        variable a, b, c;
        +
    • Multiple variable declaration: Multiple variables can be declared on one line, seperated by commas. This is an alterative to the ugly begin/end block, or the bulky single variable per line style.
      • new:
        variable a, b, c;
         
      • old:
        variable begin a; b; c; end
        -
      • Variable initialization with expressions: You can now initialize local variables with complex expressions instead of constants.
        • new:
          variable tile := tile_num(dude_obj);
          +
      • Variable initialization with expressions: You can now initialize local variables with complex expressions instead of constants.
        • new:
          variable tile := tile_num(dude_obj);
           
        • old:
          variable tile;
           tile := tile_num(dude_obj);
          -

          NOTE: if your expression starts with a constant (eg. 2+2), enclose it in parentheses, otherwise compiler will be confused and give you errors.

      • Hexadecimal numerical constants: Simply prefix a number with 0x to create a hexadecimal. The numbers 0 to 9 and a-f are allowed in the number. The number may not have a decimal point.
        • new:
          a := 0x1000;
          +

          NOTE: If your expression starts with a constant (eg. 2 + 2), enclose it in parentheses, otherwise compiler will be confused and give you errors.

      • Hexadecimal numerical constants: Simply prefix a number with 0x to create a hexadecimal. The numbers 0 to 9 and letters A to F are allowed in the number. The number may not have a decimal point.
        • new:
          a := 0x1000;
           
        • old:
          a := 4096;
          -
      • Increment/decrement operators: ++ and -- can be used as shorthand for +=1 and -=1 respectively. They are mearly a syntactic shorthand to improve readability, and so their use is only allowed where +=1 would normally be allowed.
        • new:
          a++;
          +
      • Increment/decrement operators: ++ and -- can be used as shorthand for += 1 and -= 1 respectively. They are mearly a syntactic shorthand to improve readability, and so their use is only allowed where += 1 would normally be allowed.
        • new:
          a++;
           
        • old:
          a += 1;
          -
      • break & continue statements: they work just like in most high-level languages. break jumps out of the loop. continue jumps right to the beginning of the next iteration (see for and foreach sections for additional details).
        • new:
          while (i < N) begin
          +
      • break & continue statements: They work just like in most high-level languages. break jumps out of the loop. continue jumps right to the beginning of the next iteration (see for and foreach sections for additional details).
        • new:
          while (i < N) begin
             // ...
             if (/* some condition */) then break;
             // ...
          @@ -66,14 +68,14 @@ end
             end
           end
           
      • for loops: Another piece of syntactic shorthand, to shorten while loops in many cases. Parentheses around the loop statements are recommended but not required (when not using parentheses, a semicolon is required after the 3rd loop statement).
        • new:
          for (i := 0; i < 5; i++) begin
          -  display_msg("i = "+i);
          +  display_msg("i = " + i);
           end
           
        • old:
          i := 0;
           while (i < 5) do begin
          -  display_msg("i = "+i);
          +  display_msg("i = " + i);
             i++;
           end
          -

          NOTE: continue statement in a for loop will recognize increment statement (third statement in parentheses) and will execute it before jumping back to the beginning of loop. This way you will not get an endless loop.

      • switch statements: A shorthand way of writing big if then else if... blocks
        • new:
          switch get_attack_type begin
          +

          NOTE: continue statement in a for loop will recognize increment statement (third statement in parentheses) and will execute it before jumping back to the beginning of loop. This way you will not get an endless loop.

      • switch statements: A shorthand way of writing big if then else if... blocks
        • new:
          switch get_attack_type begin
             case ATKTYPE_PUNCH: display_msg("punch");
             case ATKTYPE_KICK: display_msg("kick");
             default: display_msg("something else");
          @@ -87,16 +89,16 @@ end else if tmp == ATKTYPE_KICK then begin
           end else begin
             display_msg("something else");
           end
          -
      • empty statements in blocks are allowed: This is just a convenience to save scripters a bit of memory. Some of the macros in the fallout headers include their own semicolons while others do not. With the original compiler you had to remember which was which, and if you got it wrong the script would not compile. Now it’s always safe to include your own semicolon, even if the macro already had its own. For example, this would not compile with the original sslc, but will with the sfall edition:
        #define my_macro diplay_msg("foo");
        +
    • Empty statements in blocks are allowed: This is just a convenience to save scripters a bit of memory. Some of the macros in the Fallout headers include their own semicolons while others do not. With the original compiler you had to remember which was which, and if you got it wrong the script would not compile. Now it’s always safe to include your own semicolon, even if the macro already had its own. For example, this would not compile with the original sslc, but will with the sfall edition:
      #define my_macro diplay_msg("foo");
       
       procedure start begin
         my_macro;
       end
      -
    • Procedure stringify operator @: designed to make callback-procedures a better option and allow for basic functional programming. Basically it replaces procedure names preceeded by @ by a string constant. Not many people know that since vanilla Fallout you can call procedures by “calling a variable” containing it’s name as a string value. There was a couple of problems using this:
      • optimizer wasn’t aware that you are referencing a procedure, and could remove it, if you don’t call it explicitly (can be solved by adding making procedure “critical”)
      • you couldn’t see all references of a procedure from a Script Editor
      • it was completely not obvious that you could do such a thing, it was a confusing syntax
      • old:
        callbackVar := "Node000";
        +

        NOTE: Does not work currently.

      • Procedure stringify operator @: Designed to make callback-procedures a better option and allow for basic functional programming. Basically it replaces procedure names preceeded by @ by a string constant.
        • old:
          callbackVar := "Node000";
           callbackVar();
           
        • new:
          callbackVar := @Node000;
           callbackVar();
          -
      • *arrays: In vanilla fallout arrays had to be constructed by reserving a block of global/map variables. Since sfall 2.7, specific array targeted functions have been available, but they are fairly messy and long winded to use. The compiler provides additional syntactic shorthand for accessing and setting array variables, as well as for array creation. When declaring an array variable, put a constant integer in []’s to give the number of elements in the array. (before sfall 3.4 you had to specify size in bytes for array elements, now it’s not required, see “arrays.txt” for more information)
        • new:
          procedure bingle begin
          +

          Not many people know that since vanilla Fallout you can call procedures by “calling a variable” containing it’s name as a string value. There was a couple of problems using this:

        • optimizer wasn’t aware that you are referencing a procedure, and could remove it, if you don’t call it explicitly (can be solved by adding making procedure critical)
        • you couldn’t see all references of a procedure from a Script Editor
        • it was completely not obvious that you could do such a thing, it was a confusing syntax
      • (*) Arrays: In vanilla Fallout, arrays had to be constructed by reserving a block of global/map variables. Since sfall 2.7, specific array targeted functions have been available, but they are fairly messy and long winded to use. The compiler provides additional syntactic shorthand for accessing and setting array variables, as well as for array creation. When declaring an array variable, put a constant integer in []` to give the number of elements in the array. (before sfall 3.4 you had to specify size in bytes for array elements, now it’s not required, see “Arrays” page for more information)
        • new:
          procedure bingle begin
             variable a[2];
             a[0] := 5;
             a[a[0] - 4] := a[0] + 4;
          @@ -109,20 +111,20 @@ end
             set_array(a, get_array(a, 0) - 4, get_array(a, 0) + 4);
             display_msg("a[0]=" + get_array(a, 0) + ", a[1]=" + get_array(a, 1));
           end
          -
      • *array expressions: sometimes you need to construct an array of elements and you will probably want to do it in just one expression. This is now possible:
        • new:
          list := ["A", "B", "C", "D"];
          +
      • (*) Array expressions: Sometimes you need to construct an array of elements and you will probably want to do it in just one expression. This is now possible:
        • new:
          list := ["A", "B", "C", "D"];
           
        • old:
          list := temp_array(4, 2);
           list[0] := "A";
           list[1] := "B";
           list[2] := "C";
           list[3] := "D";
          -

          Syntax specific for associative arrays is also available. (see “arrays.txt” for full introduction to this type of arrays).

      • *map array expressions:
        map := {5: "five", 10: "ten", 15: "fifteen", 20: "twelve"};
        -
        • “dot” syntax to access elements of associative arrays. “dot” syntax allows to work with arrays like objects:
          trap.radius := 3;
          +

          Syntax specific for associative arrays is also available. (see “Arrays” page for full introduction to this type of arrays).

      • (*) Map array expressions:
        map := {5: "five", 10: "ten", 15: "fifteen", 20: "twelve"};
        +
      • (*) The dot . syntax to access elements of associative arrays and allow to work with arrays like objects:
        trap.radius := 3;
         trap.tile := tile_num(dude_obj);
         

        You can chain dot and bracket syntax to access elements of multi-dimensional arrays:

        collectionList[5].objectList[5].name += " foo";
        -

      NOTE: when using incremental operators like +=, *=, ++, -- compiler will use additional temp variable to get an array at penultimate level in order to avoid making the same chain of “get_array” calls twice.

      • foreach loops: A shorthand method of looping over all elements in an array. Syntax is foreach (<symbol> in <expression>).
      • new:
        procedure bingle begin
        +

        NOTE: When using incremental operators like +=, *=, ++, -- compiler will use additional temp variable to get an array at penultimate level in order to avoid making the same chain of get_array calls twice.

      • (*) foreach loops: A shorthand method of looping over all elements in an array. Syntax is foreach (<symbol> in <expression>).
        • new:
          procedure bingle begin
             variable critter;
             foreach (critter in list_as_array(LIST_CRITTERS)) begin
          -    display_msg(""+critter);
          +    display_msg("" + critter);
             end
           end
           
        • old:
          procedure bingle begin
          @@ -135,8 +137,8 @@ end
               display_msg("" + critter);
             end
           end
          -

          If you want an index array element (or key for “maps”) at each iteration, use syntax: foreach (<symbol>: <symbol> in <expression>)

          foreach (pid: price in itemPriceMap) begin
          -if (itemPid == pid) then
          -  itemPrice := price;
          +

        If you want an index array element (or key for “maps”) at each iteration, use syntax: foreach (<symbol>: <symbol> in <expression>)

        foreach (pid: price in itemPriceMap) begin
        +  if (itemPid == pid) then
        +    itemPrice := price;
         end
        -

        If you want to add additional condition for continuing the loop, use syntax: foreach (<symbol> in <expression> while <expression>). In this case loop will iterate over elements of an array until last element or until “while” expression is true (whatever comes first).

      NOTE: just like for loop, “continue” statement will respect increments of a hidden counter variable, so you can safely use it inside foreach.

    int2ssl note

    int2ssl by Anchorite (TeamX) is included in sfall modderspack package. It was updated to support all additional opcodes of sfall, along with some syntax features. You can use it to decompile any sfall or non-sfall script.

    Fixes

    • playmoviealpharect was using the token for playmoviealpha, breaking both functions in the process.
    • addbuttonflag had an entry in the token table, and could be parsed, but was missing an entry in the emit list. This resulted in the compiler accepting it as a valid function, but not outputting any code for it into the compiled script.
    • The function tokenize was missing an entry in the token table, and so would not be recognised by the compiler.
    • Fixed the check for the call "foo" syntax so that non-string constants will no longer be accepted.

    Backward compatibility

    There are several changes in this version of sslc which may result in problems for previously working scripts. A new command line option -b is available, which will turn off all new fixes and features which have the possibility of causing a previously compiling script to change its behaviour. (And only those features; anything which would not compile under the old sslc is not affected.) This includes the following:

    • Since for, foreach, break, continue, in and tokenize are now hardcoded names, existing scripts that use any of them as a variable or procedure name will no longer compile.
    • Missing a semicolon after a variable declaration is now a hard error. (Originally sslc would check for the semicolon, but would not complain if it was missing.)
    • The function addbuttonflag used to be recognised by the compiler, but would not emit any code into the int file.
    • The function playmoviealpharect compiled as playmoviealpha.
+

If you want to add additional condition for continuing the loop, use syntax: foreach (<symbol> in <expression> while <expression>). In this case loop will iterate over elements of an array until last element or until “while” expression is true (whatever comes first).

NOTE: Just like for loop, continue statement will respect increments of a hidden counter variable, so you can safely use it inside foreach.

Fixes

  • playmoviealpharect was using the token for playmoviealpha, breaking both functions in the process.
  • addbuttonflag had an entry in the token table, and could be parsed, but was missing an entry in the emit list. This resulted in the compiler accepting it as a valid function, but not outputting any code for it into the compiled script.
  • The function tokenize was missing an entry in the token table, and so would not be recognised by the compiler.
  • Fixed the check for the call "foo" syntax so that non-string constants will no longer be accepted.

Backward compatibility

There are several changes in this version of sslc which may result in problems for previously working scripts. A new command line option -b is available, which will turn off all new fixes and features which have the possibility of causing a previously compiling script to change its behaviour. (And only those features; anything which would not compile under the old sslc is not affected.) This includes the following:

  • Since for, foreach, break, continue, in and tokenize are now hardcoded names, existing scripts that use any of them as a variable or procedure name will no longer compile.
  • Missing a semicolon after a variable declaration is now a hard error. (Originally sslc would check for the semicolon, but would not complain if it was missing.)
  • The function addbuttonflag used to be recognised by the compiler, but would not emit any code into the int file.
  • The function playmoviealpharect compiled as playmoviealpha.

int2ssl note

int2ssl by Anchorite (TeamX) is included in sfall modderspack package. It was updated to support all additional opcodes of sfall, along with some syntax features. You can use it to decompile any sfall or non-sfall script.