Jump to content

Photo

Timed Secrets


  • Please log in to reply
14 replies to this topic

#1 TheLegend_njf

TheLegend_njf

    Deified

  • Members
  • Real Name:Grant

Posted 01 May 2017 - 07:01 AM

I'd like a script that works like secret combos, but work similar to Ocarina of Time where a timer starts before they revert to normal.

 

The timer will have a clicking sound that will click faster the last 1 or 2 seconds, but I'd also like that to be an option for puzzles and rooms where I'd feel the clicking would actually be annoying. 



#2 Gégé

Gégé

    Senior

  • Members
  • Real Name:Gérard
  • Location:France

Posted 01 May 2017 - 09:25 AM

Maybe this
ffc script ChronoSecret{
    void run(int Time, int Click){
        int time = Time;
        int Chrono = Time/10;
        int Delay = Time/10;

        int chrono = Chrono;
        int delay = 0;


        	while(true){

                if(Time > 0){
                    Time --;

                    if(chrono > 0)chrono --;
                    else{
                        Delay /= 2;
                        chrono = Chrono;
                    } 

                    if(delay > 0)delay--;
                    else{
                        Game->PlaySound(Click);
                        delay = Delay;
                    }
                }
                else{
                    Screen->TriggerSecrets();
                    break;
                }
                
            Waitframe();
        }
    }
}
D0 = Time
D1 = Sfx Click

Each 10% of time, delay click is reduced.
If time 0, secret silent is triggered (Temporary)

#3 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 01 May 2017 - 09:56 AM

Remember that once secrets have been triggered you can't undo them, and for this to work the way you want, you need a way to go back and forth between states. So you could either use tiered secrets, or alter the script and change combos manually instead of using actual secrets.

 

Also make sure the script correctly resets the screen state every time you reenter the room, since you can't know in what state it'll be when the player leaves (thus interrupting the ffc script).



#4 ShadowTiger

ShadowTiger

    The Doctor Is In

  • Members

Posted 01 May 2017 - 02:43 PM

Remember that once secrets have been triggered you can't undo them,

WHAT?! :eek: Oh my god. I think I just had a heart attack. You're not kidding, are you? Not even via scripts? It can't be set to Screen->SECRET = false; or something syntactically incorrect?
  • Binx likes this

#5 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 01 May 2017 - 04:24 PM

Well, it's a bit sloppy to do so, but couldn't you just set an FFC script that changes a specific combo manually to whatever the "secret" is, then changes it back once the timer runs out? It might give you trouble if you're using the built-in door types (I haven't tested it), but I use combo-changing scripts for a number of purposes, in my quests (triggers, secrets, warps, etc); I can't imagine it would be too hard to set a timer to reset it (the biggest issue I could see is there being a limit to how many combos you could change per FFC trigger).

 

EDIT: Oh, I probably should have read the rest of Jamian's post, before commenting. Yeah, that seems to be the easiest way to do it, rather than using the built-in secrets.


WHAT?! :eek: Oh my god. I think I just had a heart attack. You're not kidding, are you? Not even via scripts? It can't be set to Screen->SECRET = false; or something syntactically incorrect?

I think the Screen->State[Secrets] thing only runs once per screen when Link enters a room, and only checks if secrets are permanent or temporary. Not sure if it can be manually triggered.


Edited by Binx, 01 May 2017 - 04:21 PM.


#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 May 2017 - 02:02 AM

Reverting secrets, is on the to-do list; alongside Screen->TriggerSecret(int id) .

One thing you may wish to consider, is that you can use timed combo cycling with inherent triggers, or other inherent flags, for this type of effect.

Edited by ZoriaRPG, 02 May 2017 - 02:09 AM.

  • Binx likes this

#7 TheLegend_njf

TheLegend_njf

    Deified

  • Members
  • Real Name:Grant

Posted 02 May 2017 - 04:34 PM

or alter the script and change combos manually instead of using actual secrets.

 

This was kinda what I had in mind actually. It'll work similar to how red/blue blocks work, or scripts of similar approaches. The script would alter combos, but still play the secret sfx correctly as if it were a secret.


  • Binx likes this

#8 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 May 2017 - 09:01 PM

This was kinda what I had in mind actually. It'll work similar to how red/blue blocks work, or scripts of similar approaches. The script would alter combos, but still play the secret sfx correctly as if it were a secret.

 

Fair enough: Will this suffice? It changes only one combo, at the position of the ffc. (You did not specify your precise end-goal, and I rolled a '1' on my Mentalism-ESP skill check.)

 

