KF Custom weapon development help requested

  • 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/

Barrage o' Fail

FNG / Fresh Meat
Jun 12, 2013
15
0
0
Sun-Earth L4 point
I'm stepping into new waters doing this, but after two months of trial-and-erring my way through a new project, I'm about ready to release it into the wild, but wanted to see if I couldn't get some help on the last few bits that keep nagging me.

There's three specific things; custom perk discounts, bloodied melee textures, and third-person/attachment views:

First, is there any way to allow perk levels to give discounts on custom weapons without using Server Perks/SCRN Balance or any other outside package? For example, is there any way to insert code like the following into a weapon's pickup uc and have it work?

Code:
function ???? something()
    {
        local KFPlayerReplicationInfo KFPRI;
        KFPRI = KFPlayerReplicationInfo(Instigator.PlayerReplicationInfo);

        if (KFPRI != none)
        {
            if (KFPlayerReplicationInfo(Weapon.Instigator.PlayerReplicationInfo).ClientVeteranSkill.default.PerkIndex == 4)
            {
            Cost=1200
            }
            else
            {
            Cost=default.Cost;
            }
        }
        else
        {
        Cost=default.Cost;
        }
    return Super.Cost
    }

defaultproperties
{
    blah
    blah
    Cost=2000
}
Second, I have a blood-covered texture for melee strikes, but it is not being swapped via the BloodSkinSwitchArray. Everything else is pointing to the right texture (a combiner, actually), but it doesn't appear, and my venture is that it just doesn't happen for custom weapons.

*corollary to the above, the arm textures remain unchanged and perma-lit across character types despite using the same combiner as the default 9mm arms*

Lastly, is there a way to have custom movement/usage animations, or, not relying on the defaults in the KF_Soldier_Trip file? As it is now, I've got the new gun using the M14's 3P animations, and it looks close, but is still noticeably off. It's alt-fire animations I switched in the attachment uc to use melee animations instead, but it remains idle when used in-game. I suspected this had to do with bone names or heirarchies in the model or animation, but experimenting with both proved fruitless [parenting the mesh to the base M14 bone lets it move as expected, but melee is idle; parenting the Pipe_3rd bone to the M14 bone and the mesh to the Pipe bone in the hopes that the mesh would be affected by both the rifle and melee animations only made neither one work].

EDIT: I feel I should also mention that Professor Google hasn't been much help in finding solutions to any of these problems; looking for perk discounts almost always points me toward the Server Perks stuff, looking for bloody-texture fixes goes to that one post about *removing* the texture, and the only useful thing brought up in the third-person/attachment searches was YoYoBatty's code to remove muzzle flashes from melee weapons.
 
Last edited:

Skell

Active member
Mar 21, 2013
1,245
2
38
On the Internet.
Perk stuff
Look at IJC's weapon pack back when it was a mod. Their code essentially made extensions of vanilla perks and added bonuses. I'd link you the source code of my weapon pack but it's about to go into V3 so I can't atm. Your perks would looks something like this (using the example of getting discounts):
Code:
class MyVet/perkname/ extends KFVet/perkname/ abstract;
static function float GetCostScaling(KFPlayerReplicationInfo KFPRI, class<Pickup> Item){
    if(Item == class'MyNewWeapon')
        return super.GetCostScaling(KFPRI, class'MyWeaponToImitate');
    return super.GetCostScaling(KFPRI, Item);
}
Essentially what this does is takes your weapon and goes through the function of the original perk's as if it was one of the weapons receiving a discount. If any changes occur to the perks after your release, your mod will inherit them.
Bloody material stuff
So, if you're using a custom texture for your weapon, it's probably because KFMeleeGun sucks at loading assets.

My work around uses a InitMaterials() function pretty much identical to that of the ZEDGun (for the screen). Make sure to do up your Destroyed() and PreTravelCleanUp() functions properly too, as you want these textures removed when they're not in use. I used WeaponTick() for mine doing a check for if either texture == none.

Animation stuff
You can rename the meshes and the animations to new packages. I'm not an animator so I don't know if you can just add new animations to a package, but it's probably possible. I've moved weapons into new packages so that I can make new notifies and stuff.
 

Barrage o' Fail

FNG / Fresh Meat
Jun 12, 2013
15
0
0
Sun-Earth L4 point
I used the code for the discount, and although it compiled, it didn't function as intended (do I need to switch to this newer extended perk somehow?). I went through and copied the bits of the actual perk being extended and swapped the item-specific names, but that had the same result. I also tried looking around for the IJC pack as a mutator, and it doesn't look like it exists anywhere anymore. Toying around with the above and the code I posted earlier yielded either no change or compiling errors, so I may just have to wait for a working example or keep the price at some static-but-decent cost.

As for the texture, I went through the ZED gun's code and copied out the various functions mentioned, but still no change. You said that KFMeleeGun sucks at loading textures, but it uses the same stuff as the ZED gun for preloading, so I figure there's something somewhere else causing the problem.

As for the third-person stuff, I think I'll leave it as-is, since even if I renamed/duplicated the existing animations and tweaked them to fit the custom model, there'd be no way to get the player models to use the new anims over the ones in the KF_Weapons_Trip file.

