Objects and scripts



ObjectPtr dialog_obj()

Returns a pointer to the object (critter) the player is having a conversation or bartering with.

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


int get_script(ObjectPtr)

Accepts a pointer to an object and returns its scriptID (line number in scripts.lst), or -1 if the object is unscripted.



ObjectPtr loot_obj()

Returns a pointer to the target object (container or critter) of the loot screen.

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


int (ObjectPtr invenObj, ObjectPtr itemObj)

Returns number of itemObj inside invenObj’s inventory, note that both arguments are object pointers. useful when dealing with different stacks of same item (obj_is_carrying_obj_pid just returns total for all stacks of the same PID.)



ObjectPtr real_dude_obj()

Returns the initial dude_obj after set_dude_obj was used.

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


void remove_script(ObjectPtr)

Accepts a pointer to an object and will remove the script from that object.



void set_dude_obj(ObjectPtr critter)

Take control of a given critter. Passing value 0 will reset control back to “real” dude.

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


void set_script(ObjectPtr, int scriptid)

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.


void set_self(ObjectPtr)

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.
  • Will revert back to its original value after the next function call.
  • Calling self_obj(0) will also revert self_obj to 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.