UCC Reference

intrinsic_reference

For Usecode C purposes, the avatar is an NPC just like any other. Constants referred to below (usually in ALL CAPS) are defined in 'src/headers/constants.uc' unless otherwise stated.

Unlike Usecode C-defined functions, intrinsics do not have compiler-enforced prototypes. The signatures below describe the values expected by the engine, rather than declarations to copy into your source. Supply the documented parameters and use the named intrinsic so UCC selects the correct game-specific ID.

There is no fixed 12-argument buffer limit in the current engine. This does not make arbitrary argument lists meaningful: the implementation determines which values it reads, how it interprets them, and whether omitted arguments have defaults. Omit an argument only when the intrinsic description explicitly makes it optional. The runtime checks each intrinsic's declared minimum argument count before calling its implementation; calls with too few arguments print a diagnostic and are skipped. Optional-argument defaults are handled by the implementation, which receives exactly the arguments supplied by the caller.

The descriptions and ID table have been checked against usecode/intrinsics.cc, usecode/bgintrinsics.h, usecode/siintrinsics.h, and usecode/sibetaintrinsics.h. UCC portrait statements are also checked against tools/compiler/ucparse.yy.

To the right of many intrinsic 'prototypes', you can see an indicator between square brackets. This indicator is a quick way to see if that intrinsic is available for the specific game you are interested in. The possible values of these indicators are:

Indicator Meaning
[BG] BG-specific intrinsic
[SI] SI-specific intrinsic
[Exult] Exult-specific intrinsic, available to both BG and SI
[BG, Exult] Originally BG-only, Exult allows it in SI too
[SI, Exult] Originally SI-only, Exult allows it in BG too
[Exult: BG] Exult-specific intrinsic, available only to BG
[Exult: SI] Exult-specific intrinsic, available only to SI
(not present) Intrinsic available for BG and SI

The '[Exult]', '[BG, Exult]' and '[SI, Exult]' indicators are essentially equivalent to no indicator at all; they are used in this document only for completeness.

The intrinsic prototypes below are in Usecode C-esque form. It is actually more like C than Usecode C. Specifically, all parameters have a type instead of the Usecode C-'var'. The parameter type indicates what Exult will be expecting; the Usecode C compiler won't care in the slightest what you pass as a parameter. The parameter types I use are as follows:

Parameter / value Description
int This means any integer, positive or negative.
object Any object or NPC. It can be an object reference, 'item' or a number (that must be negative, which Exult will convert to an NPC if it is in the correct range).
actor Any NPC. It is evaluated the same way as 'object' is, but Exult will reject anything that can't be converted to an NPC. Monsters are also accepted.
bool A 'true'/'false' parameter. Can be a number (nonzero/zero), an array (non-empty/empty) or a comparison expression (e.g., a == b).
string A string (text). Strings in usecode are any set of characters surrounded by double-quotes; for example, "This is a string.". If you need a double-quote inside a string you can 'escape' it by prefixing them with a backslash: "\""; alternatively, Exult converts '@' into a double-quote.
function A usecode function, which must be declared with either, the shape# or the object# specifiers. In Usecode C, this can be the function name or its usecode number. For example: 'extern Bolt shape#(0x2D3) ();' can be passed as 'Bolt' (the function name), '0x2D3' (its function number since 'shape#(shnum) == shnum' if shnum < 0x400) or as '&Bolt' (using the 'address of' operator '&' to get the function number).

If the parameter name is followed by a '[]', it indicates an array with elements of the specified type. Example: 'actor npc[]' means an array of NPCs. If there is a number between the brackets, it means an array of that length; for example, 'int num[3]' means an array with 3 'int' elements. In some cases, an array can be of type 'mixed' to indicate that not all of the array's elements are of the same type.

Some intrinsics are 'overloaded'; i.e., they accept more than one parameter type. In those cases, all of the possibilities are listed as prototypes.

If the parameter list is simply '[special]', see the description for details.

If the intrinsic is preceded by a parameter type, it means that the intrinsic returns something of that type; the description explains the return value. In some cases, the return value can be 'mixed[]' to indicate that the intrinsic returns an array, not all of which are of the same type.

All intrinsics can be called as presented in the list. If an intrinsic has at least one parameter, it can be called in 'calle' form, with the first parameter as its 'object'. Example:

int UI_execute_usecode_array(object obj, int script[]);
int obj->execute_usecode_array(int script[]);

The first parameter and the '->' can both be omitted if 'obj' is 'item', and if you omit either of them you must omit both or the Usecode will fail to compile. For stylistic purposes, the 'calle' form should be used only when the first parameter is an object or NPC (or 'item'). For all intrinsics with 'appropriate' parameter types, I have listed both forms in the list below.

