1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[Tutorial] Modifying the Visibilty of Weapons

Discussion in 'Civ4 - Modding Tutorials & Reference' started by Gagonite, Mar 3, 2009.

  1. Gagonite

    Gagonite Irishman

    Joined:
    Nov 6, 2005
    Messages:
    208
    Hey everyone, as per requested, here’s the tutorial on not only getting units to use other units’ animations in addition to their own, but also to have various weapons and accessories visible in some animations, while invisible in others.

    An example of this that’s already in the game is the Longbowman. During most of his animations, his melee weapon – a staff – is invisible to the player, while his ranged weapon – the longbow – is visible. However, during his various Melee animations (StrikeA, HurtA, DieA, etc), the longbow disappears while his staff comes into view. Now, it’s a relatively simple process to recreate this for other units. Simple, but repetitive, since you essentially need to modify the same things for every animation that the weapons/accessories need to be seen or not seen in.

    First off however, there are a few things you need to get started.

    - The file(s) with the textures, animations, and .nif files that you want to use.
    - Nifskope (Nifviewer probably works too, however this Tutorial is using Nifskope)
    - KonverterFM
    - PakBuild
    - Patience and the will to succeed!


    Alright, there we have it. Not a long list, as the process isn’t hard or complex.

    For the tutorial, I will be making the Modern Worker unit have a Redcoat-style combat animation using the Marine’s weapon, in addition to his usual worker animations.

    First, unpack the various .pak files in the Vanilla folder, usually to a folder on your desktop for this purpose.

    Then, locate the Redcoat and Modernworker files, and copy them to your desktop. After that, create a new folder named for whatever your new unit is going to be, in this case I will name my folder “Combat Engineer”. Put both the Redcoat and Modernworker files in the folder. This allows easy access to the files you need without having to dig around in the unpacked files.

    The next step is to merge the .kfm files of the Worker and Redcoat .kfm. Note: I won’t be listing the exact steps of merging the .kfm files, there is another tutorial on that, so I’ll list what’s only needed for this tutorial. Of course, you don’t want every animation for both, there is a select few you’ll need. Here are the ones you’ll want to copy from the Redcoat file:

    - HurtA
    - RangedFortify
    - RangedIdle
    - RangedStrike
    - RangedDieA
    - RangedDieB

    The two RangedDieX_Fade animations are optional and are there if you want your unit to fade away after he dies. I usually don’t put those in, but it’s a choice of preference.

    Copy those six animations and paste them into your .kfm file that’ll be the new one. I usually copy the Worker .kfm file, rename it CombatEngineer, and use that one. Also, I’d recommend deleting the ‘Surrender’ animation in that file. One last thing to do in the new .kfm file is at the top, change the associated nif file to whatever you will be naming your new nif file, in this case CombatEngineer.nif.

    Now that your new .kfm file is complete, we need to get all the associated .kf files into the folder with the .kfm file. We will also need the .dds files. Just copy every file from the Worker file (With the exception of the .kfm file, unless you used it for the new animations) and paste them into the folder where your CombatEngineer stuff will go. Also, rename the .nif of the Worker to your new unit, in this case CombatEngineer. Now, copy the .kf files that are for each of the Redcoat animations, as well as the .dds file and paste them into your Combat Engineer folder.

    Here’s where the fun begins. Open up your new CombatEngineer .nif file and left click once on the Engineer’s body. Then look at the left and look for a BIP or Bip01 tree.



    In this case, the worker’s skeleton is named BIP. All associated body parts will begin with that name. Now, we need to see what skeleton the Redcoat animations use, so open up any of the Redcoat .kf files. In this case I’ll be opening up the RangedStrike one. Once you do that, click on NiControllerSequence, then go down to the bottom and expand the Controlled Blocks tree.



    Once expanded, you’ll see a bunch of BIP body parts. Good, this means we don’t have to change all of the body parts’ names. Sometimes, you’ll encounter that animation files using Bip01 skeletons, which means, if your .nif file has a BIP skeleton, you’ll need to rename every Bip01 in the .kf to BIP. More on how to rename them later.

    Luckily, since these are already named correctly, the animation files of the Redcoat should work well with the Worker’s skeleton. To make sure it does, go to your CombatEngineer.nif file and up at the top click on Spells -> Animation -> Attach .KF. Or you can go there by right clicking anywhere and doing the same thing.



    Once there, choose one of the Redcoat animations. I chose RangedStrike. Load that one. You should see a small window open up that says the following:



    That’s not a problem unless theres a skeleton piece (such as Bip01 Head) or something of that sort in it. Also, look at your Worker in the NifSkope. He’s probably in some sort of pose that you’ll recognize as one of the Redcoat’s.



    As you can see by my worker, he’s looking like he’s holding up a rifle, albeit there’s no rifle. No worries, at least we know the animation works properly. Reload the .nif file, it can get a bit messy if you save the .nif with the .kf in it. It’s not fatal to what yer doing, but it’s just best to keep things clean.

    Alright, now here’s the part most of you’ve been waiting for. The weapons. We’ll only be using one weapon in this tutorial (The Marine’s rifle), but it works the same for as many weapons as you want. First off, we need to retrieve the rifle from the Marines.nif. Find the unpacked file and open the .nif. Once there, click on his rifle.



    As you can see, the Clip of the Rifle isn’t actually part of the rifle. No worries. Instead of copying just the rifle, we need to copy the entire NiNode that contains the Rifle, it’s shooting effect, and the clip. Go to the NiNode and right click, then go to Block and Copy Branch. Make sure you copy the branch, not just the NiNode, else you’ll miss most of the stuff.



    Once that’s completed, go to your CombatEngineer.nif and go Copy Branch it somewhere under the current trees. It’ll look like this once complete:



    As you can see, the rifle is there, but it’s untextured. It’s because we don’t have the proper .dds file in the Combat Engineer folder. It’s a simple fix. First save and close your CombatEngineer.nif. Then copy-paste the two .dds files in the Marine folder to your Combat Engineer folder. Reopen the CombatEngineer.nif. Vuala, it’s textured.



    Alright, now we need to attach it to the Worker’s right hand and position it correctly. You’ll also probably notice that I forgot to re-open my .nif file, and accidently saved the redcoat’s RangedStrike.kf with it. It’s not a huge deal, it won’t hurt anything, just kind of annoying.

    So, in order to attach the gun to his hand, we need to find his Right hand’s bone.



    As you can see, its deep in the forest of sub-trees. Once found, click on it (No real need to open it’s tree) and down at the bottom you’ll notice it allows 6 children, all of which are filled with various tools.



    Double click on where the 6 is, and raise it to 7. Then, click on the little green refresh button, now he has 7 slots available, one of which is open for his new rifle. Double click on where it says “None” and type in the number of the NiNode that corresponds to the AK-47. In this case, the number is 154.



    You’ll notice the rifle moves into some weird off place. Find the section of the Rifle where it allows you to change it’s rotation and position and fiddle around with it until it looks good on his hand. Note: Make sure you adjust the rotation/position of the entire Node, not just the rifle, else the clip and gun-blast will be separate. After trying it out, here are the coordinates I found useful.

    Rotation (In Euler) Y: -45 P: 0 R: 35
    Translation: X: 10 Y: 5 Z: 0

    You may change it as you prefer of course, this is just what I got. Here’s what it looks like: (Remember mine’s saved with the .kf file by mistake)



    It’s a bit hard to see in the jumble of tools, but it’s there. Now that the gun is there, as it is, it’ll be there 100% of the time during all of the Worker’s animations in-game. We can’t have that now can we? In actuality we’ll need to modify nearly every animation to state when it needs to be visible and invisible. However, in this tutorial, I’ll only be demonstrating changing one of the .kf files. It’s the same thing for all of the others.

    Before you go on, save the CombatEngineer.nif.

    Alright, first we need an NiVisController in the NiNode containing the AK-47. Luckily for us, there are plenty attached to the various tools. Open up one of the tools’ NiNodes, and you’ll see three more tabs. One of which is a flag, followed by the words NiVisController. That’s what we want. Right click on it and COPY. Don’t bother with Copy Branch for this one.



    Once that’s done, paste it somewhere below the rest of the trees, then click on it. Find where it says “Target”, and enter the number of the AK-47’s NiNode, which is 114. Seems as if it changed from when we first copied it over. No worries, but make sure you check that in future cases.

    Next, Click on the AK-47’s NiNode and locate where it says “Controller”. Type in the number of the copied NiVisController, in this case it’s 169. Ok, now the NiVisController is attached to the weapon and it’s parts. Save the .nif.

    Now, go to your Combat Engineer foldier and locate the Modernworker_MD_Idle.kf file. Open it. The place where the worker normally is, is blank. That’s supposed to be like that, though I don’t know why. Click on the tree that is named NiControllerSequence. Also expand it, but don’t un-click it. At the bottom, you’ll notice there are two tabs named “Num Controlled Blocks” and “Controlled Blocks”. These are much like the Children of the .nif. Raise the number of Num Controlled Blocks by 1, to 38, then click the refresh button.



    Once done, expand the &#8220;Controlled Blocks&#8221; tree and go down to the bottom of it where there is an <empty> spot. This is where our rifle goes. Expand the <empty> tree. There are a measily 4 things we need to modify here and then we&#8217;re done with this .kf file.

    First off, go back up to the top where you first expanded the NiControllerSequence tree. If you haven&#8217;t already, expand that tree, then look for one of the many NiBoolInterpolator tabs. Each of these control the visibility of an item. They all have values, either No or Yes. Yes means this object is visible during this animation, No means it isn&#8217;t. Copy one of the ones that has a No value, and paste it below the tree. Keep a tab on it&#8217;s name. Also, you can change the value if you wish by merely double clicking on the Yes or No and it will change to the other one.

    In my case, the new NiBoolInterpolator&#8217;s number is 55. Now, go back to the <Empty> slot where we were before. First click on Interpolator and change the Value to the number of the associated NiBoolInterpolator, in this case 55. Then go to the String Palette and change it to 3. You&#8217;ll find the number for the String Palette in the main branch of the NiControllerSequence tree. Then, go down to Node Name Offset and click on the little TXT button. Type in the NiNode name from the .nif file of the name of the object that you want it to effect. In this case, our rifle&#8217;s NiNode is AK47_Marine. BE WARNED, you MUST spell it PERFECTLY in order for it to work. Capitalization IS required where it&#8217;s needed as well.

    The last thing you need to do is go to Controller Type Offset, click the little TXT button, and type in NiVisController. Save the .kf file.



    Guess what? Yer done! Well, at least with this animation file. If you load the unit using it&#8217;s new unique .kfm file in a mod, you&#8217;ll notice that his gun won&#8217;t appear. In order for it to appear, you will need to do these same steps on one of the attack animations and make it appear.

    Also, a word of note from something I&#8217;ve noticed. Objects that have visibility controllers on certain animations, but not others, will retain the visibility status of the last animation that DID have the controller. That&#8217;s why our rifle doesn&#8217;t appear yet. Now, if you modified one more file, the Rangedstrike file and made it so the weapon would show up there, the weapon would continue to stay in his hand until he did a new Idle animation. Using this tactic, you can sometimes forgo modifying an animation file, provided if the item you don&#8217;t (or do) want appearing won&#8217;t be in an animation right before the animation file that doesn&#8217;t have a controller for it.

    So there you have it! A tutorial on how to make weapons appear and disappear for particular animations. Using this method I made the Welsh Longbowman, who uses a spear-attack instead of a staff attack, and the Landsknecht Arquebusier, a musketman who uses a Light Swordsman melee attack. I&#8217;ll be finishing up this Worker sometime as well&#8230; I may even give him a melee attack as well.

    Hope this works for you guys! :goodjob:
     
  2. CurryAztec

    CurryAztec Uncle Hồ

    Joined:
    Dec 9, 2008
    Messages:
    182
    Looks great! I can see you put a lot of thought into this tutorial, which will help a lot of people make great creations like you! Keep up the good work! :goodjob:
     
  3. Flintlock1415

    Flintlock1415 Emperor

    Joined:
    Feb 24, 2008
    Messages:
    1,057
    Location:
    MN
    Damn, double post.
     
  4. Flintlock1415

    Flintlock1415 Emperor

    Joined:
    Feb 24, 2008
    Messages:
    1,057
    Location:
    MN
    Hey, great tutorial here. :goodjob: I can't even get to the first step, though, as it won't work with mac (and its written in C#, which will make it harder to port.) :sad:
    Is there any workaround for this, or am I stuck? :(
     
  5. Gagonite

    Gagonite Irishman

    Joined:
    Nov 6, 2005
    Messages:
    208
    I honestly don't know.. I don't know the first thing about Mac's. :( What can't you get open though? NifSkope?
     
  6. Flintlock1415

    Flintlock1415 Emperor

    Joined:
    Feb 24, 2008
    Messages:
    1,057
    Location:
    MN
    Oh, s#!t, I didn't even say that the program is KonverterFM. :blush: Sedna17 compiled Nifskope for Mac users, but I'm just learning how to program on my mac and would be lost in converting KonverterFM to being useful on a Mac. :confused:
     
  7. Gagonite

    Gagonite Irishman

    Joined:
    Nov 6, 2005
    Messages:
    208
    Ah, well I wish I could help :sad: Though, you can still do the part where you choose which weapons are available to which animation, you just can't add new animations to units. Like you could put the Archer's daggers on his hips during ranged combat, and have them change to his hands during melee, as they are now.
     
  8. Flintlock1415

    Flintlock1415 Emperor

    Joined:
    Feb 24, 2008
    Messages:
    1,057
    Location:
    MN
    That stinks, :( although I'm getting way ahead of myself anyway since I've yet to learn about how units are done in Nifskope (Leaderheads are way easier! :lol: )
     
  9. Gagonite

    Gagonite Irishman

    Joined:
    Nov 6, 2005
    Messages:
    208
    I honestly haven't even tried doing a Leaderhead. I've only been focusing on units.. I'll have to give it a shot one of these days.
     
  10. Ekmek

    Ekmek on steam: ekmek_e

    Joined:
    Aug 7, 2002
    Messages:
    6,058
    Location:
    San Diego, California
    yeah LHs seem way easier. I've never been able to make a unit. but with tis tutorial I'll give it another shot. Thx!
     
  11. zenspiderz

    zenspiderz Just some bloke..

    Joined:
    Apr 10, 2006
    Messages:
    1,496
    I am trying to make the real legionnaire I mentioned above using your guide but have hit a problem. When i use a mali skirmisher or worker anim with the legionnaire model the models shoulders become flattened and weird looking. This is my first attempt at this but my best guess is that the skeleton/bones/whatever of the legionnaire is not the same as the bones of the mali and worker. If this is so then is it possible to use a differnet bone/skeleton underneath the legionnaire model and how do i do it? Any tutorials on this? thanks in advance.
    Spoiler :
     

    Attached Files:

  12. Gagonite

    Gagonite Irishman

    Joined:
    Nov 6, 2005
    Messages:
    208
    It looks like you didn't rename the Neck bone in the animation. That square that popped up saying "Couldn't find X" says it can't find a Neck bone. Try that, make sure the neck bone is named properly.
     
  13. zenspiderz

    zenspiderz Just some bloke..

    Joined:
    Apr 10, 2006
    Messages:
    1,496
    No it is worse than that the legionaire model doesn't have a neck bone at all. So could i add a neck bone in nifscope?

    I have experimented with skeleton swapping in blender but haven't quite got the hang of it yet.

    EDIT. Just had another go at armature swapping in blender, and i suceeded in giving my legionaire the skeleton of the mali skirmisher, i have also tried out the new rigged model with some anims and they all work pretty well. So i think i have cracked it and should soon have the model ready for release as soon as i get time to finish it.
     
  14. zenspiderz

    zenspiderz Just some bloke..

    Joined:
    Apr 10, 2006
    Messages:
    1,496
    I wonder how you can remove objects from a kf file?
     
  15. Gagonite

    Gagonite Irishman

    Joined:
    Nov 6, 2005
    Messages:
    208
    You should be able to go to the Controlled Blocks and just change the name of the object you want to remove to blank, in which It won't affect it's old target and instead affect nothing.
     
  16. zenspiderz

    zenspiderz Just some bloke..

    Joined:
    Apr 10, 2006
    Messages:
    1,496
    Ok i have finished the pilum throwing, road digging legionary and very nice it turned out too.

    download page



    Many thanks to Gagonite as it was your tutotial that inspired me to make it.
     
  17. Gagonite

    Gagonite Irishman

    Joined:
    Nov 6, 2005
    Messages:
    208
    Nice work! :goodjob: Glad to see that my tutorial is working for people.
     
  18. Deliverator

    Deliverator Graphical Hackificator

    Joined:
    Feb 12, 2008
    Messages:
    4,711
    Location:
    London, UK
    Good tutorial. It works, but I have an issue. I'm trying to add melee animations from one unit to a musketman unit. The trouble is the scale of the musketman unit and existing animations is greater than the scale of the melee animation I'm trying to use. I want to keep the existing model and animations so is there a way I can scale up (or down) an animation?

    I've attached the files so you can see what I mean. When you attach the Veteran Soldier animation to this NIF you can the body is basically scrunched up because the original target unit was smaller. I've seen in the Coyote's tutorial that they are Scale parameters in the KF file, but having had a quick play I couldn't get them to do anything.
     
  19. The_Coyote

    The_Coyote Emperor

    Joined:
    Mar 1, 2008
    Messages:
    1,367
    Location:
    Europe
    you could try to go to node 5 (NiTransformInterpolator of BIP Pelvis) of the veteran strike, go the details of the NiTransformData (node 6) and add under translation and scale two keys (start time 0, end time 0.7), almost good value in a nifskope check for translation was x=0, y=0, z= 40 and for scale 0.5
     
  20. Deliverator

    Deliverator Graphical Hackificator

    Joined:
    Feb 12, 2008
    Messages:
    4,711
    Location:
    London, UK
    Thanks man. I'll try out what you say.
     

Share This Page