Esempio n. 1
0
    def Enable(self) -> None:
        def BlockCall(caller: unrealsdk.UObject, function: unrealsdk.UFunction,
                      params: unrealsdk.FStruct) -> bool:
            return False

        unrealsdk.RegisterHook("WillowGame.FrontendGFxMovie.ShowMOTD",
                               self.Name, BlockCall)
        unrealsdk.RegisterHook(
            "WillowGame.WillowPlayerController.CanAcessOakUpsell", self.Name,
            BlockCall)
Esempio n. 2
0
    def Enable(self) -> None:
        def end_load(caller: unrealsdk.UObject, function: unrealsdk.UFunction,
                     params: unrealsdk.FStruct) -> bool:
            unrealsdk.RegisterHook("WillowGame.WillowGameViewportClient.Tick",
                                   __file__, thread_tick)

            level_name: str = bl2tools.get_world_info(
            ).GetStreamingPersistentMapName().lower()
            for op in self.Options:  # type: OptionManager.Options.Spinner
                # Check if map gets modified using its description we earlier set
                if op.CurrentValue == "Enabled" and level_name in op.Description:
                    if self.loading_option.CurrentValue == "Enabled":
                        t = threading.Thread(target=self.load_map,
                                             args=(op.Caption, level_name))
                        self.loader_threads.append(t)
                        t.start()
                    else:
                        self.load_map(op.Caption, level_name)
            return True

        def start_load(caller: unrealsdk.UObject,
                       function: unrealsdk.UFunction,
                       params: unrealsdk.FStruct) -> bool:
            if params.MovieName is None:
                return True
            if self.loader_threads:
                for t in self.loader_threads:
                    t.join()
                self.loader_threads.clear()
                unrealsdk.RemoveHook(
                    "WillowGame.WillowGameViewportClient.Tick", __file__)
            return True

        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

        unrealsdk.RegisterHook(
            "WillowGame.WillowPlayerController.WillowClientDisableLoadingMovie",
            __file__, end_load)
        unrealsdk.RegisterHook(
            "WillowGame.WillowPlayerController.WillowClientShowLoadingMovie",
            __file__, start_load)
Esempio n. 3
0
    def Enable(self) -> None:
        def DisplayRecentDamageForPlayer(caller: unrealsdk.UObject,
                                         function: unrealsdk.UFunction,
                                         params: unrealsdk.FStruct) -> bool:
            PC = unrealsdk.GetEngine().GamePlayers[0].Actor
            if params.PC != PC:
                return True

            damage = params.DamageEventData.TotalDamageForDamageType
            if damage < 10**self.MinDamageSlider.CurrentValue:
                return True

            actor = params.DamageEventData.DamagedActor

            name = actor.PathName(actor)
            if actor.AIClass is not None and actor.AIClass.DefaultDisplayName is not None:
                name = actor.AIClass.DefaultDisplayName

            if actor.BalanceDefinitionState.BalanceDefinition is not None:
                ptNum = PC.GetCurrentPlaythrough() + 1
                for pt in actor.BalanceDefinitionState.BalanceDefinition.PlayThroughs:
                    if pt.PlayThrough > ptNum:
                        continue
                    if pt.DisplayName is None or len(pt.DisplayName) == 0:
                        continue
                    name = pt.DisplayName

            unrealsdk.Log(
                f"Dealt {damage} damage to level {actor.GetExpLevel()} {name}")

            return True

        unrealsdk.RegisterHook(
            "WillowGame.WillowDamageTypeDefinition.DisplayRecentDamageForPlayer",
            "TrueDamageLogger", DisplayRecentDamageForPlayer)
