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

Buyable ending script

broken avatar :(
Created 10 years ago
by Masterdrvracer
0 Members and 1 Guest are viewing this topic.
4,903 views
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 5 March 2015
Last active: 5 years ago
Posts
3
Respect
Forum Rank
Fresh Corpse
Primary Group
Member
×
Masterdrvracer's Contact & Social Links
Hi, i have the standard TOM_BMX script for the buyable ending in my map but instead of requiring eletricity to buy i want that the player reaches a at least round 22 to buy it, i don't have any knowlege in scripting and i'm hoping someone can help

nazi_zombie_mapname.gsc

Code Snippet
Plaintext
level.tom_victory = false;
end_trig = getentarray( "end_game","targetname" );
array_thread( end_trig,::end_game );



end_game()
{
    user = undefined;
    cost = 22222;                                        //change to cost that you want

    self setCursorHint("HINT_NOICON");
    self UseTriggerRequireLookAt();
    self setHintString("The power must be activated first");                //remove line if you want it to work without power

    flag_wait( "electricity_on" );                                //remove line if you want it to work without power

    self setHintString("Pressione &&1 Para fugir no carro do Colono [Custo da Gasolina: "+cost+"]");            //text hint trigger

    while(1)
    {
        self waittill("trigger", user);
        if( is_player_valid(user) && user.score >= cost )
        {
            play_sound_at_pos( "cha_ching", self.origin );
            user thread maps\_zombiemode_score::minus_to_player_score( cost );
            self delete();

            level notify( "end_game" );
                        level notify("tom_planes");
            level.tom_victory = true;
        }
        else
        {
            play_sound_at_pos( "no_cha_ching", self.origin );
        }
    }
}

_zombiemode.gsc

Code Snippet
Plaintext
end_game()
{
    level waittill ( "end_game" );

    level.intermission = true;

    update_leaderboards();

    game_over = NewHudElem( self );
    game_over.alignX = "center";
    game_over.alignY = "middle";
    game_over.horzAlign = "center";
    game_over.vertAlign = "middle";
    game_over.y -= 10;
    game_over.foreground = true;
    game_over.fontScale = 3;
    game_over.alpha = 0;
    game_over.color = ( 1.0, 1.0, 1.0 );
    game_over SetText( &"ZOMBIE_GAME_OVER" );

    game_over FadeOverTime( 1 );
    game_over.alpha = 1;

    survived = NewHudElem( self );
    survived.alignX = "center";
    survived.alignY = "middle";
    survived.horzAlign = "center";
    survived.vertAlign = "middle";
    survived.y += 20;
    survived.foreground = true;
    survived.fontScale = 2;
    survived.alpha = 0;
    survived.color = ( 1.0, 1.0, 1.0 );

    if( level.round_number < 2 && level.tom_victory == false )
    {
        survived SetText( &"ZOMBIE_SURVIVED_ROUND" );
    }
    else if( level.tom_victory == false )
    {
        survived SetText( &"ZOMBIE_SURVIVED_ROUNDS", level.round_number );
    }
   
    if( level.tom_victory == true )
    {
        survived.color = ( 0.423, 0.004, 0 );
        survived SetText( "He is awesome!!!" );
    }

    //TUEY had to change this since we are adding other musical elements
    setmusicstate("end_of_game");
    setbusstate("default");

    survived FadeOverTime( 1 );
    survived.alpha = 1;

    wait( 1 );

    //play_sound_at_pos( "end_of_game", ( 0, 0, 0 ) );
    wait( 2 );
    intermission();

    wait( level.zombie_vars["zombie_intermission_time"] );

    level notify( "stop_intermission" );
    array_thread( get_players(), ::player_exit_level );

    bbPrint( "zombie_epilogs: rounds %d", level.round_number );

    wait( 1.5 );

    if( is_coop() )
    {
        ExitLevel( false );
    }
    else
    {
        MissionFailed();
    }



    // Let's not exit the function
    wait( 666 );
}
Marked as best answer by Masterdrvracer 10 years ago
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 10 December 2013
Last active: 4 years ago
Posts
159
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
My Contact & Social Links
More
×
Linoxet's Groups
Linoxet's Contact & Social LinksTutizillalinoxetbanguela
I'm not the best with scripting, but I think this can work

Code Snippet
Plaintext
end_game()
{
    level.round_to_escape = 22; //round to escape (round pra fugir no blindado)

    user = undefined;
    cost = 22222;                                        //change to cost that you want

    self setCursorHint("HINT_NOICON");
    self UseTriggerRequireLookAt();

    self setHintString("Pressione &&1 Para fugir no carro do Colono [Custo da Gasolina: "+cost+"]");            //text hint trigger

    while(1)
    {
        self waittill("trigger", user);
        if( is_player_valid(user) && user.score >= cost && level.round_number >= level.round_to_escape)
        {
            play_sound_at_pos( "cha_ching", self.origin );
            user thread maps\_zombiemode_score::minus_to_player_score( cost );
            self delete();

            level notify( "end_game" );
            level notify("tom_planes");
            level.tom_victory = true;
        }
        else
        {
            play_sound_at_pos( "no_cha_ching", self.origin );
        }
    }
}


Vamos todo mundo no meu carro, ele não toma tiro!
Eu tava tentando um mapa DPP também, não sei se tu lembra, sou o  Abundaminavel  :please:

EDIT: Fixed :p (Thanks Harry and buttkicker845)
Last Edit: January 22, 2016, 05:10:06 am by Linoxet
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
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.
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 LinksHarryBo000[email protected]HarryBo21
Code Snippet
Plaintext
if( level.round_number == level.round_to_escape ) //quando chegar no round 22, "libera" o trigger
{
level.can_scape = true;
}

Code Snippet
Plaintext
if( level.round_number == level.round_to_escape ) //quando chegar no round 22, "libera" o trigger
{
level.can_scape = true;
        wait .1;
}

add a wait, or if they "hold" the button, it may infinite loop - depending on if the trigger is already set to delay or not ( triger use is, trigger raidius isnt for example )

your also waiting on "between round over" from round 1 onwards. As its then "waiting" for someone to touch the tigger before continuing & your not checking equal to "or greater"
Last Edit: January 22, 2016, 05:08:24 am by Harry Bo21
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
Signature
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
Code Snippet
Plaintext
end_game()
{
level.round_to_escape = 22; //round to escape (round pra fugir no blindado)
level.can_scape = false;
    user = undefined;
    cost = 22222;                                        //change to cost that you want

    self setCursorHint("HINT_NOICON");
    self UseTriggerRequireLookAt();

    self setHintString("Pressione &&1 Para fugir no carro do Colono [Custo da Gasolina: "+cost+"]");            //text hint trigger

    while(1)
    {
    level waittill( "between_round_over" );

if( level.round_number == level.round_to_escape ) //quando chegar no round 22, "libera" o trigger
{
level.can_scape = true;
}

        self waittill("trigger", user);
        if( is_player_valid(user) && user.score >= cost && level.can_scape == true)
        {
            play_sound_at_pos( "cha_ching", self.origin );
            user thread maps\_zombiemode_score::minus_to_player_score( cost );
            self delete();

            level notify( "end_game" );
            level notify("tom_planes");
            level.tom_victory = true;
        }
        else
        {
            play_sound_at_pos( "no_cha_ching", self.origin );
        }
    }
}
you were on the right track but there are some things that would should be done differently
first remove this.
Code Snippet
Plaintext
                level waittill( "between_round_over" );

if( level.round_number == level.round_to_escape ) //quando chegar no round 22, "libera" o trigger
{
level.can_scape = true;
}

and then change this if statement
Code Snippet
Plaintext
if( is_player_valid(user) && user.score >= cost && level.can_scape == true)
to look like this
Code Snippet
Plaintext
if( is_player_valid(user) && user.score >= cost && level.round_number >= level.round_to_escape)
this will make it so whenever the player tries to activate the trigger it will test to see if they have reached round 22 or greater instead of only being able to work at the end of the round specifically on round 22

PS: instead of doing this
Code Snippet
Plaintext
if(level.can_scape == true)
it is more common to write it as this
Code Snippet
Plaintext
if(level.can_scape)
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
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.
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 LinksHarryBo000[email protected]HarryBo21
Quote
it is more common to write it as this
Code Snippet
Plaintext
if(level.can_scape)

Actually thatll go wrong if it were undefined, should use this

Code Snippet
Plaintext
if( isDefined( level.can_scape ) && level.can_scape )

otherwise you can get incorrect "true/false returns" - depending on the code its used in

or make a "is_true" function like treyarch did

Code Snippet
Plaintext
isTrue( value )
{
    if ( isDefined( value ) && value )
        return true;

    return false;
}
Last Edit: January 22, 2016, 05:12:28 am by Harry Bo21
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
Actually thatll go wrong if it were undefined, should use this

Code Snippet
Plaintext
if( isDefined( level.can_scape ) && level.can_scape )

thats true i forgot about the possibility of undefined. i was just trying to explain that you dont have to test for equals to when using boolean values.
Code Snippet
Plaintext
isTrue( value )
{
    if ( isDefined( value ) && value )
        return true;

    return false;
}
where is this method located? i have yet to find it in any files
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
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.
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 LinksHarryBo000[email protected]HarryBo21
they began using it from BO1 onwards

they used it before just didnt have a seperate function, so did the ( isDefined( value ) && value ) thing in the argument rather than using a function

i also saw in WAW they occasionally sloppily use

Code Snippet
Plaintext
while( 1 )
{
    if ( !isDefined( value ) )
        return;
}

which is "ok" to use, but they did it in a really sloppy wa in a number of places

Its in the BO1 code, but i actually just wrote that. Safe bet thats all it did

and ofc, is false

Code Snippet
Plaintext
isFalse( value )
{
    if ( isDefined( value ) && !value )
        return true;

    return false;
}



at a guess they will be defined in black ops 1 _utility.gsc or common_scripts




Speaking of shitty treyarch coding, heres another

Code Snippet
Plaintext
in_active_zone( origin );

in zombiemode_utility ( its something like that anyway )

you would presume it checks if that origin is in a zone, and if the zone is active, but theres a mistake. It forgot to check if its "true"

Code Snippet
Plaintext
if ( isdefined( zone[ i ] ) && isDefined( zone[ i ].is_enabled ) )

thats all they did, needed this

Code Snippet
Plaintext
if ( isdefined( zone[ i ] ) && isDefined( zone[ i ].is_enabled ) && zone[ i ].is_enabled )


I think they never actually fixed this as eventually they wrote a second function

Code Snippet
Plaintext
is_in_enabled_zone( origin )

and they periodically switch between the two "identical" function in BO2 ( although "active_zone" was fixed in BO2 )
Last Edit: January 22, 2016, 05:30:57 am by Harry Bo21
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
they began using it from BO1 onwards

they used it before just didnt have a seperate function, so did the ( isDefined( value ) && value ) thing in the argument rather than using a function
that would explain why i havent found it anywhere in waw.  i might have to go and change any of my statements from (isDefined(value) && value) to the isTrue method. thanks for the new utility lol :)
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
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.
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 LinksHarryBo000[email protected]HarryBo21
lol read my post again, just edited it to show another treyarch fail you may need

