Jul 1, 2013

GoldSource(GoldSrc) model porting. *Not important*.

NOTE:Some people will think: "This is useless information for me". 
I am not forcing you to read this. If you want it-go ahead and read at your own risk.

NOTE2: Dont post converted weapons anywhere in Internet, because of author rights(a.k.a. permissions). If you want to convert and then share weapon models, ask the creator of model first.

NOTE3: Keep in mind, some stuff might be complicated for you. In that case, you can either keep trying to understand or you can stop doing this and move on. I am not going to write down everything in order to make it easier for you. Either because I am lazy, either I am busy with Contagion stuff.

Now lets get a move on.

Once upon time, I wanted to convert some models from CS1.6 to Sven Coop(For example.)
I was looking for tutorial about that, but didnt found any of them(In my years. Maybe theres better tutorial about GoldSrc porting.).

So yeah. Today I want to share, how-to convert model from CS1.6 to Sven Coop.(Example again.)

I guess we can get started now...

Before starting. Make sure you got:

HLMV(Half-Life Model Viewer. Personally, I use Jed's one.)
De-compiler. (Also can be used with HLMV).
Compiler.
gFlip(In case, if you are righthanded or lefthanded weapon user.)
Notepad.exe
Some mathematics knowledge.
Beer.(Just in case.)

Lets get started then.

After downloading all files that you need,(GFlip may not required for use) we are going to un-archive those files in whatever folder you like.(I recommend to create an new folder, and put all files there.).

HLMV
A main program that allows you to view any GoldSrc models.(Well, most of them, correctly.)

You can view models as much as you want, but we are here to know how-to convert weapon model? Right.

Before starting, please note: HLMV may have some issues with Windows 7 system. HLMV was writed for Windows XP, but we know already, that most of people got Windows 7. If you are having slow work on your PC, please open your TaskMannger, then choose process list, and search for "hlmv.exe" If you see any>close them.

So yeah, lets open HLMV.
Ill open "Apache.mdl" for example.
We see many tabs and some options in this window. Before doing something with model, make sure you configured your tools.(A.K.A. Decompiler and compiler.)

To check them: Press "Tools" then choose "Configure tools".

Then a window will appear, asking you for path to "studiomdl.exe"(Compiler) and "mdldec.exe"(Decompiler).

Set the way for those programs, then press "O.K." button and lets get to work.

So yeah, we got everything set up and now we can start working on converting of weapon.
Today, I will use "v_deagle.mdl" from cs1.6 and gonna convert it to Sven Coop.

So yeah, first: We need to decompile model.

To do this one:
Press "Tools" then "decompile model".

Then, select the model, that you want decompile(v_deagle.mdl for example) and press "Open".

After it, an command console will appear(Its fine, dont panic) and wait when the decompiler will finish. (Note: All model files(.qc\smd\bmp images) will be saved in folder where model was.)

After it, find v_deagle.qc file and open it with notepad.exe.


After it, you will see an text, that contains some information about model.
Information like:
Model name\scales\etc.
Positions.
Reference meshes.
Hit boxes.
Attachments.
Sequences.

Most of times, when you are trying to convert model, you are only need to care about "sequences", since we are just converting weapon model.

Now decompile "v_357.mdl" from Sven Coop and open "v_357.qc" file.(Dont close "v_deagle.qc" file)

These are the animation lists, as well as descriptions for what the animations are.

Animation list for the deagle (6 animations)

idle - an idle animation
shoot1 - a shooting animation
shoot2 - a shooting animation
shoot_empty - Shooting animation that plays upon shooting the last bullet
reload - Reload animation
draw - Draw animation

Animation list for Sven's .357 (8 animations)

idle1 - an idle animation
fidget1 - a "fidget" animation - one where the player just messes around with the gun in his hand
fire1 - a shooting animation
reload - a reload animation
holster - holster animation
draw - draw animation
idle2 - an idle animation
idle3 - an idle animation
Take a note of the animations:


Deagle
idle - an idle animation

357
idle1 - an idle animation

Do they match up? Yes. The deagle's idle animation would play when the 357 is playing an idle animation.

Moving down the list, the next animations are:

Deagle
shoot1 - a shooting animation

357
fidget1 - animation where the player is messing around with the gun. plays randomly when the 357 is equipped


Do these match up? Nope. This would cause problems because when the fidget1 animation plays, the deagle will play the shooting animation.
Question appears:
How would one go about fixing this?

To remedy the fact that the desert eagle does not have a fidget animation, simply copy the idle animation. This does not cause any issues at all, because when the fidget animation would play, the gun would simply not move at all since it would be playing the idle animation.



Next on the list is the 357's shoot animation. Does the desert eagle list currently have animations that would match that description?

Deagle animation list
$sequence "idle" "idle" fps 16
$sequence "idle" "idle" fps 16
$sequence "shoot1" "shoot1" fps 38 { event 5001 0 "21" }
$sequence "shoot2" "shoot2" fps 38 { event 5001 0 "21" }
$sequence "shoot_empty" "shoot_empty" fps 38 { event 5001 0 "21" }
$sequence "reload" "reload" fps 30 { event 5004 11 "weapons/de_clipout.wav" } { event 5004 47 "weapons/de_clipin.wav" }
$sequence "draw" "draw" fps 30 { event 5004 10 "weapons/de_cock.wav" }


The answer is yes: shoot1, shoot2, and shoot_empty. If that's the case, why not just keep them all there?
To answer that question, just take another look at the animation lists.

Desert eagle's animation list
$sequence "idle" "idle" fps 16
$sequence "idle" "idle" fps 16
$sequence "shoot1" "shoot1" fps 38 { event 5001 0 "21" }
$sequence "shoot2" "shoot2" fps 38 { event 5001 0 "21" }
$sequence "shoot_empty" "shoot_empty" fps 38 { event 5001 0 "21" }
$sequence "reload" "reload" fps 30 { event 5004 11 "weapons/de_clipout.wav" } { event 5004 47 "weapons/de_clipin.wav" }
$sequence "draw" "draw" fps 30 { event 5004 10 "weapons/de_cock.wav" }

357's animation list
$sequence "idle1" "idle1" fps 30
$sequence "fidget1" "fidget1" fps 30 { event 5004 61 "weapons/357_idle_fidgetpull.wav" } { event 5004 122 "weapons/357_idle_fidgetrelease.wav" }
$sequence "fire1" "fire1" fps 30 { event 5001 0 "15" }
$sequence "reload" "reload" fps 40 {
{ event 5004 6 "weapons/357_chamberout.wav" }
{ event 5004 20 "weapons/357_shellsout.wav" }
{ event 5004 54 "weapons/357_shellsin.wav" }
{ event 5004 61 "weapons/357_quickloader.wav" }
{ event 5004 77 "weapons/357_chamberin.wav" }
}
$sequence "holster" "holster" fps 30
$sequence "draw" "draw" fps 30
$sequence "idle2" "idle2" fps 30
$sequence "idle3" "idle3" fps 30 { event 5004 8 "weapons/357_idle_squeeze.wav" } { event 5004 46 "weapons/357_idle_unsqueeze.wav" }

The only firing animation that the .357 has is the third one on the list: fire1. The desert eagle has three different animations. Shoot1 is third in the last, as is fire1, so that is okay, but what is fourth on the list?



On the .357, that would be reload, and on the deagle it is shoot2. What does this mean? It would mean that when you are reloading, a shooting animation would play. Again, the fifth on each list is follows: holster for the .357 and shoot_empty for the deagle. This means that whenever the holster animation plays for the .357, a shooting animation happens for the desert eagle. That's not what you would want, is it? So how do you fix that?

You delete the excess shoot animations in the list. It even helped clean up the list, because take a look.

Deagle's list

$sequence "idle" "idle" fps 16
$sequence "idle" "idle" fps 16
$sequence "shoot1" "shoot1" fps 38 { event 5001 0 "21" }
$sequence "reload" "reload" fps 30 { event 5004 11 "weapons/de_clipout.wav" } { event 5004 47 "weapons/de_clipin.wav" }
$sequence "draw" "draw" fps 30 { event 5004 10 "weapons/de_cock.wav" }


.357's list

$sequence "idle1" "idle1" fps 30
$sequence "fidget1" "fidget1" fps 30 { event 5004 61 "weapons/357_idle_fidgetpull.wav" } { event 5004 122 "weapons/357_idle_fidgetrelease.wav" }
$sequence "fire1" "fire1" fps 30 { event 5001 0 "15" }
$sequence "reload" "reload" fps 40 {
{ event 5004 6 "weapons/357_chamberout.wav" }
{ event 5004 20 "weapons/357_shellsout.wav" }
{ event 5004 54 "weapons/357_shellsin.wav" }
{ event 5004 61 "weapons/357_quickloader.wav" }
{ event 5004 77 "weapons/357_chamberin.wav" }
}
$sequence "holster" "holster" fps 30
$sequence "draw" "draw" fps 30
$sequence "idle2" "idle2" fps 30
$sequence "idle3" "idle3" fps 30 { event 5004 8 "weapons/357_idle_squeeze.wav" } { event 5004 46 "weapons/357_idle_unsqueeze.wav" }

The shoot1 animation is in the same spot as fire1, AND both reloads are in the same spot! So you don't need to reposition the reload animation in the list at all.



!IMPORTANT!: When converting models, BE ABSOLUTELY SURE YOU DECOMPILE THE ORIGINAL MODEL FIRST. This is critical because if you do not, it will cause errors when both models have animations with the same name. For example, in this, the reload animation for the .357 WILL NOT work with the desert eagle.

The final stretch, the conversion is almost done. You are now working with four animations for the 357

holster
draw
idle2
idle3

Looking at the desert eagle's animation list, does any match up with these?

$sequence "idle" "idle" fps 16
$sequence "idle" "idle" fps 16
$sequence "shoot1" "shoot1" fps 38 { event 5001 0 "21" }
$sequence "reload" "reload" fps 30 { event 5004 11 "weapons/de_clipout.wav" } { event 5004 47 "weapons/de_clipin.wav" }
$sequence "draw" "draw" fps 30 { event 5004 10 "weapons/de_cock.wav" }


Yes and no: You have an idle and a draw animation, but no holster animation, which comes before the draw animation in the list. How do you account for this?
Simple fix: Just copy and paste the $sequence "idle" line three times: Once before draw and twice after draw. Why would I use the idle animation for holster? Because it's generally never used, so no problems, correct?


Now you are done. This is how your final lists will look like.

Deagle animation list

$sequence "idle" "idle" fps 16
$sequence "idle" "idle" fps 16
$sequence "shoot1" "shoot1" fps 38 { event 5001 0 "21" }
$sequence "reload" "reload" fps 30 { event 5004 11 "weapons/de_clipout.wav" } { event 5004 47 "weapons/de_clipin.wav" }
$sequence "idle" "idle" fps 16
$sequence "draw" "draw" fps 30 { event 5004 10 "weapons/de_cock.wav" }
$sequence "idle" "idle" fps 16
$sequence "idle" "idle" fps 16


.357 animation list

$sequence "idle1" "idle1" fps 30
$sequence "fidget1" "fidget1" fps 30 { event 5004 61 "weapons/357_idle_fidgetpull.wav" } { event 5004 122 "weapons/357_idle_fidgetrelease.wav" }
$sequence "fire1" "fire1" fps 30 { event 5001 0 "15" }
$sequence "reload" "reload" fps 40 {
{ event 5004 6 "weapons/357_chamberout.wav" }
{ event 5004 20 "weapons/357_shellsout.wav" }
{ event 5004 54 "weapons/357_shellsin.wav" }
{ event 5004 61 "weapons/357_quickloader.wav" }
{ event 5004 77 "weapons/357_chamberin.wav" }
}
$sequence "holster" "holster" fps 30
$sequence "draw" "draw" fps 30
$sequence "idle2" "idle2" fps 30
$sequence "idle3" "idle3" fps 30 { event 5004 8 "weapons/357_idle_squeeze.wav" } { event 5004 46 "weapons/357_idle_unsqueeze.wav" }

List analysis

First spot
Deagle: idle 357: idle1
Matching animations? Yes, they are both idle animations

Second spot
Deagle: idle 357: fidget1
Matching animations? No, but the idle animation can work as a fidget animation.

Third spot
Deagle: shoot1 357: fire1
Matching animations? Yes, they are both shooting animations

Fourth spot
Deagle: reload 357: reload
Matching animations? Yes, they are both reload animations. *REMEMBER THE NOTE ABOUT DECOMPILING MODELS WITH THE SAME ANIMATION NAMES!!!!!*

Fifth spot
Deagle: idle 357: holster
Matching animations? No, but the idle animation can work as a holster animation

Sixth spot
Deagle: draw 357: draw
Matching animations? Yes, they are both draw animations. *REMEMBER THE NOTE ABOUT DECOMPILING MODELS WITH THE SAME ANIMATION NAMES!!!!!*

Seventh Spot
Deagle: idle 357: idle2
Matching animations? Yes, they are both idle animations
Eighth Spot

Eighth Spot
Deagle: idle 357: idle3
Matching animations? Yes, they are both idle animations

Now that the animation lists are similar, you are now free to save v_deagle.qc and re-compile it.


Extra tips:

Animation speeds may not match up. This can be remedied by working with the .qc file and Half Life Model Viewer simultaneously. How? That will be covered in another tutorial.

ALL counterstrike models are always left-handed, which means they are on the left side on the screen. To fix this, simply use the tool gflip. Drag and drop the converted model onto the gflip menu and the program will fix the model so it will be right-handed, or show up on the right side of the screen.

Models with transparencies, such as scopes and helmets that have glass parts, WILL mess up. There is a simple fix for this, and that would be opening up the converted model in HLMV. Then go to the Textures tab and check the Additive and Transparent boxes, go to File, and then Save Model As.

Player models are their own different story than weapon models. They are VASTLY different because Goldsource games/mods tend use different skeletons for their player models. Fixing this would need the use of Milkshape, which is something that I am not skilled at yet.



Credits: Much obliged to Horrawr who taught me this.

I hope this will help you in next time and see you later.
-Orphanage

No comments:

Post a Comment