R
Rabbit, White
Guest
longer title... How to change effects for units without re-exporting them from max
Intro
In this tutorial I will describe a method by which it is possible to change the effect that a unit produces during animation, typically firing a gun or cannon, without having to import it into max, and re-export with modified effects. This method is of course limited because you cannot modify the animation itself, and you are also limited to existing effects. So how is this useful you might ask? Well, if you created a unit that uses existing animations but needs a different effect, then with this method you could do that without changing the effect of the original unit.
Software
For this to work you will need a hex editor which is basically like a text editor but for non-text files. I personally use UltraEdit-32 but there are many alternatives out there, some are free.
First step "Effect in a haystack"
You need to figure out what effect you actually want to change. What I mean is, lets say you want to switch the tanks cannon effect to a rifles firing effect. Well, you need to know what the tanks effect is called, which might not always be obvious. Find and open the file CIV4EffectInfos.xml in Assets/XML/Misc. This is the file that defines all the effects in the game.
Now, right here you might think to yourself, well theres an effect called EFFECT_WEAPON_CANNONFIRE_MODERN_TANKS, and since theres no similar effect for non-modern tanks that must mean that both tanks use the same effect. And youd be right, except that both tanks in fact use the EFFECT_WEAPON_PANZER_FIRE. You will also note that the effect itself calls on the fx_weapon_cannonfire_modern.nif file and in fact the same effects file is used for a lot of units, including destroyers and battleships. (As far as I know the EFFECT_WEAPON_CANNONFIRE_MODERN_TANKS effect is not actually used by any units.)
So basically this is where a bit of experimentation comes into play. Find the effect that you think is used by the unit and change the <Path> tag to point to a different effect and then run the game and test it. If the units effect has changed then you found the right effect.
Second step "A Panzer by any other name"
So, now that we found what effect the tank uses we want to change it. If you simply change the path, then the effect will change also for modern armors and panzers, and we dont want that.
So what you need to do is duplicate the effect definition and give it a different name. It is important that the new name has the exact same length as the old one. In this case I changed it to EFFECT_WEAPON_KRAMER_FIRE (Ive been watching a lot Seinfield, so sue me!
). Then change the path to point to the torrent_of_racial_slurs.nif file
just kidding
, change the path to whatever effect you want to be used, in this case its the rifles firing effect - Art/Effects/weapon_rifleblast_old/fx_rifleblast_old.nif.
Okay, half the work is done well, more like 10% but half sounds better.
Third step Look Ma - No animations!
Now, if all I really wanted to do is change the tanks effect then I would simply now modify the animations files of the tank and be done with it. However, this tutorial is, for the most part, intended to be used with custom units so I will quickly setup the tank as a typical custom unit. (This part assumes you know how to do that so I'll go over this quickly.)
I make a copy of the tank folder and call it whatever. Then remove all the animation files (KF/KFM), create a new art entry for it in the CIV4ArtDefines_Unit.xml file. Make sure that the NIFs are referenced from the new folder but the animation is still using the old tank animation path. Then create a new unit in the CIV4UnitInfos.xml file, which points to the new tank art definition. So, at this point, this is your typical custom unit. So, the million dollar question is, how do I make this custom unit use the new effect I defined?
Fourth step Let my animations go!
Now we need to put the animations, i.e. KF/KFM files, that the custom unit is using in the same folder its located at. This is needed because we're going to be modifying one of these files to use the new effect, and if we modify one then all of them have to be copied into the new locaiton.
IMPORTANT: In the folder of the custom unit, when you put the animations in, you must put the NIF of the unit who's animations are used by the custom unit, in other words the NIF with the same name as the KFM file being used by the unit. In this case itll be tank.nif and its already there, but if you created for example a hover tank and called the NIFs hover_tank.nif and hover_tank_fx.nif then youll need to copy the original tank.nif together with the tank animation files. This extra NIF file isn't, strictly speaking, used but without it the unit won't work.
Once you copy the animations you need to change the units art entry so that now the KFM tag points to this new copy of the animations.
Well, at this point everything is setup, theres only one last thing to do and youre good to go.
Fifth step "Hexing all the way to the bank"
Using the hex editor open the appropriate KF file, in this case its tank_md_rangedstrike.kf (that' gonna be the file for most gun based units - ships, tanks, soldiers, etc.). Scroll to the end of the file and find the section that says something like "Effect:EFFECT_PANZER_FIRE:EFFECT_WEAPON_PANZER_FIRE". (It will of course be different for other units.) Then change only the EFFECT_WEAPON_PANZER_FIRE part to EFFECT_WEAPON_KRAMER_FIRE. Make sure that you change the last part, not the middle one.
Effect:EFFECT_PANZER_FIRE:EFFECT_WEAPON_PANZER_FIRE
Effect - refers to the fact that it's an effect
EFFECT_PANZER_FIRE - is the name of the node to which the effect is attached, if you open the unit you will find such a node
EFFECT_WEAPON_PANZER_FIRE - the name of the effect from XMLs
If you launch the game now the new tank will use the rifle blast, while the old tank will still use the regular tank effect.
Well, that's it folks. This was one of the less interesting tutorials on something that isn't going to be used by most people but if at least one person found it useful then my job here is done.
Cheers
Intro
In this tutorial I will describe a method by which it is possible to change the effect that a unit produces during animation, typically firing a gun or cannon, without having to import it into max, and re-export with modified effects. This method is of course limited because you cannot modify the animation itself, and you are also limited to existing effects. So how is this useful you might ask? Well, if you created a unit that uses existing animations but needs a different effect, then with this method you could do that without changing the effect of the original unit.
Software
For this to work you will need a hex editor which is basically like a text editor but for non-text files. I personally use UltraEdit-32 but there are many alternatives out there, some are free.
First step "Effect in a haystack"
You need to figure out what effect you actually want to change. What I mean is, lets say you want to switch the tanks cannon effect to a rifles firing effect. Well, you need to know what the tanks effect is called, which might not always be obvious. Find and open the file CIV4EffectInfos.xml in Assets/XML/Misc. This is the file that defines all the effects in the game.
Now, right here you might think to yourself, well theres an effect called EFFECT_WEAPON_CANNONFIRE_MODERN_TANKS, and since theres no similar effect for non-modern tanks that must mean that both tanks use the same effect. And youd be right, except that both tanks in fact use the EFFECT_WEAPON_PANZER_FIRE. You will also note that the effect itself calls on the fx_weapon_cannonfire_modern.nif file and in fact the same effects file is used for a lot of units, including destroyers and battleships. (As far as I know the EFFECT_WEAPON_CANNONFIRE_MODERN_TANKS effect is not actually used by any units.)
So basically this is where a bit of experimentation comes into play. Find the effect that you think is used by the unit and change the <Path> tag to point to a different effect and then run the game and test it. If the units effect has changed then you found the right effect.
Second step "A Panzer by any other name"
So, now that we found what effect the tank uses we want to change it. If you simply change the path, then the effect will change also for modern armors and panzers, and we dont want that.
So what you need to do is duplicate the effect definition and give it a different name. It is important that the new name has the exact same length as the old one. In this case I changed it to EFFECT_WEAPON_KRAMER_FIRE (Ive been watching a lot Seinfield, so sue me!


Okay, half the work is done well, more like 10% but half sounds better.
Third step Look Ma - No animations!
Now, if all I really wanted to do is change the tanks effect then I would simply now modify the animations files of the tank and be done with it. However, this tutorial is, for the most part, intended to be used with custom units so I will quickly setup the tank as a typical custom unit. (This part assumes you know how to do that so I'll go over this quickly.)
I make a copy of the tank folder and call it whatever. Then remove all the animation files (KF/KFM), create a new art entry for it in the CIV4ArtDefines_Unit.xml file. Make sure that the NIFs are referenced from the new folder but the animation is still using the old tank animation path. Then create a new unit in the CIV4UnitInfos.xml file, which points to the new tank art definition. So, at this point, this is your typical custom unit. So, the million dollar question is, how do I make this custom unit use the new effect I defined?
Fourth step Let my animations go!
Now we need to put the animations, i.e. KF/KFM files, that the custom unit is using in the same folder its located at. This is needed because we're going to be modifying one of these files to use the new effect, and if we modify one then all of them have to be copied into the new locaiton.
IMPORTANT: In the folder of the custom unit, when you put the animations in, you must put the NIF of the unit who's animations are used by the custom unit, in other words the NIF with the same name as the KFM file being used by the unit. In this case itll be tank.nif and its already there, but if you created for example a hover tank and called the NIFs hover_tank.nif and hover_tank_fx.nif then youll need to copy the original tank.nif together with the tank animation files. This extra NIF file isn't, strictly speaking, used but without it the unit won't work.
Once you copy the animations you need to change the units art entry so that now the KFM tag points to this new copy of the animations.
Well, at this point everything is setup, theres only one last thing to do and youre good to go.
Fifth step "Hexing all the way to the bank"
Using the hex editor open the appropriate KF file, in this case its tank_md_rangedstrike.kf (that' gonna be the file for most gun based units - ships, tanks, soldiers, etc.). Scroll to the end of the file and find the section that says something like "Effect:EFFECT_PANZER_FIRE:EFFECT_WEAPON_PANZER_FIRE". (It will of course be different for other units.) Then change only the EFFECT_WEAPON_PANZER_FIRE part to EFFECT_WEAPON_KRAMER_FIRE. Make sure that you change the last part, not the middle one.
Spoiler quick break down of the effect entry, if you're interested :
Effect:EFFECT_PANZER_FIRE:EFFECT_WEAPON_PANZER_FIRE
Effect - refers to the fact that it's an effect
EFFECT_PANZER_FIRE - is the name of the node to which the effect is attached, if you open the unit you will find such a node
EFFECT_WEAPON_PANZER_FIRE - the name of the effect from XMLs
If you launch the game now the new tank will use the rifle blast, while the old tank will still use the regular tank effect.
Well, that's it folks. This was one of the less interesting tutorials on something that isn't going to be used by most people but if at least one person found it useful then my job here is done.

Cheers