• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code [Help] Assistance with Creating New Perk Bonuses

Hello All!

I need help with creating a new perk bonus for my new perk.
The Perk Bonus is called ModifyOverheatCoolDownRate and it is to reduce the duration of guns cooling down like the M134 Minigun made by the Russian Modders.

Here is what I have coded so far in my perk file:
Code:
static function float ModifyOverheatCoolDownRate(KFPlayerReplicationInfo KFPRI, class<KFWeapon> Other, out float CDRate)
{
	if ( M134DT(Other) != none )
	{
		if ( KFPRI.ClientVeteranSkillLevel <= 4 )
		{
			CDRate = 1.00 - (0.05 * float(KFPRI.ClientVeteranSkillLevel));
		}
		else if ( KFPRI.ClientVeteranSkillLevel <= 5 )
		{
			CDRate = 0.60;
		else
		{
			CDRate = 0.40; // Level 6 and beyond - 60% Faster CoolDown Rate
		}
		return CDRate;
	}
	CDRate = 1.0;
	return CDRate;
}

and in my own VeterancyTypes file:
Code:
static function float ModifyOverheatCoolDownRate(KFPlayerReplicationInfo KFPRI, class<KFWeapon> Other, out float CDRate)
{
	CDRate = 1.0;
	return 1.0;
}

How would I make it affect the cooldown rate of the weapons like M134?
 
Last edited:
In the weapon class where the cooldown number is handled:

Code:
if ( KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo) != none && KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo).ClientVeteranSkill != none )
{
    CooldownMod = KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo).ClientVeteranSkill.Static.ModifyOverheatCoolDownRate(KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo));
}
Personally, I would remove your out parameter and replace it with a simple return. Also, there's no need to really put a weapon checker because only 1 weapon uses this. Because of these 2 reasons, I removed all parameters but the KFPRI.

Hope it helps.
 
Upvote 0
In the weapon class where the cooldown number is handled:

Code:
if ( KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo) != none && KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo).ClientVeteranSkill != none )
{
    CooldownMod = KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo).ClientVeteranSkill.Static.ModifyOverheatCoolDownRate(KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo));
}
Personally, I would remove your out parameter and replace it with a simple return. Also, there's no need to really put a weapon checker because only 1 weapon uses this. Because of these 2 reasons, I removed all parameters but the KFPRI.

Hope it helps.
I put the weapon checker in for adding future weapons and I might add the overheating and cooling systems in other guns like the M249.

Also, I have only edited my perk file and my VeterancyTypes file, I have not touched the weapon file yet.

Does this mean I should add your lines of code into the weapon file?
 
Upvote 0
Does this mean I should add your lines of code into the weapon file?
How else did you think the weapon would know to use this perk bonus? haha

Instigator seems to be a global variable so you don't have to set it up in whatever function this needs to be in. If the cooldown is calculated/set inside of the weapon class, you can copy and paste that wherever the cooldown is calc'd and do a *= to the CooldownMod var.

I believe you just have to add a Weapon.Instigator to my code if it's done in the fire class.
 
Upvote 0
How else did you think the weapon would know to use this perk bonus? haha

Instigator seems to be a global variable so you don't have to set it up in whatever function this needs to be in. If the cooldown is calculated/set inside of the weapon class, you can copy and paste that wherever the cooldown is calc'd and do a *= to the CooldownMod var.

I believe you just have to add a Weapon.Instigator to my code if it's done in the fire class.
Thanks man!

Though, I did not use "*=", I used the code the syringe (Maybe next time I should have looked here first xd) used:
Code:
if (HeatLevel > 0 && KFFire(FireMode[0]).LastFireTime < level.TimeSeconds - 4)
{
	if ( KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo) != none && KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo).ClientVeteranSkill != none )
	{
		HeatLevel = FMax(0, HeatLevel - DT/10) * KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo).ClientVeteranSkill.Static.ModifyOverheatCoolDownRate(KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo));
	}
	else
	{
		HeatLevel = FMax(0, HeatLevel - DT/10); //Cool Rate
	}
}

Thanks again, Skell :D
 
Upvote 0