Tally
9th May 2013, 14:58
The following is a tutorial I posted for COD4 mod Openwarfare. But the principles in it apply to COD2 also.
----------------------------------------------------------------------------------------------------
This is a tutorial about creating custom third person animations. In particular, about creating xanim files which define where the character model hands are placed on a custom weapon. For the purposes of this tutorial I will be talking about a specific problem - the problem of the hand placings on the BO1 minigun.
Without custom animation files, this is what the problem looks like in a demo video:
http://imageshack.us/a/img854/6433/brokenr.png (http://www.xfire.com/videos/5f9eff)
You will see that the character model is not holding the minigun correctly. The right hand is almost there, but the left hand is left up in the air as if it were holding a standard COD4 rifle. We need it to hold the briefcase-type handle on the minigun.
I got Tito to port all the minigun xanims over from BO1 to COD4 for me, and introducing custom scripting by myself into the MP .SCRIPT files, this is what the FIXED version looks like:
http://img694.imageshack.us/img694/9917/fixedd.png (http://www.xfire.com/videos/5f9f03)
Here are all the files I used to fix the hand postions.
DOWNLOAD (http://filemob.com/2891650f001677a4)
For the purposes of the mod I am working on, I only needed crouch animations. But I have included all the xanim files for every animation state, and here is a basic explanation of how it works, and how to do your own:
How It Works:
1. For all first person animations, the xanims are listed in the weapon file. If you want a custom weapon to hold a custom weapon properly, we all know that you create a viewsleeves rig and do it like that. But for all world animations - that is the third person animations - these are referenced in the playeranim.script file. The 2 have nothing to do with each other. You cannot define a first person animation with a .SCRIPT file, and you cannot define a world animation with a first person xanim listed in the weapon file. If you want the world model to hold a weapon correctly, you have to do that with a .SCRIPT file. So, if your custom world model has an unusual way of holding a weapon - as in the case of the BO1 minigun - this is why it becomes necessary to introduce .SCRIPT files into your mod.
COD multiplayer only uses 2 files for world animations - multiplayer.atr and playeranim.script. No other file can be used. This is different than in SP, where you can state what animation file you want to use with the using_animtree( <filename> ) function. Needless to say, this does not work in MP.
2. Whereas the central file used in MP is the playeranims.script file, all the xanims listed in there are actually references to the xanims in multiplayer.atr. So, if you don't included an edited copy of multiplayer.atr it will throw an error telling you that you have a file listed which isn't recognised. So, obviously, you include it as a rawfile in your mod.CSV file.
3. Animation files are listed very simply in an .ATR file:
main
{
//
// Torso Animations
//
torso
{
// all files are prefixed with pt_ - which presumably stands for "player torso"
}
//
// Legs Animations (also full body anims)
//
legs
{
// all files are prefixed with pb_ - which presumably stands for "player body"
}
}
That's it! You don't really have much to think about with an .ATR file. As long as you put all files prefixed with pt_ under the torso grouping, and all files prefixed with pb_ under the legs grouping, they can go in any order.
4. The real nitty gritty of MP third world animations are done in playeranim.script. But even here, things are more-or-less explained in the developer notes in the margins. So, once you digest it, it is actually very straight forward. I wont say too much about here because it would require quite a lengthy tutorial and you really need to read the file to see what is going on. What I will say here is what I did specifically for the minigun:
1. STATES
I defined 3 states. As my minigun player is crouched all the time, I only needed to do ones which were crouched:
ANIMATIONS
STATE COMBAT
{
idle
{
playerAnimType minigun
{
both pb_minigun_crouch_idle
}
}
idlecr
{
playerAnimType minigun
{
both pb_minigun_crouch_idle
}
}
idleprone
{
playerAnimType minigun
{
both pb_minigun_crouch_idle
}
}
}
Obviously, if you were going to do a full set you would need to dig into the other STATE type animations and add the relevant xanim file to that STATE.
2. EVENTS
As my minigun player is crouched all the time, I only needed to do 1 EVENT:
EVENTS
fireweapon
{
playerAnimType minigun
{
torso pt_minigun_crouch_fire
}
}
5. The player plays the animation listed in the weapon file under playerAnimType. If you have a full compliment of animations, you can get the world character to do anything you like, just by defining all such animations in the .SCRIPT file. Or, you can define small groups of animations, and simply change the playerAnimType description in the weapon file, and simply change the player's weapon. This is how it is done in PEZBOT - 5 weapons have 5 different animation types, and all 5 groups are defined in the .SCRIPT file.
6. One final file you have to add is mp/playeranimtypes.txt. This lists all the MP animation types. If you don't add this file, the game will throw an error on load saying that an unknown anim type is listed in your weapon file. So, simply add your custom anim type and add the edited file to your mod.CSV file.
7. To add all the files to your mod, you add them to mod.CSV like this:
rawfile,mp/playeranim.script
rawfile,animtrees/multiplayer.atr
rawfile,mp/playeranimtypes.txt
xanim,pt_minigun_crouch_fire
xanim,pb_minigun_crouch_idle
That's it. Not overly complicated once you break it down into small digestible pieces.
CREDITS:
Tito - for all the BO1 minigun xanim files.
Tally - scripting and tutorial
----------------------------------------------------------------------------------------------------
This is a tutorial about creating custom third person animations. In particular, about creating xanim files which define where the character model hands are placed on a custom weapon. For the purposes of this tutorial I will be talking about a specific problem - the problem of the hand placings on the BO1 minigun.
Without custom animation files, this is what the problem looks like in a demo video:
http://imageshack.us/a/img854/6433/brokenr.png (http://www.xfire.com/videos/5f9eff)
You will see that the character model is not holding the minigun correctly. The right hand is almost there, but the left hand is left up in the air as if it were holding a standard COD4 rifle. We need it to hold the briefcase-type handle on the minigun.
I got Tito to port all the minigun xanims over from BO1 to COD4 for me, and introducing custom scripting by myself into the MP .SCRIPT files, this is what the FIXED version looks like:
http://img694.imageshack.us/img694/9917/fixedd.png (http://www.xfire.com/videos/5f9f03)
Here are all the files I used to fix the hand postions.
DOWNLOAD (http://filemob.com/2891650f001677a4)
For the purposes of the mod I am working on, I only needed crouch animations. But I have included all the xanim files for every animation state, and here is a basic explanation of how it works, and how to do your own:
How It Works:
1. For all first person animations, the xanims are listed in the weapon file. If you want a custom weapon to hold a custom weapon properly, we all know that you create a viewsleeves rig and do it like that. But for all world animations - that is the third person animations - these are referenced in the playeranim.script file. The 2 have nothing to do with each other. You cannot define a first person animation with a .SCRIPT file, and you cannot define a world animation with a first person xanim listed in the weapon file. If you want the world model to hold a weapon correctly, you have to do that with a .SCRIPT file. So, if your custom world model has an unusual way of holding a weapon - as in the case of the BO1 minigun - this is why it becomes necessary to introduce .SCRIPT files into your mod.
COD multiplayer only uses 2 files for world animations - multiplayer.atr and playeranim.script. No other file can be used. This is different than in SP, where you can state what animation file you want to use with the using_animtree( <filename> ) function. Needless to say, this does not work in MP.
2. Whereas the central file used in MP is the playeranims.script file, all the xanims listed in there are actually references to the xanims in multiplayer.atr. So, if you don't included an edited copy of multiplayer.atr it will throw an error telling you that you have a file listed which isn't recognised. So, obviously, you include it as a rawfile in your mod.CSV file.
3. Animation files are listed very simply in an .ATR file:
main
{
//
// Torso Animations
//
torso
{
// all files are prefixed with pt_ - which presumably stands for "player torso"
}
//
// Legs Animations (also full body anims)
//
legs
{
// all files are prefixed with pb_ - which presumably stands for "player body"
}
}
That's it! You don't really have much to think about with an .ATR file. As long as you put all files prefixed with pt_ under the torso grouping, and all files prefixed with pb_ under the legs grouping, they can go in any order.
4. The real nitty gritty of MP third world animations are done in playeranim.script. But even here, things are more-or-less explained in the developer notes in the margins. So, once you digest it, it is actually very straight forward. I wont say too much about here because it would require quite a lengthy tutorial and you really need to read the file to see what is going on. What I will say here is what I did specifically for the minigun:
1. STATES
I defined 3 states. As my minigun player is crouched all the time, I only needed to do ones which were crouched:
ANIMATIONS
STATE COMBAT
{
idle
{
playerAnimType minigun
{
both pb_minigun_crouch_idle
}
}
idlecr
{
playerAnimType minigun
{
both pb_minigun_crouch_idle
}
}
idleprone
{
playerAnimType minigun
{
both pb_minigun_crouch_idle
}
}
}
Obviously, if you were going to do a full set you would need to dig into the other STATE type animations and add the relevant xanim file to that STATE.
2. EVENTS
As my minigun player is crouched all the time, I only needed to do 1 EVENT:
EVENTS
fireweapon
{
playerAnimType minigun
{
torso pt_minigun_crouch_fire
}
}
5. The player plays the animation listed in the weapon file under playerAnimType. If you have a full compliment of animations, you can get the world character to do anything you like, just by defining all such animations in the .SCRIPT file. Or, you can define small groups of animations, and simply change the playerAnimType description in the weapon file, and simply change the player's weapon. This is how it is done in PEZBOT - 5 weapons have 5 different animation types, and all 5 groups are defined in the .SCRIPT file.
6. One final file you have to add is mp/playeranimtypes.txt. This lists all the MP animation types. If you don't add this file, the game will throw an error on load saying that an unknown anim type is listed in your weapon file. So, simply add your custom anim type and add the edited file to your mod.CSV file.
7. To add all the files to your mod, you add them to mod.CSV like this:
rawfile,mp/playeranim.script
rawfile,animtrees/multiplayer.atr
rawfile,mp/playeranimtypes.txt
xanim,pt_minigun_crouch_fire
xanim,pb_minigun_crouch_idle
That's it. Not overly complicated once you break it down into small digestible pieces.
CREDITS:
Tito - for all the BO1 minigun xanim files.
Tally - scripting and tutorial