UGX-Mods

Call of Duty: Black Ops 3 => Tutorial Desk => Scripting => Topic started by: shinged on October 15, 2016, 08:33:03 am

Title: [Tutorial] Buyable powerups
Post by: shinged on October 15, 2016, 08:33:03 am
Hey guys, im here with a simple tutorial on how to add buyable powerups. This is what the end result should look like


 So lets start with the script, open up your mapname.gsc located in root/usermaps/mapname/scritps/zm/mapname.gsc
Make sure you dont open the CSC

 Now somewhere at the top of the gsc, add this
Code Snippet
Plaintext
#using scripts\zm\_zm_score;

 At the bottom of the main function, add this
Code Snippet
Plaintext
thread buyable_powerup();

 Now at the bottom of your gsc paste this
Code Snippet
Plaintext
function buyable_powerup()
{
level.buyable_powerup_cost = 100; // Cost for powerup
level.buyable_powerup_cooldown = 20; // Cooldown in seconds for buyable trigger
while(1)
{
while(1)
{
buyable_powerup_trig = GetEnt("buyable_powerup_trig", "targetname");
buyable_powerup_trig SetHintString("Press and hold &&1 to spawn Powerup [Cost: " + level.buyable_powerup_cost + "]");
buyable_powerup_trig SetCursorHint("HINT_NOICON");
buyable_powerup_spawn = struct::get( "powerup_spawn", "targetname" );
buyable_powerup_trig waittill("trigger", player);

if(player.score >= level.buyable_powerup_cost)
{
player zm_score::minus_to_player_score(level.buyable_powerup_cost);

break;
}
}

/*
If you want a specific powerup, then uncomment the buyable_powerup_spawn below and delete or comment out the one above it.
Available Powerups: double_points, free_perk, full_ammo, nuke, fire_sale, carpenter, insta_kill, shield_charge, bonfire_sale,
*/

buyable_powerup_spawn thread zm_powerups::special_powerup_drop(buyable_powerup_spawn.origin);
//buyable_powerup_spawn thread zm_powerups::specific_powerup_drop("full_ammo", buyable_powerup_spawn.origin);

buyable_powerup_trig SetHintString("Recharing...");

wait(level.buyable_powerup_cooldown);
}
}


 Now for the radiant part, all you need is two things, the trigger to buy the powerup and the script_struct for where the powerup will spawn.
Make a trigger_use with this kvp
Code Snippet
Plaintext
"buyable_powerup_trig", "targetname"
Make a script_struct with this kvp
Code Snippet
Plaintext
"powerup_spawn", "targetname"
Title: Re: [Tutorial] Buyable powerups
Post by: Minepro14 on November 15, 2016, 12:08:49 am
not working for me, the triger says "Not available"
Title: Re: [Tutorial] Buyable powerups
Post by: shinged on November 15, 2016, 07:11:15 pm
not working for me, the triger says "Not available"

You might have given the trigger the wrong kvp, or maybe you scripted something wrong
Title: Re: [Tutorial] Buyable powerups
Post by: Minepro14 on November 15, 2016, 09:13:18 pm
i have done what you say
Title: Re: [Tutorial] Buyable powerups
Post by: LSDsuperfruit on December 13, 2017, 07:16:39 pm
bonfire_sale is not working. I can hear the powerup sound, but bonfire sale is not showing up.
Title: Re: [Tutorial] Buyable powerups
Post by: Overkill_NL on February 20, 2018, 12:53:11 pm
Im trying to find the mapname.gsc in usermaps. But I can't find it there, the only place where I find mapname.gsc is in the mods map. Does it still work then?
Title: Re: [Tutorial] Buyable powerups
Post by: isaacscott935 on July 05, 2018, 06:21:56 pm
not working for me, the triger says "Not available"

This error is caused by not having matching KVPs in radiant and in the scripts. Check you copied the script correctly.
Title: Re: [Tutorial] Buyable powerups
Post by: Harry Bo21 on July 06, 2018, 12:35:33 am
Recharing?
Title: Re: [Tutorial] Buyable powerups
Post by: BIGCountrysTV on January 06, 2020, 09:31:37 am
I know this is an old post but hoping someone will respond.

Is there a way to put a delay before the actual powerup spawns at the location? I want a delay to activate a sound then have it appear. This is what I have been trying but isnt working.

level.buyable_powerup_cost = 2500; // Cost for powerup
level.buyable_powerup_delay = 10; //Delay before the powerup appears in seconds
level.buyable_powerup_cooldown = 10; // Cooldown in seconds for buyable trigger in seconds

Line 2 is the line I put in for the delay.

Any help is appreciated

Thanks

EDIT:
I figured it out. Dont know how to delete :P