Page 1 of 1
GetLevel
Posted: Mon Aug 25, 2003 4:50 pm
by Nighthawk4
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?
Posted: Mon Aug 25, 2003 4:58 pm
by Jordicus
you could use either:
or
Code: Select all
int GetCharacterLevel(
object oTarget
);
Posted: Mon Aug 25, 2003 5:05 pm
by Myk D'vor
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
Posted: Mon Aug 25, 2003 5:11 pm
by Myk D'vor
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
Posted: Mon Aug 25, 2003 5:20 pm
by Jordicus
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..
Posted: Mon Aug 25, 2003 8:21 pm
by Actually
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...
Posted: Mon Aug 25, 2003 9:04 pm
by Nighthawk4
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?
Posted: Tue Aug 26, 2003 12:50 am
by maxinion
OnEnter for the area. GetEnteringObject(). Check if he has the map. Reveal if he does.