Attempting to define new PC racial type constants via scripting

Good morning!

This may be kind of a dunce question, but it sapped about 4 hours of my time last night trying to figure it out. :slight_smile: I have a group of custom races defined in my racialtypes.2da that I want to check via scripting- so when someone clicks on something or uses a given spell, it’ll check their racial type and modify the effects.

However when I attempt to do this via script, I get an unknown constant error. I kind of expected that because there isn’t a definition of what this racial type is, but when I attempt to define it with something like:

const string racialtype_aasimar;

I get nothing.

I’ve attempted (unsuccessfully) to get nwscript to return the race of the PC as well using a switch statement with the standard racial types as well. I was trying to figure out what NWN saw this PC as, but it just doesn’t give me anything back at all.

Is this stuff hard coded and I’m just spinning my wheels or is my approach way off?

That because they are not const strings.
They are const int RACIAL_TYPE_AASIMAR = (Row number in your racialtypes.2da)

If you look Beamdog’s racial constants in scripting (constant tab you see they number them)
and they define them in nwscript.
That why function int GetRacialType(object oCreature) return an integer also and not a string.

1 Like

Man, I feel dumb… I even looked into that possibility, I don’t know why it didn’t jump out at me.

Thanks so much for this, I made my script and it fired right up and worked flawlessly. Thank you, @ShadowM