• 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 Unresolved Reference Shenanigans.

Toilet Duckie

Active member
May 18, 2009
25
1
I've done a little RO modding in the past (silly BA64s, SVT Shotgun, etc.) so I decided to give KF modding a whirl. My first project (after learning that the Trader SFX are buried so deep in the code that a "Resident Evil 4 Merchant" mod would be impractical) is porting over the STG44 from RO. Nothing to release, mind you, just doing it for experience and kicks.

I've hit a snag, though. Using the Bullpup code as a starting point, I believe that I've got everything in working order... except for one thing. Observe the following line of code from BullpupPickup.uc :

StaticMesh=StaticMesh'KF_pickups_Trip.Bullpup_Pickup'

Innocent enough, right? My understanding is that this line tells UCC to look in the "StaticMeshes" folder for KF_pickups_Trip.usx . It then searches inside that for Bullpup_Pickup. However, when I do this:

StaticMesh=StaticMesh'WeaponPickupSM.Weapons.stg44'

I get the compiler error "unresolved reference". I know what you are thinking: "Silly Duckie, referencing a .usx file from RO in a different game!" The problem is that I copied WeaponPickupSM from RO's StaticMeshes folder. I still get the error.

Compounding this problem is that if I open up UnrealED / Killing Floor SDK, WeaponPickupSM doesn't appear in the Static Mesh browser. Yet I can open it from within the SDK without any issues and even browse around, check that stg44 exists in it, etc.

So, long story short: What's the gimmick stopping me from adding new Static Meshes, Sounds, Animations, whatever to their respective folders and having them recognized when referenced in code?
 
That didn't work, either. However, I stumbled onto a semi-solution. If I open WeaponPickupSM.usx in the Killing Floor SDK and then save it under a different name (not changing anything, mind you) the error goes away.

Perhaps this has something to do with the package / packages being created for RO, and re-saving them updates the packaging format?

My new and much, much less likely to be solved error is that Axis_stg44_1st.ukx causes the KF SDK to crash when I try to open it with a "Bad export index 34/23" error. Weapons3rd_anm.ukx didn't have any problems with being open/saved, so it must be something more annoying in that particular package...

Nothing's ever as simple as it should be, eh?

Edit: Well, judging by the error I was seeing, it was a problem with "notifiers" in the animation file. I got rid of those as a test and it solved the problem. Now I have the STG "model" in game, firing with STG noises, having proper ammo amounts and its own damage values and so on. Latest problem: I cannot for the life of me get it to display the proper texture..err.. skin... err.. whatever you call it. Well, that and the bullets coming from the wrong place on the screen and other minor issues...

Edit #2: Pro tip for people starting out on porting weapons: Don't forget that "texture links" get broken in the process of renaming things. The reason the STG44 lying on the ground was textureless was because I had renamed the texture file. Oddly enough, the texture for 1st person animations was "correct", but some value called "SleevNum" was goofing up the texture. Long story short, I now have what looks like and sounds like an STG44. Just need to fix the animation somehow..

Shamelessly Editing Yet Again: I had a thought: Why not just port ALL of RO's gun code into KF? It'd be easier than reverse-engineering the guns if it worked and might avoid all of the strange animation/texture issues? If it worked. Nah, too much trouble for something that's probably semi-illegal.

Final Edit, I promise! (for this post at least): A little more tinkering has yielded decent results on the "not porting all of RO" side. The only things not functioning properly now are sounds during the reload animation and where the bullets "spawn" when you are firing from the hip. Technically, the animation isn't "perfect", but that has more to do with a few variable tweaks and the manner in which KF handles switching from hip to ironsight. With any luck, I'll have a fully functional and usable STG tomorrow. Guess I'll try a rifle next.
 
Last edited:
Upvote 0
The reload sounds are missing because those are actually part of the notifies that you deleted. You'll need to add new ones with the sounds to get things working again. In fact, the reason you were having problems with them before is that they were still attempting to reference RO sound packages which it wasn't able to find.

As far as the bullet spawning, I guess it depends on whether you attempted to rip the STG's code or just slap the model in place of the Bullpup. RO weapons by default fire from the muzzle bone of the weapon mesh, allowing proper freeaim. KF by contrast, almost certainly fires all its rounds from the centre of the player's screen, hipped or not. Though I have to admit, I haven't actually looked at its code, so I can't be 100% sure, but that's how it appears from playing the game and watching the tracers. If you're using the RO weapon class (albeit modified), then you'll need to change the prefiretrace/spawnprojectile origin point from the muzzle bone to the point of aim. Basically the same as how RO sets the origin while you're ironsighted.
 
Last edited:
Upvote 0
Nah, I didn't port or modify the RO gun code. I used the Bullpup as a base for a "quick and dirty" switch over.

Now that you mention it, though... maybe every gun DOES fire from the center of the screen. I was a little confused because PlayerViewOffset in the _Weapon_.uc file allows you to alter where the weapon itself appears relative to your viewpoint, but a similarly named EffectViewOffset didn't appear to have any effect.

Any idea where to view the "bones" on a model? Maybe something was broken or misnamed during translation.

Oh, and I did figure out the reload sound effects thing. Seems kind of silly that one portion of the weapon's overall sound is stored/triggered from animation but not the rest.
 
Upvote 0
The sounds that are triggered by animations are the ones that don't occur at the start or end. So for firing and whatnot, the sound plays as soon as the animation starts, so it can be triggered via the code. For a reload though, it's generally playing a whole set of different sounds at points along the animation and that would be stupidly complicated to do through the code.

To view the bones on a weapon, open up the editor, bring up the animations tab and the weapon mesh you want, and on the toolbar, about the middle, there are a couple of icons of little stick people. The icon directly to the left of that will turn on the bones (keep clicking it to toggle whether the mesh is simultaneously visible or not) and the first of the little people icons is to show the bone names.

If there is a problem of missing bones though (or incorrect name references) you'll see it in the log file (under KillingFloor\System) as an error or warning.

Also, the thing with the texture, where you said that "SleeveNum" was messing things up, that's the value that tells RO which team a player is on, so that you have the correct sleeve (Allied/Axis) when you pick up an enemy weapon. Obviously there's no such thing in KF, so it was tying itself in knots trying to load a value that didn't exist.
 
Last edited:
Upvote 0