def Disable(self) -> None: unrealsdk.RemoveHook( "WillowGame.WillowPlayerController.WillowClientDisableLoadingMovie", __file__) unrealsdk.RemoveHook( "WillowGame.WillowPlayerController.WillowClientShowLoadingMovie", __file__)
def HandleInputKey(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: if caller != self._TrainingBox: return True self._HandleInput(params.ukey, params.uevent) self.OnInput(params.ukey, params.uevent) # Decode when we exit from keypresses if params.uevent == 1: if params.ukey in self._SubmitKeys: unrealsdk.RemoveHook( "WillowGame.WillowGFxTrainingDialogBox.HandleInputKey", "CustomTextInputBox") self._TrainingBox = None self.OnSubmit("".join(self._Message)) elif params.ukey in self._ExitKeys: unrealsdk.RemoveHook( "WillowGame.WillowGFxTrainingDialogBox.HandleInputKey", "CustomTextInputBox") self._TrainingBox = None self.OnSubmit("") # Normally the use key causes exits too, block it useKey = "FAKE" if caller.GetPC().PlayerInput is not None: useKey = caller.GetPC().PlayerInput.GetKeyForAction( "Use", True) return str(params.ukey) != useKey
def Disable(self) -> None: unrealsdk.RemoveHook( "WillowGame.DualWieldActionSkill.OnActionSkillEnded", self.Name) unrealsdk.RemoveHook( "WillowGame.DualWieldActionSkill.EquipInitialWeapons", self.Name) unrealsdk.RemoveHook("WillowGame.WillowInventoryManager.NextWeapon", self.Name) unrealsdk.RemoveHook("WillowGame.WillowInventoryManager.PrevWeapon", self.Name) unrealsdk.RemoveHook("WillowGame.DualWieldActionSkill.SwitchToWeapon", self.Name) unrealsdk.RemoveHook( "WillowGame.DualWieldActionSkill.BringWeaponsUpAfterPutDown", self.Name) unrealsdk.RemoveHook( "WillowGame.Behavior_RefillWeapon.ApplyBehaviorToContext", self.Name) unrealsdk.RemoveHook("WillowGame.WillowPawn.TossInventory", self.Name) unrealsdk.RemoveHook("WillowGame.WillowPlayerPawn.EndClimbLadder", self.Name) unrealsdk.RemoveHook("Engine.Weapon.ClientGivenTo", self.Name) if self.NumWeapObj is not None: self.NumWeapObj.NumberOfWeapons = 2 # Let it unload again self.NumWeapObj.ObjectFlags.A &= ~0x4000 self.NumWeapObj = None
def Disable(self): unrealsdk.RemoveHook("WillowGame.WillowDialogAct_Talk.Activate", f"{__file__}Talk") unrealsdk.RemoveHook( "GearboxFramework.Behavior_TriggerDialogEvent.ApplyBehaviorToContext", f"{__file__}Event") unrealsdk.RemoveHook("WillowGame.WillowHUD.CreateWeaponScopeMovie", f"{__file__}TalkMapLoaded")
def Disable(self) -> None: unrealsdk.RemoveHook("Engine.Inventory.GiveTo", self.Name) unrealsdk.RemoveHook("Engine.WillowInventory.CanBeUsedBy", self.Name) unrealsdk.RemoveHook("WillowGame.ItemCardGFxObject.SetItemCardEx", self.Name) unrealsdk.RemoveHook( "WillowGame.WillowInventoryManager.InventoryShouldBeReadiedWhenEquipped", self.Name)
def Disable(self): unrealsdk.RemoveHook("WillowGame.WillowSaveGameManager.SaveGame", "SaveGame_HookBSABT") unrealsdk.RemoveHook( "WillowGame.WillowPlayerController.ShouldLoadSaveGameOnSpawn", "OnSpawn_HookBSABT") unrealsdk.RemoveHook( "WillowGame.WillowPlayerController.ClientSetPawnLocation", "Spawn_HookBSABT")
def Disable(self) -> None: try: os.remove(self.ENABLED_FILE) except FileNotFoundError: pass unrealsdk.RemoveHook("WillowGame.FrontendGFxMovie.ShowMOTD", "AdBlock") unrealsdk.RemoveHook( "WillowGame.WillowPlayerController.CanAcessOakUpsell", "AdBlock")
def Disable(self) -> None: unrealsdk.RemoveHook("WillowGame.TextChatGFxMovie.AddChatMessage", self.Name) unrealsdk.RemoveHook( "WillowGame.WillowGFxDialogBox.DisplayOkBoxTextFromSpark", self.Name) unrealsdk.RemoveHook( "WillowGame.WillowGFxMoviePressStart.DoSparkAuthentication", self.Name)
def Disable(self) -> None: AsyncUtil.CancelFutureCallbacks(self.Name) unrealsdk.RemoveHook( "WillowGame.WillowInteractiveObject.ConditionalReactToUse", self.Name) unrealsdk.RemoveHook( "WillowGame.WillowInteractiveObject.InitializeFromDefinition", self.Name) unrealsdk.RemoveHook("WillowGame.WillowInteractiveObject.Touch", self.Name) unrealsdk.RemoveHook("WillowGame.WillowInteractiveObject.UnTouch", self.Name)
def AddChatMessageInternal(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: # Oddly enough it tries to call this on the object for the actual chatbox, not our own # one, so we have to block it on all objects - likely won't matter but worth noting. unrealsdk.RemoveHook( "WillowGame.TextChatGFxMovie.AddChatMessageInternal", "ChatBoxInput") unrealsdk.RemoveHook( "WillowGame.TextChatGFxMovie.HandleTextChatInput", "ChatBoxInput") self.OnSubmit(params.msg) return False
def Cancelled(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: if caller == self._OptionBox: unrealsdk.RemoveHook("WillowGame.WillowGFxDialogBox.Accepted", "CustomOptionBox") unrealsdk.RemoveHook("WillowGame.WillowGFxDialogBox.Cancelled", "CustomOptionBox") unrealsdk.RemoveHook( "WillowGame.WillowGFxDialogBox.HandleInputKey", "CustomOptionBox") self._OptionBox = None self.OnCancel() return True
def HandleTextChatInput(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: if caller == self._Chat: self.OnInput(params.ukey, params.uevent) if params.ukey == "Escape": unrealsdk.RemoveHook( "WillowGame.TextChatGFxMovie.AddChatMessageInternal", "ChatBoxInput") unrealsdk.RemoveHook( "WillowGame.TextChatGFxMovie.HandleTextChatInput", "ChatBoxInput") self.OnSubmit("") return True
def Disable(self) -> None: unrealsdk.RemoveHook( "GearboxFramework.PopulationMaster.SpawnPopulationControlledActor", self.Name) unrealsdk.RemoveHook( "WillowGame.PopulationOpportunityDen.PostBeginPlay", self.Name) for den in unrealsdk.FindAll("PopulationOpportunityDen"): self.MultiplyDenIfAble(den, 1 / self.MultiplierSlider.CurrentValue) # Being careful incase our reference has been GCed if unrealsdk.FindAll( "WillowPopulationMaster")[-1] == self.CurrentPopMaster: self.CurrentPopMaster.MaxActorCost = self.OriginalLimit
def Disable(self) -> None: try: os.remove(self.ENABLED_FILE) except FileNotFoundError: pass unrealsdk.RemoveHook("WillowGame.WillowGFxMoviePressStart.DoSparkAuthentication", "FixHotfixes")
def OnMainMenu(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: self.Execute(self.MainMenuTasks) unrealsdk.RemoveHook("WillowGame.FrontendGFxMovie.Start", self.Name) return True
def _TopLevelOptionsPopulate(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: """ This function is called to create the options menu. We use it to inject our `MODS` menu. """ # If not mods have accessable options, we want to disable the mods entry disabled = True for mod in ModObjects.Mods: if not mod.IsEnabled: continue if _is_anything_shown(mod.Options): disabled = False break def AddListItem(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: """ This function is called every time an item is added to *any* menu list - we obviously can't use a generic hook. Using it cause it simplifies the code to add our own entry. """ if params.Caption == "$WillowGame.WillowScrollingList.BackCaption": caller.AddListItem(_MOD_OPTIONS_EVENT_ID, _MOD_OPTIONS_MENU_NAME, disabled, False) return True unrealsdk.RunHook("WillowGame.WillowScrollingList.AddListItem", "ModMenu.OptionManager", AddListItem) unrealsdk.DoInjectedCallNext() caller.Populate(params.TheList) unrealsdk.RemoveHook("WillowGame.WillowScrollingList.AddListItem", "ModMenu.OptionManager") return False
def _on_main_menu(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: unrealsdk.RegisterMod(_OptionsWrapper()) unrealsdk.RemoveHook("WillowGame.FrontendGFxMovie.Start", "OptionsWrapper") return True
def _FrontEndPopulate(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: """ This function is called to create the front end menu. We use it to replace the DLC caption and event id. """ def AddListItem(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: """ This function is called every time an item is added to *any* menu list - we obviously can't use a generic hook. Using it cause it simplifies the code to replace the caption. """ if params.Caption == "$WillowMenu.WillowScrollingListDataProviderFrontEnd.DLC": unrealsdk.DoInjectedCallNext() caller.AddListItem(_MODS_EVENT_ID, _MODS_MENU_NAME, False, False) return False return True unrealsdk.RunHook("WillowGame.WillowScrollingList.AddListItem", "ModMenu.MenuManager", AddListItem) unrealsdk.DoInjectedCallNext() caller.Populate(params.TheList) unrealsdk.RemoveHook("WillowGame.WillowScrollingList.AddListItem", "ModMenu.MenuManager") return False
def Disable(self) -> None: try: os.remove(self.ENABLED_FILE) except FileNotFoundError: pass unrealsdk.RemoveHook("WillowGame.WillowGFxDialogBox.DisplayOkBoxTextFromSpark", "NoOfflineWarning")
def HandleVerificationReceived(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: base = unrealsdk.FindAll("SparkServiceConfiguration")[-1] for i in range(self.DUMMY_AMOUNT): obj = unrealsdk.ConstructObject(Class=base.Class, Outer=base.Outer) obj.ServiceName = "Dummy" unrealsdk.RemoveHook("GearboxFramework.SparkInitializationProcess.HandleVerificationReceived", "FixHotfixes") return True
def HandleVerificationReceived(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: PC = unrealsdk.GetEngine().GamePlayers[0].Actor for i in range(self.DUMMY_AMOUNT): obj = unrealsdk.ConstructObject(unrealsdk.FindClass("SparkServiceConfiguration")) PC.ServerRCon(f"set {PC.PathName(obj)} ServiceName Dummy_{i}") unrealsdk.RemoveHook("GearboxFramework.SparkInitializationProcess.HandleVerificationReceived", "FixHotfixes") return True
def ApplyWeaponSaveGameData(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: """ We need to call `FixupSavedWeapons` at the start here, but it uses an out argument. If we block `ValidateWeaponDefinition` and `IsLocalPlayerController`, so they return false, this function will do nothing except make that call for us """ unrealsdk.RunHook( "WillowGame.WillowPlayerController.IsLocalPlayerController", __name__, Block) unrealsdk.RunHook( "WillowGame.WillowPlayerController.ValidateWeaponDefinition", __name__, Block) caller.ApplyWeaponSaveGameData(params.SaveGame) unrealsdk.RemoveHook( "WillowGame.WillowPlayerController.IsLocalPlayerController", __name__) unrealsdk.RemoveHook( "WillowGame.WillowPlayerController.ValidateWeaponDefinition", __name__) # Now we can recreate the call like normal inv_manager = caller.GetPawnInventoryManager() is_local = caller.IsLocalPlayerController() for idx, saved_weap in enumerate(params.SaveGame.WeaponData): if saved_weap.QuickSlot != 0: if caller.Role == 3: # ROLE_Authority ServerSetWeaponSaveGameData(caller, idx, saved_weap.WeaponDefinitionData, saved_weap.QuickSlot, saved_weap.Mark) continue if is_local: inv_manager.ClientAddWeaponToBackpack( expand_weapon_definition_data(saved_weap.WeaponDefinitionData), saved_weap.Mark, False, 14) if is_local: caller.UnloadableDlcWeaponData = list( params.SaveGame.UnloadableDlcWeaponData) caller.ServerItemSaveGameDataCompleted() return False
def OnEnd(self) -> None: ShowChatMessage("Crowd Control:", f"{self.Name} wore off.", ShowTimestamp=False) unrealsdk.RemoveHook("WillowGame.WillowHUDGFxMovie.Start", "CCHideHUD") # Seems the hook sticks around a tick or something, this doesn't work unless I delay it AsyncUtil.RunIn(0.05, unrealsdk.GetEngine().GamePlayers[0].Actor.DisplayHUD)
def thread_tick(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: if self.loader_threads and all(not x.is_alive() for x in self.loader_threads): self.loader_threads.clear() unrealsdk.RemoveHook( "WillowGame.WillowGameViewportClient.Tick", __file__) return True
def IsShowing(self) -> bool: """ Gets if the chat box is currently being displayed. Returns: True if the chat box is currently being displayed, False otherwise. """ if self._IsChatGCed() and self._WasChatOpened: self._WasChatOpened = False # If we thought chat was open then we likely still have hooks lying around unrealsdk.RemoveHook( "WillowGame.TextChatGFxMovie.AddChatMessageInternal", "ChatBoxInput") unrealsdk.RemoveHook( "WillowGame.TextChatGFxMovie.HandleTextChatInput", "ChatBoxInput") return self._WasChatOpened
def Disable(self) -> None: AsyncUtil.CancelFutureCallbacks("CrowdControl") unrealsdk.RemoveHook("WillowGame.FrontendGFxMovie.ConfirmQuit_Clicked", "CrowdControl") if self._listener is not None: self._listener.kill() self._listener = None for callback in Effects.ON_DISABLE: callback()
def Disable(self) -> None: AsyncUtil.CancelFutureCallbacks(self.Name) unrealsdk.RemoveHook("WillowGame.WillowInteractiveObject.ConditionalReactToUse", self.Name) unrealsdk.RemoveHook("WillowGame.WillowInteractiveObject.InitializeFromDefinition", self.Name) unrealsdk.RemoveHook("WillowGame.WillowInteractiveObject.Touch", self.Name) unrealsdk.RemoveHook("WillowGame.WillowInteractiveObject.UnTouch", self.Name) unrealsdk.RemoveHook("WillowGame.WillowPlayerController.WillowClientDisableLoadingMovie", self.Name) unrealsdk.RemoveHook("WillowGame.WillowVendingMachine.GenerateInventory", self.Name) unrealsdk.RemoveHook("WillowGame.WillowPlayerController.PayForUsedObject", self.Name)
def _GameSessionEnded(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: global _message_queue # If there are no queued messages, we have nothing to do. if len(_message_queue) == 0: return True # Cease observing message timeouts and empty the message queue. unrealsdk.RemoveHook("Engine.PlayerController.PlayerTick", "ModMenu.NetworkManager") _message_queue = deque() return True
def _dequeue_message() -> None: """ Remove the frontmost message from the message queue, sending the following one, if any. """ _message_queue.popleft() # If the queue is not empty, send the now-frontmost message. if len(_message_queue) > 0: _message_queue[0].send() # If this was the last message in the queue, we may cease observing message timeouts. else: unrealsdk.RemoveHook("Engine.PlayerController.PlayerTick", "ModMenu.NetworkManager")
def Hide(self) -> None: """ Hides the chat box, without running any callbacks. Displays a warning but does nothing if the chat box is not currently being displayed. """ if not self.IsShowing(): unrealsdk.Log( "[UserFeedback] Warning: tried to hide a chat box that was already closed" ) return unrealsdk.RemoveHook( "WillowGame.TextChatGFxMovie.AddChatMessageInternal", "ChatBoxInput") unrealsdk.RemoveHook("WillowGame.TextChatGFxMovie.HandleTextChatInput", "ChatBoxInput") self._Chat.StopTextChatInternal() self._Chat.Close()