Author Topic: Respawn object help?  (Read 391 times)

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
Respawn object help?
« on: December 29, 2010, 10:56:38 pm »


               I have a statue ..with this script in the ondeath.
question: If a PC smashes the statue it respawns ....BUT if it is destroyed by my other script when someone clicks on a door it does not respawn .
I need this statue to respawn after being destroyed .....




void RespawnObject(string sResRef, int iType, location lLoc) {
CreateObject(iType, sResRef, lLoc);
}
void main()
{
string sResRef = GetResRef(OBJECT_SELF);
int iType = GetObjectType(OBJECT_SELF);
// For creatures, save the location at spawn-time as a local location and
// use it instead. Otherwise, the creature will respawn where it died.
// No changes are required for placeables as they do not move (usually ;-)
location lLoc =GetLocation(OBJECT_SELF);
float fDelay = 10.0;  // 5 minute delay; adjust as desired
AssignCommand(GetModule(), DelayCommand(fDelay, RespawnObject(sResRef, iType, lLoc)));
}
 
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Respawn object help?
« Reply #1 on: December 29, 2010, 11:37:05 pm »


               

Knight_Shield wrote...

I have a statue ..with this script in the ondeath.
question: If a PC smashes the statue it respawns ....BUT if it is destroyed by my other script when someone clicks on a door it does not respawn .
I need this statue to respawn after being destroyed .....
 

I don't think the DestroyObject() function triggers a placeable's OnDeath event. You'll have to use something like this to destroy the statue:

object oStatue = GetObjectByTag("StatueTag");
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(GetCurrentHitPoints(oStatue)), oStatue);

-420
               
               

               
            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
Respawn object help?
« Reply #2 on: December 30, 2010, 12:02:38 am »


               It works really good ...thnx 420 ! ! !   This is for my exploding Monster Statues muwahaha