Edit detail for StaminaModel revision 4 of 36

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
Editor: DonovanBaarda
Time: 2012/10/19 22:52:02 GMT-4
Note:

changed:
-  M = 1 + Km*E
  M = 1.0 + Km*E

changed:
-  Km = 1, for a max lift of 1x your own body weight.
-
-A real max lift is about 2x your own body weight, but anything over 1x is totally impractical. I suggest Km=1 so that the top-half of the encumbrance bar doesn't go unused and give players an unrealistic impression of how much they can carry. Note the largest professional rugby league player is 133Kg, though 100~125Kg is probably more realistic for a big hero.
  Km = 1.0, for a max lift in number of your own body weights.

A real max lift is about 2x your own body weight, but anything over 1x is unsustainable. I suggest Km=1.0 so that the top-half of the encumbrance bar doesn't go unused and give players an unrealistic impression of how much they can carry. Note the largest professional rugby league player is 133Kg, though 100~125Kg is probably more realistic for a big hero's bodyweight.

changed:
-When you are damaged/healed and your health changes, it damages/restores some of both fatigued and unfatigued muscles. There should be a change in S that reflects this. For a change in health of dH::
Whenever you are damaged/healed and your health changes, it damages/restores some of both fatigued and unfatigued muscles. There should be a change in S that reflects this. For a change in health of dH::

added:
If S < Smin you are too tired to lift that much weight and collapse.


changed:
-  dS = -F * Smin * dt
-
-If S < Smin you are too tired to lift that much weight and collapse.
  Elift = Smin
  dS = -F * Elift * dt

Where::

  Elift is the fraction of all muscles applied to lifting.

changed:
-  dS = R * (Smax - S) * dt
  Erest = (Smax - S)
  dS = R * Erest * dt

Where::

  Erest is the fraction of all muscles that are fatigued and resting.

changed:
-Going uphill doesn't affect stamina burn rates, but it does modify movement speed. Going downhill doesn't have much effect at all::
Going uphill burns extra energy, ultimately slowing you down. Going downhill doesn't burn any extra energy::

added:
  horizRate = dh/dd = cos(climbAngle)
  climbSpeed = climbRate * moveSpeed
  horizSpeed = horizRate * moveSpeed
  Eclimb = Kc * M * max(0,climbSpeed)
  dS = -F * Eclimb * dt

changed:
-  climbRate is vertical displacement per total distance moved.
  climbRate is vertical movement per total distance moved.
  horizRate is horizontal movement per total distance moved.
  moveSpeed is movement speed as a fraction of max horizontal running speed.
  climbSpeed is vertical speed as a fraction of max horizontal running speed.
  horizSpeed is horizontal speed as a fraction of max horizontal running speed. 
  Kc = 6, climbing vertical is Kc x the cost of running the same horizontal distance.
  Eclimb is the fraction of all muscles applied to climbing.

changed:
-  Kc = 4, so climbing vertical is Kc+1 = 5x the cost of running horizontally.

Record 15m speed climbing top speed is 6.26sec, or about 2m/sec, compared to 100m record top speeds of about 12m/sec. This suggest climbing uses as much energy as going 6x the distance horizontally, but some documentation suggests it is 10x. It often surprises players how much affect climbing really has, so for playability you may want to lower Kc.

removed:
-
-Record 15m speed climbing top speed is 6.26sec, or about 2m/sec, compared to 100m record top speeds of about 12m/sec. This suggest climbing uses as much energy as going 6x the distance horizontally, but some documentation suggests it is 10x. It often surprises players how much affect climbing really has, so we use Kc=4 for playability.

changed:
-  dS = -F * 16 * walkSpeed^3 = -F * 16*Ks^3 * (S - Smin) * dt
  Ewalk = 16 * M * horizSpeed^3
  dS = -F * Ewalk * dt = -F * 16*Ks^3 * (S - Smin) * dt

changed:
-  dS = -F * runSpeed/climbScale = -F * (S - Smin) * dt
-  runSpeed = climbScale * (S - Smin)/M
  Erun = M*horizSpeed
  dS = -F * Erun * dt = -F * (S - Smin) * dt
  moveSpeed = climbScale * (S - Smin)/M

