コード例 #1
0
ファイル: __init__.py プロジェクト: plu5/PythonSDK
class MapLoader(SDKMod):
    Name: str = "Borderlands 2 Map Reloader"
    Version: str = "1.1"
    Author: str = "FromDarkHell"
    Description: str = "Quickly farm items and save quit at a button press!\n\nLocation Restore: Whether to restore location on quickload"
    Types: ModTypes = ModTypes.Utility
    SaveEnabledState: EnabledSaveType = EnabledSaveType.LoadWithSettings

    Keybinds: List[ModMenu.Keybind] = [
        ModMenu.Keybind("Quickload w/o Saving", "F7"),
        ModMenu.Keybind("Quickload w/ Saving", "F8"),
        ModMenu.Keybind("Toggle Location Restore", "F10"),
        ModMenu.Keybind("Save Location", "F5"),
    ]

    def __init__(self):
        # It might be a good idea to restore our position after a load.
        self.restoreLocation = True
        self.loading = False
        self.consistentLocation = False
        self.toggledLocation = False
        # Store some data that we can use to reload the map
        self.SelectedDifficulty = 0
        self.OverpoweredLevel = 0
        self.Coords = [0, 0, 0]  # X, Y, Z
        self.Rotation = [0, 0, 0]  # Pitch, Roll, Yaw

    def GameInputPressed(self, input) -> None:
        name = input.Name
        if name == "Quickload w/o Saving":
            _ReloadCurrentMap(True)
        elif name == "Quickload w/ Saving":
            _ReloadCurrentMap(False)
        elif name == "Toggle Location Restore":
            self.restoreLocation = not self.restoreLocation
            state = "Location restoration is now {}".format(
                "enabled" if self.restoreLocation else "disabled")
            Log(f"[Map Loader] {state}")
            _DisplayFeedback(state)
        elif name == "Save Location":
            self.toggledLocation = True
            self.consistentLocation = not self.consistentLocation
            state = "Save Location is now {}".format(
                "enabled (Saves on quickload quit)" if self.
                consistentLocation else "disabled")
            Log(f"[Map Loader] {state}")
            _DisplayFeedback(state)

    def Enable(self) -> None:
        super().Enable()

    def Disable(self) -> None:
        ModMenu.RemoveHooks(self)
コード例 #2
0
class Commander(ModMenu.SDKMod):
    Name: str = "Commander"
    Version: str = "2.1"
    Description: str = "Perform various changes to the game using key bindings."
    Author: str = "mopioid"
    Types: ModTypes = ModTypes.Gameplay

    Options: List[ModMenu.Options.Base] = [
        _Positions, _DamageNumbers, _ClientTeleporting, _ClientSpeedPermissions
    ]
    SaveEnabledState: ModMenu.EnabledSaveType = ModMenu.EnabledSaveType.LoadWithSettings

    Keybinds: List[ModMenu.Keybind] = [
        ModMenu.Keybind( "Toggle Third Person",   "Equals",       OnPress=_ToggleThirdPerson   ),
        ModMenu.Keybind( "Halve Game Speed",      "LeftBracket",  OnPress=_HalveGameSpeed      ),
        ModMenu.Keybind( "Double Game Speed",     "RightBracket", OnPress=_DoubleGameSpeed     ),
        ModMenu.Keybind( "Reset Game Speed",      "None",         OnPress=_ResetGameSpeed      ),
        ModMenu.Keybind( "Toggle World Freeze",   "Backslash",    OnPress=_TogglePlayersOnly   ),
        ModMenu.Keybind( "Toggle HUD",            "Semicolon",    OnPress=_ToggleHUD           ),
        ModMenu.Keybind( "Toggle Damage Numbers", "Quote",        OnPress=_ToggleDamageNumbers ),
        ModMenu.Keybind( "Save Position",         "Period",       OnPress=_SavePosition        ),
        ModMenu.Keybind( "Restore Position",      "Comma",        OnPress=_RestorePosition     ),
        ModMenu.Keybind( "Select Position",       "Slash",        OnPress=_SelectPosition      ),
        ModMenu.Keybind( "Teleport Forward",      "Up",           OnPress=_MoveForward         ),
        ModMenu.Keybind( "Quit Without Saving",   "End",          OnPress=_QuitWithoutSaving   ),
    ]
    
    def Enable(self):
        super().Enable()
        if not _DamageNumbers.CurrentValue:
            _DamageNumberParticleSystem.Emitters = _NoDamageNumberEmitters

    def Disable(self):
        super().Disable()
        _DamageNumberParticleSystem.Emitters = _DamageNumberEmitters

    @ClientMethod
    def ClientApplyGameSpeed(self, speed, PC = None):
        _ApplyGameSpeed(speed)

    @ClientMethod
    def ClientApplyPlayersOnly(self, playersOnly, PC = None):
        _ApplyPlayersOnly(playersOnly)

    @ClientMethod
    def ClientApplyPosition(self, position, name, PC = None):
        _ApplyPosition(_GetPlayerController(), position)
        if name is not None:
            _Feedback(f"Restored Position " + name)

    @ClientMethod
    def ClientFeedback(self, feedback, PC = None):
        _Feedback(feedback)

    @ServerMethod
    def ServerRequestPosition(self, position, name, PC = None):
        if _ClientTeleporting.CurrentValue == "Allow":
            _ApplyPosition(PC, position)
            self.ClientApplyPosition(position, name, PC)
        else:
            self.ClientFeedback("Only session host may teleport players.", PC)

    @ServerMethod
    def ServerRequestGameSpeed(self, speed, PC = None):
        if _ClientSpeedPermissions.CurrentValue:
            _ApplyGameSpeed(speed)
        else:
            self.ClientFeedback("Only session host may modify game speed.", PC)

    @ServerMethod
    def ServerRequestPlayersOnly(self, playersOnly, PC = None):
        if _ClientSpeedPermissions.CurrentValue:
            _ApplyPlayersOnly(playersOnly)
        else:
            self.ClientFeedback("Only session host may toggle game freeze.", PC)
コード例 #3
0
        Pipeline = params.Pipeline
    )

    global _total_damage
    _total_damage += damage

    return True


_continuous_option = ModMenu.Options.Slider(
    Caption = "Continuous Time Window",
    Description = "The number of seconds over which DPS should be averaged in continuous mode",
    StartingValue = 3.0, MinValue = 0.5, MaxValue = 12, Increment = 0.5
)

_continuous_keybind = ModMenu.Keybind("Show/Hide Continuous Average")
_accumulator_keybind = ModMenu.Keybind("Start/Stop/Clear Accumulator")

class DPSMeter(ModMenu.SDKMod):
    Name: str = "DPS Meter"
    Version: str = "1.0"
    Description: str = "Provides means of estimating damage dealt per second."
    Author: str = "mopioid"
    Types: ModMenu.ModTypes = ModMenu.ModTypes.Utility

    SaveEnabledState: ModMenu.EnabledSaveType = ModMenu.EnabledSaveType.LoadOnMainMenu

    Options: Sequence[ModMenu.Options.Base] = [_continuous_option]

    Keybinds: Sequence[ModMenu.Keybind] = [_continuous_keybind, _accumulator_keybind]