Template:Cs-solve

From Tales of Maj'Eyal
Jump to: navigation, search


This template is used to generate values for scaling which uses the combatScale function. See also: Template:cs.

Format

{{cs-solve
|x=
|y_low=
|x_low=
|y_high=
|x_high= 
|power= (default 0.5, optional)
|shift= (default 0, optional)
|add= (default 0, optional)
|digit= (default 0, optional)
}}

Use

When given a function of type:

combatScale(self:getStr(7, true) * self:getTalentLevel(t), 5, 0, 40, 35)

These values map to:

combatScale(x, y_low, x_low, y_high, x_high, power, add, shift)

And 'raw' or 'log' is not currently implemented.

x is always the changing value you want to generate the final result for. This may be a combination of talents, stats, or something else; it's up to you to provide meaningful values. In the example above, x is defined as 0.07*Str*talent_level.

Therefore, we can use the following:

  • x=(input desired value)
  • y_low=5
  • x_low=0
  • y_high=40
  • x_high=35
  • power, shift, add have default values

Therefore:

combatScale(self:getStr(7, true) * self:getTalentLevel(t), 5, 0, 40, 35) for (str=30, talent_level=3) is:

{{cs-solve|x=6.3|y_low=5|x_low=0|y_high=40|x_high=35}}
= 19.85



Other parameters

digit defines the rounding of the final result. If digit=1, it will be rounded to the nearest whole number. Otherwise (if omitted), it will be rounded to two decimal places.

You should not usually need to override these.


Math

(replace all 'high' with 'y_high', 'low' with 'y_low') Input: power(=0), add(=0), shift(=0), x_low (=1), x_high(=5), y_low, y_high, (raw or log), t

Psuedo code for m:

  • m = (y_high - y_low) / ( (x_high+shift)^power - (x_low+shift)^power )
  • Expr for m: {{#expr:( ( {{{high|0}}} - {{{low|0}}} )/( ( {{{x_high|5}}} + {{{shift|0}}} )^ {{{power|0.5}}} - ( {{{x_low|1}}} + {{{shift|0}}} )^ {{{power|0.5}}} )) }}

Psuedo code for b:

  • b = low - m*(x_low+shift)^power
  • Expr for b (unexpanded): {{#expr:{{{low|0}}} - (m)*({{{xlow|1}}}+{{{shift|0}}})^{{{power|0.75}}} }}
  • Expr for b (expanded): {{#expr:{{{low|0}}} - ({{#expr:( ( {{{high|0}}} - {{{low|0}}} )/( ( {{{x_high|5}}} + {{{shift|0}}} )^ {{{power|0.5}}} - ( {{{x_low|1}}} + {{{shift|0}}} )^ {{{power|0.5}}} )) }} )*({{{x_low|1}}}+{{{shift|0}}})^{{{power|0.75}}} }}

Psuedo code for the whole thing:

  • Output = m * (t+shift)^power + b + add
  • Expr for output (unexpanded): (m)* {{#expr:({{{t|0}}}+{{{shift|0}}})^{{{power|0.5}}} }} + (b) + add
  • Expr for output (expanded): {{#expr: ({{#expr:( ( {{{high|0}}} - {{{low|0}}} )/( ( {{{x_high|5}}} + {{{shift|0}}} )^ {{{power|0.5}}} - ( {{{x_low|1}}} + {{{shift|0}}} )^ {{{power|0.5}}} )) }} ) * {{#expr:({{{t|0}}}+{{{shift|0}}})^{{{power|0.5}}} }} + ({{#expr:{{{low|0}}} - ({{#expr:( ( {{{high|0}}} - {{{low|0}}} )/( ( {{{x_high|5}}} + {{{shift|0}}} )^ {{{power|0.5}}} - ( {{{x_low|1}}} + {{{shift|0}}} )^ {{{power|0.5}}} )) }} ) *({{{x_low|1}}}+{{{shift|0}}})^{{{power|0.50}}} }}) + {{{add|0.5}}} }}