Modme Forums
Menu:

Help with Custom Perk

Game Modding | Call of Duty: Black Ops 3 | Scripting


ModmeBot:

Thread By: Blink-420
I am trying to have my perk give the player 2x points when he has the perk. Any help would be appreciated. I've tried this

function checkCustomPerk()
{
	while(1)
	{
		if( self.hasCustomPerk == true )
		{
		self
			set_zombie_var( "zombie_score_kill", 				100 );
			set_zombie_var( "zombie_score_damage", 				10 );
			set_zombie_var( "zombie_score_bonus_melee", 		160 );
			set_zombie_var( "zombie_score_bonus_head", 			100 );
			set_zombie_var( "zombie_score_bonus_neck", 			40 );
			set_zombie_var( "zombie_score_bonus_torso", 		20 );
		}
		else
		{
		self
    		set_zombie_var( "zombie_score_kill", 				50 );
			set_zombie_var( "zombie_score_damage", 				5 );
			set_zombie_var( "zombie_score_bonus_melee", 		80 );
			set_zombie_var( "zombie_score_bonus_head", 			50 );
			set_zombie_var( "zombie_score_bonus_neck", 			20 );
			set_zombie_var( "zombie_score_bonus_torso", 		10 );
		}
		wait(0.01);
	}
}

And I've tried this:

function checkCustomPerk()
{
	while(1)
	{
		if( self.hasCustomPerk == true )
		{
			self 
			SetDvar( "zombie_score_kill", 100);
			SetDvar( "zombie_score_damage", 10);
			SetDvar( "zombie_score_bonus_melee", 160);
			SetDvar( "zombie_score_bonus_head", 100);
			SetDvar( "zombie_score_bonus_neck", 40);
			SetDvar( "zombie_score_bonus_torso", 20);
		}
		else
		{
			self 
			SetDvar( "zombie_score_kill", 50);
			SetDvar( "zombie_score_damage", 5);
			SetDvar( "zombie_score_bonus_melee", 180);
			SetDvar( "zombie_score_bonus_head", 50);
			SetDvar( "zombie_score_bonus_neck", 20);
			SetDvar( "zombie_score_bonus_torso", 10);
		}
		wait(0.01);
	}
}



I'm not a great scripter so and I'm not really sure what else to try :( Thanks for any help in advance :)


ModmeBot:

Reply By: m1cke
Thats from _zm.gsc isen't it?


ModmeBot:

Reply By: Blink-420

m1ckeThats from _zm.gsc isen't it?


Yes


ModmeBot:

Reply By: m1cke
i have heard that u can't edit _zm.gsc unfortunently :(


ModmeBot:

Reply By: Blink-420

m1ckei have heard that u can't edit _zm.gsc unfortunently :(


Well I'm not editing that .gsc, I referred to the _zm.gsc for help. Its in my own script, so I just need to figure out how to enable double points while the player has this perk. The perk works, the shader and everything, it just doesnt do anything right now until I get this figured out


ModmeBot:

Reply By: m1cke

Blink-420
m1ckei have heard that u can't edit _zm.gsc unfortunently :(


Well I'm not editing that .gsc, I referred to the _zm.gsc for help. Its in my own script, so I just need to figure out how to enable double points while the player has this perk. The perk works, the shader and everything, it just doesnt do anything right now until I get this figured out


Don't think you can do that to.


ModmeBot:

Reply By: m1cke
btw blink if u do get it working why not release it would be cool


ModmeBot:

Reply By: Blink-420
UPDATE, I have the script working... but after getting one kill with double points it goes back to normal points.. this is the script



function checkCustomPerk()
{
	while(1)
	{
		if( self.hasCustomPerk == true )
		{
			zombie_utility::set_zombie_var( "zombie_score_damage_normal", 20 );  // points gained for a hit with a non-automatic weapon
			zombie_utility::set_zombie_var( "zombie_score_damage_light", 10 );  // points gained for a hit with an automatic weapon
			zombie_utility::set_zombie_var( "zombie_score_bonus_melee", 120 );  // Bonus points for a melee kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_head", 100 );  // Bonus points for a head shot kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_neck", 80 );  // Bonus points for a neck shot kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_torso", 50 );  // Bonus points for a torso shot kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_burn", 50 );  // Bonus points for a burn kill
			zombie_utility::set_zombie_var( "zombie_score_kill_4player", 150 );  //Base points for a kill with 4 players
			zombie_utility::set_zombie_var( "zombie_score_kill_3player", 150 );  //Base points for a kill with 3 players
			zombie_utility::set_zombie_var( "zombie_score_kill_2player", 150 );  //Base points for a kill with 2 players
			zombie_utility::set_zombie_var( "zombie_score_kill_1player", 150 );  //Base points for a kill with 1 player
		}
		else
		{
			break;
		}
		wait(0.01);
	}
}


