Garry's Mod

Garry's Mod

Not enough ratings
Porting Soul SFM Halo 5 Spartan models to gmod
By SuperMario20
This is a guide on porting Soul_ SFM H5 Spartans to gmod in a few simple steps! This will go through the steps of rigging, making npcs, and making playermodels, all the way up to Lua Scripting!
   
Award
Favorite
Favorited
Unfavorite
Importing Soul_ SFM models, rigging, and exporting.
-------IMPORTING-------

1. First, download the model you want to bring into gmod. Then, download Crowbar: https://drive.google.com/file/d/0Bz8zS9qTrqHWVFhINFplTEZOWFk/view?usp=sharing

2. Open crowbar, goto decompile, select the .mdl file/folder, and hit decompile. Now download Blender: https://www.blender.org/download/

3. Don't forget to get Blender Source Tools as well: https://developer.valvesoftware.com/wiki/Blender_Source_Tools

4. Open Blender, select import>import qc/qci/smd/dmx. Now select your decompiled qc file.

5. It should pull up your model without it's texture. That means that it is working.

6. EDIT: DO NOT DELETE YOUR MODELS SKELETON. Go into edit mode with your model's skeleton. For each bone similar to valve biped, rename it to its valve biped counterpart bone. (Rename bip_pelvis to ValveBiped.Bip01_Pelvis, rename bip_r_hand to ValveBiped.Bip01_R_Hand, etc.) Then delete the fixup bones.

7. Now, for the techs it of your spartan model, go into edit mode, and click a vertex group like bip_r_upperarm_fixup, or something. Press select. Find the ValveBiped.Bip01_R_Upperarm vertex group. Click on it. Press assign. Now delete the bip_r_upperarm_fixup. It will break the model if you keep it. Now do this for each vertex group, if vertices turn orange when you select a fixup. Now if your model has multiple techsuits, then go into their vertex groups and dedete all of them. Leave the one that you fixed. Now select the other techsuits, and select the fixed on as the active. Now press ctrl c. Click copy vertex weights. Tada! All of the techsuits are fixed. Do this for the armor bodygroups as well.

8. Now you can delete the original skeleton.
7. Download my halo 5 spartan skeleton: https://drive.google.com/open?id=0B4uIyiNMjhuaT3d6cjNCY3h6MTg

8. Import the qc into the same window that your model is in.

If your model is not in the correct rotation to the skeleton, then change it's rotation to -90 degrees. If your model has multiple bodygroups, then you will have to do this to each one.

9. Delete helljumper_male_reference and helljumper_male_physics. That was the original model file. Your model file/files is/are the new one/ones.

-------RIGGING-------

1. Select helljumper_male.qc_skeleton, press a twice and then press ctrl+p. Select Armature Deform.

2. Select the skeleton. Go into pose mode. Press a. Drag the skeleton to see if the model is connected.

3. If some parts of the model did not move, then the model's rigging was broken or you deleted a bone earlier.

-------EXPORTING-------

1. Now go into properties, select the export path. Select ragdoll.smd. Set the subfolder to YOURMODELNAME_anims. Now click export.

2. Copy over helljumper_male_physics and helljumper_male.qc into your decompiled model's folder. That is it for exporting.
QC Scripting and LUA Scripting
-------QC-SCRIPTING-------

1. Open helljumper_male.qc with your favorite text editor.

2. Open your model's original qc file with your favorite text editor.

3. Delete everything in the helljumper_male.qc file.

4. Paste this into it:

// Created by Crowbar 0.42.0.0

$ModelName "PATH TO MODEL/YOUR MODEL_NPC OR _PM.mdl"

BODYGROUPS GO HERE

$SurfaceProp "metal"

$Contents "solid"

$EyePosition 0 0 70

$MaxEyeDeflection 90

$MostlyOpaque

$CDMATERIALS LINES GO HERE

$Attachment "chest" "ValveBiped.Bip01_Spine2" 5 4 0 rotate 0 90 90
$Attachment "forward" "ValveBiped.forward" 0 0 0 rotate 0 0 0
$Attachment "anim_attachment_head" "ValveBiped.Bip01_Head1" 0 0 0 rotate -90 -90 0

$CBox 0 0 0 0 0 0

$BBox -27.884 -10.349 -4.91 27.852 10.949 72.929


