Frictional Games Forum (read-only)

Full Version: Opening cabinet
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a problem:

When I walk into Script6 (area) enemy6 spawns into cabinet, but doesnt get out. It looks like this:

My script:

PHP Code:
////////////////////////////
// Run when entering map
void OnEnter()
{
SetLanternDisabled(false);
SetEntityCallbackFunc("tinderbox""OnPickup");
AddEntityCollideCallback("Player""script1""SetMessage1"true1);
AddEntityCollideCallback("Player""script3""easterown"true1);
AddEntityCollideCallback("Player""script5""collideenemy4"true1);
AddEntityCollideCallback("Player""script6""collideenemy6"true1);
AddEntityCollideCallback("Player""Check1area""check1"true1);
AddEntityCollideCallback("Player""Check2area""check2"true1);
SetEntityPlayerInteractCallback("door2""Collide"true);
SetEntityConnectionStateChangeCallback("lever""func_shelf");
AddEntityCollideCallback("Player""startenemy5""collideenemy5"true1);
}

void collideenemy6(string &in asParentstring &in asChildint alState)
{
    
ClearEnemyPatrolNodes("enemy6");
    
SetEntityActive("enemy6"true);
    
SetSwingDoorLocked("cabinet"falsetrue);
    
AddTimer("timer123"0.7f"startenemy6");
    
StartPlayerLookAt("cabinet"34"StopPlayerLookAt");
    
AddEnemyPatrolNode("enemy6""PathNodeArea_6"0"");
}

void startenemy6(string &in asTimer)
{
    
ClearEnemyPatrolNodes("enemy6");
    
SetEntityActive("enemy6"true);
    
ShowEnemyPlayerPosition("enemy6");
    
AddEntityCollideCallback("enemy6""noticeenemy6""notenemy6"true1);
}

void collideenemy4(string &in asParentstring &in asChildint alState)
{
    
ClearEnemyPatrolNodes("enemy4");
    
SetEntityActive("enemy4"true);
    
AddEnemyPatrolNode("enemy4""PathNodeArea_2"0"");
    
AddEnemyPatrolNode("enemy4""PathNodeArea_3"0"");
    
AddEntityCollideCallback("enemy4""fadeenemy4""Fadeenemy4"true1);
}

void collideenemy5(string &in asParentstring &in asChildint alState)
{
    
ClearEnemyPatrolNodes("enemy5");
    
SetEntityActive("enemy5"true);
    
AddEnemyPatrolNode("enemy5""PathNodeArea_4"0"");
    
AddEnemyPatrolNode("enemy5""PathNodeArea_5"0"");
    
AddEntityCollideCallback("enemy5""fadeenemy5""Fadeenemy5"true1);
    
}

void Fadeenemy5(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive("enemy5"false);
}

void Fadeenemy4(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive("enemy4"false);
}

void Collide(string &in asEntity)
{
    
SetEntityPlayerInteractCallback("door1""Collide2"true);
}

void Collide2(string &in asEntity)
{
//    ClearEnemyPatrolNodes("enemy2");
//    SetEntityActive("enemy2", true);
    
AddEnemyPatrolNode("enemy2""PathNodeArea_1"0"");
    
AddEntityCollideCallback("enemy2""script4""Collideenemy2"true1);
}

void Collideenemy2(string &in asParentstring &in asChildint alState)
{
    
SetPropHealth("door2"50);
    
ShowEnemyPlayerPosition("enemy2");
}

void check1(string &in asParentstring &in asChildint alState)
{
    
CheckPoint ("Check1""Check1""CheckPoint01""Misc""DeathHint2");
}

void check2(string &in asParentstring &in asChildint alState)
{
    
CheckPoint ("Check2""Check1""CheckPoint01""Misc""DeathHint1");
}

void CheckPoint01(string &in asNameint alCount)
{
    
SetPlayerHealth(RandFloat(80,90));
    
SetPlayerSanity(RandFloat(40,60));
    
SetPlayerMoveSpeedMul(1);
    
SetPlayerRunSpeedMul(1);
    
SetPlayerCrouching(false);
    
}

void easterown(string &in asParentstring &in asChildint alState)
{
    
AddTimer("eastern"3.0f"easterr");
}

