Making variables modify other variables?

I have in a WIP a number of skills a character can learn while in the game. Most of these are learning to use a new weapon but some of them are more mundane (such as learning to read).

If I wanted to make a skill a percentage which then attaches a modifier to an existing percentage (for example, strength of 50 gives… +5 or something to another check) is this possible?

Also, how would this be implemented as simply as possible? Creating a dozen *if statements for each scene would be madness and messy. Is there a single (or a small handful) of commands that can do this?

1 Like

I actually have a similar system I’m using in my WIP.

The simpler way to do this is:

*create strength 50
*create endurance 20
*create str_end 0

*set str_end ((round(strength * 0.1)) + endurance)

*if (str_end > 50)

Let’s say we have these variables as an example, and you want strength to give a 10% bonus to endurance. str_end would be the endurance stat with a bonus modifier from strength.

In this case, str_end would have a value of 25. (20 base endurance + 5 from the 10% bonus from strength)

You’ll need to calculate str_end every time you need to do a check, but if you don’t want to do that, and if you’ll be doing checks throughout the story, I would suggest creating a subroutine in conjuction with *params.


So in another scene file, using the same variables from before:

*label strength_plus
*params amount
*set strength +amount
*set str_end ((round(strength * 0.1)) + endurance)

And then, whenever you want to increase strength, instead of

*set strength +10

you have to write

*gosub_scene stat strength_plus 10

stat would be the name of the separate scene file. strength_plus is the label I used above. Then 10 is how much you want to increase strength.

Then you’ll have to repeat this for each stat (just copy and paste, then replace the variable names with the corresponding stats).

It doesn’t look worth the effort, but I also have a much more complex subroutine. :sweat_smile:


I’d create a few gosubs and then insert when needed. For example…

*label strengthboost
*if strength > 50
   *set fighting + 5

and then anytime you want to call that routine, simply say *gosub strengthboost
You can copy and paste the same subroutines into the end of every file so as to call upon them whenever needed.

Edit: @Franzinyte beat me to it haha (and with a more elegant approach!) It really is up to you @RascaldeesV2, there are more and less complex ways depending on what you want to achieve. But absolutely doable!

1 Like

Hehe. Actually, your suggestion has made me realize a simpler solution.

You don’t need to use *params if you’re not doing anything complex. Just use a single subroutine for all the calculations. So something like:

*label calculate_stats
*set str_end ((round(strength * 0.1)) + endurance)
*comment place all other calculations here

Just put it at the bottom of every scene file, then just put *gosub calculate_stats before every check.


Thanks everyone! Sorry I didn’t get to this sooner. I think I was asleep.

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