Level up script

Level up Script
This is a long over-due question that needs answered. There are several ways to do this, I will post 2 simple scripts here that can be modified to your own needs.

The basic formula for gaining a level is this, (((CurrentLevel +1) * CurrentLevel) / 2) * 1000 i.e. To Gain 5th level from 4th level the PC would need, (((4 + 1) * 4) / 2) * 1000 = 10,000 XP points needed for 5th level.

Here is a Script that will allow you to level up 1 level each time an object is used.

void main {   object oPC = GetLastUsedBy; int nCurrentL = GetHitDice(oPC); int nXP = (((nCurrentL + 1)*nCurrentL)/2)*1000; SetXP(oPC,nXP); }

The next script is a script that will set your level to 5 as long as you are already less than level 5. You can change the int nLevelMax to what ever you want the max level to be.

void main {   object oPC = GetLastUsedBy; int nCurrentL = GetHitDice(oPC); int nLevelMax = 5; if(nCurrentL < nLevelMax) {       int nXP = ((nLevelMax*(nLevelMax - 1))/2)*1000; SetXP(oPC,nXP); } }

Again this is in a OnUsed of an object. If you would like to use it in a conversation then change this line, object oPC = GetLastUsedBy; to this, object oPC = GetPCSpeaker; and place it in a "Actions Taken" script node of your conversation.