Esempio n. 4
0
    def Show(self) -> None:
        """ Displays the training box. """
        self._TrainingBox = unrealsdk.GetEngine().GamePlayers[0].Actor.GFxUIManager.ShowTrainingDialog(
            self.Message,
            self.Title,
            self.MinDuration,
            self.MenuHint,
            not self.PausesGame
        )
        self._TrainingBox.SetPriority(self.Priority)
        self._TrainingBox.ApplyLayout()

        def HandleInputKey(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool:
            if caller == self._TrainingBox:
                self.OnInput(params.ukey, params.uevent)

                # We don't have a good function to hook for when this exits so we have to decode it
                #  from the key presses
                if self._TrainingBox is not None and self._TrainingBox.DelayUntilShowOk < 0 and params.uevent == 1:
                    use_key = "FAKE"
                    if caller.GetPC().PlayerInput is not None:
                        use_key = caller.GetPC().PlayerInput.GetKeyForAction("Use", True)
                    if params.ukey in self._ExitKeys or params.ukey == use_key:
                        unrealsdk.RemoveHook("WillowGame.WillowGFxTrainingDialogBox.HandleInputKey", "CustomTrainingBox")
                        self._TrainingBox = None
                        self.OnExit()
            return True

        unrealsdk.RegisterHook("WillowGame.WillowGFxTrainingDialogBox.HandleInputKey", "CustomTrainingBox", HandleInputKey)
Esempio n. 5
0
    def Enable(self) -> None:
        def CreateWeaponScopeMovie(caller: unrealsdk.UObject,
                                   function: unrealsdk.UFunction,
                                   params: unrealsdk.FStruct) -> bool:
            for clas, handler in self.CLASS_HANDLER_MAP.items():
                for obj in unrealsdk.FindAll(clas):
                    if obj not in self.MenuObjects:
                        handler(obj)
            return True

        unrealsdk.RegisterHook("WillowGame.WillowHUD.CreateWeaponScopeMovie",
                               "ItemLevelUncapper", CreateWeaponScopeMovie)

        # If you're re-enabling then we can exit right here, the rest of this is non-reversible
        if len(self.MenuObjects) > 0:
            return

        # Objects we load here will still be alive for all the FindAll commands, we don't need to
        #  parse them yet
        for package, objects in self.FORCE_LOAD.items():
            unrealsdk.LoadPackage(package)
            for obj in objects:
                unrealsdk.KeepAlive(unrealsdk.FindObject(obj[0], obj[1]))

        # Do our inital parse over everything, saving what we can access
        for clas, handler in self.CLASS_HANDLER_MAP.items():
            for obj in unrealsdk.FindAll(clas):
                self.MenuObjects.add(obj)
                handler(obj)
Esempio n. 6
0
    def Enable(self) -> None:
        def WillowClientDisableLoadingMovie(caller: unrealsdk.UObject,
                                            function: unrealsdk.UFunction,
                                            params: unrealsdk.FStruct) -> bool:
            for clas, handler in self.CLASS_HANDLER_MAP.items():
                for obj in unrealsdk.FindAll(clas):
                    if obj not in self.MenuObjects:
                        handler(obj)
            return True

        unrealsdk.RegisterHook(
            "WillowGame.WillowPlayerController.WillowClientDisableLoadingMovie",
            self.Name, WillowClientDisableLoadingMovie)

        # If you're re-enabling then we can exit right here, the rest of this is non-reversible
        if len(self.MenuObjects) > 0:
            return

        # Objects we load here will still be alive for all the FindAll commands, we don't need to
        #  parse them yet
        for package, objects in self.FORCE_LOAD.items():
            unrealsdk.LoadPackage(package)
            for obj_name in objects:
                obj = unrealsdk.FindObject(obj_name[0], obj_name[1])
                if obj is None:
                    unrealsdk.Log(
                        f"[{self.Name}] Unable to find object '{obj_name[1]}'")

                unrealsdk.KeepAlive(obj)

        # Do our inital parse over everything, saving what we can access
        for clas, handler in self.CLASS_HANDLER_MAP.items():
            for obj in unrealsdk.FindAll(clas):
                self.MenuObjects.add(obj)
                handler(obj)
Esempio n. 7
0
    def Enable(self):
        def Teleport(caller: unrealsdk.UObject, function: unrealsdk.UFunction,
                     params: unrealsdk.FStruct) -> bool:
            return self.get_location(caller, function, params)

        unrealsdk.RegisterHook(
            "WillowGame.StatusMenuMapGFxObject.PlaceCustomObjective",
            "MarkerHook", Teleport)
Esempio n. 8
0
    def Show(self) -> None:
        """ Displays the chat box. """
        if self._IsChatGCed():
            self._Chat = unrealsdk.GetEngine(
            ).GamePlayers[0].Actor.GFxUIManager.PlayMovie(_ChatDef)

        self._Chat.SetPriority(self.Priority)
        self._Chat.StartTextChat()
        self._WasChatOpened = True

        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 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

        unrealsdk.RegisterHook(
            "WillowGame.TextChatGFxMovie.AddChatMessageInternal",
            "ChatBoxInput", AddChatMessageInternal)
        unrealsdk.RegisterHook(
            "WillowGame.TextChatGFxMovie.HandleTextChatInput", "ChatBoxInput",
            HandleTextChatInput)
Esempio n. 9
0
    def Enable(self) -> None:
        if self.Token is None:
            return

        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= STARTF_USESHOWWINDOW
        startupinfo.wShowWindow = SW_SHOWMINNOACTIVE

        self._listener = subprocess.Popen(
            ["python", "-m", "Listener", self.Token],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            cwd=self.BASE_PATH,
            startupinfo=startupinfo)

        def OnTick() -> None:
            if self._listener is None:
                return
            if self._listener.poll() is not None:
                # Since the lister has quit we can safely call read without blocking
                # Only do this on stderr though cause that's where exceptions go
                if self._listener.stderr is not None:
                    line = self._listener.stderr.read()
                    if len(line) > 0:
                        self.HandleStderr(
                            line.decode("utf8").replace("\\n", "\n")[:-2])
                self.HandleChildQuit()
                return

            if self._listener.stdout is not None and GetPipeAvailableLen(
                    self._listener.stdout) > 0:
                line = self._listener.stdout.readline()
                self.HandleStdout(
                    line.decode("utf8").replace("\\n", "\n")[:-2])

            if self._listener.stderr is not None and GetPipeAvailableLen(
                    self._listener.stderr) > 0:
                line = self._listener.stderr.readline()
                self.HandleStderr(
                    line.decode("utf8").replace("\\n", "\n")[:-2])

        def OnQuit(caller: unrealsdk.UObject, function: unrealsdk.UFunction,
                   params: unrealsdk.FStruct) -> bool:
            if self._listener is not None:
                self._listener.kill()

            return True

        AsyncUtil.RunEveryTick(OnTick, self.Name)

        # TODO: better quit hook
        unrealsdk.RegisterHook(
            "WillowGame.FrontendGFxMovie.ConfirmQuit_Clicked", self.Name,
            OnQuit)

        for callback in Effects.ON_ENABLE:
            callback()
Esempio n. 10
0
    def Enable(self):
        def DoSlide(caller: unrealsdk.UObject, function: unrealsdk.UFunction,
                    params: unrealsdk.FStruct) -> bool:
            # self.handle_duck(caller, function, params)
            return True

        def AdvancedMove(caller: unrealsdk.UObject,
                         function: unrealsdk.UFunction,
                         params: unrealsdk.FStruct) -> bool:
            # self.handle_move(caller, function, params)
            Log("Ayy")

            return True

        unrealsdk.RegisterHook("WillowGame.WillowPlayerInput.DuckPressed",
                               "SlideHook", DoSlide)
        unrealsdk.RegisterHook("Engine.PlayerController.PCServerMoveInner",
                               "MoveHook", AdvancedMove)
Esempio n. 11
0
    def Enable(self):
        def EndLoad(caller: UObject, function: UFunction,
                    params: FStruct) -> bool:
            self.calc_driver_cam()
            return True

        unrealsdk.RegisterHook(
            "WillowGame.VehicleSpawnStationTerminal.UnlockForOtherUsers",
            "LoadCar", EndLoad)
Esempio n. 12
0
    def Enable(self) -> None:
        def DisplayOkBoxTextFromSpark(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool:
            if params.Section == "dlgCouldNotConnectSHiFT":
                caller.Close()
                return False
            return True

        unrealsdk.RegisterHook("WillowGame.WillowGFxDialogBox.DisplayOkBoxTextFromSpark", "NoOfflineWarning", DisplayOkBoxTextFromSpark)

        open(self.ENABLED_FILE, "a").close()
Esempio n. 13
0
    def Enable(self) -> None:
        def DoSparkAuthentication(caller: unrealsdk.UObject,
                                  function: unrealsdk.UFunction,
                                  params: unrealsdk.FStruct) -> bool:
            caller.ShouldStartSparkInitialization = False
            return True

        unrealsdk.RegisterHook(
            "WillowGame.WillowGFxMoviePressStart.DoSparkAuthentication",
            self.Name, DoSparkAuthentication)
Esempio n. 14
0
    def Enable(self) -> None:
        def PostBeginPlay(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool:
            unrealsdk.DoInjectedCallNext()
            caller.PostBeginPlay()

            caller.bShowUndiscoveredMissions = False
            return False

        unrealsdk.RegisterHook("WillowGame.WillowPlayerController.PostBeginPlay", self.Name, PostBeginPlay)
        unrealsdk.GetEngine().GamePlayers[0].Actor.bShowUndiscoveredMissions = False
Esempio n. 15
0
    def Enable(self) -> None:
        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

        unrealsdk.RegisterHook("GearboxFramework.SparkInitializationProcess.HandleVerificationReceived", "FixHotfixes", HandleVerificationReceived)
Esempio n. 16
0
    def Enable(self):
        def EndLoad(caller: UObject, function: UFunction,
                    params: FStruct) -> bool:
            for _, obj in self.call_order:
                func = getattr(obj, "on_end_load")
                func()
            return True

        unrealsdk.RegisterHook(
            "WillowGame.WillowPlayerController.WillowClientDisableLoadingMovie",
            "EndLoading", EndLoad)
Esempio n. 17
0
    def Enable(self):
        def Loot(caller: UObject, function: UFunction,
                 params: FStruct) -> bool:
            for _ in range(self.multiplier):
                unrealsdk.DoInjectedCallNext()
                caller.DropLootOnDeath(params.Killer, params.DamageType,
                                       params.DamageTypeDefinition)
            return True

        unrealsdk.RegisterHook("WillowGame.WillowPawn.DropLootOnDeath",
                               "LootHook", Loot)
Esempio n. 18
0
    def Enable(self) -> None:
        self.call_order_end_load.sort()
        self.call_order_start_load.sort()

        def EndLoad(caller: unrealsdk.UObject, function: unrealsdk.UFunction,
                    params: unrealsdk.FStruct) -> bool:
            curr_map = unrealsdk.GetEngine().GetCurrentWorldInfo(
            ).GetStreamingPersistentMapName().lower()
            logging.logger.debug(f"Loaded map: {curr_map}")
            for _, func in self.call_order_end_load:
                try:
                    func(curr_map)
                except Exception as e:
                    logging.logger.error(repr(e))
                    logging.logger.error(
                        f"Something went wrong on ClientDisableLoadingMovie in {func}!"
                    )
            return True

        def StartLoading(caller: unrealsdk.UObject,
                         function: unrealsdk.UFunction,
                         params: unrealsdk.FStruct) -> bool:
            if params.MovieName is None:
                return True
            logging.logger.debug(f"Loading map: {params.MovieName}")
            for _, func in self.call_order_start_load:
                try:
                    func(params.MovieName)
                except Exception as e:
                    logging.logger.error(repr(e))
                    logging.logger.error(
                        f"Something went wrong on ClientShowLoadingMovie in {func}!"
                    )
            return True

        unrealsdk.RegisterHook(
            "WillowGame.WillowPlayerController.WillowClientDisableLoadingMovie",
            "hkManagerEndLoading", EndLoad)
        unrealsdk.RegisterHook(
            "WillowGame.WillowPlayerController.WillowClientShowLoadingMovie",
            "hkManagerStartLoading", StartLoading)
Esempio n. 19
0
    def Enable(self) -> None:
        def DoSparkAuthentication(caller: unrealsdk.UObject,
                                  function: unrealsdk.UFunction,
                                  params: unrealsdk.FStruct) -> bool:
            caller.ShouldStartSparkInitialization = False
            return True

        unrealsdk.RegisterHook(
            "WillowGame.WillowGFxMoviePressStart.DoSparkAuthentication",
            "AlwaysOffline", DoSparkAuthentication)

        open(self.ENABLED_FILE, "a").close()
Esempio n. 20
0
    def Enable(self) -> None:
        hookmanager.instance.register_end_load(self.on_end_load, 5)

        for file in self.files:
            with open(file, "r") as File:
                for line in File:
                    if line.split() and line.split()[0].lower() == "set":
                        self.need_mat_inst_const.append(
                            line.split()[1].strip())
        self.need_mat_inst_const = list(
            unrealsdk.FindObject("Object", x)
            for x in set(self.need_mat_inst_const))
        self.need_mat_inst_const = [
            x for x in self.need_mat_inst_const if x is not None
        ]

        def command(caller: unrealsdk.UObject, function: unrealsdk.UFunction,
                    params: unrealsdk.FStruct) -> bool:
            x = params.Command.split()[0].strip().lower()
            if x == "update":
                self.get_free_mat_inst_consts(True)
                return False

            elif x == "exec_skin" and not self.is_game_bl2:
                # we need to read the file and find all MatInstConsts in case we are playing TPS
                binaries = self.PATH
                while os.path.basename(binaries).lower() != "binaries":
                    binaries = os.path.abspath(os.path.join(binaries, ".."))
                exec_file = os.path.join(
                    binaries,
                    params.Command.split()[1].lstrip("/").lstrip(
                        "\\"))  # this is case-sensitive
                if not os.path.isfile(exec_file):  # we could not find the file
                    return True
                with open(exec_file) as fp:
                    for l in fp:
                        if l.lower().startswith(
                                "set") and unrealsdk.FindObject(
                                    "MaterialInstanceConstant",
                                    l.split()[1]) is not None:
                            try:
                                Materials.exec_skins(l, self.is_game_bl2)
                            except Exception as e:
                                logging.logger.error(e)
                                logging.logger.error(f"Error in: {l}")
                # we need to return false because f**k TPS.
                # If the game handles the exec it will sometimes not apply skins for whatever reason
                return False
                # we still want to return to the original function
            return True

        unrealsdk.RegisterHook("Engine.PlayerController.ConsoleCommand",
                               "ConsoleCommand", command)
Esempio n. 21
0
    def Enable(self):
        def SaveGame_Hook(caller: UObject, function: UFunction,
                          params: FStruct) -> bool:

            if GetEngine().GetCurrentWorldInfo().GetStreamingPersistentMapName(
            ) != "menumap" and not self.b_load:
                self.filename = params.Filename
                self.save_spawn_station(GetEngine().GetCurrentWorldInfo().GRI.
                                        ActiveRespawnCheckpointTeleportActor)
            return True

        def LoadSave(caller: UObject, function: UFunction,
                     params: FStruct) -> bool:
            if params.bIsInitialSpawn or params.bIsClassChange:
                self.b_load = True
                self.set_location_counter = 0
                pc = bl2tools.get_player_controller()
                self.filename = pc.GetSaveGameNameFromid(
                    pc.GetCachedSaveGame().SaveGameId)
            return True

        def Spawn_Hook(caller: UObject, function: UFunction,
                       params: FStruct) -> bool:
            self.set_location_counter += 1
            # On the 3rd time calling this function the pawn actually gets placed in the map itself
            # I couldn't find any better function, it seems this is the easiest implementation
            if self.b_load and self.set_location_counter == 3:
                self.b_load = False
                self.set_spawn_location(bl2tools.get_player_controller().Pawn)
                return False
            return True

        unrealsdk.RegisterHook("WillowGame.WillowSaveGameManager.SaveGame",
                               "SaveGame_HookBSABT", SaveGame_Hook)
        unrealsdk.RegisterHook(
            "WillowGame.WillowPlayerController.ShouldLoadSaveGameOnSpawn",
            "LoadSaveBSABT", LoadSave)
        unrealsdk.RegisterHook(
            "WillowGame.WillowPlayerController.ClientSetPawnLocation",
            "Spawn_HookBSABT", Spawn_Hook)
Esempio n. 22
0
    def Enable(self):
        self.load_files()

        def StartLoading(caller: UObject, function: UFunction, params: FStruct) -> bool:
            if params.MovieName != "None":
                emitterpool = GetEngine().GetCurrentWorldInfo().MyEmitterPool
                for component in self.components_to_destroy:
                    emitterpool.ReturnToPool(component)
                self.components_to_destroy.clear()
            return True

        unrealsdk.RegisterHook("WillowGame.WillowPlayerController.WillowClientShowLoadingMovie", "StartLoading",
                               StartLoading)
Esempio n. 23
0
    def Enable(self) -> None:
        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

        unrealsdk.RegisterHook("GearboxFramework.SparkInitializationProcess.HandleVerificationReceived", "FixHotfixes", HandleVerificationReceived)

        open(self.ENABLED_FILE, "a").close()
Esempio n. 24
0
    def Enable(self):
        def map_loaded(caller: unrealsdk.UObject,
                       function: unrealsdk.UFunction,
                       params: unrealsdk.FStruct) -> bool:
            pc = unrealsdk.GetEngine().GamePlayers[0].Actor
            if pc and pc.Pawn:
                self.ak_events = [
                    ak for ak in unrealsdk.FindAll("AkEvent")[1:] if ak.bVoice
                ]
            return True

        def talk(caller: unrealsdk.UObject, function: unrealsdk.UFunction,
                 params: unrealsdk.FStruct) -> bool:
            for talk_event in caller.TalkData:
                talk_event.TalkAkEvent = random.choice(self.ak_events)

            return True

        def event(caller: unrealsdk.UObject, function: unrealsdk.UFunction,
                  params: unrealsdk.FStruct) -> bool:
            if caller.Group:
                for acts in caller.Group.TalkActs:
                    try:
                        for data in acts.TalkData:
                            data.TalkAkEvent = random.choice(self.ak_events)
                    except:
                        pass
            return True

        unrealsdk.RegisterHook("WillowGame.WillowDialogAct_Talk.Activate",
                               f"{__file__}Talk", talk)
        unrealsdk.RegisterHook(
            "GearboxFramework.Behavior_TriggerDialogEvent.ApplyBehaviorToContext",
            f"{__file__}Event", event)
        unrealsdk.RegisterHook("WillowGame.WillowHUD.CreateWeaponScopeMovie",
                               f"{__file__}TalkMapLoaded", map_loaded)
Esempio n. 25
0
    def Enable(self):
        def InjectSkills(caller: UObject, function: UFunction,
                         params: FStruct) -> bool:
            if not self.Seed:
                self.Seed = random.randrange(sys.maxsize)
                unrealsdk.Log("Randomizing with seed '{}'".format(self.Seed))
                self.RNG = random.Random(self.Seed)
                self.RecordSeed()
            else:
                self.RNG = random.Random(self.Seed)
            self.RandomizeTree(params.SkillTreeDef)
            return True

        unrealsdk.RegisterHook("WillowGame.PlayerSkillTree.Initialize",
                               "InjectSkills", InjectSkills)
Esempio n. 26
0
        def ConditionalReactToUse(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool:
            if caller.Class.Name != "WillowVendingMachine":
                return True
            if params.UsedType != 1:
                return True
            if params.User is None:
                return True

            PC = params.User.Controller
            PRI = PC.PlayerReplicationInfo

            wallet = PRI.GetCurrencyOnHand(0)
            cost = 0
            if caller.ShopType == 2:
                cost = self.GetHealthCost(params.User, caller)
            elif caller.ShopType == 1:
                cost = self.GetAmmoCost(params.User, caller)
            else:
                return True

            if cost == 0 or wallet < cost:
                PC.NotifyUnableToAffordUsableObject(1)
                return True

            # If you have updating costs on, block payment so we can do it manually
            # This ensures that it always costs the right amount, even if it's displaying wrong
            #  (e.g. if in coop a different player is closer to the vendor)
            if self.UpdatingOption.CurrentValue:
                vendor = caller

                def PayForUsedObject(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool:
                    if params.UsedObject.ObjectPointer == vendor and params.UsabilityType == 1:
                        unrealsdk.RemoveHook("WillowGame.WillowPlayerController.PayForUsedObject", self.Name)
                        return False
                    else:
                        return True

                unrealsdk.RegisterHook("WillowGame.WillowPlayerController.PayForUsedObject", self.Name, PayForUsedObject)

            PRI.AddCurrencyOnHand(0, -cost)
            PC.SetPendingTransactionStatus(1)

            if caller.ShopType == 2:
                self.BuyHealth(params.User, caller)
            elif caller.ShopType == 1:
                self.BuyAmmo(params.User, caller)

            return True
Esempio n. 27
0
    def Enable(self):
        for file in self.files:
            with open(file, "r") as File:
                for line in File:
                    if line.split() and line.split()[0].lower() == "set":
                        self.need_mat_inst_const.append(line.split()[1].strip())
        self.need_mat_inst_const = list(FindObject("Object", x) for x in set(self.need_mat_inst_const))
        self.need_mat_inst_const = [x for x in self.need_mat_inst_const if x is not None]

        def command(caller: UObject, function: UFunction, params: FStruct) -> bool:
            if params.Command.split()[0].strip().lower() == "update":
                self.get_free_mat_inst_consts(True)
                return False
            return True

        unrealsdk.RegisterHook("Engine.PlayerController.ConsoleCommand", "ConsoleCommand", command)
Esempio n. 28
0
    def Enable(self) -> None:
        if not self.ini_works:
            pc = bl2tools.get_player_controller()
            pc.GFxUIManager.ShowTrainingDialog(
                "Documents>My Games>Borderlands 2>WillowGame>Config>WillowEngine.ini Please Change "
                "bForceNoMovies=TRUE to bForceNoMovies=FALSE.\nIf you do not change it, Exodus won't work. Make sure "
                "to restart the game after making these changes.", "Note", 10)
            raise Exception(
                "Won't enable Exodus with bForceNoMovies .ini Tweak!")

        self.Constructor.Enable()
        self.HotfixMan.Enable()
        self.Pawns.Enable()
        self.Materials.Enable()
        self.Saves.Enable()
        self.Assignor.Enable()
        self.Spawner.Enable()
        hookmanager.instance.Enable()
        logging.logger.info(f"Everything setup and ready to play :)")
        if not self.config.getboolean("main", "has_seen_version_notes"):
            self.config.set("main", "has_seen_version_notes", "true")
            with open(os.path.join(self.FILE_PATH, "settings.ini"), "w") as f:
                self.config.write(f)
            self.show_version_notes()

        def init_spawn(caller: unrealsdk.UObject,
                       function: unrealsdk.UFunction,
                       params: unrealsdk.FStruct) -> bool:
            if self.initial_spawn:
                pc = bl2tools.get_player_controller()
                if pc is not None:
                    hud = pc.GetHUDMovie()
                    if hud is not None:
                        self.initial_spawn = False
                        hud.ClearTrainingText()
                        hud.AddTrainingText(
                            "Everything seems to be up and running.\nIf you encounter"
                            " any issues please report it to me on Discord."
                            "\n\nGood luck on the hunt, Vault Hunter!",
                            f"Constructor V.: {self.Version} Is Running",
                            8.000000, (), "", False, 0,
                            pc.PlayerReplicationInfo, True)
            return True

        unrealsdk.RegisterHook("WillowGame.WillowHUD.CreateWeaponScopeMovie",
                               "ConstructorRunningMsg", init_spawn)
Esempio n. 29
0
    def Enable(self) -> None:
        def SetTopStat(caller: unrealsdk.UObject,
                       function: unrealsdk.UFunction,
                       params: unrealsdk.FStruct) -> bool:
            if params.LabelText == "Fire Rate":
                newRate = f"{float(params.ValueText) * 60:.1f}"
                aux = "" if params.AuxText is None else params.AuxText

                unrealsdk.DoInjectedCallNext()
                caller.SetTopStat(params.StatIndex, params.LabelText, newRate,
                                  params.CompareArrow, aux, params.IconName)
                return False

            return True

        unrealsdk.RegisterHook("WillowGame.ItemCardGFxObject.SetTopStat",
                               "RoundsPerMinute", SetTopStat)
Esempio n. 30
0
    def Show(self) -> None:
        """ Displays the text input box. """
        self._Message = list(self.DefaultMessage)
        self._CursorPos = len(self._Message)
        self._IsShiftPressed = False

        self._TrainingBox = unrealsdk.GetEngine(
        ).GamePlayers[0].Actor.GFxUIManager.ShowTrainingDialog(
            self.DefaultMessage + "<u>  </u>", self.Title, 0, 0,
            not self.PausesGame)
        self._TrainingBox.SetPriority(self.Priority)
        self._TrainingBox.ApplyLayout()

        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

        unrealsdk.RegisterHook(
            "WillowGame.WillowGFxTrainingDialogBox.HandleInputKey",
            "CustomTextInputBox", HandleInputKey)