コード例 #1
0
 def PlaySMD(self, caller, function, params):
     BPD = caller.BehaviorProviderDefinition
     BPD.BehaviorSequences[0].BehaviorData2[7].Behavior.SpawnFactory = None
     EmitterPool = bl2sdk.GetEngine().GetCurrentWorldInfo().MyEmitterPool
     Arms = bl2sdk.GetEngine().GamePlayers[0].Actor.Pawn.Arms
     EmitterPool.SpawnEmitterMeshAttachment(bl2sdk.FindObject("ParticleSystem", "FX_ENV_Misc.Particles.Part_Confetti"), Arms, "L_Forearm")
     bl2sdk.GetEngine().GamePlayers[0].Actor.Pawn.PlayAkEvent(bl2sdk.FindObject("AkEvent", "Ake_Seq_Missions.SQ.Ak_Play_SQ_ClaptrapParty_hornBlow"))
コード例 #2
0
    def HandleLootBeams(self, caller, function, params):
        #We search for the EmitterPool to spawn our particles from, also we need a location.
        EmitterSpawner = bl2sdk.GetEngine().GetCurrentWorldInfo().MyEmitterPool
        Location = (caller.Location.X, caller.Location.Y, caller.Location.Z)
        Rotation = (caller.Rotation.Pitch, caller.Rotation.Yaw, caller.Rotation.Roll)
        #If the RBState Position is 0 it means its not on the ground
        if caller.RBState.Position.X != 0:
            if self._Exodus == True:
                #These are the RarityLevels of src
                #RareUnique
                if caller.InventoryRarityLevel in range(11, 21):
                    EmitterSpawner.SpawnEmitter(self.GetParticle(0), Location, Rotation)
                    caller.PlayAkEvent(bl2sdk.FindObject("AkEvent", "Ake_UI.UI_Mission.Ak_Play_UI_Mission_Reward"))
                #Seraph
                elif caller.InventoryRarityLevel in range(61, 71):
                    EmitterSpawner.SpawnEmitter(self.GetParticle(1), Location, Rotation)
                    caller.PlayAkEvent(bl2sdk.FindObject("AkEvent", "Ake_UI.UI_Mission.Ak_Play_UI_Mission_Reward"))
                 #Fabled/Vile
                elif caller.InventoryRarityLevel in range(71, 86):
                    EmitterSpawner.SpawnEmitter(self.GetParticle(2), Location, Rotation)
                    caller.PlayAkEvent(bl2sdk.FindObject("AkEvent", "Ake_UI.UI_Mission.Ak_Play_UI_Mission_Reward"))
                 #Legendary/Malevolent
                elif caller.InventoryRarityLevel in range(86, 101):
                    EmitterSpawner.SpawnEmitter(self.GetParticle(3), Location, Rotation)
                    caller.PlayAkEvent(bl2sdk.FindObject("AkEvent", "Ake_UI.UI_HUD.Ak_Play_UI_HUD_Chapter_Stinger"))
                #Pearlescent/Augment
                elif caller.InventoryRarityLevel in range(101, 151) or caller.InventoryRarityLevel == 500:
                    EmitterSpawner.SpawnEmitter(self.GetParticle(4), Location, Rotation)
                    caller.PlayAkEvent(bl2sdk.FindObject("AkEvent", "Ake_UI.UI_HUD.Ak_Play_UI_HUD_Chapter_Stinger"))
                #Rainbow
                elif caller.InventoryRarityLevel in range(551, 551):
                    EmitterSpawner.SpawnEmitter(self.GetParticle(5), Location, Rotation)
                    caller.PlayAkEvent(bl2sdk.FindObject("AkEvent", "Ake_UI.UI_HUD.Ak_Play_UI_HUD_Chapter_Stinger"))

            elif self._Reborn == True:
                #These are the RarityLevels of Reborn
                #Legendary and Unique Legendary
                if caller.InventoryRarityLevel in range(5, 11) or caller.InventoryRarityLevel in range(61, 81):
                    EmitterSpawner.SpawnEmitter(self.GetParticle(2), Location, Rotation)
                    caller.PlayAkEvent(bl2sdk.FindObject("AkEvent", "Ake_UI.UI_HUD.Ak_Play_UI_HUD_Chapter_Stinger"))
                #Unique Blue
                elif caller.InventoryRarityLevel in range(41, 51):
                    EmitterSpawner.SpawnEmitter(self.GetParticle(1), Location, Rotation)
                    caller.PlayAkEvent(bl2sdk.FindObject("AkEvent", "Ake_UI.UI_Mission.Ak_Play_UI_Mission_Reward"))
                 #Moxxi
                elif caller.InventoryRarityLevel in range(51, 61):
                    EmitterSpawner.SpawnEmitter(self.GetParticle(0), Location, Rotation)
                    caller.PlayAkEvent(bl2sdk.FindObject("AkEvent", "Ake_UI.UI_Mission.Ak_Play_UI_Mission_Reward"))
                 #Seraph
                elif caller.InventoryRarityLevel in range(81, 91):
                    EmitterSpawner.SpawnEmitter(self.GetParticle(3), Location, Rotation)
                    caller.PlayAkEvent(bl2sdk.FindObject("AkEvent", "Ake_UI.UI_HUD.Ak_Play_UI_HUD_Chapter_Stinger"))
                #Pearl
                elif caller.InventoryRarityLevel in range(91, 171) or caller.InventoryRarityLevel == 500:
                    EmitterSpawner.SpawnEmitter(self.GetParticle(4), Location, Rotation)
                    caller.PlayAkEvent(bl2sdk.FindObject("AkEvent", "Ake_UI.UI_HUD.Ak_Play_UI_HUD_Chapter_Stinger"))
                #Rainbow
                elif caller.InventoryRarityLevel == 506:
                    EmitterSpawner.SpawnEmitter(self.GetParticle(5), Location, Rotation)
                    caller.PlayAkEvent(bl2sdk.FindObject("AkEvent", "Ake_UI.UI_HUD.Ak_Play_UI_HUD_Chapter_Stinger"))