ModmeBot:

Reply By: m1cke

Blink-420UPDATE, I have the script working... but after getting one kill with double points it goes back to normal points.. this is the script



function checkCustomPerk()
{
	while(1)
	{
		if( self.hasCustomPerk == true )
		{
			zombie_utility::set_zombie_var( "zombie_score_damage_normal", 20 );  // points gained for a hit with a non-automatic weapon
			zombie_utility::set_zombie_var( "zombie_score_damage_light", 10 );  // points gained for a hit with an automatic weapon
			zombie_utility::set_zombie_var( "zombie_score_bonus_melee", 120 );  // Bonus points for a melee kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_head", 100 );  // Bonus points for a head shot kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_neck", 80 );  // Bonus points for a neck shot kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_torso", 50 );  // Bonus points for a torso shot kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_burn", 50 );  // Bonus points for a burn kill
			zombie_utility::set_zombie_var( "zombie_score_kill_4player", 150 );  //Base points for a kill with 4 players
			zombie_utility::set_zombie_var( "zombie_score_kill_3player", 150 );  //Base points for a kill with 3 players
			zombie_utility::set_zombie_var( "zombie_score_kill_2player", 150 );  //Base points for a kill with 2 players
			zombie_utility::set_zombie_var( "zombie_score_kill_1player", 150 );  //Base points for a kill with 1 player
		}
		else
		{
			break;
		}
		wait(0.01);
	}
}



Really weird ur looping the script so maybe add a customperkthink function and just have it checking if the player gets the abbility or not.


ModmeBot:

Reply By: Blink-420
Well now its working, but it's giving all players double points.. not just the player with the perk.. this is my script now



function checkCustomPerk2()
{
	while(1)
	{
		if( self.hasCustomPerk == true )
		{
			zombie_utility::set_zombie_var( "zombie_score_damage_normal", 20 );  // points gained for a hit with a non-automatic weapon
			zombie_utility::set_zombie_var( "zombie_score_damage_light", 10 );  // points gained for a hit with an automatic weapon
			zombie_utility::set_zombie_var( "zombie_score_bonus_melee", 40 );  // Bonus points for a melee kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_head", 75 );  // Bonus points for a head shot kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_neck", 60 );  // Bonus points for a neck shot kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_torso", 50 );  // Bonus points for a torso shot kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_burn", 50 );  // Bonus points for a burn kill
			zombie_utility::set_zombie_var( "zombie_score_kill_4player", 75 );  //Base points for a kill with 4 players
			zombie_utility::set_zombie_var( "zombie_score_kill_3player", 75 );  //Base points for a kill with 3 players
			zombie_utility::set_zombie_var( "zombie_score_kill_2player", 75 );  //Base points for a kill with 2 players
			zombie_utility::set_zombie_var( "zombie_score_kill_1player", 75 );  //Base points for a kill with 1 player
		}
		else
		{
			zombie_utility::set_zombie_var( "zombie_score_damage_normal", 10 );  // points gained for a hit with a non-automatic weapon
			zombie_utility::set_zombie_var( "zombie_score_damage_light", 10 );  // points gained for a hit with an automatic weapon
			zombie_utility::set_zombie_var( "zombie_score_bonus_melee", 60 );  // Bonus points for a melee kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_head", 50 );  // Bonus points for a head shot kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_neck", 40 );  // Bonus points for a neck shot kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_torso", 25 );  // Bonus points for a torso shot kill
			zombie_utility::set_zombie_var( "zombie_score_bonus_burn", 25 );  // Bonus points for a burn kill
			zombie_utility::set_zombie_var( "zombie_score_kill_4player", 50 );  //Base points for a kill with 4 players
			zombie_utility::set_zombie_var( "zombie_score_kill_3player", 50 );  //Base points for a kill with 3 players
			zombie_utility::set_zombie_var( "zombie_score_kill_2player", 50 );  //Base points for a kill with 2 players
			zombie_utility::set_zombie_var( "zombie_score_kill_1player", 50 );  //Base points for a kill with 1 player
		}
		wait(0.01);
	}
}


ModmeBot:

Reply By: natesmithzombies
You may be able to do this much simpler than you are attempting. Call the init_doublePoint_perk() function as soon as you can, you could even do so in mapname.gsc by pasting these functions at the bottom of it and threading as usual. It would be cleaner to do this all in your perk script though:



function init_doublePoint_perk()
{
	level.player_score_override = &checkCustomPerk; 
}

