Skip to content

Respawn creature - On death

Hey guys, any way to respawn a creature on death? I know it is easily done by encounters, but I would like to make a Boss respawn after someone killed him. The problem is, this boss already has a script on his death, a "local var change" used to complete the quest.

Someone mentioned that it is possible to do on the "OnHeartbeat" of the area, can someone add more depth on how to do this?

Thanks o/

Comments

  • PhantomizerPhantomizer Member Posts: 76
    You could probably run an OnHeartbeat script that checks the area for the Boss to determine If It's spawned or not, If not, It'll check to see how long ago It was killed (I'm not sure this Is a possible function?) and It's been X amount of minutes since It was killed, It'll spawn him again.

    Might also be possible add a check to see if a PC Is In the area or not after the time check, so It doesn't spawn the boss, unless a PC Is In the area to help with lag.
  • TrueWarlordTrueWarlord Member Posts: 2
    edited March 2018
    Ok, I manage to make it works, but for some reason, the "ActionWait" function is not working, nor the "DelayCommand".
    Can someone help me? I want it to wait like 30 seconds before it respawns on my Waypoint.
    Here is my code:

    ----
    void main()
    {
    object oPC = GetLastKiller();
    if (!GetIsPC(oPC)) return;
    int nInt;
    nInt = GetLocalInt(oPC, "quest1");
    nInt += 1;
    SetLocalInt(oPC, "quest1", nInt);
    object oTarget;
    object oSpawn;
    location lTarget;
    oTarget = GetWaypointByTag("respawnteste");
    lTarget = GetLocation(oTarget);
    oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "bosstest", lTarget);
    }
    ----
  • squattingmonksquattingmonk Member Posts: 59
    edited March 2018
    ActionWait() and DelayCommand() will be ineffective in an OnDeath script because the dead creature can't execute those commands. Instead, you need to assign those commands to the module. Here's one way you could go about this:

    // Spawns the boss at our waypoint void SpawnBoss() { object oTarget = GetWaypointByTag("respawnteste"); location lTarget = GetLocation(oTarget); CreateObject(OBJECT_TYPE_CREATURE, "bosstest", lTarget); } void main() { object oPC = GetLastKiller(); if (!GetIsPC(oPC)) return; int nInt = GetLocalInt(oPC, "quest1"); SetLocalInt(oPC, "quest1", nInt + 1); AssignCommand(GetModule(), DelayCommand(30.0, SpawnBoss())); }
    Post edited by squattingmonk on
  • antirelicantirelic Member Posts: 20
    I've seen this done quiet effectively;

    OnDeath:. Create a spawner object at death location
    Spawner: creates the new creature and deletes itself

Sign In or Register to comment.