Facts
Released
2010
Platforms
Linux, Windows, macOS
Developer
Frictional Games
Publisher
Frictional Games, THQ
Series
Amnesia
Code
Source release by Frictional Games
Evidence
Code (20)
Sources
1
On this page
  1. How it plays
  2. Related
  3. Mechanics
  4. References
  5. Sources

The source release leaves out the game’s data, including the configuration file that sets most of the rates below, so the code gives the rules and the shapes of the curves but not the lantern’s burn time or the darkness drain per second.

#How it plays

#Light

The player carries a lantern with oil from 0 to 100, starting full1. Lit, it burns oil at a steady rate per second, and at 0 it goes out and won’t relight until oil is added2. Its light fades in proportion to the oil over the last stretch3. A flask of oil adds its own amount, up to 100, and is wasted past that4. This is a light-source timer that the player refills.

The other light is the level’s own lamps, which the player lights with tinderboxes, one each. Tinderboxes are a plain count with no limit, and the player can’t put a lit lamp out5,6. Lighting one also restores sanity, by an amount weighted toward a set maximum the lower sanity is6.

In hard mode the maps hold fewer of both: about 65 in 100 flasks are removed as a map loads, and 70 to 95 in 100 tinderboxes, the more the more the player already carries7.

#Sanity

Sanity runs from 0 to 1001. It drains in darkness, with the lantern counting as light; the drain builds over 10 seconds in the dark and fades over about 3 in light8. It drops in steps while the player can see a monster within 35 units9, when a bug or spider crawls close10, and when a level’s script deals a scare11. It creeps back up by itself below a set level12, rises with each lamp lit6, and jumps when a script function sets it, to 100 from under 2513.

Each level of sanity has its effects. Under sustained loss it plays a heartbeat and a draining sound, three times as often at 0 as at 10014. Looking at a monster blurs the screen15. Low sanity warps the screen, more the lower it goes, and below a second, lower level it smears the image and sets the player panting16. Low enough, the player hears and sees things: footsteps, sounds, particles, and bugs that aren’t there, played in a level’s marked areas, with a wait between them set by the sanity band17.

At 0 the player collapses. The lantern goes out, the world’s sounds slow to half speed, every monster in the map is alerted, and the view sinks and rolls before the player wakes with sanity set to a fixed amount18,19. In hard mode the collapse kills the player18.

The code also holds a top-up of health, sanity, and oil after a death, commented out20.

  • Code that would top up health, sanity, and oil to random amounts between configured bounds after a death is commented out, though the bounds are still read from the configuration.20

Mechanics

MechanicKindHow
Light-source timerRefillable counta lantern whose oil, out of 100, burns at a configured rate and is topped up by flasks; tinderboxes light fixed lamps one each
Darknessstanding in the dark drains sanity, building to its full rate over 10 seconds
Every claim about this game, by concept (21)
generalHealth, sanity, and lamp oil each run from 0 to 100. A new player starts with all three at 100 and no tinderboxes. Adding sanity or oil stops at 100.Code
At an interval the configuration sets, the game checks whether the player can see a monster: one within 35 units, inside the camera's view, with a clear line to at least two of five points on its body. If any is seen, sanity drops by a configured amount, once per check however many are in view.Code
On the same check, a crawling critter (a bug or spider) within 3 units of the player's head takes away a configured amount of sanity.Code
While a monster is in sight, the screen takes a pulsing radial blur that builds to full over about 3.3 seconds of looking (computed).Code
Below a limit the configuration sets, sanity rises by itself at a configured rate per second.Code
When sanity stays below a configured low level for longer than a configured time, it is set to a configured amount. Time spent back above the level counts the timer down again.Code
When a loss takes sanity below 0, it is held at 0 and the player collapses; in hard mode the player dies instead of recovering. A collapse puts out the lantern, slows the world's sounds to half speed at three-quarters volume, and alerts every active monster in the map to the player.Code
During a collapse the view sinks and rolls up to 35 degrees while random sounds play. After a time the configuration sets, sanity is set to a configured amount, the world's sounds return, and the view rises back.Code
Under sustained loss of sanity, such as the darkness drain, a heartbeat and a draining sound repeat, faster the lower sanity is: three times as often at 0 as at 100 (computed). A single loss plays neither: each loss keeps the sounds' timers running for one second, too short for either to fire, and they restart from zero once a second passes without a loss. The draining sound has three strengths: one above 75 sanity, one above 50, and one at 50 or below.Code
Below a sanity level the configuration sets, a wavy distortion covers the screen, stronger the lower sanity falls: its strength is 1 − sanity over that level. Below a second, lower level, also configured, the image smears, the player pants every 0.5 to 5 seconds, and a hint shows.Code
A sudden sanity loss that a level's script deals plays a sound and briefly narrows and stretches the view with a smear, then eases it back.Code
Hallucinations come as events of four kinds: a sound, footsteps, particles, and crawling bugs. Each event has a highest sanity at which it can play. An event starts when the player is in one of a level's insanity areas, sanity is at or below a configured level, and the wait since the last event has run out. The wait is one of three configured lengths, chosen by which of three configured sanity bands the player is in when the last event ends. The event is picked at random among those not yet played, and when all have played they become available again.Code
A script function sets sanity to 100 when it is under 25, to 90 under 50, and to 80 under 75, and adds 5 above that. Its small version adds 20, 15, 10, or 5 across the same bands.Code
Code that would top up health, sanity, and oil to random amounts between configured bounds after a death is commented out, though the bounds are still read from the configuration.Code
DarknessWhere the light on the player falls to a level the configuration sets, sanity drains. A lit lantern counts as light. The drain starts from nothing and builds to its full rate over 10 seconds of darkness, and fades back over about 3.3 seconds of light (computed). It pauses during flashbacks and memory flashes, and when a level's script turns it off.Code
Light-source timerWhile the lantern is lit, its oil falls each second by a rate set in the game's configuration, except while a memory flash (a scripted flash of text) is showing. When the oil reaches 0 the lantern goes out with an out-of-oil sound, and the player can't light it again until oil is added.Code
Below a level of oil set in the game's configuration, the lantern's light dims in proportion to the oil left, reaching black at 0.Code
Using a flask of oil needs the lantern in the inventory, and does nothing when the lantern is full. Otherwise it adds the flask's own amount, stops at 100, and uses up the flask. Up to 99 flasks stack in one inventory slot.Code
Picking up a tinderbox adds 1 to a count the player carries, instead of placing an item in the inventory. The count has no upper limit: a limit of 10 is commented out.Code
Lighting an unlit lamp takes one tinderbox, and fails with a message when the count is 0. Each lighting also raises sanity, by an amount between a minimum and a maximum set in the configuration, weighted toward the maximum by (1 − s/100)², where s is the sanity before. A lit lamp does nothing when the player uses it, so the player can't put it out.Code
In hard mode, each map's tinderboxes and oil flasks are thinned as the map loads: about 65 in every 100 flasks are removed, and between 70 and 95 in every 100 tinderboxes, more the more tinderboxes the player carries, reaching 95 at six (computed from the removal rates).Code