コード例 #3
0
 def DoubleGameSpeed(self):
     speed = self.DefaultGameInfo.GameSpeed
     if speed < 32:
         speed *= 2
         worldInfo = bl2sdk.GetEngine().GetCurrentWorldInfo()
         worldInfo.TimeDilation = speed
         self.DefaultGameInfo.GameSpeed = speed
     self.Feedback("Game Speed: " + str(Fraction(speed)))
コード例 #4
0
    def PlayEmote(self):
        #up to and including index 16 are animations only, after that come ParticleSystems
        if self._animation < 17:
            #We are going to change the animations that are played on melee to play our emotes instead
            SpecialMoves = [
                "GD_Assassin_Streaming.Anims.WeaponAnim_Melee",
                "GD_Lilac_Psycho_Streaming.Anims.WeaponAnim_Melee",
                "GD_Mercenary_Streaming.Anims.WeaponAnim_Melee",
                "GD_PlayerShared.Anims.WeaponAnim_Melee_WeaponBlade",
                "GD_Siren_Streaming.Anims.WeaponAnim_Melee",
                "GD_Soldier_Streaming.Anims.WeaponAnim_Melee",
                "GD_Tulip_Mechro_Streaming.Anims.WeaponAnim_Melee"
            ]

            PC = self.GetPlayerController()
            for Move in SpecialMoves:
                if bl2sdk.FindObject("SpecialMove_WeaponAction", Move) != None:
                    PC.ConsoleCommand(
                        "set " + Move + " AnimName " + self.ChooseAnimation(),
                        0)
                    PC.ConsoleCommand(
                        "set " + Move + " EndingCondition EC_Loop", 0)
                    #The first 2 animations are Moxxie only
                    if self._animation in (0, 1):
                        PC.ConsoleCommand(
                            "set " + Move +
                            " AnimSet AnimSet'Anim_Moxxi.Anim_Moxxi'", 0)
                    #Index 2 is Tannis only
                    elif self._animation == 2:
                        PC.ConsoleCommand(
                            "set " + Move +
                            " AnimSet AnimSet'Anim_Tannis.Anim_Tannis'", 0)
                    #Index 3, 4 is Brick only
                    elif self._animation in (3, 4):
                        PC.ConsoleCommand(
                            "set " + Move +
                            " AnimSet AnimSet'Anim_Brick.Anim_Brick'", 0)

                    elif self._animation == 16:
                        PC.ConsoleCommand(
                            "set " + Move +
                            " AnimSet AnimSet'Anim_Assassin.Base_Assassin'", 0)
                    else:
                        PC.ConsoleCommand(
                            "set " + Move +
                            " AnimSet AnimSet'Anim_Generic_NPC.Anim_Generic_NPC'",
                            0)
            PC.ConsoleCommand("camera 3rd", 0)
            PC.Behavior_Melee()
        else:
            PlayerMesh = self.GetPlayerController().Pawn.Mesh
            Particle = bl2sdk.FindObject("ParticleSystem",
                                         self.ChooseAnimation())
            self.GetPlayerController().ConsoleCommand("camera 3rd", 0)
            bl2sdk.GetEngine().GetCurrentWorldInfo(
            ).MyEmitterPool.SpawnEmitterMeshAttachment(Particle, PlayerMesh,
                                                       "head")