changed:
-  runSpeed is the running speed as a fraction of max running speed.
  moveSpeed is the running speed as a fraction of max running speed.

changed:
-  jumpScale = (S - Smin)/(1 + Kj*E)
  jumpScale = (S - Smin)/M

changed:
-  jumpVelocity is take-off velocity (for physics models).
  jumpHeight is the height of the jump in meters.
  jumpVelocity is take-off velocity in meters/sec (for physics models).

The RealisticFatigue? document was a bit too messy and Oblivion specific. This is an attempt to tidy and simplify it into something that can be used for other games. In particular, "stamina" is a better name than "fatigue".

Basic Attributes

The following attributes are in the range 0.0 (empty) to 1.0 (full). Note that there can be underlying health/strength/endurance/etc attributes that translate these into different numbers, but from the fatigue models point of view, the only thing that matters is the fraction of full health/stamina/encumbrance:

H - health. The fraction of life remaining after taking damage.
S - stamina. The fraction of un-damaged, un-fatigued muscles available for lifting/moving/fighting/etc.
E - encumbrance. The fraction of max lift worth of equipment currently carried.

The following constants adjust how quickly you get tired and recover. They are normally constants but could be tweaked per-character based on some endurance attribute:

F - stamina burn rate, stamina/second
R - stamina recovery rate, stamina/second

Note that R/(F+R) is the "steady state" or minimum S value reached for constant activity, so the the R/F ratio is important. Studies show F is 0.008~0.033, R is 0.0026~0.013, and F/R is 0.3~0.5, so F=0.03, R=0.01, for F/R = 1/3 is realistic, and gives an average fatigue recovery rate of 0.5%/sec. However for gameplay reasons speeding it up to F=0.9, R=0.03 might be better.

Many of the formulas use the total mass of the player in body-weights which is calculated as:

M = 1.0 + Km*E

Where:

Km = 1.0, for a max lift in number of your own body weights.

A real max lift is about 2x your own body weight, but anything over 1x is unsustainable. I suggest Km=1.0 so that the top-half of the encumbrance bar doesn't go unused and give players an unrealistic impression of how much they can carry. Note the largest professional rugby league player is 133Kg, though 100~125Kg is probably more realistic for a big hero's bodyweight.

Wounds

Wounds are modeled as damaged muscles, reducing your available muscles for running/fighting/etc. It applies a constant "drain" or cap on your stamina. This could be indicated as a red max stamina marker on the top end of the stamina bar:

Smax = H^(1/Kh)

Where:

Kh=2, but can be tuned up to delay the onset of wound effects.

Note RF uses Smax=1-(1-H)^Kh instead, which compared to the above makes drains less for small injuries, but more for big ones, making it harder to "turn the tables" in combat. The above formula is probably better for gameplay.

Whenever you are damaged/healed and your health changes, it damages/restores some of both fatigued and unfatigued muscles. There should be a change in S that reflects this. For a change in health of dH:

H = H + dH
dSmax = H^(1/Kh) - Smax
dS = dSmax * S/Smax
Smax = Smax + dSmax
S = S + dS

Where:

dH is the change in health.
dSmax is the change in Smax
dS is the change in S

Note this ensures that at low stamina a hit winds you a bit, but not too much.

Encumbrance

Encumbrance preoccupies muscles, leaving less available for running/attacking/etc, and there is a minimum stamina required to lift everything you are carrying. It can be shown using a black min stamina marker on the bottom end of the stamina bar. These preoccupied muscles also should be subtracted from S when considering how fast you can run, hard you can hit etc:

Smin = (Km/2 * E)^Ke

Where:

Ke=2, but can be tuned up to delay the onset of encumbrance effects.

If S < Smin you are too tired to lift that much weight and collapse.

Note RF implements this as an additional "drain" on S, but that is slightly miss-leading as it is not really damaged/fatigued muscles and thus should not affect fatigue indicators like panting etc.

Lifting stuff not only pre-occupies muscles, but also fatigues them. This is how stamina is constantly burned by encumbrance when standing:

Elift = Smin
dS = -F * Elift * dt

Where:

Elift is the fraction of all muscles applied to lifting.

Recovery

Fatigued muscles (that are not wounded) continuously recover at a constant rate. This is how stamina recovers:

Erest = (Smax - S)
dS = R * Erest * dt

Where:

Erest is the fraction of all muscles that are fatigued and resting.

Note that stamina S cannot increase past Smax.

Climbing

Going uphill burns extra energy, ultimately slowing you down. Going downhill doesn't burn any extra energy:

climbRate = dz/dd = sin(climbAngle)
horizRate = dh/dd = cos(climbAngle)
climbSpeed = climbRate * moveSpeed
horizSpeed = horizRate * moveSpeed
Eclimb = Kc * M * max(0,climbSpeed)
dS = -F * Eclimb * dt
climbScale = 1/(1 + Kc*max(0,climbRate))

Where:

dz is vertical travel distance.
dd is total travel distance.
climbAngle is the elevation angle of the direction traveled.
climbRate is vertical movement per total distance moved.
horizRate is horizontal movement per total distance moved.
moveSpeed is movement speed as a fraction of max horizontal running speed.
climbSpeed is vertical speed as a fraction of max horizontal running speed.
horizSpeed is horizontal speed as a fraction of max horizontal running speed.
Kc = 6, climbing vertical is Kc x the cost of running the same horizontal distance.
Eclimb is the fraction of all muscles applied to climbing.
climbScale is the speed scaling factor for climbing.

Record 15m speed climbing top speed is 6.26sec, or about 2m/sec, compared to 100m record top speeds of about 12m/sec. This suggest climbing uses as much energy as going 6x the distance horizontally, but some documentation suggests it is 10x. It often surprises players how much affect climbing really has, so for playability you may want to lower Kc.

climbRate should probably be low-pass filtered so jitter/bob doesn't burn fatigue like crazy. This is done by actually calculating it with:

climbRate = (dt*ds/dd + RC*climbRate)/(dt + RC)

Where:

RC = 0.5, but can be tweaked to adjust smoothing.

Walking

This is how stamina is burned when walking, and how walking speed varies with stamina and encumbrance:

Ewalk = 16 * M * horizSpeed^3
dS = -F * Ewalk * dt = -F * 16*Ks^3 * (S - Smin) * dt
walkSpeed = climbScale^(2/3) * Ks * ((S - Smin)/M)^(1/3)

Where:

Ks = 0.25 is max walking speed as a fraction of max run speed. Can be tuned down to reduce walking speed and stamina burn.
walkSpeed is walking speed as a fraction of max run speed.

Note Kw=0.25 represents a realistic maximum fast walking speed of around 2.5m/sec. Using Kw=0.2 would be like a more casual walking speed of 2m/sec, and significantly reduces the stamina burn.

Running

This is is how stamina is burned when running, and running speed varies with stamina and encumbrance:

Erun = M*horizSpeed
dS = -F * Erun * dt = -F * (S - Smin) * dt
moveSpeed = climbScale * (S - Smin)/M

where:

moveSpeed is the running speed as a fraction of max running speed.

Record 100m top speeds average about 10m/sec and peak at 12m/sec. A realistic maximum running speed (for a hero) would be about 10m/sec.

Jumping

This is how stamina is burned by jumping, and how jump height varies with stamina and encumbrance:

dS = -F * (S - Smin)
jumpScale = (S - Smin)/M
jumpVelocity = sqrt(2*g*jumpHeight)

Where:

Kj = 2, but can be tuned down to reduce encumbrance effects on jumping.
jumpScale is the jump height as a fraction of max jump height.
jumpHeight is the height of the jump in meters.
jumpVelocity is take-off velocity in meters/sec (for physics models).
g = 9.81m/s^2 is the gravitational constant.

A jump burns as much fatigue as running for 1 second. A realistic max vertical jump height (for a hero) would be 1m.

Attacking/Blocking

The speed and effectiveness of attacks and blocks depends on available stamina, and also burns stamina:

dS = -F * W * (S - Smin)