Answered How can I code that monkeys on Ascension always drop as first perk Juggernog?

BlackOpsModder

Veteran
Messages
80
Reaction score
20
Points
578
Hey guys basicly what I want to do is make the monkeys on Ascension always drop as first perk the jug perk and if the player alredy has jug give any alleatory perk, I found this code so far, but I don`t have a idea how to edit it, can someone help me?
It`s on _zombiemode_perks;gsc

Code:
give_random_perk()
{
    vending_triggers = GetEntArray( "zombie_vending", "targetname" );

    perks = [];
    for ( i = 0; i < vending_triggers.size; i++ )
    {
        perk = vending_triggers[i].script_noteworthy;

        if ( isdefined( self.perk_purchased ) && self.perk_purchased == perk )
        {
            continue;
        }

        if ( !self HasPerk( perk ) )
        {
            perks[ perks.size ] = perk;
        }
    }

    if ( perks.size > 0 )
    {
        perks = array_randomize( perks );
        self give_perk( perks[0] );
    }
}
 

CabCon

Head Administrator
Staff member
Head Staff Team
Messages
4,873
Reaction score
2,882
Points
1,053
Hey guys basicly what I want to do is make the monkeys on Ascension always drop as first perk the jug perk and if the player alredy has jug give any alleatory perk, I found this code so far, but I don`t have a idea how to edit it, can someone help me?
It`s on _zombiemode_perks;gsc

Code:
give_random_perk()
{
    vending_triggers = GetEntArray( "zombie_vending", "targetname" );

    perks = [];
    for ( i = 0; i < vending_triggers.size; i++ )
    {
        perk = vending_triggers[i].script_noteworthy;

        if ( isdefined( self.perk_purchased ) && self.perk_purchased == perk )
        {
            continue;
        }

        if ( !self HasPerk( perk ) )
        {
            perks[ perks.size ] = perk;
        }
    }

    if ( perks.size > 0 )
    {
        perks = array_randomize( perks );
        self give_perk( perks[0] );
    }
}
Here you go, this should work:
Code:
give_random_perk()
{
    vending_triggers = GetEntArray( "zombie_vending", "targetname" );

    perks = [];
    for ( i = 0; i < vending_triggers.size; i++ )
    {
        perk = vending_triggers[i].script_noteworthy;

        if ( isdefined( self.perk_purchased ) && self.perk_purchased == perk )
        {
            continue;
        }

        if ( !self HasPerk( perk ) )
        {
            perks[ perks.size ] = perk;
        }
    }

    if ( perks.size > 0 )
    {
        if ( !self HasPerk( "specialty_armorvest" ) )
        {
            perks[0] = "specialty_armorvest";
        }
        else
            perks = array_randomize( perks );
        self give_perk( perks[0] );
    }
}
 

BlackOpsModder

Veteran
Messages
80
Reaction score
20
Points
578
It worked! 3 out of 3 try gave me jug.
Can u explain me how this function exactly works?
THX alot man
 

CabCon

Head Administrator
Staff member
Head Staff Team
Messages
4,873
Reaction score
2,882
Points
1,053
It worked! 3 out of 3 try gave me jug.
Can u explain me how this function exactly works?
THX alot man
You're very much welcome. Take care.

Yes, sure. Commented the explanations.
The only part I changed was this one:
Code:
if ( perks.size > 0 )
   {
       perks = array_randomize( perks );
       self give_perk( perks[0] );
   }
to this:
Code:
if ( perks.size > 0 )
    {
        if ( !self HasPerk( "specialty_armorvest" ) ) //Here it will check if the player already got jug. The function self HasPerk( PERKNAME ) will check if the player already have a certain perk. The !-Operator adds the NOT to the if. (Feel free to google the !-Operator)
        {
            perks[0] = "specialty_armorvest"; //If the player doesn't got jug it will set the first index of the array from the collected perks to jug.
        }
        else //if the player already got jug
            perks = array_randomize( perks ); //it will randomize any other perk
        self give_perk( perks[0] ); //will give the first item from the perks array.
    }

Here is also a list with all 'GSC names' of the perks:
Code:
Perk Name:Juggernaut                 GSC Name: "specialty_armorvest"
Perk Name:Quickrevive                 GSC Name: "specialty_quickrevive"
Perk Name:Fastreload                 GSC Name: "specialty_fastreload"
Perk Name:Doubletap                 GSC Name: "specialty_rof"
Perk Name:Marathon                     GSC Name: "specialty_longersprint"       
Perk Name:Divetonuke                 GSC Name: "specialty_flakjacket"
Perk Name:Additionalprimaryweapon     GSC Name: "specialty_additionalprimaryweapon"
Perk Name:Deadshot                     GSC Name: "specialty_deadshot"

I hope this helped a bit. :y: If you would like to learn more about GSC take a look into our tutorial section: Tutorial Section | CabConModding If you only looking for Call of Duty: Black Ops 1 related scripts, take a look inside this section: Call of Duty: Black Ops 1 Scripts | CabConModding
 
Top