Amnesia: The Dark Descent

Amnesia: The Dark Descent

Community content for Amnesia: The Dark Descent
Get community created content for Amnesia: The Dark Descent. Even better, learn how to create your own content and to share it.
Learn More
Help with Scripting for a custom story
Not sure if this is the right place to post this, but because Frictional Games Forum seems to apparently be "closed permanently", that's why I'm asking this here instead.

I am new to this, but I am creating a few custom stories, I need some help with some scripts but not sure how to get them to work.

First and foremost, is there a way to create a timer effect that the game will end if the player does not move from a certain area after awhile (similar to the Cells)?

And secondly, with that in mind, I'm wondering how to create multiple game endings - like good ending, bad ending, etc.?

And just in case you asked - I did look at the original scriptings in the Cells HPS files, but I couldn't understand anything there.

If anyone can help me with these scriptings it would be greatly appreciated.
Last edited by [BMS] Alberto Garcia Perez Ayma; 24 Apr @ 8:19am
< >
Showing 1-1 of 1 comments
Hi there,

You're absolutely in the right place — and it's great that you're diving into custom stories! I'll try to help you out with your questions.
1. Timer that ends the game if the player doesn't move from a certain area

Yes, you can definitely do this in HPL2 (Amnesia: The Dark Descent). Here's a simple example of how you could implement such a timer:

void OnStart()
{
AddTimer("CheckMovement", 10.0f, "CheckPlayerMoved");
}

float lastPlayerPosX;

void CheckPlayerMoved(string &in asTimer)
{
float currPosX = GetPlayerPosX();

if (abs(currPosX - lastPlayerPosX) < 0.1f) {
// Player hasn't moved much, trigger game over
StartPlayerDeath();
} else {
// Player moved, update last position and reset timer
lastPlayerPosX = currPosX;
AddTimer("CheckMovement", 10.0f, "CheckPlayerMoved");
}
}

In this script, you store the player’s X-position, wait 10 seconds, and then check if the player has moved significantly. If not, the player "dies" (or you could call a custom ending). You can extend this by checking Y and Z positions too.

Tip: You'll want to use GetPlayerPos() and maybe store all three coordinates if movement in any direction counts.

2. Multiple Endings (Good, Bad, etc.)

This can be done using different script areas and variables. For example:

void OnStart()
{
SetLocalVarInt("EndingType", 0); // default
}

void OnEnterArea_GoodEnding(string &in asArea)
{
SetLocalVarInt("EndingType", 1);
AddTimer("EndGame", 2.0f, "TriggerEnding");
}

void OnEnterArea_BadEnding(string &in asArea)
{
SetLocalVarInt("EndingType", 2);
AddTimer("EndGame", 2.0f, "TriggerEnding");
}

void TriggerEnding(string &in asTimer)
{
int endType = GetLocalVarInt("EndingType");

if (endType == 1)
StartCredits("good.ogg", false, "EndingGood");
else if (endType == 2)
StartCredits("bad.ogg", false, "EndingBad");
else
StartCredits("default.ogg", false, "EndingDefault");
}

Make sure you define these script areas in your map using the Level Editor.
< >
Showing 1-1 of 1 comments
Per page: 1530 50