//void main() {} // Respawns oCreature after waiting nDelay heartbeats (default is 10 minutes) // uses the location they died at if iUseWaypoint is set to 0. Otherwise, the // number of waypoints to choose between (0 - n-1). If you specify 1 waypoint // it respawns the creature where it was initially placed // Make sure to tag waypoints "RespawnPoint"+ n>=0 or "YourWaypointTag"+ n>=0 // or whatever but don't forget the number at the end! void RespawnCreature (object oCreature=OBJECT_SELF, int nDelay=900, int iUseWaypoint=1, string sRespawnTag="RespawnPoint"); // usage: // // if (GetIsPC(GetEnteringObject()) && !GetLocalInt(OBJECT_SELF, "Populated")) // RepopArea(); // // Should be used in the OnEnter event of an area. // Make sure oArea is an area if you're not calling it from an area event. void RepopArea (object oArea=OBJECT_SELF); // usage: // // if (GetIsPC(GetExitingObject()) // && !GetIsPC(GetNearestCreatureToLocation(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, Location(OBJECT_SELF, Vector(10.0, 10.0, 1.0), 90.0)))) // DepopArea(); // // Should be used in the OnExit event of an area. // Make sure oArea is an area if you're not calling it from an area event. void DepopArea (object oArea=OBJECT_SELF); // used in RepopArea() to allow unique tags. void CheckTag(object oCreature, string sTag, location lWhere); // used in RepopArea() to keep track of wounded creatures so they don't heal // upon repopping. void CheckHP(object oCreature, int nHP); //This was used to remove duplicate creatures that were produced //when a pointer would become corrupted while cycling through. //Bioware has released a workaround though so this is obsolete. void RemoveDuplicates(object oCreature); //Called by RemoveDuplicates void DeleteDupes(object oCreature); void RespawnToRepop(string sResRef, location lLoc, string sTag, int nHP=0); void VoidCreateObject(string sResRef, location lLoc, string sTag, int nObjectType=OBJECT_TYPE_CREATURE) { CreateObject(nObjectType, sResRef, lLoc, FALSE, sTag); } void RespawnCreature (object oCreature=OBJECT_SELF, int nDelay=600, int iUseWaypoint=1, string sRespawnTag="RespawnPoint") { //Get the location, tag, and resref for the creature string sResRef=GetResRef(oCreature); string sTag=GetTag(oCreature); location lDiedHere=GetLocation(oCreature); location lSpawnedHere=GetLocalLocation(oCreature, "SpawnHere"); location lLoc; if(iUseWaypoint==0) { //respawn where the creature died lLoc=lDiedHere; } else if (iUseWaypoint==1) { //Respawn the creature where it was placed. lLoc=lSpawnedHere; } else { //otherwise, respawn at a random waypoint of the range and name specified int iRandom=Random(iUseWaypoint); //used GetNearestObject... so they don't respawn in another area object oRespawnPoint=GetNearestObjectByTag(sRespawnTag+IntToString(iRandom), oCreature); //if there's no such waypoint, just respawn where you died if (!GetIsObjectValid(oRespawnPoint))lLoc=lDiedHere; else lLoc=GetLocation(oRespawnPoint); } if(GetLocalInt(GetArea(oCreature), "Populated")) AssignCommand(GetModule(), DelayCommand(IntToFloat(nDelay), VoidCreateObject(sResRef, lLoc, sTag))); else AssignCommand(GetModule(), DelayCommand(IntToFloat(nDelay), RespawnToRepop(sResRef, lLoc, sTag))); } void RepopArea (object oArea=OBJECT_SELF) { int bPopulated=GetLocalInt(oArea, "Populated"); string sCreature; object oCreature; string sTag; int nCount; location lWhere; int nHP; int nTotal=GetLocalInt(oArea, "TotalMOBs"); for (nCount=1; nCount<=nTotal; nCount++) { sCreature=GetLocalString(oArea, "Creature"+IntToString(nCount)); sTag=GetLocalString(oArea, "Tag"+IntToString(nCount)); lWhere=GetLocalLocation(oArea, "Location"+IntToString(nCount)); nHP=GetLocalInt(oArea, "HP"+IntToString(nCount)); oCreature=CreateObject(OBJECT_TYPE_CREATURE, sCreature, lWhere, FALSE, sTag); DelayCommand(0.4, CheckHP(oCreature, nHP)); // DelayCommand(0.5, RemoveDuplicates(oCreature)); DeleteLocalString(oArea, "Creature"+IntToString(nCount)); DeleteLocalString(oArea, "Tag"+IntToString(nCount)); DeleteLocalLocation(oArea, "Location"+IntToString(nCount)); DeleteLocalInt(oArea, "HP"+IntToString(nCount)); } SetLocalInt(oArea, "Populated", TRUE); DeleteLocalInt(oArea, "TotalMOBs"); } void DepopArea(object oArea=OBJECT_SELF) { location lCheckPoint=Location(oArea, Vector(10.0, 10.0, 1.0), 90.0); object oCreature=GetNearestCreatureToLocation(PLAYER_CHAR_IS_PC, PLAYER_CHAR_NOT_PC, lCheckPoint); int nCount=1; int nTotal=GetLocalInt(oArea, "TotalMOBs"); location lWhere; int nHP; while (GetIsObjectValid(oCreature)) { lWhere=GetLocation(oCreature); nHP=GetCurrentHitPoints(oCreature); if (!GetIsPC(GetMaster(oCreature)) && !GetIsPC(GetMaster(GetMaster(oCreature))) && !GetIsPC(GetLocalObject(oCreature, "PCMaster")) ) { SetLocalString(oArea, "Creature"+IntToString(nCount), GetResRef(oCreature)); SetLocalString(oArea, "Tag"+IntToString(nCount), GetTag(oCreature)); SetLocalLocation(oArea, "Location"+IntToString(nCount), lWhere); SetLocalInt(oArea, "HP"+IntToString(nCount), nHP); AssignCommand(oCreature, SetIsDestroyable(TRUE)); SetPlotFlag(oCreature, FALSE); DestroyObject(oCreature); } nCount++; oCreature=GetNearestCreatureToLocation(PLAYER_CHAR_IS_PC, PLAYER_CHAR_NOT_PC, lCheckPoint, nCount); } nCount--; nTotal=nTotal+nCount; SetLocalInt(oArea, "TotalMOBs", nTotal); SetLocalInt(oArea, "Populated", FALSE); } void CheckTag(object oCreature, string sTag, location lWhere) { if (sTag!=GetTag(oCreature)) { CopyObject(oCreature, lWhere, OBJECT_INVALID, sTag); DestroyObject(oCreature, 0.1); } } void CheckHP(object oCreature, int nHP) { int nCurrentHP=GetCurrentHitPoints(oCreature); if (nHP==0) return; if (nHP