GLOBAL.setmetatable(env, { __index = function(t, k) return GLOBAL.rawget(GLOBAL, k) end }) --GLOBAL 相关照抄 local leif_flag = GetModConfigData("leif_flag") local Recipes = { --树精守卫雕像 { name = "largechop_certificate_leif_idol", ingredient = { Ingredient("cutgrass", 3), Ingredient("livinglog", 2), Ingredient("nightmarefuel", 5) }, product = "leif_idol", builder_tag = "leif_idol_medal", level = TECH.NONE, filters = { "CHARACTER" }, }, --木板 { name = "largechop_certificate_log", ingredient = { Ingredient("log", 3) }, product = "boards", level = TECH.NONE, builder_tag = "log_medal", filters = { "CHARACTER" }, }, -- 硬木帽 { name = "largechop_certificate_woodcarvedhat", ingredient = { Ingredient("log", 6), Ingredient("pinecone", 1) }, product = "woodcarvedhat", level = TECH.NONE, builder_tag = "woodcarvedhat_medal", filters = { "CHARACTER" }, }, -- 木手杖 { name = "largechop_certificate_walking_stick", ingredient = { Ingredient("log", 3), Ingredient("pinecone", 1) }, product = "walking_stick", level = TECH.NONE, builder_tag = "walking_stick_medal", filters = { "CHARACTER" }, }, } for _, value in pairs(Recipes) do AddRecipe2( value.name, value.ingredient, value.level, { product = value.product, builder_tag = value.builder_tag }, value.filters ) end local function AddTag(owner) for _, value in pairs(Recipes) do if "leif_idol_medal" ~= value.builder_tag then owner:AddTag(value.builder_tag) end end end local function RemoveTag(owner) for _, value in pairs(Recipes) do if "leif_idol_medal" ~= value.builder_tag then owner:RemoveTag(value.builder_tag) end end end -- 对树精守卫加一倍伤害 -- flag 为 true 加100% false 加 41.41% local function AddTreeguardDamageBonus(inst, flag) local damagetypebonus = inst.components.damagetypebonus --TUNING.SKILLS.WOODIE.DAMAGE_BONUS_VS_TREEGUARDS 为 1+41.41% local num = flag and 2 or 1 local multiplier = flag and 2 or TUNING.SKILLS.WOODIE.DAMAGE_BONUS_VS_TREEGUARDS if damagetypebonus ~= nil then damagetypebonus:AddBonus("evergreens", inst, multiplier, "largechop_certificate_treeguard_bonus" .. num) end end local function RemoveTreeguardDamageBonus(inst, flag) local num = flag and 2 or 1 local damagetypebonus = inst.components.damagetypebonus if damagetypebonus ~= nil then damagetypebonus:RemoveBonus("evergreens", inst, "largechop_certificate_treeguard_bonus" .. num) end end -- 中级伐木勋章 AddPrefabPostInit("mediumchop_certificate", function(inst) if inst.components.equippable then local oldEquipFn = inst.components.equippable.onequipfn inst.components.equippable:SetOnEquip(function(inst, owner) oldEquipFn(inst, owner) if leif_flag then AddTreeguardDamageBonus(owner, false) end end) local oldOnunequipfn = inst.components.equippable.onunequipfn inst.components.equippable:SetOnUnequip(function(inst, owner) oldOnunequipfn(inst, owner) if leif_flag then RemoveTreeguardDamageBonus(owner, false) end end) end end) -- 高级伐木勋章 AddPrefabPostInit("largechop_certificate", function(inst) if inst.components.equippable then local oldEquipFn = inst.components.equippable.onequipfn inst.components.equippable:SetOnEquip(function(inst, owner) oldEquipFn(inst, owner) if leif_flag then AddTreeguardDamageBonus(owner, true) end if owner.prefab ~= "woodie" then AddTag(owner) -- 本源加成 树精守卫雕像 if HasOriginMedal(owner) then owner:AddTag("leif_idol_medal") end end end) local oldOnunequipfn = inst.components.equippable.onunequipfn inst.components.equippable:SetOnUnequip(function(inst, owner) oldOnunequipfn(inst, owner) if leif_flag then RemoveTreeguardDamageBonus(owner, true) end if owner.prefab ~= "woodie" then RemoveTag(owner) if HasOriginMedal(owner) then owner:RemoveTag("leif_idol_medal") end end end) end end)