Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Checkpoint help
Dominic0904 Offline
Member

Posts: 63
Threads: 14
Joined: Apr 2011
Reputation: 0
#1
Checkpoint help

Hey there,

Basically I was wondering how do you get a checkpoint to reload your progress back to what it was when you actually triggered the checkpoint?
An example;

I enter the maze, the door locks and it spawns the Brute, I walk forward, trigger the checkpoint and afterwards I open a lot of doors in the maze, collect a key and then get killed by the Brute.
When the checkpoint loads, all the doors are still open, the brute is gone and I still possess the key.

Here is the relevant script for that area:

Quote://When CellarChase is called, it created a timer called "PreLookTimer" that lasts .4 seconds, it also
//locks "CellarDoor_01" and plays a door slam sound
//NOTE: ADD IN VOICE OVER AND ADJUST THE TIMERS TO MATCH THE VOICE OVERS
void CellarChase(string &in asParent, string &in asChild, int alState)
{

AddTimer("PreLookTimer", 0.4f, "PreLookTimer");
SetSwingDoorLocked("CellarDoor_01", true, false);
PlaySoundAtEntity("", "scare_slam_door", "CellarDoor_01", 0, false);

}

//Once PreLookTimer is finished, it forces the player to look at "CellarDoor_01", disables player movement
//and creates another timer called "LookAtDoorTimer" that lasts for 2 seconds
void PreLookTimer(string &in asTimer)
{
StartPlayerLookAt("CellarDoor_01", 5, 5, "");
SetPlayerActive(false);
AddTimer("LookAtDoorTimer", 2, "LookAtDoorTimer");


}

//Once LookAtDoorTimer has finished, it allows the player to move again and stops the player from being
//forced to look at "CellarDoor_01". It then sets "CellarBrute_01" to active and shows the brute the
//player's position. Lastly, the trigger area "BruteDisappear_01" is set to active so that the player
//can collide with it.
void LookAtDoorTimer(string &in asTimer)
{
StopPlayerLookAt();
SetPlayerActive(true);
SetEntityActive("CellarBrute_01", true);
SetEntityActive("BruteDisappear_01", true);
SetEntityActive("Checkpoint_2", true); //< SETS THE TRIGGER AREA TO ACTIVE
/////////////////THESE SCREEN EFFECTS STOP IF THE PLAYER LOOKS AT THE BRUTE////////////////
FadeRadialBlurTo(0.03f, 1);
FadeSepiaColorTo(0, 4);
FadeImageTrailTo(0.02f, 1);
///////////////////////////////////////////////////////////////////////////////////////////

AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_1", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_2", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_3", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_4", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_5", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_6", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_7", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_8", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_9", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_10", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_11", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_12", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_13", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_14", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_15", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_16", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_17", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_18", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_19", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_20", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_21", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_22", 0, "");
AddEnemyPatrolNode("CellarBrute_01", "BrutePatrolNode_23", 0, "");
}

void SecondCheckpoint(string &in asParent, string &in asChild, int alState)
{
/////PLAYS A SOUND WHEN THE PLAYER WALKS INTO THE TRIGGER AREA, TO TEST IF IT WORKS////
PlaySoundAtEntity("", "unlock_door", "Player", 0, false);
/////CHECKPOINT 1, IF THE PLAYER DIES THEY ARE RESPAWNED AT PLAYER START POSITION "CHECKPOINTSPAWN_1"/
CheckPoint ("", "CheckpointSpawn_2", "", "Checkpoint_2_Death_Message", "MazeRoomDeath");


}



void LevelEndKey_1(string &in EntityName, string &in Type)
{
if(Type == "OnPickup")
{

SetSwingDoorLocked("CellarDoor_01", false, false);
}
}


So how would I go about it so that when the checkpoint reloads, it would reload the map and the player's progress in the state that it was meant to, such as the doors being closed, the Brute still roaming the area and the player not having the key any more.

