Jump to content

Photo

Small Easy Script Request


  • Please log in to reply
3 replies to this topic

#1 Dawnlight

Dawnlight

    My name is NOT Jason!

  • Members
  • Real Name:Justin
  • Location:Chicago, IL

Posted 21 December 2012 - 07:42 PM

I need a script where when a secret is activated, it's followed by a String after a certain period of time.

Something like this:
Trigger Secret -> All Actions Freeze for about 1 Second -> a sound plays (in this case, a door opening from far away) -> All actions freeze for another second -> String Plays

If you can produce a script like this, that would be awesome. Will add you to credits.

Thanks!

Edited by Dawnlight, 21 December 2012 - 07:43 PM.


#2 Kite

Kite

    ???

  • Members

Posted 21 December 2012 - 09:48 PM

I'm really rusty with scripting since I literally haven't touched it for a few months. So hopefully this FFC Script works somewhat like what you wanted (the input values are documented in the comments at the top). If not, then I just goofed horribly. icon_razz.gif

I had to take some liberties since ZC cannot automatically determine the length of a sound effect and wait for it to finish playing. So basically, you need to enter a pause value (in frames) before the SFX plays followed by how long you want the pause to continue once the SFX starts playing (in frames). So for instance, you could enter 60 frames for D1 to make ZC wait around for a second then you could enter 140 frames for D2 if your sfx lasts for around 80 frames and you want to add one second of padding afterwards.

Also, this script will only work with permanent secrets. If you want to use temporary secrets to trigger it, checking for combo flags on the screen or something similar would have to be done.

CODE
import "std.zh"

// D0 = SFX to play
// D1 = Length to wait before playing SFX in frames (60 frames ~ 1 second)
// D2 = Length to wait when SFX starts playing until the string happens in frames (ZC doesn't have a way to wait for a SFX to finish playing automatically)
// D3 = String to play
// Note: This will only work with permanent secrets. If you want temporary secrets, you'd probably have to keep track of secret flags on the screen.
// Note2: This will not freeze FFCs since they kind of need to remain running for the script to work.
ffc script soundFreeze
{
    void run(int sfx, int pause_length, int sfx_length, int string)
    {
        bool firstRun = Screen->State[ST_SECRET]; // Check to see if secrets were set off already to avoid triggering script immediately on a screen entrance.
        while(!firstRun)
        {
            if(Screen->State[ST_SECRET]) // Secrets activated while on the screen.
            {
                int tempComboType = Screen->ComboT[0]; // Store combo type to restore it later.
                // Pause for pause length
                Screen->ComboT[0] = CT_SCREENFREEZE;
                Waitframes(pause_length);            
                // Play Sound
                Game->PlaySound(sfx);
                // Wait for "length" of sfx and then padding
                Waitframes(sfx_length);
                // Unpause
                Screen->ComboT[0] = tempComboType;
                // Play String
                Screen->Message(string);
                // Set script as executed
                firstRun = true;
            }
            Waitframe();
        }//!End while(!firstRun)
    }//!End void run()
}//!End ffc script soundFreeze


#3 Soga

Soga

    Secretly Alive

  • Members

Posted 21 December 2012 - 10:49 PM

I have an idea for a way to make your script also automatically work for temporary secrets. What if you had D4 be the position of the secret combo and D5 be the ID of the secret combo used when the secret is activated? That way, all you have to do is check if the combo at that position has turned into the secret combo.

#4 Dawnlight

Dawnlight

    My name is NOT Jason!

  • Members
  • Real Name:Justin
  • Location:Chicago, IL

Posted 22 December 2012 - 12:05 PM

It works perfectly!

Thank you SO much Nick! icon_smile.gif I appreciate it!

Edited by Dawnlight, 22 December 2012 - 12:05 PM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users