UGX-Mods

Call of Duty: Black Ops 3 => Tutorial Desk => Scripting => Topic started by: shinged on December 02, 2016, 10:20:34 pm

Title: [Tutorial] Custom Perks
Post by: shinged on December 02, 2016, 10:20:34 pm
Hey guys, today i'm gonna guide you guys through making a custom perk. You need at least a bit of scripting knowledge to do this as your perk won't actually do anything without scripting it ;)
IT IS EXTREMELY EASY TO GET CLIENT MISMATCH ERRORS WITH THIS,
HOWEVER IF YOU ARE POSITIVELY SURE YOU DID EVERYTHING 100% CORRECTLY LET ME KNOW
AND I WILL TRY TO FIX IT

First download my scripts here: https://mega.nz/#!Rk8D2JbI!rcYRTDhkgdYxC4TJiyHZW5N5k-dBMVHU8ZjjB1QJt9c (https://mega.nz/#!Rk8D2JbI!rcYRTDhkgdYxC4TJiyHZW5N5k-dBMVHU8ZjjB1QJt9c)

So lets start off by copying some shit.
 - Drag and drop everything but the .txt into your mapname/scripts/zm folder.
 - Open up your mapname GSC and paste this somewhere at the top
Code Snippet
Plaintext
#using scripts\zm\zm_custom_perk_shader;
#using scripts\zm\_zm_perk_custom_perk;
- at the bottom of main() function put this
Code Snippet
Plaintext
level thread custom_perk_shader::custom_perk_shaders_init();

 - Now open up your mapname CSC and paste this somewhere at the top
Code Snippet
Plaintext
#using scripts\zm\_zm_perk_custom_perk;

 - Open up your mapname ZONE file and paste this at the bottom
Code Snippet
Plaintext
// custom perk shader script by Matarra
scriptparsetree,scripts/zm/zm_custom_perk_shader.gsc
// custom perk
scriptparsetree,scripts/zm/_zm_perk_custom_perk.gsc
scriptparsetree,scripts/zm/_zm_perk_custom_perk.csc
scriptparsetree,scripts/zm/_zm_perk_custom_perk.gsh
xmodel,kh_elemental_nade_vending // CHANGE THESE TO YOUR VALUES - XMODEL NAME FOR YOUR MACHINE
material,kh_perk_elemental_nades // CHANGE THESE TO YOUR VALUES - THIS IS YOUR PERK SHADER MATERIAL NAME

 - Now in Radiant, copy quick revive and stamp the prefab. Delete everything but the struct at the bottom.
 - Change these KVP's
Code Snippet
Plaintext
"specialty_customperk", "script_noteworthy"
"your xmodel name for perk machine", "model"

Now lets move on to APE, we'll save scripting for last
 - Make a material and call it something you'll remember, this will be the perk shader.
 - Give this these settings
