UGX-Mods

Call of Duty: Black Ops 1 => Tutorial Desk => Scripting => Topic started by: death_reaper0 on June 08, 2018, 10:34:38 pm

Title: [BO1] Perk Script Overhaul
Post by: death_reaper0 on June 08, 2018, 10:34:38 pm
this is a modification to the base perks script that allows people to do multiple things easier, this includes:
-easy to add custom perks
-built in perk slots (per player and global)
-automatically detects any perks in the map ran (no need to add level variables)
-changes functions to allow perks to be customized with 1 line each (price, model, sounds, bottle weapon etc)


first of all, back up your original perks script (in case something goes wrong or you want to revert back)

go to bo1 raw/maps and find _zombiemode_perks.gsc and make a copy of it, rename to whatever you want (e.g. _zombiemode_perks_old.gsc)

now open the original and delete EVERYTHING and replace it with this:
https://pastebin.com/V62yFrP6

save the file and that's pretty much it, now i'll go over how to use any additions (these are also listed in the file)

adding a perk WITH a specific specialty used by the game
around line 113 you should see some lines like this:
Code Snippet
Plaintext
	level thread add_perk("vending_jugg", "specialty_armorvest", "jugger_light", "zombie_vending_jugg_on", 2500, undefined, &"ZOMBIE_PERK_JUGGERNAUT", "specialty_juggernaut_zombies", "zombie_perk_bottle_jugg", "mx_jugger_sting", undefined);
this is what adds juggernog specifically to the map/mod, there's one of these for each perk native to the game (including dlc)
to add a new perk your going to copy that line and place it under them. now we're going to change it, heres what each part of that line means (also listed in the file if you forget)

Code Snippet
Plaintext
add_perk( vending_machine, specialty, light_fx, machine_change, cost, perk_name, perk_name_actual, shader, bottle_weapon, short_jingle, function);
vending_machine - targetname on machine
specialty - trigger specialty (script_noteworthy)
light_fx - name of fx used for machine (level._effect[ -> light_fx <- ]) e.g. "zombie_vending_jugg_on"
machine_change - name of model to change to when powers on (CAN leave undefined if none)
cost - cost of the perk (should be a whole number e.g. 2500 )
perk_name - string of perks name e.g. "Deadshot Daquari" (leave undefined if string is already made e.g. &"ZOMBIE_PERK_JUGGERNAUT")
perk_name_actual - use this if above is undefined ONLY! should be used if string exists e.g. "ZOMBIE_PERK_JUGGERNAUT"
shader - name of icon to show up in game e.g. "specialty_juggernaut_zombies"
bottle_weapon - name of bottle used when drinking e.g. "zombie_perk_bottle_jugg"
short_jingle - name of jingle to play upon purchase e.g. "mx_jugger_sting"
function - threaded fuction that will only play if perk exists e.g. ::my_fuction

adding a perk WITHOUT a specific specialty used by the game
this is pretty much the exact same as the above, except you WILL NOT need a specific specialty, i can be literally anything you can think of, like "specialty_a_custom_perk" only thing is each perk needs a unique one, can even be as simple as "specialty_perk1" and "specialty_perk2"
when adding, use
Code Snippet
Plaintext
add_custom_perk( vending_machine, specialty, light_fx, machine_change, cost, perk_name, perk_name_actual, shader, bottle_weapon, short_jingle, function);
instead
when using this however you will need to use different ways of checking the perk, such as finding if the player has it, for giving it and removing it by special means. these are also listed in the file but here they are again
Code Snippet
Plaintext
HasPerk( specialty_NAME )		-|-	will become	-|-		maps\_zombiemode_perks::HasCustomPerk( specialty_NAME )
UnsetPerk( specialty_NAME ) -|- will become -|- maps\_zombiemode_perks::UnsetCustomPerk( specialty_NAME )
SetPerk( specialty_NAME ) -|- will become -|- maps\_zombiemode_perks::SetCustomPerk( specialty_NAME )

some small extra stuff for this are as follows
Code Snippet
Plaintext
extra fuctions for custom specialty perks
maps\_zombiemode_perks::IsCustomPerk( specialty_NAME ) - returns true if specialty is listed as a custom specialty
maps\_zombiemode_perks::CreateCustomPerk( specialty_NAME ) - shouldnt be needed, but this will create a custom specialty (add_custom_perk() will automaticly use this)
maps\_zombiemode_perks::HasThePerk( specialty_NAME ) - finds out if player has that perk as custom or normal (it will find out if its custom or normal for you)



now on to some small extras
changing perk slots
per player you will need to call
Code Snippet
Plaintext
maps\_zombiemode_perks::give_perk_slot();

on a player, this gives 1 perk slot. if you want to add more just call it as many times as you wish
to change the base perk slot amount change
Code Snippet
Plaintext
	level.perk_limit = 4;	//change to be perk limit for all players

to however many you want, should be at line 28


custom perk fuctions
this already includes 2 custom perks i have made, use them if you want but you may need to edit if you do. these will not come with any models or shaders, you will need to make your own
TUFBREW
this is pretty much the double damge doubletap 2.0 uses, if you would like this to be doubletap 2.0 instead you can change
Code Snippet
Plaintext
tufbrew_func( mod, hit_location, hit_origin, player, amount )
{
if(player HasThePerk("specialty_bulletdamage") && ( mod == "MOD_RIFLE_BULLET" || mod == "MOD_PISTOL_BULLET" ) )
{
if(amount >= self.health)
player maps\_zombiemode_score::player_add_points( "death", mod, hit_location, self.isdog );
self DoDamage( amount, player.origin );
}
return false;
}

to
Code Snippet
Plaintext
tufbrew_func( mod, hit_location, hit_origin, player, amount )
{
if(player HasThePerk("specialty_rof") && ( mod == "MOD_RIFLE_BULLET" || mod == "MOD_PISTOL_BULLET" ) )
{
if(amount >= self.health)
player maps\_zombiemode_score::player_add_points( "death", mod, hit_location, self.isdog );
self DoDamage( amount, player.origin );
}
return false;
}

this should be around line 1738

CANDOLIER
this perk lets each gun have 2 more clips of ammo
this one will require a LOT of editing. if you want to get it to work uncomment line 129, should look like
Code Snippet
Plaintext
	level thread candolier();	//bandolier perk, 2 extra clips of ammo for each gun, add to weapon files of each gun

and now you will need to go to EVERY gun you are going to use and change the maxammo and startammo to be 2 clips higher than it should be, and how the script will work is WITHOUT the perk it detects if the player has any ammo from these 2 extra clips, and if so remove them, with it, it will ignore the extra ammo and let the player take it. its important that all guns do this cause it will not skip over the guns you dont use this on. this is why it is commented out by default


if used please credit, if you have any trouble reply here and i'll answer if i can
Title: Re: [BO1] Perk Script Overhaul
Post by: MothMan21726198 on October 21, 2021, 03:25:55 pm
Thanks this was extremly helpful. Just how do i go about adding a model.
Title: Re: [BO1] Perk Script Overhaul
Post by: MothMan21726198 on October 23, 2021, 08:35:21 am
trying to use this as a mod script which replaces the original when i do this for whatever reason quick revive and mule kick mess up (testing it on kino). Quickrevive can be walked through and has a random wooden plank sticking out of it and cant be bought. And the mule kick machine is entirely absent. Any suggestions on how to fix this, because i like the format and would like to keep using it.