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
Mina Darsh Offline
Member

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

No one knows yet? Kinda stuck with this so any help would be appreciated. Smile
04-17-2011, 08:33 AM
Find
Mina Darsh Offline
Member

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

Sorry, but, bump!
04-19-2011, 09:39 AM
Find
Mooserider Offline
Member

Posts: 64
Threads: 11
Joined: Jan 2011
Reputation: 2
#4
RE: Curious Hio, Scripting questions. (Current: Checkpoints.)

It seems to me that there are a few problems in the script.
When you put a // before a function, it treats it as a comment on the script and won't do anything.
Also, just so you know, you don't need the two "{"s and "}"s for functions, only one, Like:

void Collide_Callback(string &in asParent, string &in asChild, int alState)
{
//Functions here
}

If removing the //s before some of the functions doesn't help, then I don't know, sorry. As for having the door wide open, however, The thing that comes to mind for me is to force the door open, like this:

SetSwingDoorClosed("mansion_1", false, false);
SetSwingDoorDisableAutoClose("mansion_1", true);
AddPropImpulse("mansion_1", X, Y, Z, "world");

Replace X,Y,and Z with the coordinates that the force comes from. Check the coordinates of the door in the editor and play around with it a bit to get it right.

To close the door, just use:

SetSwingDoorClosed("mansion_1", true, false);
SetSwingDoorDisableAutoClose("mansion_1", false);

Hope it helps.

Working on a FC: "Don't Let Go "
04-19-2011, 11:47 AM
Find
Mina Darsh Offline
Member

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

The commented out functions are meant to be like that, I was trying around and when I'm not sure if I want it removed entirely yet, I comment it out to disable it, just didn't get to removing them before posting the example here. Will try the door though, thanks, still need to figure out why the checkpoint is being an arse.
04-19-2011, 05:30 PM
Find
Mooserider Offline
Member

Posts: 64
Threads: 11
Joined: Jan 2011
Reputation: 2
#6
RE: Curious Hio, Scripting questions. (Current: Checkpoints.)

Ah, sorry about that. I wish you luck getting it to work, I hate having problems that take ages to solve.

Working on a FC: "Don't Let Go "
04-19-2011, 11:23 PM
Find
Mina Darsh Offline
Member

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

Hmm, I want to poke Frictional's script expert for this, but I bet they're busy. :o
04-20-2011, 07:56 AM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#8
RE: Curious Hio, Scripting questions. (Current: Checkpoints.)

For the scriptarea_2, you're setting it as false before the new callback for it is made. Put the callback before it. Also, try taking out the SetMoveObjectState. If you're resetting the prop, you shouldn't need it.
(This post was last modified: 04-20-2011, 12:51 PM by MrBigzy.)
04-20-2011, 12:46 PM
Find
Mina Darsh Offline
Member

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

Gah, still did not solve it, weird thing is, 'mister_moody' sometimes succesfully tries to attack the player again, and sometimes exits the door that's supposed to be deactivated until he walks into the area named 'AreaGruntCheckedRoom' before finishing his routine. It seems to happen randomly...

Here's the script as it looks now, also removed the outquoted functions to keep it clean:
Spoiler below!
void CheckPoint01(string &in asName, int alCount)
{
    {
    ResetProp("mansion_1"); ResetProp("rolled_up_carpet_1");
    AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
    AddEntityCollideCallback("mister_moody", "AreaGruntCheckedRoom", "CollideAreaGruntCheckedRoom", true, -1);
    AddEntityCollideCallback("mister_moody" , "ScriptArea_2" , "GoPoof" , false , 1);
    SetEntityActive("ScriptArea_2", false);
    }
}

////////////////////////////
// Rawr! Scary monster comin'!
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
    {
    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);
    }
}

////////////////////////////
//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);
    AddEnemyPatrolNode("mister_moody", "PathNodeArea_1", 3, "");
    AddEnemyPatrolNode("mister_moody", "PathNodeArea_2", 0, "");
    }
}

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");
    AddEntityCollideCallback("Player" , "ScriptArea_1" , "MonsterFunc1" , true , 1);
    AddEntityCollideCallback("mister_moody", "AreaGruntCheckedRoom", "CollideAreaGruntCheckedRoom", true, -1);
    AddEntityCollideCallback("mister_moody" , "ScriptArea_2" , "GoPoof" , false , 1);
    SetEntityActive("ScriptArea_2", false);
    }
}

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

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

}


Also, the door needs to be open again when the map resets, but now, with or without command the door is closed already.
04-20-2011, 04:22 PM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#10
RE: Curious Hio, Scripting questions. (Current: Checkpoints.)

Are you certain the checkpoint is actually working? Put a second playerstart area and make it so it spawns you there to test if it actually works or not.
04-20-2011, 04:42 PM
Find




Users browsing this thread: 1 Guest(s)