(http://i.imgur.com/4n7abOG.png)
(http://i.imgur.com/NlcXCfX.png)
(http://i.imgur.com/uq0vBYF.png)

Now for the scripting part, there really isn't that much to do because i mostly did it all for you. If you want to change variable names you can, but i suggest leaving them alone and just changing whats in the gsh, and certain things like hintstrings in the gsc.
 - Open up the custom_perk.gsh and change everything to your own shit. I suggest leaving the price really low for testing.
 - Dont worry about this variable
Code Snippet
Plaintext
CUSTOM_SHADER
we dont have access to treyarchs hud elements so i had to script them in manually. So just leave the value alone.
 
Open up the custom_perk.gsc
 - At the top add this somewhere
Code Snippet
Plaintext
#precache( "material", "kh_perk_elemental_nades" ); // CHANGE THIS TO YOUR PERK SHADER
Obviously change kh_perk_elemental_shit to your own material name in APE.
 - Find this
Code Snippet
Plaintext
zm_perks::register_perk_basic_info( PERK_CUSTOM_PERK, "customperk", CUSTOM_PERK_COST, "Hold [{+activate}] for Elemental-Nades [Cost: &&1]", GetWeapon( CUSTOM_PERK_BOTTLE_WEAPON ) );
change the hintstring to your perkname.
 - Find this
Code Snippet
Plaintext
trigger = GetEnt("vending_customperk", "target"); // CHANGE THIS TO YOUR PERK MACHINE NAME
change "vending_customperk" to whatever you might have changed it to in the gsh.
 - Find this
Code Snippet
Plaintext
trigger SetHintStringForPlayer(self, "Hold [{+activate}] for Elemental-Nades [Cost: 3000]"); // CHANGE THIS TO YOUR HINTSTRING ABOVE

and change it to your hintstring once again. This time you will need to specify the cost of it.
 - In the final function is where you will script your perk effect, the function gets called one time when the player purchases the perk.

Code Snippet
Plaintext
give_custom_perk()
and
Code Snippet
Plaintext
take_custom_perk( b_pause, str_perk, str_result )
both only get threaded a single time.

So there you have it. This tutorial is probably my largest tutorial yet and might have some errors. If you guys find any let me know and i will fix them asap.

If you follow my tutorial you MUST credit me. Simply saying: "Matarra - Custom perk shader script and custom perk tutorial" will suffice
Title: Re: [Tutorial] Custom Perks
Post by: Cxwh on December 02, 2016, 11:40:01 pm
Awesome tutorial dude :D
Title: Re: [Tutorial] Custom Perks
Post by: shinged on December 03, 2016, 12:35:16 am
Awesome tutorial dude :D
Thanks man <3
Title: Re: [Tutorial] Custom Perks
Post by: Blink-420 on December 03, 2016, 12:55:52 am
Awesome, very very much appreciated. Working great and very easy to follow tutorial! I have a question, might be stupid.. how do you create more than 1 of these custom perks? :)
Title: Re: [Tutorial] Custom Perks
Post by: shinged on December 03, 2016, 01:46:22 am
copy the gsc, gsh, and csc. And you would have to rename a bunch of variables. Then put #using in your mapname GSC and CSC. Also add them too your zone file. Its gonna take a bit of scripting knowledge to figure out and i'd prefer people to try to learn it themselves. It makes it much easier to understand treyarchs coding down the line
Title: Re: [Tutorial] Custom Perks
Post by: Blink-420 on December 03, 2016, 02:27:31 am
copy the gsc, gsh, and csc. And you would have to rename a bunch of variables. Then put #using in your mapname GSC and CSC. Also add them too your zone file. Its gonna take a bit of scripting knowledge to figure out and i'd prefer people to try to learn it themselves. It makes it much easier to understand treyarchs coding down the line

Yeah I figured thats how it would have to be done but wasn't sure.. thanks :)

Double Post Merge: December 03, 2016, 04:18:28 am
Also, one thing I just noticed is that you can buy the perk over and over taking up another perk slot, and the shader will repeat itself. But once you buy the perk once the hintstring won't pop up again on the machine.
Title: Re: [Tutorial] Custom Perks
Post by: morphiac on December 06, 2016, 04:54:53 am
How do I select individual objects in a prefab?
Title: Re: [Tutorial] Custom Perks
Post by: hajhaka on December 06, 2016, 03:30:20 pm
It just lets me spam buy it even if i already have it
Title: Re: [Tutorial] Custom Perks
Post by: Blink-420 on December 06, 2016, 11:57:29 pm
How do I select individual objects in a prefab?
You have to select the prefab - right click - prefab and stamp the prefab
Title: Re: [Tutorial] Custom Perks
Post by: MJPWGaming on December 13, 2016, 02:15:32 am
It just lets me spam buy it even if i already have it

Same here. Everything else is great. And you can fill up your max perk slots with this.

(https://i.gyazo.com/786db6fa80ec89ed4043d24449df00c9.jpg)
Title: Re: [Tutorial] Custom Perks
Post by: qwerty195 on December 30, 2016, 04:44:26 pm
I made a custom model for the perk machine and bottle weapon. How do I refer to them in the gsh though? I don't tink just putting the name in from APE works.
Title: Re: [Tutorial] Custom Perks
Post by: shinged on December 30, 2016, 06:47:15 pm
I made a custom model for the perk machine and bottle weapon. How do I refer to them in the gsh though? I don't tink just putting the name in from APE works.
You also need to precache the model either in your zone file or by placing the model somewhere in your map. Usually you replace the machine model in radiant with yours
Title: Re: [Tutorial] Custom Perks
Post by: qwerty195 on January 02, 2017, 11:55:06 pm
Okay I have no idea why this has happened because it was working alright earlier, but now whenever I buy the custom perk, this happens:
This is obviously very broken and I don't know why. I checked through all the files a million times to see that I've followed the tutorial, but maybe I'm missing something? The last thing I was doing was trying to get the custom models for the perk machine, bottle and shader to work (which by the way, the perk machine model does work). Any ideas?
Title: Re: [Tutorial] Custom Perks
Post by: HitmanVere on January 08, 2017, 02:53:15 pm
Okay I have no idea why this has happened because it was working alright earlier, but now whenever I buy the custom perk, this happens:
  • There is no animation involving the drinking of the perk
  • The shader doesn't appear
  • The actual perk effect doesn't happen
  • Player can no longer sprint or knife
  • Seems to nullify the effects of Solo quick revive (maybe other perks; I haven't really tested)
This is obviously very broken and I don't know why. I checked through all the files a million times to see that I've followed the tutorial, but maybe I'm missing something? The last thing I was doing was trying to get the custom models for the perk machine, bottle and shader to work (which by the way, the perk machine model does work). Any ideas?

Its not properly giving you perks weaponfile, thats why you cant sprint/knife and animation doesnt play
Title: Re: [Tutorial] Custom Perks
Post by: qwerty195 on January 10, 2017, 03:12:17 pm
Quote
Its not properly giving you perks weaponfile, thats why you cant sprint/knife and animation doesnt play
I figured it out. Like you said I didn't do the perk bottle weapon correctly and that caused all the errors. I changed it back to the stock speed cola bottle and now it works fine.
Title: Re: [Tutorial] Custom Perks
Post by: DeletedUser on January 17, 2017, 04:31:18 pm
How do I select individual objects in a prefab?
All you need to do is select it in radiant right click hgover your mouse over prefab and at the bottom it says stamp prefab
Title: Re: [Tutorial] Custom Perks
Post by: Harry Bo21 on January 17, 2017, 10:16:08 pm
dont stamp...

"enter" prefab
Title: Re: [Tutorial] Custom Perks
Post by: qwerty195 on January 20, 2017, 07:36:13 pm
I got this perk thing figured out alright and everything works fine, except that Solo Quick Revive doesn't work after you purchase the custom perk. You just die like you don't have it.
Title: Re: [Tutorial] Custom Perks
Post by: Archaicvirus on May 31, 2017, 12:12:05 am
This is the fix for anyone having the problem where you can spam buy the perk 4 times:

Code Snippet
Plaintext
//In your perk_name.gsc add these lines in the give_custom_perk() function 
//shown below
function give_custom_perk(){
if(!isdefined(self.disabled_perks))
self.disabled_perks = [];
self.disabled_perks[PERK_FREEZE] = true;    //Change PERK_FREEZE to the caps name you gave it in your
//perk_name.gsh file. By default in this tutorial it's called PERK_CUSTOM_PERK
#define PERK_FREEZE "specialty_freeze" // CHANGE THIS TO PERKNAME //This line in my gsh file for example


}

*Credit to death_reaper0 for the solution https://ugx-mods.com/forum/index.php/topic,15329.0.html
Title: Re: [Tutorial] Custom Perks
Post by: Harry Bo21 on May 31, 2017, 05:56:57 pm
you cant use custom speciallties

this wont work

if self haasPerk( whatever ) will stilll return false
Title: Re: [Tutorial] Custom Perks
Post by: Archaicvirus on May 31, 2017, 11:19:11 pm
How so? The way I have it set up I just check a custom variable self.hasFreezePerk which I set in the give perk function and also set it to false in the take perk function. The function that's responsible for the perk effect checks for that custom variable by way of a damage callback on zombies with the attacker. Everything is working fine that I can tell. I'll follow your advice though, my only concern is that if I use an existing specialty, won't I inadvertently gain that ability?
Title: Re: [Tutorial] Custom Perks
Post by: Astaal on July 14, 2017, 12:34:57 am
Potentially dumb question, how do I align the perk to fit in the perkl 'queue'? Is there a bit of code that I'm missing?
 
(http://i.imgur.com/cElrcKh.jpg)
Title: Re: [Tutorial] Custom Perks
Post by: Seagoatdaddy on May 19, 2020, 04:37:20 am
Not to necro the thread or anything, but your script download is no longer there. It has been removed and I'm wondering where I can even find this script again.