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 user to fly freely around the map.
- Press F9 to start freeflight, then press F7 to start orthographic perspective. Press F7 again to disable. Press F9 again to disable freeflight. When freeflight is disabled, you can press F8 to start cinematic freeflight, where your character is visible and the camera has acceleration. Don't press F9 or F8 while in the other mode to prevent weirdness. Q and E are up/down in all modes. Scroll changes speed in regular freeflight, elevation in orthographic perspective.
- --]]
- FreeFlight = FreeFlight or {}
- local mod = FreeFlight
- local mod_name = "FreeFlight"
- -- ##########################################################
- -- ################## Variables #############################
- -- Initialize variables
- local Camera = Camera
- local EchoConsole = EchoConsole
- local FreeFlightManager = FreeFlightManager
- local GameSettingsDevelopment = GameSettingsDevelopment
- local ScriptViewport = ScriptViewport
- local ScriptWorld = ScriptWorld
- local Managers = Managers
- local Mods = Mods
- mod.first_run_fov_changed = false
- -- ##########################################################
- -- ################## Functions #############################
- -- ##########################################################
- -- #################### Hooks ###############################
- -- Freeflight Manager --
- -- Initialize input service
- Mods.hook.set(mod_name, "FreeFlightManager._enter_global_free_flight", function (func, self, data, ...)
- if not self.input_manager then
- -- Register free flight input manager/service
- local input_manager = Managers.input
- self.register_input_manager(self, input_manager)
- end
- -- Original Function
- local result = func(self, data, ...)
- return result
- end)
- -- Leave unit detached
- Mods.hook.set(mod_name, "FreeFlightManager.drop_player_at_camera_pos", function (func, ...) return end)
- -- Prevent crash when trying to freeze camera frustum
- Mods.hook.set(mod_name, "FreeFlightManager._exit_frustum_freeze", function (func, ...) return end)
- Mods.hook.set(mod_name, "FreeFlightManager._enter_frustum_freeze", function (func, ...) return end)
- -- Input Manager --
- -- Prevent error when taking control of devices without debug console active
- Mods.hook.set(mod_name, "InputManager.device_unblock_service", function (func, self, device_type, device_index, service_name, ...)
- if service_name == "Debug" or service_name == "DebugMenu" then
- return
- end
- -- Original Function
- local result = func(self, device_type, device_index, service_name, ...)
- return result
- end)
- -- ##########################################################
- -- ################### Script ###############################
- Managers.free_flight = Managers.free_flight or FreeFlightManager:new()
- GameSettingsDevelopment.disable_free_flight = false
- -- ##########################################################
Add Comment
Please, Sign In to add comment