コード例 #5
0
    def TogglePlayersOnly(self):
        # Get the current WorldInfo object from the engine.
        worldInfo = bl2sdk.GetEngine().GetCurrentWorldInfo()
        # Get the WorldInfo's current players only state.
        playersOnly = worldInfo.bPlayersOnly

        # Display the state we will be switching to to the user.
        self.Feedback("Players Only: " + ("Off" if playersOnly else "On"))
        # Apply the change.
        worldInfo.bPlayersOnly = not playersOnly
コード例 #6
0
 def HandleDamage(self, caller, function, params):
     #We only want to play a sound if we were the ones who actually dealt the damage
     if params.PC == bl2sdk.GetEngine().GamePlayers[0].Actor:
         #DamageEventFlags = 1 -> Crit therefore if its not equal to 1 then it wasnt a crit
         if params.DamageEventData.DamageEventFlags != 1:
             self.PlaySound(params.PC)
         else:
             self.PlayCritSound(params.PC)
             if self.Status == "Enabled+Particles":
                 self.AddParticle(params)
コード例 #7
0
    def Execute(self):
        """Invoked by the SDK when our mod is enabled from the mods menu."""

        # We will be looking up the object responsible for storing hotfixes.
        micropatch = None
        for service in bl2sdk.FindObject(
                "GearboxAccountData",
                "Transient.GearboxAccountData_1").Services:
            # If the service's name is "micropatch" then it is the hotfix
            # object, and we are done.
            if service.ServiceName == "Micropatch":
                micropatch = service
                break

        # Create a dictionary of the existing hotfixes using the hotfix
        # objects's keys and values properties. Since we are interested in
        # unique hotfix values rather than keys, invert the mapping from keys to
        # values for our representation.
        hotfixes = dict(zip(micropatch.Values, micropatch.Keys))

        # Prevent a crash when the `set` console command attempts to update
        # arrays which were previously allocated by the SDK.
        micropatch.Keys = []
        micropatch.Values = []

        # Obtain the current player controller object.
        playerController = bl2sdk.GetEngine().GamePlayers[0].Actor
        try:
            # Use the controller to perform a console command executing the
            # legacy mod file. We wrap this in a `try` statement to suppress the
            # SDK's return value error.
            playerController.ConsoleCommand('exec "' + self.Filename + '"', 0)
        except:
            pass

        # If the executed file contained hotfixes, the hotfix object's
        # properties will now contain their keys and values. Update our
        # dictionary with these, inverting their mapping as described above.
        hotfixes.update(zip(micropatch.Values, micropatch.Keys))

        # Generate new lists from the final hotfix dictionary's keys and values,
        # and apply them to the hotfix object.
        micropatch.Keys = list(hotfixes.values())
        micropatch.Values = list(hotfixes.keys())

        # If we have not previously executed this file, record its last modified
        # time at time of execution, and update its UI to reflect its status.
        if self.ExecutedTime == None:
            self.ExecutedTime = os.path.getmtime(self.Filepath)
            self.Status = "Executed"
            self.SettingsInputs = {
                "Enter": "Re-execute",
                "Insert": "Unhide Mods"
            }