I only noticed coz i was testing my monkeys so flew through one of my doors, threw it, and it still counted as "in bounds" despite me using that check and manually entering a "inactive" zone lol. When i looked i saw why instantly...


In theory this means, if you played Der Riese, and threw a monkey into another zone that was still closed - it would count, and all the zombies would freeze in place coz they cant "get" there
Last Edit: January 22, 2016, 05:33:44 am by Harry Bo21
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
Signature
Let's keep this thread on topic from here on in. -DBZ

+1 to off-topic reply -DBZ

lmao. Too funny.

Goliath Script Placer: http://ugx-mods.com/forum/index.php/topic,11234.msg125257/topicseen.html#new

"...Christ, people. Learn C, instead of just stringing random characters
together until it compiles (with warnings)..."

-Linus Torvalds
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Code Snippet
Plaintext
isTrue( value )
{
    if ( isDefined( value ) && value )
        return true;

    return false;
}

How to script like Treyarch:

1. Create a bunch of bogus functions that do literally nothing

2. Create functions using bogus logic

3. Duplicate a function everytime you need to use it in a campaign level instead of including it into a utility where it can be accessed once with the same code.

4. Leave commented code from the initial release of the game in the scripts

Edit:

For call of duty games in general. So many crappy utility functions that use bogus logic.
Last Edit: January 22, 2016, 05:49:40 am by daedra descent
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
yeah its possible, ive done it before by throwing a monkey over the door that leads to the teleporter by the power.

