generated from Jaysyn/ModuleTemplate
Initial Commit
Initial Commit.
This commit is contained in:
37
_module/nss/s_respawnself.nss
Normal file
37
_module/nss/s_respawnself.nss
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
s_respawnself - Respawn self
|
||||
*/
|
||||
|
||||
|
||||
void RespawnObject(string sTag, int iType, location lLoc);
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
string sTag = GetTag(OBJECT_SELF);
|
||||
int iType = GetObjectType(OBJECT_SELF);
|
||||
|
||||
/* use respawn location if defined otherwise respawn at death location */
|
||||
location lLoc = GetLocalLocation(OBJECT_SELF, "RESPAWN_LOCATION");
|
||||
if (!GetIsObjectValid(GetAreaFromLocation(lLoc)))
|
||||
lLoc = GetLocation(OBJECT_SELF);
|
||||
|
||||
float fDelay = GetLocalFloat(OBJECT_SELF, "RESPAWN_DELAY");
|
||||
if (fDelay <= 0.0)
|
||||
fDelay = 60.0; /* 1 minute */
|
||||
|
||||
AssignCommand(GetArea(OBJECT_SELF), DelayCommand(fDelay, RespawnObject(sTag, iType, lLoc)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RespawnObject(string sTag, int iType, location lLoc) {
|
||||
|
||||
// ResRef must be derivable from Tag
|
||||
string sResRef = GetStringLowerCase(GetStringLeft(sTag, 16));
|
||||
|
||||
CreateObject(iType, sResRef, lLoc);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user