function checkCustomPerk( damage_weapon, player_points )
{
	if( isDefined( self.hasCustomPerk ) && self.hasCustomPerk )
		zm_score::add_to_player_score( player_points ); 
	
	return player_points; 
}



The simplicity of this script has drawbacks. You will notice I am adding to players score when I should be doing player_points*2 instead. This is because there appears to be a different check for a pers_upgrade_pistol_points right after. I imagine that is not there for no reason so it is crucial to add points immediately to the player's score otherwise the double points will be overwritten. Additionally by adding to player score twice the points will not be doubled in the same way that double points does it i.e it will show up twice on the hud +100 +100 for 200 instead of +200. This could all be cleaner if we can edit stock scripts, which we cant :( lol



All of this is untested so let me know if it works out for you. Scripting is an art of simplicity and brevity, keep your code short if you can


ModmeBot:

Reply By: Blink-420

natesmithzombiesYou may be able to do this much simpler than you are attempting. Call the init_doublePoint_perk() function as soon as you can, you could even do so in mapname.gsc by pasting these functions at the bottom of it and threading as usual. It would be cleaner to do this all in your perk script though:



function init_doublePoint_perk()
{
	level.player_score_override = &checkCustomPerk; 
}

function checkCustomPerk( damage_weapon, player_points )
{
	if( isDefined( self.hasCustomPerk ) && self.hasCustomPerk )
		zm_score::add_to_player_score( player_points ); 
	
	return player_points; 
}



The simplicity of this script has drawbacks. You will notice I am adding to players score when I should be doing player_points*2 instead. This is because there appears to be a different check for a pers_upgrade_pistol_points right after. I imagine that is not there for no reason so it is crucial to add points immediately to the player's score otherwise the double points will be overwritten. Additionally by adding to player score twice the points will not be doubled in the same way that double points does it i.e it will show up twice on the hud +100 +100 for 200 instead of +200. This could all be cleaner if we can edit stock scripts, which we cant :( lol



All of this is untested so let me know if it works out for you. Scripting is an art of simplicity and brevity, keep your code short if you can


It's working! Haven't tested multiplayer I'll get back to you on that... Although, It is a bit crazy the amount of points you're getting from it. Is there anyway to lessen the amount of points for each thing, or overall. Such as I was able to do through set_zombie_var? Thanks!


ModmeBot:

Reply By: natesmithzombies

Blink-420It's working! Haven't tested multiplayer I'll get back to you on that... Although, It is a bit crazy the amount of points you're getting from it. Is there anyway to lessen the amount of points for each thing, or overall. Such as I was able to do through set_zombie_var? Thanks!


Unfortunately the only things passed to that function are the damage weapon and the points. The best you can do is the following:

function init_doublePoint_perk()
{
	level.player_score_override = &checkCustomPerk; 
}

function checkCustomPerk( damage_weapon, player_points )
{
	if( isDefined( self.hasCustomPerk ) && self.hasCustomPerk )
		zm_score::add_to_player_score( player_points/4 ); // I added a divisor of 4 to lessen the points 
	
	return player_points; 
}


ModmeBot:

Reply By: Blink-420

natesmithzombies
Blink-420It's working! Haven't tested multiplayer I'll get back to you on that... Although, It is a bit crazy the amount of points you're getting from it. Is there anyway to lessen the amount of points for each thing, or overall. Such as I was able to do through set_zombie_var? Thanks!


Unfortunately the only things passed to that function are the damage weapon and the points. The best you can do is the following:

function init_doublePoint_perk()
{
	level.player_score_override = &checkCustomPerk; 
}

function checkCustomPerk( damage_weapon, player_points )
{
	if( isDefined( self.hasCustomPerk ) && self.hasCustomPerk )
		zm_score::add_to_player_score( player_points/4 ); // I added a divisor of 4 to lessen the points 
	
	return player_points; 
}



Thank you very much :)


ModmeBot:

Reply By: natesmithzombies

Blink-420
natesmithzombies
Blink-420It's working! Haven't tested multiplayer I'll get back to you on that... Although, It is a bit crazy the amount of points you're getting from it. Is there anyway to lessen the amount of points for each thing, or overall. Such as I was able to do through set_zombie_var? Thanks!


Unfortunately the only things passed to that function are the damage weapon and the points. The best you can do is the following:

function init_doublePoint_perk()
{
	level.player_score_override = &checkCustomPerk; 
}

function checkCustomPerk( damage_weapon, player_points )
{
	if( isDefined( self.hasCustomPerk ) && self.hasCustomPerk )
		zm_score::add_to_player_score( player_points/4 ); // I added a divisor of 4 to lessen the points 
	
	return player_points; 
}



Thank you very much :)


You're welcome! :)