There are a couple of undocumented commands for building sounds.
The first command sfx_build_weapon_name is for automatically building the sound associated with a weapon:
item:=create_object(PID_GATLING_LASER,0,0);
add_mult_objs_to_inven(self_obj,item,1);
wield_obj(item);
sound := sfx_build_weapon_name(snd_weapon_attack, item, hit_left_weapon_primary, self_obj);
reg_anim_play_sfx(self_obj, sound, 0);
The valid values of the 1st parameter are:
snd_weapon_ready
snd_weapon_attack
snd_weapon_out
snd_weapon_ammo_flying
snd_weapon_hitting
The valid values (hit mode) of the 3rd parameter are:
hit_left_weapon_primary
hit_left_weapon_secondary
hit_right_weapon_primary
hit_right_weapon_secondary
hit_punch
hit_kick
hit_left_weapon_reload
hit_right_weapon_reload
These values are found in \mapper\scripts\headers\define.h
Another command sfx_build_char_name is for automatically building the sound associated with an animation:
sound := sfx_build_char_name(self_obj, ANIM_dancing_autofire, snd_die);
reg_anim_play_sfx(self_obj, sound, 0);
The valid values of the 3rd parameter were found in define.h
snd_knock_down
snd_pass_out
snd_die
snd_contact
Using these two commands most of the animations in my animation test script have the proper sounds playing.
There are also some other sounds defined:
/* GSound Values */
// gsound_character_types
#define snd_human (0)
#define snd_monster (1)
// gsound_character_extra
#define snd_unused (0)
#define snd_knock_down (1)
#define snd_pass_out (2)
#define snd_die (3)
#define snd_contact (4)
// gsound_sfx_action
#define snd_active (0)
#define snd_passive (1)
// gsound_sfx_weapon_action_type
#define snd_weapon_ready (0)
#define snd_weapon_attack (1)
#define snd_weapon_out (2)
#define snd_weapon_ammo_flying (3)
#define snd_weapon_hitting (4)
// gsound_sfx_scenery_action
#define snd_open (0)
#define snd_close (1)
#define snd_locked (2)
#define snd_unlocked (3)
#define snd_used (4)
// hit_mode
#define hit_left_weapon_primary (0)
#define hit_left_weapon_secondary (1)
#define hit_right_weapon_primary (2)
#define hit_right_weapon_secondary (3)
#define hit_punch (4)
#define hit_kick (5)
#define hit_left_weapon_reload (6)
#define hit_right_weapon_reload (7)
The thing is, I don't know how to play these other sounds (like the scenery ones). It looks to me like there are some other undocumented sfx commands to play them. We know two of the sfx commands (found in script source code) but I think there are others.
Here are some examples of code from the FO2 scripts:
sound := sfx_build_char_name(self_obj, ANIM_kick_leg, snd_contact);
sound := sfx_build_char_name(self_obj, ANIM_exploded_to_nothing, snd_die);
sound := sfx_build_char_name(self_obj, ANIM_throw_punch, snd_contact);
sound := sfx_build_char_name(self_obj, ANIM_fall_back, snd_knock_down);
sound := sfx_build_weapon_name(snd_weapon_hitting, obj_carrying_pid_obj(g1, PID_HK_G11E), hit_left_weapon_primary, self_obj);
The first command sfx_build_weapon_name is for automatically building the sound associated with a weapon:
item:=create_object(PID_GATLING_LASER,0,0);
add_mult_objs_to_inven(self_obj,item,1);
wield_obj(item);
sound := sfx_build_weapon_name(snd_weapon_attack, item, hit_left_weapon_primary, self_obj);
reg_anim_play_sfx(self_obj, sound, 0);
The valid values of the 1st parameter are:
snd_weapon_ready
snd_weapon_attack
snd_weapon_out
snd_weapon_ammo_flying
snd_weapon_hitting
The valid values (hit mode) of the 3rd parameter are:
hit_left_weapon_primary
hit_left_weapon_secondary
hit_right_weapon_primary
hit_right_weapon_secondary
hit_punch
hit_kick
hit_left_weapon_reload
hit_right_weapon_reload
These values are found in \mapper\scripts\headers\define.h
Another command sfx_build_char_name is for automatically building the sound associated with an animation:
sound := sfx_build_char_name(self_obj, ANIM_dancing_autofire, snd_die);
reg_anim_play_sfx(self_obj, sound, 0);
The valid values of the 3rd parameter were found in define.h
snd_knock_down
snd_pass_out
snd_die
snd_contact
Using these two commands most of the animations in my animation test script have the proper sounds playing.
There are also some other sounds defined:
/* GSound Values */
// gsound_character_types
#define snd_human (0)
#define snd_monster (1)
// gsound_character_extra
#define snd_unused (0)
#define snd_knock_down (1)
#define snd_pass_out (2)
#define snd_die (3)
#define snd_contact (4)
// gsound_sfx_action
#define snd_active (0)
#define snd_passive (1)
// gsound_sfx_weapon_action_type
#define snd_weapon_ready (0)
#define snd_weapon_attack (1)
#define snd_weapon_out (2)
#define snd_weapon_ammo_flying (3)
#define snd_weapon_hitting (4)
// gsound_sfx_scenery_action
#define snd_open (0)
#define snd_close (1)
#define snd_locked (2)
#define snd_unlocked (3)
#define snd_used (4)
// hit_mode
#define hit_left_weapon_primary (0)
#define hit_left_weapon_secondary (1)
#define hit_right_weapon_primary (2)
#define hit_right_weapon_secondary (3)
#define hit_punch (4)
#define hit_kick (5)
#define hit_left_weapon_reload (6)
#define hit_right_weapon_reload (7)
The thing is, I don't know how to play these other sounds (like the scenery ones). It looks to me like there are some other undocumented sfx commands to play them. We know two of the sfx commands (found in script source code) but I think there are others.
Here are some examples of code from the FO2 scripts:
sound := sfx_build_char_name(self_obj, ANIM_kick_leg, snd_contact);
sound := sfx_build_char_name(self_obj, ANIM_exploded_to_nothing, snd_die);
sound := sfx_build_char_name(self_obj, ANIM_throw_punch, snd_contact);
sound := sfx_build_char_name(self_obj, ANIM_fall_back, snd_knock_down);
sound := sfx_build_weapon_name(snd_weapon_hitting, obj_carrying_pid_obj(g1, PID_HK_G11E), hit_left_weapon_primary, self_obj);