Frictional Games Forum (read-only)

Full Version: Resetting level upon death
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I placed a Checkpoint at the beginning of one of my maps, expecting the level to be reset to what it was when you crossed it on the event of your death. The checkpoint works like I assume it should (the death hint shows), but the level is just as it was when the player dies. Which is a huge problem because the player's path is blocked continually as he progresses through the level.

How can i get everything to be reset when the player spawns?
When you placed the checkpoint, didn't you make use of its callback feature? It does not sound like you did.
I didn't because I don't know what to put under it to make the map reset.

Callback syntax: void MyFunc(string &in asName, int alCount)


Count is 0 on the first checkpoint load!


I see this on the scripts page but don't know what I'm supposed to actually put there.

CheckPoint ("", "PlayerStartArea_1", "reset", "DeathHint", "run");

void reset("?????", 0)
{
?????
}
(03-28-2012, 04:28 AM)Damascus Wrote: [ -> ]or do I have to go through undoing every single thing that's changed in the map?

Pretty much.
(NEVER MIND, I'M DUMB)

Well it took an absolute novel's worth of additional scripting but I was able to have everything in the level reset, except for entities that have been moved by the player. Thanks for your help!
Alright, facing a new problem on this. The level successfully resets so long as all my timers have finished running, but if the player dies while the timer is still running, it keeps going and blocks the player from advancing. It's a timer sequence, so I wonder if that has something to do with it.

Spoiler below!
void CheckPointActive(string &in asParent, string &in asChild, int alState)
{
CheckPoint ("", "PlayerStartArea_1", "reset", "Ch01Misc", "run");
}

void reset(string &in asName, int alCount)
{
SetPropActiveAndFade("slime_6way_3", false, 1.0f); //disable slime
SetPropActiveAndFade("slime_anim_wall_3", false, 1.0f);
SetPropActiveAndFade("slime_pile_2", false, 1.0f);
SetEntityActive("AreaGuardianKill_lump_2", false); // disable kill area
FadeLightTo("PointLight_2", 0.0f, 0.0f, 0.0f, 0.0f, -1, 1); // disable guardian light
[REPEAT ABOUT A MILLION TIMES]
RemoveEntityCollideCallback("Player", "AreaStartGuardian"); // resetting callbacks
AddEntityCollideCallback("Player", "AreaStartGuardian", "CollideStartGuardian", true, 1);
[ALSO REPEAT A BUNCH]
RemoveTimer("TimerGuardian"); // end timers
RemoveTimer("TimerGuardian2");
RemoveTimer("TimerGuardian3");
RemoveTimer("RestartMusic");
RemoveTimer("CollapseTimer");
SetLocalVarInt("GuardianStep", 0); // reset timer vars
SetLocalVarInt("GuardianStep2", 0);
SetSwingDoorClosed("prison_section_1", true, false); // close all opened doors
SetSwingDoorClosed("cellar_wood01_4", true, false);
SetSwingDoorClosed("cellar_wood01_2", true, false);
}

void CollideStartGuardian(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("SlimeLoopOnPlayer","25_slime_loop.snt", "Player", 2, false);
AddTimer("TimerGuardian", 0, "TimerGuardian");
}

void CollideStartGuardian2(string &in asParent, string &in asChild, int alState)
{
AddTimer("TimerGuardian2", 0, "TimerGuardian2");
}

void TimerGuardian(string &in asTimer)
{
AddLocalVarInt("GuardianStep", 1);
float fEventSpeed = 1.6f;

switch(GetLocalVarInt("GuardianStep")) {
case 1:
SetPropActiveAndFade("slime_6way_3", true, 1.0f);
SetPropActiveAndFade("slime_anim_wall_3", true, 1.0f);
SetPropActiveAndFade("slime_pile_2", true, 1.0f);
SetEntityActive("AreaGuardianKill_lump_2", true);
FadeLightTo("PointLight_2", 0.8f, 0.0f, 0.0f, 0.0f, -1, 1);
StartScreenShake(0.1f, RandFloat(0.15f,0.6f), 0, 0.1);
CreateParticleSystemAtEntity("","ps_guardian_appear_explosion.ps", "AreaGuardianEffectsFloor_lump_2", false);
CreateParticleSystemAtEntity("","ps_guardian_appear_explosion.ps", "AreaGuardianEffectsLWall_lump_2", false);
CreateParticleSystemAtEntity("","ps_guardian_appear_explosion.ps", "AreaGuardianEffectsRWall_lump_2", false);
PlaySoundAtEntity("", "25_guardian_slime_appear.snt", "AreaGuardianKill_lump_2", 0, false);
break;
[GOD IN HEAVEN, MORE REPETITION]
}
if(GetLocalVarInt("GuardianStep") < 27) AddTimer("guardian", fEventSpeed, "TimerGuardian");
}

void TimerGuardian2(string &in asTimer)
{
AddLocalVarInt("GuardianStep2", 1);
float fEventSpeed = 1.0f;

switch(GetLocalVarInt("GuardianStep2")) {
case 1:
CreateParticleSystemAtEntity("","ps_break_cavein.ps", "AreaGuardianCavein", false);
StartScreenShake(0.1f, RandFloat(0.15f,0.6f), 0, 0.1);
PlaySoundAtEntity("", "explosion_rock_large.snt", "AreaGuardianCavein", 0, false);
break;
[BOLLY, ANOTHER ROUND OF CASES MY FRIEND]
}
if(GetLocalVarInt("GuardianStep2") < 11) AddTimer("guardian2", fEventSpeed, "TimerGuardian2");
}

So yeah, that's everything. Like I said, if the two sequenced timers have stopped running, everything resets the way it should and runs again properly when I go through the level a second time. However, if the player dies while the sequences are still going, they are still going when the level resets too.