local B=Vector3.new(.05,.05,.05)local r=Color3.new(1,1,1)local z=0 local n=1 local t=1 local J=.05 local m=.9 local w=Vector3.new(0,-1,0)local x=.25 local u=.75 local D=1000 local I=40 local O=100 local R=20 local M="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\053\049\054\055\057\049\054\050\049"local V=.2 local H=1 local q=1 local i="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\056\050\050\056\056\051\048\052\056"local g=.7 local A=NumberSequence.new(10)local v=NumberRange.new(.8)local j=600 local C=60 local T="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\056\050\050\056\053\054\054\051\051"local X=.85 local K=NumberSequence.new({NumberSequenceKeypoint.new(0,5.33,2.75),NumberSequenceKeypoint.new(1,5.33,2.75)})local c=NumberRange.new(.8)local h=NumberRange.new(0,360)local P=600 local s=60 local Z="\114\098\120\097\115\115\101\116\105\100\058\047\047\049\056\050\050\056\053\054\054\051\051"local N=.6 local W=NumberSequence.new({NumberSequenceKeypoint.new(0,0),NumberSequenceKeypoint.new(.4,3),NumberSequenceKeypoint.new(1,0)})local E=NumberRange.new(.1,.15)local S=NumberRange.new(0,360)local F=20 local a=.5 local o=50 local e=20 local k=100 local p=70 local G=100 local f=Vector2.new(10,10)local d=2 local b=500 local l=-100 local Y=100 local Q=550 local y=6 local U=35 local L={Vector3.new(.141421363,0,.141421363),Vector3.new(-0.141421363,0,.141421363),Vector3.new(-0.141421363,0,-0.141421363),Vector3.new(.141421363,0,-0.141421363);Vector3.new(.400000006,0,0),Vector3.new(.282842726,0,.282842726),Vector3.new(2.44929371e-17,0,.400000006);Vector3.new(-0.282842726,0,.282842726);Vector3.new(-0.400000006,0,4.89858741e-17),Vector3.new(-0.282842726,0,-0.282842726),Vector3.new(-7.34788045e-17,0,-0.400000006),Vector3.new(.282842726,0,-0.282842726),Vector3.new(.600000024,0,0);Vector3.new(.485410213,0,.352671146),Vector3.new(.185410202,0,.570633948);Vector3.new(-0.185410202,0,.570633948),Vector3.new(-0.485410213,0,.352671146),Vector3.new(-0.600000024,0,7.34788112e-17);Vector3.new(-0.485410213,0,-0.352671146),Vector3.new(-0.185410202,0,-0.570633948),Vector3.new(.185410202,0,-0.570633948),Vector3.new(.485410213,0,-0.352671146);Vector3.new(.772740662,0,.207055241),Vector3.new(.565685451,0,.565685451);Vector3.new(.207055241,0,.772740662);Vector3.new(-0.207055241,0,.772740662),Vector3.new(-0.565685451,0,.565685451),Vector3.new(-0.772740662,0,.207055241);Vector3.new(-0.772740662,0,-0.207055241);Vector3.new(-0.565685451,0,-0.565685451),Vector3.new(-0.207055241,0,-0.772740662);Vector3.new(.207055241,0,-0.772740662);Vector3.new(.565685451,0,-0.565685451);Vector3.new(.772740662,0,-0.207055241)}


local MIN_SIZE = Vector3.new(0.05,0.05,0.05)				-- Size of main emitter part when rain inactive

local RAIN_DEFAULT_COLOR = Color3.new(1,1,1)				-- Default color3 of all rain elements
local RAIN_DEFAULT_TRANSPARENCY = 0							-- Default transparency scale ratio of all rain elements
local RAIN_DEFAULT_SPEEDRATIO = 1							-- Default speed scale ratio of falling rain effects
local RAIN_DEFAULT_INTENSITYRATIO = 1						-- Default intensity ratio of all rain elements
local RAIN_DEFAULT_LIGHTEMISSION = 0.05						-- Default LightEmission of all rain elements
local RAIN_DEFAULT_LIGHTINFLUENCE = 0.9						-- Default LightInfluence of all rain elements
local RAIN_DEFAULT_DIRECTION = Vector3.new(0,-1,0)			-- Default direction for rain to fall into

