40 lines
1.4 KiB
Plaintext
40 lines
1.4 KiB
Plaintext
//
|
|
// Res_Heartbeat script
|
|
//
|
|
// Scan the immediate area for any creature in the same faction. If one exists and is dead, then
|
|
// resurrect it.
|
|
//
|
|
// Use a semaphore (res_semaphore) to prevent multiple calls.
|
|
//
|
|
void main()
|
|
{
|
|
float fMaxDistance = 15.0; // I won't resurrect anything further away than this.
|
|
float fResDelay = 2.0; // How long before I do something after resurrection starts.
|
|
location lSelf = GetLocation(OBJECT_SELF);
|
|
object oTarget;
|
|
|
|
//
|
|
// Don't bother if semaphore is already set or if I can't cast resurrection
|
|
//
|
|
if ((GetLocalInt(oTarget, "Res_Semaphore") != TRUE) && GetHasSpell(SPELL_RESURRECTION)) {
|
|
|
|
oTarget = GetFirstObjectInShape(SHAPE_SPHERE, fMaxDistance, lSelf, TRUE, OBJECT_TYPE_CREATURE);
|
|
|
|
while (GetIsObjectValid(oTarget)) {
|
|
|
|
if ((GetIsDead(oTarget)) && GetIsFriend(oTarget)) {
|
|
ClearAllActions();
|
|
ActionDoCommand(SetCommandable(FALSE));
|
|
ActionCastSpellAtObject(SPELL_RESURRECTION, oTarget);
|
|
SetLocalInt(oTarget, "Res_Semaphore", TRUE);
|
|
DelayCommand(fResDelay, SetCommandable(TRUE));
|
|
DelayCommand(fResDelay, DeleteLocalInt(oTarget, "Res_Semaphore"));
|
|
return;
|
|
}
|
|
|
|
oTarget = GetNextObjectInShape(SHAPE_SPHERE, fMaxDistance, lSelf, TRUE, OBJECT_TYPE_CREATURE);
|
|
}
|
|
}
|
|
|
|
}
|