References

  1. ^ abCodeFrictionalGames/AmnesiaTheDarkDescentLuxPlayer.cpp 267–270, 907–910, 932–936
    How we know

    Health, sanity, and lamp oil each run from 0 to 100. A new player starts with all three at 100 and no tinderboxes. Adding sanity or oil stops at 100.

    267	mfHealth = 100;
    268	mfSanity = 100;
    269	mfLampOil = 100;
    270	mlTinderboxes =0;
    
    amnesia/src/game/LuxPlayer.cpp lines 267–270 at acc95cd · upstream ↗
    907	if(mfSanity >= 100 && afX>0) return;
    ⋮
    909	mfSanity += afX;
    910	if(mfSanity > 100) mfSanity = 100;
    
    amnesia/src/game/LuxPlayer.cpp lines 907–910 at acc95cd · upstream ↗
    932	if(mfLampOil >= 100 && afX>0) return;
    ⋮
    934	mfLampOil += afX;
    935	if(mfLampOil > 100) mfLampOil = 100;
    936	if(mfLampOil < 0) mfLampOil = 0;
    
    amnesia/src/game/LuxPlayer.cpp lines 932–936 at acc95cd · upstream ↗

    Claim page

  2. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxPlayerHelpers.cpp 1639, 1703–1713, 1799–1807
    How we know

    While the lantern is lit, its oil falls each second by a rate set in the game's configuration, except while a memory flash (a scripted flash of text) is showing. When the oil reaches 0 the lantern goes out with an out-of-oil sound, and the player can't light it again until oil is added.

    1639	mfLowerOilSpeed = gpBase->mpGameCfg->GetFloat("Player_Lantern","LowerOilSpeed",0);
    
    amnesia/src/game/LuxPlayerHelpers.cpp line 1639 at acc95cd · upstream ↗
    1703	if(mbActive && gpBase->mpEffectHandler->GetEmotionFlash()->IsActive()==false)
    ⋮
    1705		float fOil = mpPlayer->GetLampOil();
    1706		fOil -= mfLowerOilSpeed *afTimeStep;
    1707		if(fOil <=0)
    ⋮
    1709			fOil = 0;
    1710			gpBase->mpHelpFuncs->PlayGuiSoundData(msOutOfOilSound, eSoundEntryType_Gui);
    1711			SetActive(false, true);
    ⋮
    1713		mpPlayer->SetLampOil(fOil);
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1703–1713 at acc95cd · upstream ↗
    1799    if(abCheckForOilAndItems && abX && mpPlayer->GetLampOil() <=0)
    ⋮
    1801		if(abUseEffects)
    ⋮
    1803			gpBase->mpHintHandler->Add("LanternNoOil", kTranslate("Hints", "LanternNoOil"), 0);
    1804			gpBase->mpHelpFuncs->PlayGuiSoundData(msOutOfOilSound, eSoundEntryType_Gui);
    ⋮
    1806		return;
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1799–1807 at acc95cd · upstream ↗

    Claim page

  3. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxPlayerHelpers.cpp 1640, 1692–1698
    How we know

    Below a level of oil set in the game's configuration, the lantern's light dims in proportion to the oil left, reaching black at 0.

    1640	mfFadeLightOilAmount = gpBase->mpGameCfg->GetFloat("Player_Lantern","FadeLightOilAmount",0);
    
    amnesia/src/game/LuxPlayerHelpers.cpp line 1640 at acc95cd · upstream ↗
    1692	cColor lightColor = mDefaultColor;
    1693	float fOil = gpBase->mpPlayer->GetLampOil();
    1694	if(fOil < mfFadeLightOilAmount)
    ⋮
    1696		lightColor =  mDefaultColor * (fOil / mfFadeLightOilAmount);
    ⋮
    1698	mpLight->SetDiffuseColor(lightColor * mfAlpha);
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1692–1698 at acc95cd · upstream ↗

    Claim page

  4. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxItemType.cpp 355–358, 368–383
    How we know

    Using a flask of oil needs the lantern in the inventory, and does nothing when the lantern is full. Otherwise it adds the flask's own amount, stops at 100, and uses up the flask. Up to 99 flasks stack in one inventory slot.

    355cLuxItemType_LampOil::cLuxItemType_LampOil()  : iLuxItemType("LampOil", eLuxItemType_LampOil)
    ⋮
    357	mbHasCount = true;
    358	mlMaxCount = 99;
    
    amnesia/src/game/LuxItemType.cpp lines 355–358 at acc95cd · upstream ↗
    368void cLuxItemType_LampOil::OnUse(cLuxInventory_Item *apItem, int alSlotIndex)
    ⋮
    370	cLuxInventory *pInventory = gpBase->mpInventory;
    371	if(pInventory->HasItemOfType(eLuxItemType_Lantern)==false)
    ⋮
    373		pInventory->SetMessageText(kTranslate("Inventory","OilNeedsLantern"),0);
    374		return;
    ⋮
    377	float fLampOil = gpBase->mpPlayer->GetLampOil();
    378	if(fLampOil >= 100) return;
    ⋮
    380	fLampOil += apItem->GetAmount();
    381	if(fLampOil > 100) fLampOil = 100;
    382	gpBase->mpPlayer->SetLampOil(fLampOil);
    383	pInventory->RemoveItem(apItem);
    
    amnesia/src/game/LuxItemType.cpp lines 368–383 at acc95cd · upstream ↗

    Claim page

  5. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxItemType.cpp 402–415; LuxPlayer.h 191; +1 files
    How we know

    Picking up a tinderbox adds 1 to a count the player carries, instead of placing an item in the inventory. The count has no upper limit: a limit of 10 is commented out.

    402bool cLuxItemType_Tinderbox::GetHasMaxAmount()
    ⋮
    404	//if(gpBase->mpPlayer->GetTinderboxes()>=10) return true;
    405	return false;
    ⋮
    408bool cLuxItemType_Tinderbox::BeforeAddItem(cLuxInventory_Item *apItem)
    ⋮
    410	gpBase->mpHintHandler->Add("PickTinderbox", kTranslate("Hints", "PickTinderbox"), 0);
    ⋮
    412	gpBase->mpPlayer->AddTinderboxes(1);
    ⋮
    414	return true;
    
    amnesia/src/game/LuxItemType.cpp lines 402–415 at acc95cd · upstream ↗
    191	void AddTinderboxes(int alX){ mlTinderboxes += alX; }
    
    amnesia/src/game/LuxPlayer.h line 191 at acc95cd · upstream ↗
    1127	//////////////////////////
    1128	//Check if something else should be done with the item (like adding to notebook).
    1129	if(pItemType->BeforeAddItem(pItem))
    ⋮
    1131		if(apRemoveItemProp) *apRemoveItemProp = true;
    1132		hplDelete(pItem);
    1133		return NULL;
    
    amnesia/src/game/LuxInventory.cpp lines 1127–1134 at acc95cd · upstream ↗

    Claim page

  6. ^ abcCodeFrictionalGames/AmnesiaTheDarkDescentLuxProp_Lamp.cpp 203–209, 217–221, 227–250; LuxGlobalDataHandler.cpp 38–39
    How we know

    Lighting an unlit lamp takes one tinderbox, and fails with a message when the count is 0. Each lighting also raises sanity, by an amount between a minimum and a maximum set in the configuration, weighted toward the maximum by (1 − s/100)², where s is the sanity before. A lit lamp does nothing when the player uses it, so the player can't put it out.

    203bool cLuxProp_Lamp::CanInteract(iPhysicsBody *apBody)
    ⋮
    205	if(CanBeIgnitByPlayer() && mbLit==false) return true;
    206	if(msInteractCallback != "") return true;
    ⋮
    208	return false;
    
    amnesia/src/game/LuxProp_Lamp.cpp lines 203–209 at acc95cd · upstream ↗
    217	if(mbLit)
    ⋮
    219		//SetLit(false, true);
    220		//Nothing...
    
    amnesia/src/game/LuxProp_Lamp.cpp lines 217–221 at acc95cd · upstream ↗
    228		if(gpBase->mpPlayer->GetTinderboxes()<=0)
    ⋮
    230			gpBase->mpMessageHandler->SetMessage(kTranslate("Game","NoMoreTinderboxes"), 0);
    231			return false;
    ⋮
    236		float fIncreaseAmount = 1.0f - gpBase->mpPlayer->GetSanity() / 100.0f;
    237		fIncreaseAmount = fIncreaseAmount*fIncreaseAmount; //Want exp curve
    238		float fSanityAdd =	gpBase->mpGlobalDataHandler->GetLightLampMinSanityIncrease() * (1-fIncreaseAmount) + 
    239							gpBase->mpGlobalDataHandler->GetLightLampMaxSanityIncrease()*fIncreaseAmount;
    240		gpBase->mpPlayer->AddSanity(fSanityAdd, false);
    ⋮
    244		gpBase->mpPlayer->AddTinderboxes(-1);
    ⋮
    250		SetLit(true, true);
    
    amnesia/src/game/LuxProp_Lamp.cpp lines 227–250 at acc95cd · upstream ↗

    1 more excerpts on the claim page

  7. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxMap.cpp 205–207, 215–232, 257–269, 273–283, 306–311
    How we know

    In hard mode, each map's tinderboxes and oil flasks are thinned as the map loads: about 65 in every 100 flasks are removed, and between 70 and 95 in every 100 tinderboxes, more the more tinderboxes the player carries, reaching 95 at six (computed from the removal rates).

    205	//////////////////
    206	// HARDMODE
    207	if (gpBase->mbHardMode)
    
    amnesia/src/game/LuxMap.cpp lines 205–207 at acc95cd · upstream ↗
    215		float fMin = 7.0f / 10.0f;
    216		float fMax = 9.5f / 10.0f;
    ⋮
    218		float fCurrentNumTinderBoxes = static_cast<float>(gpBase->mpPlayer->GetTinderboxes());
    219		float fMaxNumTinderboxes = 6;
    ⋮
    221		float fT = fCurrentNumTinderBoxes / fMaxNumTinderboxes;
    ⋮
    223		float fTinderBoxRemoveEvery = (1.0f - fT)*fMin + fT*fMax;
    ⋮
    225		float fTinderBoxCounter = 0.0f;
    226		//float fTinderBoxRemoveEvery = 8.5f / 10.0f;
    ⋮
    228		int lNumTotalOil = 0;
    229		int lNumRemovedOil = 0;
    ⋮
    231		float fLampOilCounter = 0.0f;
    232		float fLampOilRemoveEvery = 6.5f / 10.0f;
    
    amnesia/src/game/LuxMap.cpp lines 215–232 at acc95cd · upstream ↗
    257					if (itemType == eLuxItemType_Tinderbox)
    ⋮
    259						lNumTotalTinderboxes++;
    260						fTinderBoxCounter += fTinderBoxRemoveEvery; 
    ⋮
    262						if (fTinderBoxCounter >= 1.0f)
    ⋮
    264							fTinderBoxCounter -= 1.0f;
    265							vEntitiesToDestroy.push_back(pEntity);
    266							lNumRemovedTinderboxes++;
    267							continue;
    
    amnesia/src/game/LuxMap.cpp lines 257–269 at acc95cd · upstream ↗

    2 more excerpts on the claim page

  8. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxPlayerHelpers.cpp 2821, 2836, 2773–2789, 2916, 2935–2936, 2940–2950
    How we know

    Where the light on the player falls to a level the configuration sets, sanity drains. A lit lantern counts as light. The drain starts from nothing and builds to its full rate over 10 seconds of darkness, and fades back over about 3.3 seconds of light (computed). It pauses during flashbacks and memory flashes, and when a level's script turns it off.

    2821	mfMinDarknessLightLevel = gpBase->mpGameCfg->GetFloat("Player_Darkness","MinLightLevel",0);
    
    amnesia/src/game/LuxPlayerHelpers.cpp line 2821 at acc95cd · upstream ↗
    2836	mfSanityLossPerSecond = gpBase->mpGameCfg->GetFloat("Player_Darkness", "SanityLossPerSecond",0);
    
    amnesia/src/game/LuxPlayerHelpers.cpp line 2836 at acc95cd · upstream ↗
    2775		if(mpPlayer->GetHelperLantern()->IsActive())
    ⋮
    2777			mfExtendedLightLevel += 1.0f;
    2778			mfNormalLightLevel += 1.0f;
    ⋮
    2784			float fExtLight = gpBase->mpMapHelper->GetLightLevelAtPos(vTestPos[i], &vSkipLights, mfRadiusAdd);
    ⋮
    2787			mfExtendedLightLevel = cMath::Max(fExtLight, mfExtendedLightLevel);
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 2773–2789 at acc95cd · upstream ↗

    3 more excerpts on the claim page

  9. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxPlayerHelpers.cpp 1160–1161, 1343–1354, 1401–1416, 1420–1441, 1449–1451
    How we know

    At an interval the configuration sets, the game checks whether the player can see a monster: one within 35 units, inside the camera's view, with a clear line to at least two of five points on its body. If any is seen, sanity drops by a configured amount, once per check however many are in view.

    1160	mfCheckNearEnemyInterval = gpBase->mpGameCfg->GetFloat("Player_Sanity","CheckNearEnemyInterval",0);
    1161	mfNearEnemyDecrease = gpBase->mpGameCfg->GetFloat("Player_Sanity","NearEnemyDecrease",0);
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1160–1161 at acc95cd · upstream ↗
    1343	if(mfCheckEnemySeenCount >0)
    ⋮
    1345		mfCheckEnemySeenCount-=afTimeStep;
    1346		return;
    ⋮
    1348	mfCheckEnemySeenCount = mfCheckNearEnemyInterval;
    ⋮
    1350	/////////////////////////////////////
    1351	// Init vars
    1352	bool bSeenEnemy = false;
    1353	cLuxMap *pMap = gpBase->mpMapHandler->GetCurrentMap();
    1354	float fMaxRangeSqrt = 35 * 35;
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1343–1354 at acc95cd · upstream ↗
    1401		if(pEnemy->IsActive()==false) continue;
    1402		if(pEnemy->CausesSanityDecrease()==false) continue;
    ⋮
    1404		iCharacterBody *pCharBody = pEnemy->GetCharacterBody();
    ⋮
    1406		//////////////////////////////
    1407		//Check so enemy is in range
    1408		float fDistSqrt = cMath::Vector3DistSqr(pCharBody->GetPosition(), vPlayerHeadPos);
    1409		if(fDistSqrt > fMaxRangeSqrt) continue;
    ⋮
    1411		//////////////////////////////
    1412		//Check so enemy is in FOV
    1413		if( pCam->GetFrustum()->CollideBoundingVolume(pCharBody->GetCurrentBody()->GetBoundingVolume()) == eCollision_Outside)
    ⋮
    1415			continue;
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1401–1416 at acc95cd · upstream ↗

    2 more excerpts on the claim page

  10. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxPlayerHelpers.cpp 1162, 1365–1391
    How we know

    On the same check, a crawling critter (a bug or spider) within 3 units of the player's head takes away a configured amount of sanity.

    1162	mfNearCritterDecrease = gpBase->mpGameCfg->GetFloat("Player_Sanity","NearCritterDecrease",0);
    
    amnesia/src/game/LuxPlayerHelpers.cpp line 1162 at acc95cd · upstream ↗
    1365	float fMinCritterDistSqrt = 3.0f * 3.0f;
    ⋮
    1379		if(pCritter->CausesSanityDecrease()==false) continue;
    ⋮
    1381		float fDistSqrt = cMath::Vector3DistSqr(pProp->GetBody(0)->GetLocalPosition(), vPlayerHeadPos); 
    1382		if(fDistSqrt > fMinCritterDistSqrt) continue;
    ⋮
    1388	if(bNearCritter)
    ⋮
    1390		mpPlayer->LowerSanity(mfNearCritterDecrease, true);
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1365–1391 at acc95cd · upstream ↗

    Claim page

  11. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxPlayer.cpp 609–616; LuxPlayerHelpers.cpp 1203–1208, 1480–1497
    How we know

    A sudden sanity loss that a level's script deals plays a sound and briefly narrows and stretches the view with a smear, then eases it back.

    609void cLuxPlayer::GiveSanityDamage(float afAmount)
    ⋮
    611	gpBase->mpHintHandler->Add("SanityHit", kTranslate("Hints", "SanityHit"), 0);
    ⋮
    613	LowerSanity(afAmount, true);
    ⋮
    615	mpSanity->StartHit();
    
    amnesia/src/game/LuxPlayer.cpp lines 609–616 at acc95cd · upstream ↗
    1203void cLuxPlayerSanity::StartHit()
    ⋮
    1205	mbHitActive = true;
    ⋮
    1207	gpBase->mpHelpFuncs->PlayGuiSoundData("sanity_damage", eSoundEntryType_Gui);
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1203–1208 at acc95cd · upstream ↗
    1480	if(mbHitActive)
    ⋮
    1482		mfHitAlpha += afTimeStep * mfHitZoomInSpeed;
    1483		if(mfHitAlpha >= 1)
    ⋮
    1485			mfHitAlpha =1;
    1486			mbHitActive = false;
    ⋮
    1489	else
    ⋮
    1491		mfHitAlpha -= afTimeStep * mfHitZoomOutSpeed;
    1492		if(mfHitAlpha < 0) mfHitAlpha =0;
    ⋮
    1495	gpBase->mpEffectHandler->GetImageTrail()->FadeTo(mfHitAlpha * 0.9f, 100);
    1496	mpPlayer->FadeAspectMulTo(1 - mfHitAlpha * mfHitZoomInAspectMul, 100);
    1497	mpPlayer->FadeFOVMulTo(1 - mfHitAlpha * mfHitZoomInFOVMul, 100);
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1480–1497 at acc95cd · upstream ↗

    Claim page

  12. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxPlayerHelpers.cpp 1147–1148, 1328–1333
    How we know

    Below a limit the configuration sets, sanity rises by itself at a configured rate per second.

    1147	mfSanityRegainSpeed = gpBase->mpGameCfg->GetFloat("Player_Sanity","SanityRegainSpeed",0);
    1148	mfSanityRegainLimit = gpBase->mpGameCfg->GetFloat("Player_Sanity","SanityRegainLimit",0);
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1147–1148 at acc95cd · upstream ↗
    1328	float fSanity = mpPlayer->GetSanity();
    1329	if(fSanity < mfSanityRegainLimit)
    ⋮
    1331		fSanity += afTimeStep * mfSanityRegainSpeed;
    1332		mpPlayer->SetSanity(fSanity);
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1328–1333 at acc95cd · upstream ↗

    Claim page

  13. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxScriptHandler.cpp 1504–1531
    How we know

    A script function sets sanity to 100 when it is under 25, to 90 under 50, and to 80 under 75, and adds 5 above that. Its small version adds 20, 15, 10, or 5 across the same bands.

    1504void __stdcall cLuxScriptHandler::GiveSanityBoost()
    ⋮
    1506	if(gpBase->mpPlayer->GetSanity() < 25.0f)
    1507		gpBase->mpPlayer->AddSanity(100.0f - gpBase->mpPlayer->GetSanity());
    1508	else if(gpBase->mpPlayer->GetSanity() < 50.0f)
    1509		gpBase->mpPlayer->AddSanity(90.0f - gpBase->mpPlayer->GetSanity());
    1510	else if(gpBase->mpPlayer->GetSanity() < 75.0f)
    1511		gpBase->mpPlayer->AddSanity(80.0f - gpBase->mpPlayer->GetSanity());
    1512	else
    1513		gpBase->mpPlayer->AddSanity(5.0f);
    ⋮
    1517//-----------------------------------------------------------------------
    ⋮
    1519void __stdcall cLuxScriptHandler::GiveSanityBoostSmall()
    ⋮
    1521	cLuxPlayer* pPlayer = gpBase->mpPlayer;
    ⋮
    
    amnesia/src/game/LuxScriptHandler.cpp lines 1504–1531 at acc95cd · upstream ↗

    Claim page

  14. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxPlayerHelpers.cpp 1212–1215, 1535–1567, 1569–1583
    How we know

    Under sustained loss of sanity, such as the darkness drain, a heartbeat and a draining sound repeat, faster the lower sanity is: three times as often at 0 as at 100 (computed). A single loss plays neither: each loss keeps the sounds' timers running for one second, too short for either to fire, and they restart from zero once a second passes without a loss. The draining sound has three strengths: one above 75 sanity, one above 50, and one at 50 or below.

    1212void cLuxPlayerSanity::SetSanityLost()
    ⋮
    1214	mfSanityLostCount = 1.0f;
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1212–1215 at acc95cd · upstream ↗
    1537	if(mfSanityLostCount <= 0)
    ⋮
    1544		return;
    ⋮
    1547	float fSanity = mpPlayer->GetSanity();
    1548	float fNormalizedSanity = fSanity / 100.0f;
    ⋮
    1551	mfSanityLostCount -= afTimeStep;
    ⋮
    1553	mfSanityDrainVolume += afTimeStep * 0.1f;
    1554	if(mfSanityDrainVolume > 1) mfSanityDrainVolume =1;
    ⋮
    1556	float mfSpeedMul = 1 + (1 - fNormalizedSanity) * 2.0f;
    ⋮
    1558	mfSanityHeartbeatCount += afTimeStep * mfSpeedMul * 0.1f;
    1559	if(mfSanityHeartbeatCount >= 1)
    ⋮
    1563		float fVol = (1.0f - fNormalizedSanity*0.5f) * mfSanityDrainVolume;
    ⋮
    1566			gpBase->mpHelpFuncs->PlayGuiSoundData("sanity_heartbeat", eSoundEntryType_Gui, fVol);
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1535–1567 at acc95cd · upstream ↗
    1569	mfSanityDrainCount += afTimeStep * mfSpeedMul * 0.33f;
    1570	if(mfSanityDrainCount >= 1)
    ⋮
    1572		mfSanityDrainCount =0;
    1573		tString sSoundFile="";
    1574		if(fSanity > 75)
    1575			sSoundFile = "sanity_drain_low";
    1576		else if(fSanity > 50)
    1577			sSoundFile = "sanity_drain_med"; 
    1578		else
    1579			sSoundFile = "sanity_drain_high";
    ⋮
    1581		if(mpPlayer->IsDead()==false)
    1582			gpBase->mpHelpFuncs->PlayGuiSoundData(sSoundFile, eSoundEntryType_Gui, mfSanityDrainVolume);
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1569–1583 at acc95cd · upstream ↗

    Claim page

  15. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxPlayerHelpers.cpp 1504–1530
    How we know

    While a monster is in sight, the screen takes a pulsing radial blur that builds to full over about 3.3 seconds of looking (computed).

    1506	if(mbEnemyIsSeen)
    ⋮
    1508		if(mfSeenEnemyCount <1)
    ⋮
    1510			mfSeenEnemyCount += afTimeStep * 0.3f;
    ⋮
    1518		float fPulse = 0.5f + (sin(mfT*2.5f)*0.5f + 0.5f)*0.5f;
    ⋮
    1520		gpBase->mpEffectHandler->GetRadialBlur()->SetBlurStartDist(0.2f);
    1521		gpBase->mpEffectHandler->GetRadialBlur()->FadeTo(0.12f * mfSeenEnemyCount*fPulse, 10.0f);
    ⋮
    1525		if(mfSeenEnemyCount > 0)
    ⋮
    1527			mfSeenEnemyCount -= afTimeStep * 0.15f;
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1504–1530 at acc95cd · upstream ↗

    Claim page

  16. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxPlayerHelpers.cpp 1150–1151, 1262–1272, 1293–1295, 1588–1620
    How we know

    Below a sanity level the configuration sets, a wavy distortion covers the screen, stronger the lower sanity falls: its strength is 1 − sanity over that level. Below a second, lower level, also configured, the image smears, the player pants every 0.5 to 5 seconds, and a hint shows.

    1150	mfSanityVeryLowLimit = gpBase->mpGameCfg->GetFloat("Player_Sanity","SanityVeryLowLimit",0);
    1151	mfSanityEffectsStart = gpBase->mpGameCfg->GetFloat("Player_Sanity","SanityEffectsStart",0);
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1150–1151 at acc95cd · upstream ↗
    1262	if(mpPlayer->GetSanity() > mfSanityEffectsStart && mfSanityDrainVolume <=0 && mfInsaneWaveAlpha <=0)
    ⋮
    1264		gpBase->mpPostEffectHandler->GetInsanity()->SetActive(false);
    1265		return;
    ⋮
    1268	gpBase->mpPostEffectHandler->GetInsanity()->SetActive(true);
    ⋮
    1270	float fSanity = mpPlayer->GetSanity();
    1271	float fGoalAlpha = 1 - fSanity / mfSanityEffectsStart;
    1272	if(fGoalAlpha < 0) fGoalAlpha =0;
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1262–1272 at acc95cd · upstream ↗
    1293	gpBase->mpPostEffectHandler->GetInsanity()->SetWaveAlpha(mfInsaneWaveAlpha * mfSanityWaveAlphaMul);//mfInsaneWaveAlpha);
    1294	gpBase->mpPostEffectHandler->GetInsanity()->SetWaveSpeed(mfInsaneWaveAlpha * mfSanityWaveSpeedMul);//*mfInsaneWaveAlpha);
    1295	gpBase->mpPostEffectHandler->GetInsanity()->SetZoomAlpha(mfSanityDrainVolume * fZoomMul);
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1293–1295 at acc95cd · upstream ↗

    1 more excerpts on the claim page

  17. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxInsanityHandler.cpp 921–928, 52–56, 881–884, 745–753, 795–821; LuxArea_Insanity.cpp 104–110
    How we know

    Hallucinations come as events of four kinds: a sound, footsteps, particles, and crawling bugs. Each event has a highest sanity at which it can play. An event starts when the player is in one of a level's insanity areas, sanity is at or below a configured level, and the wait since the last event has run out. The wait is one of three configured lengths, chosen by which of three configured sanity bands the player is in when the last event ends. The event is picked at random among those not yet played, and when all have played they become available again.

    921iLuxInstanityEvent* cLuxInsanityHandler::EventTypeToData(const tString& asType)
    ⋮
    923	tString sLowType = cString::ToLowerCase(asType);
    ⋮
    925    if(sLowType == "soundstream") return hplNew(cLuxInstanityEvent_SoundStream, () );
    926	if(sLowType == "steps") return hplNew(cLuxInstanityEvent_Steps, () );
    927	if(sLowType == "particles") return hplNew(cLuxInstanityEvent_Particles, () );
    928	if(sLowType == "bugs") return hplNew(cLuxInstanityEvent_Bugs, () );
    
    amnesia/src/game/LuxInsanityHandler.cpp lines 921–928 at acc95cd · upstream ↗
    52void iLuxInstanityEvent::LoadData(cXmlElement * apVarElem)
    ⋮
    54	msName = apVarElem->GetAttributeString("Name","Unknown");
    55	msSet = apVarElem->GetAttributeString("Set","");
    56	mfMaxSanity = apVarElem->GetAttributeFloat("MaxSanity",100);
    
    amnesia/src/game/LuxInsanityHandler.cpp lines 52–56 at acc95cd · upstream ↗
    104	if(CollidesWithPlayer())
    ⋮
    106		if(gpBase->mpInsanityHandler->NewEventIsPossible())
    ⋮
    108			if(mbAutoDisable) SetActive(false);
    109			gpBase->mpInsanityHandler->StartEvent();
    
    amnesia/src/game/LuxArea_Insanity.cpp lines 104–110 at acc95cd · upstream ↗

    3 more excerpts on the claim page

  18. ^ abCodeFrictionalGames/AmnesiaTheDarkDescentLuxPlayer.cpp 619–637, 869–881; LuxPlayerHelpers.cpp 109–129, 141–148
    How we know

    When a loss takes sanity below 0, it is held at 0 and the player collapses; in hard mode the player dies instead of recovering. A collapse puts out the lantern, slows the world's sounds to half speed at three-quarters volume, and alerts every active monster in the map to the player.

    619void cLuxPlayer::LowerSanity(float afAmount, bool abUseEffect)
    ⋮
    621	if(mfHealth <=0) return;
    ⋮
    623	mfSanity -= afAmount;
    624	if(mfSanity < 0)
    ⋮
    626		mfSanity =0;
    ⋮
    629		mpInsanityCollapse->Start();
    ⋮
    631		//////////////////
    632		// HARDMODE
    633		if (gpBase->mbHardMode)
    ⋮
    635			SetHealth(0.f);
    
    amnesia/src/game/LuxPlayer.cpp lines 619–637 at acc95cd · upstream ↗
    869void cLuxPlayer::SetSanity(float afX)
    ⋮
    871	mfSanity = afX;
    ⋮
    873	//////////////////
    874	// HARDMODE
    875	if (gpBase->mbHardMode)
    ⋮
    877		if (mfSanity <= 0)
    ⋮
    879			SetHealth(0.f);
    
    amnesia/src/game/LuxPlayer.cpp lines 869–881 at acc95cd · upstream ↗
    109void cLuxPlayerInsanityCollapse::Start()
    ⋮
    115	gpBase->mpHelpFuncs->PlayGuiSoundData(msStartSound, eSoundEntryType_World);
    ⋮
    121	mpPlayer->GetHelperLantern()->SetActive(false,false, false);
    ⋮
    128	pSoundHandler->FadeGlobalVolume(0.75f, 0.15f, eSoundEntryType_World,eLuxGlobalVolumeType_InsanityCollapse, false);
    129	pSoundHandler->FadeGlobalSpeed(0.5f, 0.125f, eSoundEntryType_World,eLuxGlobalVolumeType_InsanityCollapse, false);
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 109–129 at acc95cd · upstream ↗

    1 more excerpts on the claim page

  19. ^CodeFrictionalGames/AmnesiaTheDarkDescentLuxPlayerHelpers.cpp 64, 78, 196–216, 220–253
    How we know

    During a collapse the view sinks and rolls up to 35 degrees while random sounds play. After a time the configuration sets, sanity is set to a configured amount, the world's sounds return, and the view rises back.

    64	mfSleepTime = gpBase->mpGameCfg->GetFloat("Player_General","InsanityCollapse_SleepTime",0);
    
    amnesia/src/game/LuxPlayerHelpers.cpp line 64 at acc95cd · upstream ↗
    78	mfAwakenSanity = gpBase->mpGameCfg->GetFloat("Player_General","InsanityCollapse_AwakenSanity", 0);
    
    amnesia/src/game/LuxPlayerHelpers.cpp line 78 at acc95cd · upstream ↗
    196	if(mlState == 0 || mlState == 1)
    ⋮
    198		//////////////////////
    199		// Height add
    200		if(mfHeightAdd > mfHeightAddGoal)
    ⋮
    202			mfHeightAdd-= mfHeightAddCollapseSpeed*afTimeStep;
    203			if(mfHeightAdd < mfHeightAddGoal)
    ⋮
    205				mfHeightAdd = mfHeightAddGoal;
    206				mlState = 1;
    ⋮
    208			mpPlayer->SetHeadPosAdd(eLuxHeadPosAdd_InsanityCollapse, cVector3f(0,mfHeightAdd,0));
    ⋮
    211		//////////////////////
    212		// Roll
    213		mfRoll += cMath::ToRad(mfRollCollapseSpeed)*afTimeStep;
    ⋮
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 196–216 at acc95cd · upstream ↗

    1 more excerpts on the claim page

  20. ^ abCodeFrictionalGames/AmnesiaTheDarkDescentLuxPlayerHelpers.cpp 1870–1876, 2257–2281
    How we know

    Code that would top up health, sanity, and oil to random amounts between configured bounds after a death is commented out, though the bounds are still read from the configuration.

    1870	mfMaxSanityGain = gpBase->mpGameCfg->GetFloat("Player_General","Death_MaxSanityGain",0);
    1871	mfMaxHealthGain = gpBase->mpGameCfg->GetFloat("Player_General","Death_MaxHealthGain",0);
    1872	mfMaxOilGain = gpBase->mpGameCfg->GetFloat("Player_General","Death_MaxOilGain",0);
    ⋮
    1874	mfMinSanityGain = gpBase->mpGameCfg->GetFloat("Player_General","Death_MinSanityGain",0);
    1875	mfMinHealthGain = gpBase->mpGameCfg->GetFloat("Player_General","Death_MinHealthGain",0);
    1876	mfMinOilGain = gpBase->mpGameCfg->GetFloat("Player_General","Death_MinOilGain",0);
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 1870–1876 at acc95cd · upstream ↗
    2257    /*if(gpBase->mpSaveHandler->AutoLoad())
    ⋮
    2269		if(fSanity < mfMaxSanityGain)
    ⋮
    2271			fSanity = cMath::RandRectf(cMath::Max(fSanity, mfMinSanityGain), mfMaxSanityGain);
    ⋮
    2273		if(fOil < mfMaxHealthGain)
    ⋮
    2275			fOil = cMath::RandRectf(cMath::Max(fOil, mfMinOilGain), mfMaxOilGain);
    ⋮
    2281	}*/
    
    amnesia/src/game/LuxPlayerHelpers.cpp lines 2257–2281 at acc95cd · upstream ↗

    Claim page

Sources

Code