local RAIN_TRANSPARENCY_T1 = .25							-- Define the shape (time-wise) of the transparency curves for emitters
local RAIN_TRANSPARENCY_T2 = .75

local RAIN_SCANHEIGHT = 1000								-- How many studs to scan up from camera position to determine whether occluded

local RAIN_EMITTER_DIM_DEFAULT = 40							-- Size of emitter block to the side/up
local RAIN_EMITTER_DIM_MAXFORWARD = 100						-- Size of emitter block forwards when looking at the horizon
local RAIN_EMITTER_UP_MODIFIER = 20							-- Maximum vertical displacement of emitter (when looking fully up/down)

local RAIN_SOUND_ASSET = "rbxassetid://1516791621"
local RAIN_SOUND_BASEVOLUME = 0.2							-- Starting volume of rain sound effect when not occluded
local RAIN_SOUND_FADEIN_TIME = 1							-- Tween in/out times for sound volume
local RAIN_SOUND_FADEOUT_TIME = 1

local RAIN_STRAIGHT_ASSET = "rbxassetid://1822883048"		-- Some properties of the straight rain particle effect
local RAIN_STRAIGHT_ALPHA_LOW = 0.7							-- Minimum particle transparency for the straight rain emitter
local RAIN_STRAIGHT_SIZE = NumberSequence.new(10)
local RAIN_STRAIGHT_LIFETIME = NumberRange.new(0.8)
local RAIN_STRAIGHT_MAX_RATE = 600							-- Maximum rate for the straight rain emitter
local RAIN_STRAIGHT_MAX_SPEED = 60							-- Maximum speed for the straight rain emitter

local RAIN_TOPDOWN_ASSET = "rbxassetid://1822856633"		-- Some properties of the top-down rain particle effect
local RAIN_TOPDOWN_ALPHA_LOW = 0.85							-- Minimum particle transparency for the top-down rain emitter
local RAIN_TOPDOWN_SIZE = NumberSequence.new {
	NumberSequenceKeypoint.new(0, 5.33, 2.75);
	NumberSequenceKeypoint.new(1, 5.33, 2.75);
}			
local RAIN_TOPDOWN_LIFETIME = NumberRange.new(0.8)
local RAIN_TOPDOWN_ROTATION = NumberRange.new(0,360)
local RAIN_TOPDOWN_MAX_RATE = 600							-- Maximum rate for the top-down rain emitter
local RAIN_TOPDOWN_MAX_SPEED = 60							-- Maximum speed for the top-down rain emitter

local RAIN_SPLASH_ASSET = "rbxassetid://1822856633"			-- Some properties of the splash particle effect
local RAIN_SPLASH_ALPHA_LOW = 0.6							-- Minimum particle transparency for the splash emitters
local RAIN_SPLASH_SIZE = NumberSequence.new {				
	NumberSequenceKeypoint.new(0, 0);
	NumberSequenceKeypoint.new(.4, 3);
	NumberSequenceKeypoint.new(1, 0);
}
local RAIN_SPLASH_LIFETIME = NumberRange.new(0.1, 0.15)
local RAIN_SPLASH_ROTATION = NumberRange.new(0,360)
local RAIN_SPLASH_NUM = 20									-- Amount of splashes per frame
local RAIN_SPLASH_CORRECTION_Y = .5							-- Offset from impact position for visual reasons
local RAIN_SPLASH_STRAIGHT_OFFSET_Y = 50					-- Offset against rain direction for straight rain particles from splash position
local RAIN_NOSPLASH_STRAIGHT_OFFSET_Y_MIN = 20				-- Min/max vertical offset from camera height for straight rain particles
local RAIN_NOSPLASH_STRAIGHT_OFFSET_Y_MAX = 100				-- when no splash position could be found (i.e. no floor at that XZ-column)

