generated from Jaysyn/ModuleTemplate
38 lines
836 B
Plaintext
38 lines
836 B
Plaintext
/*
|
|
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);
|
|
|
|
}
|
|
|