GetLevel
Moderator: Event DM
- Nighthawk4
- 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
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?
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.
- Jordicus
- Team Member; Retired with Honors
- Posts: 8042
- Joined: Tue Jan 21, 2003 3:46 pm
- Location: Whitehall, PA (GMT -4)
- Contact:
you could use either:
or
Code: Select all
int GetXP(
object oCreature
);
Code: Select all
int GetCharacterLevel(
object oTarget
);
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
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
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...
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...
- Nighthawk4
- 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:
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.