MemeMayhem / ModExamples

11 stars 3 forks source link

属性溢出了,怎么办 #96

Closed dfgf123 closed 1 month ago

dfgf123 commented 1 month ago

最大值设置3,但溢出了 觉得主要是3.神器和4.属性创建处错误

1.人物 2.弹药 3.神器 4.属性创建 5.能力

1.人物

    Api:CopyCharacter("", {      
        id = "taffy",
        display_name = "仙人·塔菲",
        short_description = "塔菲不唐喵,不唐,塔菲不唐喵~",
        icon = DCEI.Texture("taffy"),
        icon_low_resolution = DCEI.Texture("taffy_s"), 
        icon_high_resolution = DCEI.Texture("taffy_l"), 
        unit = DCEI.Unit("COMBAT Unit First Mod Character"),
        attack_ids = {
            "bangbang",
            "bangbang",
            "bangbang",
        },
        attributes = {
            health_per_second= 22,
            health_maximum= 2222,
        },
        perks = {
            "bangbang",
        },
        relics = {
            "qi",
        },
    })

2.弹药

    Api:RegisterMissile("bangbang", {
        id = "bangbang",
        display_name = "22~66随机伤害",
        flavor_text = "糖砸到小伤,棍子戳到就死了",
        icon= DCEI.Texture("bangbang"),
        missile = DCEI.SimpleUnit("bangbang"),
        damage = function(attack_data, caster)
            return math.random(22,66)

        end,

    })

3.神器

    Api:RegisterRelic("qi", {
        id = "qi",
        display_name = "糖能量(炼气期)",
        description = "增加1防御力和攻击力。  每次攻击敌人临时 1回血和修炼进度",
        flavor_text = "塔菲会修仙喵,塔菲不是飞舞喵",
        icon = DCEI.Texture("qi"),
        rarity = "permanent",
        modify_attributes = {
            attack = 1,
            block = 1,
        }
    }, function(combat_unit)
        local name = "my_power_cookie"
        combat_unit.Attack:RegisterOnMissileHitCallback(name, function(level, attack_data, caster, target)
            for i = 1, level do    --临时加
                combat_unit:ModifyAttribute("health_per_second", 1, false)
                combat_unit:ModifyAttribute("xiuwei", 1, false)
            end
            combat_unit.run_instance:ModifySavedPerkDataAttributes("xiuwei", 1)  --永久加
        end)
        combat_unit.Attack:RegisterOnMissileImpactCallback(name, function(level, attack_data, caster, target)
            local old_xiuwei = caster:GetBoundedAttribute("xiuwei")
            local new_xiuwei = old_xiuwei + 1

            if new_xiuwei >= xiuweimax then
                new_xiuwei = 0
                xiuwei = 0
                -- Add emojis to the persistent deck.
                local deck_size = #caster.Attack:GetEmojiDeck()
                for i = 1, level do
                    caster.run_instance:ModifySavedPerkDataEmojis("bangbang", deck_size + i)
                end

                -- Add emojis to the combat deck (not persisted).
                caster.Attack:AddEmojiToDeck("bangbang", level)
                caster:PlayAwardEmojiAnimation("bangbang", level)
            end

            caster:ModifyAttribute("custom_attribute_rock_quest", new_xiuwei - old_xiuwei)
            caster.run_instance:SetSavedPerkDataAttributes("custom_attribute_rock_quest", new_xiuwei)
        end)
    end)

4.属性

    Api:RegisterAttribute({
        id = "xiuwei",
        display_name = "修炼进度",
        description = "85筑基  260金丹  600元婴   1100化神   2900练虚   4200大乘 ",
        icon = DCEI.Texture("xiuwei"),
        display_type = Api.DisplayType.Integer,
        is_neutral = true, -- if true, font color will always be white
        flavor_text = "好!练!",
        display_requirements = {
            is_hero = true, -- only show for hero
            perk = "custom_perk_rock_quest", -- only show if has this perk
            default_value = 0,
            max = xiuweimax -- for visual only, you need to keep current value <= max
        },
    })

5.能力

[^5]:

    Api:RegisterPerk("bangbang", {
        id = "bangbang",
        display_name = "棒棒糖",
        perk_type = "perk",
        description = "获得一根棒棒糖(*^▽^*)",
        icon = DCEI.Texture("bangbang"),
        --perk_type = "missile",
        rarity = "rare",
        attacks = {
            bangbang = 1,
        },
    })
end)
fx013 commented 1 month ago

这是从这个示例改的?https://github.com/MemeMayhem/ModExamples/tree/main/Medium-PerkQuest

你运行这个示例mod会有同样的问题吗?

dfgf123 commented 1 month ago

这是从这个示例改的?https://github.com/MemeMayhem/ModExamples/tree/main/Medium-PerkQuest

你运行这个示例mod会有同样的问题吗?

是从这个改过来的,没运行过示例

dfgf123 commented 1 month ago

这是从这个示例改的?https://github.com/MemeMayhem/ModExamples/tree/main/Medium-PerkQuest

你运行这个示例mod会有同样的问题吗?

        if new_xiuwei >= xiuweimax then
            new_xiuwei = 0
            combat_unit:ModifyAttribute("xiuwei", -xiuweimax+1, false)
            combat_unit.run_instance:ModifySavedPerkDataAttributes("xiuwei", -xiuweimax+1) 

            -- Add emojis to the persistent deck.
            local deck_size = #caster.Attack:GetEmojiDeck()
            for i = 1, level do
                caster.run_instance:ModifySavedPerkDataEmojis("bangbang", deck_size + i)
            end

            -- Add emojis to the combat deck (not persisted).
            caster.Attack:AddEmojiToDeck("bangbang", level)
            caster:PlayAwardEmojiAnimation("bangbang", level)
        end

OK了