Page 1 of 1

Checking for Psion Class

PostPosted: Sun Dec 12, 2004 9:33 am
Author: Deider
I'm writing a script that needs to check to see if a PC has psion levels.

This is what I've tried to use:

Code: Select all
int nPsionLvl = GetLevelByClass(CLASS_TYPE_PSIONICIST, oPC);


I'm pretty sure I got the CLASS_TYPE_ variable right for the psion class, but the script does not compile because it doesn't consider PSIONICIST to be valid. Is there a script I need to include, a script somewhere that defines this new class type variable, to get my script to compile?

EDIT: Fuzz has told me that the psionicist class is entry #200 in the copap .tlk file. If that helps in any way... :)

PostPosted: Sun Dec 12, 2004 10:22 am
Author: KaiRal Windspar
It is technically considered a PrC, right? Isn't that relevant?

PostPosted: Sun Dec 12, 2004 10:58 am
Author: Deider
Don't think so - I've checked for the Shifter class before using this function, and it worked. The standard PrCs have their own variables, like CLASS_TYPE_SHIFTER.

Tried this from another angle. The classes are also defined by integers - monk is 4, for example. Fuzz checked for me and the psion class seems to be #60. So I tried this out:

Code: Select all
void main()
{
object oPC = GetPCSpeaker();
int nCount = 1;
int nPsionCheck = GetClassByPosition(nCount, oPC);

while (nCount < 4)
{
    if (nPsionCheck = 60)
    {
        //do some secret gnome stuff
    }
    else {return;}
nCount++;
}
}


... but it didn't work. Am I just making a stupid coding mistake here? It's 6am, I should be sleeping, but I want to figure this out :)

PostPosted: Sun Dec 12, 2004 11:50 am
Author: Themicles
The TLK has absolutely nothing to do with this.

The classes 2da file is where you want to look for the number.

The constant name probably doesn't work unless it was added to the inc_constants. Check in there for it.

*was out drinking with friends last night, and woke up too damn early for no good reason*

-Themicles

PostPosted: Sun Dec 12, 2004 11:58 am
Author: Alustriel
Check if the file inc_constant contains the line (was an update some time ago), if so then the constant can be used:
const int CLASS_TYPE_PSIONICIST = 60;


This should work whether or not the constant is defined, although I rather use the constant for future maintenance

void main()
{
object oPC = GetPCSpeaker();
if (GetLevelByClass(60, oPC)>=1)
{
//do some secret gnome stuff
}

PostPosted: Sun Dec 12, 2004 1:06 pm
Author: dougnoel
Yeah, you need to have the file inc_constants.nss in your module. You also need to have it included in your script. If you don't have the file, you can extract it from a mod. (I have a current copy I can upload for you too.)

Please don't define the constant again. You can cause problems for someone later on if both those files get included in another script, or if one includes the otehrs. And the error message isn't very helpful when you declare a constant twice.

In three easy steps:
1.)Slap this line at the top of your script:
#include "inc_constants"
2.) Save the script.
3.) Then go to the constants tab on the right of the screen. Type in class_type in the search box and you will see a big list of all of them. You can find the Psion one (it will be bolded because it's not a Bioware const), double-click on it and it will be inserted into your code wherever your cursor is.

PostPosted: Mon Dec 13, 2004 7:40 am
Author: Deider
Thanks guys!! :D

EDIT: Hey doug, could you upload the current version? The one I found was from August of 2003. Or just mail it to me at deider@avlis.org. Thanks! :)

PostPosted: Mon Dec 13, 2004 6:41 pm
Author: dougnoel
Deider wrote:Thanks guys!! :D

EDIT: Hey doug, could you upload the current version? The one I found was from August of 2003. Or just mail it to me at deider@avlis.org. Thanks! :)

I'll get it to you this evening when I get home.