The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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
Curious Hio, Scripting questions. (Current: Checkpoints.)
Mina Darsh Offline
Member

Posts: 227
Threads: 24
Joined: Sep 2010
Reputation: 0
#1
Curious Hio, Scripting questions. (Current: Checkpoints.)

Figured that I might have more questions about scripting in the feature, so I pretty much made one topic in which I'm planning to ask all my scripting related questions, hence the title. Smile

Anyway, I'm currently struggling with checkpoints. I'm including the full script at the bottom of this post, but first what I wish to do and what I have achieved so far.

What does the script actually do now.

The script makes an enemy spawn when the player enters a script zone named "ScriptArea_1", at least, not right away, first a door which is wide open from the start slams shut, and after 2 seconds 'mister_moody' the Grunt spawns and starts to patrol to the room. If 'mister_moody' succesfully finishes his routine, the script area "AreaGruntCheckedRoom" he leaves resets his path and leads him to the level door. Also "ScriptArea_2" is made active which causes 'mister_moody' to be set non-active after a second if he touches the area. Now this all goes like planned, but now it comes...

What does the script not do or do wrong now.

Now I made a checkpoint of "PlayerStartArea_1", in hope that when the player interrupts 'mister_moody's' patrol for coffee and gets killed by him, that the majority of the encounter gets reset and can be performed all over again to the letter. Now the following goes wrong: Firstly, the door named "mansion_1" gets reset, but is now closed instead of wide open. And, when the player enters the enemy trigger area, 'mister_moody' is spawned but gets caught by "ScriptArea_2" and immediately despawns when the timer is finished. This I find to be odd as the checkpoint function should deactivate "ScriptArea_2" but I guess "AreaGruntCheckedRoom" still tries to activate the second script area as it has detected 'mister_moody' leaving already. At least, this I think is happening, but I cannot find out how to tell "AreaGruntCheckedRoom" to stop activating "ScriptArea_2" and wait for 'mister_moody' to enter and activate "ScriptArea_2" again when he leaves.

Can anyone perhaps help?

Edit: Forgot to mention, the enemy 'mister_moody' spawns at "ScriptArea_2", that's why the area needs to be deactivated until 'mister_moody' has moved out of it.

Edit 2: Made some mistakes in this post with the Script Areas, should be correct now, sorry if it confused anyone... Blush

Spoiler below!
void CheckPoint01(string &in asName, int alCount)
{
    {
    ResetProp("mansion_1"); ResetProp("rolled_up_carpet_1");
    
    SetEntityActive("ScriptArea_2", false);
    SetMoveObjectState("mansion_1", 1);
    //AddTimer("HelpTimer", 0.5, "ResetHelper");
    AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
    AddEntityCollideCallback("mister_moody", "AreaGruntCheckedRoom", "CollideAreaGruntCheckedRoom", true, -1);
    AddEntityCollideCallback("mister_moody" , "ScriptArea_2" , "GoPoof" , false , 1);
    }
}

//void ResetHelper(string &in asTimer)
//{
    //{
    //}
//}

////////////////////////////
// Rawr! Scary monster comin'!
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
    {
    //SetEntityActive("mister_moody", true);
    SetSwingDoorClosed("mansion_1", true, false);
    PlaySoundAtEntity("doorclosed", "door_mansion_close.snt", "mansion_1", 0.2f, false);
    PlaySoundAtEntity("scare","react_scare.snt", "Player", 0.5f, false);
    CreateParticleSystemAtEntity("breakps", "ps_hit_wood", "ScriptArea_3", false);
    AddTimer("YayAnotherTimer", 2.0f, "SpawnMisterMoody");
    GiveSanityDamage(20.0f, true);
    PlayMusic("dan_grunt", false, 0.8f, 0, 0, false);
    AddEnemyPatrolNode("mister_moody", "PathNodeArea_1", 3, "");
    AddEnemyPatrolNode("mister_moody", "PathNodeArea_2", 0, "");
    }
}

////////////////////////////
//Make Mister Moody leave.
void CollideAreaGruntCheckedRoom(string &in asParent, string &in asChild, int alState)
{
    {
    ClearEnemyPatrolNodes("mister_moody");
    AddEnemyPatrolNode("mister_moody", "PathNodeArea_3", 0, "");
    SetEntityActive("ScriptArea_2", true);
    }
}

void GoPoof(string &in asParent , string &in asChild , int alState)
{
    {
    AddTimer("YayATimer", 1.0f, "BeGone");
    }
}

void SpawnMisterMoody(string &in asTimer)
{
    {
    SetEntityActive("mister_moody", true);
    }
}

void BeGone(string &in asTimer)
{
    {
    SetEntityActive("mister_moody", false);
    PlaySoundAtEntity("doorgruntleave","10_open_door.snt", "level_wood_1", 0.5, false);
    }
}

////////////////////////////
// Run first time starting map
void OnStart()
{
    {
    
    CheckPoint("check01","PlayerStartArea_1", "CheckPoint01", "Hints", "Death_Test");
    SetEntityActive("ScriptArea_2", false);
    AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
    AddEntityCollideCallback("mister_moody", "AreaGruntCheckedRoom", "CollideAreaGruntCheckedRoom", true, -1);
    AddEntityCollideCallback("mister_moody" , "ScriptArea_2" , "GoPoof" , false , 1);
    }
}

////////////////////////////
// Run when entering map
void OnEnter()
{
    {
    PlayMusic("02_amb_safe", true, 0.7f, 5, 0, true);
    PreloadParticleSystem("ps_hit_wood");
    
    PreloadSound("door_mansion_close"); PreloadSound("react_scare");
    }
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

(This post was last modified: 04-16-2011, 09:29 PM by Mina Darsh.)
04-16-2011, 08:49 PM
Find


Messages In This Thread
Curious Hio, Scripting questions. (Current: Checkpoints.) - by Mina Darsh - 04-16-2011, 08:49 PM



Users browsing this thread: 1 Guest(s)