Also, you may have noticed that I did not include the parameter type of 'obj' when I gave the 'calle' form of execute_usecode_array; since I will only give the 'calle' form when the parameter type is 'object' or 'actor', I feel that it is unneeded.

Usecode arrays are one-based: the first element is array[1]. Array sizes in signatures describe the number of elements, not the last zero-based index. Flat coordinate lists such as [x1, y1, x2, y2] are single arrays, not arrays of arrays.

Intrinsic IDs and game availability

The following IDs come from Exult's usecode/bgintrinsics.h, usecode/siintrinsics.h, and usecode/sibetaintrinsics.h. Select the appropriate table with #game "blackgate", #game "serpentisle", or #game "serpentbeta"; use the named intrinsic in source rather than copying an ID from another game. Multiple IDs in a cell are aliases for the same intrinsic. An em dash means that the intrinsic is absent from that table. UNKNOWN and NOP entries are omitted.

The badges on individual descriptions distinguish original game support from Exult extensions for BG and SI. This table also records SI beta availability, which those badges do not cover. In particular, SI beta has sib_path_run_usecode and sib_is_dest_reachable with different signatures from their counterparts, supports the virtue-stone intrinsics, and lacks save_pos and teleport_to_saved_pos.

Intrinsic BG SI SI beta
UI_a_or_an 0x96 0xb2 0xb1
UI_add_answer 0x05 0x0c 0x0c
UI_add_cont_items 0xb8 0x36 0x36
UI_add_party_items 0x2c 0x35 0x35
UI_add_spell 0x52 0x66 0x65
UI_add_to_keyring — 0xc3 0xc2
UI_add_to_party 0x1e 0x26 0x26
UI_advance_time 0x78 0x8e 0x8d
UI_ambient_light 0xd4 0x9f 0x9e
UI_apply_damage 0x61 0x76 0x75
UI_approach_avatar 0xa0 0xbf 0xbe
UI_armageddon 0x5b 0x70 0x6f
UI_attack_avatar 0x7c 0x92 0x91
UI_attack_object 0x54 0x69 0x68
UI_begin_casting_mode 0xb4 0xc9 0xc8
UI_book_mode 0x55 0x6a 0x69
UI_book_mode_ex 0xc0 0xcd 0xcc
UI_call_guards 0x7a 0x90 0x8f
UI_can_avatar_reach_pos — 0x96 0x95
UI_cause_light 0x57 0x6c 0x6b
UI_center_view 0xa2 0xcf 0xce
UI_change_npc_face0 0xcc 0x0a 0x0a
UI_change_npc_face1 0xcd 0x0b 0x0b
UI_clear_answers 0x09 0x10 0x10
UI_clear_item_flag 0x8a 0xa5 0xa4
UI_clear_item_say 0xb9 0x4e 0x4d
UI_click_on_item 0x33 0x3f 0x3f
UI_clone 0x4d 0x5f 0x5e
UI_close_gump 0x80 0x9a 0x99
UI_close_gump2 0xd9 0xda 0xd9
UI_close_gumps 0x7e 0x98 0x97
UI_close_gumps2 0xd8 0xd9 0xd8
UI_count_objects 0x28 0x31 0x31
UI_create_barge_object 0xd5 0xd6 0xd5
UI_create_new_egg 0xdc 0xdd 0xdc
UI_create_new_object 0x24 0x2c 0x2c
UI_create_new_object2 0xb7 0x2d 0x2d
UI_delayed_execute_usecode_array 0x02 0x02 0x02
UI_die_roll 0x10 0x17 0x17
UI_direction_from 0x87 0xa2 0xa1
UI_display_area 0x4f 0x61 0x60
UI_display_map 0x48 — —
UI_display_map_ex 0xbf 0xcc 0xcb
UI_display_runes 0x32 0x3e 0x3e
UI_earthquake 0x59 0x6e 0x6d
UI_end_conversation — 0x86 0x85
UI_error_message 0x34 0x40 0x40
UI_execute_usecode_array 0x01 0x01 0x01
UI_fade_palette 0x8c 0xa8 0xa7
UI_fade_palette_sleep 0xd7 0xa9 0xa8
UI_find_direction 0x1a 0x22 0x22
UI_find_nearby 0x35 0x41 0x41
UI_find_nearby_avatar 0x30 0x3c 0x3c
UI_find_nearest 0x0e 0x15 0x15
UI_find_object 0x29 0x32 0x32
UI_fire_projectile 0x76 0x8c 0x8b
UI_flash_mouse 0x6a 0x7f 0x7e
UI_game_day 0xda 0xdb 0xda
UI_game_hour 0x38 0x45 0x44
UI_game_minute 0x39 0x46 0x45
UI_get_alignment 0x3c 0x49 0x48
UI_get_array_size 0x5e 0x73 0x72
UI_get_attack_mode 0xa1 0x5a 0x59
UI_get_avatar_ref 0x22 0x2a 0x2a
UI_get_barge 0x58 0x6d 0x6c
UI_get_body_npc 0xa3 0x65 0x64
UI_get_cont_items 0x2a 0x33 0x33
UI_get_container 0x6e 0x83 0x82
UI_get_dead_party 0x93 0xaf 0xae
UI_get_distance 0x19 0x21 0x21
UI_get_item_flag 0x88 0xa3 0xa2
UI_get_item_frame 0x12 0x1a 0x1a
UI_get_item_frame_rot 0x6b 0x80 0x7f
UI_get_item_gump_position 0xdd 0xde 0xdd
UI_get_item_quality 0x14 0x1c 0x1c
UI_get_item_quantity 0x16 0x1e 0x1e
UI_get_item_shape 0x11 0x18 0x18
UI_get_item_weight 0xc9 0x19 0x19
UI_get_lift 0x42 0x50 0x4f
UI_get_map_num 0xb6 0xcb 0xca
UI_get_music_track 0x2d 0x38 0x38
UI_get_npc_id 0xa4 0xbc 0xbb
UI_get_npc_name 0x27 0x30 0x30
UI_get_npc_number 0x3a 0x47 0x46
UI_get_npc_object 0x1b 0x23 0x23
UI_get_npc_prop 0x20 0x28 0x28
UI_get_npc_warmth 0xd1 0xbb 0xba
UI_get_object_position 0x18 0x20 0x20
UI_get_oppressor 0xa6 0x5c 0x5b
UI_get_party_list 0x23 0x2b 0x2b
UI_get_party_list2 0x8d 0xaa 0xa9
UI_get_random 0x00 0x00 0x00
UI_get_readied 0xa7 0xbe 0xbd
UI_get_schedule_type 0x1c 0x24 0x24
UI_get_shape_flag 0xe4 0xe5 0xe4
UI_get_skin_colour 0xcb 0xa6 0xa5
UI_get_slider_value 0xe2 0xe3 0xe2
UI_get_speech_track 0x69 0x7e 0x7d
UI_get_temperature 0xce 0xb8 0xb7
UI_get_temperature_zone 0xd0 0xb9 0xb8
UI_get_timer 0x65 0x7a 0x79
UI_get_usecode_fun 0xb5 0xca 0xc9
UI_get_weapon 0xa8 0x5d 0x5c
UI_get_weather 0x44 0x52 0x51
UI_give_last_created 0x36 0x42, 0x43 0x42
UI_halt_scheduled 0x5c 0x71 0x70
UI_has_spell 0xd2 0xd4 0xd3
UI_in_combat 0x8e 0xab 0xaa
UI_in_gump_mode 0x81 0x9b 0x9a
UI_in_usecode 0x79 0x8f 0x8e
UI_in_usecode_path 0xd6 0xd7 0xd6
UI_infravision 0xbe 0xc5 0xc4
UI_init_conversation — 0x85 0x84
UI_input_numeric_value 0x0c 0x13 0x13
UI_is_dead 0x37 0x44 0x43
UI_is_dest_reachable 0xc6 0xd1 0xd0
UI_is_not_blocked 0x85 0xa0 0x9f
UI_is_npc 0x31 0x3d 0x3d
UI_is_on_keyring — 0xc2 0xc1
UI_is_pc_female 0x5a 0x6f 0x6e
UI_is_pc_inside 0x62 0x77 0x76
UI_is_readied 0x72 0x88 0x87
UI_is_water 0x90 0xac 0xab
UI_item_say 0x40, 0x7f 0x4d, 0x99 0x4c, 0x98
UI_kill_npc 0x49 0x57 0x56
UI_lightning 0x5d 0x72 0x71
UI_mark_virtue_stone 0x5f — 0x73
UI_modify_schedule 0xa9 0xb5 0xb4
UI_mouse_exists 0x68 0x7d 0x7c
UI_move_object 0x3e 0x4b 0x4a
UI_nap_time 0x77 0x8d 0x8c
UI_npc_nearby 0x2f 0x3a 0x3a
UI_npc_nearby2 — 0x3b 0x3b
UI_obj_sprite_effect 0x7b 0x91 0x90
UI_on_barge 0x6d 0x82 0x81
UI_part_of_day 0x3b 0x48 0x47
UI_path_run_usecode 0x7d 0x94 0x93
UI_play_music 0x2e 0x39 0x39
UI_play_scene 0xdb 0xdc 0xdb
UI_play_sound_effect 0x0f 0x16 0x16
UI_play_sound_effect2 0x86 0xa1 0xa0
UI_pop_answers 0x08 0x0f 0x0f
UI_printf 0xaa 0xc7 0xc6
UI_push_answers 0x07 0x0e 0x0e
UI_recall_virtue_stone 0x60 — 0x74
UI_reduce_health 0x71 0x87 0x86
UI_remove_all_spells 0xca 0x67 0x66
UI_remove_answer 0x06 0x0d 0x0d
UI_remove_cont_items 0xab 0x37 0x37
UI_remove_from_area 0xac 0xc4 0xc3
UI_remove_from_keyring — 0xc8 0xc7
UI_remove_from_party 0x1f 0x27 0x27
UI_remove_item 0x6f 0x84 0x83
UI_remove_npc 0x3f 0x4c 0x4b
UI_remove_npc_face 0x04 0x04 0x04
UI_remove_npc_face0 0xc3 0x07 0x07
UI_remove_npc_face1 0xc4 0x08 0x08
UI_remove_party_items 0x2b 0x34 0x34
UI_remove_spell 0xd3 0xd5 0xd4
UI_reset_conv_face 0x91 0xad 0xac
UI_restart_game 0x73 0x89 0x88
UI_resurrect 0x51 0x63 0x62
UI_resurrect_npc — 0x64 0x63
UI_revert_schedule 0xad 0xb4 0xb3
UI_roll_to_win 0x4a 0x58 0x57
UI_run_endgame 0x75 0x8b 0x8a
UI_run_schedule 0xae 0xb7 0xb6
UI_save_pos 0xba 0x74 —
UI_select_from_menu 0x0a 0x11 0x11
UI_select_from_menu2 0x0b 0x12 0x12
UI_set_alignment 0x3d 0x4a 0x49
UI_set_attack_mode 0x4b 0x59 0x58
UI_set_barge_dir 0xaf 0xc0 0xbf
UI_set_camera 0x92, 0xbc 0xae 0xad
UI_set_conversation_slot 0xc5 0x09 0x09
UI_set_gump_shape 0xe0 0xe1 0xe0
UI_set_gump_text 0xdf 0xe0 0xdf
UI_set_gump_text_font 0xe3 0xe4 0xe3
UI_set_intercept_item 0xb0 0xc6 0xc5
UI_set_item_flag 0x89 0xa4 0xa3
UI_set_item_frame 0x13 0x1b 0x1b
UI_set_item_frame_rot 0x6c 0x81 0x80
UI_set_item_gump_position 0xde 0xdf 0xde
UI_set_item_quality 0x15 0x1d 0x1d
UI_set_item_quantity 0x17 0x1f 0x1f
UI_set_item_shape 0x0d 0x14 0x14
UI_set_last_created 0x25 0x2e 0x2e
UI_set_lift 0x43 0x51 0x50
UI_set_light 0x82 0x9c 0x9b
UI_set_new_schedules 0xb1 0xb6 0xb5
UI_set_npc_id 0xa5 0xbd 0xbc
UI_set_npc_name 0xc7 0xd2 0xd1
UI_set_npc_prop 0x21 0x29 0x29
UI_set_opponent 0xb2 0x5e 0x5d
UI_set_oppressor 0x4c 0x5b 0x5a
UI_set_orrery 0x63 — —
UI_set_path_failure 0x8b 0xa7 0xa6
UI_set_polymorph 0xbd 0xb3 0xb2
UI_set_schedule_type 0x1d 0x25 0x25
UI_set_slider_value 0xe1 0xe2 0xe1
UI_set_temperature 0xcf 0xba 0xb9
UI_set_time_palette 0x84 0x9e 0x9d
UI_set_timer 0x66 0x7b 0x7a
UI_set_to_attack 0x41 0x4f 0x4e
UI_set_usecode_fun 0xc8 0xd3 0xd2
UI_set_weather 0x45 0x53 0x52
UI_show_npc_face 0x03 0x03 0x03
UI_show_npc_face0 0xc1 0x05 0x05
UI_show_npc_face1 0xc2 0x06 0x06
UI_si_display_map — 0x56 0x55
UI_si_path_run_usecode 0xb3 0xc1 0xc0
UI_sib_is_dest_reachable — — 0x96
UI_sib_path_run_usecode — — 0x94
UI_sit_down 0x46 0x54 0x53
UI_sprite_effect 0x53 0x68 0x67
UI_start_blocking_speech 0x8f 0xd8 0xd7
UI_start_speech 0x74 0x8a 0x89
UI_stop_arresting — 0x93 0x92
UI_stop_time 0x56 0x6b 0x6a
UI_summon 0x47 0x55 0x54
UI_telekenesis 0x95 0xb1 0xb0
UI_teleport_to_saved_pos 0xbb 0x75 —
UI_update_last_created 0x26 0x2f 0x2f
UI_view_tile 0x94 0xb0 0xaf
UI_wearing_fellowship 0x67 0x7c 0x7b
UI_wizard_eye 0x50 0x62 0x61

Full intrinsic reference | Reference definitions