Howdy!
This one is a bit of a doozy.
In my game, you have the option to do certain activities in your downtime. Each of these activities increase the age of your character (since your character is immortal, they can afford to spend a lifetime just focusing on one thing).
I figured it would be silly if your character’s age increased by exactly the same amount each time, so I wanted to increase it by a flat rate (80 years) plus a random amount of time between zero years and forty years. I.E. your character spends between 80-120 years on their task.
I achieved this by running a subroutine for increasing the age of a character. The subroutine goes back to the scene “downtime”, regardless of where you are in the story, as you can also activate this subroutine during other portions of the game, and runs a preset code.
The other thing that makes this a BIT more complicated is that the game checks if you’ve surpassed a certain age. If you are, it runs an “omen” i.e. a quick scene foretelling of dark times ahead. I won’t go into the code for the omens, but it’s basically check the age of the character: if it’s between these two ages and you haven’t already run the omen, then run the omen. Otherwise, nothing happens and the game procedes as normal with nobody the wiser. The omens work really well and I’m pretty proud of that.
So this is what we’ve got so far:
*gosub_scene downtime age_increase
...
*label age_increase
*temp increase 0
*rand increase 0 40
*set age (age + increase)
*set age +80
*gosub_scene omens omens
*return
When I first tested it, everything seemed really great. And for the most part it works perfectly! There’s only one problem. I’ll give you an example.
I select the option to explore the world. I see that my character’s age has increased. I check the stat screen and see that I used to be 200 years old, and now I’m 295. Everything seems great.
So I go back to the description of me exploring the world, and I think, oh man, I actually forgot the age of my character. Silly me. So I open up the stat screen and check again.
Now my age is 301.
Uh oh.
I close the stat screen and open it again. 299.
I close it and open it again. 318.
OH NO.
This wouldn’t be a HUGE issue, but it means you can technically start an omen, open up the statscreen, close it, and then not actually meet the requirements for the omen that you’re currently playing. I haven’t done this yet but it can’t be good.
It’s also a pretty big immersion-breaking issue.
Are there any tips to prevent this?
Notably, one thing which I’m not sure of which I’d like to know even if it’s not a good solution for this particular problem: if you have a temp variable in one scene, and then you go to a subroutine in a completely different scene, does the temp variable persist across both the scene you’re in and the subroutine in another scene? Because that might be a way of counteracting this.
I noticed that the problem DOESN’T persist for this particular bit of code, which randomises how much money you get from an action (in this case, you get between 1800-2200 gold, average 2000).
*temp bonus 0
*rand bonus 0 400
How will you increase your wealth?
*choice
# I beguile my way into the influence of a merchant's guild.
*if (charisma >= 40)
You leverage favours and relationships between some of the most influential people you can find, gaining yourself a tidy sum of money.
*set wealth (wealth + bonus)
*set wealth +1800
*goto_scene downtime
...
Like I mentioned, the amount of money stays the same even if you check your statscreen over and over. I think it’s because the choice moves you to a new page, so the *rand isn’t rerolled.
Thanks for the help! Hope I gave enough information to be useful.