UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Round break

broken avatar :(
Created 9 years ago
by Soy-Yo
0 Members and 1 Guest are viewing this topic.
4,028 views
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 3 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
Signature
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
I need this for my map, so I made the script and decided to make a tutorial for this. If there's already one I'm sorry, but I haven't found any (at least here).
It's like in Grid Lock: when you finish a round you have a break to do whatever you want without zombies. The break will end when the time is out or when the host press enter (you might want to change it to other thing).
I haven't tested it online, but it should work well. And please, report me any bug.

Let's start.


If you have NOT done it before, go to root/raw/maps and copy _zombiemode.gsc.
Then go to root/mods/YOUR_MOD_NAME/maps and paste it there.

If you already had this file there you should backup it !!

Open it with the text editor of your choice.

First, find these lines:

Code Snippet
Plaintext
level.custom_introscreen = ::zombie_intro_screen; 
level.custom_intermission = ::player_intermission;
level.reset_clientdvars = ::onPlayerConnect_clientDvars;
and copy this just below:
Code Snippet
Plaintext
level.roundBreakTimeout = 200; // number of seconds of round break

Feel free to change "200" to the time you want the round break to be.

Now find this function:

Code Snippet
Plaintext
chalk_round_hint()

and replace it entirely with:

Code Snippet
Plaintext
chalk_round_hint(br)
{
fade_time = 0.5;

huds = [];
huds[huds.size] = level.chalk_hud1;

if( level.round_number > 5 && level.round_number < 11 )
{
huds[huds.size] = level.chalk_hud2;
}

    // --- Soy-yo's round break --- \\

    if( isDefined( br ) && br ) {
        hud = create_simple_hud();
        hud.alignX = "left";
        hud.alignY = "bottom";
        hud.horzAlign = "left";
        hud.vertAlign = "bottom";
        hud.color = (1,1,1);
        hud.alpha = 0;
        hud.fontScale = 12;
        hud setText( "BREAK" );

        array_thread( huds,::hideRoundHuds,fade_time );
        wait(fade_time * 2);

        hud fadeOverTime(fade_time);
        hud.alpha = 1;
        wait(fade_time);
        hud fadeOverTime(fade_time);
        hud.color = ( 0.423, 0.004, 0 );

        level notify( "round_break_hud_created" );

        level waittill( "round_break_finished" );

        hud fadeOverTime(fade_time);
        hud.color = (1,1,1);
        wait(fade_time);
        hud fadeOverTime(fade_time);
        hud.alpha = 0;
        wait(fade_time);

        array_thread( huds,::showRoundHuds,fade_time );

        hud destroy_hud();

        return;
    }

    // --- Soy-yo's round break --- \\


time = level.zombie_vars["zombie_between_round_time"];
for( i = 0; i < huds.size; i++ )
{
huds[i] FadeOverTime( time * 0.25 );
huds[i].color = ( 1, 1, 1 );
}
if(IsDefined(level.eggs) && level.eggs !=1)
{
if(IsDefined(level.doground_nomusic  && level.doground_nomusic == 0 ))
{
setmusicstate("round_end");
wait( time * 0.25 );
}
else if(IsDefined(level.doground_nomusic  && level.doground_nomusic == 1 ))
{
play_sound_2D( "bright_sting" );

}
}
// play_sound_at_pos( "end_of_round", ( 0, 0, 0 ) );



// Pulse
//fade_time = 0.5;
steps =  ( time * 0.5 ) / fade_time;
for( q = 0; q < steps; q++ )
{
for( i = 0; i < huds.size; i++ )
{
if( !IsDefined( huds[i] ) )
{
continue;
}

huds[i] FadeOverTime( fade_time );
huds[i].alpha = 0;
}

wait( fade_time );

for( i = 0; i < huds.size; i++ )
{
if( !IsDefined( huds[i] ) )
{
continue;
}

huds[i] FadeOverTime( fade_time );
huds[i].alpha = 1;
}

wait( fade_time );
}

for( i = 0; i < huds.size; i++ )
{
if( !IsDefined( huds[i] ) )
{
continue;
}

huds[i] FadeOverTime( time * 0.25 );
// huds[i].color = ( 0.8, 0, 0 );
huds[i].color = ( 0.423, 0.004, 0 );
huds[i].alpha = 1;
}
}

Now find this line inside this function and comment it:

Code Snippet
Plaintext
// FUNCTION
round_think()
// ---------- \\
// COMMENT THIS LINE:
level thread spectators_respawn();
// ---------- \\

It should look like:

Code Snippet
Plaintext
// ... code above

        round_wait();
        level.first_round = false;

        // level thread spectators_respawn();

        //        round_text( &"ZOMBIE_ROUND_END" );
        level thread chalk_round_hint();

// ... code below

Find the "round_wait()" function and inside of it, just at the end, add this lines:

Code Snippet
Plaintext
// --- Soy-yo's round break --- \\

breakHud = createTimerHud();
roundBreak();
level notify( "round_break_finished" );
level.inRoundBreak = false; // may need it for other scripts
breakHud destroy_hud();

// --- Soy-yo's round break --- \\

Finally, add these functions just bellow the "round_wait()" function (outside of it).

Code Snippet
Plaintext
// --- Soy-yo's round break --- \\

hideRoundHuds(f) {
    self fadeOverTime(f);
    self.color = (1,1,1);
    wait(f);
    self fadeOverTime(f);
    self.alpha = 0;
}

showRoundHuds(f) {
    self fadeOverTime(f);
    self.alpha = 1;
}
roundBreak() {

    level notify( "round_break_started" ); // may need it for other scripts
    level.inRoundBreak = true; // may need it for other scripts
    self endon( "enter_pressed" );

    level thread spectators_respawn(); // make everyone respawn first

    thread chalk_round_hint(true);

    thread keyListenerInit( get_players()[0],"enter" );

    wait( level.roundBreakTimeout );

}

keyListenerInit(player,key) { // only for host, easy to change for everyone

    //level endon( "round_break_finished" );

    level waittill( "round_break_hud_created" ); // wait until hud is created to avoid bugs

    hint = create_simple_hud( player );
    hint.foreground = true;
    hint.hidewheninmenu = true;
    hint.alignX = "center";
    hint.alignY = "middle";
    hint.horzAlign = "center";
    hint.vertAlign = "middle";
    hint.y = -48;
    hint.alpha = 1;
    hint.fontScale = 1.25;
    hint setText( "Press ENTER to start round " + (level.round_number + 1) );

    pressed = getIfKeyPressed(player,key);
    //while(1) {
    //     if( player buttonPressed(key) ) break;
    //     wait(0.1);
    //}

    hint destroy_hud();

    if( pressed ) self notify( "enter_pressed" );
}

getIfKeyPressed(pl,k) {

    level endon( "round_break_finished" );

    while(1) {
         if( pl buttonPressed(k) ) return true;
         wait(0.1);
    }

    return false;
}

createTimerHud() {
    hud = create_simple_hud();
    hud.foreground = true;
    hud.hidewheninmenu = false;
    hud.alignX = "right";
    hud.alignY = "top";
    hud.horzAlign = "right";
    hud.vertAlign = "top";
    hud.x = -2;
    hud.y = -2;
    hud.alpha = 1;
    hud.fontScale = 9;
    hud.color = ( 0.423, 0.004, 0 );
    hud setTimer( level.roundBreakTimeout );

    return hud;
}

// --- Soy-yo's round break --- \\

If you want to do something when the round break starts or if you need to check if you are in the round break you can use this:

Code Snippet
Plaintext
level waittill( "round_break_started" ); // do something when break starts
level waittill( "round_break_finished" ); // do something when break ends
level endon( "round_break_started" ); // end your function when break starts
level endon( "round_break_finished" ); // end your function when break ends
Code Snippet
Plaintext
if( isDefined( level.inRoundBreak ) && level.inRoundBreak ) // you are in round break
if( !isDefined( level.inRoundBreak ) || !level.inRoundBreak ) // you are NOT in round break
if( isDefined( level.inRoundBreak ) && !level.inRoundBreak ) // you are NOT in round break and NOT in round 1
if( !isDefined( level.inRoundBreak ) ) // you are in round 1 and not in a break
if( isDefined( level.inRoundBreak ) ) // you are in round break or not, but not in round 1

If you use it in your map, please give credit to me. Enjoy it. :)
Last Edit: October 18, 2015, 12:12:21 pm by Soy-Yo
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 4 years ago
Posts
6,877
Respect
1,004Add +1
Forum Rank
Immortal
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Signature
If you want scripts / features made for you, then contact me by PM or email / skype etc
it will cost you tho so if you have no intention of reciprocating don't even waste my time ;)
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social Links[email protected]HarryBo21HarryBo000
if you change it to do this :

