Objects and scripts


dialog_obj

sfall.h

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.


get_script

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.


loot_obj

sfall.h

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.


obj_is_carrying_obj

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.)


real_dude_obj

sfall.h

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.


remove_script

void remove_script(ObjectPtr)

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


set_dude_obj

sfall.h

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.


set_script

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.


set_self

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.