Game Mechanics More efficient determination of random events

equazcion

Skeletron Prime
While most random events are determined on a per-day basis, two of them have their dice rolls occur per game tick: Rain and the Traveling Merchant. I'd assume they are done this way because they need to occur at random times, as opposed to most events that occur at specific times (like dawn or nightfall).

The routine for the Traveling Merchant is especially complex-ish for a per-tick thing (every 60th of a second, all day every day), since there are prerequisites for his appearance -- and each of those prerequisites is determined all over again, at every tick.

You could easily make these rolls more efficient by determining them once per day, as with other events: Each dawn, run the routine to determine if the event will happen on that day, and if it will, perform another roll to determine and save a time to trigger it. Afterward, at each tick, simply check whether the event is scheduled for today and if so, whether the current tick was the one saved for today's triggering.

I think a change like this could help improve performance. Just a suggestion. Thanks for watching.
 
Last edited:
Yeah, from a programmer's perspective this would be a tiny bit more complicated to implement but would help a lot with performance. Performing one operation to determine a condition and then checking every tick if the condition is met is a lot more efficient than determining the condition and checking it every tick. Frankly, I thought they'd know how to use for loops more efficiently.

Oh well, still a good idea.
 
Back
Top Bottom