'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.