80 lines
1.9 KiB
Plaintext
80 lines
1.9 KiB
Plaintext
////////////////////////////////////
|
|
//Created by Genisys / Guile 5/08/08
|
|
////////////////////////////////////
|
|
/*
|
|
|
|
XP Bank (Not an original concept)
|
|
|
|
This script goes in the Action Taken
|
|
event of my DM Conversation to store
|
|
XP in the database for the Player to
|
|
retrieve with any character, in case
|
|
they totally messed up their
|
|
character.
|
|
(Cost 1% of XP and 500 Gp / Level)
|
|
|
|
*/
|
|
////////////////////////////////////
|
|
|
|
void main()
|
|
{
|
|
//Declare Major Variables
|
|
object oPC;
|
|
oPC = GetPCSpeaker();
|
|
int cGold = GetGold(oPC);
|
|
int nLvl = GetHitDice(oPC);
|
|
int nGold = nLvl * 500;
|
|
int cXP = GetXP(oPC);
|
|
int pXP = (cXP / 100) * 99; //99%
|
|
|
|
|
|
//If the PC has enough gold...
|
|
if(cGold>nGold)
|
|
{
|
|
//If the PC has at least 100 XP (Required to prevent an error)
|
|
if(pXP > 99)
|
|
{
|
|
//Note this is set for multiplayer, use the script setxp2 for single player!
|
|
string pCD = GetPCPublicCDKey(oPC, FALSE);
|
|
|
|
//Just in case the PC loses thier xp/gold let's write a log entry!
|
|
WriteTimestampedLogEntry("The following Player Has Used the DM Globe" +
|
|
"to store XP / " + GetPCPlayerName(oPC) + "/ " + IntToString(pXP));
|
|
|
|
int rXP = GetCampaignInt("STORED_XP", GetPCPublicCDKey(oPC), GetModule());
|
|
int tXP = rXP + pXP;
|
|
//Store thier XP information first in a nwn database file!
|
|
SetCampaignInt("STORED_XP", GetPCPublicCDKey(oPC), tXP, GetModule());
|
|
|
|
//Take all the player's XP
|
|
SetXP(oPC, 0);
|
|
|
|
//Let's make sure the character is saved!!!!
|
|
ExportSingleCharacter(oPC);
|
|
|
|
//Then boot the PC..
|
|
DelayCommand(5.0, BootPC(oPC));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//If they PC doesn't have enough XP..
|
|
if(pXP<99)
|
|
{
|
|
FloatingTextStringOnCreature("You don't have enough XP!", oPC);
|
|
}
|
|
//If the PC doesn't have enough gold..
|
|
else if(cGold<nGold)
|
|
{
|
|
FloatingTextStringOnCreature("You don't have enough gold!", oPC);
|
|
}
|
|
//In case of errors..
|
|
else
|
|
{
|
|
FloatingTextStringOnCreature("Please notify a DM's there is an error" +
|
|
" with the XP Bank.", oPC);
|
|
}
|
|
}
|
|
//Script End
|
|
}
|