ive also noticed that there are a multitude of both utility and engine methods that i can not find any trace of actually being used.


How to script like Treyarch:

1. Create a bunch of bogus functions that do literally nothing

2. Create functions using bogus logic

3. Duplicate a function everytime you need to use it in a campaign level instead of including it into a utility where it can be accessed once with the same code.

4. Leave commented code from the initial release of the game in the scripts

Edit:

For call of duty games in general. So many crappy utility functions that use bogus logic.
cant forget to include a bunch of methods that are never used in your own scripts!
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
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.
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 LinksHarryBo000[email protected]HarryBo21
cant realy deny that, although their work in BO2 is monumentally better than some of the complete and utter shit ive seen in WAW lol

like the jugg bug... 3 entire maps and still didnt get fixed


even then tho they do some way overcomplicated shit. Should see brutus script lol

Like following a piece of string in a bundle



Ill admit tho i struggle deciding what should be placed in a shared utility, have to be careful not to be calling anything that may error if that "other thing" doesnt exist

I had a bit of logic for redirecting AI, but relied on changes i made to zombiemode_spawner so when i handed my utility out with something else, everyone got game crashes lol



anything you cant find in the game scripts are usually written in the engine. Sometimes theres a few missing off the script references. I work it out this way

wordWord() - engine based
word_word() - treyarch made it
Last Edit: January 22, 2016, 06:02:18 am by Harry Bo21
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet

