I'm wondering if anyone knows how a companion's stats and skills are "stored." Are they connected to the object itself, associated with a tag, or otherwise stored in the module?
Let me explain what I want to do: My companion will leave the party for a while, undergo a crisis, return as a different model, and rejoin the party. However, I want the choices the player made in assigning stats and skills at level-up to remain rather than considering it a completely new companion.
Option 1) Is this as simple as giving the new model the same tag as the original one?
Option 2) I seem to recall some talk about a script to exchange head morphs. Has this ever been implemented? And is there something similar for switching a model?
(And can this be transferred across modules? - Say hypothetically, you
wanted to create a module that could port the Main Campaign character
but also bring Zevran into the new module with the same stats he had at
the end of the same campaign.)
Transforming a Companion?
Débuté par
Qutayba
, sept. 07 2010 09:37
#1
Posté 07 septembre 2010 - 09:37
#2
Posté 07 septembre 2010 - 10:14
1) The stats and abilities are tied to the object. Since this is within a module, you can extract the required information and assign the same to the new character. Tags won't help here as they are merely for identification purposes.
2) Even if such a script were possible, I'd think it will work only on save-games. You can assign a different appearance for the character.
3) Haven't examined save game files but I wouldn't think this is possible. You can import the plot settings so one possibility is to create different plots for stats and set the flag # corresponding to the stat value alone. Of course, this would be difficult for float values so you might have to do some rounding stuff.
Or, you can create an item with a separate variables table and put in all the information there. Question is - would it be imported too?
Abilities can use the same plot logic with flags being set for abilities that have been selected.
Of course, there could be an easier way too
2) Even if such a script were possible, I'd think it will work only on save-games. You can assign a different appearance for the character.
3) Haven't examined save game files but I wouldn't think this is possible. You can import the plot settings so one possibility is to create different plots for stats and set the flag # corresponding to the stat value alone. Of course, this would be difficult for float values so you might have to do some rounding stuff.
Or, you can create an item with a separate variables table and put in all the information there. Question is - would it be imported too?
Abilities can use the same plot logic with flags being set for abilities that have been selected.
Of course, there could be an easier way too
#3
Posté 07 septembre 2010 - 11:04
I have a script I use at character creation to copy a player's choices over to a new creature. It goes something like this:
//uses constants from 2da_constants_h
void CopyBase(int property, object dest, object source)
{
SetCreatureProperty(dest,property,GetCreatureProperty(source,property,PROPERTY_VALUE_BASE),PROPERTY_VALUE_BASE);
}
void GiveAbilities(object dest, object source)
{
SetName(dest,GetName(source);
CopyBase(PROPERTY_ATTRIBUTE_AP, dest, source);
CopyBase(PROPERTY_ATTRIBUTE_ARMOR, dest, source);
...//NOTE: Tons of other PROPERTY_ATTRIBUTE constants in here
CopyBase(PROPERTY_ATTRIBUTE_REGENERATION_HEALTH_COMBAT, dest, source);
CopyBase(PROPERTY_DEPLETABLE_HEALTH, dest, source);
CopyBase(PROPERTY_DEPLETABLE_MANA_STAMINA, dest, source);
CopyBase(PROPERTY_SIMPLE_AGE, dest, source);
...//Bunch of other PROPERTY_SIMPLE s in here
CopyBase(PROPERTY_SIMPLE_THREAT_DECREASE_RATE, dest, source);
SetNumTactics(dest,GetNumTactics(source));
HealCreature(dest,FALSE,9999.0,TRUE);
int[] abilities = GetAbilityList(source);
//this code adds the abilities. It also fills out the qbar at random
int i;
for (i = 0; i < GetArraySize(abilities); i++)
{
int nType = GetAbilityType(abilities[i]);
if (nType == ABILITY_TYPE_SPELL || nType == ABILITY_TYPE_TALENT)
{
AddAbilityEx(dest,abilities[i],-1);
}
else
{
AddAbility(dest,abilities[i]);
}
}
//This is giving them a specialisation point, you'll
//probably just want to copy the property. Note there isn't
//actually an existing constant for this.
//I don't even remember where I found out it was 38
SetCreatureProperty(dest,38,1.0/*spec points*/);
}
I'm not sure if I missed out on anything in there. I'm using this for a level 1 character but I think it should scale okay.
Note also that the destination creature has NO EVENT SCRIPT. This is to prevent the game from scaling them normally. After you're done you'll want to call SetEventScript(character,RESOURCE_SCRIPT_PLAYER_CORE). You'll also want to add them to the party using SetFollowerState() rather than UT_Hire, because again UT_Hire will try to rescale them.
Also note this doesn't tranfer tactics. I'm not sure it's actually possible to save a custom tactics configuration from a party member through scripting.
It also doesn't transfer items. You may want to give diferent items to the character, but perhaps you want some of them to be the same. You can use GetItemInEquipSlot, AddItem & EquipItem to move an item across to a the new version.
Note also that as far as I can see from looking at script.ldf and 2da_constants_h, all the attributes of all types are in the range 1-59. So instead of explicitly naming everything as I did with constants, you could just loop through 1-59 and copy them all.
//uses constants from 2da_constants_h
void CopyBase(int property, object dest, object source)
{
SetCreatureProperty(dest,property,GetCreatureProperty(source,property,PROPERTY_VALUE_BASE),PROPERTY_VALUE_BASE);
}
void GiveAbilities(object dest, object source)
{
SetName(dest,GetName(source);
CopyBase(PROPERTY_ATTRIBUTE_AP, dest, source);
CopyBase(PROPERTY_ATTRIBUTE_ARMOR, dest, source);
...//NOTE: Tons of other PROPERTY_ATTRIBUTE constants in here
CopyBase(PROPERTY_ATTRIBUTE_REGENERATION_HEALTH_COMBAT, dest, source);
CopyBase(PROPERTY_DEPLETABLE_HEALTH, dest, source);
CopyBase(PROPERTY_DEPLETABLE_MANA_STAMINA, dest, source);
CopyBase(PROPERTY_SIMPLE_AGE, dest, source);
...//Bunch of other PROPERTY_SIMPLE s in here
CopyBase(PROPERTY_SIMPLE_THREAT_DECREASE_RATE, dest, source);
SetNumTactics(dest,GetNumTactics(source));
HealCreature(dest,FALSE,9999.0,TRUE);
int[] abilities = GetAbilityList(source);
//this code adds the abilities. It also fills out the qbar at random
int i;
for (i = 0; i < GetArraySize(abilities); i++)
{
int nType = GetAbilityType(abilities[i]);
if (nType == ABILITY_TYPE_SPELL || nType == ABILITY_TYPE_TALENT)
{
AddAbilityEx(dest,abilities[i],-1);
}
else
{
AddAbility(dest,abilities[i]);
}
}
//This is giving them a specialisation point, you'll
//probably just want to copy the property. Note there isn't
//actually an existing constant for this.
//I don't even remember where I found out it was 38
SetCreatureProperty(dest,38,1.0/*spec points*/);
}
I'm not sure if I missed out on anything in there. I'm using this for a level 1 character but I think it should scale okay.
Note also that the destination creature has NO EVENT SCRIPT. This is to prevent the game from scaling them normally. After you're done you'll want to call SetEventScript(character,RESOURCE_SCRIPT_PLAYER_CORE). You'll also want to add them to the party using SetFollowerState() rather than UT_Hire, because again UT_Hire will try to rescale them.
Also note this doesn't tranfer tactics. I'm not sure it's actually possible to save a custom tactics configuration from a party member through scripting.
It also doesn't transfer items. You may want to give diferent items to the character, but perhaps you want some of them to be the same. You can use GetItemInEquipSlot, AddItem & EquipItem to move an item across to a the new version.
Note also that as far as I can see from looking at script.ldf and 2da_constants_h, all the attributes of all types are in the range 1-59. So instead of explicitly naming everything as I did with constants, you could just loop through 1-59 and copy them all.
Modifié par FergusM, 08 septembre 2010 - 02:16 .





Retour en haut







