I have a weather system in my game that I recently converted from utilizing area to client.screen (recommended by a fellow dev)-- because I'm a stickler for detail, I have a raindrop splash effect that I want to appear on random turfs all over the map while it's raining. I know HOW to code it, but the problem is that "for looping" over all of the turfs in the world causes visible lag. I tried to relegate it to just show up on 1 type of tile and still the same result. The only other way I can think of doing it is to create a bunch of screen objects at random screen_locs but that just seems so...yuck. I like clean, efficient code.
Is there a better way that won't cause overhead?
In response to Lummox JR
|
|
Lummox JR wrote:
What's the loop that's causing all that lag? for loop for every turf in world, and then applying the visual at a prob of 33%. Experimented with objs, overlays, and even creating the visual at runtime to be applied later but every way caused a short lag spike Also, IMO client.screen won't perform any better than areas for this purpose, unless your rain overlay is a fairly large image. Yeah I actually didn't notice a performance difference tbh, but I do like that I don't have to have to paint a bunch of area on my map lol |
Using the client's screen in this way seems like alot more work than just using anything else :P
|
In response to SolarOblivion
|
|
Putting rain on every turf is definitely not the way to go. Put it only on turfs the players might actually see.
|
In response to Kozuma3
|
|
Kozuma3 wrote:
Using the client's screen in this way seems like alot more work than just using anything else :P Actually quite simple thanks to being able to set screen_loc from southwest to northeast. Just paints the rain icon over the screen nice and easy |
SolarOblivion wrote:
Kozuma3 wrote: But as I mentioned in today's developement news post, I discovered the code that handles that is really, really outdated and in need of some TLC. It's liable to cause a performance hit. |
In response to Lummox JR
|
|
Lummox JR wrote:
Putting rain on every turf is definitely not the way to go. Put it only on turfs the players might actually see. That's the thing though-- players could be anywhere in the game, you know? I'm at least saving myself a different headache by having weather illogically change for everyone, everywhere. |
When it's raining, just have a simple loop. Every tick, pick a player at random who's in a rainy area, then pick a random turf in range of them. If it's rainable and a certain random threshold is met, add a raindrop there.
|
In response to Lummox JR
|
|
Lummox JR wrote:
When it's raining, just have a simple loop. Every tick, pick a player at random who's in a rainy area, then pick a random turf in range of them. If it's rainable and a certain random threshold is met, add a raindrop there. Hmmm clever. I'll try that, thanks. |
Also, IMO client.screen won't perform any better than areas for this purpose, unless your rain overlay is a fairly large image.