OK, so I got this great Mana using script off of the Vault from the great guys doing Ultima Returns. Their script set the mana off of the characters intelligence score. What I want to do is tell the script to see what the characters primary attribute is and set it to that. CHAR for sorceror, WIS for clerics, ect...I figure there's an ABILITY_PRIMARY but cant figure it out. Thanks in advance!
[code=auto:0]
//Return the current mana maximum
float GetManaMax(object oPC)
{
return GetAbilityScore(oPC, ABILITY_INTELLIGENCE) ;
[end code]
Script wizards! Cast your magic here!
Débuté par
christinetooley
, févr. 10 2011 04:37
#1
Posté 10 février 2011 - 04:37
#2
Posté 10 février 2011 - 09:13
Could do something like so:
//Return the current mana maximum
float GetManaMax(object oPC)
{
int iPrimary;
int iINT = GetAbilityScore(oPC, ABILITY_INTELLIGENCE);
int iCHA = GetAbilityScore(oPC, ABILITY_CHARISMA);
int iWIS = GetAbilityScore(oPC, ABILITY_WISDOM);
iPrimary = iINT;
if (iCHA > iPrimary) iPrimary = iCHA;
if (iWIS > iPrimary) iPrimary = iWIS;
return iPrimary;
}
Hope it helps.
//Return the current mana maximum
float GetManaMax(object oPC)
{
int iPrimary;
int iINT = GetAbilityScore(oPC, ABILITY_INTELLIGENCE);
int iCHA = GetAbilityScore(oPC, ABILITY_CHARISMA);
int iWIS = GetAbilityScore(oPC, ABILITY_WISDOM);
iPrimary = iINT;
if (iCHA > iPrimary) iPrimary = iCHA;
if (iWIS > iPrimary) iPrimary = iWIS;
return iPrimary;
}
Hope it helps.
#3
Posté 10 février 2011 - 09:47
That will return the highest ability score of the three, but not necessarily the primary score for that particular spell-casting class. They will usually be one and the same, although multi-class characters might break the mold. A sorceror/monk for instance might have a higher wisdom, even though it isn't the primary spell-casting ability.
#4
Posté 10 février 2011 - 09:54
The classes 2da may have a column for the primary attribute of a class. If it does then you can use the 2da functions to retrieve it. You would also have to check if it is a spell caster class and check each of the character's classes.
#5
Posté 24 mai 2011 - 06:54
So, how could I do a check class type script?
#6
Posté 24 mai 2011 - 07:18
OK, so I'm writing this as I make it up, but try something like this:
You need to decide what to do when, say, someone has two different spellcasting classes. Usually this will be something like Sorc X/Warlock 2, which both use Cha, but a character could take random combinations like Druid/Bard. In this case, the above code will use the greater casting ability, but only of the ones which are primary abilities of a class said player has. You might prefer just to take the highest level ckass or something, it depends how you're using this.
int nAbility = 10;
if(GetLevelByclass(oPC, class_TYPE_WIZARD) >= 1)
{
int nInt = GetAbilityScore(oPC, ABILITY_INTELLIGENCE);
if(nInt > nAbility) { nAbility = nInt; }
}
if(GetLevelByclass(oPC, class_TYPE_SORCERER) >= 1 ||
GetLevelByclass(oPC, class_TYPE_BARD) >= 1 ||
GetLevelByclass(oPC, class_TYPE_WARLOCK) >= 1)
{
int nCha = GetAbilityScore(oPC, ABILITY_CHARISMA);
if(nCha > nAbility) { nAbility = nInt; }
}
if(GetLevelByclass(oPC, class_TYPE_CLERIC) >= 1 ||
GetLevelByclass(oPC, class_TYPE_DRUID) >= 1 ||
GetLevelByclass(oPC, class_TYPE_FAVOURED_SOUL) >= 1
GetLevelByclass(oPC, class_TYPE_SPIRIT_SHAMAN) >= 1)
{
int nWis = GetAbilityScore(oPC, ABILITY_WISDOM);
if(nWis > nAbility) { nAbility = nWis; }
}
You need to decide what to do when, say, someone has two different spellcasting classes. Usually this will be something like Sorc X/Warlock 2, which both use Cha, but a character could take random combinations like Druid/Bard. In this case, the above code will use the greater casting ability, but only of the ones which are primary abilities of a class said player has. You might prefer just to take the highest level ckass or something, it depends how you're using this.
Modifié par The Fred, 24 mai 2011 - 07:18 .
#7
Posté 24 mai 2011 - 07:42
My codebase caches the primary class of a character, and the top spell casting class. Functions which get the primary casting stat, and the like are all implemented, but i decided to cache things like this because a lot of engine features ( AI, casting epic spells ) require this and to get an accurate value is pretty involved, and the work involved actually solves quite a few problems.
#8
Posté 24 mai 2011 - 08:47
Alright The Fred, that looks like what I need but I cant seem to integrate it into the rest of my script to compile right, darn it. Will keep trying but I am NO SCRIPT GOD like you and Pain. *sigh* Thanks for your help guys. And Pain, I have no idea what your code base is. LOL. Told ya, Im NO SCRIPT GOD. haha
#9
Posté 24 mai 2011 - 09:48
OK well I don't know what the script is that you're trying to modify, but I think if you just put the above code inside the GetMaxMana() function and stick "return nAbility;" on the bottom it should work. Only thing is that GetMaxMana() is for some reason returning a float, so you might have to put "return IntToFloat(nAbility);" instead, though I think NWN2 handles that (or what you put originally probably wouldn't work).
#10
Posté 25 mai 2011 - 12:11
If you care about being compatible with user created classes, I would use the 2da functions to read the SpellAbil column in the classes.2da file. This will be set to the primary ability used for spell casting for that class. The Get2DA and Search2DA functions should be sufficient.
Regards
Regards
#11
Posté 25 mai 2011 - 07:21
Yes, you could do that, though the above approach only checks to see if the player qualifies as a certain type of caster, rather than checking for the highest, etc. Since you can't add more base spellcasting classes (I guess you could have pseudo-casters or something, though), you probably don't need to do that, though. If you were going to use, say, the highest caster class to determine the bonus, then you'd probably want to use the 2da (but then there's the issue that gaining a level could lower your mana).
#12
Posté 25 mai 2011 - 08:20
Depends on if you know the class. If you do you just use that to pull the spell casting ability from classes.2da.
If you don't know the class, then you have to figure out the caster levels, which means you have to look at the feats chosen so you know if that palemaster set of levels adds to the wizard or sorceror base class based on how many level increases they get. This is what the issue is in epic spells, and just taking the highest stat was actually one solution.
The thing is i've worked up a complete system which does most of this in my _SCInclude_CacheStats which you are welcome to look at. It basically just runs on the character prior to being needed, and stores vars on them which are useful to a lot of scripts. One huge advantage is it reduces a lot of the overhead coming from the AI which needs this exact same information constantly.
This is really depending on how accurate you want to make things, it's often a good idea to just approximate and taking the highest of the three stats is usually going to give you the right stat.
If you don't know the class, then you have to figure out the caster levels, which means you have to look at the feats chosen so you know if that palemaster set of levels adds to the wizard or sorceror base class based on how many level increases they get. This is what the issue is in epic spells, and just taking the highest stat was actually one solution.
The thing is i've worked up a complete system which does most of this in my _SCInclude_CacheStats which you are welcome to look at. It basically just runs on the character prior to being needed, and stores vars on them which are useful to a lot of scripts. One huge advantage is it reduces a lot of the overhead coming from the AI which needs this exact same information constantly.
This is really depending on how accurate you want to make things, it's often a good idea to just approximate and taking the highest of the three stats is usually going to give you the right stat.





Retour en haut






