Author Sticky: Post Working Scripts Here
Calidarien Posted: Friday, 21 June 05:57PM
1. Script Name: cal_level_up
2. What it does: Sets the speaker's XP to the exact amount for the next level, regardless of whether the speaker has actually used the GUI to level up. Also provides gold.
3. Notes: Be sure to call this script from a conversation, because that is how it figures out which PC to gift. The gold given is based on the DMG, which has some quirks, but those values can be changed easily. One possible change is to use some fraction of the NWN maximums.
4. The Script itself
NWScript:
//Script: cal_level_up

//Author: Albert Shih (Calidarien)

//Version: v1.0, 2002-06-21

//Usage: Calling this script from a conversation will set the speaker's

//  experience and gold to the next level

//Notes: I used DMG values for the gold appropriate for each level.

//

//Convert experience to effective level

int XPtoLevel(int nXP) {

  return FloatToInt((1+sqrt(1+4.*nXP/500))/2);

}

//

//Retrieve the DMG values of starting gold appropriate for a certain level

int Gold(int nLevel) {

  switch (nLevel) {

    case 1: return 100;

    case 2: return 900;

    case 3: return 2700;

    case 4: return 5400;

    case 5: return 9000;

    case 6: return 13000;

    case 7: return 19000;

    case 8: return 27000;

    case 9: return 36000;

    case 10: return 49000;

    case 11: return 66000;

    case 12: return 49000;

    case 13: return 110000;

    case 14: return 150000;

    case 15: return 200000;

    case 16: return 260000;

    case 17: return 340000;

    case 18: return 440000;

    case 19: return 580000;

    case 20: return 760000;

  }

  return 0;

}

//

void main()

{

  object player = GetPCSpeaker();

  int nLevel = XPtoLevel(GetXP(player));

  if (nLevel != 20) {

    SetXP(player, nLevel*(nLevel+1)*500);

    GiveGoldToCreature(player, Gold(nLevel+1)-Gold(nLevel));

  } else {

    GiveXPToCreature(player, 1);

    GiveGoldToCreature(player, 1);

  }

}