The one success with all the experimentation was getting the hands to at least appear properly lit, even if they don't change with the player models.

I'll be working today on putting together footage of the nearly-completed project, so you'll at least be able to see what it is I'm working on.
 

DMN666

Active member
Jun 14, 2012
2,569
12
38
Brooklyn, NY

Barrage o' Fail

FNG / Fresh Meat
Jun 12, 2013
15
0
0
Sun-Earth L4 point
*palms forehead*
Yeah, that was the first thing that came up in the searches, but since the originators themselves had the links in their post going nowhere, it hadn't occurred to me to go through the thread looking for mirrors.

Thanks for that; guess I'll give it a look-through after work tomorrow.

EDIT: Nevermind, I just tried it with a near-verbatim copy of the IJC veteran stuff, and it still had its same price. I'm beginning to think TWI arranged it such that the perks can no longer be extended and thus have outrageous discounts or damage bonuses for whatever someone wants.
 
Last edited:

Skell

Active member
Mar 21, 2013
1,245
2
38
On the Internet.
*palms forehead*
Yeah, that was the first thing that came up in the searches, but since the originators themselves had the links in their post going nowhere, it hadn't occurred to me to go through the thread looking for mirrors.

Thanks for that; guess I'll give it a look-through after work tomorrow.

EDIT: Nevermind, I just tried it with a near-verbatim copy of the IJC veteran stuff, and it still had its same price. I'm beginning to think TWI arranged it such that the perks can no longer be extended and thus have outrageous discounts or damage bonuses for whatever someone wants.
Extending perks works. Make sure you're replacing the old ones properly.
 

Barrage o' Fail

FNG / Fresh Meat
Jun 12, 2013
15
0
0
Sun-Earth L4 point
As for the cost-lowering part, I used the script almost exactly as it appeared in the IJC files, with my gun's pickup being used instead. I even went through some other peoples' recent submissions on the Workshop and found their stuff to be unaffected as well. From the perk-related stuff I was able to find, I did manage to make the gun behave differently depending on the wielder's perk and its level, so I know TWI didn't disable at least that for modding.

As for the aforementioned video, here it [was]. I ran into some more stuff to work on when recording it, but I've taken care of most of it between yesterday and today. All that is left is to fix up the animation a bit, and whatever else I notice in the meantime.

Out of curiosity and for the sake of being thorough, am I correct in assuming the cost-altering code should be going into the custom perk-extending perk; and the bloody texture-swapping code should be in the main body of the actual gun's code (not its pickup or swing uc files)?
 
Last edited:

Barrage o' Fail

FNG / Fresh Meat
Jun 12, 2013
15
0
0
Sun-Earth L4 point
Update

Update

It's been close to 48 hours now and I can't see my previous post with the old video link [removed], but I'm probably going to release to the Workshop soon anyway. I was able to give the gun some bonuses depending on what perk the user is, at the least.

As it is now, my attempt at extending the Berserker perk for the discount looks like this:

Code:
class BG57iKVet extends KFVetBerserker abstract;
    
//Copied and adapted from IJCVetCommando
//from the IJC Weapon Pack White v27

// Change the cost of particular items
static function float GetCostScaling(KFPlayerReplicationInfo KFPRI, class<Pickup> Item)
{
    if ( Item == class'BG57iKPickup' )
    {
        return 0.9 - (0.10 * float(KFPRI.ClientVeteranSkillLevel)); // Up to 70% discount
    }
    return super.GetCostScaling(KFPRI, Item);
}
    
defaultproperties
{
    VeterancyName="Berserker Test"
}
It compiles fine, but no change occurs in-game, whether I play as a Berserker, any other perk, or using the console to change directly to the extended version via "set KFPlayerReplicationInfo ClientVeteranSkill BG57iKVet". This last one changed me to an empty perk (the icon in the corner disappeared), and the prices remained unchanged, and continued testing with this (putting the package name in front of BG57iKVet) actually reset my perks to 0 until I restarted KF.

Can I ask what should be done in order to get the texturing issue taken care of? I intend to keep trial-and-erring my way through it some more, until it works or I get frustrated enough to go without it.
 
Last edited:

Barrage o' Fail

FNG / Fresh Meat
Jun 12, 2013
15
0
0
Sun-Earth L4 point
update v3

update v3

[I'm gonna try this without any links in it and see if it works this time, as it'll the third time I've tried to post an update without seeing it added to the end of the thread]

I can't seem to get the perk to extend, or rather, it compiles but the discount is not applied.

Some good news, though, is that I got the bloody material texture to appear (it's a matter of the gun being an extension of KFMeleeGun, not anything else or even having KFMeleeGun's contents used verbatim within it). The bad news, though is that the alternate texture looks terrible and needs a lot of work (rolls eyes as another week delays release).

EDIT: Nevermind the delay, I went and posted a new video and released it to the Workshop. Killing Floor: The "Big Stick" Bolt Gun - YouTube I ended up making it two separate weapons, since extensions of the KFMeleeGun don't seem to have their ammo-buying trader buttons visible (even if they remain functional otherwise), and I wanted that to remain in the regular version.

Even if it ends up not working, I still credit Skell for the codework regarding the perk extension and discount; I'm still convinced that perks can't be extended that easily.
 
Last edited: