• 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 [Tutorial] Custom Perks

Give this function a go in your perk class. Let me know if it works for you.

Code:
function bool CheckReplacement(Actor Other, out byte bSuperRelevant) 
{
    if (Other.IsA('KFHumanPawn'))
    {
        KFHumanPawn(Other).RequiredEquipment[0] = "";
        KFHumanPawn(Other).RequiredEquipment[1] = "";
    }
    return true;
}
[/QUOTE]
 Jst so you know, this doesn't work inside the perk as me and ro_sauce tried to get this to work for his perks.
 
Upvote 0
Hi there,
I'm working on a custom perk and all is working fine. I got a random melee weapon ability specific to your perk level (i.e. tireiron for perk under level 3 and i.e. a rusty shovel above). But what I need is to remove the given Weapons "Knife" and "9mm" Pistol, because this perk should use it's own. How could I do this? I searched all classes for the veterancy types (anchestors included), if there is some line that says giving this items to the player, but I don't find one.
Would be nice if someone could help me. Thank you.

Put this in your perk code:
Code:
static function AddDefaultInventory(KFPlayerReplicationInfo KFPRI, Pawn P)
{
	local Inventory I;

	// Delete standard guns
	I = P.FindInventoryType(Class'Knife');
	if( I!=None )
		I.Destroy();
	I = P.FindInventoryType(Class'Single');
	if( I!=None )
		I.Destroy();
	KFHumanPawn(P).RequiredEquipment[0] = "";
	KFHumanPawn(P).RequiredEquipment[1] = "";

	// Then give perk specific weapons.
	if ( KFPRI.ClientVeteranSkillLevel < 3 )
		KFHumanPawn(P).CreateInventoryVeterancy(string(Class'MyTireIron'), GetCostScaling(KFPRI, class'MyTireIron'));
	else KFHumanPawn(P).CreateInventoryVeterancy(string(Class'MyShovel'), GetCostScaling(KFPRI, class'MyShovel'));
}
 
Last edited:
Upvote 0
Hi
I'm trying to get the G36C Ammo/Mag and the recoil upgrades into a new commando perk I'm making

Would I be able to get the code to add the G36C to these?

Code:
static function float ModifyRecoilSpread(KFPlayerReplicationInfo KFPRI, WeaponFire Other, out float Recoil)
-------------------------------------------------------------------------------
static function float AddExtraAmmoFor(KFPlayerReplicationInfo KFPRI, Class<Ammunition> AmmoType) 
-------------------------------------------------------------------------------
static function float GetAmmoPickupMod(KFPlayerReplicationInfo KFPRI, KFAmmunition Other)
-------------------------------------------------------------------------------
static function float GetMagCapacityMod(KFPlayerReplicationInfo KFPRI, 
KFWeapon Other)
The "---------------" lines above are ment to seperate the lines of code and are not part of the actual code (I had trouble spacing the lines). And as for the damage and the price changes those should be working and set right now. Thanks!
 
Upvote 0
I've a questions...

I've a questions...

Is there limits of appilcation weapons and perks, charater command line in Serverperks.ini?
I was appiled 20~25 perk and approximately 200~250 weapons in serverperks.ini
By the way.... Server'll work ... But, Access is not.
I guess a problem with weapons.
I never had a problem when coding, It's a problem that applies to the server...hm
And ...If a problem with the weapon in "serverperks.ini", Is there any way to automatically removed?
 
Last edited:
Upvote 0
Hi
I'm trying to get the G36C Ammo/Mag and the recoil upgrades into a new commando perk I'm making

Would I be able to get the code to add the G36C to these?

Code:
static function float ModifyRecoilSpread(KFPlayerReplicationInfo KFPRI, WeaponFire Other, out float Recoil)
-------------------------------------------------------------------------------
static function float AddExtraAmmoFor(KFPlayerReplicationInfo KFPRI, Class<Ammunition> AmmoType) 
-------------------------------------------------------------------------------
static function float GetAmmoPickupMod(KFPlayerReplicationInfo KFPRI, KFAmmunition Other)
-------------------------------------------------------------------------------
static function float GetMagCapacityMod(KFPlayerReplicationInfo KFPRI, 
KFWeapon Other)
The "---------------" lines above are ment to seperate the lines of code and are not part of the actual code (I had trouble spacing the lines). And as for the damage and the price changes those should be working and set right now. Thanks!
Hey. I would personally say the best way to see how a perk is fully unstable is to look at the official perks TWI made. They are a great way of learning by comparing to what is already made. They are in the KFMod file under the names KFVetBerserker etc. I hope this'll help with your learning :)
 
Upvote 0
so sad=..=

so sad=..=

Hmm, If I follow what you are saying ASSAYARO, I think that's to do with a limit with array sizes. Until Marco's implementation of sub categories in the trader you were limited to about 50 weapons. As for a work around I don't know where to start looking.

Mr.Gartley Look pm
Spoiler!

I regret making perks.:(
so sad...labor in vain...hm
 
Upvote 0
Mutator Newbie

Mutator Newbie

Hi, I'd like to create a mutator that makes it so that only the Owner of a weapon can pick it up.

In other words, if someone buys a weapon at the trader and then turns around and drops it so that he can buy another - Someone else cant come along and pick it up and sell it. Only the ORIGINAL owner can pick it back up. Any weapon that spawns on the map would have an owner set as WORLD so that anyone can pick it up, and maybe if the player dies, all of their weaps would then be set to Owner = WORLD

I am a C/C++ programmer so i should be able to create it (Assumnig it doesn't already exists somewhere) But I have never even looked at the UR SDK or anything yet.

Question is:

1) Looking for a good quick start guide to mutators (this thread will probably work) And any other links.

2) SDK docs and reference materials - Obviously I would need to study the STRUCTS and CLASSES associated with players and Items

