Contagion Guide

How to create custom weapons for Contagion [IN PROGRESS] for Contagion

How to create custom weapons for Contagion [IN PROGRESS]

Overview

This guide will give a step-by-step perspective of making custom weapons for Contagion. This guide will be updated as I continue the steps of creating a mod. It does not cover UV mapping and texturing your models.

Foreword and required programs.

Yo, I’m Vixx and I assume you’re interested in making custom weapons for Contagion since you’re reading this. This guide will go through each step of weapon creation in detail, with pictures!
Now, in order to use this guide you’re going to need a few programs;

– 3D modeling program or suite and at least basic knowledge of how it functions (I use Blender 2.72 and will be using it for screenshots)
– If using Blender you’ll need the Blender Source Tools, available here [link]
– Crowbar. It’s a program that compiles and decompiles Source models, get it here
[link]
(join the Crowbar group too if you want)
– VTFEdit. This is more of a texture viewer than an editor, at least how I use it, but it’s good for checking Alpha levels, more on that later.
[link]
– GFScape. This handly little program allows you to open .VPKs and Extract them, usefull for reverse engineering [link]
– An image editing program with .VTF capabilities ( I use Paint.NET, if you do too you’ll need this [link] )

After you’ve got all of that installed You’re almost ready to begin. The rest I’ll be showing you in the next section.

What this guide DOESN’T cover

– UV mapping
– Textureing
– 3D program use
– QC Syntax
-VMT Parameters and Syntax

There are tons of guides out there for these already so I’m not going to cover them here.

Prepwork

First, navigate to your Contagion instal folder, that’d usually be SteamAppsCommonContagion Then open the “contagion” folder inside the “Contagion” folder, confusing I know, but the difference is key. Inside there should be a bunch of .VPK files named things like Maps, Mareials, Scripts, Sounds and other stuff. If you’ve installed GFScape you should be able to double click on them to open them, Only the .VPKs with _dir at the end of thier name should be opened, so find models_dir.vpk and open it, Then right click on “root” in the file tree on the left side of the window that opens and select Extract.
I extracted the entire games fileset to a folder on my destop for convenience but you can put them wherever you like.
Next we’re going to open Crowbar, select the Decompiler tab at the top and browse for the file to be decompiled, for this guide I’m going to be using the models for the 1911, so they’de be in v_1911 and w_modelsw_1911 . I’ve already done this for a previous mod I released so I’m not going to show you this step

Viewmodel pt. 1 (Import and Join)

Now we’re going to open Blender and import the new mesh first, then import the reference >smd that we decompiled earilier, make sure it’s the “V” reference and not the “W” since that comes later (I had this replacement already prepared so I didn’t need to waste time making it for this guide),

Once we have them both imported we’re going to join them as one object, with Blender this is done by right-clicking on the replacement model then holding shift and right-clicking on the original model, the order is very important as it sets the parent object so make sure the original mesh is selected last. Then after all the objects have been selected press Ctrl+J or select Join from the toolbox on the left.
If you’ve done it right the name should look like the highlighted are in the second picture, otherwise Ctrl+Z is your friend.

Once we’re satisfied everything went right we can move on to the next step.

Viewmodel pt.2 (Materials and Vertex Groups)

Next, we need to delete the old mesh from the object, you can select the verts to delete easily through the material tab when in Edit Mode, after that switch back to Object mode and delete the material of the original mesh since we don’t need it anymore.(For this mod I left the flashlight so it will use the standard light from the base game but you don’t have to do this if you haver a custom light). As a reminder Source uses the material names for .VMT files so remember what you named things.

Once that’s done it’s time to set Vertex Groups, I’m not going to tell you how to do that since there’s tons of tutorials on that for Blender already, though I marked with red the groups that you should NOT assign verts to. For those unaware Vertex Grouos are essential for Source animations to work properly.

After we assign all the verts to their respective groups we move on to step 3 of the viewmodel.

Viewmodel pt. 3 (Edge Split, Vertex Normals and Armature)

First thing; DON’T EVER MESS WITH THE ARMATURE. don’t copy it, don’t apply it, don’t move it, don’t click on it at all, I did that once and had to redo the entire project fromn scratch.

Anyway, eveything in this section takes place in the modifiers tab of the object, so we’re going to navigate to that tab and click on “Add Modifier” and select Edge Split.

The Edge Split modifier hasa couple of variables in how it’s handled, one of them is Edge Angle, which sets all edges over a specified face angle as sharp edges, the other is Sharp Edges, which sets manually defined edges as sharp. These two variables can be used at the same time or individually, I use a mixture of them since the first time I did this I set individual edges only, that took me seven hours.
If you do want to set individual edges this is accomplished in Edit mode, make sure that Edge Select is enabled and not Vertex select, then select the edge(s) you want sharp and click the botton indicated below. (it’s up to you if you want to recalculate the Vertex Normals or not, I reccomend it.)

When we’re finished deciding what edges should be sharp or not we do two things, first we DO NOT apply the Edge Split modifier, Blender does that for us when we export the model. Second we look how mudch prettier the pistol is now and move on to the next section.

Viewmodel pt. 4 (Animations)

Once we have the model itself completed we need to fix some of the broken animations. Two or three animations will always be broken after a decompile, the a_ironsight, the a_idle_delta, and the a_emtpy if the model has one, these are all simple to reconstruct since they’re not actually animations but single frame poses that the animations blend together.

First we import a_idle into Blender, then (with the armature bones selected) we go into pose mode, this animation should only require working in the keyframe area, indicated below

