Difference between revisions of "Template:Rest Hours Per Day/doc"

From RimWorld Wiki
Jump to navigation Jump to search
m (→‎Syntax: I misunderstood the color section. Now, if those 2 numbers at the end made sense...)
m (The values were just the min/max section of the day that a pawn does not need to rest at Sleep rate 1. Not truly relevant, so axed. Added the formulas, for reference.)
Line 18: Line 18:
 
:24/x    = ((~0.57143% * RE * RRM)/(0.237% * RFR))+1    <br>
 
:24/x    = ((~0.57143% * RE * RRM)/(0.237% * RFR))+1    <br>
 
:x        = 24/((~0.57143% * RE * RRM)/(0.237% * RFR))+1 <br>
 
:x        = 24/((~0.57143% * RE * RRM)/(0.237% * RFR))+1 <br>
The final value is then rounded to the second decimal place.
 
  
0.65857 - lowest work % of a day
+
The exact formulas used by this template are (always rounded to 2 decimals):
0.9207 - highest work % of a day
+
*'''alpha''': <code>(1-(1/(((0.0057143 * {{{RE|1}}}  * {{{RRM|1}}}) /(0.00237 * {{{RFF|1}}} )) + 1))-0.65875)/(0.9207-0.65875)</code>
 +
*'''Percentage returned''': <code>(1/(((0.0057143 * {{{RE|1}}}  * {{{RRM|1}}}) /(0.00237 * {{{RFF|1}}} )) + 1)) * 100</code>
 +
*'''Hours returned''': <code>Percentage returned*0.24</code>
  
 
==Examples:==
 
==Examples:==

Revision as of 19:09, 27 February 2025

This template calculates how much time, in both percentage and absolute terms, a pawn requires to fully rest per day. It's only mean to be used by Template:Rest Hours Per Day, which itself is used in Rest#Comparison_tables.

Syntax

{{Rest Hours Per Day|RE|RRM|RFF|color}}

RE = Rest Effectiveness. Defaults to 1.
RRM = Rest Rate Multiplier. Defaults to 1.
RFF = Rest Fall Factor. Defaults to 1.
color = Optional. If present, the alpha/transparency of the background colour of this cell will be calculated. The lower the required hours, the less transparent the color

  • If not present, the cell will be colorless.
  • Internally the color is determined by hsla(110, 100%, 40%, alpha). The alpha values range from 0 to 1.

The formulas used by this template were obtained by solving the following equation (Where x = sleeping hours):

x * ~0.57143% * RE * RRM = (24-x) * 0.237% * RFR
x/(24-x) = (0.237% * RFR)/(~0.57143% * RE * RRM)
(24-x)/x = (~0.57143% * RE * RRM)/(0.237% * RFR)
(24/x)-1 = (~0.57143% * RE * RRM)/(0.237% * RFR)
24/x = ((~0.57143% * RE * RRM)/(0.237% * RFR))+1
x = 24/((~0.57143% * RE * RRM)/(0.237% * RFR))+1

The exact formulas used by this template are (always rounded to 2 decimals):

  • alpha: (1-(1/(((0.0057143 * 1 * 1) /(0.00237 * 1 )) + 1))-0.65875)/(0.9207-0.65875)
  • Percentage returned: (1/(((0.0057143 * 1 * 1) /(0.00237 * 1 )) + 1)) * 100
  • Hours returned: Percentage returned*0.24

Examples:

{{Rest Hours Per Day|RE=2.15|RRM=2.24|RFF=1|color=1}}

7.93%
(1.9 hrs)

{{Rest Hours Per Day|RE=2.15|RRM=2.24|RFF=0.8|color=1}}

6.45%
(1.55 hrs)