diff --git a/vmf/scripts/mods/vmf/modules/core/mutators/mutators_dice.lua b/vmf/scripts/mods/vmf/modules/core/mutators/mutators_dice.lua index 719f59d..5fc675d 100644 --- a/vmf/scripts/mods/vmf/modules/core/mutators/mutators_dice.lua +++ b/vmf/scripts/mods/vmf/modules/core/mutators/mutators_dice.lua @@ -39,7 +39,7 @@ end -- ##### Hooks ######################################################################################################### -- ##################################################################################################################### -vmf:hook("GameModeManager.complete_level", function(func, ...) +vmf:hook(GameModeManager, "complete_level", function(func, ...) local num_dice = 0 local max_dice = 7 local mission_system = Managers.state.entity:system("mission_system") diff --git a/vmf/scripts/mods/vmf/modules/core/mutators/mutators_info.lua b/vmf/scripts/mods/vmf/modules/core/mutators/mutators_info.lua index fa71b64..1e8ba04 100644 --- a/vmf/scripts/mods/vmf/modules/core/mutators/mutators_info.lua +++ b/vmf/scripts/mods/vmf/modules/core/mutators/mutators_info.lua @@ -57,7 +57,7 @@ end -- ##################################################################################################################### -- Append difficulty name with enabled mutators' titles -vmf:hook("IngamePlayerListUI.update_difficulty", function(func_, self) +vmf:hook_origin(IngamePlayerListUI, "update_difficulty", function(self) local difficulty_settings = Managers.state.difficulty:get_difficulty_settings() local difficulty_name = difficulty_settings.display_name @@ -76,8 +76,7 @@ end) -- Notify everybody about enabled/disabled mutators when Play button is pressed on the map screen -vmf:hook("MatchmakingStateHostGame.host_game", function(func, ...) - func(...) +vmf:hook_safe(MatchmakingStateHostGame, "host_game", function() set_lobby_data() local names = add_enabled_mutators_titles_to_string(", ") if names ~= "" then @@ -90,8 +89,9 @@ vmf:hook("MatchmakingStateHostGame.host_game", function(func, ...) end) +-- @TODO: can't I do it with hook_safe? Also can't I just use 'sender' intead of extracting peer_id form cookie? -- Send special messages with enabled mutators list to players just joining the lobby -vmf:hook("MatchmakingManager.rpc_matchmaking_request_join_lobby", function(func, self, sender, client_cookie, ...) +vmf:hook(MatchmakingManager, "rpc_matchmaking_request_join_lobby", function(func, self, sender, client_cookie, ...) local name = add_enabled_mutators_titles_to_string(", ") if name ~= "" then local message = vmf:localize("whisper_enabled_mutators") .. ": " .. name diff --git a/vmf/scripts/mods/vmf/modules/core/mutators/mutators_manager.lua b/vmf/scripts/mods/vmf/modules/core/mutators/mutators_manager.lua index 6d39cd2..4989455 100644 --- a/vmf/scripts/mods/vmf/modules/core/mutators/mutators_manager.lua +++ b/vmf/scripts/mods/vmf/modules/core/mutators/mutators_manager.lua @@ -493,8 +493,7 @@ end -- ##### Hooks ######################################################################################################### -- ##################################################################################################################### -vmf:hook("DifficultyManager.set_difficulty", function(func, ...) - func(...) +vmf:hook_safe(DifficultyManager, "set_difficulty", function() disable_impossible_mutators(true, "disabled_reason_difficulty_change") end) diff --git a/vmf/scripts/mods/vmf/modules/core/network.lua b/vmf/scripts/mods/vmf/modules/core/network.lua index 9528c43..f9d6dea 100644 --- a/vmf/scripts/mods/vmf/modules/core/network.lua +++ b/vmf/scripts/mods/vmf/modules/core/network.lua @@ -227,8 +227,8 @@ end -- ##### Hooks ######################################################################################################## -- #################################################################################################################### -vmf:hook("ChatManager.rpc_chat_message", - function(func, self, sender, channel_id, message_sender, message, localization_param, ...) +vmf:hook("ChatManager", "rpc_chat_message", + function(func, self, sender, channel_id, message_sender, message, localization_param, ...) if channel_id == VERMINTIDE_CHANNEL_ID then @@ -299,16 +299,16 @@ vmf:hook("ChatManager.rpc_chat_message", end end) -vmf:hook("PlayerManager.add_remote_player", function (func, self, peer_id, player_controlled, local_player_id, clan_tag) +vmf:hook(PlayerManager, "add_remote_player", function (func, self, peer_id, player_controlled, ...) if player_controlled then send_rpc_vmf_ping(peer_id) end - return func(self, peer_id, player_controlled, local_player_id, clan_tag) + return func(self, peer_id, player_controlled, ...) end) -vmf:hook("PlayerManager.remove_player", function (func, self, peer_id, local_player_id) +vmf:hook(PlayerManager, "remove_player", function (func, self, peer_id, ...) if _vmf_users[peer_id] then @@ -332,7 +332,7 @@ vmf:hook("PlayerManager.remove_player", function (func, self, peer_id, local_pla end end - func(self, peer_id, local_player_id) + func(self, peer_id, ...) end) -- #################################################################################################################### diff --git a/vmf/scripts/mods/vmf/modules/gui/custom_menus.lua b/vmf/scripts/mods/vmf/modules/gui/custom_menus.lua index f1e3fc5..a8afbb4 100644 --- a/vmf/scripts/mods/vmf/modules/gui/custom_menus.lua +++ b/vmf/scripts/mods/vmf/modules/gui/custom_menus.lua @@ -72,8 +72,7 @@ end -- ##### Hooks ######################################################################################################## -- #################################################################################################################### -vmf:hook("IngameUI.setup_views", function(func, self, ingame_ui_context) - func(self, ingame_ui_context) +vmf:hook_safe(IngameUI, "setup_views", function(self, ingame_ui_context) for view_name, view_settings in pairs(views_settings) do @@ -97,15 +96,11 @@ vmf:hook("IngameUI.setup_views", function(func, self, ingame_ui_context) end end) -vmf:hook("IngameUI.init", function(func, self, ingame_ui_context) - func(self, ingame_ui_context) - +vmf:hook_safe(IngameUI, "init", function(self) ingame_ui = self end) -vmf:hook("IngameUI.destroy", function(func, self) - func(self) - +vmf:hook_safe(IngameUI, "destroy", function() ingame_ui = nil end) diff --git a/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua b/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua index edf70b7..19c0fde 100644 --- a/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua +++ b/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua @@ -173,7 +173,7 @@ end -- #################################################################################################################### local LUA_SCRIPT_CALLER_POSITION = 4 -vmf:hook("UIRenderer.create", function(func, world, ...) +vmf:hook(UIRenderer, "create", function(func, world, ...) local is_modified = false @@ -239,25 +239,22 @@ vmf:hook("UIRenderer.create", function(func, world, ...) end) -vmf:hook("UIRenderer.destroy", function(func, self, world) - +vmf:hook_safe(UIRenderer, "destroy", function(self) _ui_renderers[self] = nil - - func(self, world) end) -vmf:hook("UIAtlasHelper.has_atlas_settings_by_texture_name", function(func, texture_name) +vmf:hook(UIAtlasHelper, "has_atlas_settings_by_texture_name", function(func, texture_name, ...) if _custom_ui_atlas_settings[texture_name] then return true end - return func(texture_name) + return func(texture_name, ...) end) -vmf:hook("UIAtlasHelper.get_atlas_settings_by_texture_name", function(func, texture_name) +vmf:hook(UIAtlasHelper, "get_atlas_settings_by_texture_name", function(func, texture_name, ...) if _custom_none_atlas_textures[texture_name] then return @@ -267,7 +264,7 @@ vmf:hook("UIAtlasHelper.get_atlas_settings_by_texture_name", function(func, text return _custom_ui_atlas_settings[texture_name] end - return func(texture_name) + return func(texture_name, ...) end) -- #################################################################################################################### diff --git a/vmf/scripts/mods/vmf/modules/ui/chat/chat_actions.lua b/vmf/scripts/mods/vmf/modules/ui/chat/chat_actions.lua index 8031f87..c5d3200 100644 --- a/vmf/scripts/mods/vmf/modules/ui/chat/chat_actions.lua +++ b/vmf/scripts/mods/vmf/modules/ui/chat/chat_actions.lua @@ -46,25 +46,19 @@ end -- ##### Hooks ######################################################################################################## -- #################################################################################################################### -vmf:hook("WorldManager.create_world", function(func, self, name, ...) - local world = func(self, name, ...) - +vmf:hook_safe(WorldManager, "create_world", function(self_, name) if name == "top_ingame_view" then initialize_drawing_function() end - - return world end) -vmf:hook("ChatGui.block_input", function(func, ...) - func(...) - +vmf:hook_safe("ChatGui", "block_input", function() _chat_opened = true end) -vmf:hook("ChatGui._update_input", function(func, self, input_service, menu_input_service, dt, no_unblock, chat_enabled) +vmf:hook("ChatGui", "_update_input", function(func, self, input_service, menu_input_service, dt, no_unblock, chat_enabled) local command_executed = false diff --git a/vmf/scripts/mods/vmf/modules/ui/mutators/mutators_gui.lua b/vmf/scripts/mods/vmf/modules/ui/mutators/mutators_gui.lua index f8ab8fd..7819cb2 100644 --- a/vmf/scripts/mods/vmf/modules/ui/mutators/mutators_gui.lua +++ b/vmf/scripts/mods/vmf/modules/ui/mutators/mutators_gui.lua @@ -383,15 +383,12 @@ end -- ##### Hooks ######################################################################################################## -- #################################################################################################################### -vmf:hook("MapView.init", function (func, self, ingame_ui_context) - func(self, ingame_ui_context) - +vmf:hook_safe(MapView, "init", function (self) initialize_mutators_ui(self) end) -vmf:hook("MapView.update", function (func, self, dt, t) - func(self, dt, t) +vmf:hook_safe(MapView, "update", function (self, dt) if self.menu_active and _IS_MUTATORS_GUI_INITIALIZED then diff --git a/vmf/scripts/mods/vmf/modules/ui/options/vmf_options_view.lua b/vmf/scripts/mods/vmf/modules/ui/options/vmf_options_view.lua index 1df7167..a700f14 100644 --- a/vmf/scripts/mods/vmf/modules/ui/options/vmf_options_view.lua +++ b/vmf/scripts/mods/vmf/modules/ui/options/vmf_options_view.lua @@ -4578,9 +4578,8 @@ vmf.disable_mods_options_button = function () change_mods_options_button_state("disable") end --- @BUG: Game crashes occasionaly here. See attached log -- create mods options menu button in Esc-menu -vmf:hook("IngameView.setup_button_layout", function (func, self, layout_data) +vmf:hook(IngameView, "setup_button_layout", function (func, self, layout_data, ...) local mods_options_button = { display_name = vmf:localize("mods_options"), @@ -4595,7 +4594,7 @@ vmf:hook("IngameView.setup_button_layout", function (func, self, layout_data) end end - func(self, layout_data) + func(self, layout_data, ...) for _, button_info in ipairs(self.active_button_data) do if button_info.transition == "vmf_options_view" then