//------------------------------------------------------------------------------ // // reset_add // // Accepts a vote to reset the server and if enough votes have been submitted, // actiones the reset // //------------------------------------------------------------------------------ // // Created By: Nachos // Created On: 04-12-2003 // // Altered By: Michael Tuffin [Grug] // Altered On: 07-01-2004 // // Added to by Shayan on 19/01/2005 // //------------------------------------------------------------------------------ // // Known bugs/issues... // - Due to a change in the 1.61 patch module tag, title and filename must all // match for the reset to work // //------------------------------------------------------------------------------ // // Changelog... // Version: 001 (07-01-2004) // - Added ExitingComment() function to generate a random comment // - Added PreparePlayers() function to display the comment and fade to black // // Version: 000 (04-12-2003) // - Created and up and running // //------------------------------------------------------------------------------ float GA_RESET_VOTES_NEEDED = 5.0; //------------------------------------------------------------------------------ // Returns int with count of players on server int ServerPlayerCount(); // Returns a string comment to float over the player string ExitingComment(); // Prepares the players for reset void PreparePlayers(); //------------------------------------------------------------------------------ int ServerPlayerCount() { int nPCs = 0; object oPC = GetFirstPC(); while (GetIsObjectValid(oPC) == TRUE) { nPCs = nPCs + 1; oPC = GetNextPC(); } return nPCs; } void SuckEnergy(object oVoter) { float HitPoints = IntToFloat(GetCurrentHitPoints(oVoter)); effect EvilSuckEffect = EffectVisualEffect(VFX_FNF_SUMMON_EPIC_UNDEAD); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EvilSuckEffect, oVoter, 5.0); effect dmg = EffectDamage(FloatToInt(HitPoints/2), DAMAGE_TYPE_NEGATIVE, DAMAGE_POWER_ENERGY); ApplyEffectToObject(DURATION_TYPE_PERMANENT,dmg,oVoter); } //------------------------------------------------------------------------------ string ExitingComment() { switch (d20()) { case 1: return "Thank you come again..."; break; case 2: return "Darkness engulfs the lands that surround you..."; break; case 3: return "You feel dizzy, the world begins to spin..."; break; case 4: return "Spider sense, tingling..."; break; case 5: return "A change in the program..."; break; case 6: return "This feels familiar..."; break; case 7: return "So this is what Death feels like..."; break; case 8: return "This world has fallen! But from it's ashes shall arise a new Mortar..."; break; case 9: return "The time of Dark Moon has come... You have failed!"; break; case 10: return "Microsoft wishes to announce that they are not liable for the following Black Screen of Death... apparently their color is Blue."; break; case 11: return "Any last words...?"; break; case 12: return "White, Dark and Blood...?"; break; case 13: return "Alright... Who did that?"; break; case 14: return "So I says to Mabel I says..."; break; case 15: return "The meaning of life is..."; break; case 16: return "Mummy! I want my mummy!"; break; } return "It is the time for death and rebirth..."; } //------------------------------------------------------------------------------ void PreparePlayers() { if(!GetLocalInt(OBJECT_SELF, "STOP_RESET")) { ExportAllCharacters(); string sFloatyTextComment = ExitingComment(); object oPC = GetFirstPC(); while (GetIsObjectValid(oPC) == TRUE) { FloatingTextStringOnCreature(sFloatyTextComment, oPC, TRUE); DelayCommand(2.0, FadeToBlack(oPC, FADE_SPEED_MEDIUM)); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_METEOR_SWARM), oPC); oPC = GetNextPC(); } } } void ResetOrStop() { if(GetLocalInt(OBJECT_SELF, "STOP_RESET")) { SetLocalInt(OBJECT_SELF, "STOP_RESET", FALSE); return; } else { StartNewModule("Rhun"); } } void ShoutResetString() { if(!GetLocalInt(OBJECT_SELF, "STOP_RESET")) { SpeakString("The server shall be reset in one minute.", TALKVOLUME_SHOUT); } } void ReloadModule(object oMod) { SetLocalInt(oMod, "ResetTimer", TRUE); SpeakString("The server shall be reset in two minutes.", TALKVOLUME_SHOUT); DelayCommand(60.0, ShoutResetString()); DelayCommand(117.0, PreparePlayers()); DelayCommand(120.0, ResetOrStop()); } //------------------------------------------------------------------------------ void main() { object oUser = GetLastUsedBy(); object oMod = GetModule(); int iVotes = GetLocalInt(oMod, "Reset"); float ServerPlayers = IntToFloat(ServerPlayerCount()); int iPlayersNeeded = FloatToInt(GA_RESET_VOTES_NEEDED); //fail safe if(ServerPlayers > 12.0) { iPlayersNeeded = FloatToInt(ServerPlayers*0.5); } // How many people must be logged in at the time? if(!GetIsPC(oUser)) {return;} //Only one DM needs to do is touch the crystal for the reset to begin. if(GetIsDM(oUser) && !GetLocalInt(oMod, "ResetTimer")) { SpeakString("A module reload was initiated by: " + GetName(oUser), TALKVOLUME_SHOUT); ReloadModule(oMod); return; } else if (GetIsDM(oUser) && GetLocalInt(oMod, "ResetTimer")) { SetLocalInt(OBJECT_SELF, "STOP_RESET", TRUE); SetLocalInt(oMod, "ResetTimer", FALSE); SetLocalInt(oMod, "Reset", 0); SpeakString("The server reset process has been terminated by: " + GetName(oUser) + ". All player votes have been discarded, and previous voters cannot re-vote.", TALKVOLUME_SHOUT); return; } if ((!GetLocalInt(oMod, "ResetTimer")) && (ServerPlayerCount() >= iPlayersNeeded)) { if(!GetLocalInt(oMod, "Reset"+GetPCPublicCDKey(oUser))) { SuckEnergy(oUser); SetLocalInt(oMod, "Reset"+GetPCPublicCDKey(oUser), TRUE); SetLocalInt(oMod, "Reset", iVotes += 1); SpeakString("There are now "+ IntToString(GetLocalInt(oMod, "Reset"))+ " of " + IntToString(iPlayersNeeded) + " reset votes needed on the Crystal of Renewal.", TALKVOLUME_SHOUT); if (IntToFloat(GetLocalInt(oMod, "Reset")) >= GA_RESET_VOTES_NEEDED) //Edit this number to require more votes { ReloadModule(oMod); } } else { SpeakString("Your will is already known to the crystal... you cannot force it, nor can you undo it."); } } else { if (ServerPlayerCount() < iPlayersNeeded) FloatingTextStringOnCreature("There are not enough people in the world to begin it again", oUser, FALSE); else if(GetLocalInt(oMod, "ResetTimer")) FloatingTextStringOnCreature("The world is already in the process to begin anew.", oUser, FALSE); } } //------------------------------------------------------------------------------