I've searched around on the forums and I can't seem to find anything related to my problem. If you want me to post other parts of my script, just ask.
Thanks.
04-24-2013, 06:01 PM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#2
RE: Checkpoint help

Try this:
PHP Code: (Select All)
//Create a checkpoint, as you have already, and set the callback function //Function(string &in asName, int alCount)

//For example,

void CheckPointCallback(string &in asNameint alCount)
{
 
//Now, you want the enemy to respawn, the key to be removed from the player's inventory and placed back in its original spot, right?

         
if(HasItem("yourkey"//or GetEntityExists("enemyname"), use whichever works
         
{
          
//You'll probably have to re-add the pickup and collide callbacks

          
SetEntityActive("enemyname",false); //I'm pretty sure the enemy will "remember" its initial spot, so deactivating it here and reactivating it in a callback doesn't matter
          
RemoveItem("yourkey");
          
//Unlock/relock the doors?
          
CreateEntityAtArea("keyname(same one)","file for key +.ent","area to create it at",false); //Spawns another key. I *believe* keeping the
// same name will allow you to use it like the original key

        
}


Hopefully this gives you a general idea. It's pretty rough, but play around with it.

Also, I'm sorry if this fails to answer the problem you were having. My head hurts pretty bad today.



*edit* why is the page stretching? -.-

RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ
(This post was last modified: 04-25-2013, 03:41 AM by Tomato Cat.)
04-24-2013, 07:16 PM
Find
Dominic0904 Offline
Member

Posts: 63
Threads: 14
Joined: Apr 2011
Reputation: 0
#3
RE: Checkpoint help

I managed remove the key and respawn it. But I got a few problems. I have tried adding the callback which was only this;
PHP Code: (Select All)
AddEntityCollideCallback("Player""LockCellarDoor_01""CellarChase"true1); 

That's the callback that triggers the door to lock and makes the Brute active (check the script in my first post under "CellarCase")

And also, I can't get the doors to close again, this is what I put for the doors

PHP Code: (Select All)
SetSwingDoorClosed("prison_*"truefalse); 

(the asterisk is so that it closes all the doors with the name "prison_" and whatever number is at the end of them. But I also tried with just "prison_1" and it didn't work at all.

I don't need to lock the initial door because that already reloads as being locked for some reason.
04-24-2013, 09:01 PM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#4
RE: Checkpoint help

Are you saying that you can't re-add the CellarChase callback? If so, I would check that everything is spelled the same, and make sure all your parameters/arguments match.

As for SetSwingDoorClosed, I would, again, make sure that the names of your doors are in fact named "prison_#" in the editor. (I make this mistake all the time!)

Do you mean that the door stays locked after the checkpoint function is called? In your CellarChase function, you're locking it with SetSwingDoorLocked. Perhaps you aren't unlocking it when the checkpoint function is called?

If you wish, you can send me the hps and map file so I could take a better look.

RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ
(This post was last modified: 04-24-2013, 11:08 PM by Tomato Cat.)
04-24-2013, 11:08 PM
Find
Dominic0904 Offline
Member

Posts: 63
Threads: 14
Joined: Apr 2011
Reputation: 0
#5
RE: Checkpoint help

Yeah, I add it back and then does nothing, it doesn't reset the "Lock door, spawn brute and enable checkpoint" scene.

I bolded the callback, is it because I set it to be destroyed after being triggered once? I don't think that would be the case because I changed
it to false and it didn't do anything. It still does not trigger when I walk through it the second time round (when the checkpoint loads after dying)

Quote:void ReloadCheckpoint2(string &in asName, int alCount)
{
if(HasItem("LevelEndKey_1"))
{
SetSwingDoorClosed("prison_*", true, false);
AddEntityCollideCallback("Player", "LockCellarDoor_01", "CellarChase", true, 1);
SetEntityActive("CellarBrute_01", false);
RemoveItem("LevelEndKey_1");
CreateEntityAtArea("LevelEndKey_1", "key_laboratory.ent", "RespawnCellarKey", false);
}
}


As for the doors, all my doors are named the exact same name. But it still doesn't work Sad

And the door at the beginning I was talking about. How the scene plays out is like this;

Player opens door to Maze

Steps into a trigger area which forces the player to look at the entrance door, locks that door, then after a timer has triggered it spawns a brute to patrol the area.

The player can walk a few steps forward to then trigger the checkpoint to save.

I included my .hps if what I am saying is too confusing haha. All the comments are for my Markers as this is my university project. There is a large comment that says "ALL THE SCRIPT FOR THE MAZE", that is the section which I am talking about.
https://dl.dropboxusercontent.com/u/2282...ceHall.hps

Thanks Smile
04-25-2013, 02:13 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#6
RE: Checkpoint help

Is your script area's name called "LockCellarDoor_1"?

EDIT: I also noticed that some of the check point is wrong. Make sure you follow this.
PHP Code: (Select All)
CheckPoint (stringasNamestringasStartPosstringasCallbackstringasDeathHintCatstringasDeathHintEntry); 
asName - Name of the checkpoint.
asStartPos - the PlayerStartArea of your position.
asCallback - The callback called.
asDeathHintCat - The category of the death message.
asDeathHintEntry - The entry of the death message. The entry must be in the same category as the death hint category.

"Veni, vidi, vici."
"I came, I saw, I conquered."
(This post was last modified: 04-25-2013, 03:00 PM by PutraenusAlivius.)
04-25-2013, 02:33 PM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#7
RE: Checkpoint help

Could you perhaps post a download link for your .map file? It would help if I also had the map file.


If not, then one thing you could try is changing this:

PHP Code: (Select All)
CheckPoint ("""CheckpointSpawn_2""ReloadCheckpoint2""Checkpoint_2_Death_Message""MazeRoomDeath"); 

To something like this:

PHP Code: (Select All)
CheckPoint("Checkpoint2""CheckpointSpawn_2""ReloadCheckpoint2""Checkpoint_2_Death_Message""MazeRoomDeath"); 

I'm not so sure adding a name will matter..But hey, troubleshooting. =p

RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ
04-25-2013, 02:51 PM
Find
Dominic0904 Offline
Member

Posts: 63
Threads: 14
Joined: Apr 2011
Reputation: 0
#8
RE: Checkpoint help

(04-25-2013, 02:33 PM)JustAnotherPlayer Wrote: Is your script area's name called "LockCellarDoor_1"?

EDIT: I also noticed that some of the check point is wrong. Make sure you follow this.
PHP Code: (Select All)
CheckPoint (stringasNamestringasStartPosstringasCallbackstringasDeathHintCatstringasDeathHintEntry); 
asName - Name of the checkpoint.
asStartPos - the PlayerStartArea of your position.
asCallback - The callback called.
asDeathHintCat - The category of the death message.
asDeathHintEntry - The entry of the death message. The entry must be in the same category as the death hint category.


The Script area is called LockCellarDoor_01, not LockCellarDoor_1.


(04-25-2013, 02:33 PM)Mr Credits Wrote: Could you perhaps post a download link for your .map file? It would help if I also had the map file.


Yeah sure, bit of derp of my part haha
https://dl.dropboxusercontent.com/u/2282...ceHall.map

Tried adding Checkpoint2 into the first string but it didn't change anything. Doors still open, callback does happen when you walk through the trigger area.
(This post was last modified: 04-25-2013, 03:59 PM by Dominic0904.)
04-25-2013, 03:58 PM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#9
RE: Checkpoint help

Post the actual .map file, not the text one. =p

RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ
04-25-2013, 04:14 PM
Find
Dominic0904 Offline
Member

Posts: 63
Threads: 14
Joined: Apr 2011
Reputation: 0
#10
RE: Checkpoint help

Sorry! Should of tested it first haha, this one should work.
https://dl.dropboxusercontent.com/u/2282...ceHall.zip
04-25-2013, 04:32 PM
Find




Users browsing this thread: 1 Guest(s)