Call of Duty: Black Ops III

Call of Duty: Black Ops III

Not enough ratings
[Scripting] Random Perk Refund
By Mysti and 1 collaborators
   
Award
Favorite
Favorited
Unfavorite
Introduction
Hey guys, yet another tutorial from me, this one is pretty simple. It's just a Perk Refund script.

Let's say you have Jugg and suddently really want Mule Kick, now you can refund Jugg then you get a set amount of back then you're free to buy Mule since you no longer have Jugg.

But without any waiting, let's get onto the scripting.
Radiant Requirements
You only really need a trigger in Radiant, but I am going to use an xModel to alert the user to it's something you can interact with. I'll be keeping it simple and using
p7_zm_teddybear_sitting
I've just added it as a normal model since we won't be doing anything with it. Now, wrap a trigger around it and give it the following KVP.

Key
Value
targetname
perk_refund

that's all she wrote to do with radiant. so now we can move onto the scripting side of things.
Scripting Requirements
So, first things first. We need to include a few files at the top of our map. So make sure you put these 3 lines at the top of our your file below the rest of the includes

#using scripts\zm\_zm_perks; //Taking Perks #using scripts\zm\_zm_score; //Giving Points Back #insert scripts\zm\_zm_perks.gsh; //For Global Perk Defines.

Now add this line

level thread init_perk_refund();
below
level.pathdist_type = PATHDIST_ORIGINAL;

Then all the way down the bottom of your file put these two functions, then save you're done.
function init_perk_refund() { self endon("disconnect"); vending_triggers = GetEntArray("zombie_vending", "targetname"); if ( vending_triggers.size < 1 ) //To Make Me Stop Running If The Map Has No Perks. { return; } refund_trigger = GetEnt("perk_refund","targetname"); refund_trigger SetHintString("Press ^3&&1^7 To Refund A Perk"); //^3 Yellow [USE] Key, ^7 Reset Text Back To Normal Colour. refund_trigger SetCursorHint("HINT_NOICON"); refund_trigger UseTriggerRequireLookAt(); do { refund_trigger waittill("trigger", Who); if(Who.num_perks == 0) { Who IPrintLnBold("Sorry! You Don't Have Any Perks To Refund"); continue; } else { Who take_random_perk(); } wait .5; }while(true); } function take_random_perk() { a_str_perks = GetArrayKeys( level._custom_perks ); perks = []; for ( i = 0; i < a_str_perks.size; i++ ) { perk = a_str_perks;

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

if ( self HasPerk( perk ) || self zm_perks::has_perk_paused( perk ) )
{
perks[ perks.size ] = perk;
}
}

if ( perks.size > 0 )
{
perks = array::randomize( perks );
perk = perks[0];

perk_str = perk + "_stop";
self notify( perk_str );

if (zm_perks::use_solo_revive() && perk == PERK_QUICK_REVIVE)
{
self.lives--;
self zm_score::add_to_player_score(250); //Solo Quick Revive
}
else if(perk == PERK_QUICK_REVIVE)
{
self zm_score::add_to_player_score(750); //Co-Op Quick Revive
}
else
{
self zm_score::add_to_player_score(level._custom_perks[perk].cost / 2); //Every Other Perk Cost / 2
}
}
}
Final Words
I only really made this tutorial because I remember playing a few maps in World at War that had this feature, I'll make a second part to this for specific perk removal, but that requires more work and more code to get going so it might cause a bit of a headache if you want a lot of perks in your map.

Anyway, Thanks for reading I'll see you in the next one.
5 Comments
SHAZADI HAJI 22 Feb @ 4:45am 
hello i use ur refund random perk but i use trigger_multiple can u tell me how to change the code to when player attach the trigger then it will active
LΛLO 11 Jun, 2017 @ 8:53am 
good job
lekkus 8 Jun, 2017 @ 8:49am 
Verry usefull
Mysti  [author] 5 Jun, 2017 @ 4:37pm 
Because this is designed for people who want to mod the game using the mod tools, not for players who want to use this in any map.
Jacob S. 3 Jun, 2017 @ 2:43pm 
Dope