$BoneMerge "ValveBiped.Bip01_Pelvis"
$BoneMerge "ValveBiped.Bip01_Spine"
$BoneMerge "ValveBiped.Bip01_Spine1"
$BoneMerge "ValveBiped.Bip01_Spine2"
$BoneMerge "ValveBiped.Bip01_Spine4"
$BoneMerge "ValveBiped.Bip01_R_Clavicle"
$BoneMerge "ValveBiped.Bip01_R_UpperArm"
$BoneMerge "ValveBiped.Bip01_R_Forearm"
$BoneMerge "ValveBiped.Bip01_R_Hand"


$Sequence "ragdoll" {
"YOUR MODEL ANIMS FOLDER\ragdoll.smd"
activity "ACT_DIERAGDOLL" 1
fadein 0.2
fadeout 0.2
fps 30
}

$IncludeModel "m_anm.mdl"
$IncludeModel "m_shd.mdl"
$IncludeModel "m_pst.mdl"
$IncludeModel "m_gst.mdl"
$IncludeModel "cs_fix.mdl"
$IncludeModel "m_ss.mdl"
//Include those for a playermodel.
$IncludeModel "humans/male_shared.mdl"
$IncludeModel "humans/male_ss.mdl"
$IncludeModel "humans/male_gestures.mdl"
$IncludeModel "humans/male_postures.mdl"
//Include these for an npc. If you are making a ragdoll, you do not need any $IncludeModel lines.

$IKChain "rhand" "ValveBiped.Bip01_R_Hand" knee 0.707 0.707 0
$IKChain "lhand" "ValveBiped.Bip01_L_Hand" knee 0.707 0.707 0
$IKChain "rfoot" "ValveBiped.Bip01_R_Foot" knee 0.707 -0.707 0
$IKChain "lfoot" "ValveBiped.Bip01_L_Foot" knee 0.707 -0.707 0

$IKAutoPlayLock "rfoot" 1 0.1
$IKAutoPlayLock "lfoot" 1 0.1

$CollisionJoints "helljumper_male_physics.smd"
{
$mass 1
$inertia 10
$damping 0.05
$rotdamping 0.01
$rootbone "ValveBiped.Bip01_Pelvis"


$jointconstrain "ValveBiped.Bip01_L_Thigh" x limit -12 12 0
$jointconstrain "ValveBiped.Bip01_L_Thigh" y limit -73 6 0
$jointconstrain "ValveBiped.Bip01_L_Thigh" z limit -93 30 0

$jointconstrain "ValveBiped.Bip01_L_Calf" x limit 0 0 0
$jointconstrain "ValveBiped.Bip01_L_Calf" y limit 0 0 0
$jointconstrain "ValveBiped.Bip01_L_Calf" z limit -8 126 0

$jointconstrain "ValveBiped.Bip01_R_Thigh" x limit -12 12 0
$jointconstrain "ValveBiped.Bip01_R_Thigh" y limit -8 75 0
$jointconstrain "ValveBiped.Bip01_R_Thigh" z limit -97 32 0

$jointconstrain "ValveBiped.Bip01_R_Calf" x limit 0 0 0
$jointconstrain "ValveBiped.Bip01_R_Calf" y limit 0 0 0
$jointconstrain "ValveBiped.Bip01_R_Calf" z limit -12 126 0

$jointconstrain "ValveBiped.Bip01_R_Foot" x limit 0 0 0
$jointconstrain "ValveBiped.Bip01_R_Foot" y limit -25 6 0
$jointconstrain "ValveBiped.Bip01_R_Foot" z limit -15 35 0

$jointconstrain "ValveBiped.Bip01_Spine2" x limit -48 48 0
$jointconstrain "ValveBiped.Bip01_Spine2" y limit -25 25 0
$jointconstrain "ValveBiped.Bip01_Spine2" z limit -25 50 0

$jointconstrain "ValveBiped.Bip01_L_UpperArm" x limit -30 30 0
$jointconstrain "ValveBiped.Bip01_L_UpperArm" y limit -95 84 0
$jointconstrain "ValveBiped.Bip01_L_UpperArm" z limit -86 26 0

$jointconstrain "ValveBiped.Bip01_L_Forearm" x limit 0 0 0
$jointconstrain "ValveBiped.Bip01_L_Forearm" y limit 0 0 0
$jointconstrain "ValveBiped.Bip01_L_Forearm" z limit -149 4 0

$jointconstrain "ValveBiped.Bip01_R_UpperArm" x limit -39 39 0
$jointconstrain "ValveBiped.Bip01_R_UpperArm" y limit -79 95 0
$jointconstrain "ValveBiped.Bip01_R_UpperArm" z limit -93 23 0

$jointconstrain "ValveBiped.Bip01_R_Forearm" x limit 0 0 0
$jointconstrain "ValveBiped.Bip01_R_Forearm" y limit 0 0 0
$jointconstrain "ValveBiped.Bip01_R_Forearm" z limit -149 4 0

$jointconstrain "ValveBiped.Bip01_R_Hand" x limit -60 60 0
$jointconstrain "ValveBiped.Bip01_R_Hand" y limit 0 0 0
$jointconstrain "ValveBiped.Bip01_R_Hand" z limit -57 70 0

$jointconstrain "ValveBiped.Bip01_Head1" x limit -20 20 0
$jointconstrain "ValveBiped.Bip01_Head1" y limit -25 25 0
$jointconstrain "ValveBiped.Bip01_Head1" z limit -13 30 0

$jointconstrain "ValveBiped.Bip01_L_Hand" x limit -37 37 0
$jointconstrain "ValveBiped.Bip01_L_Hand" y limit 0 0 0
$jointconstrain "ValveBiped.Bip01_L_Hand" z limit -57 59 0

$jointconstrain "ValveBiped.Bip01_L_Foot" x limit 0 0 0
$jointconstrain "ValveBiped.Bip01_L_Foot" y limit -19 19 0
$jointconstrain "ValveBiped.Bip01_L_Foot" z limit -15 35 0
}

