Frictional Games Forum (read-only)
How to make grunt respawn when player dies? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: How to make grunt respawn when player dies? (/thread-21904.html)



How to make grunt respawn when player dies? - Zokrar - 06-23-2013

At the moment, if my player dies, all the enemies in the map will not spawn when the player re-spawns. How do I make the enemies spawn every life?


RE: How to make grunt respawn when player dies? - Your Computer - 06-23-2013

Using ResetProp on the monster followed by SetEntityActive should work.


RE: How to make grunt respawn when player dies? - The chaser - 06-23-2013

Or you can make a checkpoint. If you post your script, I'll put it for you Smile


RE: How to make grunt respawn when player dies? - Zokrar - 06-23-2013

Ooh, ok sweet. Here's the script.

Edit: the formatting kind of went to shit. Want me to post the file to download, or can you work from this?

Spoiler below!
Code:
void OnStart(){    if(ScriptDebugOn())    {        GiveItemFromFile("lantern", "lantern.ent");    }            //****** ATTACKING GRUNTS *********        SetEntityActive("gruntTwo", false);    SetEntityPlayerLookAtCallback("gruntOne", "GruntOne", false);    SetEntityPlayerLookAtCallback("gruntTwo", "GruntTwo", false);    AddLocalVarInt("Grunt1State", 1);    AddLocalVarInt("Grunt2State", 1);        //****** ATTACKING GRUNTS *********            SetSkyBoxActive(true);       SetSkyBoxTexture("nighttime.dds");                     PlayMusic("ending_alexander.ogg", true, 0.30, 2.00, 5, true);}



//****** ATTACKING GRUNTS *********void GruntOne(string &in asEntity, int alState) {    if(alState == 1)     {         if(GetLocalVarInt("Grunt1State") == 1)        {              SetEntityActive("gruntOne", false);              CreateParticleSystemAtEntity("electro1", "ps_electro_charge.ps", "gruntOne", true);              PlaySoundAtEntity("grunt1", "15_bang.snt", "Player", 0, false);              AddTimer("GruntOneSpawnDelay", 3, "GruntOneTimer");              SetLocalVarInt("Grunt1State", 0);          }     }}
void GruntTwo(string &in asEntity, int alState) {    if(alState == 1)    {        if(GetLocalVarInt("Grunt2State") == 1)        {                SetEntityActive("gruntTwo", false);            CreateParticleSystemAtEntity("electro2", "ps_electro_charge.ps", "gruntTwo", true);            PlaySoundAtEntity("grunt2", "15_bang.snt", "Player", 0, false);            AddTimer("GruntTwoSpawnDelay", 3, "GruntTwoTimer");            SetLocalVarInt("Grunt2State", 0);        }    }}
void GruntOneTimer(string &in asTimer){    SetEntityActive("gruntTwo", true);    DestroyParticleSystem("electro2");    SetLocalVarInt("Grunt1State", 1);    ShowEnemyPlayerPosition("gruntTwo");}
void GruntTwoTimer(string &in asTimer){    ShowEnemyPlayerPosition("gruntOne");    SetEntityActive("gruntOne", true);    DestroyParticleSystem("electro1");    SetLocalVarInt("Grunt2State", 1);}//****** ATTACKING GRUNTS *********




RE: How to make grunt respawn when player dies? - The chaser - 06-23-2013

(06-23-2013, 03:16 PM)Zokrar Wrote: Ooh, ok sweet. Here's the script.

Edit: the formatting kind of went to shit. Want me to post the file to download, or can you work from this?

Spoiler below!
Code:
void OnStart(){    if(ScriptDebugOn())    {        GiveItemFromFile("lantern", "lantern.ent");    }            //****** ATTACKING GRUNTS *********        SetEntityActive("gruntTwo", false);    SetEntityPlayerLookAtCallback("gruntOne", "GruntOne", false);    SetEntityPlayerLookAtCallback("gruntTwo", "GruntTwo", false);    AddLocalVarInt("Grunt1State", 1);    AddLocalVarInt("Grunt2State", 1);        //****** ATTACKING GRUNTS *********            SetSkyBoxActive(true);       SetSkyBoxTexture("nighttime.dds");                     PlayMusic("ending_alexander.ogg", true, 0.30, 2.00, 5, true);}



//****** ATTACKING GRUNTS *********void GruntOne(string &in asEntity, int alState) {    if(alState == 1)     {         if(GetLocalVarInt("Grunt1State") == 1)        {              SetEntityActive("gruntOne", false);              CreateParticleSystemAtEntity("electro1", "ps_electro_charge.ps", "gruntOne", true);              PlaySoundAtEntity("grunt1", "15_bang.snt", "Player", 0, false);              AddTimer("GruntOneSpawnDelay", 3, "GruntOneTimer");              SetLocalVarInt("Grunt1State", 0);          }     }}
void GruntTwo(string &in asEntity, int alState) {    if(alState == 1)    {        if(GetLocalVarInt("Grunt2State") == 1)        {                SetEntityActive("gruntTwo", false);            CreateParticleSystemAtEntity("electro2", "ps_electro_charge.ps", "gruntTwo", true);            PlaySoundAtEntity("grunt2", "15_bang.snt", "Player", 0, false);            AddTimer("GruntTwoSpawnDelay", 3, "GruntTwoTimer");            SetLocalVarInt("Grunt2State", 0);        }    }}
void GruntOneTimer(string &in asTimer){    SetEntityActive("gruntTwo", true);    DestroyParticleSystem("electro2");    SetLocalVarInt("Grunt1State", 1);    ShowEnemyPlayerPosition("gruntTwo");}
void GruntTwoTimer(string &in asTimer){    ShowEnemyPlayerPosition("gruntOne");    SetEntityActive("gruntOne", true);    DestroyParticleSystem("electro1");    SetLocalVarInt("Grunt2State", 1);}//****** ATTACKING GRUNTS *********

Doesn't matter, got the script from your other thread:

Put a ScriptArea right before all your stuff happens.

void OnStart()
{
if(ScriptDebugOn())
{
GiveItemFromFile("lantern", "lantern.ent");
}

AddEntityCollideCallback(“Player”, “ScriptArea_1”, “Restart”, true, 1);

///The ScriptArea_1 is right before all your things happen

void Restart(string &in asParent, string &in asChild, int alState)
{
CheckPoint (“FirstCheckpoint”, “PlayerStartArea_1”, “Happening”, “DeathCategory”, “Deathtext”);
}

void Happening(string &in asName, int alCount)
{
SetEntityPlayerLookAtCallback("gruntOne", "GruntOne", false);
SetEntityPlayerLookAtCallback("gruntTwo", "GruntTwo", false);
AddLocalVarInt("Grunt1State", 1);
AddLocalVarInt("Grunt2State", 1);
}


//****** ATTACKING GRUNTS *********

SetEntityPlayerLookAtCallback("gruntOne", "GruntOne", false);
SetEntityPlayerLookAtCallback("gruntTwo", "GruntTwo", false);
AddLocalVarInt("Grunt1State", 1);
AddLocalVarInt("Grunt2State", 1);

//****** ATTACKING GRUNTS *********


SetSkyBoxActive(true);
SetSkyBoxTexture("nighttime.dds");


PlayMusic("ending_alexander.ogg", true, 0.30, 2.00, 5, true);
}




//****** ATTACKING GRUNTS *********
void GruntOne(string &in asEntity, int alState)
{
if(alState == 1)
{
if(GetLocalVarInt("Grunt1State") == 1)
{
SetEntityActive("gruntOne", false);
CreateParticleSystemAtEntity("electro1", "ps_electro_charge.ps", "gruntOne", true);
PlaySoundAtEntity("grunt1", "15_bang.snt", "Player", 0, false);
AddTimer("GruntOneSpawnDelay", 3, "GruntOneTimer");
SetLocalVarInt("Grunt1State", 0);
}
}
}

void GruntTwo(string &in asEntity, int alState)
{
if(alState == 1)
{
if(GetLocalVarInt("Grunt2State") == 1)
{
SetEntityActive("gruntTwo", false);
CreateParticleSystemAtEntity("electro2", "ps_electro_charge.ps", "gruntTwo", true);
PlaySoundAtEntity("grunt2", "15_bang.snt", "Player", 0, false);
AddTimer("GruntTwoSpawnDelay", 3, "GruntTwoTimer");
SetLocalVarInt("Grunt2State", 0);
}
}
}

void GruntOneTimer(string &in asTimer)
{
SetEntityActive("gruntTwo", true);
DestroyParticleSystem("electro2");
SetLocalVarInt("Grunt1State", 1);
}

void GruntTwoTimer(string &in asTimer)
{
SetEntityActive("gruntOne", true);
DestroyParticleSystem("electro1");
SetLocalVarInt("Grunt2State", 1);
}
//****** ATTACKING GRUNTS *********


This should work.

Maybe this helps you.

http://wiki.frictionalgames.com/hpl2/tutorials/scripting/checkpoints_using_scriptarea_s