// SP Reset Menu // Players can use this dialog script to reset their SP for a nominal fee. // Modified by Zunath #include "zzdlg_main_inc" #include "adv_include" #include "rwt_include" #include "inc_helper_funcs" const string RESPONSE_PAGE = "adv_reset_responses"; const string PAGE_MAIN = "main_page"; const string PAGE_QUESTIONS = "questions_page"; const string PAGE_RESET_SP = "reset_sp_page"; // Prototypes void MainPageInit(); void MainPageSelect(); void QuestionsPageInit(); void QuestionsPageSelect(); void ResetSPPageInit(); void ResetSPPageSelect(); void OnInit() { dlgChangeLabelNext("Next page"); dlgChangeLabelPrevious("Previous page"); dlgChangePage(PAGE_MAIN); dlgActivatePreservePageNumberOnSelection(); dlgActivateResetResponse(); } // Create the page void OnPageInit( string sPage ) { DeleteList( RESPONSE_PAGE, dlgGetSpeakingPC() ); if( sPage == PAGE_MAIN ) MainPageInit( ); else if(sPage == PAGE_QUESTIONS) QuestionsPageInit(); else if(sPage == PAGE_RESET_SP) ResetSPPageInit(); dlgSetActiveResponseList( RESPONSE_PAGE ); } // Handles any selection. void OnSelection( string sPage ) { if ( sPage == PAGE_MAIN ) MainPageSelect( ); else if(sPage == PAGE_QUESTIONS) QuestionsPageSelect(); else if(sPage == PAGE_RESET_SP) ResetSPPageSelect(); } void OnReset( string sPage ) { dlgChangePage( PAGE_MAIN ); dlgResetPageNumber( ); } void OnAbort( string sPage ) { DeleteList( RESPONSE_PAGE, dlgGetSpeakingPC() ); } void OnEnd( string sPage ) { DeleteList( RESPONSE_PAGE, dlgGetSpeakingPC() ); } void OnContinue( string sPage, int iContinuePage ) { } // Message handler void main() { dlgOnMessage(); } // Specific scripting starts here // MAIN PAGE START void MainPageInit( ) { object oPC = dlgGetSpeakingPC(); dlgSetPrompt("Looking to start fresh? I can help you unlearn the tactics you've chosen for a nominal fee."); dlgAddResponseAction(RESPONSE_PAGE, "I have some questions."); dlgAddResponseAction(RESPONSE_PAGE, "I'd like to reset my skill point allocation."); dlgDeactivateResetResponse(); dlgActivateEndResponse( "End" ); } void MainPageSelect( ) { if(dlgIsSelectionEqualToName("I have some questions.")) { dlgSetPrompt("What would you like to know?"); dlgChangePage(PAGE_QUESTIONS); } else if(dlgIsSelectionEqualToName("I'd like to reset my skill point allocation.")) { dlgChangePage(PAGE_RESET_SP); } } void QuestionsPageInit() { dlgAddResponseAction(RESPONSE_PAGE, "What do you mean by 'unlearn my tactics'?"); dlgAddResponseAction(RESPONSE_PAGE, "How much do you charge to reset my skill points?"); dlgAddResponseAction(RESPONSE_PAGE, "Is there a wait period in between resets?"); dlgAddResponseAction(RESPONSE_PAGE, "Do I lose anything?"); dlgActivateResetResponse("Back", ColorTokenBlue()); } void QuestionsPageSelect() { string sMessage; int iSelection = dlgGetSelectionIndex() + 1; switch(iSelection) { // What do you mean by 'unlearn my tactics'? case 1: { sMessage += "You have learned many different techniques for surviving this outbreak, right? What if I told you that you "; sMessage += "could be missing out on some more important skills?\n\n"; sMessage += "Like you, I've survived this outbreak and if there's one thing I have noticed it's the people who refuse to "; sMessage += "try new techniques that wind up getting killed.\n\n"; sMessage += "If you're interested in my services, I only charge a nominal fee.\n"; break; } // How much do you charge to reset my skill points? case 2: { sMessage += "I initially charge 2000. As you use more of my services, though, it becomes increasingly harder to reset the "; sMessage += "skills you have learned. For that reason, I charge another 500 for each additional time.\n\n"; sMessage += "Your first time using my services will be free!"; break; } // Is there a wait period in between resets? case 3: { sMessage += "My training is fairly intensive. I will not be able to reset your skills for 72 hours (real world time) after "; sMessage += "the reset has occurred. Once that wait period has passed you are more than welcome to use my services again.\n"; break; } // Do I lose anything? case 4: { sMessage += "Any skills you have increased with SP will be reset back to zero. All SP used to increase those attributes will be "; sMessage += "returned to you and you can redistribute them as you see fit.\n"; break; } } dlgSetPrompt(sMessage); } void ResetSPPageInit() { object oPC = dlgGetSpeakingPC(); object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE); int iTimelock = GetLocalInt(oDatabase, ADV_SP_RESET_COOLDOWN); int iUnixTime = RWT_GetUnixTimestamp(); // Time lock hasn't passed - inform player when they will be able to // reset their SP. if(iTimelock > iUnixTime) { string sDate = RWT_GetTimestampFromUnix(iTimelock); string sMessage = "I'm sorry but it's too soon for you to do another skill point reset. You need more time to recover from my services.\n\n"; sMessage += ColorTokenGreen() + "Next SP Reset Available: " + ColorTokenEnd() + sDate + "\n"; dlgSetPrompt(sMessage); } else { int iResetCount = GetLocalInt(oDatabase, ADV_SP_RESET_COUNT); int iCost = ADV_SP_RESET_INITIAL_COST + (ADV_SP_RESET_ADDITIONAL_COST * iResetCount); int iGold = GetGold(oPC); // This is the player's first time resetting his or her SP. It's free if the module designer // chose to implement it in the ADV_INCLUDE configuration section. if(GetLocalInt(oDatabase, ADV_SP_RESET_FIRST_TIME_USED) == FALSE && ADV_SP_RESET_FIRST_TIME_FREE) { iCost = 0; } string sMessage = "You're interested in resetting your skill point allocation?\n\n"; sMessage += "Before we continue with this, I need you to unequip all items or else my services will not work.\n\n"; sMessage += "It will also cost you " + IntToString(iCost) + " to perform this skill point reset.\n\n"; sMessage += "Are you sure you want to continue with this?\n"; dlgSetPrompt(sMessage); // PC doesn't have enough money if(iCost <= iGold && !GetIsDM(oPC)) { dlgAddResponseAction(RESPONSE_PAGE, "Yes, please reset my SP allocation. (Price: " + IntToString(iCost) + ")"); } } dlgActivateResetResponse("Back", ColorTokenBlue()); } void ResetSPPageSelect() { object oPC = dlgGetSpeakingPC(); object oDatabase = GetItemPossessedBy(oPC, PC_DATABASE); int iTimelock = GetLocalInt(oDatabase, ADV_SP_RESET_COOLDOWN); int iUnixTime = RWT_GetUnixTimestamp(); int iResetCount = GetLocalInt(oDatabase, ADV_SP_RESET_COUNT); int iCost = ADV_SP_RESET_INITIAL_COST + (ADV_SP_RESET_ADDITIONAL_COST * iResetCount); int iGold = GetGold(oPC); // DM's can't reset SP if(GetIsDM(oPC)) return; // Safety check - make sure they can't continue if the time lock hasn't passed if(iTimelock > iUnixTime) { FloatingTextStringOnCreature(ColorTokenRed() + "Cooldown has not passed. Please wait longer before doing that." + ColorTokenEnd(), oPC, FALSE); return; } // This is the player's first time resetting his or her SP. It's free if the module designer // chose to implement it in the ADV_INCLUDE configuration section. if(GetLocalInt(oDatabase, ADV_SP_RESET_FIRST_TIME_USED) == FALSE && ADV_SP_RESET_FIRST_TIME_FREE) { iCost = 0; } // PC doesn't have enough money. if(iGold < iCost) { FloatingTextStringOnCreature(ColorTokenRed() + "You don't have enough money to make that purchase." + ColorTokenEnd(), oPC, FALSE); return; } // We need to cycle through the PC's equipment slots. If anything is equipped we need to let them know to unequip the item // before doing an SP reset. int iLoop; for (iLoop = 0; iLoop < NUM_INVENTORY_SLOTS; iLoop++) { object oItem = GetItemInSlot(iLoop, oPC); if(GetBaseItemType(oItem) != BASE_ITEM_CREATUREITEM && GetIsObjectValid(oItem)) { FloatingTextStringOnCreature(ColorTokenRed() + "All items must be unequipped before you can do a skill point reset.", oPC, FALSE); return; } } int iCooldown = RWT_CreateCooldown(ADV_SP_RESET_COOLDOWN_UNIXTIME); SetLocalInt(oDatabase, ADV_SP_RESET_COOLDOWN, iCooldown); ReinitializePlayerCharacter(oPC, -1, 0.5, FALSE); // Take gold from player AssignCommand(oPC, TakeGoldFromCreature(iCost, oPC, TRUE)); // Increase the number of times a player has reset his or her SP SetLocalInt(oDatabase, ADV_SP_RESET_COUNT, iResetCount + 1); }