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"))
def ChangeVisuals(self): Mesh = bl2sdk.FindObject( "StaticMeshComponent", "GD_GrenadeMods.Projectiles.Grenade_Fastball:StaticMeshComponent_21" ) Mesh.StaticMesh = bl2sdk.FindObject("StaticMesh", "Prop_Details.Meshes.Pizza")
def ChangeVisuals(self): Mesh = bl2sdk.FindObject( "StaticMeshComponent", "GD_GrenadeMods.Projectiles.Grenade_Fastball:StaticMeshComponent_21" ) Mesh.StaticMesh = bl2sdk.FindObject( "StaticMesh", "FX_WEP_Shared.Meshes.RL_Rocket_Child")
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")
def Load(self): bl2sdk.LoadPackage("SanctuaryAir_Dynamic") bl2sdk.KeepAlive( bl2sdk.FindObject("ParticleSystem", "FX_ENV_Misc.Particles.Part_Confetti")) bl2sdk.KeepAlive( bl2sdk.FindObject( "AkEvent", "Ake_Seq_Missions.SQ.Ak_Play_SQ_ClaptrapParty_hornBlow"))
def RandomizeBranch(self, SkillTreeBranchDef): self.PreloadPackages() TierCountOdds = [95, 40, 80, 30, 80, 40] HasBloodlust = False HasHellborn = False for Tier in range(6): Pity = True TierLayout = [False, False, False] MaxPoints = 0 NewSkills = [] for Skill in range(3): if (self.RNG.randint(0, 100) < TierCountOdds[Tier] or Skill == 2 and Pity): if Skill == 2 and Pity: Skill = self.RNG.randint(0, 2) Pity = False TierLayout[Skill] = True SkillDefNum = self.RNG.randint(0, len(self.ValidSkills) - 1) SkillDefName = self.ValidSkills.pop(SkillDefNum) SkillDef = bl2sdk.FindObject("SkillDefinition", SkillDefName) MaxPoints += SkillDef.MaxGrade NewSkills.append(SkillDef) HasHellborn = HasHellborn or "Hellborn" in SkillDef.GetFullName( ) if not HasBloodlust and SkillDef.GetName() in [ "BloodfilledGuns", "BloodyTwitch", ]: HasBloodlust = True self.ValidSkills += self.BloodlustSkills if SkillDef.GetName() == "Anarchy": self.ValidSkills += self.AnarchySkills if HasBloodlust: NewSkills.append( bl2sdk.FindObject( "SkillDefinition", "GD_Lilac_Skills_Bloodlust.Skills._Bloodlust")) if HasHellborn: NewSkills.append( bl2sdk.FindObject( "SkillDefinition", "GD_Lilac_Skills_Hellborn.Skills.FireStatusDetector", )) NewSkills.append( bl2sdk.FindObject( "SkillDefinition", "GD_Lilac_Skills_Hellborn.Skills.AppliedStatusEffectListener", )) SkillTreeBranchDef.Layout.Tiers[Tier].bCellIsOccupied = TierLayout SkillTreeBranchDef.Tiers[Tier].Skills = NewSkills SkillTreeBranchDef.Tiers[Tier].PointsToUnlockNextTier = min( MaxPoints, 5)
def initial_setup(self): bl2sdk.LoadPackage("Orchid_WormBelly_Dynamic") bl2sdk.LoadPackage("DamTop_Dynamic") turret = bl2sdk.FindObject("Object", "GD_RolandNPC.Projectiles.Projectile_RolandTurret_DamTop:" "BehaviorProviderDefinition_0.Behavior_SpawnFromPopulationSystem_39." "PopulationFactoryBalancedAIPawn_0") rakkhive = bl2sdk.FindObject("AIPawnBalanceDefinition", "GD_Orchid_Pop_RakkHive.Character." "PawnBalance_Orchid_RakkHive") pawn_rakkhive = bl2sdk.FindObject("WillowAIPawn", "GD_Orchid_RakkHive.Character.Pawn_RakkHive") bl2sdk.KeepAlive(turret) bl2sdk.KeepAlive(rakkhive) bl2sdk.KeepAlive(pawn_rakkhive)
def RandomizeWeaponSkin(self): #Find the MaterialInstanceConstant of Random Skin RandomMaterial = bl2sdk.FindObject("MaterialInstanceConstant", self.GetRandomSkin()) #Some skins use a parent skin as a template, in that case copy its values first! if not RandomMaterial.Parent.Name == "Master_Gun": #print("Material Parent:") #print(RandomMaterial.Parent) for temp in RandomMaterial.Parent.VectorParameterValues: color = (temp.ParameterValue.R, temp.ParameterValue.G, temp.ParameterValue.B, temp.ParameterValue.A) self.ChronosMaterial.SetVectorParameterValue( temp.ParameterName, color) for temp in RandomMaterial.Parent.TextureParameterValues: if not temp.ParameterValue == None: self.ChronosMaterial.SetTextureParameterValue( temp.ParameterName, temp.ParameterValue) for temp in RandomMaterial.Parent.ScalarParameterValues: self.ChronosMaterial.SetScalarParameterValue( temp.ParameterName, temp.ParameterValue) #print("Material:") #print(RandomMaterial) for temp in RandomMaterial.VectorParameterValues: color = (temp.ParameterValue.R, temp.ParameterValue.G, temp.ParameterValue.B, temp.ParameterValue.A) self.ChronosMaterial.SetVectorParameterValue( temp.ParameterName, color) for temp in RandomMaterial.TextureParameterValues: if not temp.ParameterValue == None: self.ChronosMaterial.SetTextureParameterValue( temp.ParameterName, temp.ParameterValue) for temp in RandomMaterial.ScalarParameterValues: self.ChronosMaterial.SetScalarParameterValue( temp.ParameterName, temp.ParameterValue)
def ForceLoad(self): bl2sdk.LoadPackage("SanctuaryAir_Dynamic") bl2sdk.LoadPackage("CastleKeep_FX") bl2sdk.LoadPackage("CastleKeep_Combat") bl2sdk.LoadPackage("CastleKeep_Mission") for Particle in self.Particles: temp = bl2sdk.FindObject("ParticleSystem", Particle) bl2sdk.KeepAlive(temp)
def HandleKill(self, caller, function, params): if params.Killer == self.get_pc(): spawn = bl2sdk.FindObject("Object", "GD_Orchid_RakkHive.Animation.Anim_RakkHive_Shake:" "BehaviorProviderDefinition_0.Behavior_AISpawn_43") for popdef in bl2sdk.FindAll("WillowPopulationDefinition"): for i in popdef.ActorArchetypeList: try: WillowAiPawn = i.SpawnFactory.PawnBalanceDefinition.AIPawnArchetype if WillowAiPawn.BodyClass == caller.BodyClass: spawn.PopDef = popdef break except: continue desc = bl2sdk.FindObject("Object", "GD_GrenadeMods.Delivery.Delivery_NastySurprise:" "AttributePresentationDefinition_4") desc.Description = "Catch 'em all!<br>Currently holding: " + str(caller.CurrentNameTag.NameTag) return True
def ForceLoad(self): #Needed for the cool Katana moves bl2sdk.LoadPackage("GD_Assassin_Streaming_SF") bl2sdk.KeepAlive( bl2sdk.FindObject( "WillowAnimDefinition", "GD_Assassin_Hologram.SpecialMove.SpecialMove_HologramScrewAround" )) bl2sdk.KeepAlive( bl2sdk.FindObject("AnimSet", "Anim_Assassin.Base_Assassin")) #We dont want these animations to unload Objects = [ "GD_NPCShared.Perches.Perch_NPC_ArmsCrossedForever:SpecialMove_PerchLoop_0", "GD_NPCShared.Perches.Perch_NPC_BangOnSomething:SpecialMove_PerchLoop_0", "GD_NPCShared.Perches.Perch_NPC_BarrelSitForever:SpecialMove_PerchLoop_0", "GD_NPCShared.Perches.Perch_NPC_ChairSitForever:SpecialMove_PerchLoop_0", "GD_NPCShared.Perches.Perch_NPC_DartsHit:SpecialMove_PerchLoop_0", "GD_NPCShared.Perches.Perch_NPC_KickGround:SpecialMove_PerchLoop_0", "GD_NPCShared.Perches.Perch_NPC_LeanOnCounterForever:SpecialMove_PerchLoop_0", "GD_NPCShared.Perches.Perch_NPC_LeanOnWallNonRandom:SpecialMove_PerchLoop_0", "GD_NPCShared.Perches.Perch_NPC_LookAtGround:SpecialMove_PerchLoop_0", "GD_NPCShared.Perches.Perch_NPC_PeerUnder:SpecialMove_PerchLoop_0", "GD_Moxxi.Perches.Perch_Moxxi_Dance:SpecialMove_PerchLoop_0", "GD_Moxxi.Perches.Perch_Moxxi_WipeBar:SpecialMove_PerchLoop_0", "GD_TannisNPC.Perches.Perch_Tannis_HandsOnHips:SpecialMove_PerchLoop_0", "GD_BrickNPC.Perches.Perch_Brick_Pushups:SpecialMove_PerchLoop_0" ] bl2sdk.LoadPackage("SanctuaryAir_Dynamic") for Object in Objects: x = bl2sdk.FindObject("SpecialMove_PerchLoop", Object) bl2sdk.KeepAlive(x) #This are our Particles that can be used Particles = [ "FX_ENV_Misc.Particles.Part_Confetti", "FX_Distillery.Particles.PS_Hearts_Looping_8-Bit", "FX_CHAR_Merc.Particles.Part_Merc_MoneyShotImpact", "FX_Distillery.Particles.PS_Nast_Drunk_Thresher" ] bl2sdk.LoadPackage("Distillery_Dynamic") bl2sdk.LoadPackage("Distillery_Mission") bl2sdk.LoadPackage("GD_Mercenary_Streaming_SF") for Particle in Particles: x = bl2sdk.FindObject("ParticleSystem", Particle) bl2sdk.KeepAlive(x)
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" }
def PartChanges(self): ChronosBarrel = bl2sdk.FindObject( "WeaponPartDefinition", "GD_Weap_SniperRifles.Barrel.SR_Barrel_Jakobs_Skullmasher") ChronosTitle = bl2sdk.FindObject( "WeaponNamePartDefinition", "GD_Weap_SniperRifles.Name.Title_Jakobs.Title_Legendary_Skullmasher" ) ChronosRedText = bl2sdk.FindObject( "AttributePresentationDefinition", "GD_Weap_SniperRifles.Name.Title_Jakobs.Title_Legendary_Skullmasher:AttributePresentationDefinition_8" ) ChronosTitle.PartName = "Chronos" ChronosRedText.NoConstraintText = "ZA WARUDO!" #Change the actual weapon stats ''' ModifierType = 0 -> MT_Scale ModifierType = 1 -> MT_PreAdd ModifierType = 2 -> MT_PostAdd ''' #setting the clip size to 1 ClipSize = bl2sdk.FindObject("AttributeDefinition", "D_Attributes.Weapon.WeaponClipSize") ChronosBarrel.WeaponAttributeEffects[0].AttributeToModify = ClipSize ChronosBarrel.WeaponAttributeEffects[0].ModifierType = 0 #ChronosBarrel.WeaponAttributeEffects[0].BaseModifierValue.BaseValueConstant = -100000000.000000 ChronosBarrel.WeaponAttributeEffects[3].AttributeToModify = ClipSize ChronosBarrel.WeaponAttributeEffects[3].ModifierType = 2 ChronosBarrel.WeaponAttributeEffects[ 3].BaseModifierValue.BaseValueConstant = 1.000000 #increasing the damage ChronosBarrel.WeaponAttributeEffects[ 1].BaseModifierValue.BaseValueConstant = 1.000000 #change shot impulse to crit damage CritDamage = bl2sdk.FindObject( "AttributeDefinition", "D_Attributes.GameplayAttributes.PlayerCriticalHitBonus") ChronosBarrel.WeaponAttributeEffects[2].AttributeToModify = CritDamage ChronosBarrel.WeaponAttributeEffects[2].ModifierType = 0 ChronosBarrel.WeaponAttributeEffects[ 2].BaseModifierValue.BaseValueConstant = 1.000000
def PlayAudio(self): AkEvents = [ "Ake_VOCT_Contextual.Ak_Play_VOCT_GuiltGun_Killed_Enemy", "Ake_VOCT_Contextual.Ak_Play_VOCT_Fink_CoS_Arena_Win", "Ake_VOCT_Contextual.Ak_Play_VOCT_Loader1340_Killed_Enemy", "Ake_VOCT_Contextual.Ak_Play_VOCT_Loader1340_One_Shot_Kill", "Ake_VOCT_Contextual.Ak_Play_VOCT_CaptCabrera_CoS_Arena_Win", "Ake_VOCT_Contextual.Ak_Play_VOCT_IndoBot5K_CoS_Arena_Win", "Ake_VOCT_Contextual.Ak_Play_VOCT_Fink_CoS_Arena_Round_Commence", "Ake_VOCT_Contextual.Ak_Play_VOCT_Fink_CoS_Arena_Round_Begin" ] MakeNoise = bl2sdk.FindObject("AkEvent", random.choice(AkEvents)) PlayerController = self.GetPlayerController() PlayerController.PlayAkEvent(MakeNoise)
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()
def ForceLoad(self): bl2sdk.LoadPackage("SanctuaryAir_Dynamic") temp = bl2sdk.FindObject("ParticleSystem", "FX_ENV_Misc.Particles.Part_Confetti") bl2sdk.KeepAlive(temp)
class Chronos(bl2sdk.BL2MOD): Name = "Chronos" Description = "Replaces the Skullmasher with Chronos, a sniper Rifle that slows down time while aiming down sights. Zooming out randomizes your weapons skin." Author = "Juso" #This function is used to alter the weapons stats and also change its name and red text. def PartChanges(self): ChronosBarrel = bl2sdk.FindObject( "WeaponPartDefinition", "GD_Weap_SniperRifles.Barrel.SR_Barrel_Jakobs_Skullmasher") ChronosTitle = bl2sdk.FindObject( "WeaponNamePartDefinition", "GD_Weap_SniperRifles.Name.Title_Jakobs.Title_Legendary_Skullmasher" ) ChronosRedText = bl2sdk.FindObject( "AttributePresentationDefinition", "GD_Weap_SniperRifles.Name.Title_Jakobs.Title_Legendary_Skullmasher:AttributePresentationDefinition_8" ) ChronosTitle.PartName = "Chronos" ChronosRedText.NoConstraintText = "ZA WARUDO!" #Change the actual weapon stats ''' ModifierType = 0 -> MT_Scale ModifierType = 1 -> MT_PreAdd ModifierType = 2 -> MT_PostAdd ''' #setting the clip size to 1 ClipSize = bl2sdk.FindObject("AttributeDefinition", "D_Attributes.Weapon.WeaponClipSize") ChronosBarrel.WeaponAttributeEffects[0].AttributeToModify = ClipSize ChronosBarrel.WeaponAttributeEffects[0].ModifierType = 0 #ChronosBarrel.WeaponAttributeEffects[0].BaseModifierValue.BaseValueConstant = -100000000.000000 ChronosBarrel.WeaponAttributeEffects[3].AttributeToModify = ClipSize ChronosBarrel.WeaponAttributeEffects[3].ModifierType = 2 ChronosBarrel.WeaponAttributeEffects[ 3].BaseModifierValue.BaseValueConstant = 1.000000 #increasing the damage ChronosBarrel.WeaponAttributeEffects[ 1].BaseModifierValue.BaseValueConstant = 1.000000 #change shot impulse to crit damage CritDamage = bl2sdk.FindObject( "AttributeDefinition", "D_Attributes.GameplayAttributes.PlayerCriticalHitBonus") ChronosBarrel.WeaponAttributeEffects[2].AttributeToModify = CritDamage ChronosBarrel.WeaponAttributeEffects[2].ModifierType = 0 ChronosBarrel.WeaponAttributeEffects[ 2].BaseModifierValue.BaseValueConstant = 1.000000 def GetPlayerController(self): return bl2sdk.GetEngine().GamePlayers[0].Actor #This function contains a list of all Sniper skins in the game, its used to randomly chose any of these skins as a template for Chronos Skin. def GetRandomSkin(self): SniperSkins = [ "Aster_GunMaterials.Materials.Mati_VladofCommonSR_Patriot", "Aster_GunMaterials.Materials.sniper.Mati_Dahl_Emerald_Sniper", "Aster_GunMaterials.Materials.sniper.Mati_Hyperion_Diamond_Sniper", "Aster_GunMaterials.Materials.sniper.Mati_Jakobs_Citrine_Sniper", "Aster_GunMaterials.Materials.sniper.Mati_Maliwan_Aquamarine_Sniper", "Aster_GunMaterials.Materials.sniper.Mati_Vladof_Garnet_Sniper", "Common_GunMaterials.Materials.sniper.Mati_DahUniqueSR_Sloth", "Common_GunMaterials.Materials.sniper.Mati_DahlCommonSR", "Common_GunMaterials.Materials.sniper.Mati_DahlEpicSR", "Common_GunMaterials.Materials.sniper.Mati_DahlLegendarySRPitchfork", "Common_GunMaterials.Materials.sniper.Mati_DahlRareSR", "Common_GunMaterials.Materials.sniper.Mati_DahlUncommonSR", "Common_GunMaterials.Materials.sniper.Mati_GearboxSR", "Common_GunMaterials.Materials.sniper.Mati_HyperionCommonSR", "Common_GunMaterials.Materials.sniper.Mati_HyperionEpicSR", "Common_GunMaterials.Materials.sniper.Mati_HyperionLegendarySRInvader", "Common_GunMaterials.Materials.sniper.Mati_HyperionRareSR", "Common_GunMaterials.Materials.sniper.Mati_HyperionUncommonSR", "Common_GunMaterials.Materials.sniper.Mati_HyperionUniqueSR_FremingtonsEdge", "Common_GunMaterials.Materials.sniper.Mati_HyperionUniqueSR_Longbow", "Common_GunMaterials.Materials.sniper.Mati_HyperionUniqueSR_Morningstar", "Common_GunMaterials.Materials.sniper.Mati_JakobsCommonSR", "Common_GunMaterials.Materials.sniper.Mati_JakobsEpicSR", "Common_GunMaterials.Materials.sniper.Mati_JakobsLegendarySRSkullmasher", "Common_GunMaterials.Materials.sniper.Mati_JakobsRareSR", "Common_GunMaterials.Materials.sniper.Mati_JakobsUncommonSR", "Common_GunMaterials.Materials.sniper.Mati_JakobsUniqueSR_Buffalo", "Common_GunMaterials.Materials.sniper.Mati_JakobsUniqueSR_Tresspasser", "Common_GunMaterials.Materials.sniper.Mati_MaliwanCommonSR", "Common_GunMaterials.Materials.sniper.Mati_MaliwanEpicSR", "Common_GunMaterials.Materials.sniper.Mati_MaliwanLegendarySRVolcano", "Common_GunMaterials.Materials.sniper.Mati_MaliwanRareSR", "Common_GunMaterials.Materials.sniper.Mati_MaliwanUncommonSR", "Common_GunMaterials.Materials.sniper.Mati_MaliwanUniqueSR_ChereAmie", "Common_GunMaterials.Materials.sniper.Mati_VladofCommonSR", "Common_GunMaterials.Materials.sniper.Mati_VladofEpicSR", "Common_GunMaterials.Materials.sniper.Mati_VladofLegendarySRLyudmila", "Common_GunMaterials.Materials.sniper.Mati_VladofRareSR", "Common_GunMaterials.Materials.sniper.Mati_VladofUncommonSR", "Gladiolus_GunMaterials.Materials.sniper.Mati_Maliwan_6_Storm", "Iris_GunMaterials.Materials.sniper.Mati_JakobsUniqueSR_Cobra", "Lobelia_GunMaterials.Materials.sniper.Mati_Jakobs_Pearl_Godfinger", "Orchid_GunMaterials.Materials.sniper.Mati_MaliwanRareSR_Pimpernel", "Orchid_GunMaterials.Materials.sniper.Mati_VladofCommonSR_Patriot", "Sage_GunMaterials.Materials.sniper.Mati_JakobsCommonSR_ElephantGun", "Sage_GunMaterials.Materials.sniper.Mati_JakobsRaidSR_HawkEye" ] return random.choice(SniperSkins) #This function gets called everytime the player unzooms the chronos, it will then randomly change the weapons skin #It uses one random already existing sniper skin as a template. It copys all the values from the template to its own skin. #Search first for the Material of the Skullmasher ChronosMaterial = bl2sdk.FindObject( "MaterialInstanceConstant", "Common_GunMaterials.Materials.sniper.Mati_JakobsLegendarySRSkullmasher" ) def RandomizeWeaponSkin(self): #Find the MaterialInstanceConstant of Random Skin RandomMaterial = bl2sdk.FindObject("MaterialInstanceConstant", self.GetRandomSkin()) #Some skins use a parent skin as a template, in that case copy its values first! if not RandomMaterial.Parent.Name == "Master_Gun": #print("Material Parent:") #print(RandomMaterial.Parent) for temp in RandomMaterial.Parent.VectorParameterValues: color = (temp.ParameterValue.R, temp.ParameterValue.G, temp.ParameterValue.B, temp.ParameterValue.A) self.ChronosMaterial.SetVectorParameterValue( temp.ParameterName, color) for temp in RandomMaterial.Parent.TextureParameterValues: if not temp.ParameterValue == None: self.ChronosMaterial.SetTextureParameterValue( temp.ParameterName, temp.ParameterValue) for temp in RandomMaterial.Parent.ScalarParameterValues: self.ChronosMaterial.SetScalarParameterValue( temp.ParameterName, temp.ParameterValue) #print("Material:") #print(RandomMaterial) for temp in RandomMaterial.VectorParameterValues: color = (temp.ParameterValue.R, temp.ParameterValue.G, temp.ParameterValue.B, temp.ParameterValue.A) self.ChronosMaterial.SetVectorParameterValue( temp.ParameterName, color) for temp in RandomMaterial.TextureParameterValues: if not temp.ParameterValue == None: self.ChronosMaterial.SetTextureParameterValue( temp.ParameterName, temp.ParameterValue) for temp in RandomMaterial.ScalarParameterValues: self.ChronosMaterial.SetScalarParameterValue( temp.ParameterName, temp.ParameterValue) SkullMasherBarrel = bl2sdk.FindObject( "WeaponPartDefinition", "GD_Weap_SniperRifles.Barrel.SR_Barrel_Jakobs_Skullmasher") 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 #Checks if weapon is zoomed in #Hooks the games SetZoomState function ZoomHook = "WillowGame.WillowWeapon.SetZoomState" def Enable(self): self.PartChanges() bl2sdk.RegisterHook(self.ZoomHook, "ZoomHook", IsZoomingHook) def Disable(self): bl2sdk.RemoveHook(self.ZoomHook, "ZoomHook")
def PlayCritSound(self, PlayerController): #AkEvent = bl2sdk.FindObject("AkEvent", "Ake_UI.UI_HUD.Ak_Play_UI_Alert_CoOp_Ding") AkEvent = bl2sdk.FindObject( "AkEvent", "Ake_UI.UI_Generic.Ak_Play_UI_Generic_InGame_Close") PlayerController.PlayAkEvent(AkEvent)
def ForceLoad(self): bl2sdk.LoadPackage("SanctuaryAir_Dynamic") bl2sdk.KeepAlive( bl2sdk.FindObject("StaticMesh", "Prop_Details.Meshes.Pizza"))
def GetParticle(self, index): temp = bl2sdk.FindObject("ParticleSystem", self.Particles[index]) print(temp) return temp
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 Exodus #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"))
def GetParticle(self): return bl2sdk.FindObject("ParticleSystem", "FX_ENV_Misc.Particles.Part_Confetti")
class Commander(bl2sdk.BL2MOD): Name = "Commander" Description = ( "By mopioid.\n\nPerform various changes to the game using keybindings." ) LocalModDir = os.path.dirname(os.path.realpath(__file__)) SettingsPath = os.path.join(LocalModDir, "settings.json") """The path to the file in which we store our settings.""" def __init__(self): """Attempts to load the user's settings from their settings file.""" try: with open(self.SettingsPath) as settingsFile: # Decode the JSON data contained in the settings file. settings = json.load(settingsFile) # Convert the settings file's list of ignored files to a set for # our own usage. self.Bindings = settings.get("bindings", dict()) if type(self.Bindings) is not dict: self.Bindings = dict() self.Positions = settings.get("positions", dict()) if type(self.Positions) is not dict: self.Positions = dict() # If this fails, set up empty values for our settings. except: self.Bindings = dict() self.Positions = dict() self.GameInputs = { "Halve Game Speed": ("LeftBracket", self.HalveGameSpeed), "Double Game Speed": ("RightBracket", self.DoubleGameSpeed), "Reset Game Speed": ("Backslash", self.ResetGameSpeed), "Save Position": ("Period", self.SavePosition), "Restore Position": ("Comma", self.RestorePosition), "Teleport Forward": ("Up", self.MoveForward), "Toggle World Freeze": ("Slash", self.TogglePlayersOnly), "Toggle HUD": ("Semicolon", self.ToggleHUD), "Toggle Damage Numbers": ("Quote", self.ToggleDamageNumbers), "Toggle Third Person": ("Equals", self.ToggleThirdPerson), "Quit Without Saving": ("End", self.QuitWithoutSaving), } def SaveSettings(self): """Saves the current settings in JSON format to our settings file.""" # Create a dictionary with our settings. settings = {"bindings": self.Bindings, "positions": self.Positions} # Save the settings dictionary to our settings file in JSON format. with open(self.SettingsPath, "w") as settingsFile: json.dump(settings, settingsFile, indent=4) def Enable(self): for name, (key, _) in self.GameInputs.items(): key = self.Bindings.get(name, key) self.RegisterGameInput(name, key) def Disable(self): for name in self.GameInputs: self.UnregisterGameInput(name) def GameInputPressed(self, input): self.GameInputs[input.Name][1]() def GameInputRebound(self, name, key): self.Bindings[name] = key self.SaveSettings() def GetPlayerController(self): """Return the current WillowPlayerController object for the local player.""" return bl2sdk.GetEngine().GamePlayers[0].Actor DefaultGameInfo = bl2sdk.FindObject( "WillowCoopGameInfo", "WillowGame.Default__WillowCoopGameInfo" ) """A reference to the WillowCoopGameInfo template object.""" # We use this for managing game speed, as transient WorldInfo objects pull # their TimeDilation from it. def Feedback(self, feedback): """Presents a "training" message to the user with the given string.""" # Get the current player controller and the graphics object for its HUD. playerController = self.GetPlayerController() HUDMovie = playerController.GetHUDMovie() # If there is no graphics object, we cannot display feedback. if HUDMovie is None: return # We will be displaying the message for two *real time* seconds. duration = 2.0 * self.DefaultGameInfo.GameSpeed # Clear any previous message that may be displayed. HUDMovie.ClearTrainingText() # Present the training message as per the function's signature: # AddTrainingText(string MessageString, string TitleString, float Duration, Color DrawColor, string HUDInitializationFrame, bool PausesGame, float PauseContinueDelay, PlayerReplicationInfo Related_PRI1, optional bool bIsntActuallyATrainingMessage, optional WillowPlayerController.EBackButtonScreen StatusMenuTab, optional bool bMandatory) HUDMovie.AddTrainingText( feedback, "Commander", duration, (), "", False, 0, playerController.PlayerReplicationInfo, True, ) def ConsoleCommand(self, command): """Performs the given string as a console command.""" playerController = self.GetPlayerController() try: playerController.ConsoleCommand(command, 0) except: pass def ToggleThirdPerson(self): # Assume our local player controller is the first in the engine's list. playerController = self.GetPlayerController() # Check the state of the current player controller's camera. If it is # in third person, we will be switching to first, and vice versa. camera = "3rd" if playerController.UsingFirstPersonCamera() else "1st" # Perform the "camera" console command using the player controller, with # the argument as determined above. self.ConsoleCommand("camera " + camera) def HalveGameSpeed(self): speed = self.DefaultGameInfo.GameSpeed if speed > 0.0625: speed /= 2 worldInfo = bl2sdk.GetEngine().GetCurrentWorldInfo() worldInfo.TimeDilation = speed self.DefaultGameInfo.GameSpeed = speed self.Feedback("Game Speed: " + str(Fraction(speed))) 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))) def ResetGameSpeed(self): worldInfo = bl2sdk.GetEngine().GetCurrentWorldInfo() worldInfo.TimeDilation = 1.0 self.DefaultGameInfo.GameSpeed = 1.0 self.Feedback("Game Speed: 1") def ToggleHUD(self): self.ConsoleCommand("ToggleHUD") DamageNumberEmitterObject = bl2sdk.FindObject( "ParticleSystem", "FX_CHAR_Damage_Matrix.Particles.Part_Dynamic_Number" ) DamageNumberEmitters = list(DamageNumberEmitterObject.Emitters) NoDamageNumberEmitters = [ None, None, DamageNumberEmitters[2], DamageNumberEmitters[3], DamageNumberEmitters[4], DamageNumberEmitters[5], DamageNumberEmitters[6], DamageNumberEmitters[7], DamageNumberEmitters[8], DamageNumberEmitters[9], DamageNumberEmitters[10], DamageNumberEmitters[11], DamageNumberEmitters[12], DamageNumberEmitters[13], DamageNumberEmitters[14], DamageNumberEmitters[15], DamageNumberEmitters[16], ] def ToggleDamageNumbers(self): if self.DamageNumberEmitterObject.Emitters[0] is None: self.DamageNumberEmitterObject.Emitters = self.DamageNumberEmitters self.Feedback("Damage Numbers: On") else: self.DamageNumberEmitterObject.Emitters = self.NoDamageNumberEmitters self.Feedback("Damage Numbers: Off") def GetMapName(self): return bl2sdk.GetEngine().GetCurrentWorldInfo().GetMapName(True) def GetRotationAndLocation(self): # Assume our local player controller is the first in the engine's list. playerController = self.GetPlayerController() # Our rotation struct is stored in the player controller, while our # location struct is stored in its associated pawn object. return playerController.Rotation, playerController.Pawn.Location def SavePosition(self): rotation, location = self.GetRotationAndLocation() position = { "X": location.X, "Y": location.Y, "Z": location.Z, "Pitch": rotation.Pitch, "Yaw": rotation.Yaw, } self.Positions[self.GetMapName()] = position self.SaveSettings() self.Feedback("Saved Position") def RestorePosition(self): mapName = self.GetMapName() if mapName in self.Positions: position = self.Positions[mapName] rotation, location = self.GetRotationAndLocation() location.X = position["X"] location.Y = position["Y"] location.Z = position["Z"] rotation.Pitch = position["Pitch"] rotation.Yaw = position["Yaw"] self.Feedback("Restored Position") else: self.Feedback("No Position Saved") RadiansConversion = 65535.0 / math.pi / 2.0 def MoveForward(self): rotation, location = self.GetRotationAndLocation() pitch = rotation.Pitch / Commander.RadiansConversion yaw = rotation.Yaw / Commander.RadiansConversion location.Z += math.sin(pitch) * 250 location.X += math.cos(yaw) * math.cos(pitch) * 250 location.Y += math.sin(yaw) * math.cos(pitch) * 250 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 def QuitWithoutSaving(self): self.ConsoleCommand("disconnect")
def PlaySound(self, PlayerController): AkEvent = bl2sdk.FindObject( "AkEvent", "Ake_UI.UI_Generic.Ak_Play_UI_Generic_InGame_Select") PlayerController.PlayAkEvent(AkEvent)