//////////////////////////////////
/// Reverting Secret Combo FFC ///
///      Requested by NJF      ///
///        By: ZoriaRPG        ///
///             v0.1           ///
///        3rd May, 2017       ///
//////////////////////////////////////////////////////////////////////////////////////////////
/// D0: The time in frames to wait before reverting.                                       ///
/// D1: The sound effect to play. Will play default if established and this is set to 0.   ///
/// D2: The combo to use. Will not change the combo graphicsa if set to 0.                 ///
///     Use -1 to change to Combo 0.                                                       ///
/// D3: The flag to use. Use a positive value for a flag, a negative value for an inherent ///
///     flag, or 0 for no change.                                                          ///
/// D4: The CSet to change into, 0 for no change. Use -1 for CSet 0.                       ///
/// D5: The solidity setting. Use 0 for no change, and use -1 to set to a solidity of '0'. ///
//////////////////////////////////////////////////////////////////////////////////////////////


const int SFX_UNSECRET = 0; //Set to a sound to use as a default for reverting secrets,
const int FFC_REVERT_SECRET_DEFAULT_TIME = 300; //A default amount of time.

ffc script RevertingTimedSecret{
    void run(int time, int sound, int combo, int flag, int cset, int solid){
        int cmb = ComboAt(this->X, this->Y); //Store the combo position for performance reasons.
        int c[6]; //Holds the original values for the combo that we are changing.
        //Set the default time if the D0 arg is unset.         
        if ( time <= 0 ) { time = FFC_REVERT_SECRET_DEFAULT_TIME };
        
        //Store the original values.
        c[0] = Screen->ComboD[cmb];
        c[1] = Screen->ComboF[cmb];
        c[2] = Screen->ComboI[cmb];
        c[3] = Screen->ComboC[cmb];
        c[4] = Screen->ComboT[cmb];
        c[5] = Screen->ComboS[cmb];
        
        while(true){
            //Wait until a secret on the screen is triggered.
            while(!Screen->State[ST_SECRETS]) { Waitframe(); continue; }
            
            //When a secret is triggered, run the changes.
            while(Screen->State[ST_SECRETS]) {
                if ( combo ) Screen->ComboD[cmb] = combo;
                if ( flag > 0 ) Screen->ComboF[cmb] = flag;
                if ( flag < 0 ) Screen->ComboI[cmb] = ( flag * -1 );
                if ( cset > 0 ) Screen->ComboC[cmb] = cset;
                if ( cset < 0 ) Screen->ComboC[cmb] = 0; //A way to set CSet 0.
                if ( type ) Screen->ComboT[cmb] = type;
                if ( solid > 0 ) Screen->ComboS[cmb] = vbound(solid, 1, 4);
                if ( solid < 0 ) Screen->ComboS[cmb] = 0; //A way to set Solid = 0.
                
                //Count down the timer and wait to revert.
                while (time--) { Waitframe(); }
                
                //! The timer has elapsed.
                
                //Play the sound if set.
                if ( sound ) Game->PlaySound(sound);
                if ( !sound && SFX_UNSECRET ) Game->PlaySound(SFX_UNSECRET);
                
                //Restore the combo.
                Screen->ComboD[cmb] = c[0];
                Screen->ComboF[cmb] = c[1];
                Screen->ComboI[cmb] = c[2];
                Screen->ComboC[cmb] = c[3];
                Screen->ComboT[cmb] = c[4];
                Screen->ComboS[cmb] = c[5];
                
                //Restore the time for this ffc, so that we can reactivate it later.
                if ( this->InitD[0] > 0 ) time = this->InitD[0];
                else time = FFC_REVERT_SECRET_DEFAULT_TIME;
                
                //Clear the secret state.
                Screen->State[ST_SECRETS] = false;
                Waitframe();
                continue;
            }
            Waitframe();
        }
    }
}

  • ShadowTiger likes this

#9 ShadowTiger

ShadowTiger

    The Doctor Is In

  • Members

Posted 03 May 2017 - 09:41 AM

//Clear the secret state.
Screen->State[ST_SECRETS] = false;
Waitframe();
continue;

Ah-HA!! So there is a way to undo a screen's secrets in "Screen->State[ST_SECRETS] = false;" - Is that permanent in the sense that it won't revert if you re-enter the screen? Will it stay untriggered if done that way?

Also, side note, if you don't mind. What is "continue;" ?

#10 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 03 May 2017 - 10:36 AM

