//Created By Guile 4/24/08
//This script will take 50 gp & XP / level and then allow them to relevel.

//Note Palemaster & Red Dragon Disciples should never be allowed to
//Complete relevel their character due to a bug which allows them to keep stats!
//The conversation this is attached to prevents them from choosing the option.

void main()
{
object oPC;
oPC = GetPCSpeaker();

int nCCXP;
nCCXP = GetXP(oPC);

SetLocalInt(oPC, "pc_exact_xp", nCCXP);
GetLocalInt(oPC, "pc_exact_xp");

int nLvl;
nLvl = GetHitDice(oPC);


int bXP;
bXP = nLvl * 50;

int vXP;
vXP = nCCXP - bXP;

int bGold;
bGold = nLvl * 50;

int aGold;
aGold = GetGold(oPC);

if(aGold >= bGold)
{
TakeGoldFromCreature(bGold, oPC);

SetXP(oPC, 0);
SetXP(oPC, vXP);
}

else
{
TakeGoldFromCreature(bGold, oPC);

string sMsg;
sMsg = "You didn't have enough gold to relevel, so you lost gold anyway!";
SendMessageToPC(oPC, sMsg);
}

}