Advertisement
Aussiemon

NoFog.lua

Apr 25th, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.74 KB | None | 0 0
  1. --[[
  2. author: Aussiemon
  3.  
  4. -----
  5.  
  6. Copyright 2018 Aussiemon
  7.  
  8. 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:
  9.  
  10. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  11.  
  12. 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.
  13.  
  14. -----
  15.  
  16. Allows the modification of advanced graphics settings through moods.
  17. --]]
  18.  
  19. local mod_name = "AdvGraphicsOptions"
  20.  
  21. -- ##########################################################
  22. -- ################## Variables #############################
  23.  
  24. AdvGraphicsOptions = AdvGraphicsOptions or {}
  25. local mod = AdvGraphicsOptions
  26.  
  27. -- Change these values to set custom graphics options
  28. mod.custom_mood = {
  29.  
  30. variable_weights = { -- 0 = Disabled override, 1 = Enabled override
  31.  
  32. custom_fog_blend_enabled = 1,
  33. custom_fog_blend = 0,
  34. custom_fog_blend_color = 0,
  35. custom_fog_blend_direction = 0,
  36.  
  37. fog_enabled = 1,
  38. fog_color = 0,
  39. fog_depth_range = 0,
  40. fog_sun_blend = 0,
  41. fog_type = 0,
  42.  
  43. height_fog_offset_falloff = 1,
  44.  
  45. skydome_fog_height_falloff = 1,
  46.  
  47. wind_amount = 1
  48. },
  49.  
  50. variables = { -- Change these to configure override settings, then set their value to 1 in the table above.
  51.  
  52. custom_fog_blend_enabled = 0, -- 0
  53. custom_fog_blend = {
  54. 1,
  55. 8,
  56. 1
  57. },
  58. custom_fog_blend_color = {
  59. 0,
  60. 0,
  61. 0
  62. },
  63. custom_fog_blend_direction = {
  64. 0.91508618606599,
  65. -0.40325831928332,
  66. 0
  67. },
  68.  
  69. fog_enabled = 0, -- 1
  70. fog_color = {
  71. 0.040441176470588,
  72. 0.047707612456747,
  73. 0.0625
  74. },
  75. fog_depth_range = {
  76. [1.0] = 5,
  77. [2.0] = 292.68
  78. },
  79. fog_sun_blend = {
  80. 0.195,
  81. 4.15,
  82. 0.668
  83. },
  84. fog_type = 1, -- 1
  85.  
  86. height_fog_offset_falloff = {
  87. [1.0] = -375.61,
  88. [2.0] = 1780.5523560976
  89. },
  90.  
  91. skydome_fog_height_falloff = {
  92. [1.0] = 0.088,
  93. [2.0] = -2.93
  94. },
  95.  
  96. wind_amount = {
  97. 0,
  98. 0,
  99. 0
  100. }
  101. },
  102. editor_variables = {}
  103. }
  104.  
  105. -- MoodSettings registry value
  106. mod.mood_setting = {
  107. environment_setting = "custom",
  108. blend_in_time = 0,
  109. blend_out_time = 0,
  110. particle_effects_on_enter = {},
  111. particle_effects_on_exit = {}
  112. }
  113.  
  114. local Managers = Managers
  115. local MoodSettings = MoodSettings
  116. local MoodPriority = MoodPriority
  117. local Mods = Mods
  118. local MOOD_BLACKBOARD = MOOD_BLACKBOARD
  119. local table = table
  120. local require = require
  121.  
  122. -- ##########################################################
  123. -- ################## Functions #############################
  124.  
  125. mod.update_moods = function()
  126.  
  127. -- Get local camera
  128. local camera = Managers.state.camera
  129. if not camera then
  130. return
  131. end
  132.  
  133. -- Get local mood handler
  134. local mood_handler = camera.mood_handler
  135. if not mood_handler then
  136. return
  137. end
  138.  
  139. -- Add to tables that store mood references
  140. MoodSettings["custom"] = mod.mood_setting
  141. local need_priority_setting = true
  142. for i = 1, #MoodPriority do
  143. if MoodPriority[i] == "custom" then
  144. need_priority_setting = false
  145. break
  146. end
  147. end
  148. if need_priority_setting then
  149. table.insert(MoodPriority, 1, "custom")
  150. end
  151.  
  152. -- Take the lua mood script
  153. local environment = require("scripts/settings/lua_environments/moods")
  154.  
  155. -- Add custom entry
  156. environment.settings["custom"] = mod.custom_mood
  157.  
  158. -- Update moods in local mood handler
  159. local env_vars, type_map = mood_handler.parse_environment_settings(mood_handler, environment)
  160. mood_handler.environment_variables = env_vars
  161. mood_handler.environment_variables_type_map = type_map
  162. end
  163.  
  164. -- ##########################################################
  165. -- #################### Hooks ###############################
  166.  
  167. -- Add our custom mood setting at mood handler initialization
  168. Mods.hook.set(mod_name, "MoodHandler.init", function (func, self, world)
  169.  
  170. -- Add to tables that store mood references
  171. MoodSettings["custom"] = mod.mood_setting
  172. local need_priority_setting = true
  173. for i = 1, #MoodPriority do
  174. if MoodPriority[i] == "custom" then
  175. need_priority_setting = false
  176. break
  177. end
  178. end
  179. if need_priority_setting then
  180. table.insert(MoodPriority, 2, "custom")
  181. end
  182.  
  183. self.world = world
  184. self.playing_particles = {}
  185. self.current_mood = "custom"
  186. self.mood_blends = nil
  187. self.mood_weights = {}
  188.  
  189. -- Take the lua mood script
  190. local environment = require("scripts/settings/lua_environments/moods")
  191.  
  192. -- Add custom entry
  193. environment.settings["custom"] = mod.custom_mood
  194.  
  195. -- Update moods in this new mood handler
  196. local env_vars, type_map = self.parse_environment_settings(self, environment)
  197. self.environment_variables = env_vars
  198. self.environment_variables_type_map = type_map
  199. self.environment_variables_to_set = {}
  200. self.environment_weight_remainder = 1
  201.  
  202. return
  203. end)
  204.  
  205. -- Change default mood setting to custom mood setting
  206. Mods.hook.set(mod_name, "StateInGameRunning.update_mood", function (func, self, dt, t)
  207.  
  208. local mood_settings = MoodSettings
  209. local mood_priority = MoodPriority
  210. local mood_handler = Managers.state.camera.mood_handler
  211. local mood_timers = self.mood_timers
  212. local mood_blackboard = MOOD_BLACKBOARD
  213. local wanted_mood = nil
  214.  
  215. for i = 1, #mood_priority, 1 do
  216. local mood = mood_priority[i]
  217.  
  218. if mood_timers[mood] and mood_timers[mood] < t then
  219. mood_timers[mood] = nil
  220. mood_blackboard[mood] = false
  221. end
  222.  
  223. if mood_blackboard[mood] == true then
  224. if not wanted_mood then
  225. wanted_mood = mood
  226. elseif mood_settings[mood].hold_time then
  227. mood_blackboard[mood] = false
  228. end
  229. end
  230. end
  231.  
  232. wanted_mood = wanted_mood or "custom"
  233.  
  234. if wanted_mood ~= mood_handler.current_mood then
  235. mood_handler.set_mood(mood_handler, wanted_mood)
  236.  
  237. if wanted_mood ~= "custom" then
  238. local hold_time = mood_settings[wanted_mood].hold_time
  239.  
  240. if hold_time then
  241. mood_timers[wanted_mood] = t + hold_time
  242. end
  243. end
  244. end
  245. end)
  246.  
  247. -- ##########################################################
  248. -- ################### Script ###############################
  249.  
  250. mod.update_moods()
  251.  
  252. -- ##########################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement