modernuo/Projects/UOContent/Misc/StaminaSystem.cs

513 lines
15 KiB
C#
Raw Permalink Normal View History

using System;
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ModernUO.CodeGeneratedEvents;
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
using Server.Collections;
using Server.Logging;
using Server.Mobiles;
using Server.Spells.Ninjitsu;
namespace Server.Misc;
public enum DFAlgorithm
{
Standard,
PainSpike
}
public static class StaminaSystem
{
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
private static readonly ILogger logger = LogFactory.GetLogger(typeof(StaminaSystem));
private static readonly TimeSpan ResetDuration = TimeSpan.FromHours(4);
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
private static readonly Dictionary<PlayerMobile, IHasSteps> _etherealMountStepCounters = [];
private static readonly Dictionary<IHasSteps, StepsTaken> _stepsTaken = [];
private static readonly HashSet<IHasSteps> _resetHash = [];
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
// TODO: This exploits single thread processing and is not thread safe!
public static DFAlgorithm DFA { get; set; }
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
public static int StonesOverweightAllowance { get; set; }
public static bool CannotMoveWhenFatigued { get; set; }
public static int StonesPerOverweightLoss { get; set; }
public static int BaseOverweightLoss { get; set; }
public static double AdditionalLossWhenBelow { get; set; }
public static bool EnableMountStamina { get; set; }
public static bool UseMountStaminaOnlyWhenOverloaded { get; set; }
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
// Pub 46 (UOML+)
public static bool GlobalEtherealMountStamina { get; set; }
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
public static void Configure()
{
CannotMoveWhenFatigued = ServerConfiguration.GetOrUpdateSetting("stamina.cannotMoveWhenFatigued", !Core.AOS);
StonesPerOverweightLoss = ServerConfiguration.GetOrUpdateSetting("stamina.stonesPerOverweightLoss", 25);
StonesOverweightAllowance = ServerConfiguration.GetOrUpdateSetting("stamina.stonesOverweightAllowance", 4);
BaseOverweightLoss = ServerConfiguration.GetOrUpdateSetting("stamina.baseOverweightLoss", 5);
AdditionalLossWhenBelow = ServerConfiguration.GetOrUpdateSetting("stamina.additionalLossWhenBelow", 0.10);
EnableMountStamina = ServerConfiguration.GetOrUpdateSetting("stamina.enableMountStamina", true);
UseMountStaminaOnlyWhenOverloaded = ServerConfiguration.GetSetting("stamina.useMountStaminaOnlyWhenOverloaded", Core.SA);
GlobalEtherealMountStamina = ServerConfiguration.GetSetting("stamina.globalEtherealMountStamina", Core.ML);
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
public static void Initialize()
{
EventSink.Movement += EventSink_Movement;
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
EventSink.Logout += Logout;
// Credit idle time
using var queue = PooledRefQueue<IHasSteps>.Create();
foreach (var m in _stepsTaken.Keys)
{
// We cannot remove since we are iterating.
ref var stepsTaken = ref RegenSteps(m, out var exists, removeOnInvalidation: false);
if (exists && stepsTaken.Steps <= 0)
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
queue.Enqueue(m);
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
}
while (queue.Count > 0)
{
_stepsTaken.Remove(queue.Dequeue());
}
}
[OnEvent(nameof(PlayerMobile.PlayerDeletedEvent))]
public static void OnPlayerDeleted(Mobile m)
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
RemoveEntry(m as IHasSteps);
}
[OnEvent(nameof(PlayerMobile.PlayerLoginEvent))]
public static void OnLogin(PlayerMobile pm)
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
bool exists;
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
if (EnableMountStamina)
{
// Start idle for mount
ref var stepsTaken = ref GetStepsTaken(pm.Mount, out exists);
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
if (exists)
{
if (stepsTaken.Steps <= 0 || Core.Now >= stepsTaken.IdleStartTime + ResetDuration)
{
_stepsTaken.Remove(pm.Mount);
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
else
{
stepsTaken.IdleStartTime = Core.Now;
}
}
_resetHash.Remove(pm.Mount);
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
ref var regenStepsTaken = ref RegenSteps(pm, out exists);
if (exists)
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
regenStepsTaken.IdleStartTime = Core.Now;
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
}
private static void Logout(Mobile m)
{
if (_stepsTaken == null || _stepsTaken.Count == 0)
{
return;
}
if (EnableMountStamina)
{
// Regain mount idle time
ref var stepsTaken = ref RegenSteps(m.Mount, out var exists);
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
if (exists)
{
stepsTaken.IdleStartTime = Core.Now;
_resetHash.Add(m.Mount);
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
}
if (m is PlayerMobile pm)
{
ref var stepsTaken = ref RegenSteps(pm, out var exists);
if (exists)
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
stepsTaken.IdleStartTime = Core.Now;
}
}
}
private static bool IsEthereal(IHasSteps m, out PlayerMobile pm)
{
if (m is not EtherealMount and not VirtualMountItem)
{
pm = null;
return false;
}
pm = ((IMount)m).Rider as PlayerMobile;
return pm != null;
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
public static void RemoveEntry(IHasSteps m)
{
if (m == null)
{
return;
}
if (GlobalEtherealMountStamina && IsEthereal(m, out var pm))
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
_etherealMountStepCounters.Remove(pm);
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
_stepsTaken.Remove(m);
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
public static void OnDismount(IMount mount)
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
if (!EnableMountStamina)
{
return;
}
if (RegenSteps(mount))
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
_resetHash.Add(mount);
return;
}
_resetHash.Remove(mount);
}
private static ref StepsTaken GetStepsTaken(IHasSteps m, out bool exists)
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
if (m == null)
{
exists = false;
return ref Unsafe.NullRef<StepsTaken>();
}
if (GlobalEtherealMountStamina && IsEthereal(m, out var pm))
{
ref var stepsCounter = ref CollectionsMarshal.GetValueRefOrNullRef(_etherealMountStepCounters, pm);
if (Unsafe.IsNullRef(ref stepsCounter))
{
exists = false;
return ref Unsafe.NullRef<StepsTaken>();
}
m = stepsCounter;
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
ref var stepsTaken = ref CollectionsMarshal.GetValueRefOrNullRef(_stepsTaken, m);
exists = !Unsafe.IsNullRef(ref stepsTaken);
return ref stepsTaken;
}
private static ref StepsTaken GetOrCreateStepsTaken(IHasSteps m, out bool created)
{
if (GlobalEtherealMountStamina && IsEthereal(m, out var pm))
{
ref var stepsCounter = ref CollectionsMarshal.GetValueRefOrAddDefault(_etherealMountStepCounters, pm, out var stepsCounterExists);
if (!stepsCounterExists)
{
stepsCounter = new EtherealMountStepCounter();
}
m = stepsCounter;
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
ref var stepsTaken = ref CollectionsMarshal.GetValueRefOrAddDefault(_stepsTaken, m, out var exists);
created = !exists;
if (created)
{
stepsTaken.Entity = m;
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
return ref stepsTaken;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool RegenSteps(IHasSteps m, int amount = 0, bool removeOnInvalidation = true)
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
RegenSteps(m, out var exists, amount, removeOnInvalidation);
return exists;
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
// Triggered on logout, dismount, and world load
private static ref StepsTaken RegenSteps(IHasSteps m, out bool exists, int amount = 0, bool removeOnInvalidation = true)
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
if (m == null)
{
exists = false;
return ref Unsafe.NullRef<StepsTaken>();
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
ref var stepsTaken = ref GetStepsTaken(m, out exists);
if (!exists)
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
return ref Unsafe.NullRef<StepsTaken>();
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
exists = RegenSteps(ref stepsTaken, amount, removeOnInvalidation);
return ref stepsTaken;
}
private static bool RegenSteps(ref StepsTaken stepsTaken, int amount = 0, bool removeOnInvalidation = true)
{
var entity = stepsTaken.Entity;
var stepsGained = (int)((Core.Now - stepsTaken.IdleStartTime) / entity.IdleTimePerStepsGain * entity.StepsGainedPerIdleTime);
stepsTaken.Steps -= stepsGained + amount;
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
if (stepsTaken.Steps <= 0)
{
if (removeOnInvalidation)
{
RemoveEntry(entity);
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
return false;
}
stepsTaken.Steps = 0;
}
return true;
}
public static void FatigueOnDamage(Mobile m, int damage)
{
var fatigue = DFA switch
{
DFAlgorithm.Standard => damage * (100.0 / m.Hits) * ((double)m.Stam / 100) - 5.0,
DFAlgorithm.PainSpike => damage * (100.0 / m.Hits + (50.0 + m.Stam) / 100 - 1.0) - 5.0,
_ => 0.0
};
if (fatigue > 0)
{
m.Stam -= (int)fatigue;
}
}
public static int GetMaxWeight(Mobile m) => m.MaxWeight;
public static void EventSink_Movement(MovementEventArgs e)
{
var from = e.Mobile;
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
if (!from.Player || !from.Alive || from.AccessLevel > AccessLevel.Player)
{
return;
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
var maxWeight = GetMaxWeight(from) + StonesOverweightAllowance;
var overweight = Mobile.BodyWeight + from.TotalWeight - maxWeight;
if (EnableMountStamina && from.Mount != null)
{
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
ProcessMountMovement(from.Mount, overweight, e);
}
else
{
ProcessPlayerMovement(overweight, e);
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
DeathStrike.AddStep(from);
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
private static void ProcessPlayerMovement(int overweight, MovementEventArgs e)
{
var from = e.Mobile;
var running = (e.Direction & Direction.Running) != 0;
if (overweight > 0)
{
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
var stamLoss = GetStamLoss(from, overweight, running);
from.Stam -= stamLoss;
if (from.Stam <= 0)
{
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
// You are too fatigued to move, because you are carrying too much weight!
from.SendLocalizedMessage(500109);
e.Blocked = true;
return;
}
}
if (!running)
{
return;
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
if (AdditionalLossWhenBelow > 0 && from.Stam / Math.Max(from.StamMax, 1.0) < AdditionalLossWhenBelow)
{
--from.Stam;
}
if (CannotMoveWhenFatigued && from.Stam <= 0)
{
from.SendLocalizedMessage(500110); // You are too fatigued to move.
e.Blocked = true;
return;
}
if (from is PlayerMobile pm)
{
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
ref StepsTaken stepsTaken = ref GetOrCreateStepsTaken(pm, out var created);
if (!created)
{
RegenSteps(ref stepsTaken, removeOnInvalidation: false);
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
var steps = ++stepsTaken.Steps;
// 3x steps if mounted is used when EnableMountStamina is false
var maxSteps = pm.StepsMax * (from.Mount != null ? 3 : 1);
if (steps > maxSteps)
{
--pm.Stam;
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
stepsTaken.Steps = 0;
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
stepsTaken.IdleStartTime = Core.Now;
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
private static void ProcessMountMovement(IMount mount, int overweight, MovementEventArgs e)
{
var from = e.Mobile;
var maxSteps = mount.StepsMax;
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
var running = (e.Direction & Direction.Running) != 0;
var stamLoss = overweight > 0 ? GetStamLoss(from, overweight, running) : 0;
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
if (stamLoss <= 0 && (!running || UseMountStaminaOnlyWhenOverloaded))
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
return;
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
ref var stepsTaken = ref GetOrCreateStepsTaken(mount, out var created);
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
if (!created)
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
RegenSteps(ref stepsTaken, removeOnInvalidation: false);
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
stepsTaken.Steps += stamLoss + 1;
stepsTaken.IdleStartTime = Core.Now;
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
if (stepsTaken.Steps > maxSteps)
{
stepsTaken.Steps = maxSteps;
from.SendLocalizedMessage(500108); // Your mount is too fatigued to move.
e.Blocked = true;
}
}
public static int GetStamLoss(Mobile from, int overWeight, bool running)
{
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
var loss = BaseOverweightLoss + overWeight / StonesPerOverweightLoss;
if (from.Mounted)
{
loss /= 3;
}
if (running)
{
loss *= 2;
}
return loss;
}
public static bool IsOverloaded(Mobile m)
{
if (!m.Player || !m.Alive || m.AccessLevel > AccessLevel.Player)
{
return false;
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
return Mobile.BodyWeight + m.TotalWeight > GetMaxWeight(m) + StonesOverweightAllowance;
}
private struct StepsTaken
{
public IHasSteps Entity;
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
public int Steps;
public DateTime IdleStartTime;
}
private class ResetTimer : Timer
{
private static readonly TimeSpan _checkDuration = TimeSpan.FromHours(1);
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
private DateTime _nextCheck;
public ResetTimer() : base(TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5)) => _nextCheck = Core.Now;
public static void Initialize()
{
new ResetTimer().Start();
}
~ResetTimer()
{
StaminaSystem.logger.Error($"{nameof(ResetTimer)} is no longer running!");
}
protected override void OnTick()
{
if (Core.Now < _nextCheck)
{
return;
}
if (_resetHash.Count > 0)
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
using var queue = PooledRefQueue<IHasSteps>.Create();
ref StepsTaken stepsTaken = ref Unsafe.NullRef<StepsTaken>();
foreach (var m in _resetHash)
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
stepsTaken = ref GetStepsTaken(m, out var exists);
if (!exists || Core.Now >= stepsTaken.IdleStartTime + ResetDuration)
{
queue.Enqueue(m);
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
if (_resetHash.Count == queue.Count)
{
_resetHash.Clear();
}
else
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
{
while (queue.Count > 0)
{
_resetHash.Remove(queue.Dequeue());
}
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
}
_nextCheck = Core.Now + _checkDuration;
feat: Adds Stamina System to overhaul overweight. (#1465) ## Overhaul to Stamina (Overweight) System ### Added configurations ```json { "settings": { "stamina.enableMountStamina": "True", "stamina.cannotMoveWhenFatigued": "True", "stamina.stonesPerOverweightLoss": "25", "stamina.stonesOverweightAllowance": "4", "stamina.baseOverweightLoss": "5", "stamina.additionalLossWhenBelow": "0.1", "stamina.mountLastMoveStepsReset": "01:00:00:00", "stamina.enableMountStamina": "True", "stamina.useMountStaminaOnlyWhenOverloaded": "False", }, } ``` - `stamina.cannotMoveWhenFatigued` - By default, Pre-AOS expansions will outright block a player if they are fatigued. A player is fatigued when they run out of stamina by any mechanism. - `stamina.stonesPerOverweightLoss` - The amount of stamina lost for every X stones above overweight. Example, if a person is overweight 28 stones overweight, then there there is 1 additional stamina. 28 / 25 = 1 (no decimals, no rounding) - `stamina.stonesOverweightAllowance` - The number of stones allowed before overweight penalties take affect. This _does not_ substract from the overweight stones calculation. - `stamina.baseOverweightLoss` - The base amount of stamina loss for being overweight. While running, the final amount is multiplied by 2. If mount stamina is turned off, then the final amount is divided by 3 while mounted. ### Mount stamina Mounts have a new property `StepsMax` to determine the maximum steps they can take before being fatigued. To regain steps, the player _must stay on the mount and not move_ (per OSI). The gain rates are configurable. If a mount is dismounted, or the player logs off, the mount is considered inactive and mounts regain all of their steps after _24 hours_. ### Changes to player stamina Players now have a proper inactivity time reset for their steps. If a player is idle for 16 seconds (including logging off, or the server being offline), then the steps counter is rest. ### Developer Notes - `StepsTaken` - This field has been removed. It was not serialized and could not be used reliably. If a developer was using it, then the recommendation is to build a mechanism to track total steps another way. - `IHasStamina` - This new interface was added and currently `IMount` and `PlayerMobile` are valid types. Important: Entities that are sent to the StaminaSystem for tracking (mounts, players, or something else), must be an `ISerializable` to be serialized properly. If they are not, then the serialization system will record a null, and nothing will be deserialized upon world load. No errors will be given.
2023-09-16 17:52:54 -07:00
}
}
// Placeholder for a special case where Ethereal mount steps are global to the player
private class EtherealMountStepCounter : IHasSteps
{
// The properties are not actually used
public int StepsMax => 3840;
public int StepsGainedPerIdleTime => 1;
public TimeSpan IdleTimePerStepsGain => TimeSpan.FromSeconds(1);
}
}