Then we select each keyframe by clicking on the last one in line and pressing Alt+I, you can also use the arrow keys to navigate frames. We need to delete all keyframes from 0 to 1, then we set the end frame to 1 and delete frame 1. The next part might be a little complicated, we click on frame 0 to set the pose, then move to empty frame 1 and insert a keyframe with LocRotScale, shown below.

Now, when we do that we select every bone node EXCEPT ContagionViewReload (Marked with red box) , don’t have that one selected when you insert the keyframe into 1, once we do that we delete frame 0 so what were left with is a two frame pose that has an empty frame 0 and a pose on frame 1. If everything has been done correctly we’ll have sucessfully reconstructed the Idle Delta pose

Now, the ironsight pose takes much more work even though it’s essentially the same process, the only thing different is we actually have to position the weapon in frame 1. I’ts important that your aiming point be in line with the green line of the Blender grid, so it faces the right direction.

Lastly, the Empty pose for guns that have it (mostly just the pistols), it’s made just like the Idle_Delta pose except you manupulate some bones, such as the slide, slide lock and barrel to show that the pistol is empty and the slide locked back if applicable (This is something I don’t think even the developers did despite coding it in, so mods that use actual empty poses are really cool.

A Few Notes On Aiming;
Due to the difference between real ballistics and aiming versus videogame aiming a number of problems arise when making the ironsight pose, most notable the Source engine doesn’t nativel support ballistic arcs, bullets travel in a perfect line (offset by spread modifier in the weapon script).
So keep that in mind when making the ironsight pose, personally with pistols I make my POI to be just above the front sight post, as that is a common and effective aiming tactic for actual pistols.

Next is the distance from your view and the sights themselves, personally I found that the default distance for weapons was comically too far from your “eyes”, as if you were holding even rifles with arms outstretched as far as possible, obviously this is not a good aiming tactic so my mods have the ironsight pose much closer to player view, it’s really up to you how far or close you make your pose, but a good distance for pistols is shown in the last image, remember that player view is from the center of the grid, not ContagionViewReload.

Next up; World and Physics models!

Export Viewmodel.

Before we continue to the world model we need to export the viewmodel, so save, then export as SMD using the settings indicated in the picture below


Don’t bothe with the engine path for the QC compiler as we do that manually.

World Model pt. 1 (Mesh, Vert Groups, Animations, and LODs,)

First thing, save, then save a copy somewhere else.

Okay, if everything went well with the viewmodel we can start on the world model (the one we see on the ground and in other players hands) this isn’t exactly a necessary step , but it’s best for immersion, though a good chunk of modders for Contagion don’t bother with it, we are not those.

First, delete the armature bones and all vertex groups, do not delete materials, then we import the worldmodel reference SMD, it’s very important we remove the vertex group and armature of the viewmodel. Otherwise it will conflict with the world model.

So, we’ve got both our objects in our scene, the first thing we do is position our new mesh in the same spot and location as the original as shown below
(In the picture below it shows a USP instead of a 1911, I did some cleanup of my hard drive at the time so didn’t have an already decompiled world model of the base 1911 so I used one of my previous mods instead)


We’re going to go ahead and apply the EdgeSplit modifier we set up earlier since it won’t carry over when we join the objects together.

Then (in Object Mode) select the new mesh, then the old mesh with shift+RightClick. make sure the original mesh is the last one selected then joing them with Ctrl=J.

Then delete the old mesh, and any materials from the old mesh that you are not going to use, the materials for your new mesh will be carried over, modifiers will not be carried over.

Just like the viewmodel we set up vertex groups next, though this time the entire model goes into one group, the ValveBiped.Bip01_R_Hand get’s all the mesh assigned to it, this means that world models have no actual animations beyond moving the entire mesh as a whole.

That’s actually it for the world models, since none of the animations for it are broken by Crowbar upon decompiling.

Now, since the programming side of Contagion is all over the place only about a third of the weapons have LOD replacer models, I prefer not to use them at all so I won’t show how to make them, if you really want you could just make them from the hi-tri world model and dissolve as you see fit.

Anyway, export the world model just like the viewmodel but the a different folder

Wordld Model pt. 2 (Physics)

So, we’ve finished the world model, now we open the physics SMD for the original model, it shares one common bone with the world models armatur which is good, it should put that bone in the same place as the one from the world model.

The physics model is spuer easy, we go into Edit Mode and move the box so that it completely hides the weapon (in this case a pistol) We can resize and shift it any way we want so it follows the shape of the weapon as closely as possible while still remaining as simple a shape as possible


There, look at our pretty physics box, this acts as the collision boundary for all of the Source Physics systems. We then export the physics.SMD to the same folder as the viewmodel reference

QC

This sectio won’t have any pictures since all wer’re doing herer is text based.

QC files are text logs that basically tell a compiler how to build the MDL files from all the parts, they also set special paremeters for those files upon compiling, the nice thing is that they can be read and edited with the simplest of text viewers (I use Notepad)

We’ll start with the viewmodels QC, most of it is contextueal so I can’t easily teach you gow to change things, just make sur that the animation names in the QC match up with the filenames in the animations folder you’re using, one big thing is the ironsight sequence, you need to make it look like this

$sequence “ironsight” {
“a_idle_delta”
“a_ironsight”
fps 30
loop
delta
autoplay
hidden
blendwidth 2
blend “ironsight_pose” 0 1

Make sure to NOT have subtract_idle_pose in the ironsight sequence, as it breaks the vert groups of everything except the AR15 for some reason.

The worldmodel QC needs no editsa unless you decided not to have and different LOD models, then just delete those lines, they’re near the top..

Compiling

We haven’t used Crowbar in awhile but it’s time to open it back up and compile the models

SteamSolo.com