3) Any other suggestions for a newbie - Just need to get pointed in the right direction, dont need to have my hands held along the way :D
 
Upvote 0
Thanks FluX, I was able to make the perk successfully and add some other stuff so it's working very good!

Just one question for whoever can answer. I was making a custom assault-rifle (bullpup model for now) that fires .50AE rounds and when I tried it ingame I noticed that it couldn't cause headshot damage (their heads didn't blow up and I didn't hear the cracking noise and I could see that when I shot their heads they received normal body damage and not headshot damage.

I did notice that I removed
Code:
 PvPDamageMult=1.0
from the damtype file. It was giving me compiler errors so I had to remove it from the code, did that remove headshots? If so how can I fix the problem? Thanks!
 
Upvote 0
Thanks FluX, I was able to make the perk successfully and add some other stuff so it's working very good!

Just one question for whoever can answer. I was making a custom assault-rifle (bullpup model for now) that fires .50AE rounds and when I tried it ingame I noticed that it couldn't cause headshot damage (their heads didn't blow up and I didn't hear the cracking noise and I could see that when I shot their heads they received normal body damage and not headshot damage.

I did notice that I removed
Code:
 PvPDamageMult=1.0
from the damtype file. It was giving me compiler errors so I had to remove it from the code, did that remove headshots? If so how can I fix the problem? Thanks!

Extend the damage class from KFProjectileWeaponDamageType.
 
Upvote 0
One's a generic damage type the other is one for projectile weapons, ie guns. I had this when I made a Colt1911 for KF, I wasn't getting the head shots, I changed the damage type and viola, it worked. I was going to add something about how some additional functions are handled but I can't remember so I'd rather stay silent then spread misinformation.

@xtsnet Hi there, welcome to the TWI boards. For getting started I suggest Benjamin's threads I posted right at the beginning of my thread. Those plus the other links to the likes of Beyond Unreal and the Unreal Script reference should be all you need to get started. Nose through the threads, especially in this sub forum, if you would like to see how something works most of the authors around here would happily share their source or point you in the right direction.

Have fun! ^^
 
Last edited:
Upvote 0
Without adding a second requirement the only thing I could think of is either:
(Using your examples of AR, Explosive and Melee)

#1
Edit your Explosive/Melee weapons' damage classes to add to the AR damage count (or vice versa)

#2
Create a new requirement for the perk ie BoomyARSlashyDamCount and use the perk to replace the damage types with new ones that have the function AwardDamage add to that new requirement count. (as well as the old)

I'd personally opt for option 2 myself, it's cleaner.
 
Upvote 0
in DamType,
What is the difference between KFProjectileWeaponDamageType and KFWeaponDamageType?
I don't know the difference between 2.
Explain in greater detail...
And... If misuse, make a trouble or issue or serious problem?
From experiementing on some of the weapon types, they do different things to the gameplay and how they affect the specimens.

KFWeaponDamageType is a base for all the other different damage types that TWI had made. Some are designed to give a massive kick in the shots and some are to set enermys on fire. It all depends on which one you use as to what affect they have on the specimens. You could potentially have a look at all the defaultproperties and experiment on what affects each of the functions what do. It's actually quite funny sometimes what a number change etc can do.
 
Upvote 0
Hi all,

I've been trying to make a custom headshot requirement for sharpshooter, So the requirement only counts a headshot kill if its a Siren/Husk/Scrake or Fleshpound.

If possible I still want it to record stats of headshot kills like normal. (So i can pull the % of Siren/Husk/Scrake/FP HS kills against All Sharpshooter HS at a later date.


Anyways, the tutorial shows how to set up for a damage based progression (which i've managed fine, I've also added a Sharpshooter damage requirement)

But I'm not sure about how i go about creating the custom HS requirement.


Below is from the KFWeaponDamageType.uc, this is for regular headshot kills with Sharpshooter weapons right?
Code:
static function ScoredHeadshot(KFSteamStatsAndAchievements KFStatsAndAchievements, bool bLaserSightedM14EBRKill)
{
	if ( KFStatsAndAchievements != none && Default.bSniperWeapon )
		KFStatsAndAchievements.AddHeadshotKill(bLaserSightedM14EBRKill);
}

Any help would be much appreciated.
 
Upvote 0
This all depends on how you have setup your mod for your server. If you use Marco's ServerPerks, then you'll have to do some extending unless you have your own customised version and prefer to hard code it with the other stats.

Extending of ServerPerks (or your own):
[url]http://forums.tripwireinteractive.com/showpost.php?p=1068546&postcount=3[/URL]

Hard coding stats (if your own renamed ServerPerks version):
Look at files ClientRepLink.uc, ServerStStats.uc, StatsObject.uc and SRStatList.uc (I think that is it). They all are part of the creation of the custom stat you would like to make but the function for it would be set in ServerStStats so make sure you double check for the stats ready made and compare.

Any problems, contact me :)
 
Upvote 0