コード例 #8
0
 def AddParticle(self, params):
     #First we need the EmitterPool
     EmitterSpawner = bl2sdk.GetEngine().GetCurrentWorldInfo().MyEmitterPool
     #We get the location and rotation from the parameters of our hook
     Location = (params.DamageEventData.DamageLocation.X,
                 params.DamageEventData.DamageLocation.Y,
                 params.DamageEventData.DamageLocation.Z)
     Rotation = (params.PC.Rotation.Pitch, params.PC.Rotation.Yaw,
                 params.PC.Rotation.Roll)
     #Now we actually call the games function that emitts the particles
     EmitterSpawner.SpawnEmitter(self.GetParticle(), Location, Rotation)
コード例 #9
0
ファイル: __init__.py プロジェクト: nicototah/bl2sdk_Mods
    def KillCombo(self, caller, function, params):
        self._started_at = datetime.datetime.utcnow()
        self.KillCounter += 1

        #Optional Extra Experience
        bl2sdk.GetEngine().GamePlayers[0].Actor.ExpEarn(
            int(self.KillCounter**2.8), 0)

        #50% chance to trigger an AkEvent
        if random.randint(0, 100) > 50:
            self.PlayAudio()
        self.ComboFeedback(params.EnemyName)
        return True
コード例 #10
0
    def GameInputPressed(self, input):
        """Invoked by the SDK when one of the inputs we have registered for is
		pressed in-game."""
        if input.Name == "Swap Grenade":
            inventoryManager = (
                bl2sdk.GetEngine().GamePlayers[0].Actor.GetPawnInventoryManager()
            )
            for inventory in inventoryManager.Backpack:
                if (
                    inventory.Class == bl2sdk.FindClass("WillowGrenadeMod")
                    and inventory.Mark == 2
                ):
                    inventoryManager.ReadyBackpackInventory(inventory, 0)
                    break
コード例 #11
0
 def HandleZooming(self, caller, function, params):
     #Get the speed of the Player Pawn, needs to be increased while aiming
     PlayerPawn = self.GetPlayerController().Pawn
     if caller.Instigator == PlayerPawn:
         #BaseSpeed = PlayerPawn.GroundSpeed
         if PlayerPawn.Weapon.DefinitionData.BarrelPartDefinition == self.SkullMasherBarrel:
             #Get the Current Worlinfo to set the timedilation
             WorldInfo = bl2sdk.GetEngine().GetCurrentWorldInfo()
             #1==Zooming in / 2==Zoomed in / 3==Zooming out / 0==Not Zoomed
             #Only slow time while zooming in
             if params.NewZoomState in (1, 2):
                 WorldInfo.TimeDilation = 0.4500000
                 #PlayerPawn.GroundSpeed *= 1.5
                 self.RandomizeWeaponSkin()
             elif params.NewZoomState == 0:
                 WorldInfo.TimeDilation = 1.0000000
                 #PlayerPawn.GroundSpeed = BaseSpeed
         else:
             pass
     else:
         pass
コード例 #12
0
    def StopEmote(self):
        SpecialMoves = [
            "GD_Assassin_Streaming.Anims.WeaponAnim_Melee",
            "GD_Lilac_Psycho_Streaming.Anims.WeaponAnim_Melee",
            "GD_Mercenary_Streaming.Anims.WeaponAnim_Melee",
            "GD_PlayerShared.Anims.WeaponAnim_Melee_WeaponBlade",
            "GD_Siren_Streaming.Anims.WeaponAnim_Melee",
            "GD_Soldier_Streaming.Anims.WeaponAnim_Melee",
            "GD_Tulip_Mechro_Streaming.Anims.WeaponAnim_Melee"
        ]

        PC = self.GetPlayerController()
        for Move in SpecialMoves:
            if bl2sdk.FindObject("SpecialMove_WeaponAction", Move) != None:
                PC.ConsoleCommand("set " + Move + " AnimName Melee", 0)
                PC.ConsoleCommand(
                    "set " + Move + " EndingCondition EC_OnBlendOut", 0)
                PC.ConsoleCommand("set " + Move + " AnimSet None", 0)

        PC.ConsoleCommand("camera 1st", 0)
        PC.Behavior_Melee()
        bl2sdk.GetEngine().GetCurrentWorldInfo(
        ).MyEmitterPool.ClearAllPoolComponents()
