//:://////////////////////////////////////////////////////////////////////////// //:: Sir Elric's Simple Creature Respawns - SE v2.0 //:: FileName - se_respawn_inc //:://////////////////////////////////////////////////////////////////////////// /* - Place any creatures from the stock or custom palette in your world They will then respawn in that exact location when killed. - Encounter creatures will not be effected by this respawn code - Respawn timer by default is set to 6 - 15 mins in the nw_c2_default7 OnDeath script i.e. SE_DoCreatureRespawn(5, 10); *(5)= 5 standard minutes *(10)= 1 to 10 random minutes or SE_DoCreatureRespawn(2, 0); *(2)= 2 standard minutes *(0)= 0 random minutes Adjust the timer to suit your module. - Tag a creature with _NSP to skip the respawn code eg. NW_GOBLINA_NSP - Optional from SE v1.8 onwards. Adding the local variables RESPAWN_MINUTES and/or RESPAWN_RANDOM, to a creature will override the standard respawn timer settings. Good for boss mobs. If no local variables are set on a creature, the standard respawn timer settings are used(thanks to Andi001 for the idea). - SE v1.9 changes: 1) Code optimization 2) DM spawned mobs will not respawn as they did in older versions Add this line inside the void main() of your OnModuleLoad script: DelayCommand(MOD_LOAD_DELAY, SetLocalInt(GetModule(), "ORIGINAL_PLACED_MOBS", TRUE)); (Or simply use the OnModuleLoad script in this package - x2_mod_def_load) Set the const float, MOD_LOAD_DELAY, below to suit your module (Set to 5 mins by default = 300.0) - SE v2.0 modified to include the new 1.69 horse code */ //:://////////////////////////////////////////////////////////////////////////// //:: Created By: Sir Elric //:: Created On: 17th February, 2004 //:: Updated On: 20th July, 2008 //:://////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // CONSTANTS // ----------------------------------------------------------------------------- const float MOD_LOAD_DELAY = 300.0; // Set this to allow for the time it takes, // for your module to load // Set to (5) mins by default // (300.0 = (5) minutes) // Mobs spawned after this timer will, // NOT respawn when killed. // This allows for DM spawned mobs that, // won't keep continually respawning // ----------------------------------------------------------------------------- // PROTOTYPES // ----------------------------------------------------------------------------- // Respawn mob at original placed location void SE_RespawnObject(int nType, string sResRef, location lLoc, string sNewTag, int nMinutes, int nRandom); // Respawn creature in nMinutes plus nRandom minutes // nMinutes - Minutes till respawn // nRandom - Random minutes(1 to nRandom are added to nMinutes) void SE_DoCreatureRespawn(int nMinutes, int nRandom); // ----------------------------------------------------------------------------- // FUNCTIONS // ----------------------------------------------------------------------------- void SE_RespawnObject(int nType, string sResRef, location lLoc, string sNewTag, int nMinutes, int nRandom) { object oTemp = CreateObject(nType, sResRef, lLoc, FALSE, sNewTag); if(nMinutes > 0 ) SetLocalInt( oTemp, "RESPAWN_MINUTES", nMinutes); if(nRandom > 0 ) SetLocalInt( oTemp, "RESPAWN_RANDOM", nRandom ); SetLocalInt(oTemp, "PLACED", 1); } void SE_DoCreatureRespawn(int nMinutes, int nRandom) { int nType = GetObjectType(OBJECT_SELF); string sRef = GetResRef(OBJECT_SELF); string sTag = GetTag(OBJECT_SELF); location lLoc = GetLocalLocation(OBJECT_SELF, "spawn"); float fFacing = GetFacing(OBJECT_SELF); int nEncounter = GetIsEncounterCreature(OBJECT_SELF); if(nEncounter) return; int nTemp = GetLocalInt(OBJECT_SELF, "RESPAWN_MINUTES"); if(nTemp) nMinutes = nTemp; nTemp = GetLocalInt(OBJECT_SELF, "RESPAWN_RANDOM"); if(nTemp) nRandom = nTemp; if (GetIsObjectValid(GetAreaFromLocation(lLoc))) { DeleteLocalInt(OBJECT_SELF, "spawn"); } else { lLoc = GetLocation(OBJECT_SELF); } // Standard delay time in minutes float fDelay = IntToFloat(nMinutes) * 60.0; // Add random delay time in minutes(if set) if(nRandom) fDelay = (Random(nRandom + 1)* 60) + fDelay; // Set the respawn AssignCommand(GetModule(), DelayCommand(fDelay, SE_RespawnObject(nType, sRef, lLoc, sTag, nMinutes, nRandom))); } // void main(){}