This is the version of it and constants I ended up going with. The specific alignment ones weren't really needed, but they do simplify checking.
const int _ALIGNMENT_ALL = 1;
const int _ALIGNMENT_NEUTRAL = 2;
const int _ALIGNMENT_LAWFUL = 4;
const int _ALIGNMENT_CHAOTIC = 8;
const int _ALIGNMENT_GOOD = 16;
const int _ALIGNMENT_EVIL = 32;
const int _ALIGNMENT_LAWFUL_NEUTRAL = 6;
const int _ALIGNMENT_CHAOTIC_NEUTRAL = 10;
const int _ALIGNMENT_NEUTRAL_GOOD = 18;
const int _ALIGNMENT_LAWFUL_GOOD = 20;
const int _ALIGNMENT_CHAOTIC_GOOD = 24;
const int _ALIGNMENT_NEUTRAL_EVIL = 34;
const int _ALIGNMENT_LAWFUL_EVIL = 36;
const int _ALIGNMENT_CHAOTIC_EVIL = 40;
// Code by Lightfoot8
//// Returns a bitwise value, using _ALIGNMENT_* constants.
int _GetAlignment (object oTarget = OBJECT_SELF)
{
int nAlignment;
nAlignment = 1 << GetAlignmentLawChaos (oTarget);
nAlignment |= 1 << GetAlignmentGoodEvil (oTarget);
return nAlignment;
}
Checking for good would simply be:
if (_GetAlignment () & _ALIGNMENT_GOOD)
Checking for !good is slightly more annoying, sice it requires another set of nested brackets:
if (!(_GetAlignment () & _ALIGNMENT_GOOD))
Overall, it does everything I needed, and adds the versatility of checking for a specific alignment, or a general range. Specific alignments can be checked with a standard == in addition to bit checks.
Modifié par Failed.Bard, 19 décembre 2011 - 08:12 .