Cuberite Forum
Weather. - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: Weather. (/thread-207.html)



Weather. - rs2k - 11-03-2011

I added the New / Invalid State and Thunderbolt packets. Just for testing of the packets(one packet) I made it so rain starts when you open a workbench and stop when you open a chest.

It seems thunder is overly complex. It looks like the server needs to create a thunder entity, send the thunderbolt packet, and remove the entity. I haven't tested anything with it, I just created the packet.

Weather is going to need a lot more work. Each world need to have a raining or not raining state. If raining than all players that log on need to have the rain status sent to them. If it's a thunderstorm, than random thunder bolts need to be created.

I'm not sure how the client knows the difference between a thunderstorm and rainstorm, I don't see anything but rain on the packet list. Maybe once a thunderbolt packet is sent the client turns it into a thunderstorm.
Yup, sending just the thunderbolt packet to the client does absolutely nothing. >.>

Guess I'll get to work on creating the entity.


RE: Weather. - rs2k - 11-03-2011

Got lightning kinf of working. Right now it's always striking 0,0,0.

Looks like the entity is all client side and all I have to do is tell the client where the lightning hits.

Still not sure how the server tells the client it's a lightning storm and not a rain storm. Is there a way for the server to control sky lighting directly?
Oooooh, I need to multiple the X, Y and Z by 32. Very odd. :/


Whelp, lightning works.

Now to come up with a weather system.

Each world needs an is or is not raining variable. It should probably be a char instead of a bool similar to m_GameMode I think. If the worlds m_Weather is set to rain then everyone gets the packet telling them it's raining when they log in. When the world is first set to rain everyone should get the packet at once. I'm not sure how to send every client a packet, but I'll look and see how the chat packet works.


RE: Weather. - rs2k - 11-03-2011

Figured it out.Big Grin

cRoot::Get()->GetServer()->Broadcast()
instead of
send()


RE: Weather. - rs2k - 11-10-2011

Changed broadcast to be per world.
Random chance for weather to change now. (A bit too frequent at the moment, just need to add some zeros to the chances)

added SetWeather, GetWeather and CastThunderbolt to bindings using ToLUA batch file.

Chests and Workbenches are back to normal.