Welcome! |
| | Weather Script | |
|
+7GordonGuy Sharq Mack Gambit Markka PuPeT-KaI Jackxter 11 posters | Author | Message |
---|
Jackxter
Posts : 238 Join date : 2010-07-03 Location : Delaware
Character sheet Name: Judith Both Age: 32 Race: Human
| Subject: Weather Script Wed Jul 07, 2010 1:27 am | |
| My server currently has a weather script on it with code I got from a facepunch thread. It's very easy to integrate into a script. It pretty much creates a post process effect that everyone can see showing rain, snow, and storm effects. The lag, if there is any associated with it, is usually minimum. I could post the code here if ya want. | |
| | | PuPeT-KaI
Posts : 930 Join date : 2010-02-07 Age : 27
Character sheet Name: Age: Race:
| Subject: Re: Weather Script Wed Jul 07, 2010 1:59 am | |
| FFFFFFFFFFFFFFFFF--- I want weather D:> | |
| | | Markka Moderator
Posts : 916 Join date : 2010-04-29 Age : 31
Character sheet Name: Mirage Silverspine Age: 17 Race: Human
| Subject: Re: Weather Script Wed Jul 07, 2010 4:08 am | |
| Raaaaaaaaaain!~
See through thin women clotheeees!~ | |
| | | Gambit
Posts : 2891 Join date : 2009-04-20 Age : 29
Character sheet Name: Age: Race:
| Subject: Re: Weather Script Wed Jul 07, 2010 5:03 am | |
| - Markka wrote:
- See through women clothes
that's all I read | |
| | | Markka Moderator
Posts : 916 Join date : 2010-04-29 Age : 31
Character sheet Name: Mirage Silverspine Age: 17 Race: Human
| Subject: Re: Weather Script Wed Jul 07, 2010 6:45 am | |
| Dohohoh.
But in a more serious note, yeah. That'd be sweet, especially in a night map. Rain + night = awesome. | |
| | | Mack THE GLORY
Posts : 1415 Join date : 2010-04-06 Age : 43
| Subject: Re: Weather Script Wed Jul 07, 2010 8:42 am | |
| Isn't rain like, client-side, or did they make another one?
| |
| | | Sharq
Posts : 181 Join date : 2010-07-03 Location : Club TechnoChocolate.
Character sheet Name: Age: 1 Race: Human
| Subject: Re: Weather Script Wed Jul 07, 2010 9:10 am | |
| The only problem with it is it darkens everything. Other than that it's cool. | |
| | | Jackxter
Posts : 238 Join date : 2010-07-03 Location : Delaware
Character sheet Name: Judith Both Age: 32 Race: Human
| Subject: Re: Weather Script Wed Jul 07, 2010 9:54 am | |
| Alright here's watcha gotta do. Make a file called cl_weather and put it with the rest of the gamemode stuff - Code:
-
local WEATHER={ ["sunny"]={ Brightness=0, Contrast=1, Colour=1, Precipitation=0, }, ["cloudy"]={ Brightness=0, Contrast=1, Colour=0.6, Precipitation=0, }, ["rain"]={ Brightness=-0.07, Contrast=0.9, Colour=0.4, Precipitation=10, Sound="ambient/weather/rumble_rain_nowind.wav" }, ["snow"]={ Brightness=-0.07, Contrast=0.9, Colour=0.4, Precipitation=25, Sound="ambient/wind/wind_med1.wav" }, ["sunnyrain"]={ Brightness=0, Contrast=0.7, Colour=1.2, Precipitation=10, Sound="ambient/weather/rumble_rain_nowind.wav" }, ["storm"]={ Brightness=-0.15, Contrast=0.7, Colour=0.1, Precipitation=26, Sound="ambient/weather/rumble_rain.wav" }, ["dark"]={ Brightness=0, Contrast=0.3, Colour=1, Precipitation=0, }, ["darkrain"]={ Brightness=0, Contrast=0.3, Colour=1, Precipitation=5, Sound="ambient/weather/rumble_rain_nowind.wav" }, ["darksnow"]={ Brightness=0, Contrast=0.3, Colour=1, Precipitation=25, Sound="ambient/wind/wind_med1.wav" }, }
local CurWeather={ Brightness=0, Contrast=1, Colour=1, }
SetGlobalString("weather","sunny")
local WeatherSound=nil local PrevWeather="sunny" local LastLightning=0
function WeatherOverlay()
if render.GetDXLevel() < 80 then return end
local WeatherName=GetGlobalString("weather") if not WeatherName or not WEATHER[WeatherName] then WeatherName="sunny" end local traced = {} traced.start = LocalPlayer():GetPos() traced.endpos = LocalPlayer():GetPos()+Vector(0,0,700) traced.mask = MASK_NPCWORLDSTATIC local tr=util.TraceLine(traced)
CurWeather.Brightness=math.Approach( CurWeather.Brightness, WEATHER[WeatherName].Brightness, 0.01 ) CurWeather.Contrast=math.Approach( CurWeather.Contrast, WEATHER[WeatherName].Contrast, 0.01 ) CurWeather.Colour=math.Approach( CurWeather.Colour, WEATHER[WeatherName].Colour, 0.01 )
local ScrColTab = {} ScrColTab[ "$pp_colour_addr" ] = 0 ScrColTab[ "$pp_colour_addg" ] = 0 ScrColTab[ "$pp_colour_addb" ] = 0 ScrColTab[ "$pp_colour_brightness" ]= CurWeather.Brightness ScrColTab[ "$pp_colour_contrast" ] = CurWeather.Contrast ScrColTab[ "$pp_colour_colour" ] = CurWeather.Colour ScrColTab[ "$pp_colour_mulr" ] = 0 ScrColTab[ "$pp_colour_mulg" ] = 0 ScrColTab[ "$pp_colour_mulb" ] = 0 DrawColorModify(ScrColTab) if not PrevWeather or PrevWeather~=WeatherName then if WeatherSound then WeatherSound:Stop() end if WEATHER[WeatherName].Sound then WeatherSound=CreateSound(LocalPlayer(),WEATHER[WeatherName].Sound) WeatherSound:Play() PrevWeather=WeatherName else WeatherSound=nil end end if CurTime()>LastLightning and WEATHER[WeatherName].Precipitation>25 then if math.random(1,20)==10 then LastLightning=CurTime()+30 CurWeather.Contrast=5 timer.Simple(0.2,function() CurWeather.Contrast=WEATHER[WeatherName].Contrast end) timer.Simple(3,function() surface.PlaySound(Format("ambient/atmosphere/thunder%i.wav",math.random(1,4))) end) end end if WeatherSound and tr.HitWorld or (WeatherSound and LocalPlayer():InVehicle()) then WeatherSound:SetSoundLevel(2) WeatherSound:ChangePitch(50) elseif WeatherSound then WeatherSound:SetSoundLevel(3.9) WeatherSound:ChangePitch(100) end
end hook.Add("RenderScreenspaceEffects", "WeatherOverlay", WeatherOverlay)
local LastEffect=0 function WeatherThink() if GetGlobalString("weather") == "snow" then local WeatherName=GetGlobalString("weather") if not WeatherName or not WEATHER[WeatherName] then WeatherName="sunny" end if WEATHER[WeatherName].Precipitation>0 then if CurTime()>LastEffect then LastEffect=CurTime()+1 local eff=EffectData() eff:SetMagnitude(WEATHER[WeatherName].Precipitation) util.Effect("snow",eff) end end elseif GetGlobalString("weather") == "darksnow" then local WeatherName=GetGlobalString("weather") if not WeatherName or not WEATHER[WeatherName] then WeatherName="sunny" end if WEATHER[WeatherName].Precipitation>0 then if CurTime()>LastEffect then LastEffect=CurTime()+1 local eff=EffectData() eff:SetMagnitude(WEATHER[WeatherName].Precipitation) util.Effect("snow",eff) end end else local WeatherName=GetGlobalString("weather") if not WeatherName or not WEATHER[WeatherName] then WeatherName="sunny" end if WEATHER[WeatherName].Precipitation>0 then if CurTime()>LastEffect then LastEffect=CurTime()+1 local eff=EffectData() eff:SetMagnitude(WEATHER[WeatherName].Precipitation) util.Effect("rain",eff) end end end end hook.Add("Think","",WeatherThink)
Don't forget to add AddCSLuaFile( "cl_weather.lua" ) to your init and then include( 'cl_weather.lua' ) to the cl_init file. Add this to concmd. - Code:
-
function SetSunny() SetGlobalString("weather", "sunny") end concommand.Add("setsunny", SetSunny)
function SetCloudy() SetGlobalString("weather", "cloudy") end concommand.Add("setcloudy", SetCloudy)
function SetRain() SetGlobalString("weather", "rain") end concommand.Add("setrain", SetRain)
function SetSunnyRain() SetGlobalString("weather", "sunnyrain") end concommand.Add("setsunnyrain", SetSunnyRain)
function SetStorm() SetGlobalString("weather", "storm") end concommand.Add("setstorm", SetStorm)
function SetDark() SetGlobalString("weather", "dark") end concommand.Add("setdark", SetDark)
function SetDarkRain() SetGlobalString("weather", "darkrain") end concommand.Add("setdarkrain", SetDarkRain)
function SetSnow() SetGlobalString("weather", "snow") end concommand.Add("setsnow", SetSnow)
function SetDarkSnow() SetGlobalString("weather", "darksnow") end concommand.Add("setdarksnow", SetDarkSnow)
Make a folder in lua/effects titled rain. The init file should look like this. - Code:
-
local density=CreateClientConVar("cs_raindensity","1",false,false)
function EFFECT:Init(data) self.Particles=data:GetMagnitude()*density:GetInt() self.DieTime=CurTime()+1 self.Emitter=ParticleEmitter(LocalPlayer():GetPos()) end
local function ParticleCollides(particle, pos, norm) particle:SetDieTime(0) local effectdata = EffectData() effectdata:SetStart(pos) effectdata:SetOrigin(pos) effectdata:SetScale(2) util.Effect( "watersplash", effectdata ) end
function EFFECT:Think() if CurTime()>self.DieTime then return false end local emitter = self.Emitter for i=1, self.Particles do local spawnpos = LocalPlayer():GetPos()+Vector(math.random(-1200,1200)+LocalPlayer():GetVelocity().x*2,math.random(-1200,1200)+LocalPlayer():GetVelocity().y*2,1000) local particle = emitter:Add("particle/Water/WaterDrop_001a", spawnpos) if (particle) then particle:SetVelocity(Vector(math.sin(CurTime()/4)*30,50,-700)) particle:SetLifeTime(0) particle:SetDieTime(4) particle:SetEndAlpha(255) particle:SetStartSize(0) particle:SetEndSize(5) particle:SetAirResistance(0) particle:SetStartAlpha(128) particle:SetCollide(true) particle:SetBounce(0) particle:SetCollideCallback(ParticleCollides) end end return true end
function EFFECT:Render()
end
make another one called snow. - Code:
-
function EFFECT:Init(data) self.amount = data:GetMagnitude() self.time = CurTime()+1 end
function EFFECT:Emit() local emitter = ParticleEmitter(LocalPlayer():GetPos()) for i=0, math.Round(self.amount) do local a = math.random(9999) local b = math.random(1,180) local dist = math.random(256,2048) local X = math.sin(b)*math.sin(a)*dist local Y = math.sin(b)*math.cos(a)*dist local offset = Vector(X,Y,0) local spawnpos = LocalPlayer():GetPos()+Vector(0,0,1024)+offset local particle = emitter:Add("particle/snow", spawnpos) if (particle) then particle:SetLifeTime(math.random(-2,0)) particle:SetDieTime(math.Clamp((self.amount/80)+math.random(-10,10), 10, 20)) particle:SetStartAlpha(254) particle:SetEndAlpha(254) particle:SetStartSize(2) particle:SetEndSize(2) particle:SetAirResistance(1) particle:SetGravity(Vector(0,0,math.random(-125,-50))) particle:SetCollide(true) particle:SetBounce(.01) particle:SetColor(255,255,255,255) end end emitter:Finish() end
function EFFECT:Think() if not (self.time < CurTime()) then self:Emit() else return false end end
function EFFECT:Render() end
I take no credit for the code since most of it I got off facepunch. | |
| | | GordonGuy
Posts : 171 Join date : 2010-07-03 Age : 28
Character sheet Name: Age: Race:
| Subject: Re: Weather Script Wed Jul 07, 2010 10:25 am | |
| Remove the ability for it to be changed over and over by admins so there's no weather raves again. :< | |
| | | v4ltt3ri
Posts : 46 Join date : 2010-07-04 Age : 33 Location : Finland
Character sheet Name: Age: 1 Race: Human
| Subject: Re: Weather Script Thu Jul 08, 2010 4:25 am | |
| - GordonGuy wrote:
- Remove the ability for it to be changed over and over by admins so there's no weather raves again. :<
No no, it should be able to be controlled by admins for events and such. Just make strict rules not to fuck around with it. | |
| | | Jackxter
Posts : 238 Join date : 2010-07-03 Location : Delaware
Character sheet Name: Judith Both Age: 32 Race: Human
| Subject: Re: Weather Script Thu Jul 08, 2010 1:02 pm | |
| I think he meant to make it admin only. What admin would do such a thing? | |
| | | Rutabega Moderator
Posts : 851 Join date : 2010-01-18 Age : 31
| Subject: Re: Weather Script Thu Jul 08, 2010 3:45 pm | |
| And of course the weather only effects people outside, right? | |
| | | GordonGuy
Posts : 171 Join date : 2010-07-03 Age : 28
Character sheet Name: Age: Race:
| Subject: Re: Weather Script Thu Jul 08, 2010 4:04 pm | |
| There used to be, if you stayed outside long enough you caught a cold and it lowered your health to 1, or whatever it was on third/whatever forest | |
| | | Psycheandromida He Who Wears Sunglasses at Night
Posts : 1503 Join date : 2009-09-25
| Subject: Re: Weather Script Thu Jul 08, 2010 4:32 pm | |
| - Rutabega wrote:
- And of course the weather only effects people outside, right?
The weather particles don't fall if any sort of brush (That's the walls, ground and everything block on maps) is above your head. When that happens, the ambient sound becomes muffled as if you're inside a building. | |
| | | Blitz
Posts : 820 Join date : 2009-12-20 Age : 30 Location : ATL, yo.
Character sheet Name: Herr Doktor Age: ??? Race: Doktor.
| Subject: Re: Weather Script Mon Jul 12, 2010 11:29 am | |
| Ugh, I hate the darkening effect with weather mod. | |
| | | GordonGuy
Posts : 171 Join date : 2010-07-03 Age : 28
Character sheet Name: Age: Race:
| | | | Markka Moderator
Posts : 916 Join date : 2010-04-29 Age : 31
Character sheet Name: Mirage Silverspine Age: 17 Race: Human
| Subject: Re: Weather Script Mon Jul 12, 2010 12:44 pm | |
| I like it, especially in eyerapingly bright maps. | |
| | | Blitz
Posts : 820 Join date : 2009-12-20 Age : 30 Location : ATL, yo.
Character sheet Name: Herr Doktor Age: ??? Race: Doktor.
| Subject: Re: Weather Script Mon Jul 12, 2010 1:52 pm | |
| | |
| | | Sponsored content
| Subject: Re: Weather Script | |
| |
| | | | Weather Script | |
|
Similar topics | |
|
| Permissions in this forum: | You cannot reply to topics in this forum
| |
| |
| |
|