Code Snippet
Plaintext
in round : level.inRoundBreak = undefined

not in round : level.inRoundBreak = true

then people ca use this

Code Snippet
Plaintext
if ( isDefined( level.inRoundBreak ) && level.inRoundBreak )
{
    // if round break is defined "and" is true
}
else
{
    // otherwise its false "or" undefined
}


that would resolve your round 1 issue
Last Edit: October 10, 2015, 11:05:06 pm by Harry Bo21
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 3 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
if you change it to do this :

Code Snippet
Plaintext
in round : level.inRoundBreak = undefined

not in round : level.inRoundBreak = true

then people ca use this

Code Snippet
Plaintext
if ( isDefined( level.inRoundBreak ) && level.inRoundBreak )
{
    // if round break is defined "and" is true
}
else
{
    // otherwise its false "or" undefined
}


that would resolve your round 1 issue
Maybe I didn't understand you, but I wouldn't need to change anything then, right? Because in round 1 the variable isn't defined yet, so it'll return undefined (I said null in the post, I'll change it). And then, during any other round, the variable will be false.
Did you mean to change this line...
Code Snippet
Plaintext
level.inRoundBreak = false
...to....
Code Snippet
Plaintext
level.inRoundBreak = undefined
...?
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 4 years ago
Posts
6,877
Respect
1,004Add +1
Forum Rank
Immortal
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social Links[email protected]HarryBo21HarryBo000
yes thats exactly it ;)

instead of setting it false after, set it back to undefined

treyarch used this for the is_drinking stuff, which actually caused me to break all their scripts by doing it the opposite way on my old perks lol. Only noticed when smashers bowie knife broke - along with everone elses lol

they use

Code Snippet
Plaintext
if ( isDefined( player.is_drinking ) )
{
    wait .1;
    continue;
}

i was setting is_drinking to false

so "isDefined" was returning true, no matter what, stopping the player from interacting with anything treyarch that was "wanting" it to become undefined lol

oops lol


plus this way gives you 4 options for usage too :

Code Snippet
Plaintext
if ( isDefined( level.inRoundBreak ) && level.inRoundBreak ) // If is defined, and value is true / 1

if ( isDefined( level.inRoundBreak ) && !level.inRoundBreak ) // If is defined, and value is false / 0

if ( isDefined( level.inRoundBreak ) ) // If it is defined now, regardless of true / false

if ( !isDefined( level.inRoundBreak ) ) // If it isnt defined at all now
Last Edit: October 10, 2015, 11:28:46 pm by Harry Bo21

 
Loading ...