Edit detail for StaminaModel revision 9 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/26 13:21:14 GMT-4
Note:

changed:
-  moveSpeed = climbScale * Ks * ((S - Smin)/M)^(1/3)
-  Ewalk = Kw * M * Vh^3 = Kw * M * (V * horizRate)^3 = climbScale * Ks * (S - Smin)
  moveSpeed = climbScale * Ks * ((S - Smin)/M)^(1/2)
  Ewalk = Kw * M * V^2 = Kw * M * (V * horizRate)^3 = climbScale * Ks * (S - Smin)

changed:
-  Erun = Kr * M * horizSpeed
  Erun = Kr * M * V

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, the 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. If you want you can allow temporary heavy lifts where E > 1.0 (over encumbered) and have them drop it or collapse when S < Smin.

Note the largest professional rugby league player is 133Kg, though 100~125Kg is probably more realistic for a big hero's bodyweight.

Movement speeds are measured as the fraction of Max unencumbered, unfatiged flat running speed:

V is fraction of Max speed.

Wounds

Wounds are modelled 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.0, 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:

Km=1.0, for a max lift in number of your own body weights.
Ke=2.0, 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.

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.

Lifting

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

Elift = Kl * Smin
dS = -F * Elift * dt

Where:

Kl=1.0 is the cost of lifting relative to other things.
Elift is the fraction of all muscles applied to lifting.

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)
Vc = climbRate * V
Vh = horizRate * V
Eclimb = Kc * M * max(0,Vc)
dS = -F * Eclimb * dt
climbScale = 1/(horizRate + 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.
Vc is vertical speed as a fraction of max horizontal running speed.
Vh 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.

Note climbScale is is 1/Kc=1/6 for going up vertically, and limited to 1.5 for downward slopes. This means you can walk/run up to 1.5x as fast when going downhill.

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:

moveSpeed = climbScale * Ks * ((S - Smin)/M)^(1/2)
Ewalk = Kw * M * V^2 = Kw * M * (V * horizRate)^3 = climbScale * Ks * (S - Smin)
dS = -F * Ewalk * dt

Where:

moveSpeed is movement speed as a fraction of max run speed.
Ewalk is the fraction of all muscles applied to walking.
Kw = 16.0 is the cost of walking relative to other things.
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.

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:

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

where:

Kr=1.0 is the cost of running relative to other things.
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.

The (unverified) world record for a vertical jump is around 1.5m, but anything over 1m is considered extraordinary, with 0.75m being the average for professional footballers and basketballers. Micheal Jordan could jump 1.2m. The average taken for a group of typical medical students was 0.56m for men and 0.35m for women.

Attacking/Blocking

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

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