The set_stat_max/min functions can be used to set the valid ranges on stats. Values returned by get_current_stat will be clamped to this range. The set_pc_ function only affects the player, the set_npc_ functions only affects other critters, and the set_ functions affects both.
The set_stat_max/min functions can be used to set the valid ranges on stats. Values returned by get_current_stat will be clamped to this range. The set_pc_ function only affects the player, the set_npc_ functions only affects other critters, and the set_ functions affects both.
voidreg_anim_animate_and_hide(ObjectPtr,intanimID,intdelay)
+ Animations | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Given object is destroyed at the end of current animation set.
reg_anim_light
voidreg_anim_light(ObjectPtr,intlight,intdelay)
Change light of any object. Light argument is a light radius (0-8), but you can use highest 2 bytes to pass light intensity as well (example: 0xFFFF0008 - intensity 65535 and radius 8). If highest 2 bytes are 0, intensity will not be changed. Intensity range is from 0 to 65535 (0xFFFF)
Don’t use it directly; it is generated by the compiler in foreach loops.
for lists, returns index back (no change).
for maps, returns a key at the specified numeric index (don’t rely on the order in which keys are stored though).
can be checked if given array is associative or not, by using index (-1): 0 - array is list, 1 - array is map.
arrayexpr
intarrayexpr(mixedkey,mixedvalue)
Don’t use it directly; it is used by compiler to create array expressions.
assigns value to a given key in an array, created by last create_array or temp_array call.
always returns 0.
create_array
intcreate_array(intsize,intnothing)
Creates permanent array (but not “saved”).
if size >= 0, creates list with given size.
if size == -1, creates map (associative array).
if size == -1 and flags == 2, creates a “lookup” map (associative array) in which the values of existing keys are read-only and can’t be updated. This type of array allows you to store a zero (0) key value.
returns array ID (valid until array is deleted).
fix_array
voidfix_array(intarrayID)
@@ -11,4 +11,4 @@
Makes the array saveable; it will be saved in sfallgv.sav file when saving the game.
array ID is associated with given “key”.
array becomes permanent (if it was temporary) and “saved”.
key can be of any type (int, float or string).
if you specify 0 as the key for the array ID, it will make the array “unsaved”.
scan_array
mixedscan_array(intarrayID,mixedvalue)
Searches for a first occurence of given value inside given array.
if value is found, returns its index (for lists) or key (for maps).
if value is not found, returns -1 (be careful, as -1 can be a valid key for a map).
set_array
voidset_array(intarrayID,mixedkey,mixedvalue)
Sets array value (shorthand: arrayID[key] := value).
if used on list, “key” must be numeric and within valid index range (0..size-1)
if used on map, key can be of any type
to “unset” a value from map, just set it to zero (0)
NOTE: to add a value of 0 for the key, use the float value of 0.0
temp_array
inttemp_array(intsize,intnothing)
-
Works exactly like create_array, only created array becomes “temporary”.
+
Works exactly like create_array, only created array becomes “temporary”.
diff --git a/arrays/index.html b/arrays/index.html
index ae572a74..758f86be 100644
--- a/arrays/index.html
+++ b/arrays/index.html
@@ -1,4 +1,4 @@
- Arrays | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
sfall introduces new method of storing variables - arrays.
Array is basically a container which can store variable number of values (elements). Each element in array can be of any type. Arrays can be extremely useful for some more advanced scripting, in conjunction with loops. See array function reference here.
sfall introduces new method of storing variables - arrays.
Array is basically a container which can store variable number of values (elements). Each element in array can be of any type. Arrays can be extremely useful for some more advanced scripting, in conjunction with loops. See array function reference here.
Array elements are accessed by index or key. For example:
// this code puts some string in array "list" at index 5:list[5]:="Value";
There are 2 different types of arrays currently available:
Lists - a set of values with specific size (number of elements), where all elements have numeric indexes starting from zero (0) up to array length minus one.
For example:
// this creates list with 3 elements. Element "A" has index 0, element "B" has index 1, element "C" - 2list:=["A","B","C"];
@@ -64,4 +64,4 @@
// kaboom!!!endend
-
Array operators reference
*mixed means any type
int create_array(int size, int flags):
creates permanent array (but not “saved”)
if size >= 0, creates list with given size
if size == -1, creates map (associative array)
if size == -1 and flags == 2, creates a “lookup” map (associative array) in which the values of existing keys are read-only and can’t be updated. This type of array allows you to store a zero (0) key value
NOTE: in earlier versions (up to 4.1.3/3.8.13) the second argument is not used, just use 0
returns arrayID (valid until array is deleted)
int temp_array(int size, int flags):
works exactly like create_array, only created array becomes “temporary”
void fix_array(int arrayID):
changes “temporary” array into “permanent” (“permanent” arrays are not automatically saved into savegames)
if used on list, “key” must be numeric and within valid index range (0..size-1)
if used on map, key can be of any type
to “unset” a value from map, just set it to zero (0)
NOTE: to add a value of 0 for the key, use the float value of 0.0
this works exactly like statement: arrayID[key] := value;
mixed get_array(int arrayID, mixed key):
returns array value by key or index
if key doesn’t exist or index is not in valid range, returns 0
works exactly like expression: (arrayID[key])
void resize_array(int arrayID, int size):
changes array size
applicable to maps too, but only to reduce elements
there are number of special negative values of “size” which perform various operations on the array, use macros sort_array, sort_array_reverse, reverse_array, shuffle_array from sfall.h header
void free_array(int arrayID):
deletes any array
if array was “saved”, it will be removed from a savegame
mixed scan_array(int arrayID, mixed value):
searches for a first occurrence of given value inside given array
if value is found, returns it’s index (for lists) or key (for maps)
if value is not found, returns -1 (be careful, as -1 can be a valid key for a map)
int len_array(int arrayID):
returns number of elements or key=>value pairs in a given array
if array is not found, returns -1 (can be used to check if given array exist)
void save_array(mixed key, int arrayID):
makes the array saveable; it will be saved in sfallgv.sav file when saving the game
arrayID is associated with given “key”
array becomes permanent (if it was temporary) and “saved”
key can be of any type (int, float or string)
if you specify 0 as the key for the array ID, it will make the array “unsaved”
int load_array(mixed key):
loads array from savegame data by the same key provided in save_array
returns array ID or zero (0) if none found
mixed array_key(int arrayID, int index):
don’t use it directly; it is generated by the compiler in foreach loops
for lists, returns index back (no change)
for maps, returns a key at the specified numeric index (don’t rely on the order in which keys are stored though)
can be checked if given array is associative or not, by using index (-1): 0 - array is list, 1 - array is map
int arrayexpr(mixed key, mixed value):
don’t use it directly; it is used by compiler to create array expressions
assigns value to a given key in an array, created by last create_array or temp_array call
always returns 0
Backward compatibility notes
For those who used arrays in their mods before sfall 3.4:
There is an INI parameter ArraysBehavior in Misc section of ddraw.ini. If set to 0, all scripts which used sfall arrays before should work. This basically changes that create_array will create permanent arrays which are “saved” by default and their IDs are also permanent. It is 1 by default.
NOTE: Starting from sfall 4.3.3/3.8.33, the ArraysBehavior option is removed, and arrays always work in ArraysBehavior=1 mode. Make sure to review your scripts if you need to save arrays into savegames.
How savegame compatibility is handled? Saved arrays are stored in sfallgv.sav file (in savegame) in new (more flexible) format, just after the old arrays. So basically, when you load older savegame, sfall will load arrays from old format and save them to new format on next game save. If you load savegame made with sfall 3.4 using sfall 3.3 (for example), the game shouldn’t crash, but all arrays will be lost.
Previously you had to specify size in bytes for array elements. This parameter is now ignored and you can store strings of arbitrary length in arrays.
if size == -1 and flags == 2, creates a “lookup” map (associative array) in which the values of existing keys are read-only and can’t be updated. This type of array allows you to store a zero (0) key value
NOTE: in earlier versions (up to 4.1.3/3.8.13) the second argument is not used, just use 0
returns arrayID (valid until array is deleted)
int temp_array(int size, int flags):
works exactly like create_array, only created array becomes “temporary”
void fix_array(int arrayID):
changes “temporary” array into “permanent” (“permanent” arrays are not automatically saved into savegames)
if used on list, “key” must be numeric and within valid index range (0..size-1)
if used on map, key can be of any type
to “unset” a value from map, just set it to zero (0)
NOTE: to add a value of 0 for the key, use the float value of 0.0
this works exactly like statement: arrayID[key] := value;
mixed get_array(int arrayID, mixed key):
returns array value by key or index
if key doesn’t exist or index is not in valid range, returns 0
works exactly like expression: (arrayID[key])
void resize_array(int arrayID, int size):
changes array size
applicable to maps too, but only to reduce elements
there are number of special negative values of “size” which perform various operations on the array, use macros sort_array, sort_array_reverse, reverse_array, shuffle_array from sfall.h header
void free_array(int arrayID):
deletes any array
if array was “saved”, it will be removed from a savegame
mixed scan_array(int arrayID, mixed value):
searches for a first occurrence of given value inside given array
if value is found, returns it’s index (for lists) or key (for maps)
if value is not found, returns -1 (be careful, as -1 can be a valid key for a map)
int len_array(int arrayID):
returns number of elements or key=>value pairs in a given array
if array is not found, returns -1 (can be used to check if given array exist)
void save_array(mixed key, int arrayID):
makes the array saveable; it will be saved in sfallgv.sav file when saving the game
arrayID is associated with given “key”
array becomes permanent (if it was temporary) and “saved”
key can be of any type (int, float or string)
if you specify 0 as the key for the array ID, it will make the array “unsaved”
int load_array(mixed key):
loads array from savegame data by the same key provided in save_array
returns array ID or zero (0) if none found
mixed array_key(int arrayID, int index):
don’t use it directly; it is generated by the compiler in foreach loops
for lists, returns index back (no change)
for maps, returns a key at the specified numeric index (don’t rely on the order in which keys are stored though)
can be checked if given array is associative or not, by using index (-1): 0 - array is list, 1 - array is map
int arrayexpr(mixed key, mixed value):
don’t use it directly; it is used by compiler to create array expressions
assigns value to a given key in an array, created by last create_array or temp_array call
always returns 0
Backward compatibility notes
For those who used arrays in their mods before sfall 3.4:
There is an INI parameter ArraysBehavior in Misc section of ddraw.ini. If set to 0, all scripts which used sfall arrays before should work. This basically changes that create_array will create permanent arrays which are “saved” by default and their IDs are also permanent. It is 1 by default.
NOTE: Starting from sfall 4.3.3/3.8.33, the ArraysBehavior option is removed, and arrays always work in ArraysBehavior=1 mode. Make sure to review your scripts if you need to save arrays into savegames.
How savegame compatibility is handled? Saved arrays are stored in sfallgv.sav file (in savegame) in new (more flexible) format, just after the old arrays. So basically, when you load older savegame, sfall will load arrays from old format and save them to new format on next game save. If you load savegame made with sfall 3.4 using sfall 3.3 (for example), the game shouldn’t crash, but all arrays will be lost.
Previously you had to specify size in bytes for array elements. This parameter is now ignored and you can store strings of arbitrary length in arrays.
diff --git a/art-and-appearance/index.html b/art-and-appearance/index.html
index 9d7937a1..a4984319 100644
--- a/art-and-appearance/index.html
+++ b/art-and-appearance/index.html
@@ -1,6 +1,6 @@
- Art and appearance | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Clears the cache of FRM image files loaded into memory.
art_exists
intart_exists(intartFID)
checks if given artFID exists in the game. Useful when you want to check if critter can use specific weapon: art_exists((artFid bwand 0xffff0fff) bwor (weaponAnim * 0x1000)).
refresh_pc_art
voidrefresh_pc_art
set_hero_race
voidset_hero_race(intstyle)
set_hero_style
voidset_hero_style(intstyle)
-
+
diff --git a/audio/index.html b/audio/index.html
index b77dfd95..1c298481 100644
--- a/audio/index.html
+++ b/audio/index.html
@@ -1,5 +1,5 @@
- Audio | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
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
voidset_eax_environment(intenvironment)
Obsolete since sfall 2.1a. Has no effect.
stop_sfall_sound
voidstop_sfall_sound(intsoundID)
-
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.
+
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/best-practices/index.html b/best-practices/index.html
index a1a5db48..f2fc0cec 100644
--- a/best-practices/index.html
+++ b/best-practices/index.html
@@ -1,4 +1,4 @@
- Best practices | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
If it can be done in a global script, do it in a global script. Combined with hooks, they are extremely powerful, possibilities ranging from creating new perks to UI scripting to prototype altering on-the-fly. While scripting does take a bit longer to get started, and hacking prototypes directly with GUI programs might look easier at first, consider that:
Scripts from different mods modifying the same thing can actually be compatible with each other. Binary files can’t.
Scripts can be version controlled and thus are much more easier to maintain.
If you’re using set_sfall_return, always couple it with set_sfall_arg for the corresponding arg(s), unless you have a specific reason not to. Detailed explanation is available here.
Pick yourself a 2-3 character modding prefix. Use it for:
global script names
global variable names and saved array names
debug messages
This will ensure (to some degree), that another mod doesn’t overwrite your scripts, doesn’t mess with your global variables, and that debug messages coming from your scripts can be distinguished easily.
For example, if you pick prefix “a_”, your script could be named gl_a_myscript.int, and might look like this:
#defineNAME"gl_a_myscript"
+ Best practices | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
If it can be done in a global script, do it in a global script. Combined with hooks, they are extremely powerful, possibilities ranging from creating new perks to UI scripting to prototype altering on-the-fly. While scripting does take a bit longer to get started, and hacking prototypes directly with GUI programs might look easier at first, consider that:
Scripts from different mods modifying the same thing can actually be compatible with each other. Binary files can’t.
Scripts can be version controlled and thus are much more easier to maintain.
If you’re using set_sfall_return, always couple it with set_sfall_arg for the corresponding arg(s), unless you have a specific reason not to. Detailed explanation is available here.
Pick yourself a 2-3 character modding prefix. Use it for:
global script names
global variable names and saved array names
debug messages
This will ensure (to some degree), that another mod doesn’t overwrite your scripts, doesn’t mess with your global variables, and that debug messages coming from your scripts can be distinguished easily.
For example, if you pick prefix “a_”, your script could be named gl_a_myscript.int, and might look like this:
Do not abuse set_global_script_repeat. Whenever possible, register your script as a hook instead. You can register the same procedure at multiple hook points, if necessary.
If you have set_global_script_repeat(300) in your script, you’re probably doing something wrong. That’s an invocation every 3-5 seconds, approximately.
If you have set_global_script_repeat(30), you are definitely doing something wrong. Look for suitable hooks harder, think of another way for implementing it, ask fellow modders for help.
+
Performance
Do not abuse set_global_script_repeat. Whenever possible, register your script as a hook instead. You can register the same procedure at multiple hook points, if necessary.
If you have set_global_script_repeat(300) in your script, you’re probably doing something wrong. That’s an invocation every 3-5 seconds, approximately.
If you have set_global_script_repeat(30), you are definitely doing something wrong. Look for suitable hooks harder, think of another way for implementing it, ask fellow modders for help.
diff --git a/call_offset_vx/index.html b/call_offset_vx/index.html
index 3ede4a27..296f1e0d 100644
--- a/call_offset_vx/index.html
+++ b/call_offset_vx/index.html
@@ -1,4 +1,4 @@
- call_offset_vX | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Can be used to call arbitrary functions inside Fallout. Different versions are used to call functions with different numbers of arguments. None of these functions will work unlessAllowUnsafeScriptingis enabled inddraw.ini.
Can be used to call arbitrary functions inside Fallout. Different versions are used to call functions with different numbers of arguments. None of these functions will work unlessAllowUnsafeScriptingis enabled inddraw.ini.
Returns the current amount of fuel in player’s car (between 0 and 80000). To change fuel amount, use vanilla function: metarule(METARULE_GIVE_CAR_GAS, amount) - amount can be positive or negative.
set_car_current_town
voidset_car_current_town(inttown)
Changes the current town index for the player’s car.
set_car_intface_art
sfall.h
voidset_car_intface_art(intartIndex)
-
Changes the interface art (index in intrface.lst) for the car image on the world map interface
Should be called before going to the world map
Vanilla art index is 433
+
Changes the interface art (index in intrface.lst) for the car image on the world map interface
Should be called before going to the world map
Vanilla art index is 433
diff --git a/combat/index.html b/combat/index.html
index c3ecbd2a..9b5c7183 100644
--- a/combat/index.html
+++ b/combat/index.html
@@ -1,4 +1,4 @@
- Combat | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Returns 1 if the aimed attack mode is selected, 0 otherwise.
block_combat
voidblock_combat(boolvalue)
Deny the player to enter combat mode.
combat_data
mixedcombat_data
returns a pointer to the C_ATTACK_* data for the current combat attack process (see defined constants in define_extra.h)
can be used in conjunction with the get_object_data and set_object_data functions example: sfall_func3("set_object_data", sfall_func0("combat_data"), C_ATTACK_UNUSED, 255);
disable_aimed_shots
voiddisable_aimed_shots(intpid)
@@ -17,4 +17,4 @@
Used for modifying the critical table. For details see critical hit tables. Changes are not saved, and will reset to the defaults (or to the contents of CriticalOverrides.ini, if it exists) at each game reload. Requires OverrideCriticalTable to be enabled in ddraw.ini (already enabled by default).
Allows changing the multipliers and divisors for the bullet distribution of burst attacks dynamically. All settings are automatically reset to default values (i.e. ComputeSpray_* settings in ddraw.ini) after each attack action
Should be called before the calculation of the bullet distribution (e.g. in HOOK_TOHIT or HOOK_AMMOCOST)
centerDiv/targetDiv: the minimum value of divisor is 1
centerMult/targetMult: multiplier values are capped at divisor values
NOTE: refer to the description of ComputeSpray_* settings in ddraw.ini for details of the bullet distribution of burst attacks
+
Allows changing the multipliers and divisors for the bullet distribution of burst attacks dynamically. All settings are automatically reset to default values (i.e. ComputeSpray_* settings in ddraw.ini) after each attack action
Should be called before the calculation of the bullet distribution (e.g. in HOOK_TOHIT or HOOK_AMMOCOST)
centerDiv/targetDiv: the minimum value of divisor is 1
centerMult/targetMult: multiplier values are capped at divisor values
NOTE: refer to the description of ComputeSpray_* settings in ddraw.ini for details of the bullet distribution of burst attacks
diff --git a/cursor/index.html b/cursor/index.html
index c95ce4eb..411b5a7c 100644
--- a/cursor/index.html
+++ b/cursor/index.html
@@ -1,3 +1,3 @@
- Cursor | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
makes the specified item (pid) an explosive item like Dynamite or Plastic Explosives
maxDamage is optional
activePid is for an item with an active timer, can be the same as the pid argument
the item proto must be the Misc Item type and have the Use action flag
minDamage/maxDamage are the minimum and maximum explosion damage
using the function on an item that is already set as an explosive will override its previous settings
NOTE: this function does not work for pids of Dynamite and Plastic Explosives
metarule2_explosions
intmetarule2_explosions(intarg1,intarg2)
Was made as a quick-and-dirty hack to enable dynamic changes to some explosion parameters for ranged attacks. All changed parameters are automatically reset to vanilla state after each attack action.
set_attack_explosion_art
sfall.h
voidset_attack_explosion_art(x,y)
@@ -9,4 +9,4 @@
Sets the minimum and maximum damage for Dynamite. Changed damage will be reset each time the player reloads the game.
set_explosion_max_targets
sfall.h
voidset_explosion_max_targets(x)
Sets the maximum number of additional targets for an explosion, valid range: 1..6 (default is 6).
set_explosion_radius
sfall.h
voidset_explosion_radius(grenade,rocket)
Sets a permanent radius of the explosion for grenades and/or rockets. Passing 0 means not changing the corresponding radius. Changed radius will be reset each time the player reloads the game.
set_plastic_damage
sfall.h
voidset_plastic_damage(minDmg,maxDmg)
-
Sets the minimum and maximum damage for Plastic Explosives. Changed damage will be reset each time the player reloads the game.
+
Sets the minimum and maximum damage for Plastic Explosives. Changed damage will be reset each time the player reloads the game.
diff --git a/feed.xml b/feed.xml
index 9e6ec6b5..2e243238 100644
--- a/feed.xml
+++ b/feed.xml
@@ -1 +1 @@
-Jekyll2026-01-01T12:25:00+00:00/sfall/feed.xmlsfallSfall documentation
\ No newline at end of file
+Jekyll2026-01-03T12:58:48+00:00/sfall/feed.xmlsfallSfall documentation
\ No newline at end of file
diff --git a/funcx/index.html b/funcx/index.html
index 4da8bf6a..9610817a 100644
--- a/funcx/index.html
+++ b/funcx/index.html
@@ -1,4 +1,4 @@
- funcX | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Only has an effect on the script it is called from. Every global script needs its own game_loaded block to correctly set up repeat rate. Will have no effect if called on a non-global script.
set_global_script_type
voidset_global_script_type(inttype)
-
Only has an effect on the script it is called from. Every global script needs its own game_loaded block to correctly set up the script type.
(DEPRECATED) Using type 1 requires the input wrapper to be enabled. Use available_global_script_types to check what is available.
+
Only has an effect on the script it is called from. Every global script needs its own game_loaded block to correctly set up the script type.
(DEPRECATED) Using type 1 requires the input wrapper to be enabled. Use available_global_script_types to check what is available.
diff --git a/global-scripts/index.html b/global-scripts/index.html
index c89af467..d89d38ee 100644
--- a/global-scripts/index.html
+++ b/global-scripts/index.html
@@ -1 +1 @@
- Global scripts | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
As well as the new functions, sfall also adds global scripts. These run independent of any loaded maps, but do not have an attached object (i.e. using self_obj without using set_self first will crash the script).
To use a global script, the script must have a name which begins with gl and contains a procedure called start, map_enter_p_proc, map_exit_p_proc, or map_update_p_proc. The start procedure will be executed once when the player loads a saved game or starts a new game. The map_*_p_proc procedures will be executed once when a map is being entered/left/updated. If you wish the script to be executed repeatedly, call set_global_script_repeat on the first run of the start procedure using the number of frames between each run as the argument (0 disables the script, 1 runs it every frame, 2 runs it every other frame etc.).
Global scripts have multiple modes, which can be set using the set_global_script_type function.
In the default mode (i.e. mode 0) their execution is linked to the local map game loop, so the script will not run in dialogs or on the world map.
In mode 1 their execution is linked to the player input, and so they will run whenever the mouse cursor is visible on screen, including the world map, character dialogs etc.
In mode 2, execution is linked to the world map loop, so the script will only be executed on the world map and not on the local map or in any dialog windows.
Mode 3 is a combination of modes 0 and 2, so scripts will be executed on both local maps and the world map, but not in dialog windows.
+ Global scripts | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
As well as the new functions, sfall also adds global scripts. These run independent of any loaded maps, but do not have an attached object (i.e. using self_obj without using set_self first will crash the script).
To use a global script, the script must have a name which begins with gl and contains a procedure called start, map_enter_p_proc, map_exit_p_proc, or map_update_p_proc. The start procedure will be executed once when the player loads a saved game or starts a new game. The map_*_p_proc procedures will be executed once when a map is being entered/left/updated. If you wish the script to be executed repeatedly, call set_global_script_repeat on the first run of the start procedure using the number of frames between each run as the argument (0 disables the script, 1 runs it every frame, 2 runs it every other frame etc.).
Global scripts have multiple modes, which can be set using the set_global_script_type function.
In the default mode (i.e. mode 0) their execution is linked to the local map game loop, so the script will not run in dialogs or on the world map.
In mode 1 their execution is linked to the player input, and so they will run whenever the mouse cursor is visible on screen, including the world map, character dialogs etc.
In mode 2, execution is linked to the world map loop, so the script will only be executed on the world map and not on the local map or in any dialog windows.
Mode 3 is a combination of modes 0 and 2, so scripts will be executed on both local maps and the world map, but not in dialog windows.
diff --git a/global-variables/index.html b/global-variables/index.html
index 35c75e47..6e007730 100644
--- a/global-variables/index.html
+++ b/global-variables/index.html
@@ -1,4 +1,4 @@
- Global variables | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
These functions require an EXACTLY 8 characters long, case sensitive string for the variable name. The variables behave the same as normal Fallout globals, except that they don’t have to be declared beforehand in vault13.gam. Trying to get a variable which hasn’t been set will always return 0. The functions are intended for use when a patch to a mod requires the addition of a new global variable, a case which would otherwise require the player to start a new game.
These functions require an EXACTLY 8 characters long, case sensitive string for the variable name. The variables behave the same as normal Fallout globals, except that they don’t have to be declared beforehand in vault13.gam. Trying to get a variable which hasn’t been set will always return 0. The functions are intended for use when a patch to a mod requires the addition of a new global variable, a case which would otherwise require the player to start a new game.
The graphics functions are only available if the user is using graphics mode 4 or 5. Use graphics_funcs_available to check; it returns 1 if you can use them or 0 if you can’t. Calling graphics functions when graphics_funcs_available returns 0 will do nothing.
The graphics functions are only available if the user is using graphics mode 4 or 5. Use graphics_funcs_available to check; it returns 1 if you can use them or 0 if you can’t. Calling graphics functions when graphics_funcs_available returns 0 will do nothing.
Forces the screen to redraw at times when it normally wouldn’t. If you’re using animated shader, turning this option on is recommended.
free_shader
voidfree_shader(intID)
@@ -14,4 +14,4 @@
set_shader_mode
voidset_shader_mode(intmode)
Tells sfall when to use a shader. The parameter is a set of 32 flags which specify the screens on which the shader will be disabled, unless bit 32 is set, in which case the shader will only be active on those screens. Remember that screens are displayed on top of each other; if the player opens the character menu which in combat, the game still considers the player to be in combat. See sfall.h for a list of defines.
Gets the next argument from sfall. Each time it’s called it returns the next argument, or otherwise it returns 0 if there are no more arguments left. You can arbitrarily get the value of any argument using the sfall_func1("get_sfall_arg_at", argNum) function.
get_sfall_arg_at
sfall.h
mixedget_sfall_arg_at(intargNum)
Gets the value of hook argument with the specified argument number (first argument of hook starts from 0)
get_sfall_args
intget_sfall_args()
Returns all hook arguments as a new temp array.
init_hook
intinit_hook()
@@ -13,4 +13,4 @@
So if you combine both mods together, they will run in chain and the end result will be a 75% from original hit chance (hook register order doesn’t matter in this case, if you use set_sfall_arg in both hooks).
Works the same as register_hook_proc, except that it registers the current script at the end of the hook script execution chain (i.e. the script will be executed after all previously registered scripts for the same hook, including the hs_<name>.int script). In addition, all scripts hooked to a single hook point with this function are executed in the exact order of how they were registered. In the case of using register_hook and register_hook_proc functions, scripts are executed in reverse order of how they were registered. The execution chain of script procedures for a hook is as follows: 1. Procedures registered with register_hook and register_hook_proc functions (executed in reverse order of registration). 2. The hs_<name>.int script. 3. Procedures registered with the register_hook_proc_spec function (executed in the exact order of registration).
set_sfall_arg
voidset_sfall_arg(intargNum,intvalue)
Changes argument value. The argument number (argNum) is 0-indexed. This is useful if you have several hook scripts attached to one hook point (see register_hook_proc).
set_sfall_return
voidset_sfall_return(anyvalue)
-
Used to return the new values from the script. Each time it’s called it sets the next value, or if you’ve already set all return values it does nothing.
+
Used to return the new values from the script. Each time it’s called it sets the next value, or if you’ve already set all return values it does nothing.
diff --git a/hook-types/index.html b/hook-types/index.html
index 96d01ceb..a8a7a0f2 100644
--- a/hook-types/index.html
+++ b/hook-types/index.html
@@ -1,4 +1,4 @@
- Hook types | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Runs after calculating character figure FID on the inventory screen, whenever the game decides that character appearance might change. Also happens on other screens, like barter.
NOTE: FID has following format: 0x0ABBCDDD, where: A - object type, BB - animation code (always 0 in this case), C - weapon code, DDD - FRM index in LST file.
int arg0 - the vanilla FID calculated by the engine according to critter base FID and armor/weapon being used
+ Hook types | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Runs after calculating character figure FID on the inventory screen, whenever the game decides that character appearance might change. Also happens on other screens, like barter.
NOTE: FID has following format: 0x0ABBCDDD, where: A - object type, BB - animation code (always 0 in this case), C - weapon code, DDD - FRM index in LST file.
int arg0 - the vanilla FID calculated by the engine according to critter base FID and armor/weapon being used
int arg1 - the modified FID calculated by the internal sfall code (like Hero Appearance Mod)
int ret0 - overrides the calculated FID with provided value
@@ -344,4 +344,4 @@ int ret0 - overrides the returned result of the function:
0 - not in range (can't see)
1 - in range (will see if not blocked)
2 - forced detection (will see regardless, only used in obj_can_see_obj script function which is called by every critter in the game)
-
+
diff --git a/hooks/index.html b/hooks/index.html
index e2626913..793163a3 100644
--- a/hooks/index.html
+++ b/hooks/index.html
@@ -1,4 +1,4 @@
- Hooks | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Hook scripts are specially named scripts that are run by sfall at specific points to allow mods to override normally hardcoded behaviour in a more flexible way than sfall’s normal ini configuration.
In addition to the bit of code it overrides, the script will be run once when first loaded and again at each player reload to allow for setup. Hook scripts have access to a set of arguments supplied to sfall, but aren’t required to use them all. They also return one or more values, but again they’re optional, and you only need to return a value if you want to override the default.
To aid in mods compatibility, avoid using the predefined hs_<name>.int scripts. Instead it is recommended to use a normal global script combined with register_hook_proc or register_hook.
Example setup for a hook-script based mod:
proceduretohit_hook_handlerbegin
+ Hooks | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Hook scripts are specially named scripts that are run by sfall at specific points to allow mods to override normally hardcoded behaviour in a more flexible way than sfall’s normal ini configuration.
In addition to the bit of code it overrides, the script will be run once when first loaded and again at each player reload to allow for setup. Hook scripts have access to a set of arguments supplied to sfall, but aren’t required to use them all. They also return one or more values, but again they’re optional, and you only need to return a value if you want to override the default.
To aid in mods compatibility, avoid using the predefined hs_<name>.int scripts. Instead it is recommended to use a normal global script combined with register_hook_proc or register_hook.
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:
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.
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:
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.
Loads a given INI file and returns a permanent array (map) where keys are section names and values are permanent sub-arrays (maps) where keys and values are strings.
Searches the file in the regular file system, like with all other ini-related functions.
Subsequent calls for the same file will return the same array, unless it was disposed using free_array.
get_ini_config_db
sfall.h
arrayget_ini_config_db(stringfile)
Works exactly like get_ini_config, except it searches the file in database (DAT) files. If not found, then it will try the regular file system.
get_ini_section
sfall.h
arrayget_ini_section(stringfile,stringsect)
Returns an associative array of keys and values for a given INI file and section.
If the INI file is not found, it returns an empty array.
NOTE: all keys and their values will be of String type.
get_ini_sections
sfall.h
arrayget_ini_sections(stringfile)
@@ -6,4 +6,4 @@
Reads an integer value from an ini file in the Fallout directory.
It only takes a single argument; seperate the file name, section and key with a “|” character; e.g. myvar:=get_ini_setting("myini.ini|mysec|var1")
If the file or key cannot be found or the setting argument is in an invalid format, it returns -1.
The file name is limited to 63 chars, including the extension.
The section name is limited to 32 characters.
It can also be used to get sfall settings by using ddraw.ini as the file name.
get_ini_string
stringget_ini_string(stringsetting)
Reads a string value from an ini file in the Fallout directory.
If the file or key cannot be found, it returns an empty string.
If the setting argument is in an invalid format, it returns -1 (integer).
modified_ini
intmodified_ini
Returns the value of ModifiedIni setting in [Main] section of the INI.
Writes an integer or a string value to an ini file in the Fallout directory. If the ini file does not exist, it will be created The setting argument works in the same way as in get_ini_setting, seperate the file name, section and key with a “|” character. Note: the file name is limited to 63 chars (including the extension), the section name is limited to 32 characters.
+
Writes an integer or a string value to an ini file in the Fallout directory. If the ini file does not exist, it will be created The setting argument works in the same way as in get_ini_setting, seperate the file name, section and key with a “|” character. Note: the file name is limited to 63 chars (including the extension), the section name is limited to 32 characters.
diff --git a/interface/index.html b/interface/index.html
index c03b1c52..83f91c91 100644
--- a/interface/index.html
+++ b/interface/index.html
@@ -1 +1 @@
- Interface | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Updates player’s stats in the inventory display window or on the character screen.
NOTE: works only when the interface window is opened
inventory_redraw
sfall.h
voidinventory_redraw(invSide)
-
Redraws inventory items list in the inventory/loot/barter screens. Argument invSide specifies which side needs to be redrawn: 0 - the player, 1 - target (container/NPC in loot/barter screens), -1 - both sides (same as without argument).
+
Redraws inventory items list in the inventory/loot/barter screens. Argument invSide specifies which side needs to be redrawn: 0 - the player, 1 - target (container/NPC in loot/barter screens), -1 - both sides (same as without argument).
diff --git a/keyboard-and-mouse/index.html b/keyboard-and-mouse/index.html
index d49f6b6d..05d750d9 100644
--- a/keyboard-and-mouse/index.html
+++ b/keyboard-and-mouse/index.html
@@ -1,6 +1,6 @@
- Keyboard and mouse | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
The type value in the weapon knockback functions can be 0 or 1. If 0, the value becomes an absolute distance that targets will be knocked back. If 1, the value is multiplied by the distance they would normally have been knocked back. Weapon knockback modifiers are applied in the order weapon -> attacker -> target, so a x2 weapon wielded by an abs 6 attacker hitting a /2 target will knock the target back 3 squares. The knockback functions will not override the stonewall perk or knockdowns resulting from criticals. knockback values set on weapons or critters are not saved, and must be reset each time the player reloads.
The type value in the weapon knockback functions can be 0 or 1. If 0, the value becomes an absolute distance that targets will be knocked back. If 1, the value is multiplied by the distance they would normally have been knocked back. Weapon knockback modifiers are applied in the order weapon -> attacker -> target, so a x2 weapon wielded by an abs 6 attacker hitting a /2 target will knock the target back 3 squares. The knockback functions will not override the stonewall perk or knockdowns resulting from criticals. knockback values set on weapons or critters are not saved, and must be reset each time the player reloads.
The list_xxx functions can be used to loop over all items on a map. list_begin takes an argument telling sfall what you want to list (defined in sfall.h). It returns a list pointer, which you iterate through with list_next. Finally, when you’ve finished with the list use list_end on it. Not calling list_end will result in a memory leak. Alternatively, use list_as_array to get the whole list at once as a temp array variable, which can be looped over using len_array and which you don’t need to remember to free afterwards.
The list_xxx functions can be used to loop over all items on a map. list_begin takes an argument telling sfall what you want to list (defined in sfall.h). It returns a list pointer, which you iterate through with list_next. Finally, when you’ve finished with the list use list_end on it. Not calling list_end will result in a memory leak. Alternatively, use list_as_array to get the whole list at once as a temp array variable, which can be looped over using len_array and which you don’t need to remember to free afterwards.
Returns an array of all current party members (0 - only critters that are alive and visible will be returned, 1 - all objects, including the car trunk, etc.)
+
Returns an array of all current party members (0 - only critters that are alive and visible will be returned, 1 - all objects, including the car trunk, etc.)
diff --git a/locks/index.html b/locks/index.html
index 928c57c2..79ad6c4a 100644
--- a/locks/index.html
+++ b/locks/index.html
@@ -1,4 +1,4 @@
- Locks | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Returns 1 if the lock (container or scenery) is currently jammed, 0 otherwise.
set_unjam_locks_time
sfall.h
voidset_unjam_locks_time(inttime)
Sets after how many hours (up to 127 hours) jammed locks will be unjammed if the player leaves the map. Also disables the auto unjam that occurs at midnight when the player is on the map. Passing 0 will disable the auto unjam mechanism completely. The auto unjam mechanism will be reset each time the player reloads the game.
unjam_lock
sfall.h
voidunjam_lock(ObjectPtrobj)
-
Unjams a lock immediately without having to wait until the next day, or leave the map and then return after 24 hours. Does not work in use_skill_on_p_proc procedure.
+
Unjams a lock immediately without having to wait until the next day, or leave the map and then return after 24 hours. Does not work in use_skill_on_p_proc procedure.
diff --git a/main-interface/index.html b/main-interface/index.html
index fbaa8ad4..2ed7e9e9 100644
--- a/main-interface/index.html
+++ b/main-interface/index.html
@@ -1,5 +1,5 @@
- Main interface | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Executes map_update_p_proc for all objects on map and global/hook scripts as well.
force_encounter
voidforce_encounter(intmap)
Can be called either from a global script while traveling on the world map, or from a normal script while on a local map. In either case the encounter occurs shortly after the next time the player moves on the world map. The player will not get an outdoorsman skill check.
force_encounter_with_flags
voidforce_encounter_with_flags(intmap,intflags)
Does the same thing as force_encounter, but allows the specification of some extra options (see sfall.h for available flags). Forcing a random encounter on a map that is not normally used for random encounters may cause the player to lose the car, if they have it. In this case use force_encounter_with_flags with the ENCOUNTER_FLAG_NO_CAR flag set.
get_map_enter_position
arrayget_map_enter_position()
@@ -9,4 +9,4 @@
Adjusts how fast time passes while you’re on the world map. It takes a single float as an argument, where 1 is the normal speed. This function works in addition to the WorldMapTimeMod setting in ddraw.ini and the Pathfinder perk, rather than overriding it, so calling set_map_time_multi(0.5) when the player has 2 levels of Pathfinder would result in time passing at 25% the normal speed on the world map.
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/floatabs(int/floatx)
Absolute (positive) value of x.
arctan
floatarctan(floatx,floaty)
Arctangent of x. Pass 1 as y (don’t ask…).
ceil
intceil(floatx)
@@ -11,4 +11,4 @@
Round x to the nearest integer.
sin
floatsin(floatx)
Sine of x
sqrt
floatsqrt(floatx)
Square root of x.
tan
floattan(floatx)
-
Tangent of x
+
Tangent of x
diff --git a/npc-perks/index.html b/npc-perks/index.html
index 36f40e8d..3bdc6cbf 100644
--- a/npc-perks/index.html
+++ b/npc-perks/index.html
@@ -1,6 +1,6 @@
- NPC perks | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Returns a pointer to the object (critter) the player is having a conversation or bartering with.
get_flags
sfall.h
intget_flags(ObjectPtrobj)
Gets the current value of object flags (see define_extra.h for available flags).
get_object_data
sfall.h
get_object_data(ObjectPtrobject,intoffset)
Returns the data at the specified offset of an object (see OBJ_DATA_* constants in define_extra.h for offsets).
get_script
intget_script(ObjectPtrobj)
@@ -15,4 +15,4 @@
Overrides the name of the script object that was set from scrname.msg.
The changed name will be reset each time the player leaves the map or reloads the game
Passing an empty string (“”) to the name argument or omitting it will allow the game to get the name for the object from pro_*.msg files
NOTE: this function is intended for use in normal game scripts and overrides the name only once for the same object until reset
set_script
voidset_script(ObjectPtrobj,intscriptID)
Accepts a pointer to an object and scriptID, and applies the given script to an object (scriptID accept the same values as create_object_sid from sfall 3.6). If used on an object that is already scripted, it will remove the existing script first; you cannot have multiple scripts attached to a single object. Calling set_script on self_obj will have all sorts of wacky side effects, and should be avoided. If you add 0x80000000 to the sid when calling set_script, map_enter_p_proc will be SKIPPED. The start proc will always be run.
set_self
voidset_self(ObjectPtrsetObj)
Overrides the script’s self_obj for the next function call.
It is primarily used to allow the calling of functions which take an implicit self_obj parameter (e.g. drop_obj) from global scripts, but it can also be used from normal scripts.
self_obj will be reverted to its original value after the next function call.
Calling set_self(0) will also revert self_obj to its original value. It is recommended to call this after each use of set_self in normal scripts in order to avoid unforeseen side effects.
source_obj, target_obj, and similar functions will not work if preceded by set_self.
NOTE: for use_obj, use_obj_on_obj vanilla functions to work correctly, it is required to call set_self twice. You can also access the local variables in the script of an object after calling set_self twice.
set_unique_id
sfall.h
intset_unique_id(ObjectPtrobject,intflag)
-
Assigns a unique ID number to the object and returns it. If a unique ID number has already been assigned to an object, then ID number is returned without reassignment. flag is optional.
items with unique IDs will not stack with other items of the same type in the inventory
to just get the current ID number of an object, use get_object_data(object, OBJ_DATA_ID)
unique ID numbers are saved in your savegame, and have a range from 0x10000000 to 0x7FFFFFFF
there is also a unique ID number range for the player and party members from 18000 to 83535
to assign a new ID number generated by the engine to the object (i.e. unassign a unique ID), call the function with two arguments and pass -1 for the flag argument
+
Assigns a unique ID number to the object and returns it. If a unique ID number has already been assigned to an object, then ID number is returned without reassignment. flag is optional.
items with unique IDs will not stack with other items of the same type in the inventory
to just get the current ID number of an object, use get_object_data(object, OBJ_DATA_ID)
unique ID numbers are saved in your savegame, and have a range from 0x10000000 to 0x7FFFFFFF
there is also a unique ID number range for the player and party members from 18000 to 83535
to assign a new ID number generated by the engine to the object (i.e. unassign a unique ID), call the function with two arguments and pass -1 for the flag argument
diff --git a/optimization/index.html b/optimization/index.html
index 3cce1084..06d5e053 100644
--- a/optimization/index.html
+++ b/optimization/index.html
@@ -1,4 +1,4 @@
- Optimization | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
The execution 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 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 the most efficiency, but tends 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;
+ Optimization | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
The execution 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 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 the most efficiency, but tends 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 relevant 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;
@@ -35,4 +35,4 @@ end -> end
... -> while i < tmp do begin
end -> ...
-> end
-
Mark functions with pure or inline where relevant.
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 separate 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 relevant.
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 separate 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 2aa9412b..4bdc45dc 100644
--- a/other/index.html
+++ b/other/index.html
@@ -1,4 +1,4 @@
- Other | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
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
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).
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)
+
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)
diff --git a/outline/index.html b/outline/index.html
index 8a4923f4..be142021 100644
--- a/outline/index.html
+++ b/outline/index.html
@@ -1,4 +1,4 @@
- Outline | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Returns an object that is currently highlighted by hovering the mouse above it.
set_outline
sfall.h
voidset_outline(ObjectPtrobj,intcolor)
-
sets the outline color of an object (see OUTLINE_* constants in sfall.h)
can also set a custom color from the game palette by shifting the color index value left by 8 bits: 0xCC00 where CC is the palette index (available since sfall 4.2.7/3.8.27)
passing 0 will disable the outline
+
sets the outline color of an object (see OUTLINE_* constants in sfall.h)
can also set a custom color from the game palette by shifting the color index value left by 8 bits: 0xCC00 where CC is the palette index (available since sfall 4.2.7/3.8.27)
passing 0 will disable the outline
diff --git a/perks-and-traits/index.html b/perks-and-traits/index.html
index b1d8b817..944a6692 100644
--- a/perks-and-traits/index.html
+++ b/perks-and-traits/index.html
@@ -1,4 +1,4 @@
- Perks and traits | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
sets the threshold value (failure_threshold) for the quest at which the quest will be considered failed (its description in the pipboy will be crossed out and colored red)
gvarNumber: the number of the global variable controlling the quest
thresholdValue: the value of the global variable at which the quest is counted as a failure
+ Pip-Boy | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
sets the threshold value (failure_threshold) for the quest at which the quest will be considered failed (its description in the pipboy will be crossed out and colored red)
gvarNumber: the number of the global variable controlling the quest
thresholdValue: the value of the global variable at which the quest is counted as a failure
diff --git a/read_xxx/index.html b/read_xxx/index.html
index f187c305..f56793b8 100644
--- a/read_xxx/index.html
+++ b/read_xxx/index.html
@@ -1,5 +1,5 @@
- read_xxx | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Loads the custom message file, and returns the file ID number assigned to it in range from 0x3000 to 0x3FFF for the message_str_game function to get messages from the file.
fileName: the name of the custom message file (including the .msg extension) in text\<language>\game\ directory.
Alternative form: int add_extra_msg_file(string fileName, int fileNumber)
fileNumber: the file ID number for the message_str_game function. The available range is from 0x2000 to 0x2FFF (see ExtraGameMsgFileList setting in ddraw.ini) Use fileNumber only if you want to add a message file without editing ddraw.ini or existing scripts to support the old way.
critter_inven_obj2
sfall.h
ObjectPtrcritter_inven_obj2(ObjectPtrobj,inttype)
Works just like vanilla critter_inven_obj, but correctly reports item in player’s inactive hand slot.
dialog_message
sfall.h
voiddialog_message(stringtext)
Displays a message in the NPC response window in dialog or barter screen.
Will get the number of additional points a critter has in a skill, on top of whatever they have from their stats and other bonuses
mod_skill_points_per_level
voidmod_skill_points_per_level(intvalue)
Accepts a value of between -100 and 100, and modifies the number of skill points the player recieves when they level up. This is a modification of what would otherwise happen, rather than a replacement. The value is not saved into the save game, so should be reset in the game_loaded section of a script.
Will set the number of additional points a critter has in a skill, on top of whatever they have from their stats and other bonuses. Note that skill points are part of the proto, so calling it on a critter will affect all critters that share the same proto.
set_skill_max
voidset_skill_max(intvalue)
-
Can’t be used to increase the skill cap above 300.
+
Can’t be used to increase the skill cap above 300.
diff --git a/sslc/index.html b/sslc/index.html
index c82f8a70..3b57c328 100644
--- a/sslc/index.html
+++ b/sslc/index.html
@@ -1,4 +1,4 @@
- SSLC | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
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 get rid of the dos4gw.exe reference from p.bat.
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 be safely used (and is recommended) with non-sfall scripts as well.
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 get rid of the dos4gw.exe reference from p.bat.
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 be safely used (and is recommended) with non-sfall scripts as well.
-q don't wait for input on error
-n no warnings
-b use backward compatibility mode
-l no logo
@@ -136,4 +136,4 @@ end
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.
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.
+
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.
diff --git a/stats/index.html b/stats/index.html
index 5d0edc04..f616489d 100644
--- a/stats/index.html
+++ b/stats/index.html
@@ -1,4 +1,4 @@
- Stats | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
The get/set_pc_base/extra_stat functions are equivalent to calling get/set_critter_base/extra_stat with dude_obj as the critter pointer. None of these stat functions take perks into account, and neither do they do range clamping to make sure the stats are valid. Use the normal get_critter_stat function to get a correctly perk adjusted and range clamped value for a stat.
The get/set_pc_base/extra_stat functions are equivalent to calling get/set_critter_base/extra_stat with dude_obj as the critter pointer. None of these stat functions take perks into account, and neither do they do range clamping to make sure the stats are valid. Use the normal get_critter_stat function to get a correctly perk adjusted and range clamped value for a stat.
Returns ASCII code for the first character in given string.
get_string_pointer
sfall.h
intget_string_pointer(stringtext)
(DEPRECATED) Returns a pointer to a string variable or to a text
NOTE: this function is intended for use only in HOOK_DESCRIPTIONOBJ. Starting from sfall 4.4/3.8.40, you can return normal strings directly in the hook without calling the function
string_find
sfall.h
intstring_find(stringhaystack,stringneedle)
Returns the position of the first occurrence of a needle string in a haystack string, or -1 if not found. The first character position is 0 (zero).
Converts all letters in the given string to the specified case.
toCase: 0 - lowercase, 1 - uppercase
NOTE: this function works only for English letters of A-Z/a-z.
strlen
intstrlen(stringtext)
Returns string length.
substr
stringsubstr(stringtext,intstart,intlength)
-
Cuts a substring from a string starting at “start” up to “length” characters. The first character position is 0 (zero).
If start is negative - it indicates a position starting from the end of the string (for example substr("test", -2, 2) will return last 2 charactes: “st”).
If length is negative - it means so many characters will be omitted from the end of string (example: substr("test", 0, -2) will return string without last 2 characters: “te”).
If length is zero - it will return a string from the starting position to the end of the string. New behavior for sfall 4.2.2/3.8.22
+
Cuts a substring from a string starting at “start” up to “length” characters. The first character position is 0 (zero).
If start is negative - it indicates a position starting from the end of the string (for example substr("test", -2, 2) will return last 2 charactes: “st”).
If length is negative - it means so many characters will be omitted from the end of string (example: substr("test", 0, -2) will return string without last 2 characters: “te”).
If length is zero - it will return a string from the starting position to the end of the string. New behavior for sfall 4.2.2/3.8.22
diff --git a/tags/index.html b/tags/index.html
index 8591eacc..2e90c0da 100644
--- a/tags/index.html
+++ b/tags/index.html
@@ -1,6 +1,6 @@
- Tags | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
show_iface_tag, hide_iface_tag and is_iface_tag_active relate to the boxes that appear above the interface such as SNEAK and LEVEL. You can use 0 for SNEAK (starting from sfall 4.4.4/3.8.44), 3 for LEVEL, 4 for ADDICT, and 5 to (4 + the value of BoxBarCount in ddraw.ini) for custom boxes. Remember to add your messages to intrface.msg and set up the font colours in ddraw.ini if you’re going to use custom boxes. Starting from sfall 4.1/3.8.12, is_iface_tag_active can also be used to check 0 for SNEAK, 1 for POISONED, and 2 for RADIATED.
show_iface_tag, hide_iface_tag and is_iface_tag_active relate to the boxes that appear above the interface such as SNEAK and LEVEL. You can use 0 for SNEAK (starting from sfall 4.4.4/3.8.44), 3 for LEVEL, 4 for ADDICT, and 5 to (4 + the value of BoxBarCount in ddraw.ini) for custom boxes. Remember to add your messages to intrface.msg and set up the font colours in ddraw.ini if you’re going to use custom boxes. Starting from sfall 4.1/3.8.12, is_iface_tag_active can also be used to check 0 for SNEAK, 1 for POISONED, and 2 for RADIATED.
Adds one custom box to the current boxes, and returns the number of the added tag (-1 if the tags limit is exceeded. The maximum number of boxes is limited to 126 tags.
Sets the text messages and colors for custom notification boxes to the interface without the need to add messages to intrface.msg and set up the font colors in ddraw.ini. Tag value is the same as used in show_iface_tag, hide_iface_tag, and is_iface_tag_active. The valid range is from 5 to (4 + the value of BoxBarCount in ddraw.ini) or the number of the last custom box added using the add_iface_tag function. The text is limited to 19 characters.
show_iface_tag
voidshow_iface_tag(inttag)
-
+
diff --git a/tiles-and-paths/index.html b/tiles-and-paths/index.html
index 67dd9ab2..2f58b977 100644
--- a/tiles-and-paths/index.html
+++ b/tiles-and-paths/index.html
@@ -1,4 +1,4 @@
- Tiles and paths | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Returns an array of all objects at given tile. It will include any hidden, dead or system objects (like cursor), so make sure to check properly when iterating.
tile_light
inttile_light(intelevation,inttileNum)
Returns light intensity at the given tile in range from 0 to 65535.
tile_refresh_display
voidtile_refresh_display()
Redraws the game scene (tiles, walls, objects, etc.).
tile_under_cursor
inttile_under_cursor
-
+
diff --git a/utility/index.html b/utility/index.html
index 151145b3..0a7bd6a8 100644
--- a/utility/index.html
+++ b/utility/index.html
@@ -1,5 +1,5 @@
- Utility | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
Formats given value using standart syntax of C printf function (google “printf” for format details). However, it is limited to formatting only 1 value.
Can be used to get character by ASCII code (“%c”).
typeof
inttypeof(anyvalue)
-
Returns type of the given value: VALTYPE_INT, VALTYPE_FLOAT or VALTYPE_STR.
+
Returns type of the given value: VALTYPE_INT, VALTYPE_FLOAT or VALTYPE_STR.
diff --git a/version/index.html b/version/index.html
index 49d321b2..0527bc7d 100644
--- a/version/index.html
+++ b/version/index.html
@@ -1,4 +1,4 @@
- Version | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
The fs_* functions are used to manipulate a virtual file system. Files saved here should have paths relative to the data folder, and use backslashes as the directory separator. They will take precedence over files stored in the normal data folder. They will also be saved into save games if you set a flag for them using fs_resize(fileId, -1), so be avoid creating large files. Using fs_copy followed by fs_read_xxx, you can read the contents of existing files.
The fs_* functions are used to manipulate a virtual file system. Files saved here should have paths relative to the data folder, and use backslashes as the directory separator. They will take precedence over files stored in the normal data folder. They will also be saved into save games if you set a flag for them using fs_resize(fileId, -1), so be avoid creating large files. Using fs_copy followed by fs_read_xxx, you can read the contents of existing files.
diff --git a/weapons-and-ammo/index.html b/weapons-and-ammo/index.html
index bf99936c..bc3ac7df 100644
--- a/weapons-and-ammo/index.html
+++ b/weapons-and-ammo/index.html
@@ -1,5 +1,5 @@
- Weapons and ammo | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
This also allows to set current charges of a misc item (Geiger counter, etc).
set_weapon_ammo_pid
voidset_weapon_ammo_pid(ObjectPtrweapon,intpid)
-
+
diff --git a/windows-and-images/index.html b/windows-and-images/index.html
index 3e77b80b..16bffd32 100644
--- a/windows-and-images/index.html
+++ b/windows-and-images/index.html
@@ -1,4 +1,4 @@
- Windows and images | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
arrayart_frame_data(string/intartFile/artId,intframe,introtation)
+ Windows and images | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
returns the dimensions of a given PCX or FRM frame as a temp array in the form [width, height]
artFile/artId: path to the PCX/FRM file (e.g. art\\inven\\5mmap.frm), or its FRM ID number (e.g. 0x7000026, see specification of the FID format) optional arguments:
frame: frame number, the first frame starts from zero
rotation: rotation to get the frame for, useful when reading FRM files by path
flags argument is optional. Works just like vanilla CreateWin function, but creates a window with MoveOnTop flag if the flags argument is not specified, and allows to set additional flags for the created window. MoveOnTop flag allows the created window to be placed on top of the game interface.
displays the specified PCX or FRM image in the active window created by vanilla CreateWin or sfall’s create_win script function
artFile/artId: path to the PCX/FRM file (e.g. art\\inven\\5mmap.frm), or its FRM ID number (e.g. 0x7000026, see specification of the FID format) optional arguments:
frame: frame number, the first frame starts from zero
x/y: offset relative to the top-left corner of the window
noTransparent: pass True to display an image without transparent background
NOTE: to omit optional arguments starting from the right, call the functions with different sfall_funcX (e.g. sfall_func4("draw_image", pathFile, frame, x, y))
draw_image_scaled
sfall.h
voiddraw_image_scaled(string/intartFile/artId,intframe,intx,inty,intwidth,intheight)
@@ -19,4 +19,4 @@ optional arguments:
- color1/color2: the color index in the game palette. `color1` sets the text color for the first line, and `color2` for all subsequent lines of text (default color is 145)
Fills the rectangle area of the currently selected script window with the specified color, or clears the window with transparent (index 0) color (call the function without arguments).
color: the color index in the game palette (from 0 to 255)
+
Fills the rectangle area of the currently selected script window with the specified color, or clears the window with transparent (index 0) color (call the function without arguments).
color: the color index in the game palette (from 0 to 255)
diff --git a/worldmap/index.html b/worldmap/index.html
index feb40780..532b8c6f 100644
--- a/worldmap/index.html
+++ b/worldmap/index.html
@@ -1,4 +1,4 @@
- Worldmap | sfallSkip to main contentLinkMenuExpand(external link)DocumentSearchCopyCopied
The mapper manual lists the functions world_map_x_pos and world_map_y_pos, which supposedly return the player’s x and y positions on the world map. get_world_map_x/y_pos are included here anyway, because I was unable to get those original functions to work, or even to find any evidence that they existed in game.
The mapper manual lists the functions world_map_x_pos and world_map_y_pos, which supposedly return the player’s x and y positions on the world map. get_world_map_x/y_pos are included here anyway, because I was unable to get those original functions to work, or even to find any evidence that they existed in game.
These functions take a memory address as the parameter and can write to arbitrary pieces of Fallout’s address None of these functions will work unlessAllowUnsafeScriptingis enabled inddraw.ini.
These functions take a memory address as the parameter and can write to arbitrary pieces of Fallout’s address None of these functions will work unlessAllowUnsafeScriptingis enabled inddraw.ini.