$CollisionText
{
animatedfriction
{
"animfrictionmin" "1.000000"
"animfrictionmax" "400.000000"
"animfrictiontimein" "0.500000"
"animfrictiontimeout" "0.300000"
"animfrictiontimehold" "0.000000"
}
editparams
{
"rootname" "valvebiped.bip01_pelvis"
"totalmass" "90.000000"
"jointmerge" "valvebiped.bip01_pelvis,valvebiped.bip01"
"jointmerge" "valvebiped.bip01_pelvis,valvebiped.bip01_spine1"
}}

replace anything in in caps with its counterpart in the original model qc file.

5. Now open crowbar. Go into compile. Browse to the helljumper_male.qc file that you copied over and edited. To prevent shading glitches or model glitches, set the game that has model compiler to Source Filmmaker. Now hit compile.

6. Causes of error: Not reading what I wrote right above step 5.
Having too many materials.
Having erased part of the qc that was not capitalized.

-------LUA-SCRIPTING-------

1. Create a new folder in the base directory with the materials and models folders. Call it lua.

2 Make a new folder inside of that one. Call it autorun

3. Create a .lua file for the npc there. Open it. Paste this in it:

local Category = "THE NPC FOLDER THAT YOU WANT IT TO BE IN"

local NPC = { Name = "NAME THAT YOU WANT YOUR NPC TO HAVE",
Class = "npc_citizen",
Model = "PATH TO MODEL/MODEL_NPC.mdl",
Health = "200",
KeyValues = { citizentype = 4 },
Category = Category }
Squadname = "U CAN DELETE THIS LINE IF YOU DONT WANT IT TO BE IN A SQUAD"
Weapons = { "U CAN DELETE THIS LINE TOO" },


list.Set( "NPC", "npc_ENTITY NAME(MUST HAVE NO SPACES, ONLY UNDERSCORES)", NPC )

replace anything in in caps with what you want it to be.

4. Create another .lua file for the pm there. Open it. Paste This in it:

player_manager.AddValidModel( "PLAYER MODEL NAME", "PATH TO MODEL/MODEL_PM.mdl" )
player_manager.AddValidHands( "PLAYER MODEL NAME", "PATH TO VIEW ARMS/VIEW ARMS.mdl", 0, "00000000" )

replace anything in in caps with what you want it to be.
you can delete the second line if you do not have view arms for your model.
Uploading to the workshop
-------UPLOADING-------

1. Open a command prompt type into it:
cd C:\Program Files (x86)\Steam\steamapps\common\GarrysMod\bin.

2. type into it now:
gmad create -folder "PATH TO FOLDER WITH LUA, MATERIALS, AND MODELS FOLDER" -out "WHERE YOU WANT IT TO PUT THE GMA FILE\YOUR FILE.gma
. This will not work if your model has any files with uppercase letters in it.

3. now type into the command prompt: gmpublish create -icon "PATH TO ICON\ICON.jpg" -addon "PATH TO GMA\GMA.gma

4. It has successfully been uploaded into your steam account!

5. Be sure to credit me for the skeleton! ;)

6. Have a good time messing around with dat ragdoll!