Frictional Games Forum (read-only)
How to breath heavily - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: How to breath heavily (/thread-16450.html)



How to breath heavily - Jagsrs28 - 06-24-2012

There is this tiny scary room that when I enter I want to breath HARD. I already have an Area setup called ScriptArea_2.
I want to know how do I make Daniel breath reallllly hard when I walk into this Area.






Thank You


RE: How to breath heavily - Mooserider - 06-24-2012

Try this script out:

PHP Code:
void OnStart()
{
    
AddEntityCollideCallback("Player""ScriptArea_2""PlayerInBreathArea"false0);
}
void PlayerInBreathArea(string &in asParentstring &in asChildint alState)
{
    if (
alState == 1)
    {
        
PlaySoundAtEntity("""react_breath_slow.snt""Player"0.0ffalse);
        
AddTimer("BreathTimer"2.0f"BreathTimer");
    }

    else
    {
        
RemoveTimer("BreathTimer");
    }
}

void BreathTimer(string &in asTimer)
{
    
AddTimer("BreathTimer"2.0f"BreathTimer");
    
PlaySoundAtEntity("""react_breath_slow.snt""Player"0.0ffalse);


Alternatively if you want to stay breathing even after you've left the area simply remove the lines:

PHP Code:
    else
    {
        
RemoveTimer("BreathTimer");
    } 
You can also change the .snt file if you want a different breath sound effect Smile


RE: How to breath heavily - Jagsrs28 - 06-24-2012

Error.


RE: How to breath heavily - Mooserider - 06-24-2012

What does the error box say? I tested it and it was fine for me.


RE: How to breath heavily - Jagsrs28 - 06-24-2012

void OnStart()

void OnStart()
{
AddEntityCollideCallback("Player", "ScriptArea_3", "PlayerInBreathArea", false, 0);
}
void PlayerInBreathArea(string &in asParent, string &in asChild, int alState)
{
if (alState == 1)
{
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0.0f, false);
AddTimer("BreathTimer", 2.0f, "BreathTimer");
}

else
{
RemoveTimer("BreathTimer");
}
}

{
ShowEnemyPlayerPosition("Grunty1");
AddUseItemCallback("", "Key_1", "castle_1", "KeyOnDoor", true);
AddEntityCollideCallback("Player", "ScriptArea_1", "CloseDoorFunc", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_2", "CloseDoorFunc2", true, 1);
}

void CloseDoorFunc(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("castle_1", true, true);
SetSwingDoorLocked("castle_1", true, false);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare", "Player", 0, false);
PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);
GiveSanityDamage(40.0f, true);
}

void CloseDoorFunc2(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("castle_2", true, true);
SetSwingDoorLocked("Magical Apples", true, false);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare", "Player", 0, false);
PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);
GiveSanityDamage(40.0f, true);
}

void KeyOnDoor(string &in item, string &in door)
{
SetSwingDoorLocked("castle_1", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("Key_1");
}

void OnEnter()
{

}



void OnLeave()
{

}






Error says:

FATAL ERROR: Could not load script file 'custom_stories/Morfar's House/maps/01.hps
main (3,1) : ERR : Expected',' or ';'
main (21,1) : ERR: Unexoected token '{'


RE: How to breath heavily - Mooserider - 06-24-2012

You didn't merge the new script with your current one, and you also didn't add the BreathTimer script Wink
Instead of

PHP Code:
void OnStart()

void OnStart()
{
AddEntityCollideCallback("Player""ScriptArea_3""PlayerInBreathArea"false0);
}
void PlayerInBreathArea(string &in asParentstring &in asChildint alState)
{
if (
alState == 1)
{
PlaySoundAtEntity("""react_breath_slow.snt""Player"0.0ffalse);
AddTimer("BreathTimer"2.0f"BreathTimer");
}

else
{
RemoveTimer("BreathTimer");
}
}

{
ShowEnemyPlayerPosition("Grunty1");
AddUseItemCallback("""Key_1""castle_1""KeyOnDoor"true);
AddEntityCollideCallback("Player""ScriptArea_1""CloseDoorFunc"true1);
AddEntityCollideCallback("Player""ScriptArea_2""CloseDoorFunc2"true1);


have

PHP Code:
void OnStart()
{
    
AddEntityCollideCallback("Player""ScriptArea_3""PlayerInBreathArea"false0);
    
ShowEnemyPlayerPosition("Grunty1");
    
AddUseItemCallback("""Key_1""castle_1""KeyOnDoor"true);
    
AddEntityCollideCallback("Player""ScriptArea_1""CloseDoorFunc"true1);
    
AddEntityCollideCallback("Player""ScriptArea_2""CloseDoorFunc2"true1);
}
void PlayerInBreathArea(string &in asParentstring &in asChildint alState)
{
    if (
alState == 1)
    {
        
PlaySoundAtEntity("""react_breath_slow.snt""Player"0.0ffalse);
        
AddTimer("BreathTimer"2.0f"BreathTimer");
    }

    else
    {
    
RemoveTimer("BreathTimer");
    }
}
void BreathTimer(string &in asTimer)
{
    
PlaySoundAtEntity("""react_breath_slow.snt""Player"0.0ffalse);
    
AddTimer("BreathTimer"2.0f"BreathTimer"); 


To explain the problem - you pasted the whole script I wrote instead of just putting the lines from my OnStart into your OnStart.
GL with the story Smile


RE: How to breath heavily - Jagsrs28 - 06-24-2012

(06-24-2012, 07:13 AM)Mooserider Wrote: You didn't merge the new script with your current one, and you also didn't add the BreathTimer script Wink
Instead of

PHP Code:
void OnStart()

void OnStart()
{
AddEntityCollideCallback("Player""ScriptArea_3""PlayerInBreathArea"false0);
}
void PlayerInBreathArea(string &in asParentstring &in asChildint alState)
{
if (
alState == 1)
{
PlaySoundAtEntity("""react_breath_slow.snt""Player"0.0ffalse);
AddTimer("BreathTimer"2.0f"BreathTimer");
}

else
{
RemoveTimer("BreathTimer");
}
}

{
ShowEnemyPlayerPosition("Grunty1");
AddUseItemCallback("""Key_1""castle_1""KeyOnDoor"true);
AddEntityCollideCallback("Player""ScriptArea_1""CloseDoorFunc"true1);
AddEntityCollideCallback("Player""ScriptArea_2""CloseDoorFunc2"true1);


have

PHP Code:
void OnStart()
{
    
AddEntityCollideCallback("Player""ScriptArea_3""PlayerInBreathArea"false0);
    
ShowEnemyPlayerPosition("Grunty1");
    
AddUseItemCallback("""Key_1""castle_1""KeyOnDoor"true);
    
AddEntityCollideCallback("Player""ScriptArea_1""CloseDoorFunc"true1);
    
AddEntityCollideCallback("Player""ScriptArea_2""CloseDoorFunc2"true1);
}
void PlayerInBreathArea(string &in asParentstring &in asChildint alState)
{
    if (
alState == 1)
    {
        
PlaySoundAtEntity("""react_breath_slow.snt""Player"0.0ffalse);
        
AddTimer("BreathTimer"2.0f"BreathTimer");
    }

    else
    {
    
RemoveTimer("BreathTimer");
    }
}
void BreathTimer(string &in asTimer)
{
    
PlaySoundAtEntity("""react_breath_slow.snt""Player"0.0ffalse);
    
AddTimer("BreathTimer"2.0f"BreathTimer"); 


To explain the problem - you pasted the whole script I wrote instead of just putting the lines from my OnStart into your OnStart.
GL with the story Smile
Now my key wont open a door, the door wont close behind me anymore -.- VAFAN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


RE: How to breath heavily - Mooserider - 06-24-2012

Did you still include what you had written in your script? This is the final script you should have:

PHP Code:
void OnStart(){
    
AddEntityCollideCallback("Player""ScriptArea_3""PlayerInBreathArea"false0);
    
ShowEnemyPlayerPosition("Grunty1");
    
AddUseItemCallback("""Key_1""castle_1""KeyOnDoor"true);
    
AddEntityCollideCallback("Player""ScriptArea_1""CloseDoorFunc"true1);
    
AddEntityCollideCallback("Player""ScriptArea_2""CloseDoorFunc2"true1);
}
void PlayerInBreathArea(string &in asParentstring &in asChildint alState)
{
    if (
alState == 1)
    {
        
PlaySoundAtEntity("""react_breath_slow.snt""Player"0.0ffalse);
        
AddTimer("BreathTimer"2.0f"BreathTimer");
    }

    else
    {
    
RemoveTimer("BreathTimer");
    }
}
void BreathTimer(string &in asTimer)
{
    
PlaySoundAtEntity("""react_breath_slow.snt""Player"0.0ffalse);
    
AddTimer("BreathTimer"2.0f"BreathTimer"); 
}
void CloseDoorFunc(string &in asParentstring &in asChildint alState
{
SetSwingDoorClosed("castle_1"truetrue);
SetSwingDoorLocked("castle_1"truefalse);    
PlaySoundAtEntity("""react_breath_slow.snt""Player"0false);
PlaySoundAtEntity("""react_scare""Player"0false);
PlaySoundAtEntity("""close_door.snt""Player"0false);
GiveSanityDamage(40.0ftrue);
}

void CloseDoorFunc2(string &in asParentstring &in asChildint alState
{
SetSwingDoorClosed("castle_2"truetrue);
SetSwingDoorLocked("Magical Apples"truefalse);    
PlaySoundAtEntity("""react_breath_slow.snt""Player"0false);
PlaySoundAtEntity("""react_scare""Player"0false);
PlaySoundAtEntity("""close_door.snt""Player"0false);
GiveSanityDamage(40.0ftrue);
}

void KeyOnDoor(string &in itemstring &in door)
{
SetSwingDoorLocked("castle_1"falsetrue);
PlaySoundAtEntity("""unlock_door""castle_1"0false);
RemoveItem("Key_1");
}

void OnEnter()
{

}



void OnLeave()
{