dieFade = 0 weatherAlpha = 0 weatherActive = false pUnlimited = GetBoolParam("unlimited", true) pWeather = GetBoolParam("weather", true) pSpawn = GetBoolParam("spawn", true) #include "ui/ui_extensions.lua" function init() SetBool("level.sandbox", true) SetBool("level.unlimitedammo", pUnlimited) SetBool("level.spawn", pSpawn) end function tick(dt) --Fade to black and respawn when dead if GetFloat("game.player.health") == 0 then if dieFade == 0 then SetValue("dieFade", 1, "linear", 4) end if dieFade == 1 then RespawnPlayer() end else if dieFade == 1 then SetValue("dieFade", 0, "linear", 1) end end --Unlimited ammo if pUnlimited then local tools = ListKeys("game.tool") for i=1,#tools do SetInt("game.tool."..tools[i]..".ammo", 9999) SetInt("game.tool."..tools[i]..".ammo.max", 9999) end end if pWeather then if PauseMenuButton("loc@CHANGE_WEATHER") then weatherActive = true SetBool("game.ui.hidemods", true) end if weatherActive and weatherAlpha == 0.0 then SetValue("weatherAlpha", 1.0, "easeout", 0.3) end if not weatherActive and weatherAlpha == 1.0 then SetValue("weatherAlpha", 0.0, "easein", 0.3) SetBool("game.ui.hidemods", false) end SetBool("game.windows.weather.active", weatherActive) end end function draw(dt) if dieFade > 0 then UiColor(0,0,0, dieFade) UiRect(UiWidth(), UiHeight()) end if weatherAlpha > 0.0 then -- for weather we do now want to draw a cursor if LastInputDevice() == UI_DEVICE_GAMEPAD then UiSetCursorState(UI_CURSOR_HIDE_AND_LOCK) end if weatherActive then UiMakeInteractive() SetBool("game.disablepause", true) end local width = 380 local height = 650 UiTranslate(-230+270*weatherAlpha, UiMiddle()) UiAlign("left middle") UiColor(.0, .0, .0, 0.75*weatherAlpha) UiImageBox("ui/common/box-solid-10.png", width, height, 10, 10) UiWindow(width, height) UiAlign("top left") if InputPressed("menu_cancel") or (GetBool("game.cursor.enabled") and not UiIsMouseInRect(UiWidth(), UiHeight()) and InputPressed("lmb")) then weatherActive = false end if InputPressed("pause") then weatherActive = false end UiPush() UiAlign("center middle") UiTranslate(UiWidth()/2, 60) UiFont("regular.ttf", 27) local padding = 40 local bw = width - 2 * padding local bh = 38 local sep = 20 UiColor(0.96, 0.96, 0.96) UiButtonImageBox("ui/common/box-outline-fill-6.png", 6, 6, 0.96, 0.96, 0.96, 0.8) UiButtonHoverColor(1.0,1.0,0.5,1) if UiTextButton("loc@UI_BUTTON_SUNRISE", bw, bh) then setWeather("sunrise") end UiTranslate(0, bh+sep) if UiTextButton("loc@UI_BUTTON_SUNNY", bw, bh) then setWeather("sunny") end UiTranslate(0, bh+sep) if UiTextButton("loc@UI_BUTTON_FOGGY", bw, bh) then setWeather("foggy") end UiTranslate(0, bh+sep) if UiTextButton("loc@UI_BUTTON_LIGHT_RAIN", bw, bh) then setWeather("rain") end UiTranslate(0, bh+sep) if UiTextButton("loc@UI_BUTTON_SUNSET", bw, bh) then setWeather("sunset") end UiTranslate(0, bh+sep) if UiTextButton("loc@UI_BUTTON_NIGHT", bw, bh) then setWeather("night") end UiTranslate(0, bh+sep) if UiTextButton("loc@UI_BUTTON_RAINY_NIGHT", bw, bh) then setWeather("rainynight") end UiTranslate(0, bh+sep) if UiTextButton("loc@UI_BUTTON_SNOWY", bw, bh) then setWeather("snowy") end UiTranslate(0, bh+sep) if UiTextButton("loc@UI_BUTTON_SNOWY_NIGHT", bw, bh) then setWeather("snowynight") end UiTranslate(0, bh+sep) UiTranslate(0, 10) if GetString("game.input.curdevice") == "mouse" then if UiTextButton("loc@UI_BUTTON_CLOSE", bw, bh) then weatherActive = false end else Ui:RegularFont(22) UiTranslate(0, 16) UiDrawHintsCentered({ { ico = "[[menu:menu_accept;iconsize=42,42]]", txt = "loc@UI_BUTTON_SELECT" }, { ico = "[[menu:menu_cancel;iconsize=42,42]]", txt = "loc@UI_BUTTON_CLOSE" } },20) end UiPop() end end function setWeather(env) SetEnvironmentDefault() SetPostProcessingDefault() if env == "sunset" then SetEnvironmentProperty("skybox", "sunset.dds") SetEnvironmentProperty("skyboxtint", 1, 0.5, 0.2) SetEnvironmentProperty("fogColor", 0.3, 0.2, 0.08) SetEnvironmentProperty("fogParams", 80, 200, 1, 6) SetEnvironmentProperty("sunBrightness", 1) SetEnvironmentProperty("sunColorTint", 0.2, 0.3, 1) SetEnvironmentProperty("sunFogScale", 1.0) SetEnvironmentProperty("sunGlare", 0.8) SetEnvironmentProperty("exposure", 1, 5) SetEnvironmentProperty("nightlight", false) elseif env == "sunny" then SetEnvironmentProperty("skybox", "day.dds") SetEnvironmentProperty("skyboxbrightness", 0.7) SetEnvironmentProperty("fogColor", 0.9, 0.9, 0.9) SetEnvironmentProperty("fogParams", 50, 200, 0.9, 8) SetEnvironmentProperty("sunBrightness", 4) SetEnvironmentProperty("sunColorTint", 1, 0.8, 0.6) SetEnvironmentProperty("exposure",1, 5) SetEnvironmentProperty("sunFogScale",0.15) SetEnvironmentProperty("nightlight", false) elseif env == "night" then SetEnvironmentProperty("skybox", "cloudy.dds") SetEnvironmentProperty("skyboxbrightness", 0.05) SetEnvironmentProperty("fogColor", 0.02, 0.02, 0.024) SetEnvironmentProperty("fogParams", 20, 120, 0.9, 2) SetEnvironmentProperty("exposure", 1, 5) SetEnvironmentProperty("ambience", "outdoor/night.ogg") SetEnvironmentProperty("nightlight", true) SetPostProcessingProperty("gamma", 0.9) SetPostProcessingProperty("bloom", 1.5) elseif env == "sunrise" then SetEnvironmentProperty("skybox", "cloudy.dds") SetEnvironmentProperty("skyboxtint", 1, 0.4, 0.2) SetEnvironmentProperty("skyboxbrightness", 0.6) SetEnvironmentProperty("fogColor", 1, 0.2, 0.1) SetEnvironmentProperty("fogParams", 30, 160, 0.95, 6) SetEnvironmentProperty("exposure", 1, 5) SetEnvironmentProperty("nightlight", true) elseif env == "foggy" then SetEnvironmentProperty("skybox", "cloudy.dds") SetEnvironmentProperty("skyboxtint", 1.0, 0.6, 0.4) SetEnvironmentProperty("fogColor", 0.2, 0.18, 0.15) SetEnvironmentProperty("fogParams", 0, 60, 0.9, 3) SetEnvironmentProperty("exposure", 1, 5) SetEnvironmentProperty("wetness", 0.4) SetEnvironmentProperty("puddleamount", 0.3) SetEnvironmentProperty("nightlight", false) SetEnvironmentProperty("slippery", 0.1) elseif env == "rain" then SetEnvironmentProperty("skybox", "cloudy.dds") SetEnvironmentProperty("skyboxtint", 1.0, 0.6, 0.4) SetEnvironmentProperty("fogColor", 0.1, 0.1, 0.1) SetEnvironmentProperty("fogParams", 0, 70, 0.9, 1) SetEnvironmentProperty("exposure", 1, 5) SetEnvironmentProperty("wetness", 0.5) SetEnvironmentProperty("puddleamount", 0.5) SetEnvironmentProperty("puddlesize", 0.7) SetEnvironmentProperty("rain", 0.5) SetEnvironmentProperty("ambience", "outdoor/rain_light.ogg") SetEnvironmentProperty("nightlight", false) SetEnvironmentProperty("slippery", 0.2) elseif env == "rainynight" then SetEnvironmentProperty("skybox", "cloudy.dds") SetEnvironmentProperty("skyboxbrightness", 0.02) SetEnvironmentProperty("fogColor", 0.02, 0.02, 0.024) SetEnvironmentProperty("fogParams", 10, 90, 0.9, 2) SetEnvironmentProperty("exposure", 1, 5) SetEnvironmentProperty("wetness", 0.7) SetEnvironmentProperty("puddleamount", 0.7) SetEnvironmentProperty("puddlesize", 0.7) SetEnvironmentProperty("rain", 0.9) SetEnvironmentProperty("ambience", "outdoor/rain_heavy.ogg") SetEnvironmentProperty("nightlight", true) SetEnvironmentProperty("slippery", 0.3) SetPostProcessingProperty("gamma", 0.9) SetPostProcessingProperty("bloom", 1.5) elseif env == "snowy" then SetEnvironmentProperty("skybox", "cool_day.dds") SetEnvironmentProperty("skyboxtint", 0.7, 0.7, 1.0) SetEnvironmentProperty("skyboxbrightness", 0.4) SetEnvironmentProperty("ambient", 1.0) SetEnvironmentProperty("fogColor", 0.35, 0.45, 0.6) SetEnvironmentProperty("fogParams", 10, 200, 1.0, 1.5) SetEnvironmentProperty("ambience", "outdoor/winter.ogg") SetEnvironmentProperty("sunbrightness", 3.14) SetEnvironmentProperty("suncolortint", 1, 0.85, 0.75) SetEnvironmentProperty("sunfogscale", 0.25) SetEnvironmentProperty("sunglare", 0.35) SetEnvironmentProperty("nightlight", false) SetEnvironmentProperty("slippery", 0.3) SetEnvironmentProperty("snowamount", 0.2) SetEnvironmentProperty("snowdir", 0.2, -1, 0.2, 0.2) SetPostProcessingProperty("saturation", 0.7) SetPostProcessingProperty("colorbalance", 0.7, 0.8, 1.0) elseif env == "snowynight" then SetEnvironmentProperty("skybox", "cold_wispy_sky.dds") SetEnvironmentProperty("skyboxbrightness", 0.035) SetEnvironmentProperty("fogColor", 0.005, 0.0055, 0.006) SetEnvironmentProperty("fogParams", 1, 125, 0.9, 0.5) SetEnvironmentProperty("constant", 0.002, 0.002, 0.002) SetEnvironmentProperty("ambient", 1.0) SetEnvironmentProperty("fogscale", 1.5) SetEnvironmentProperty("ambience", "outdoor/winter.ogg") SetEnvironmentProperty("nightlight", true) SetEnvironmentProperty("slippery", 0.3) SetEnvironmentProperty("snowamount", 0.2) SetEnvironmentProperty("snowdir", 0.2, -1, 0.2, 0.2) SetPostProcessingProperty("saturation", 0.7) SetPostProcessingProperty("colorbalance", 0.7, 0.8, 1.0) SetPostProcessingProperty("gamma", 0.85) SetPostProcessingProperty("bloom", 1.5) end end