Just help me figure this out. The sound for some reason works with a delay, after all the commands in the script, although I put it at the beginning. Why?
// by NWShacker, 04.2020 - makes oSelf "play" sound sSound
void PlaySoundNow(string sSound, object oSelf=OBJECT_SELF)
{
// spawn invisible placeable at oSelf's location
object oSound = CreateObject(OBJECT_TYPE_PLACEABLE,
"plc_invisobj", GetLocation(oSelf));
// make oSound play the sound
// (note: the short delay is needed for the sound)
DelayCommand(0.05, AssignCommand(oSound,
PlaySound(sSound)));
// make oSound destroy itself after playing
DelayCommand(0.5, AssignCommand(oSound,
ActionDoCommand(DestroyObject(OBJECT_SELF))));
}
void main()
{
object oPC = GetEnteringObject();
object oVi = GetNearestObjectByTag("VI");
object oBear = GetNearestObjectByTag("MM_BEAR3");
if (GetIsPC(oPC) && GetIsObjectValid(oBear) == FALSE && GetLocalInt(oPC, "brynrip") != TRUE)
{
//AddHenchman(oPC, oVi);
SetCutsceneMode(oPC);
BlackScreen(oPC);
SetLocalInt (oPC, "brynrip", TRUE);
AssignCommand(oVi, ClearAllActions());
AssignCommand(oVi, ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 2.0, 9999.9));
DelayCommand(0.2, SetCommandable(FALSE, oVi));
//ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectKnockdown(), oPC, 2.0);
AssignCommand(oPC, DelayCommand(0.8, PlaySound("bf_med_flesh")));
AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, ActionStartConversation(oPC, "bryn_rip", FALSE, FALSE));
AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 2.0, 9999.9));
DestroyObject(OBJECT_SELF, 1.0);
//DelayCommand(20.0, StopFade(oPC));
//DelayCommand(20.0, SetCutsceneMode(oPC, FALSE));
}
if (GetIsObjectValid(oBear) != FALSE && GetLocalInt(oPC, "brynrip") != TRUE)
{
PlaySoundNow("as_cv_gongring2");
BlackScreen(oPC);
SetLocalInt (oPC, "brynrip", TRUE);
AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 2.0, 9999.9));
AssignCommand(oBear, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectKnockdown(), oBear, 3.0));
AssignCommand(oBear, DelayCommand(4.0, ClearAllActions()));
AssignCommand(oBear, DelayCommand(4.1, ActionAttack(oPC)));
AssignCommand(oPC, DelayCommand(2.1, FadeFromBlack(oPC, FADE_SPEED_MEDIUM)));
DestroyObject(OBJECT_SELF, 1.0);
}
}
I recorded a video and set the Gong sound for clarity.