anything you cant find in the game scripts are usually written in the engine. Sometimes theres a few missing off the script references. I work it out this way

wordWord() - engine based
word_word() - treyarch made it

Engine must be written in C++ then, since wordWord is what you'd do for an Object Orientated language.

Safe to say, GSC isn't.
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
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.
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 LinksHarryBo000[email protected]HarryBo21
thought that was just ettiquette. I see people arguing about it all the time online lol

a javascript engine i used followed this logic too, any calls in that format were just further calling a method coded in the C+ engine

I was a newbie back then tho, years ago
Last Edit: January 22, 2016, 06:10:28 am by Harry Bo21
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 5 March 2015
Last active: 5 years ago
Posts
3
Respect
Forum Rank
Fresh Corpse
Primary Group
Member
×
Masterdrvracer's Contact & Social Links
Ok thanks everybody for the help  :)

Double Post Merge: January 22, 2016, 11:59:31 am
I'm not the best with scripting, but I think this can work

Code Snippet
Plaintext
end_game()
{
    level.round_to_escape = 22; //round to escape (round pra fugir no blindado)

    user = undefined;
    cost = 22222;                                        //change to cost that you want

    self setCursorHint("HINT_NOICON");
    self UseTriggerRequireLookAt();

    self setHintString("Pressione &&1 Para fugir no carro do Colono [Custo da Gasolina: "+cost+"]");            //text hint trigger

    while(1)
    {
        self waittill("trigger", user);
        if( is_player_valid(user) && user.score >= cost && level.round_number >= level.round_to_escape)
        {
            play_sound_at_pos( "cha_ching", self.origin );
            user thread maps\_zombiemode_score::minus_to_player_score( cost );
            self delete();

            level notify( "end_game" );
            level notify("tom_planes");
            level.tom_victory = true;
        }
        else
        {
            play_sound_at_pos( "no_cha_ching", self.origin );
        }
    }
}


Vamos todo mundo no meu carro, ele não toma tiro!
Eu tava tentando um mapa DPP também, não sei se tu lembra, sou o  Abundaminavel  :please:

EDIT: Fixed :p (Thanks Harry and buttkicker845)

My DPP map it's not spetacular it's really basic to be fair (speaking in english with you to comply with the forum rules) :poker:
Last Edit: January 22, 2016, 11:59:31 am by Masterdrvracer

 
Loading ...