Basic stamina system - 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 - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Articles (https://www.frictionalgames.com/forum/forum-40.html) +---- Thread: Basic stamina system (/thread-16949.html) Pages:
1
2
|
Basic stamina system - Your Computer - 07-13-2012 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. Here is the code for the stamina system: PHP Code: const string STAMINA_TIMER_CALLBACK_NAME = "STAMINA_TIMER_CALLBACK";
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: PHP Code: void OnEnter() In action: RE: Basic stamina system - Bas - 07-14-2012 Hilarious if you could gain stamina after enabling an energydrink. RE: Basic stamina system - Ironbard - 07-15-2012 Pretty sweet, I am trying to make something similar for a mod me and some friends are working on RE: Basic stamina system - nemesis567 - 07-17-2012 I think I'm missing something. Why do you use the this pointer all the time? Is that necessary? RE: Basic stamina system - Your Computer - 07-18-2012 (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). RE: Basic stamina system - finScript - 08-27-2012 Where should I put this code to make it work? RE: Basic stamina system - DnALANGE - 08-23-2013 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 ! RE: Basic stamina system - Daemian - 08-23-2013 How nice. I actually did something alike in my mod. It works different, it stops when the player stops running. I didn't know how to call it, so i put "auto sprint". But it's basically the guy running faster over time. PHP Code: Onstart{ PHP Code: // SPRINT { 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. RE: Basic stamina system - Your Computer - 08-23-2013 (08-23-2013, 07:29 PM)Amn Wrote: Hey YC, just a question, why you declare these constants? 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. RE: Basic stamina system - Kullin - 09-03-2013 Hey, this might sound noobish, but where should i put everything? :p |