//Created By Guile 5/5/08 //IMPORTANT//////////////////////////////////////////////////////////////////// //This is an include not an actual script (It has prototype functions in it!) //Function which you can use in any script!! Just..... //Be sure you place #include "setxp_inc" at the top of //any script you wish to utilize any function within this script. /////////////////////////////////////////////////////////////////////////////// //This is the ULTIMATE XP Include Script, it can do just about any function //you want it to do, and all you have to do is type in the function below //you want to use in your script and put #include "setxp_inc" //at the very top of the script your creating. /* Example Script - #include "setxp_inc" void main() { object oPC = GetPCSpeaker(); Relevel(oPC); } Yes, it's that simple and awesome! */ /////////////////////////////////////////////////////////////////////////////// //There are function below in green which are example of how you would //utilize each function. //I used oTarget instead of oPC, but you can use Take1Level(oPC); if you wish, //as you must define what oTarget is in your script, though oTarget can be //anything like oSpeaker, oPC, oNPC, oWhatever. =) //NOTE: I have tested releveling Palemaster & Red Dragon Disciples with this //script and they did not retain thier AC or Ability Bonuses from the class. //you should double check this yourself to verify it. /////////////////////////////////////////////////////////////////////////////// //Set this to FALSE if you DO NOT wish to utilize a Respawn Penalty! const int RESPAWN_PENALTY = TRUE; //Default = TRUE (Apply Penalty!) //This is the Respawn Penalty you can adjust it to your likings.. //The #'s below represent how much % Penalty you wish to apply! //This cannot be 0! const int GOLD_PENALTY = 3; //3% of total gold on PC const int XP_PENALTY = 10; //10% of XP (over the required min. for level)** // ** nXpPenalty represents the % of the Extra XP the PC has above //the required minimum XP for their current level, ie, if the PC is level 4 //and they have 8000 XP (They have 2000 extra, so it would take 3% of 2k) ////////////////////////////////////////////////////////////////////////// //************WARNING: DO NOT TOUCH ANYTHING BELOW!!!*******************// ////////////////////////////////////////////////////////////////////////// //Required include for Legendary Levels #include "hgll_const_inc" #include "nw_i0_plot" ////////////////////////////////////////////////////////////////////////// //PROTOTYPEs DEFINED ////////////////////////////////////////////////////////////////////////// //This function Take1Level(oTarget); will take 1 level from the Target. //It set's thier xp to the base required XP for the next lowest level. void Take1Level(object oTarget) { int cLvl = GetHitDice(oTarget); int nXP; switch (cLvl) { case 1: nXP = 0; break; case 2: nXP = 0; break; case 3: nXP = 1000; break; case 4: nXP = 3000; break; case 5: nXP = 6000; break; case 6: nXP = 10000; break; case 7: nXP = 15000; break; case 8: nXP = 21000; break; case 9: nXP = 28000; break; case 10: nXP = 36000; break; case 11: nXP = 45000; break; case 12: nXP = 55000; break; case 13: nXP = 66000; break; case 14: nXP = 78000; break; case 15: nXP = 91000; break; case 16: nXP = 105000; break; case 17: nXP = 120000; break; case 18: nXP = 136000; break; case 19: nXP = 153000; break; case 20: nXP = 171000; break; case 21: nXP = 190000; break; case 22: nXP = 210000; break; case 23: nXP = 231000; break; case 24: nXP = 263000; break; case 25: nXP = 276000; break; case 26: nXP = 300000; break; case 27: nXP = 325000; break; case 28: nXP = 351000; break; case 29: nXP = 378000; break; case 30: nXP = 406000; break; case 31: nXP = 435000; break; case 32: nXP = 465000; break; case 33: nXP = 496000; break; case 34: nXP = 528000; break; case 35: nXP = 561000; break; case 36: nXP = 595000; break; case 37: nXP = 630000; break; case 38: nXP = 666000; break; case 39: nXP = 703000; break; case 40: nXP = 741000; break; } SetXP(oTarget, nXP); } //The Function Below Give1Level(oTarget); gives the Target one level. //IMPORTANT: This function cannot be used with Take1Level(oTarget); //or it will delevel the target!!!! //I created this exlusively for the purose of my DM wand //and other scripts which only give the PC one level as a reward. void Give1Level(object oTarget) { int cLvl = GetHitDice(oTarget); int nXP; switch (cLvl) { case 1: nXP = 1000; break; case 2: nXP = 3000; break; case 3: nXP = 6000; break; case 4: nXP = 10000; break; case 5: nXP = 15000; break; case 6: nXP = 21000; break; case 7: nXP = 28000; break; case 8: nXP = 36000; break; case 9: nXP = 45000; break; case 10: nXP = 55000; break; case 11: nXP = 66000; break; case 12: nXP = 78000; break; case 13: nXP = 91000; break; case 14: nXP = 105000; break; case 15: nXP = 120000; break; case 16: nXP = 136000; break; case 17: nXP = 153000; break; case 18: nXP = 171000; break; case 19: nXP = 190000; break; case 20: nXP = 210000; break; case 21: nXP = 231000; break; case 22: nXP = 263000; break; case 23: nXP = 276000; break; case 24: nXP = 300000; break; case 25: nXP = 325000; break; case 26: nXP = 351000; break; case 27: nXP = 378000; break; case 28: nXP = 406000; break; case 29: nXP = 435000; break; case 30: nXP = 465000; break; case 31: nXP = 496000; break; case 32: nXP = 528000; break; case 33: nXP = 561000; break; case 34: nXP = 595000; break; case 35: nXP = 630000; break; case 36: nXP = 666000; break; case 37: nXP = 703000; break; case 38: nXP = 741000; break; case 39: nXP = 780000; break; case 40: nXP = GetHitDice(oTarget) + 40000; break; } SetXP(oTarget, nXP); } //This function below Relevel(oTarget), will relevel a Creature minus //50 Gold & XP / Level (They must have the cost of gold or nothing happens! //This function can go in almost any script!(Define oTarget in that script!) //Can go in OnClick / OnUsed / OnEnter (whichever event you wish to use it in) //Example: Relevel(oPC); (That's all you need to relevel the PC!) void Relevel(object oTarget) { int nLvl = GetHitDice(oTarget); int nGold = nLvl * 50; int nCCXP = GetXP(oTarget); SetLocalInt(oTarget, "pc_exact_xp", nCCXP); int gXP = GetLocalInt(oTarget, "pc_exact_xp"); if(GetGold(oTarget)>nGold) { TakeGoldFromCreature(nGold, oTarget, TRUE); SetXP(oTarget, 0); DelayCommand(1.0, GiveXPToCreature(oTarget, gXP)); } else { SendMessageToPC(oTarget, "You do not have enough gold to relevel!"); } } //The Function Relevel1(oTarget) will take 1 level from the Target and give //back thier orginal XP. This script does not cause xp loss whatsoever. void Relevel1(object oTarget) { int nCCXP; nCCXP = GetXP(oTarget); SetLocalInt(oTarget, "pc_exact_xp", nCCXP); int gXP = GetLocalInt(oTarget, "pc_exact_xp"); Take1Level(oTarget); DelayCommand(1.0, SetXP(oTarget, gXP)); } //The Function Relevel3(oTarget) will take 3 levels from the Target and give //back thier orginal XP. This script does not cause xp loss whatsoever. void Relevel5(object oTarget) { int nCCXP; nCCXP = GetXP(oTarget); SetLocalInt(oTarget, "pc_exact_xp", nCCXP); int gXP = GetLocalInt(oTarget, "pc_exact_xp"); Take1Level(oTarget); Take1Level(oTarget); Take1Level(oTarget); Take1Level(oTarget); Take1Level(oTarget); DelayCommand(1.0, SetXP(oTarget, gXP)); } //The Function Relevel5(oTarget) will take 5 levels from the Target and give //back thier orginal XP. This script does not cause xp loss whatsoever. void Relevel10(object oTarget) { int nGold = GetHitDice(oTarget) * 50; if(GetGold(oTarget) >= nGold) { int nCCXP; nCCXP = GetXP(oTarget); SetLocalInt(oTarget, "pc_exact_xp", nCCXP); int gXP = GetLocalInt(oTarget, "pc_exact_xp"); Take1Level(oTarget); Take1Level(oTarget); Take1Level(oTarget); Take1Level(oTarget); Take1Level(oTarget); Take1Level(oTarget); Take1Level(oTarget); Take1Level(oTarget); Take1Level(oTarget); Take1Level(oTarget); DelayCommand(1.0, SetXP(oTarget, gXP)); } } //This function penalizes a the person repsawning it goes in the (see below) //Example of Function: ApplyRespawnPenalty(oPC); (onplayerrespawn) event. //They cannot lose a level with this function. //They lose 20% of the excessive XP over the XP required for thier current level. //They lose 10% of thier gold. //Note This is a good script if your using Legendary Levels :) void ApplyRespawnPenalty(object oTarget) { int cLvl = GetHitDice(oTarget); int nCurrentXP = GetXP(oTarget); int nXP; //We need this switch to determine what xp they must keep.. switch (cLvl) { case 1: nXP = 0; break; case 2: nXP = 1000; break; case 3: nXP = 3000; break; case 4: nXP = 6000; break; case 5: nXP = 10000; break; case 6: nXP = 15000; break; case 7: nXP = 21000; break; case 8: nXP = 28000; break; case 9: nXP = 36000; break; case 10: nXP = 45000; break; case 11: nXP = 55000; break; case 12: nXP = 66000; break; case 13: nXP = 78000; break; case 14: nXP = 91000; break; case 15: nXP = 105000; break; case 16: nXP = 120000; break; case 17: nXP = 136000; break; case 18: nXP = 153000; break; case 19: nXP = 171000; break; case 20: nXP = 190000; break; case 21: nXP = 210000; break; case 22: nXP = 231000; break; case 23: nXP = 263000; break; case 24: nXP = 276000; break; case 25: nXP = 300000; break; case 26: nXP = 325000; break; case 27: nXP = 351000; break; case 28: nXP = 378000; break; case 29: nXP = 406000; break; case 30: nXP = 435000; break; case 31: nXP = 465000; break; case 32: nXP = 496000; break; case 33: nXP = 528000; break; case 34: nXP = 561000; break; case 35: nXP = 595000; break; case 36: nXP = 630000; break; case 37: nXP = 666000; break; case 38: nXP = 703000; break; case 39: nXP = 741000; break; case 40: nXP = 780000; break; } if(nCurrentXP>=XP_REQ_LVL41) { if(nCurrentXP>=XP_REQ_LVL41 && nCurrentXP=XP_REQ_LVL42 && nCurrentXP=XP_REQ_LVL43 && nCurrentXP=XP_REQ_LVL44 && nCurrentXP=XP_REQ_LVL45 && nCurrentXP=XP_REQ_LVL46 && nCurrentXP=XP_REQ_LVL47 && nCurrentXP=XP_REQ_LVL48 && nCurrentXP=XP_REQ_LVL49 && nCurrentXP=XP_REQ_LVL50 && nCurrentXP=XP_REQ_LVL51 && nCurrentXP=XP_REQ_LVL52 && nCurrentXP=XP_REQ_LVL53 && nCurrentXP=XP_REQ_LVL54 && nCurrentXP=XP_REQ_LVL55 && nCurrentXP=XP_REQ_LVL56 && nCurrentXP=XP_REQ_LVL57 && nCurrentXP=XP_REQ_LVL58 && nCurrentXP=XP_REQ_LVL59 && nCurrentXP=XP_REQ_LVL60) { nXP = XP_REQ_LVL60; } } int aXP = nCurrentXP; int bXP = aXP - nXP; //Subtract thier minimum XP needed for the level int dXP = bXP * XP_PENALTY; //Give 100 XP to Prevent the divide by 0 error int nResults = dXP / 100; //Break thier xp up into a percentile int nPenalty = aXP - nResults; //The application of the penalty int nGold = GetGold(oTarget); int oGold = nGold * GOLD_PENALTY; int pGold = oGold/100; //(calculate 2%) //The XP Penalty SetXP(oTarget, nPenalty); //The Gold Penalty AssignCommand(oTarget, TakeGoldFromCreature(pGold, oTarget, TRUE)); }