Dependent Statistics

Hi all

I’m VERY new to this, so pardon if this is a simple question, but I’m wondering how to write a dependent statistic.

Having already created the might, agility, and determination base statistics, I want to have the game derive the physical combat statistic from those by a simple average (mental acuity only counting at 1/2).

First I created a Physical_Combat stat at 0, then wrote this:

set Physical_Combat ((mental_acuity0.5)+might+agility+determination)/3.5

I keep getting an error for this, however. Any help please??

Also, is there a way to code for absolute values? I want people with more extreme values for ethical_sense to get more of a boost on this stat.

set Tenacity ((mental_acuity0.5) + (might*0.5) + determination + (absolute value (50 - ethical_sense)))/3

Thank you all very much in advance

Johyn

ChoiceScript can only handle two things at a time – so it’s your “might+agility+determination” that will be tripping it up. Try breaking it up like e.g.

*set Physical_Combat ((mental_acuity*0.5)+((might+agility)+determination))/3.5

and see if that works.

3 Likes

This is very helpful, I’d never have figured it out on my own, and its much appreciated!

Does anyone know how to do the absolute value thing? Or a work-around?

1 Like

For this one, as far as I know, you’d have to kludge it. Something like:

*if ethical_sense > 50
… -(50-ethical_sense)…

*if ethical_sense <= 50
… +(50-ethical_sense)…

1 Like

Thanks!!

1 Like

You may want to make use of a subroutine for the absolute values. Something like the following (I haven’t tested this code)

*comment The following value is used in the subroutine
*create AbsoluteValue1 0
*comment This value is what is actually used in the formula
*create FormulaStrength 0
*comment This is the base value
*create Strength 0
*set Strength - 12
...
*comment There is code that can make it look for all of the stats, so you don't have to code this per stat, but I'm keeping it simple here.
*set AbsoluteValue1 Strength
*gosub_scene AbsoulteValueChecker
*set FormulaStrength AbsoluteValue1 

Then you have a separate file called AbsoulteValueChecker which is coded like this.

*if AbsoluteValue1 < 0
 *set AbsoluteValue1 * -1
*return

From there, you use the FormulaStrength value in the formula you want. It can be streamlined to check different variables without having to code the individual ones, but this example is meant to show a way to make it so you don’t have to constantly make the same code all over the place.

1 Like

Nice explanation! Another simple trick is to use *set with calculated values whenever one stat should track another. It keeps things clean and makes testing easier. Also helps to update them in one place so you don’t end up with mismatched numbers later.