GLOBAL.setmetatable(env, {__index = function(t, k) return GLOBAL.rawget(GLOBAL, k) end}) PrefabFiles = { "wormwood_seeds", "wormwood_whip_plus", } Assets={ Asset("IMAGE", "images/inventoryimages/wormwood_seeds.tex"), Asset("ATLAS", "images/inventoryimages/wormwood_seeds.xml"), Asset("IMAGE", "images/wormwood_whip_plus.tex"), Asset("ATLAS", "images/wormwood_whip_plus.xml"), } --真正的种子侦探 require "prefabs/veggies" local PLANT_DEFS = require("prefabs/farm_plant_defs").PLANT_DEFS local WORMWOOD_SEEDS = Action{ priority = 999, } table.insert(TUNING.GAMEMODE_STARTING_ITEMS.DEFAULT.WORMWOOD, "armor_bramble") table.insert(TUNING.GAMEMODE_STARTING_ITEMS.DEFAULT.WORMWOOD, "compostwrap") table.insert(TUNING.GAMEMODE_STARTING_ITEMS.DEFAULT.WORMWOOD, "compostwrap") table.insert(TUNING.GAMEMODE_STARTING_ITEMS.DEFAULT.WORMWOOD, "compostwrap") WORMWOOD_SEEDS.id = "WORMWOOD_SEEDS" WORMWOOD_SEEDS.str = "辨识" WORMWOOD_SEEDS.fn = function(act) local seeds = act.target and act.target:IsValid() and act.target.prefab == "seeds" if seeds and act.doer then local x,y,z = act.target.Transform:GetWorldPosition() local emote_fx = SpawnPrefab("emote_fx") emote_fx.Transform:SetScale(0.5,0.5,0.5) emote_fx.Transform:SetPosition(x,y+0.5,z) for i = 1,act.target.components.stackable:StackSize() do --20%出杂草 local weed = false if math.random() < TUNING.FARM_PLANT_RANDOMSEED_WEED_CHANCE then weed = true end --官方随机加权代码 local season = TheWorld.state.season local weights = {} local season_mod = TUNING.SEED_WEIGHT_SEASON_MOD for k, v in pairs(VEGGIES) do weights[k] = v.seed_weight * ((PLANT_DEFS[k] and PLANT_DEFS[k].good_seasons[season]) and season_mod or 1) end local RTseed_prefab = weighted_random_choice(weights).."_seeds" local RTseed = SpawnPrefab(RTseed_prefab) if RTseed and not weed then RTseed.Transform:SetPosition(act.target.Transform:GetWorldPosition()) RTseed.components.inventoryitem:InheritMoisture(TheWorld.state.wetness, TheWorld.state.iswet) act.doer.components.inventory:GiveItem(RTseed,nil,RTseed:GetPosition()) act.doer.components.talker:Say("新的宝宝") end if weed then local zc = SpawnPrefab("wormwood_seeds") zc.Transform:SetPosition(act.target.Transform:GetWorldPosition()) zc.components.inventoryitem:InheritMoisture(TheWorld.state.wetness, TheWorld.state.iswet) act.doer.components.inventory:GiveItem(zc,nil,zc:GetPosition()) act.doer.components.talker:Say("新的宝宝") end act.doer.SoundEmitter:PlaySound("dontstarve/common/plant") act.target.components.stackable:Get(1):Remove() --删除这一个种子 end return true end end AddAction(WORMWOOD_SEEDS) AddPrefabPostInit("bramblefx_armor_upgrade", function(inst) inst.canhitplayers = false end) local function oneat(inst, data) local food = data.food if food and food.components.edible then local hungerbonus = food.components.edible:GetHunger() --延长3阶段时的开花时间 if inst.components.bloomness and inst.components.bloomness:GetLevel() >= 3 and hungerbonus > 0 then inst.components.health:StartRegen(1, 7) local BL = 1 if inst.components.skilltreeupdater and inst.components.skilltreeupdater:IsActivated("wormwood_blooming_max_upgrade") then BL = 1.3 --启用花朵力量技能提高30%恢复开花值效率 end --如果吃掉这个食物后自身饱食度>30%,这个食物所恢复的饱食度的300%转变为开花值 inst:DoTaskInTime(0,function() if hungerbonus > 0 and inst.components.hunger:GetPercent() >= 0.3 then inst.components.bloomness:Fertilize((hungerbonus*0.3)*BL) end end) end end end AddPrefabPostInit("wormwood", function(inst) inst:AddTag("quagmire_fasthands") --快采 if not TheWorld.ismastersim then return end inst:ListenForEvent("oneat", oneat) inst:ListenForEvent("finishedwork", function(inst,data) --锤击巨大作物额外收获 if data.action and data.target then if math.random() <= 0.15 then if data.target.prefab == "genesis_plantmeat_oversized" then --专门为创世纪的叶肉作物提供额外写法,令人感慨 data.target.components.lootdropper:SpawnLootPrefab("plantmeat") elseif string.sub(data.target.prefab, -10, -1) == "_oversized" then local DLW = string.gsub(data.target.prefab, "_oversized$", "") data.target.components.lootdropper:SpawnLootPrefab(DLW) elseif data.target.prefab == "weed_ivy" or data.target.prefab == "weed_tillweed" or data.target.prefab == "weed_firenettle" or data.target.prefab == "weed_forgetmelots" then --挖杂草不掉San,特殊台词 inst.components.sanity:DoDelta(10) inst:DoTaskInTime(0,function() if math.random() <= 0.5 then inst.components.talker:Say("别欺负其他朋友,请你离开。") else inst.components.talker:Say("去别的地方呆着。") end end) end end end end) inst:DoPeriodicTask(10, function() if inst.components.health:GetPercent() >= 0.8 and (inst.replica.inventory and inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.BODY) and inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.BODY).prefab == "armor_lunarplant_husk") then if not inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.BODY):HasTag("broken") and inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.BODY).components.armor:GetPercent() < 1 then --护甲耐久未满才会触发,坏掉不触发 inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.BODY).components.armor:Repair(14) end end if inst.components.health:GetPercent() >= 0.8 and (inst.replica.inventory and inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) and inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.HANDS).prefab == "wormwood_whip_plus") then if not inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.HANDS):HasTag("broken") and inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.HANDS).components.finiteuses:GetPercent() < 1 then --耐久未满才会触发 inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.HANDS).components.finiteuses:Repair(4) end end end) end) AddPrefabPostInit("wormwood", function(inst) if not TheWorld.ismastersim then return inst end inst:DoPeriodicTask(0.25, function(inst) local range = ( (inst.components.bloomness:GetLevel()*3) + 4) -- 每个开花等级增加3照顾范围 local x, y, z = inst.Transform:GetWorldPosition() for _, v in pairs(TheSim:FindEntities(x, y, z, range, {"tendable_farmplant"})) do if v.components.farmplanttendable then v.components.farmplanttendable:TendTo(inst) inst.components.sanity:DoDelta(2.5) --每次照料恢复2.5理智 --当压力值等于0时,每次照料随机加速138~140秒时间生长 if v.components.farmplantstress and v.components.farmplantstress.stress_points == 0 and v.components.growable then v.components.growable:ExtendGrowTime( -(math.random(138,140)) ) end local x1, y1, z1 = v.Transform:GetWorldPosition() if TheWorld.components.farming_manager and TheWorld.Map:IsFarmableSoilAtPoint(x1,y1,z1) then --这个点位处于耕地才会触发降低压力值 if v.components.farmplantstress and v.components.farmplantstress.stress_points >= 1 then v.components.farmplantstress.stress_points = v.components.farmplantstress.stress_points - 1 SpawnPrefab("emote_fx").Transform:SetPosition(v.Transform:GetWorldPosition()) end end end end end) end) --压键种子侦探 AddComponentAction("INVENTORY", "deployable", function(inst, doer, actions, right) if doer.prefab == "wormwood" and inst.prefab == "seeds" then if doer.components.playercontroller and doer.components.playercontroller:IsControlPressed(GLOBAL.CONTROL_FORCE_INSPECT) then table.insert(actions, ACTIONS.WORMWOOD_SEEDS_X) end end end) local WORMWOOD_SEEDS_X = Action({priority = 2,mount_valid=true}) WORMWOOD_SEEDS_X.str = "辨识" WORMWOOD_SEEDS_X.id = "WORMWOOD_SEEDS_X" WORMWOOD_SEEDS_X.fn = function(act) local seeds = act.invobject and act.invobject:IsValid() and act.invobject.prefab == "seeds" if seeds and act.doer then local x,y,z = act.doer.Transform:GetWorldPosition() local emote_fx = SpawnPrefab("emote_fx") emote_fx.Transform:SetScale(0.5,0.5,0.5) emote_fx.Transform:SetPosition(x,y+0.5,z) for i = 1,act.invobject.components.stackable:StackSize() do --20%出杂草 local weed = false if math.random() < TUNING.FARM_PLANT_RANDOMSEED_WEED_CHANCE then weed = true end --官方随机加权代码 local season = TheWorld.state.season local weights = {} local season_mod = TUNING.SEED_WEIGHT_SEASON_MOD for k, v in pairs(VEGGIES) do weights[k] = v.seed_weight * ((PLANT_DEFS[k] and PLANT_DEFS[k].good_seasons[season]) and season_mod or 1) end local RTseed_prefab = weighted_random_choice(weights).."_seeds" local RTseed = SpawnPrefab(RTseed_prefab) if RTseed and not weed then RTseed.Transform:SetPosition(act.invobject.Transform:GetWorldPosition()) RTseed.components.inventoryitem:InheritMoisture(TheWorld.state.wetness, TheWorld.state.iswet) act.doer.components.inventory:GiveItem(RTseed,nil,RTseed:GetPosition()) act.doer.components.talker:Say("新的宝宝") end if weed then local zc = SpawnPrefab("wormwood_seeds") zc.Transform:SetPosition(act.invobject.Transform:GetWorldPosition()) zc.components.inventoryitem:InheritMoisture(TheWorld.state.wetness, TheWorld.state.iswet) act.doer.components.inventory:GiveItem(zc,nil,zc:GetPosition()) act.doer.components.talker:Say("新的宝宝") end act.doer.SoundEmitter:PlaySound("dontstarve/common/plant") act.invobject.components.stackable:Get(1):Remove() --删除这一个种子 end return true end end AddAction(WORMWOOD_SEEDS_X) for sg, client in pairs{ wilson = false, wilson_client = true } do AddStategraphActionHandler(sg, ActionHandler(ACTIONS.WORMWOOD_SEEDS_X, function(inst, action) if action.invobject.components.stackable then if action.invobject.components.stackable:StackSize() <= 5 then return "domediumaction" elseif action.invobject.components.stackable:StackSize() <= 10 then return "dolongaction" else return "dolongestaction" end else return "dolongaction" end end)) end --种子侦探 AddComponentAction("SCENE", "deployable", function(inst, doer, actions, right) if doer.prefab == "wormwood" and inst.prefab == "seeds" and right then table.insert(actions, ACTIONS.WORMWOOD_SEEDS) end end) --种子侦探 for sg, client in pairs{ wilson = false, wilson_client = true } do AddStategraphActionHandler(sg, ActionHandler(ACTIONS.WORMWOOD_SEEDS, function(inst, action) if action.target.components.stackable then if action.target.components.stackable:StackSize() <= 5 then return "domediumaction" elseif action.target.components.stackable:StackSize() <= 10 then return "dolongaction" else return "dolongestaction" end else return "dolongaction" end end)) end TUNING.ARMORBRAMBLE_DMG = 25 TUNING.WORMWOOD_ARMOR_BRAMBLE_RELEASE_SPIKES_HITCOUNT = 1 TUNING.ARMORBRAMBLE_DMG_PLANAR_UPGRADE = 35 AddPrefabPostInit("armor_lunarplant_husk", function(inst) if inst.components.armor then inst.components.armor:InitCondition(1450, 0.95) end end) AddRecipe("compostwrap", --添加物品的配方 {Ingredient("poop",5),Ingredient("spoiled_food",3),Ingredient("ash",3)}, RECIPETABS.WAR, TECH.NONE, --制作栏和解锁的科技(需要科学二本) nil, nil, nil,1,"plantkin") AddRecipe("armor_lunarplant_husk", --添加物品的配方 {Ingredient("armor_bramble",1),Ingredient("lunarplant_husk",1),Ingredient("purebrilliance",1)}, RECIPETABS.WAR, TECH.NONE, --制作栏和解锁的科技(需要科学二本) wormwood_whip_plus nil, nil, nil,1,"plantkin") AddRecipe("wormwood_whip_plus", --添加物品的配方 {Ingredient("stinger",8),Ingredient("livinglog",2),Ingredient("lunarplant_husk",2)}, RECIPETABS.WAR, TECH.NONE, nil, nil, nil,1,"plantkin","images/wormwood_whip_plus.xml", --配方的贴图(跟物品栏使用同一个贴图) "wormwood_whip_plus.tex")