示例#1
0
    def GetHealthCost(self, pawn: unrealsdk.UObject, vendor: unrealsdk.UObject) -> int:
        if pawn.GetHealth() == pawn.GetMaxHealth():
            return 0

        # Not sure how this'd happen but just in case
        if vendor not in self.VialCosts:
            return 0

        # Again going to assume you haven't modded how much a vial heals
        full_heal_cost = 4 * self.VialCosts[vendor]
        missing_health = 1 - (pawn.GetHealth() / pawn.GetMaxHealth())

        return max(1, int(full_heal_cost * missing_health))
示例#2
0
        def TakeDamage(caller: unrealsdk.UObject,
                       function: unrealsdk.UFunction,
                       params: unrealsdk.FStruct) -> bool:
            PC = unrealsdk.GetEngine().GamePlayers[0].Actor

            if params.InstigatedBy != PC:
                return True

            if not self.IsOn:
                return True

            game = unrealsdk.FindAll("WillowCoopGameInfo")[-1]
            if game.IsFriendlyFire(caller, params.InstigatedBy.Pawn):
                return True

            caller.SetShieldStrength(0)
            # Try set the health to 1 so that your shot kills them, giving xp
            # Only do it if they have more than 1 health though, so that you don't get stuck in a
            #  loop if you somehow deal less than 1 damage
            if caller.GetHealth() > 1:
                caller.SetHealth(1)
            else:
                caller.SetHealth(0)

            return True
示例#3
0
    def GetHealthCost(self, Pawn: unrealsdk.UObject,
                      Vendor: unrealsdk.UObject) -> int:
        if Pawn.GetHealth() == Pawn.GetMaxHealth():
            return 0

        vial = None
        for item in unrealsdk.FindAll("WillowUsableItem"):
            if item.Owner != Vendor:
                continue
            if item.DefinitionData is None or item.DefinitionData.ItemDefinition is None:
                continue
            name = item.DefinitionData.ItemDefinition.Name
            if name == "BuffDrink_HealingInstant":
                vial = item
                break
        else:
            return 0

        # Again going to assume you haven't modded how much a vial heals
        full_heal_cost = 4 * Vendor.GetSellingPriceForInventory(
            vial, Pawn.Controller, 1)
        missing_health = 1 - (Pawn.GetHealth() / Pawn.GetMaxHealth())

        return max(1, int(full_heal_cost * missing_health))