Rain/Snow/Day/Night?

I know it’s possible using particles and whatnot, but that’s stupid. Maps can have rain and snow and light and so on, so is it possible in LUA to re-create that effect, perhaps with entities?

This thread: http://www.facepunch.com/showthread.php?t=718385 brought up the idea of changing light entities, and making them lighter darker, especially with env_sun or whatnot, which would help re-create day/night.

But rain and snow? I did some mapping research and all I can tell is that func_precipitation is the thing which makes rain (and snow?). Can that be “created”?

I can’t really experiment because I have no access to GMod or a PC here, but I’m working on plans, and I’m sure others might be interested…

Thanks!

p.s I have searched, nothing useful came up (there’s the post-process lua rain, but I want to try get Source rain).

wel its posible but it wil be neded to be set in your map ur using i gues, like if tehres an etntity in the sun box, there wil be sun, when its night an entity spawns in the night box and the sun entity wil be removed and that also whit rain and snow. i dont know if im correct now since i dont have mutch XP whit hammer.

Since it’s a brush entity, you can’t create it at runtime (AFAIK). There is unfortunately neither a turn on/off input, so I don’t think it’s possible at all.

“Eventscripts” comes with es_lightstyle. It allows you to change the lightstyle of any map, however you need to rejoin or minimize and maximize gmod for it to take effect.

I found a way around it, which is pretty hacky:

You place dynamic lights all over the map for a split second (this freezes the game for a sec) and then you remove them.

Edit:

It works okay on simple maps, such as flatgrass. But on complex maps it’s hard. You need to get the position of where to place the lights as well. Because lights don’t light up stuff that isn’t facing the light. If we had a way around this then it’d be much easier.

oh and the cubemaps won’t change obviously.

http://errur.com/i/images/3455_freespace06_v2-1_sounds0003.jpg

http://errur.com/i/images/5406_freespace06_v2-1_sounds0002.jpg

http://errur.com/i/images/8662_freespace06_v2-1_sounds0001.jpg

I used sv_skyname to change the skybox. I also removed the fog at the darkest one.

Middle one is unchanged, but with a different skybox (couldn’t remember which skybox it was).

Wow, that’s epic.

I just made a video to show off my work, this is part of a private and yet in developement roleplay gamemode.
Also this is 100% done by lua, no custom entities or whatever are used.

Watch in HQ! (Yeah I know the size is a bit raped :/)

I think this almost beats the source rain. All it needs is some postprocessing optimising, and maybe some small particle updates , then it’s done.

How? That’s amazing. Any chance you want to give me a 'lil snippet of code for that? ^^

(this is for a private gamemode as well, if you don’t want it public but don’t mind us using it, pm me)

Also, thanks CapsAdmin, that’s night/day sorted.

I would love it too. Please give me a snippet :stuck_out_tongue:

I can’t give out snippets/the script, sorry. I’ll get into trouble if I do that.

thats… realy… epic…

It’s also pretty easy to do. I’m working on something similar now and I’ll post it if it’s any good.
It’s just colour modification and particles falling from the sky.

Killer lighting effects, but why does the rain show up for a second inside?

What map is that?

Dude-man!! That’s really sweet!! If that’s still unfinished, I wonder how that’ll look once it is finished…

rp_evocity2_v1p

Right now I’m doing a ‘IsOutdoors’ check on the player, and using that to decide if the weather effects are created or not. This is to disable the weather effects when inside a building.

When you are outside, the particles will be created randomly around you at a predefined height. The problem is, that the particles are also getting created into buildings that are higher then the particle create height.

I don’t have any ideas how to fix this problem right now. Applying the ‘IsOutdoors’ check to every particle might be possible, but that’d lag the shit out of everyone.

[lua]p = FindMetaTable(“Player”)
function p:IsOutdoors()
– Perform the trace
local tr = {}
tr.start = self:GetPos()
tr.endpos = self:GetPos() + Vector(0, 0, 100000)
tr.filter = self
local trace = util.TraceLine(tr)

-- Return result
return trace.HitSky

end[/lua]

Returns a bool indicating whether the player is out or inside by checking if the the skybox is right above the player without anything in between.

Yea this is the simple way. But this means as soon as a small thing blocks the trace, a lean-to for example, the effect would stop.

Yes, but then you can check how big the object in question is. Nevermind, I know what you mean.