Ah-HA!! So there is a way to undo a screen's secrets in "Screen->State[ST_SECRETS] = false;" - Is that permanent in the sense that it won't revert if you re-enter the screen? Will it stay untriggered if done that way?

Also, side note, if you don't mind. What is "continue;" ?

 

Yeah it's permanent and yeah you can undo a screens secret, it just won't immediatly change back the screen's secret combos until you re-enter the screen or manually revert the combos in the script.


  • ShadowTiger likes this

#11 ywkls

ywkls

    Master

  • Members

Posted 03 May 2017 - 10:52 AM

Ah-HA!! So there is a way to undo a screen's secrets in "Screen->State[ST_SECRETS] = false;" - Is that permanent in the sense that it won't revert if you re-enter the screen? Will it stay untriggered if done that way?

Also, side note, if you don't mind. What is "continue;" ?

I'm not sure that does anything other than change the Screen state, which is one of the things that the game checks to see if secrets have been triggered. Usually, to get secrets to stay triggered, you have to set that to true and use the command Screen->TriggerSecrets().

 

As for continue, in a loop, that skips all subsequent commands and starts the loop over.



#12 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 03 May 2017 - 04:19 PM

Yes, by "you can't undo secrets", I meant you can't do it automatically. Unless you script that manually, the player has to leave and re-enter the screen. 

 

@ywkls ZC only reads Screen->State[ST_SECRETS] once, when you enter the room. If it's checked, it'll activate secrets. If it's not, it won't check again until you leave and come back. This is why, if you want a script to activate your secrets immediately (which is what you normally want), you also need to add Screen->TriggerSecrets() to actually trigger the secrets. If you don't have that line, ZC will store in its memory that secrets in the room are activated, but won't actually notice, and do anything about it, until you leave and re-enter.

 

@NJF regarding Zoria's script: if you want to change more than one combo, you can just have a loop scan the room for every combo (from 0 to 175), and change accordingly. Unless you really need something fancy there, Screen->ComboD might very well be the only combo attribute you need to change.

 



#13 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 04 May 2017 - 06:10 AM

It occurs to me that a more useful way to do this, is to clear Screen->State[ST_SECRETS] and then PitWarp Link to the current screen.

 

I forgot the ticking timer sound in the script above, but if you want to revert all secrets on the screen, this alternative may be better for you.


Edited by ZoriaRPG, 04 May 2017 - 06:15 AM.


#14 ShadowTiger

ShadowTiger

    The Doctor Is In

  • Members

Posted 04 May 2017 - 11:00 AM

See, this is the sort of information (The past two or three posts, specifically) that really needs to be in some global repository of information when looking up these sorts of ... ... um, either pointers or... eh, I don't know what they're called. But there's an arrow pointing to the right in Screen->State[ST_SECRETS] so... :tard:

This is seriously useful knowledge to have. I hope it's as readily-available for perusal one day as it was easily written here.

#15 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 04 May 2017 - 08:01 PM

'm writing has... Detailed explanantions of using instructions, and functions,

See, this is the sort of information (The past two or three posts, specifically) that really needs to be in some global repository of information when looking up these sorts of ... ... um, either pointers or... eh, I don't know what they're called. But there's an arrow pointing to the right in Screen->State[ST_SECRETS] so... :tard:

This is seriously useful knowledge to have. I hope it's as readily-available for perusal one day as it was easily written here.

 

That is precisely why I am working on a manual in PDF format, although zscript.txt does cover this as an example, as I recall.

 

It does not revert the combos or flags, or triggers that were changed, when you do this; but rather, it reverses one bit in a flagset that ZC uses when visiting a screen to check if ZC should draw the screen with secrets changed.

 

I think I may need to create a new screen long, for secret states, so that it is possible to enable or revert secrets individually, with 32 possible secrets; or a short if we are only retaining 16. That will make it easier to handle triggering them, and saving only specific secrets; including from the editor.

 

Here is the other script:

 

//////////////////////////////////
///  Reverting Screen Secrets  ///
///      Requested by NJF      ///
///        By: ZoriaRPG        ///
///             v0.1           ///
///        5th May, 2017       ///
////////////////////////////////////////////////////////////////////////////////////////////////
/// D0: The time in frames to wait before reverting.                                         ///
/// D1: The un-secret soond to play.                                                         ///
///     Will play default (SFX_UNSECRETSFX_UNSECRET) if established and this is set to 0.    ///
/// D2: The duration of the reversion sound effect (in frames).                              ///
/// D3: The time (in frmes) at which the player is hurried and the clock tick sound          ///
///     doubles in pace. Thus, if you have a time of 500, and the last 100 frames should be  ///
///     a faster pace, set this to '100'.                                                    ///
/// D4: The sound for the clock tick.                                                        ///
///     Will play default to SFX_TIMER_TICK if set to '0'.                                   ///
/// D5: The duratrion of the clock tick sound.                                               ///
///     Will default to SFX_UNSECRET_DURATION if set to '0'.                                 ///
////////////////////////////////////////////////////////////////////////////////////////////////

