stoffe
01-02-2007, 12:12 PM
Mod note: Some posts from this thread (http://www.lucasforums.com/showthread.php?t=174171) has been copied to the tutorial forum here for easier reference. Please post comments or questions in the original thread. ~M
To make a new shield armband you essentially need to modify 4 standard game files, and create two new files. First, the files you need to modify:
dialog.tlk
This file is located in the main game folder (where the swkotor.exe or swkotor2.exe file is located). It contains all the standard text that is shown in the game that doesn't come from mods. Make a backup copy of this file first, in case something gets messed up. Then open this file with a TLK file editor (TalkEd for example) and add a new entry to it. As the text of this entry, type in the name of your shield. Then make note of the index number (StrRef) your entry gets added as, you'll need this number soon.
Save your changes to the dialog.tlk. Remember that this file should never be put in the override folder, it should always be in the main game folder.
forceshields.2da
This 2DA file contains the specifics of a particular type of energy shield. This includes information about how much damage is blocked, what types of damage is blocked, and what visual effects are shown on the one protected by the shield.
If you don't have a copy in your override folder already you can extract one from 2da.bif with KotorTool. Add a new line to this table for your shield. It's easier if you pick the line of a similar shield and copy&paste it at the end and then just modify the values you want to be different. The columns in this file are:
(Row Label) - Just set it to the next number in sequence.
Label - This is not used by the game, just to make the file more easy to understand for humans and allow installers and such to uniquely identify a line. Set this to a unique name for your shield.
visualeffectdef - This column holds a Row Label value from visualeffects.2da, telling the game what "glow" effect to display on the one protected by the shield while it's active.
defaultradius - Unused as far as I can tell. Just set it to -1.
damageflags - This column contains a bit-field of OR-ed together damage constant numbers to tell the game what types of damage will be blocked by the shield. To get the value to put in this column, add together the numbers for the relevant damage types as listed below:
Damage type Constant value
----------------------- --------------
Bludgeoning 1
Piercing 2
Slashing 4
Universal (all) 8
Unstoppable (disruptor) 16
Cold 32
Light side 64
Electrical 128
Fire 256
Dark side 512
Sonic 1024
Ion 2048
Blaster 4096
So, for example, to make a shield that blocks all physical types of damage, you'd put 7 (1 + 2 + 4) in the damageflags column.
vulnerflags - This field works just like the damageflags field, only that the damage types specified here will deal double damage to a shield of this type. This is usually used to make Ion damage drop shields quicker, but you can specify any damage types here.
resistance - Don't know for sure what this does. I suspect it's the maximum amount of damage inflicted by a single hit that will be blocked by the shield, but that's just speculation. All standard shields in the game have this set to 300 so unless you have a reason not to I suggest you do so as well. :)
amount - This specifies the amount of damage the shield will block before it expires.
permanent - This isn't used by any of the standard shields in the game, but I think if it's set to 1 the amount column will be ignored and the shield will continue to block damage until its effect duration expires.
The remaining columns are only used for droid shields that don't use the "skin tight" glow, and will determine how their shield bubble looks. They should all be set to **** for regular armband shields worn by humanoids.
When you've added your new line and set its values, save the modified 2DA file in the override folder. Remember the line number of the new line you added, it will soon be needed.
effecticon.2da
This file is used to display feedback to a player that they are under the effect of a particular effect. In KotOR this will determine what little icon is shown on the character screen of the character. In TSL it will determine what text is shown on the "Effects" screen of the character. You should add a new line to this file for your shield, so the player will know when their character is protected by it. The columns are:
(Row Label) - Set this to the next number in sequence.
Label - Used to make the file more easily readable by humans, and lines distinguishable by installer and patcher applications, but not used by the game itself. Set it to a unique name for your shield.
iconresref - Set this to the name of a TGA or TPC file (without the .tga or .tpc extension itself) containing the icon to display on the character screen, if this is for KotOR1. In TSL you can probably leave it unset as it is not used by that game.
good - If this is set to 1 the effect will be listed as a beneficial (buff/defense) effect, which you'd want in the case of a shield. If set to 0 it will be listed as a debilitating or otherwise unbeneficial effect (such as poison, stun etc).
description - I don't think this is used by either of the games, so just set it to ****.
priority - This will affect the order in which the icon or name is displayed in the listing. Doesn't really matter what you set it to for anything else, as far as I can tell.
namestrref - This needs to be set to a StrRef of where the name of the effect (in this case the name of your shield) is stored. A StrRef is an index value in the dialog.tlk file. Set this to the StrRef of the dialog.tlk entry you added previously.
spells.2da
This contains definitions for all force powers and activatable items in the game, linking them to the script that does whatever they are meant to do. It's too complicated to describe in detail here, so just find a line for one of the existing shields in the game and copy&paste it at the end. Line 99, the common energy shield, will do nicely. Then change the following columns:
(Row Label) - Set this to the next number in sequence.
label - Set this to a unique name to identify your armband. It's not used by the game, but makes the file easier to read for humans or installer/patcher applications.
name - Set this to the StrRef number of the new entry you added to dialog.tlk above.
impactscript - This should contain the name of your script (without the .NCS extension) that is used to trigger the shield when the armband is used. Make up a new unique name for your script. It can be at most 16 characters long and may only contain characters a-z, numbers 0-9 and underscore _ characters. Remember the name, you'll soon create this file.
That's all you need to change from the original line you copied. Save your modified spells.2da file in your override folder, and remember the line number of the line you just added. This will be used shortly.
Next, the files that needs to be created:
The impact script
Create a new script source file (NSS) and give it the name you set in the impactscript column above. The content of the script could simply look something like this, and will tie together some of the files you just modified:
void main() {
effect eShield = EffectForceShield(999);
eShield = SetEffectIcon(eShield, 999);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eShield, GetSpellTargetObject(), 120.0);
}
The colored part in the script below are what needs to be modified:
Change the yellow number to the line number in forceshields.2da of the new line you added there.
Change the blue number to the line number in effecticon.2da of the new line you added there.
Change the green number to the duration, in seconds, that the shield will last (unless it will expire by blocking it's maximum amount of damage before then).
Compile your modified NSS file into an NCS file, and put the NCS file in the override folder.
The UTI file
Create a new UTI file for your armband, name it whatever you like and give it a suitable description. Set the Base Item type to Forearm Bands (46), and set the ModelVariation to the number at the end of the ii_frArmBnds_###.tpc (or .tga) texture file you want to use as inventory icon for your armband. The standard ones goes from ii_frArmBnds_001.tpc (1) to ii_frArmBnds_010.tpc (10), but you can add your own textures with your own number in the name, and set the ModelVariation accordingly.
As item property, add an Activate Item property, set the SubType to the line in spells.2da you added earlier, and set the Value to the number of charges per use you want your shield to have, determining how many times your shield item can be used before burning out.
Save the UTI file in the override folder as well, and hopefully everything should work. :)
To make a new shield armband you essentially need to modify 4 standard game files, and create two new files. First, the files you need to modify:
dialog.tlk
This file is located in the main game folder (where the swkotor.exe or swkotor2.exe file is located). It contains all the standard text that is shown in the game that doesn't come from mods. Make a backup copy of this file first, in case something gets messed up. Then open this file with a TLK file editor (TalkEd for example) and add a new entry to it. As the text of this entry, type in the name of your shield. Then make note of the index number (StrRef) your entry gets added as, you'll need this number soon.
Save your changes to the dialog.tlk. Remember that this file should never be put in the override folder, it should always be in the main game folder.
forceshields.2da
This 2DA file contains the specifics of a particular type of energy shield. This includes information about how much damage is blocked, what types of damage is blocked, and what visual effects are shown on the one protected by the shield.
If you don't have a copy in your override folder already you can extract one from 2da.bif with KotorTool. Add a new line to this table for your shield. It's easier if you pick the line of a similar shield and copy&paste it at the end and then just modify the values you want to be different. The columns in this file are:
(Row Label) - Just set it to the next number in sequence.
Label - This is not used by the game, just to make the file more easy to understand for humans and allow installers and such to uniquely identify a line. Set this to a unique name for your shield.
visualeffectdef - This column holds a Row Label value from visualeffects.2da, telling the game what "glow" effect to display on the one protected by the shield while it's active.
defaultradius - Unused as far as I can tell. Just set it to -1.
damageflags - This column contains a bit-field of OR-ed together damage constant numbers to tell the game what types of damage will be blocked by the shield. To get the value to put in this column, add together the numbers for the relevant damage types as listed below:
Damage type Constant value
----------------------- --------------
Bludgeoning 1
Piercing 2
Slashing 4
Universal (all) 8
Unstoppable (disruptor) 16
Cold 32
Light side 64
Electrical 128
Fire 256
Dark side 512
Sonic 1024
Ion 2048
Blaster 4096
So, for example, to make a shield that blocks all physical types of damage, you'd put 7 (1 + 2 + 4) in the damageflags column.
vulnerflags - This field works just like the damageflags field, only that the damage types specified here will deal double damage to a shield of this type. This is usually used to make Ion damage drop shields quicker, but you can specify any damage types here.
resistance - Don't know for sure what this does. I suspect it's the maximum amount of damage inflicted by a single hit that will be blocked by the shield, but that's just speculation. All standard shields in the game have this set to 300 so unless you have a reason not to I suggest you do so as well. :)
amount - This specifies the amount of damage the shield will block before it expires.
permanent - This isn't used by any of the standard shields in the game, but I think if it's set to 1 the amount column will be ignored and the shield will continue to block damage until its effect duration expires.
The remaining columns are only used for droid shields that don't use the "skin tight" glow, and will determine how their shield bubble looks. They should all be set to **** for regular armband shields worn by humanoids.
When you've added your new line and set its values, save the modified 2DA file in the override folder. Remember the line number of the new line you added, it will soon be needed.
effecticon.2da
This file is used to display feedback to a player that they are under the effect of a particular effect. In KotOR this will determine what little icon is shown on the character screen of the character. In TSL it will determine what text is shown on the "Effects" screen of the character. You should add a new line to this file for your shield, so the player will know when their character is protected by it. The columns are:
(Row Label) - Set this to the next number in sequence.
Label - Used to make the file more easily readable by humans, and lines distinguishable by installer and patcher applications, but not used by the game itself. Set it to a unique name for your shield.
iconresref - Set this to the name of a TGA or TPC file (without the .tga or .tpc extension itself) containing the icon to display on the character screen, if this is for KotOR1. In TSL you can probably leave it unset as it is not used by that game.
good - If this is set to 1 the effect will be listed as a beneficial (buff/defense) effect, which you'd want in the case of a shield. If set to 0 it will be listed as a debilitating or otherwise unbeneficial effect (such as poison, stun etc).
description - I don't think this is used by either of the games, so just set it to ****.
priority - This will affect the order in which the icon or name is displayed in the listing. Doesn't really matter what you set it to for anything else, as far as I can tell.
namestrref - This needs to be set to a StrRef of where the name of the effect (in this case the name of your shield) is stored. A StrRef is an index value in the dialog.tlk file. Set this to the StrRef of the dialog.tlk entry you added previously.
spells.2da
This contains definitions for all force powers and activatable items in the game, linking them to the script that does whatever they are meant to do. It's too complicated to describe in detail here, so just find a line for one of the existing shields in the game and copy&paste it at the end. Line 99, the common energy shield, will do nicely. Then change the following columns:
(Row Label) - Set this to the next number in sequence.
label - Set this to a unique name to identify your armband. It's not used by the game, but makes the file easier to read for humans or installer/patcher applications.
name - Set this to the StrRef number of the new entry you added to dialog.tlk above.
impactscript - This should contain the name of your script (without the .NCS extension) that is used to trigger the shield when the armband is used. Make up a new unique name for your script. It can be at most 16 characters long and may only contain characters a-z, numbers 0-9 and underscore _ characters. Remember the name, you'll soon create this file.
That's all you need to change from the original line you copied. Save your modified spells.2da file in your override folder, and remember the line number of the line you just added. This will be used shortly.
Next, the files that needs to be created:
The impact script
Create a new script source file (NSS) and give it the name you set in the impactscript column above. The content of the script could simply look something like this, and will tie together some of the files you just modified:
void main() {
effect eShield = EffectForceShield(999);
eShield = SetEffectIcon(eShield, 999);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eShield, GetSpellTargetObject(), 120.0);
}
The colored part in the script below are what needs to be modified:
Change the yellow number to the line number in forceshields.2da of the new line you added there.
Change the blue number to the line number in effecticon.2da of the new line you added there.
Change the green number to the duration, in seconds, that the shield will last (unless it will expire by blocking it's maximum amount of damage before then).
Compile your modified NSS file into an NCS file, and put the NCS file in the override folder.
The UTI file
Create a new UTI file for your armband, name it whatever you like and give it a suitable description. Set the Base Item type to Forearm Bands (46), and set the ModelVariation to the number at the end of the ii_frArmBnds_###.tpc (or .tga) texture file you want to use as inventory icon for your armband. The standard ones goes from ii_frArmBnds_001.tpc (1) to ii_frArmBnds_010.tpc (10), but you can add your own textures with your own number in the name, and set the ModelVariation accordingly.
As item property, add an Activate Item property, set the SubType to the line in spells.2da you added earlier, and set the Value to the number of charges per use you want your shield to have, determining how many times your shield item can be used before burning out.
Save the UTI file in the override folder as well, and hopefully everything should work. :)