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.
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: