Say I want to trigger some event with a certain likelihood throughout gameplay. For example, say I want there to be a 5% chance of engine failure in a spaceship simulator that runs for an indeterminate length of time.
When and how do I determine if that event will occur? If I determine it will occur, how do I determine when it will occur?
The problem I see is that if you calculate the chance of a failure every tick, then there's a 5% chance of failure per tick, which means over two ticks there's more than a 5% chance - something like 8% I believe. Once the game ticks 1,000 or 1,000,000 times, it's almost certain the engine will have failed (~100% chance) when there's only supposed to be "a 5% chance."
Say we somehow knew the game would last for ten minutes - then we could get a random number 1-100 and if it's 5 or less, say the engine will fail within those ten minutes. But then at minute 5, say the player upgrades his or her engine to a 2% failure rate. We could again roll the die and if we get 2 or less, the engine will fail within the next five minutes. But again, we've calculated the chances of failure twice, which means it's more likely to fail than if we calculated those chances only once.
When we look at in-game items, they never say "5% chance of failure per frame, per minute, per game, etc." What does "x% chance" really mean and how do we get a computer to tell us if and when the event will occur?