Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- author: Aussiemon
- -----
- Copyright 2018 Aussiemon
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- -----
- Allows the modification of advanced graphics settings through moods.
- --]]
- local mod_name = "AdvGraphicsOptions"
- -- ##########################################################
- -- ################## Variables #############################
- AdvGraphicsOptions = AdvGraphicsOptions or {}
- local mod = AdvGraphicsOptions
- -- Change these values to set custom graphics options
- mod.custom_mood = {
- variable_weights = { -- 0 = Disabled override, 1 = Enabled override
- custom_fog_blend_enabled = 1,
- custom_fog_blend = 0,
- custom_fog_blend_color = 0,
- custom_fog_blend_direction = 0,
- fog_enabled = 1,
- fog_color = 0,
- fog_depth_range = 0,
- fog_sun_blend = 0,
- fog_type = 0,
- height_fog_offset_falloff = 1,
- skydome_fog_height_falloff = 1,
- wind_amount = 1
- },
- variables = { -- Change these to configure override settings, then set their value to 1 in the table above.
- custom_fog_blend_enabled = 0, -- 0
- custom_fog_blend = {
- 1,
- 8,
- 1
- },
- custom_fog_blend_color = {
- 0,
- 0,
- 0
- },
- custom_fog_blend_direction = {
- 0.91508618606599,
- -0.40325831928332,
- 0
- },
- fog_enabled = 0, -- 1
- fog_color = {
- 0.040441176470588,
- 0.047707612456747,
- 0.0625
- },
- fog_depth_range = {
- [1.0] = 5,
- [2.0] = 292.68
- },
- fog_sun_blend = {
- 0.195,
- 4.15,
- 0.668
- },
- fog_type = 1, -- 1
- height_fog_offset_falloff = {
- [1.0] = -375.61,
- [2.0] = 1780.5523560976
- },
- skydome_fog_height_falloff = {
- [1.0] = 0.088,
- [2.0] = -2.93
- },
- wind_amount = {
- 0,
- 0,
- 0
- }
- },
- editor_variables = {}
- }
- -- MoodSettings registry value
- mod.mood_setting = {
- environment_setting = "custom",
- blend_in_time = 0,
- blend_out_time = 0,
- particle_effects_on_enter = {},
- particle_effects_on_exit = {}
- }
- local Managers = Managers
- local MoodSettings = MoodSettings
- local MoodPriority = MoodPriority
- local Mods = Mods
- local MOOD_BLACKBOARD = MOOD_BLACKBOARD
- local table = table
- local require = require
- -- ##########################################################
- -- ################## Functions #############################
- mod.update_moods = function()
- -- Get local camera
- local camera = Managers.state.camera
- if not camera then
- return
- end
- -- Get local mood handler
- local mood_handler = camera.mood_handler
- if not mood_handler then
- return
- end
- -- Add to tables that store mood references
- MoodSettings["custom"] = mod.mood_setting
- local need_priority_setting = true
- for i = 1, #MoodPriority do
- if MoodPriority[i] == "custom" then
- need_priority_setting = false
- break
- end
- end
- if need_priority_setting then
- table.insert(MoodPriority, 1, "custom")
- end
- -- Take the lua mood script
- local environment = require("scripts/settings/lua_environments/moods")
- -- Add custom entry
- environment.settings["custom"] = mod.custom_mood
- -- Update moods in local mood handler
- local env_vars, type_map = mood_handler.parse_environment_settings(mood_handler, environment)
- mood_handler.environment_variables = env_vars
- mood_handler.environment_variables_type_map = type_map
- end
- -- ##########################################################
- -- #################### Hooks ###############################
- -- Add our custom mood setting at mood handler initialization
- Mods.hook.set(mod_name, "MoodHandler.init", function (func, self, world)
- -- Add to tables that store mood references
- MoodSettings["custom"] = mod.mood_setting
- local need_priority_setting = true
- for i = 1, #MoodPriority do
- if MoodPriority[i] == "custom" then
- need_priority_setting = false
- break
- end
- end
- if need_priority_setting then
- table.insert(MoodPriority, 2, "custom")
- end
- self.world = world
- self.playing_particles = {}
- self.current_mood = "custom"
- self.mood_blends = nil
- self.mood_weights = {}
- -- Take the lua mood script
- local environment = require("scripts/settings/lua_environments/moods")
- -- Add custom entry
- environment.settings["custom"] = mod.custom_mood
- -- Update moods in this new mood handler
- local env_vars, type_map = self.parse_environment_settings(self, environment)
- self.environment_variables = env_vars
- self.environment_variables_type_map = type_map
- self.environment_variables_to_set = {}
- self.environment_weight_remainder = 1
- return
- end)
- -- Change default mood setting to custom mood setting
- Mods.hook.set(mod_name, "StateInGameRunning.update_mood", function (func, self, dt, t)
- local mood_settings = MoodSettings
- local mood_priority = MoodPriority
- local mood_handler = Managers.state.camera.mood_handler
- local mood_timers = self.mood_timers
- local mood_blackboard = MOOD_BLACKBOARD
- local wanted_mood = nil
- for i = 1, #mood_priority, 1 do
- local mood = mood_priority[i]
- if mood_timers[mood] and mood_timers[mood] < t then
- mood_timers[mood] = nil
- mood_blackboard[mood] = false
- end
- if mood_blackboard[mood] == true then
- if not wanted_mood then
- wanted_mood = mood
- elseif mood_settings[mood].hold_time then
- mood_blackboard[mood] = false
- end
- end
- end
- wanted_mood = wanted_mood or "custom"
- if wanted_mood ~= mood_handler.current_mood then
- mood_handler.set_mood(mood_handler, wanted_mood)
- if wanted_mood ~= "custom" then
- local hold_time = mood_settings[wanted_mood].hold_time
- if hold_time then
- mood_timers[wanted_mood] = t + hold_time
- end
- end
- end
- end)
- -- ##########################################################
- -- ################### Script ###############################
- mod.update_moods()
- -- ##########################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement