Capping an opposed pair, the easy way?

I hope this hasn’t been discussed, since I’ve poked around and couldn’t find anything specific to this…

Say we have an opposed pair measure of a Good-Evil stat, and neither one of the extremes may reach full bar. Each end needs to be capped at 90 as the stats constantly change throughout the game based on player’s decisions.

I am also displaying the opposite value in the Show Stat screen at all times, rather than the default that shows only the value of the first attribute of the opposed pair; I think it’s helpful if the player may see how they are doing on both attributes. I mean they would know that the second attribute is always complementing the first one to a total point of 100, but seeing both of values displayed is kind of nice addition.

So what I thought is I need to put something like this right after the stat is updated.


*label test
You have one minute to call the police, or escape.
*choice
  #Call the police.
    *set good +10
    *if good>90
      *set good 90
    *set evil (100-good)
    *goto callpopo
  #Escape.
    *goto escape

I wonder if the checking is something I have to always put everytime the stat changes, or if there’s an easy workaround to that? Please advise.

(just for testing the smileys, this is me at the moment confused with coding -> :-W )

Thanks in advance, guys.

You could stick it at the bottom of each scene.txt file (e.g. *label limit_stats) and just use *gosub limit_stats to call it as needed. Just remember to put the necessary *return command at the end of the sub-routine scripting, so it returns to that exact point in the story (the actual *gosub line) after making the required checks & changes.

I read up a bit on the advanced section, looks like gosub is the way to do that. I’m going to give it a try soon and post here should it be coming across any trouble. Thanks for the quick reply, Vendetta!

The alternative is to use fairmath, have a good variable only, (subtract from it when adding to evil), and in stats page:


*temp evil
*set evil 100
*set evil -good
*stat_chart
  percent Good
  percent Evil

@FcA Fairmath is pretty simple once you get the idea. Don’t worry about the exact formula, just make sure that when you declare the variable in mygame.js it’s between 1 and 99 (inclusive). Then, so long as you always use fairmath for that variable, it will stay between 1 and 99. When you %+ 20 it will add an average of 20, maybe more, maybe less, depending on what the stat was.

A personal tip: I find it easiest to figure out what I want a choice to add at the very most, then just halve it. For example, if I want a small scene about saving a puppy, but I don’t want it to really be able to flip a character from evil to good, I might decide that the most I want it to add is 30, so I halve it (15) and just make sure the maximum good path adds %+15. The most a character can get is 30, and that’s if they are super evil. A fairly evil character (say good:20~30) will get somewhere around 20~25 which will put them in a grey area.

Thanks for the heads up Reaperoa. Fairmath is one thing I haven’t really been looking at, possibly because of the formula looking a tad confusing, lol (not a code monkey here) Guess I’ll be trying it out soon if it helps cutting down work in any way… I feel I should focus more on content rather than getting too far in setting up a hardcore-deep mechanic.

Not saying that coding is less important, that is. :slight_smile:

@Reaperoa %+20 doesn’t add an average of 20, it adds an average of 10. So if you add 20%, a 1 would jump by 19 to a 20, a 50 would jump by 10 to a 60, and a 90 would jump by 2 to a 92.

@P_Tigras Eep, your right. I have a huge amount of stuff coded out just waiting for the writing, so it’s been forever since I actually looked at how fairmath worked.