def attribute_definition_helper(new_obj: unrealsdk.UObject) -> None: if new_obj.ValueResolverChain: counter = 0 temp = [] for value in new_obj.ValueResolverChain: new_value = unrealsdk.ConstructObject(Class=value.Class, Outer=new_obj, Name=f"{value.Name}_{counter}", Template=value) unrealsdk.KeepAlive(new_value) new_value.ObjectFlags.B |= 4 temp.append(new_value) counter += 1 new_obj.ValueResolverChain = temp if new_obj.ContextResolverChain: counter = 0 temp = [] for context in new_obj.ContextResolverChain: new_context = unrealsdk.ConstructObject(Class=context.Class, Outer=new_obj, Name=f"{context.Name}_{counter}", Template=context) unrealsdk.KeepAlive(new_context) new_context.ObjectFlags.B |= 4 temp.append(new_context) counter += 1 new_obj.ContextResolverChain = temp
def skill_constraints_helper(self, new_obj): number = 1000 for i, constraint in enumerate(new_obj.SkillConstraints): if constraint.Evaluator: obj = constraint.Evaluator new_constraint = unrealsdk.ConstructObject(Class=obj.Class, Outer=new_obj, Name=obj.Name + "_" + str(number), SetFlags=0x83, Template=obj) unrealsdk.KeepAlive(new_constraint) number += 1 new_obj.SkillConstraints[i].Evaluator = new_constraint self.evaluator_expression_helper(new_constraint) else: for j, obj in enumerate(constraint.EvaluatorDefinitions): new_constraint = unrealsdk.ConstructObject( Class=obj.Class, Outer=new_obj, Name=obj.Name + "_" + str(number), SetFlags=0x83, Template=obj) unrealsdk.KeepAlive(new_constraint) number += 1 new_obj.SkillConstraints[i].EvaluatorDefinitions[ j] = new_constraint self.evaluator_expression_helper(new_constraint)
def com_partlist_helper(self, obj, new_com_balance): """ This Functions purpose is it to easily create New PartLists to work with. If one constructs a new ClassModBalanceDefinition this function gets called and constructs its new PartLists The new ItemPartListCollection name will be "PartList" The new RuntimePartListCollection name will be "ItemPartListCollectionDefinition_1000" """ part_list = obj.ItemPartListCollection new_part_list = unrealsdk.ConstructObject( Class="ItemPartListCollectionDefinition", Outer=new_com_balance, Name="PartList", SetFlags=0x83, Template=part_list) unrealsdk.KeepAlive(new_part_list) runtime_part_list = obj.RuntimePartListCollection new_runtime_part_list = unrealsdk.ConstructObject( Class="ItemPartListCollectionDefinition", Outer=new_com_balance, Name="ItemPartListCollectionDefinition_1000", SetFlags=0x83, Template=runtime_part_list) unrealsdk.KeepAlive(new_runtime_part_list) new_com_balance.ItemPartListCollection = new_part_list new_com_balance.RuntimePartListCollection = new_runtime_part_list
def evaluator_expression_helper(evaluator: unrealsdk.UObject) -> None: if evaluator.Expression1: new_expression = unrealsdk.ConstructObject(Class=evaluator.Expression1.Class, Outer=evaluator, Name=f"{evaluator.Expression1.Name}_1", Template=evaluator.Expression1) unrealsdk.KeepAlive(new_expression) new_expression.ObjectFlags.B |= 4 evaluator.Expression1 = new_expression if evaluator.Expression2: new_expression = unrealsdk.ConstructObject(Class=evaluator.Expression1.Class, Outer=evaluator, Name=f"{evaluator.Expression1.Name}_2", Template=evaluator.Expression1) unrealsdk.KeepAlive(new_expression) new_expression.ObjectFlags.B |= 4 evaluator.Expression1 = new_expression
def get_free_mat_inst_consts(self, reload_only: bool = False) -> None: # We need any MeshComponent to create new MatInstConsts, I just use this cuz it's always loaded if not reload_only: # create and assign the new MatInstConsts for obj in self.need_mat_inst_const: mat = MESH.CreateAndSetMaterialInstanceConstant(0) unrealsdk.KeepAlive(mat) if obj.Class in ( unrealsdk.FindClass("ClassModDefinition"), unrealsdk.FindClass("CrossDLCClassModDefinition"), unrealsdk.FindClass("ArtifactDefinition")): obj.OverrideMaterial = mat else: obj.Material = mat for file in self.files: with open(file, "r") as TemplateFile: for line in TemplateFile: if not line.split() or line.split()[0].lower() != "set": continue else: try: Materials.exec_skins(line, self.is_game_bl2) except Exception as e: logging.logger.error(e) logging.logger.error(f"Error in: {line}")
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)
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)
def CreateIcons(self) -> None: if self.HealthIcon is not None and self.AmmoIcon is not None: return HEALTH_NAME = "Icon_RefillHealth" AMMO_NAME = "Icon_RefillAmmo" # Incase you're re-execing the file and running a new instance self.HealthIcon = unrealsdk.FindObject( "InteractionIconDefinition", f"GD_InteractionIcons.Default.{HEALTH_NAME}") self.AmmoIcon = unrealsdk.FindObject( "InteractionIconDefinition", f"GD_InteractionIcons.Default.{AMMO_NAME}") baseIcon = unrealsdk.FindObject( "InteractionIconDefinition", "GD_InteractionIcons.Default.Icon_DefaultUse") PC = unrealsdk.GetEngine().GamePlayers[0].Actor if self.HealthIcon is None: self.HealthIcon = unrealsdk.ConstructObject(Class=baseIcon.Class, Outer=baseIcon.Outer, Name=HEALTH_NAME, Template=baseIcon) unrealsdk.KeepAlive(self.HealthIcon) self.HealthIcon.Icon = 3 # Setting values directly on the object causes a crash on quitting the game # Everything still works fine, not super necessary to fix, but people get paranoid # https://github.com/bl-sdk/PythonSDK/issues/45 PC.ServerRCon( f"set {PC.PathName(self.HealthIcon)} Action UseSecondary") PC.ServerRCon( f"set {PC.PathName(self.HealthIcon)} Text REFILL HEALTH") if self.AmmoIcon is None: self.AmmoIcon = unrealsdk.ConstructObject(Class=baseIcon.Class, Outer=baseIcon.Outer, Name=AMMO_NAME, Template=baseIcon) unrealsdk.KeepAlive(self.AmmoIcon) self.AmmoIcon.Icon = 7 PC.ServerRCon( f"set {PC.PathName(self.AmmoIcon)} Action UseSecondary") PC.ServerRCon(f"set {PC.PathName(self.AmmoIcon)} Text REFILL AMMO")
def bpd_copy_helper(new_obj: unrealsdk.UObject) -> None: if new_obj.BehaviorProviderDefinition: new_bpd = unrealsdk.ConstructObject(Class="BehaviorProviderDefinition", Outer=new_obj, Name=f"{new_obj.BehaviorProviderDefinition.Name}_0", Template=new_obj.BehaviorProviderDefinition) unrealsdk.KeepAlive(new_bpd) new_bpd.ObjectFlags.B |= 4 new_obj.BehaviorProviderDefinition = new_bpd bpd_helper(new_bpd)
def ForceLoad(self): # Needed for the cool Katana moves unrealsdk.LoadPackage("GD_Assassin_Streaming_SF") unrealsdk.KeepAlive( unrealsdk.FindObject( "WillowAnimDefinition", "GD_Assassin_Hologram.SpecialMove.SpecialMove_HologramScrewAround" )) unrealsdk.KeepAlive( unrealsdk.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" ] unrealsdk.LoadPackage("SanctuaryAir_Dynamic") for Object in Objects: x = unrealsdk.FindObject("SpecialMove_PerchLoop", Object) unrealsdk.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" ] unrealsdk.LoadPackage("Distillery_Dynamic") unrealsdk.LoadPackage("Distillery_Mission") unrealsdk.LoadPackage("GD_Mercenary_Streaming_SF") for Particle in Particles: x = unrealsdk.FindObject("ParticleSystem", Particle) unrealsdk.KeepAlive(x)
def skill_presentation_helper(cloned_obj: unrealsdk.UObject, new_obj: unrealsdk.UObject) -> None: new_custom_presentations = [] for number, Presentation in enumerate(cloned_obj.SkillEffectPresentations): new_presentation = unrealsdk.ConstructObject(Class="AttributePresentationDefinition", Outer=new_obj, Name=f"AttributePresentationDefinition_{1000 + number}", Template=Presentation) unrealsdk.KeepAlive(new_presentation) new_presentation.ObjectFlags.B |= 4 new_custom_presentations.append(new_presentation) new_obj.SkillEffectPresentations = new_custom_presentations
def behavior_attribute_effect_helper(new_obj: unrealsdk.UObject) -> None: if new_obj.AttributeEffect: new_effect = unrealsdk.ConstructObject(Class=new_obj.AttributeEffect.Class, Outer=new_obj, Name=f"{new_obj.AttributeEffect.Name}_1", Template=new_obj.AttributeEffect) unrealsdk.KeepAlive(new_effect) new_effect.ObjectFlags.B |= 4 new_obj.AttributeEffect = new_effect if new_effect == unrealsdk.FindClass("SkillDefinition"): bpd_copy_helper(new_effect) skill_constraints_helper(new_effect)
def __init__(self) -> None: unrealsdk.LoadPackage("GD_Mercenary_Streaming_SF") self.NumWeapObj = unrealsdk.FindObject( "NumberWeaponsEquippedExpressionEvaluator", "GD_Mercenary_Skills.ActionSkill.Skill_Gunzerking:ExpressionTree_0.NumberWeaponsEquippedExpressionEvaluator_0" ) unrealsdk.KeepAlive(self.NumWeapObj) if self.NumWeapObj is None: del self.SettingsInputs["Enter"] self.WeaponMap = {}
def OnCreate(caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct) -> bool: all_parts: DefDataTuple if caller.Class.Name == "WillowWeapon": all_parts = expand_weapon_definition_data(caller.DefinitionData) else: all_parts = expand_item_definition_data(caller.DefinitionData) for part in all_parts: if not isinstance(part, unrealsdk.UObject): continue unrealsdk.KeepAlive(part) return True
def behavior_activate_skill_helper(new_obj: unrealsdk.UObject) -> None: if new_obj.SkillToActivate: name = bl2tools.get_obj_path_name(new_obj) new_name = f'{name.split(":")[0].split("_")[-1]}_Skill_{name.split("_")[-1]}' new_skill = unrealsdk.ConstructObject(Class=new_obj.SkillToActivate.Class, Outer=new_obj.SkillToActivate.Outer, Name=new_name, Template=new_obj.SkillToActivate) unrealsdk.KeepAlive(new_skill) new_skill.ObjectFlags.B |= 4 new_obj.SkillToActivate = new_skill bpd_copy_helper(new_skill)
def skill_constraints_helper(new_obj: unrealsdk.UObject) -> None: number = 1000 for i, constraint in enumerate(new_obj.SkillConstraints): if constraint.Evaluator: obj = constraint.Evaluator new_constraint = unrealsdk.ConstructObject(Class=obj.Class, Outer=new_obj, Name=f"{obj.Name}_{number}", Template=obj) unrealsdk.KeepAlive(new_constraint) new_constraint.ObjectFlags.B |= 4 new_obj.SkillConstraints[i].Evaluator = new_constraint evaluator_expression_helper(new_constraint) else: for j, obj in enumerate(constraint.EvaluatorDefinitions): new_constraint = unrealsdk.ConstructObject(Class=obj.Class, Outer=new_obj, Name=f"{obj.Name}_{number}", Template=obj) unrealsdk.KeepAlive(new_constraint) new_constraint.ObjectFlags.B |= 4 new_obj.SkillConstraints[i].EvaluatorDefinitions[j] = new_constraint evaluator_expression_helper(new_constraint) number += 1
def inv_partlist_helper(obj: unrealsdk.UObject, new_balance: unrealsdk.UObject) -> None: if obj.PartListCollection: part_list = obj.PartListCollection if obj.PathName(part_list).rsplit(".", 1)[0] == obj.PathName(obj).rsplit(".", 1)[0]: new_name = f"Parts_{new_balance.Name}" else: new_name = new_balance.Name new_part_list = unrealsdk.ConstructObject(Class="ItemPartListCollectionDefinition", Outer=part_list.Outer, Name=new_name, Template=part_list) unrealsdk.KeepAlive(new_part_list) new_part_list.ObjectFlags.B |= 4 new_balance.PartListCollection = new_part_list
def CreateIcons(self) -> None: if self.HealthIcon is not None and self.AmmoIcon is not None: return HEALTH_NAME = "Icon_RefillHealth" AMMO_NAME = "Icon_RefillAmmo" # Incase you're re-execing the file and running a new instance self.HealthIcon = unrealsdk.FindObject( "InteractionIconDefinition", f"GD_InteractionIcons.Default.{HEALTH_NAME}") self.AmmoIcon = unrealsdk.FindObject( "InteractionIconDefinition", f"GD_InteractionIcons.Default.{AMMO_NAME}") baseIcon = unrealsdk.FindObject( "InteractionIconDefinition", "GD_InteractionIcons.Default.Icon_DefaultUse") if self.HealthIcon is None: self.HealthIcon = unrealsdk.ConstructObject(Class=baseIcon.Class, Outer=baseIcon.Outer, Name=HEALTH_NAME, Template=baseIcon) unrealsdk.KeepAlive(self.HealthIcon) self.HealthIcon.Icon = 3 self.HealthIcon.Action = "UseSecondary" self.HealthIcon.Text = "REFILL HEALTH" if self.AmmoIcon is None: self.AmmoIcon = unrealsdk.ConstructObject(Class=baseIcon.Class, Outer=baseIcon.Outer, Name=AMMO_NAME, Template=baseIcon) unrealsdk.KeepAlive(self.AmmoIcon) self.AmmoIcon.Icon = 7 self.AmmoIcon.Action = "UseSecondary" self.AmmoIcon.Text = "REFILL AMMO"
def weapon_partlist_helper(obj: unrealsdk.UObject, new_wpn_balance: unrealsdk.UObject) -> None: """ This Functions purpose is it to easily create New PartLists to work with. If one constructs a new WeaponBalanceDefinition this function gets called and constructs its new PartLists The new WeaponPartListCollection name will be "PartList" The new RuntimePartListCollection name will be "WeaponPartListCollectionDefinition_1000" """ part_list = obj.WeaponPartListCollection new_part_list = unrealsdk.ConstructObject(Class="WeaponPartListCollectionDefinition", Outer=new_wpn_balance, Name="PartList", Template=part_list) unrealsdk.KeepAlive(new_part_list) new_part_list.ObjectFlags.B |= 4 runtime_part_list = obj.RuntimePartListCollection new_runtime_part_list = unrealsdk.ConstructObject(Class="WeaponPartListCollectionDefinition", Outer=new_wpn_balance, Name="WeaponPartListCollectionDefinition_1000", Template=runtime_part_list) unrealsdk.KeepAlive(new_runtime_part_list) new_runtime_part_list.ObjectFlags.B |= 4 new_wpn_balance.WeaponPartListCollection = new_part_list new_wpn_balance.RuntimePartListCollection = new_runtime_part_list
def custom_presentation_helper(obj: unrealsdk.UObject, new_name_part: unrealsdk.UObject) -> None: """ This function tries to copy the CustomPresentations from the old template object to the new constructed "WeaponNamePartDefinition". """ new_custom_presentations = [] for number, Presentation in enumerate(obj.CustomPresentations): new_presentation = unrealsdk.ConstructObject(Class="AttributePresentationDefinition", Outer=new_name_part, Name=f"AttributePresentationDefinition_{1000 + number}", Template=Presentation) unrealsdk.KeepAlive(new_presentation) new_presentation.ObjectFlags.B |= 4 new_custom_presentations.append(new_presentation) new_name_part.CustomPresentations = new_custom_presentations
def population_definition_helper(new_obj: unrealsdk.UObject, template_obj: unrealsdk.UObject) -> None: counter = 1000 spawn_factories = [] for l in template_obj.ActorArchetypeList: factory = l.SpawnFactory new = unrealsdk.ConstructObject(Class=factory.Class, Outer=new_obj, Name=f"{new_obj.name}_{counter}", Template=template_obj) counter += 1 unrealsdk.KeepAlive(new) new.ObjectFlags.B |= 4 spawn_factories.append(new) new_obj.ActorArchetypeList = [(x, (1, None, None, 1), (0, None, None, 0), False, False) for x in spawn_factories]
def handle_keep_alive(args: argparse.Namespace) -> None: match = re_obj_name.match(args.object) if match is None: unrealsdk.Log(f"Unable to parse object name {args.object}") return klass = match.group("class") or "Object" name = match.group("fullname") obj = unrealsdk.FindObject(klass, name) if obj is None: unrealsdk.Log(f"Unable to find object {args.object}") return unrealsdk.KeepAlive(obj)
def skill_presentation_helper(self, cloned_obj, new_obj): new_custom_presentations = [] number = 0 for Presentation in cloned_obj.SkillEffectPresentations: new_presentation = unrealsdk.ConstructObject( Class="AttributePresentationDefinition", Outer=new_obj, Name="AttributePresentationDefinition_100" + str(number), SetFlags=0x83, Template=Presentation) unrealsdk.KeepAlive(new_presentation) number += 1 new_custom_presentations.append(new_presentation) new_obj.SkillEffectPresentations = new_custom_presentations
def on_any_impact_helper(new_obj: unrealsdk.UObject) -> None: if new_obj.OnAnyImpact: new_on_any_impact = [] counter = 0 for behavior in new_obj.OnAnyImpact: new_behavior = unrealsdk.ConstructObject(Class=behavior.Class, Outer=new_obj, Name=f"{behavior.Name}_{counter}", Template=behavior) counter += 1 unrealsdk.KeepAlive(new_behavior) new_behavior.ObjectFlags.B |= 4 new_on_any_impact.append(new_behavior) if behavior.Class == unrealsdk.FindClass("Behavior_AttributeEffect"): behavior_attribute_effect_helper(new_behavior) new_obj.OnAnyImpact = new_on_any_impact
def bpd_helper(new_bpd: unrealsdk.UObject) -> None: counter = 0 for Sequence in new_bpd.BehaviorSequences: for Data in Sequence.BehaviorData2: if Data.Behavior: new_behavior = unrealsdk.ConstructObject(Class=Data.Behavior.Class, Outer=new_bpd, Name=f"{Data.Behavior.Name}_{counter}", Template=Data.Behavior) unrealsdk.KeepAlive(new_behavior) new_behavior.ObjectFlags.B |= 4 Data.Behavior = new_behavior counter += 1 if Data.Behavior.Class == unrealsdk.FindClass("Behavior_AttributeEffect"): behavior_attribute_effect_helper(new_behavior) elif Data.Behavior.Class == unrealsdk.FindClass("Behavior_ActivateSkill"): behavior_activate_skill_helper(new_behavior)
def projectile_body_composition_helper(template_obj: unrealsdk.UObject, new_obj: unrealsdk.UObject) -> None: for i, data_union in enumerate(template_obj.BodyComposition.Attachments): if data_union.Data.ComponentData.Component: template = data_union.Data.ComponentData.Component new_comp = unrealsdk.ConstructObject(Class=template.Class, Outer=new_obj, Name=f"{template.Name}_{i}", Template=template) unrealsdk.Log(bl2tools.get_obj_path_name(new_comp)) unrealsdk.KeepAlive(new_comp) if new_comp: new_comp.ObjectFlags.B |= 4 try: unrealsdk.Log(new_obj.BodyComposition.Attachments) new_obj.BodyComposition.Attachments[i].Data.ComponentData.Component = new_comp unrealsdk.Log("works") except Exception as e: unrealsdk.Log(f"Exception: {repr(e)}") unrealsdk.Log(e)
def keep_loaded(self) -> None: """ Small helper function for easily keeping objects loaded. "#" defines what Package to load, "-" are comments. Searches for any text file with the custom ending ".loaded" and tries to keep the objects listet in the file loaded. """ for file in self.l_files: with open(file, "r") as TemplateFile: for line in TemplateFile: if not line.split() or line[0] == "-": continue elif line[0] == "#": package = line[1:].strip() unrealsdk.LoadPackage(package) else: unrealsdk.KeepAlive(unrealsdk.FindObject("Object", line.strip()))
def custom_presentation_helper(self, obj, newNamePart): """ This function tries to copy the CustomPresentations from the old template object to the new constructed "WeaponNamePartDefinition". """ new_custom_presentations = [] number = 0 for Presentation in obj.CustomPresentations: new_presentation = unrealsdk.ConstructObject( Class="AttributePresentationDefinition", Outer=newNamePart, Name="AttributePresentationDefinition_100" + str(number), SetFlags=0x83, Template=Presentation) unrealsdk.KeepAlive(new_presentation) number += 1 new_custom_presentations.append(new_presentation) newNamePart.CustomPresentations = new_custom_presentations
def handle_clone(args: argparse.Namespace) -> None: src_match = re_obj_name.match(args.base) if src_match is None: unrealsdk.Log(f"Unable to parse object name {args.base}") return src_class = src_match.group("class") or "Object" src_fullname = src_match.group("fullname") src_object = unrealsdk.FindObject(src_class, src_fullname) if src_object is None: unrealsdk.Log(f"Unable to find object {args.base}") return dst_match = re_obj_name.match(args.clone) if dst_match is None: unrealsdk.Log(f"Unable to parse object name {args.clone}") return dst_class = dst_match.group("class") or "Object" if dst_class != "Object" and dst_class != src_class: unrealsdk.Log( f"Cannot clone object of class {src_class} as class {dst_class}") return dst_outer = dst_match.group("outer") dst_outer_object = None if dst_outer: dst_outer_object = unrealsdk.FindObject("Object", dst_outer) if dst_outer_object is None: unrealsdk.Log(f"Unable to find outer object {dst_outer}") return dst_name = dst_match.group("name") cloned = unrealsdk.ConstructObject(Class=src_object.Class, Outer=dst_outer_object, Name=dst_name, Template=src_object) if cloned is not None: unrealsdk.KeepAlive(cloned)
def __init__(self) -> None: # Hopefully I can remove this in a future SDK update self.Author += "\nVersion: " + str(self.Version) # type: ignore unrealsdk.LoadPackage("GD_Mercenary_Streaming_SF") obj = unrealsdk.FindObject( "NumberWeaponsEquippedExpressionEvaluator", "GD_Mercenary_Skills.ActionSkill.Skill_Gunzerking:ExpressionTree_0.NumberWeaponsEquippedExpressionEvaluator_0" ) # Almost certainly because you tried to load this in TPS if obj is None: unrealsdk.Log( "[Onezerker] Unable to find NumberWeaponsEquiped object, assuming loaded in TPS" ) self.Name = f"<font color='#ff0000'>{self.Name}</font>" # type: ignore self.Description += "\n<font color='#ff0000'>Incompatible with TPS</font>" # type: ignore self.SettingsInputs = {} self.NumWeapObj = None else: unrealsdk.KeepAlive(obj) self.NumWeapObj = obj self.WeaponMap = {}