Beispiel #1
0
def fixCAID(item, indexes):
    if not item.ConsolidatedAttributeInitData:
        return
    # I can't call len() on these arrays meaning I need to manually count it :(
    index = 0
    # Also going to reconstruct it as a string as we go
    newValue = "("
    for BVC in item.ConsolidatedAttributeInitData:
        if index in indexes:
            # Nothing we care about uses BVA/ID but just to be sure
            if BVC.BaseValueAttribute != None or BVC.InitializationDefinition != None:
                bl2sdk.Log("BVA or ID was set in CAID")
                bl2sdk.Log("BVA: " + str(BVC.BaseValueAttribute))
                bl2sdk.Log("ID: " + str(BVC.InitializationDefinition))
            # I don't really think anything uses a scale but just in case
            if BVC.BaseValueConstant * BVC.BaseValueScaleConstant < MIN_ACCEPTABLE_LEVEL:
                BVC.BaseValueConstant = MIN_ACCEPTABLE_LEVEL
                BVC.BaseValueScaleConstant = 1
        index += 1
        newValue += parseBVCTuple(BVC) + ","
    # If we had a CAID array but it was empty
    if index == 0:
        return
    placeCommand(
        Command(toFullName(item), "ConsolidatedAttributeInitData",
                newValue[:-1] + ")"))
Beispiel #2
0
def invPartList(item):
    if str(item) in BLACKLIST or str(item) in modified:
        return
    itemType = str(item).split(" ")[0]
    allParts = set()
    if itemType == "ItemPartListCollectionDefinition":
        allParts = {
            "AlphaPartData", "BetaPartData", "GammaPartData", "DeltaPartData",
            "EpsilonPartData", "ZetaPartData", "EtaPartData", "ThetaPartData",
            "MaterialPartData"
        }
    elif itemType == "WeaponPartListCollectionDefinition":
        allParts = {
            "BodyPartData", "GripPartData", "BarrelPartData", "SightPartData",
            "StockPartData", "ElementalPartData", "Accessory1PartData",
            "Accessory2PartData", "MaterialPartData"
        }
    else:
        bl2sdk.Log(f"Unknown item type on {str(item)}")
        return

    levelIndexes = set()
    for part in allParts:
        weighted = getattr(item, part).WeightedParts
        if weighted != None:
            for wPart in weighted:
                if wPart.MaxGameStageIndex:
                    levelIndexes.add(wPart.MaxGameStageIndex)
    fixCAID(item, levelIndexes)
Beispiel #3
0
def HookBindCurrentSelection(caller: UObject, function: UFunction,
                             params: FStruct) -> bool:
    selectedKeyBind = caller.KeyBinds[caller.CurrentKeyBindSelection]
    if selectedKeyBind.Tag in seperatorNames:
        return False
    selectedBinding = None

    oldKey = selectedKeyBind.CurrentKey
    newKey = params.Key

    DoInjectedCallNext()
    caller.BindCurrentSelection(newKey)

    if newKey == oldKey:
        return False

    if selectedKeyBind.Tag in GameInputBinding.ByTag:
        selectedBinding = GameInputBinding.ByTag[selectedKeyBind.Tag]
        if selectedBinding.Key in GameInputBinding.ByKey:
            del GameInputBinding.ByKey[selectedBinding.Key]

    if newKey in GameInputBinding.ByKey:
        exchangedBinding = GameInputBinding.ByKey[newKey]
        del GameInputBinding.ByKey[newKey]

        exchangedBinding.Key = oldKey
        if oldKey != "None":
            GameInputBinding.ByKey[oldKey] = exchangedBinding
        try:
            exchangedBinding.Mod.GameInputRebound(exchangedBinding.Name,
                                                  oldKey)
        except:
            bl2sdk.Log("Error notifying %s of key rebind." %
                       exchangedBinding.Mod.Name)

    if selectedBinding != None:
        selectedBinding.Key = newKey
        GameInputBinding.ByKey[newKey] = selectedBinding
        selectedBinding.Mod.GameInputRebound(selectedBinding.Name, newKey)

    translationContext = GetEngine().GamePlayers[0].GetTranslationContext()

    for keyBind in caller.KeyBinds:
        if keyBind.Tag in GameInputBinding.ByTag:
            binding = GameInputBinding.ByTag[keyBind.Tag]
            keyBind.CurrentKey = binding.Key
        keyBind.Object.SetString(
            "value",
            GetFixedLocalizedKeyName(caller, keyBind.CurrentKey),
            translationContext,
        )

    caller.ControllerMappingClip.InvalidateKeyData()
    return False
Beispiel #4
0
 def InjectSkills(caller: UObject, function: UFunction,
                  params: FStruct) -> bool:
     if not self.Seed:
         self.Seed = random.randrange(sys.maxsize)
         bl2sdk.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
Beispiel #5
0
    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
Beispiel #6
0
def log(s):
    s = str(s)
    if not s.endswith("\n"):
        s += "\n"
    bl2sdk.Log(s)