Cap on stats?

Hi so I was just wondering if there is a way to put caps on stats? Like you max out one stat it would just say 100 instead of going to like 120 or something like that?

Hei, why not use percentages for the changes in the stats in that case? or you can write something like this on the stats screen on top:
*if (stat>100)
*set stat 100

You can put in a condition like

*set strength +5
*if (strength > 100)
   *set strength 100

This is much easier if you use *gosub. I have a label at the bottom of every file in my story that looks like this…

*label minmax
*if (strength > 100)
   *set strength 100
*if (strength < 0)
   *set strength 0
(repeat for other stats)
*return

Then, every time I modify a stat, I follow that modification with *gosub minmax, which makes the game go through all of those checks and set any relationship value that’s gone over 100 back to 100, and any value that’s dropped below 0 back to 0.

*set strength +5
*gosub minmax
4 Likes

That’s what fairmath is for. You can find out more in the choicescript important commands page found here.

2 Likes

Thanks you guys!

1 Like

You don’t need to copy that code into every file.

If you make a new file called (for example) ‘stat_check’

Then change your *gosub to
*gosub_scene stat_check

You can just re-use the same checking code repeatedly.

3 Likes

If you use fairmath there’s no need for additional code. For example:
*set honor %+ 15

2 Likes

Fairmath is only useful if you want diminishing returns.

2 Likes

or to make sure it doesn’t go over 100. if you want the return to increase, set it to:
*set honor %+ 150
just change the percentage, you get the same stat boost