//Sounds
const int SFX_UNSECRET = 0; //Set to a sound to use as a default for reverting secrets,
const int SFX_TIMER_TICK = 0; //Sound of a ticking clock.
 
//Durations
const int SFX_UNSECRET_DURATION = 40; //Frames of duration for SFX to play when reverting secrets.
const int SFX_TICKER_DURATION = 30; //Frames of duration of the tick sound.
const int FFC_REVERT_SECRET_DEFAULT_TIME = 300; //A default amount of time.
const int FFC_DEFAULT_UNSECRETS_HURRY = 120; //Frames in which the timer sound will be more rapid.

ffc script RevertingTimedSecretPitwarp{
    void run(int time, int sound, int sound_dur, int hurry, int hurrysound, int hurrysound_dur){
        int t[2]; //timers and flags.
        
        if ( !hurry ) {
            //Sanity checks for hurry.
            if ( FFC_DEFAULT_UNSECRETS_HURRY ) hurry = FFC_DEFAULT_UNSECRETS_HURRY;
            else hurry 120;
        }
        
        
         
        if ( time <= 0 ) { time = FFC_REVERT_SECRET_DEFAULT_TIME };
        
        while(true){
            //Wait until a secret on the screen is triggered.
            while(!Screen->State[ST_SECRETS]) { Waitframe(); continue; }

            //When a secret is triggered, run the changes.
            while(Screen->State[ST_SECRETS]) {
              
            
                //Count down the timer and wait to revert.
                while (time--) {
                    if ( time > hurry ) { //Normal rate of ticks.
                        if ( t[0] <= 0 ) { //If we have not played the sound.
                            
                            //Play it
                            if ( hurrysound ) Game->PlaySound(hurrysoud);
                            
                            //Set the sound repeat delay timer.
                            if ( hurrysound_dur) t[0] = (hurrysound_dur *2);
                            if ( !hurrysound_dur && SFX_TICKER_DURATION ) t[0] = (SFX_TICKER_DURATION * 2);
                        }
                    }
                    if ( time <= hurry ) { //Faster rate of ticks.
                        if ( t[0] <= 0 ) { //If we have not played the sound.
                            
                            //Play it
                            if ( hurrysound ) Game->PlaySound(hurrysoud);
                            
                            //Set the sound repeat delay timer.
                            if ( hurrysound_dur) t[0] = hurrysound_dur;
                            if ( !hurrysound_dur && SFX_TICKER_DURATION ) t[0] = SFX_TICKER_DURATION;
                        }
                    }
                    if ( t[0] > 0 ) { t[0]--; } //Decrememnt sound delay timer.
                    
                            
                            
                    
                    Waitframe();
                }
            
                //! The timer has elapsed.
                
                //Play the sound if set.
                if ( sound ) {
                    Game->PlaySound(sound);
                    t[1] = 1;     // t[1] is just a flag to know that we are ready
                            // to play thepre-warp sound.
                }
                if ( !sound && SFX_UNSECRET ){
                    Game->PlaySound(SFX_UNSECRET);
                    t[1] = 1;
                }
                
                //If we are ready to play a pre-warp sound...
                if ( t[1] > 0 ) {
                    if ( sound_dur ) { Waitframes(sound_dir+1); }
                    if ( !sound_dir && SFX_UNSECRET_DURATION ) { Waitframes(SFX_UNSECRET_DURATION+1); }
                    //Clear the secret state.
                    Screen->State[ST_SECRETS] = false;
                    
                    //Restore the time for this ffc, so that we can reactivate it later.
                    if ( this->InitD[0] > 0 ) time = this->InitD[0];
                    else time = FFC_REVERT_SECRET_DEFAULT_TIME;
                    
                    Link->PitWarp(GetCurDMap(), GetCurScreen());
                }
            
                Waitframe();
                continue;
            }
            Waitframe();
        }
    }
}

Edited by ZoriaRPG, 04 May 2017 - 08:33 PM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users