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
Should work like art_change_fid_num but in reg_anim sequence.
reg_anim_combat_check
voidreg_anim_combat_check(intenable)
-
Allows to enable all reg_anim_* functions in combat (including vanilla functions) if set to 0. It is automatically reset at the end of each frame, so you need to call it before reg_anim_begin - reg_anim_end block.
reg_anim_destroy
voidreg_anim_destroy(ObjectPtr)
+
Allows enabling all reg_anim_* functions in combat (including vanilla functions) if set to 0. It is automatically reset at the end of each frame, so you need to call it before reg_anim_begin - reg_anim_end block.
reg_anim_destroy
voidreg_anim_destroy(ObjectPtr)
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)
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 occurence 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)
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
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
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)
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
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
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.
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)).
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.