Like shadow, I am also limited by not knowing how you are going to use this. Still I guess that does not limit the comments I have to make.
First:
I see no reason for two neutrals One should do just fine. If someone is true neutral they will have just the single bit set. If they are LN They will have the Lafull and neutral bit set. On the other side NG would still have just two bits set.
Second:
I realy dislike the use of BitVar += VarConstant; It can just open up to many oportunities for bugs working they way into things. When working with bits that you are tring to combine, you are much better off using the OR ( | ) operator. That way you Do Not have to worry about common bits getting added together and carring over to set a unintended bit. Belive it or not this will work: BitVar |= VarConstant;
Ok back to your constants. I feel that it is best to build off of the constants alread in the NWN system. They are:
int ALIGNMENT_ALL = 0;
int ALIGNMENT_NEUTRAL = 1;
int ALIGNMENT_LAWFUL = 2;
int ALIGNMENT_CHAOTIC = 3;
int ALIGNMENT_GOOD = 4;
int ALIGNMENT_EVIL = 5;
Using them as Bit Positions for your constants would give you.
const int FB_ALIGNMENT_ALL = 1;
const int FB_ALIGNMENT_NEUTRAL = 2;
const int FB_ALIGNMENT_LAWFUL = 4;
const int FB_ALIGNMENT_CHAOTIC = 8;
const int FB_ALIGNMENT_GOOD = 16;
const int FB_ALIGNMENT_EVIL = 32;
With the Above FB_ constants your FB_GetAlignment function becomes as simple as.
int FB_GetAlignment (object oTarget = OBJECT_SELF, int nReset = FALSE)
{
int nAlignment= GetLocalInt (oTarget, "FB_ALIGNMENT");
if (nReset || !nAlignment )
{
nAlignment = 1 << GetAlignmentLawChaos (oTarget);
nAlignment |= 1 << GetAlignmentGoodEvil (oTarget);
SetLocalInt (oTarget, "FB_ALIGNMENT", nAlignment);
}
return nAlignment;
}
Modifié par Lightfoot8, 19 décembre 2011 - 03:24 .