FANDOM


These level up scripts are scripts that allow advancing player characters (PCs) based upon levels instead of experience points. The basis for these scripts is the formula converting a level to the number of experience points required for that level:

(level * (level - 1) / 2) * 1000

For example, a PC earns level 5 upon gaining (5*4/2)*1000 = 10,000 experience points.

The first script gives a PC enough experience to the take another level. If the PC already has enough experience, it will do nothing. In its current form, it would be the OnUsed event handler for a placeable. Hence, a player would use the placeable to advance a single level.

void main()
{
    object oPC = GetLastUsedBy();
    int nCurrentLevel = GetHitDice(oPC);
    int nGoalXP = (nCurrentLevel + 1) * nCurrentLevel * 500;

    if ( GetXP(oPC) < nGoalXP )
        SetXP(oPC,nGoalXP);
}

The next script advances a PC to a fixed level, provided the PC has not yet earned that level. This is also written as an OnUsed event handler. To change the target level, change the value of GOAL_LEVEL.

const int GOAL_LEVEL = 5;

void main()
{
    object oPC = GetLastUsedBy();
    int nGoalXP = GOAL_LEVEL * (GOAL_LEVEL - 1) * 500;

    if ( GetXP(oPC) < nGoalXP )
        SetXP(oPC, nGoalXP);
}

In other events Edit

To use this scripts in different events, GetLastUsedBy would need to be changed to a different function. For example, to make these scripts usable in a conversation (as an "Actions Taken" script) change that function to GetPCSpeaker.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.