Server Totals
M'Chek - (3)
Visimontium - (2)
Wilderness - (0)
Ferrell - (0)
Elysia - (0)
Le'Or - (0)
Deglos - (0)
Underdark - (0)
Mikona - (0)
Total players: 5
Gallery
  • Winter Ball 2015
    Album name: DM Events
    Uploaded by: Ronan
    Uploaded: Sat Jan 03, 2015 4:38 pm

Links Menu

GetLevel

Moderators: Nighthawk4, Dungeon Masters

GetLevel

PostAuthor: 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


Please visit:
Avlis UK, ACE Forum and SATF Forum

Image
User avatar
Nighthawk4
Eldest DM
Eldest DM
 
Posts: 23898
Images: 2
Joined: Fri Feb 07, 2003 8:32 pm
Location: The Home of the Bard of Avon
Timezone: GMT
DM Avatar: DruEl

PostAuthor: 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
);
User avatar
Jordicus
Team Member; Retired with Honors
 
Posts: 8048
Joined: Tue Jan 21, 2003 3:46 pm
Location: Whitehall, PA (GMT -4)

PostAuthor: 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

PostAuthor: 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

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

PostAuthor: 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..
User avatar
Jordicus
Team Member; Retired with Honors
 
Posts: 8048
Joined: Tue Jan 21, 2003 3:46 pm
Location: Whitehall, PA (GMT -4)

PostAuthor: 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...

Actually
Sage
 
Posts: 1823
Joined: Sat Dec 14, 2002 10:11 pm
Location: Red Zone: Cuba

PostAuthor: 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


Please visit:
Avlis UK, ACE Forum and SATF Forum

Image
User avatar
Nighthawk4
Eldest DM
Eldest DM
 
Posts: 23898
Images: 2
Joined: Fri Feb 07, 2003 8:32 pm
Location: The Home of the Bard of Avon
Timezone: GMT
DM Avatar: DruEl

PostAuthor: maxinion » Tue Aug 26, 2003 12:50 am

OnEnter for the area. GetEnteringObject(). Check if he has the map. Reveal if he does.
User avatar
maxinion
Team Member; Retired with Honors
 
Posts: 2780
Joined: Mon Mar 17, 2003 7:44 pm
Location: Bay Area, CA
DM Avatar: Andrinor


Return to NWN Scripting

Who is online

Registered users: Bing [Bot], Google [Bot]