Frictional Games Forum (read-only)
Need a bit of help - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Need a bit of help (/thread-56211.html)



Need a bit of help - RaXZerGamingZ - 01-19-2019

Hello

I am working on a small custom story and i need some commands to work but they aren't working. I need the player's max Health and Sanity to be 50 instead of 100 and i can't get it to work. Help is appreciated.


RE: Need a bit of help - Mudbill - 01-19-2019

In your script file, all you need to do is add 2 lines of code to your OnStart method.

PHP Code:
void OnStart()
{
    SetPlayerHealth(50.0f);
    SetPlayerSanity(50.0f); 


You can find these functions on the wiki page: HPL2 Scripts


RE: Need a bit of help - RaXZerGamingZ - 01-19-2019

haha i guess i overthought it, does this method also prevent the player from having more than 50 HP/Sanity by using Sanity Potions or Sanity rewards from completing puzzles?

Edit: tested it and it doesn't, is it possible to do that?


RE: Need a bit of help - Darkfire - 01-20-2019

Yes, it's expected. You could run a looping timer to always reduce the health to 50 if the player goes above the limit.
The timer frequency is set to an amount which shouldn't bug the game, but it's fast enough for players not to notice the change.
You also need to start the timer somewhere. And use RemoveTimer to stop it

Code:
void HealthCap(string &in asTimer)
{
   AddTimer("loop", 0.4f, "HealthCap");
   if( GetPlayerHealth()  > 50.0f)
   {
       SetPlayerHealth(50.0f);
   }
}



RE: Need a bit of help - RaXZerGamingZ - 01-20-2019

Interesting method, I'll see if it needs to be added but I think the custom story would work without it, i'll see.


RE: Need a bit of help - Mudbill - 01-20-2019

Use it if you must, but avoid it if possible. Darkfire did consider this so the example isn't bad, but I want to elaborate on "bug the game."

Every time a callback is triggered (including timers), an index is incremented. This index must not exceed 65535, else the game will crash upon next loading screen.

Usually this is only a worry if you use a rapidly repeating timer. Darkfire's example loops about 5 times in 2 seconds, so it's frequent, but not rapid. To put this into perspective, if you loop a timer as fast as possible, being 60 times in 1 second, you will hit the limit in about 15 minutes of gameplay.

If you can avoid hitting the limit in about 3 hours, I say you're good to do as you please regarding these. This is an engine limitation.