This is something i've been meaning to create for a while but was busy deciding how i should handle this. Unfortunately (though not entirely), Amnesia uses an outdated version of AngelScript, so i had to rely on classes as a means of imitating namespaces. Likewise unfortunate, in AngelScript functions are taken as "read-only" and the engine doesn't look for member functions for what i was trying to do, so i couldn't create proxies for the AddTimer function by changing the "pointers" of functions to member functions.
StaminaSystem:tate is the current "StaminaStage" of the player.
StaminaSystem::length is the amount of time in seconds that the player is allowed to run for before entering a more exhausted state.
StaminaSystem::is_running holds whether or not the player is understood to be "running." Use StaminaSystem::IsPlayerRunning() to access the variable outside of the class. (Note: StaminaSystem must have been started in order for this to return expected values.)
StaminaSystem::head_bobbing is used to store a toggle state to determine which direction the player's head should move in.
The StaminaStages values should be self-explanatory.
When the player reaches the StaminaStages::Exhausted state, the player is prevented from moving for 1/2 the time of StaminaSystem::length; and when the player reaches StaminaStages::Low and is not running, 1/4 the time of StaminaSystem::length is required to regain full stamina.
To activate it for your map, having something as simple as this is enough:
(07-17-2012, 11:00 PM)nemesis567 Wrote: I think I'm missing something. Why do you use the this pointer all the time? Is that necessary?
Mostly for readability. It's not required to do that when accessing a member (except when a variable with the same name as another member is declared within the same, local scope).
I took it and works perfectly fine!
Also it is sort of random here for the breathing and walking again!
Awesome feature!
Also i added some FadeImageTrailTo(5,1); for the exausted part, gives it that little extra.
Nice toutch Your computer, + rep for that !
(This post was last modified: 08-23-2013, 05:45 PM by DnALANGE.)
It's useful for large levels.
If you change fBonusMax speed goes to hell.
Hey YC, just a question, why you declare these constants? STAMINA_PLAYER_HEAD_BOB = "STAMINA_PLAYER_HEAD_BOB";
Just to avoid writing quotation marks? I'm curious.
(08-23-2013, 07:29 PM)Amn Wrote: Hey YC, just a question, why you declare these constants? STAMINA_PLAYER_HEAD_BOB = "STAMINA_PLAYER_HEAD_BOB";
Just to avoid writing quotation marks? I'm curious.
I used them in multiple places in my script. So, if i ever choose to edit the string value, i won't have to search for every location i used it in, i can just change the value and it'll be reflected across the script.