Dependent Statistics

Hi all

I have what I think might actually be a complicated questions here. Certainly is for me…

I want to have independent statistics which the player influences (the choices make them go up or down), and then from these are calculated some “dependent statistics” for skill checks.

For example:

Independent stats: Choices can affect these via fairmath.

Intelligence: 20

Social IQ: 20

Dependent Stats: Skill check is based on this

Persuasion = (Int+SIQ)/2

I created and set the independent stats, and they’re adjusting as hoped per choices. Yay.

I created and set the dependent states based on the independent stats. The math is right for the starting values, but the dependent stats aren’t updating when the independent stats change through the game. Can anyone please help?!

*create Mental_Acuity 20
*create Might 20
*create Agility 20
*create Perception 20
*create Social_Intellegence 20
*create Determination 20
*create Ethical_Sense 50

*create Physical_Combat 0
*create Ranged_Combat 0
*Create Evasion 0
*Create Deception 0
*create Persuasion 0
*create Intimidation 0
*create Tenacity 0
*Create mental_toughness 0
*create Constitution 0
*create Intellegence 0
*create Evasionpt 0

*create ESAV 0
*create Self_Orientation 0
*create Other_Orientation 0


*if  ethical_Sense >=50 
	*set ESAV (ethical_sense-50)
	*goto orient
*if ethical_sense <50
	*set  ESAV (50-ethical_sense)
	*goto orient

*label orient
*set Self_orientation ((ethical_sense-50)/3)
*goto int
*set Other_Orientation ((50-(ethical_Sense))/3)
*goto int

*label int
*Set mental_toughness ((mental_acuity*0.5) + (might*0.5))
*Set evasionpt ((agility + (0.5*social_intellegence)) + (0.5*perception))
*set Intellegence (mental_acuity-(0.5*ESAV))
*set Physical_Combat ((mental_acuity*0.5) + (might + agility))/2.5
*set Ranged_Combat ((mental_acuity*0.5) + (agility + perception))/2.5
*set Evasion ((mental_acuity*0.5) + evasionpt)/2.5
*set Deception ((((mental_acuity*0.5) + (perception + social_intellegence))/2.5) + (Other_orientation*0.33333333))
*set Persuasion ((((mental_acuity*0.5) + (social_intellegence + perception))/2.5) + (Self_orientation*0.33333333))
*set Intimidation ((mental_acuity*0.5) + (might + social_intellegence))/2.5
*set Tenacity (mental_toughness + (determination + ESAV))/2
*set Constitution (((might*0.5)+determination) + ESAV)/1.5

Yes, that won’t happen automatically. When you create or set a stat using some other stat, that only uses the value of the independent stat at that moment of play–not the changing values going forward.

The best way to do what you’re trying to do is with a *gosub. One way of doing it: just before you check a dependent stat, you insert the line:

*gosub update_ds

And lower down in your code (I keep mine at the bottom of the file, after *finish, to make sure they can only be reached by gosubs) have

*label update_ds
*Set mental_toughness ((mental_acuity*0.5) + (might*0.5))
*Set evasionpt ((agility + (0.5*social_intellegence)) + (0.5*perception))
...etc etc for all the other dependent stats...
*return

That’s just about the only way I know to be sure that your dependent stats will be drawing on the latest value of the independent ones.

Depending on the frequency of upward nudges and checks, you might place the *gosubs differently and slightly more efficiently – maybe at the end of a section where you’re increasing the independent stats without checking the dependent ones – but if your game is constantly giving opportunities to increase indept stats and test dept ones, constant gosubs is your only choice. (I believe.)

3 Likes

This is perfect!

I haven’t tested it thoroughly yet, because I’m not sure how to tell whether my stats are changing besides manually playing through the game, but it seems to work and its pretty simple to build the sub at the bottom and then just past in the goto command after each choice the player makes.

Thanks!

1 Like

Happy to help!

Just make sure that instead of

you use gosub – that’ll work a lot better.

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.