So, it’s been a long while since I was last able to do any real work on this game (personal issues on top of complications due to the outbreak of COVID-19 forced me to put it away) and have finally managed to sit down and crank out a bit of creativity.
I decided to work on a new mechanic to introduce into the game: random events.
These will mostly be small, inconsequential events like interactions between different characters aboard your ship, though I have vague plans to add more significant events in the future.
I have written up a basic framework for how these events will work, but have encountered a potentially game-breaking issue that I’m struggling to think my way around.
Basically, here’s what I’m dealing with:
*rand event_roll 1 100
#Go to the Galaxy Map
*if (event_roll <= 80)
*if (event_roll >= 81)
*rand event_choice 1 2
*if (event_choice = 1) and (event_1 = 0)
*set event_1 1
*if (event_choice = 2) and (event_2 = 0)
*set event_2 1
Explanation for what’s going on here:
“*rand event_roll“ decides whether or not a random event will take place at all.
There is a 20% chance (may change in the future) for an event to occur every time you access the Galaxy Map, otherwise the game continues as usual.
If the roll is successful (you roll 81-100), a second roll takes place to randomly determine which event will occur (currently there are only two, there will be many more in the future).
“event_1 = 0”/“event_2 = 0” are variables I created to ensure a specific event can never occur more than once. (It will also be used to keep track of what ‘stage’ of each event the player is on. This is necessary because my game is not linear).
Here is where the problem comes in: if all of the events have been played, the code will keep re-rolling “event_choice“ into an infinite loop.
The only solution I have thought of to this is adding a chance for “event_choice” to roll 0, which would then “*goto galaxy_map“ as if the event roll failed.
My problem with that solution is that:
- There is a chance the roll will skip an event, even if one is available to play, and:
- If there are no available events, there could be a large number of redundant rolls before it gets a 0, which I’d rather avoid.
So, if anyone has a better solution to this issue, I’d really love to hear it!!
Thanks in advance!