GetLevel

Moderator: Event DM

Post Reply
User avatar
Nighthawk4
Assist DM
Assist DM
Posts: 25898
Joined: Fri Feb 07, 2003 8:32 pm
Timezone: GMT
DM Avatar: DruEl
Location: The Home of the Bard of Avon
Contact:

GetLevel

Post by Nighthawk4 » Mon Aug 25, 2003 4:50 pm

I am trying to write a training Module.

I can set an NPC to give gold and XP to my PC.

However, whilst the gold can be a fixed amount each time, the XP would be better if related to the PC's level.

How do I get the PC's level?

Is it also possible to give a level, rather than work out how much XP is needed for the next level?

I know I have seen this somewhere in the Toolset. I have seen it done in other modules - and of course, the DM Client can do it.

How do I script this please?
Life is never as bad as you think it is, although that doesn't help at the time.
Orleron wrote:I think it's a fun idea if you can idiot-proof it. Problem is God always builds a better idiot. :P
User avatar
Jordicus
Team Member; Retired with Honors
Posts: 8042
Joined: Tue Jan 21, 2003 3:46 pm
Location: Whitehall, PA (GMT -4)
Contact:

Post by Jordicus » Mon Aug 25, 2003 4:58 pm

you could use either:

Code: Select all

int GetXP(
    object oCreature
);
or

Code: Select all

int GetCharacterLevel(
    object oTarget
);
Myk D'vor
Lord of Blithering Idiots
Posts: 111
Joined: Mon Feb 24, 2003 9:05 am

Post by Myk D'vor » Mon Aug 25, 2003 5:05 pm

The easiest way to get the total level of a PC is GetHitDice(oPC). This adds all the multi-class levels if there are any.

The easiest way to compute how much exp is needed for the NEXT level is:

int iCurLvl = GetHitDice(oPC);
int iXpNeeded = (iCurLvl*(iCurLvl+1)/2)*1000;
int iAward = iXpNeeded - GetXP(oPC);
GiveXPToCreature(oPC,iAward);

It may not look pretty, but it works perfectly, every time, and awards exactly enough XP to get to the next level. If you'd rather award an entire level, regardless of current XP (not advised) you just award iCurLvl*1000

I'd put in a check to reject people who are already level 20 from getting xp this way, but that's just me, you may want to leave it open-ended.

Myk D'Vor
Myk D'vor
Lord of Blithering Idiots
Posts: 111
Joined: Mon Feb 24, 2003 9:05 am

Post by Myk D'vor » Mon Aug 25, 2003 5:11 pm

GetCharacterLevel is not a function within NWN, Jordicus, sorry. GetCasterLevel is, but not usable for this, and GetLevelByClass and GetLevelByPosition both get specific levels of a multiclass character, not the total. GetHitDice is the way to go.

Myk
User avatar
Jordicus
Team Member; Retired with Honors
Posts: 8042
Joined: Tue Jan 21, 2003 3:46 pm
Location: Whitehall, PA (GMT -4)
Contact:

Post by Jordicus » Mon Aug 25, 2003 5:20 pm

funny.. it was listed in the NWN lexicon as a valid function.. :?

ah.. I see what the deal is. it requires: #include "NW_I0_GENERIC"

must be a custom functin routine or something..
Actually
Sage
Posts: 1823
Joined: Sat Dec 14, 2002 10:11 pm
Location: Red Zone: Cuba

Post by Actually » Mon Aug 25, 2003 8:21 pm

On a related note...

Is there a way to determine if a PC is of class X short of a nested if statement to check GetClassByPosition() for all three possible positions?

I'm looking to build triggers that certain classes will be exempt from, regardless of whether and when they multiclassed.

Bye Now,
Jerry Cornelius - Oh good, Ultima X. I was afraid for a minute that the corpse of my favorite series wasn't going to get completely raped...
User avatar
Nighthawk4
Assist DM
Assist DM
Posts: 25898
Joined: Fri Feb 07, 2003 8:32 pm
Timezone: GMT
DM Avatar: DruEl
Location: The Home of the Bard of Avon
Contact:

Post by Nighthawk4 » Mon Aug 25, 2003 9:04 pm

Myk D'vor wrote:The easiest way to get the total level of a PC is GetHitDice(oPC). This adds all the multi-class levels if there are any.

The easiest way to compute how much exp is needed for the NEXT level is:

int iCurLvl = GetHitDice(oPC);
int iXpNeeded = (iCurLvl*(iCurLvl+1)/2)*1000;
int iAward = iXpNeeded - GetXP(oPC);
GiveXPToCreature(oPC,iAward);

It may not look pretty, but it works perfectly, every time, and awards exactly enough XP to get to the next level. If you'd rather award an entire level, regardless of current XP (not advised) you just award iCurLvl*1000

I'd put in a check to reject people who are already level 20 from getting xp this way, but that's just me, you may want to leave it open-ended.

Myk D'Vor

This worked perfectly - thankyou.

One more problem - I am trying to use the ExploreAreaForPlayer function to reveal the area on the map, if the player has obtained a map - like on Avlis.

I would prefer a general script, so if you have a map of Area X, you get the Area X revealed when you enter it.

At the moment, I am just trying to reveal each area as I go into it. I am using GetArea, but not too sure how to identify the PC.

However, it is not working.

Any ideas please?
Life is never as bad as you think it is, although that doesn't help at the time.
Orleron wrote:I think it's a fun idea if you can idiot-proof it. Problem is God always builds a better idiot. :P
User avatar
maxinion
Team Member; Retired with Honors
Posts: 2778
Joined: Mon Mar 17, 2003 7:44 pm
DM Avatar: Andrinor
Location: Bay Area, CA
Contact:

Post by maxinion » Tue Aug 26, 2003 12:50 am

OnEnter for the area. GetEnteringObject(). Check if he has the map. Reveal if he does.
Post Reply