コード例 #13
0
ファイル: __init__.py プロジェクト: nicototah/bl2sdk_Mods
    def GetLocation(self, caller, function, params):
        if self.RemovedMarker == True:
            Pawn = bl2sdk.GetEngine().GamePlayers[0].Actor.Pawn
            for i in caller.MapObjects:
                if i.CustomObjectLoc.X != 0.0:  #Get our newest Marker
                    MarkerLoc = (i.CustomObjectLoc.X, i.CustomObjectLoc.Y)

            bl2sdk.Log("MarkerLoc: " + str(MarkerLoc))
            #Get all the objects delta to our Marker
            for MapObjectsLoc in self.MapObjects:
                MapObjLoc = (MapObjectsLoc.Location.X,
                             MapObjectsLoc.Location.Y)
                delta = (
                    (MapObjLoc[0] - MarkerLoc[0])**2 +
                    (MapObjLoc[1] - MarkerLoc[1])**2
                )**(
                    0.5
                )  #Calculate the distance between each Point of interest and our maker
                self.ObjectDelta.append(delta)

            temp = self.ObjectDelta.index(min(self.ObjectDelta))
            Pawn.Location = (self.MapObjects[temp].Location.X,
                             self.MapObjects[temp].Location.Y,
                             self.MapObjects[temp].Location.Z + 200)

            self.MapObjects.clear()
            self.ObjectDelta.clear()
            self.RemovedMarker = False
            return True
        else:
            for i in caller.MapObjects:  #Fill up our List with all interesting objects on map
                if i.ClientInteractiveObject is not None:
                    self.MapObjects.append(i.ClientInteractiveObject)
                if i.Vehicle is not None:
                    self.MapObjects.append(i.Vehicle)
            self.RemovedMarker = True
            return True
コード例 #14
0
 def GetMapName(self):
     return bl2sdk.GetEngine().GetCurrentWorldInfo().GetMapName(True)
コード例 #15
0
 def ResetGameSpeed(self):
     worldInfo = bl2sdk.GetEngine().GetCurrentWorldInfo()
     worldInfo.TimeDilation = 1.0
     self.DefaultGameInfo.GameSpeed = 1.0
     self.Feedback("Game Speed: 1")
コード例 #16
0
ファイル: bl2tools.py プロジェクト: nicototah/bl2sdk_Mods
def get_weapon_holding():
    """
    Get the weapon the WillowPlayerPawn is currently holding.
    :return: WillowWeapon
    """
    return bl2sdk.GetEngine().GamePlayers[0].Actor.Pawn.Weapon
コード例 #17
0
 def get_pc(self):
     return bl2sdk.GetEngine().GamePlayers[0].Actor
コード例 #18
0
 def GetPlayerController(self):
     return bl2sdk.GetEngine().GamePlayers[0].Actor
コード例 #19
0
ファイル: bl2tools.py プロジェクト: nicototah/bl2sdk_Mods
def get_current_worldinfo():
    return bl2sdk.GetEngine().GetCurrentWorldInfo()
コード例 #20
0
 def GetPlayerController(self):
     """Return the current WillowPlayerController object for the local player."""
     return bl2sdk.GetEngine().GamePlayers[0].Actor
コード例 #21
0
ファイル: bl2tools.py プロジェクト: nicototah/bl2sdk_Mods
def get_player_controller():
    """
    Get the current WillowPlayerController Object.
    :return: WillowPlayerController
    """
    return bl2sdk.GetEngine().GamePlayers[0].Actor