Sfall funcX macros


add_extra_msg_file

sfall.h

int add_extra_msg_file(string fileName)

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.

This is a macro, you need to include sfall.h to use it.


create_win

sfall.h

void create_win(string winName, int x, int y, int width, int height, int flags)

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.

This is a macro, you need to include sfall.h to use it.


critter_inven_obj2

sfall.h

ObjectPtr critter_inven_obj2(ObjectPtr obj, int type)

Works just like vanilla critter_inven_obj, but correctly reports item in player’s inactive hand slot.

This is a macro, you need to include sfall.h to use it.


dialog_message

sfall.h

void dialog_message(string text)

Risplays a message in the NPC response window in dialog or barter screen.

This is a macro, you need to include sfall.h to use it.


draw_image

sfall.h

void draw_image(string/int pathFile/artId, int frame, int x, int y, bool noTransparent)
  • displays the specified FRM image in the active window created by vanilla CreateWin or sfall’s create_win script function
  • pathFile/artId: path to the FRM file (e.g. “art\inven\5mmap.frm”), or its FRM ID number (e.g. 117440550, 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))

This is a macro, you need to include sfall.h to use it.


draw_image_scaled

sfall.h

void draw_image_scaled(string/int pathFile/artId, int frame, int x, int y, int width, int height)
  • displays the specified FRM image in the active window created by vanilla CreateWin or sfall’s create_win script function
  • pathFile/artId: path to the FRM file (e.g. art\\inven\\5mmap.frm), or its FRM ID number (e.g. 117440550, 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
  • width/height: image size, used to scale the image when displaying it. Pass -1 to either width or height to keep the aspect ratio when scaling
  • 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))
  • if called without x/y/width/height arguments, the image will be scaled to fit the window without transparent background

This is a macro, you need to include sfall.h to use it.


get_current_inven_size

sfall.h

get_current_inven_size(ObjectPtr object)

Returns the current inventory size of the container or the critter.

This is a macro, you need to include sfall.h to use it.


get_flags

sfall.h

int get_flags(ObjectPtr obj)

Gets the current value of object flags (see define_extra.h for available flags).

This is a macro, you need to include sfall.h to use it.


get_metarule_table

sfall.h

array get_metarule_table

Returns names of all currently available scripting functions.

This is a macro, you need to include sfall.h to use it.


get_object_ai_data

sfall.h

int get_object_ai_data(ObjectPtr object, int aiParam)

Returns the setting value from the AI packet of an object (critter). Use AI_CAP_* constants from define_extra.h for the aiParam argument to get AI value.

This is a macro, you need to include sfall.h to use it.


get_object_data

sfall.h

get_object_data(ObjectPtr object, int offset)

Returns the data at the specified offset of an object (see OBJ_DATA_* constants in define_extra.h for offsets).

This is a macro, you need to include sfall.h to use it.


item_weight

sfall.h

int item_weight(ObjectPtr obj)

Gets the current weight of an object.

This is a macro, you need to include sfall.h to use it.


metarule_exist

sfall.h

bool metarule_exist(string metaruleName)

Returns True if the specified name of metarule (sfall_funcX) function exists in the current version of sfall.

This is a macro, you need to include sfall.h to use it.


npc_engine_level_up

sfall.h

void npc_engine_level_up(bool toggle)

Enables/disables the engine function that increases the level of party members in the player leveling process. If the engine function is disabled, the process of leveling up party members should be performed by script functions.

This is a macro, you need to include sfall.h to use it.


obj_under_cursor

sfall.h

ObjectPtr obj_under_cursor(bool crSwitch, bool inclDude)

Returns the object under the cursor on the main game screen. crSwitch: True - only checks critters and ignores their cover (roof tiles, walls, scenery, etc.), False - checks all objects (can’t check critters under objects). Passing False to the inclDude argument will ignore dude_obj

This is a macro, you need to include sfall.h to use it.


set_drugs_data

sfall.h

void set_drugs_data(int type, int pid, int value)

Overrides the parameters of drugs set in the configuration file (DrugsFile setting in ddraw.ini). Type: 0 - changes the value of NumEffects for the drug (see Drugs.ini for the description of NumEffects), 1 - changes the duration of the addiction effect for the drug (a value of 1 = one game minute).

This is a macro, you need to include sfall.h to use it.


set_flags

sfall.h

void set_flags(ObjectPtr obj, int flags)

Sets the current flags of an object. All flags are rewritten with given integer, so first get current flags with get_flags and use bwor/bwand to set/remove specific flag.

This is a macro, you need to include sfall.h to use it.


set_object_data

sfall.h

set_object_data(ObjectPtr object, int offset, int data)

Sets the data at the specified offset of an object.

This is a macro, you need to include sfall.h to use it.


set_rest_heal_time

sfall.h

void set_rest_heal_time(int time)

Sets the time interval in minutes for healing during resting. The default is 180. Note: The interval will be reset each time the player reloads the game.

This is a macro, you need to include sfall.h to use it.


set_rest_mode

sfall.h

void set_rest_mode(int flags)

Sets the bit flags for the rest mode (see RESTMODE_* constants in sfall.h). Passing 0 will reset the rest mode. It will also be reset each time the player reloads the game.

This is a macro, you need to include sfall.h to use it.


set_unique_id

sfall.h

int set_unique_id(ObjectPtr object, int flag)

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

This is a macro, you need to include sfall.h to use it.


spatial_radius

sfall.h

int spatial_radius(ObjectPtr obj)

Returns radius of spatial script, associated with given dummy-object (returned by create_spatial).

This is a macro, you need to include sfall.h to use it.