Left 4 Dead 2

Left 4 Dead 2

Not enough ratings
FAQ for weapon model hacking/swapping in L4D2 with Blender
By pizza and 1 collaborators
This guide has nothing to do with playing the game: it is for modders. In this tutorial I'll try to show and explain how to deal with some frequent issues hacking weapon models in to L4D2.
   
Award
Favorite
Favorited
Unfavorite
Introduction
This guide is mostly going to be for my own reference. It might not make any sense.

The process:

1. Find the old model with animation set, and new model. Download them.
* Old model = the model in the game you want to replace (e.g it has a good animation set, but you want a different model).
* New model = the model you're replacing with
2. Crowbar decompile both your models in to separate folders
3. Import your new model in to Blender and clean it up: only the mesh should remain. No skeleton etc.
4. Import your old model in to the project.
5. In Object Mode, translate/rotate/scale the new model so that its in the position of the old model.
6. Apply the transform! Very important. (Ctrl + A)
7. In Edit Mode, assign the vertex groups of your new model to the corresponding ones of the vertex groups in your new model. Make sure their names are parallel.
8. Assign the new model's armature to the old model's skeleton.
9. You can test by importing an animation and seeing if your new model moves correctly. If all/part of it isn't rigged, it will be very clear.
10. Ready for export to .dmx, compile using Crowbar and test in game.

Insurgency tutorials for model swapping

Just refer to this and maybe this[web.archive.org]. Everything is pretty much the same.

Only things I would add:

TAB to change from Edit Mode to Object Mode. View (left, right, top, etc) is on the bottom left corner. Vertex groups bind automatically to bones, as long as there is a armature modifier.
Fixing third person worldmodel magazine is not detaching or in the wrong place
If the magazine is not detaching, make sure the bones and vertex groups are set up correctly. To do this, you will need to access a reference worldmodel where magazine detachment is working. I decompiled these for this example.


If your magazine is in the wrong position like this, make sure the ValveBiped.weapon_bone_Clip bone is correctly positioned relative to your ValveBiped.weapon_bone. We will need to look at our reference worldmodel to see the positions.

The new model is on the left while the reference model is on the right.

This is for the weapon_bone bone.

The positions themselves are not that important: its the difference in positions. Observe the X and Z axis and how they change for the weapon_bone_Clip bone. We need to set the values like so:


As you can see, in the reference model the Y axis changed by 10 and in the new model the Z axis changed by 10. Why are the axis different? Because for some reason in the new model the worldmodel is setup with butt facing down Z and muzzle facing up Z, whereas in the reference model its down Y to up Y. Again, its not the X Y Z values of the bones that are important, its the difference between them and the orientation of the bones that is important. Since in the reference model the muzzle is facing up Y, we change the Y axis of ValveBiped.weapon_bone_Clip +10 so it moves towards the muzzle relative to ValveBiped.weapon_bone. Since in the new model the muzzle is facing up Z, we change the Z axis of ValveBiped.weapon_bone_Clip +10 so it moves towards the muzzle ValveBiped.weapon_bone. Other than the affected axis, since the bones are aligned in every other axis, the two bones can share the same values for all the other axis.

Most worldmodels will be facing down Y and up Y, so you should be able to set the X Y Z for each bone to be exactly the same as the reference model. If you execute correctly, the worldmodel should look like this:

Pose is ♥♥♥♥♥♥ up after opening decompiled viewmodel smd file
Help my model looks like this:
Import the idle animation, where it should be fine.
Then do this.[blender.stackexchange.com]
Deploy animation is distorted after compiling:
This has to do with the deploy_layer sequence. Changing the smd and subract often fixes it.

Change the deploy_layer sequence from this:
$sequence "deploy_layer" { "v_desert_rifle_anims\deploy_layer.smd" activity "ACT_VM_DEPLOY_LAYER" 1 delta // This subtract option added by Crowbar to prevent jigglebone problems when delta sequences are recompiled. subtract "deploy_layer" 0 { event 5004 1 "Rifle_Desert.Deploy" } { event 5004 10 "Rifle_Desert.SlideBack" } { event 5004 17 "Rifle_Desert.SlideForward" } fadein 0.2 fadeout 0.2 fps 30 ikrule "lhand" touch "body" contact 0 fakeorigin 0 0 0 fakerotate 0 0 0 floor 0 height 0 radius 0 range 0 0 32 32 target 1 ikrule "rhand" touch "body" contact 0 fakeorigin 0 0 0 fakerotate 0 0 0 floor 0 height 0 radius 0 range 0 0 32 32 target 0 }
to this:
$sequence "deploy_layer" { "v_desert_rifle_anims\deploy.smd" activity "ACT_VM_DEPLOY_LAYER" 1 delta // This subtract option added by Crowbar to prevent jigglebone problems when delta sequences are recompiled. subtract "idle" 0 { event 5004 1 "Rifle_Desert.Deploy" } { event 5004 10 "Rifle_Desert.SlideBack" } { event 5004 17 "Rifle_Desert.SlideForward" } fadein 0.2 fadeout 0.2 fps 28 ikrule "lhand" touch "body" contact 0 fakeorigin 0 0 0 fakerotate 0 0 0 floor 0 height 0 radius 0 range 0 0 32 32 target 1 ikrule "rhand" touch "body" contact 0 fakeorigin 0 0 0 fakerotate 0 0 0 floor 0 height 0 radius 0 range 0 0 32 32 target 0 }
Why isn't automatic keyframe saving working Blender
Make sure these settings are right (bottom-left of screen):

Change position/rotation of bone for multiple keyframes
Let's say you want to change the position of the left hand bone on a reload animation, but are unable to apply your changes to every frame at once. Use the graph editor.
More here: especially the part about G and Y[blender.stackexchange.com]
Changing the idle animation doesn't do anything wtf?
You have to change both the idle and walk animations to change the idle/walk animations, because they sort of depend on each other.
5 Comments
D€ÂƚΉ♤₵ђ€₳ƚ Nov 5, 2024 @ 5:05am 
Thanks for this
Undercooked Linguine Mar 16, 2021 @ 11:54am 
is
Recoil Jan 6, 2020 @ 7:57pm 
pls give sack of potatos to me
pizza  [author] Aug 18, 2019 @ 12:14am 
Thanks man, yeah lol I made this for when I come back two years later and try to mod something else in to this stupid game
Rymd Aug 17, 2019 @ 5:04am 
this would have come in handy when i tried to compile sumthing [i.imgur.com] 2 years ago, nice work