local RAIN_OCCLUDED_MINSPEED = 70							-- Minimum speed for the occluded straight rain emitters
local RAIN_OCCLUDED_MAXSPEED = 100							-- Maximum speed for the occluded straight rain emitters
local RAIN_OCCLUDED_SPREAD = Vector2.new(10,10)				-- Spread angle for the occluded straight rain emitters
local RAIN_OCCLUDED_MAXINTENSITY = 2						-- How many occluded straight rain particles are emitted for every splash for max intensity

local RAIN_OCCLUDECHECK_OFFSET_Y = 500						-- Vertical offset from camera height to start scanning downward from for splashes
local RAIN_OCCLUDECHECK_OFFSET_XZ_MIN = -100				-- Range of possible XZ offset values from camera XZ position for the splashes
local RAIN_OCCLUDECHECK_OFFSET_XZ_MAX = 100
local RAIN_OCCLUDECHECK_SCAN_Y = 550						-- Scan magnitude along rain path

local RAIN_UPDATE_PERIOD = 6								-- Update the transparency of the main emitters + volume of rain inside every X frames

local RAIN_VOLUME_SCAN_RADIUS = 35							-- Defining grid for checking how far the camera is away from a spot exposed to rain
local RAIN_VOLUME_SCAN_GRID = {								-- Unit range grid for scanning how far away user is from rain space
	-- range 0.2, 4 pts
	Vector3.new(0.141421363, 0, 0.141421363);
	Vector3.new(-0.141421363, 0, 0.141421363);
	Vector3.new(-0.141421363, 0, -0.141421363);
	Vector3.new(0.141421363, 0, -0.141421363);
	-- range 0.4, 8 pts
	Vector3.new(0.400000006, 0, 0);
	Vector3.new(0.282842726, 0, 0.282842726);
	Vector3.new(2.44929371e-17, 0, 0.400000006);
	Vector3.new(-0.282842726, 0, 0.282842726);
	Vector3.new(-0.400000006, 0, 4.89858741e-17);
	Vector3.new(-0.282842726, 0, -0.282842726);
	Vector3.new(-7.34788045e-17, 0, -0.400000006);
	Vector3.new(0.282842726, 0, -0.282842726);
	-- range 0.6, 10 pts
	Vector3.new(0.600000024, 0, 0);
	Vector3.new(0.485410213, 0, 0.352671146);
	Vector3.new(0.185410202, 0, 0.570633948);
	Vector3.new(-0.185410202, 0, 0.570633948);
	Vector3.new(-0.485410213, 0, 0.352671146);
	Vector3.new(-0.600000024, 0, 7.34788112e-17);
	Vector3.new(-0.485410213, 0, -0.352671146);
	Vector3.new(-0.185410202, 0, -0.570633948);
	Vector3.new(0.185410202, 0, -0.570633948);
	Vector3.new(0.485410213, 0, -0.352671146);
	-- range 0.8, 12 pts
	Vector3.new(0.772740662, 0, 0.207055241);
	Vector3.new(0.565685451, 0, 0.565685451);
	Vector3.new(0.207055241, 0, 0.772740662);
	Vector3.new(-0.207055241, 0, 0.772740662);
	Vector3.new(-0.565685451, 0, 0.565685451);
	Vector3.new(-0.772740662, 0, 0.207055241);
	Vector3.new(-0.772740662, 0, -0.207055241);
	Vector3.new(-0.565685451, 0, -0.565685451);
	Vector3.new(-0.207055241, 0, -0.772740662);
	Vector3.new(0.207055241, 0, -0.772740662);
	Vector3.new(0.565685451, 0, -0.565685451);
	Vector3.new(0.772740662, 0, -0.207055241);
}

