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

[TUT]Add bubble gum

broken avatar :(
Created 2 years ago
by HunShen
0 Members and 1 Guest are viewing this topic.
868 views
broken avatar :(
×
broken avatar :(
Location: cn托里市
Date Registered: 8 November 2022
Last active: 1 year ago
Posts
17
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
HunShen's Groups
HunShen's Contact & Social LinksHUNSHEN
root/mods/mapname/maps/mapname.gsc
 
Code Snippet
Plaintext
level thread DLC3_threadCalls();
thread gobble_gum_machine();

mapname.gsc
Code Snippet
Plaintext
gobble_gum_machine()
{
    //image of gobble gum
    PrecacheShader( "specialty_gobble_gum_zombies");
    PrecacheShader( "specialty_nuke");
    //cost of gobble gum buy
    cost = 500;
 
    //activate the following script code when player buys perk
    trigger = getEnt("gobble_gum_trigger", "targetname");
 
 
    bought_round_number = undefined;
    //level.round_number = 0;
    last_round = 0;
 
    trigger setHintString ("Hold &&1 to dispense Gobble Gum [500]");
 
        //hold code till trigger is activated
        trigger waittill("trigger", player);
 
        using_player = player;
 
        //random gumball script here
            //--------------------------------------
        gobble_gums_index = 0;
 
        gobble_gums = ;
 
        add_to_array("gobble_gums","insta_kill");
        add_to_array("gobble_gums","double_points");
        add_to_array("gobble_gums","nuke");
        add_to_array("gobble_gums","plain_sight");
        add_to_array("gobble_gums","pack_a_punch");
 
        //gobble_gum = gobble_gums[RandomInt(gobble_gums.size)];
 
        //gobble_gum = array_randomize(gobble_gums);
 
        //if( gobble_gums_index >= gobble_gums.size )
        //{
        //    gobble_gums_index = 0;
        //    randomize_gobble_gums(gobble_gums);
        //}
 
        //gobble_gums_index++;
 
        //--------------------------------------
        //final gumball selected from script
        //this pack a punch gobble gum packs my current gun for 30 seconds and then returns the old one after the time has ran out!
        gumball = "pack_a_punch";
        //this gumball code will give me the gumball without picking a random one
        //--------------------------------------
 
 
        if ( player.score < cost )
        {
            //player iprintln( "Not enough points to buy Perk: " + perk );
            self playsound("deny");
            player thread play_no_money_perk_dialog();
            //continue;
        }
        else
        {
            //blur players view for effect
            player setblur( 4, 0.1 );
            wait(0.6);
            player setblur(0, 0.1);
 
            //add the image of the shader to the hud
            player thread gumball_hud_create(gumball);
 
            //subtract players points for the cost of the gobble gum machine
            player maps\_zombiemode_score::minus_to_player_score(cost);
 
            player thread gobble_gum_activate(using_player, gumball);
 
            //bought_round_number = level.round_number;
        }
 
        //rerun the gobble gum machine script so it keeps running
        thread gobble_gum_machine();
 
}
 
gobble_gum_activate(using_player, gumball)
{
    perk_bottle = "specialty_quickrevive";
    while(1)
    {
        if(using_player useButtonPressed())
        {
            if(gumball == "none")
            {
                //iprintln("You have no gobble gums!");
            }
            else
            {
                //get players gun
                gun = self GetCurrentWeapon();
 
                //eat gobble gum when pressed button
                thread perk_give_bottle_begin(perk_bottle);
 
                //play blowing bubble sound effect
                //using_player playsound("blowing_gobble_gum");
                //notify player the gumball is being chewed (the player has the gumball)
                iprintln("Chewing Gobble Gum!");
                wait 3;
                thread perk_give_bottle_end(gun, perk_bottle);
 
                //remove gobble gum from hud because it was used
                using_player thread gumball_hud_destroy(gumball);
 
                //player eat gumball and recieve effects
                thread player_eat(gumball, using_player, gun);
                using_player setElectrified(true);
                gumball = "none";
            }
            wait 1;
        }
        wait 0.01;
 
    }
}
 
player_eat(gumball, using_player, gun)
{
    if(gumball == "insta_kill")
    {
        maps\_zombiemode_powerups::insta_kill_powerup();
    }
    if(gumball == "nuke")
    {
        maps\_zombiemode_powerups::nuke_powerup();
    }
    if(gumball == "max_ammo")
    {
        maps\_zombiemode_powerups::full_ammo_powerup();
    }
    if(gumball == "carpenter")
    {
 
    }
    if(gumball == "double_points")
    {
        maps\_zombiemode_powerups::double_points_powerup();
    }
    if(gumball == "pack_a_punch")
    {
        //time how long the player gets to use their pack-a-punched gun (seconds)
        level.packapunch_timeout = 30;
 
        packa_timer = spawn("script_origin", self.origin);
 
        using_player TakeWeapon(gun);
        using_player GiveWeapon(gun+"_upgraded");
        //using_player GiveMaxAmmo(gun+"_upgraded");
        using_player switchToWeapon(gun+"_upgraded");
 
        self thread wait_for_timeout(packa_timer);
        self waittill("pap_timeout");
 
        using_player TakeWeapon(self GetCurrentWeapon());
        wait 0.01;
        using_player GiveWeapon(gun);
        using_player switchToWeapon(gun);
    }
    //perkacholic is still beta
    if(gumball == "perkacholic")
    {
        using_player perk_hud_create("specialty_armorvest");
        using_player perk_hud_create("specialty_quickrevive");
        using_player perk_hud_create("specialty_fastreload");
        using_player perk_hud_create("specialty_rof");
        using_player.health = 300;
    }
    if(gumball == "plain_sight")
    {
        zombies = getaiarray("axis");
        zombies flagEnemyUnattackable();
    }
    if(gumball == "anywhere_but_here")
    {
        doggie = getent("start_zone_spawners_dog", "targetname");
        using_player setOrigin(doggie.origin);
        //using_player setElectrified(true);
    }
}
 
wait_for_timeout(packa_timer)
{
    wait( level.packapunch_timeout );
 
    self notify( "pap_timeout" );
    //packa_timer stoploopsound(.05);
    //packa_timer playsound( "packa_deny" );
}
 
gumball_hud_create(gumball)
{
    if ( !IsDefined( self.gumball_hud ) )
    {
        self.gumball_hud = ;
    }
 
    /#
        if ( GetDVarInt( "zombie_cheat" ) >= 5 )
        {
            if ( IsDefined( self.gumball_hud[gumball] ) )
            {
                return;
            }
        }
#/
        shader = "";
        overlay = "";
 
        switch(gumball)
        {
        case "pack_a_punch":
            shader = "specialty_gobble_gum_zombies";
            break;
 
        case "insta_kill":
            shader = "specialty_gobble_gum_zombies";
            break;
 
        case "nuke":
            shader = "specialty_nuke";
            break;
 
        case "max_ammo":
            shader = "specialty_gobble_gum_zombies";
            break;
 
        case "double_points":
            shader = "specialty_gobble_gum_zombies";
            break;
 
        case "carpenter":
            shader = "specialty_gobble_gum_zombies";
            break;
 
        case "perkacholic":
            shader = "specialty_gobble_gum_perkacholic";
            break;
 
        case "plain_sight":
            shader = "specialty_gobble_gum_zombies";
            break;
 
        default:
            shader = "specialty_gobble_gum_zombies";
            break;
        }
 
        hud = create_simple_hud( self );
        hud.foreground = true;
        hud.sort = 1;
        hud.hidewheninmenu = false;
        hud.alignX = "right";
        hud.alignY = "bottom";
        hud.horzAlign = "right";
        hud.vertAlign = "bottom";
        hud.x = self.gumball_hud.size - 35;
        hud.y = hud.y - 100;
        hud.alpha = 1;
        hud SetShader( shader, 48, 48 );
 
        self.gumball_hud2 = hud;
 
}
 
perk_hud_create( perk )
{
    if ( !IsDefined( self.perk_hud ) )
    {
        self.perk_hud = ;
    }
 
    /#
        if ( GetDVarInt( "zombie_cheat" ) >= 5 )
        {
            if ( IsDefined( self.perk_hud ) )
            {
                return;
            }
        }
#/
 
 
        shader = "";
 
        switch( perk )
        {
        case "specialty_armorvest":
            shader = "specialty_juggernaut_zombies";
            break;
 
        case "specialty_quickrevive":
            shader = "specialty_quickrevive_zombies";
            break;
 
        case "specialty_fastreload":
            shader = "specialty_fastreload_zombies";
            break;
 
        case "specialty_rof":
            shader = "specialty_doubletap_zombies";
            break;
 
        default:
            shader = "";
            break;
        }
 
        hud = create_simple_hud( self );
        hud.foreground = true;
        hud.sort = 1;
        hud.hidewheninmenu = false;
        hud.alignX = "left";
        hud.alignY = "bottom";
        hud.horzAlign = "left";
        hud.vertAlign = "bottom";
        hud.x = self.perk_hud.size * 30;
        hud.y = hud.y - 70;
        hud.alpha = 1;
        hud SetShader( shader, 24, 24 );
 
        self.perk_hud = hud;
 
}
 
gumball_hud_destroy(gumball)
{
    self.gumball_hud[gumball] destroy_hud();
    self.gumball_hud[gumball] = undefined;
}
 
perk_hud_destroy(perk)
{
    self.perk_hud[perk] destroy_hud();
    self.perk_hud[perk] = undefined;
}
 
perk_give_bottle_begin(perk_bottle)
{
    self DisableOffhandWeapons();
    self DisableWeaponCycling();
 
    self AllowLean( false );
    self AllowAds( false );
    self AllowSprint( false );
    self AllowProne( false );        
    self AllowMelee( false );
 
    wait( 0.05 );
 
    if ( self GetStance() == "prone" )
    {
        self SetStance( "crouch" );
    }
 
    gun = self GetCurrentWeapon();
    weapon = "";
 
    switch( perk_bottle )
    {
    case "specialty_armorvest":
        weapon = "zombie_perk_bottle_jugg";
        break;
 
    case "specialty_quickrevive":
        weapon = "zombie_perk_bottle_revive";
        break;
 
    case "specialty_fastreload":
        weapon = "zombie_perk_bottle_sleight";
        break;
 
    case "specialty_rof":
        weapon = "zombie_perk_bottle_doubletap";
        break;
    }
 
    self GiveWeapon( weapon );
    self SwitchToWeapon( weapon );
 
    return gun;
}
 
 
perk_give_bottle_end(gun, perk_bottle)
{
    assert( gun != "zombie_perk_bottle_doubletap" );
    assert( gun != "zombie_perk_bottle_revive" );
    assert( gun != "zombie_perk_bottle_jugg" );
    assert( gun != "zombie_perk_bottle_sleight" );
    assert( gun != "syrette" );
 
    self EnableOffhandWeapons();
    self EnableWeaponCycling();
 
    self AllowLean( true );
    self AllowAds( true );
    self AllowSprint( true );
    self AllowProne( true );        
    self AllowMelee( true );
    weapon = "";
    switch( perk_bottle )
    {
    case "specialty_armorvest":
        weapon = "zombie_perk_bottle_jugg";
        break;
 
    case "specialty_quickrevive":
        weapon = "zombie_perk_bottle_revive";
        break;
 
    case "specialty_fastreload":
        weapon = "zombie_perk_bottle_sleight";
        break;
 
    case "specialty_rof":
        weapon = "zombie_perk_bottle_doubletap";
        break;
    }
 
    // TODO: race condition?
    if ( self maps\_laststand::player_is_in_laststand() )
    {
        self TakeWeapon(weapon);
        return;
    }
 
    if ( gun != "none" && gun != "mine_bouncing_betty" )
    {
        self SwitchToWeapon( gun );
    }
    else
    {
        // try to switch to first primary weapon
        primaryWeapons = self GetWeaponsListPrimaries();
        if( IsDefined( primaryWeapons ) && primaryWeapons.size > 0 )
        {
            self SwitchToWeapon( primaryWeapons[0] );
        }
    }
 
    self GiveWeapon(gun);
    self SwitchToWeapon(gun);
}
 
play_no_money_perk_dialog()
{
 
    index = maps\_zombiemode_weapons::get_player_index(self);
 
    player_index = "plr_" + index + "_";
    if(!IsDefined (self.vox_nomoney_perk))
    {
        num_variants = maps\_zombiemode_spawner::get_number_variants(player_index + "vox_nomoney_perk");
        self.vox_nomoney_perk = ;
        for(i=0;i<num_variants;i++)
        {
            self.vox_nomoney_perk[self.vox_nomoney_perk.size] = "vox_nomoney_perk_" + i;    
        }
        self.vox_nomoney_perk_available = self.vox_nomoney_perk;        
    }    
    sound_to_play = random(self.vox_nomoney_perk_available);
 
    self.vox_nomoney_perk_available = array_remove(self.vox_nomoney_perk_available,sound_to_play);
 
    if (self.vox_nomoney_perk_available.size < 1 )
    {
        self.vox_nomoney_perk_available = self.vox_nomoney_perk;
    }
 
    self maps\_zombiemode_spawner::do_player_playdialog(player_index, sound_to_play, 0.25);
 
}
Radiant 一 trigger_use KVP
Code Snippet
Plaintext
targetname=gobble_gum_trigger

 

I don't have a model that you need to set up yourself
Last Edit: December 06, 2022, 09:35:57 am by HunShen
broken avatar :(
×
broken avatar :(
[UGX] Maintainer (Admin & Programmer)
Location: deFriedrichshafen, Baden-Württemberg, Germany
Date Registered: 29 August 2012
Last active: 6 hours ago
Posts
440
Respect
Forum Rank
Perk Hacker
Primary Group
UGX Administrator
My Groups
More
My Contact & Social Links
More
Personal Quote
Dolphin!
Signature
changed one line of code, bug is fixed


Coming to work on monday morning.
When a bug mysteriously disappears.


:ugxmods: Developer ;)
×
Delta's Groups
UGX Administrator
UGX Team Member
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
UGX Chat Moderator Has the ability to mute, kick, or ban chat members for being abusive or breaking the rules of the forum.
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Delta's Contact & Social LinksItsDeltaugx_deltathe-deltaugxDeltaigdeltaigDelta UGX_DeltaigdeltaPersonal Site
I cleaned up the post form asia symbol (please avoid these next time)
I keep this available, but honestly a tutorial script should have a cleaned up version of the script, without commented out code.

 
Loading ...