Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
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.