void easterr(string &in asTimer)
{
    
SetEntityActive("enemy3"true);
    
ShowEnemyPlayerPosition("enemy3");
    
StartPlayerLookAt("enemy3"34"StopPlayerLookAt");
    
AddTimer("sanitytimer"0.5f"sanitydamage");
    
SetPlayerHealth(50);
    
SetPlayerMoveSpeedMul(0);
    
SetPlayerRunSpeedMul(0);
    
SetDeathHint("Misc""DeathHint1");
}

void sanitydamage(string &in asTimer)
{
    
GiveSanityDamage(100true);
    
PlaySoundAtEntity("react""react_scare.snt""Player"0.0ffalse);
    
SetPlayerCrouching(true);
}


void func_shelf(string &in asEntityint alState)
{
    if (
alState == 1)
    {
    
SetMoveObjectState("shelf",1.0f);
    
PlaySoundAtEntity("""quest_completed.snt""shelf_move_1"0false);
        return;
    }
}




void SetMessage1(stringasTextCategorystringasTextEntryfloat afTime)
{
SetMessage("Sergej""Mutter1"0);
}

void OnPickup(string &in asItemstring &in asEntity)
{
    
SetLanternDisabled(false);
    
RemoveItem("tinderbox");
    
SetMessage("Sergej""Mutter2"0);
}
 
////////////////////////////
// Run when leaving map
void OnLeave()
{
 


Also I have the cabinet locked until you walk in to the area.
Is the cabinet named "cabinet"?

You unlock the cabinet but the grunt can't open it himself. You need to open the cabinet itself (try SetMoveObjectState("cabinet", 1);.

On another note, move your Callbacks in the onEnter() function to onStart(). Completely worthless and wasteful to have them in OnEnter. OnStart is where you want them.
(05-25-2012, 01:11 PM)Putmalk Wrote: [ -> ]Is the cabinet named "cabinet"?

You unlock the cabinet but the grunt can't open it himself. You need to open the cabinet itself (try SetMoveObjectState("cabinet", 1);.

On another note, move your Callbacks in the onEnter() function to onStart(). Completely worthless and wasteful to have them in OnEnter. OnStart is where you want them.
SetMoveObjectState("cabinet", 1); didnt work. :/

Now it looks like:

PHP Code:
void OnStart()
{
SetLanternDisabled(false);
SetEntityCallbackFunc("tinderbox""OnPickup");
AddEntityCollideCallback("Player""script1""SetMessage1"true1);
AddEntityCollideCallback("Player""script3""easterown"true1);
AddEntityCollideCallback("Player""script5""collideenemy4"true1);
AddEntityCollideCallback("Player""script6""collideenemy6"true1);
AddEntityCollideCallback("Player""Check1area""check1"true1);
AddEntityCollideCallback("Player""Check2area""check2"true1);
SetEntityPlayerInteractCallback("door2""Collide"true);
SetEntityConnectionStateChangeCallback("lever""func_shelf");
AddEntityCollideCallback("Player""startenemy5""collideenemy5"true1);
}

void collideenemy6(string &in asParentstring &in asChildint alState)
{
    
ClearEnemyPatrolNodes("enemy6");
    
SetSwingDoorLocked("cabinet"falsetrue);
    
AddTimer("timer123"0.7f"startenemy6");
    
StartPlayerLookAt("cabinet"34"StopPlayerLookAt");
    
AddEnemyPatrolNode("enemy6""PathNodeArea_6"0"");
}

void startenemy6(string &in asTimer)
{
    
SetMoveObjectState("cabinet"1);
    
ClearEnemyPatrolNodes("enemy6");
    
SetEntityActive("enemy6"true);
    
ShowEnemyPlayerPosition("enemy6");
    
AddEntityCollideCallback("enemy6""noticeenemy6""notenemy6"true1);
}

void collideenemy4(string &in asParentstring &in asChildint alState)
{
    
ClearEnemyPatrolNodes("enemy4");
    
SetEntityActive("enemy4"true);
    
AddEnemyPatrolNode("enemy4""PathNodeArea_2"0"");
    
AddEnemyPatrolNode("enemy4""PathNodeArea_3"0"");
    
AddEntityCollideCallback("enemy4""fadeenemy4""Fadeenemy4"true1);
}

void collideenemy5(string &in asParentstring &in asChildint alState)
{
    
ClearEnemyPatrolNodes("enemy5");
    
SetEntityActive("enemy5"true);
    
AddEnemyPatrolNode("enemy5""PathNodeArea_4"0"");
    
AddEnemyPatrolNode("enemy5""PathNodeArea_5"0"");
    
AddEntityCollideCallback("enemy5""fadeenemy5""Fadeenemy5"true1);
    
}

void Fadeenemy5(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive("enemy5"false);
}

void Fadeenemy4(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive("enemy4"false);
}

void Collide(string &in asEntity)
{
    
SetEntityPlayerInteractCallback("door1""Collide2"true);
}

void Collide2(string &in asEntity)
{
//    ClearEnemyPatrolNodes("enemy2");
//    SetEntityActive("enemy2", true);
    
AddEnemyPatrolNode("enemy2""PathNodeArea_1"0"");
    
AddEntityCollideCallback("enemy2""script4""Collideenemy2"true1);
}

void Collideenemy2(string &in asParentstring &in asChildint alState)
{
    
SetPropHealth("door2"50);
    
ShowEnemyPlayerPosition("enemy2");
}

void check1(string &in asParentstring &in asChildint alState)
{
    
CheckPoint ("Check1""Check1""CheckPoint01""Misc""DeathHint2");
}

void check2(string &in asParentstring &in asChildint alState)
{
    
CheckPoint ("Check2""Check1""CheckPoint01""Misc""DeathHint1");
}

void CheckPoint01(string &in asNameint alCount)
{
    
SetPlayerHealth(RandFloat(80,90));
    
SetPlayerSanity(RandFloat(40,60));
    
SetPlayerMoveSpeedMul(1);
    
SetPlayerRunSpeedMul(1);
    
SetPlayerCrouching(false);
    
}

void easterown(string &in asParentstring &in asChildint alState)
{
    
AddTimer("eastern"3.0f"easterr");
}

void easterr(string &in asTimer)
{
    
SetEntityActive("enemy3"true);
    
ShowEnemyPlayerPosition("enemy3");
    
StartPlayerLookAt("enemy3"34"StopPlayerLookAt");
    
AddTimer("sanitytimer"0.5f"sanitydamage");
    
SetPlayerHealth(50);
    
SetPlayerMoveSpeedMul(0);
    
SetPlayerRunSpeedMul(0);
    
SetDeathHint("Misc""DeathHint1");
}

void sanitydamage(string &in asTimer)
{
    
GiveSanityDamage(100true);
    
PlaySoundAtEntity("react""react_scare.snt""Player"0.0ffalse);
    
SetPlayerCrouching(true);
}


void func_shelf(string &in asEntityint alState)
{
    if (
alState == 1)
    {
    
SetMoveObjectState("shelf",1.0f);
    
PlaySoundAtEntity("""quest_completed.snt""shelf_move_1"0false);
        return;
    }
}




void SetMessage1(stringasTextCategorystringasTextEntryfloat afTime)
{
SetMessage("Sergej""Mutter1"0);
}

void OnPickup(string &in asItemstring &in asEntity)
{
    
SetLanternDisabled(false);
    
RemoveItem("tinderbox");
    
SetMessage("Sergej""Mutter2"0);
}
 
////////////////////////////
// Run when leaving map
void OnLeave()
{
 

Oh? SetObjectMoveState didn't work? Hm, okay. That wasn't a set in stone solution, I just wanted to see if it would work.

You might be able to use SetSwingDoorClosed("cabinet", false, true); function. Or you might be able to provide a force on the cabinet to make it open use AddPropForce("cabinet", int x, int y, int z, "world");.

We are trying to get the doors to open, right? So the grunt can charge out? (just double checking).
(05-25-2012, 02:00 PM)Putmalk Wrote: [ -> ]Oh? SetObjectMoveState didn't work? Hm, okay. That wasn't a set in stone solution, I just wanted to see if it would work.

You might be able to use SetSwingDoorClosed("cabinet", false, true); function. Or you might be able to provide a force on the cabinet to make it open use AddPropForce("cabinet", int x, int y, int z, "world");.

We are trying to get the doors to open, right? So the grunt can charge out? (just double checking).
Yup, thats what we are trying. Smile

And SetSwingDoorClosed("cabinet", false, true);

worked, thank you.