[分享]饥荒联机版,支持局域网联机。

YN242-自动门(用木盔甲种自动门,进出自动开关)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二四二.自动门(用木盔甲种自动门,进出自动开关) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/armor_wood.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function OnDeploy (inst, pt) 7 local door1 = SpawnPrefab("armorwood") 8 door1.Transform:SetPosition(pt.x+0.55, pt.y, pt.z-0.55) 9 door1.AnimState:SetBank("winter_meter") 10 door1.AnimState:SetBuild("winter_meter") 11 door1.AnimState:SetPercent("meter", 1) 12 door1.Transform:SetScale(1, 0.7, 1) 13 MakeObstaclePhysics(door1, 0.48) 14 door1:RemoveComponent("inventoryitem") 15 door1:RemoveComponent("fuel") 16 door1:RemoveComponent("armor") 17 door1:RemoveComponent("equippable") 18 door1:RemoveComponent("burnable") 19 door1:RemoveComponent("propagator") 20 door1:RemoveComponent("deployable") 21 door1:RemoveTag("wood") 22 door1:AddComponent("workable") 23 door1.components.workable:SetWorkAction(ACTIONS.HAMMER) 24 door1.components.workable:SetWorkLeft(2) 25 door1.components.workable:SetOnFinishCallback(function(door1) 26 SpawnPrefab("collapse_big").Transform:SetPosition(door1.Transform:GetWorldPosition()) 27 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 28 door1:Remove() 29 end ) 30 door1:AddComponent( "playerprox" ) 31 door1.components.playerprox:SetDist(2,3) 32 door1.components.playerprox:SetOnPlayerNear(function(door1) 33 door1.Transform:SetScale(0.1, 0.7, 1) 34 door1.Physics:SetActive(false) 35 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") 36 end ) 37 door1.components.playerprox:SetOnPlayerFar(function(door1) 38 door1.Transform:SetScale(1, 0.7, 1) 39 door1.Physics:SetActive(true) 40 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") 41 end ) 42 door1.components.inspectable.getstatus = function(door1) 43 door1.Transform:SetScale(0.1, 0.7, 1) 44 door1.Physics:SetActive(false) 45 door1:DoTaskInTime(3, function(door1) 46 door1.Transform:SetScale(1, 0.7, 1) 47 door1.Physics:SetActive(true) 48 end ) 49 end 50 door1:AddTag("doors") 51 local door2 = SpawnPrefab("armorwood") 52 door2.Transform:SetPosition(pt.x-0.55, pt.y, pt.z+0.55) 53 door2.AnimState:SetBank("winter_meter") 54 door2.AnimState:SetBuild("winter_meter") 55 door2.AnimState:SetPercent("meter", 1) 56 door2.Transform:SetScale(1, 0.7, 1) 57 MakeObstaclePhysics(door2, 0.48) 58 door2:RemoveComponent("inventoryitem") 59 door2:RemoveComponent("fuel") 60 door2:RemoveComponent("armor") 61 door2:RemoveComponent("equippable") 62 door2:RemoveComponent("burnable") 63 door2:RemoveComponent("propagator") 64 door2:RemoveComponent("deployable") 65 door2:RemoveTag("wood") 66 door2:AddComponent("workable") 67 door2.components.workable:SetWorkAction(ACTIONS.HAMMER) 68 door2.components.workable:SetWorkLeft(2) 69 door2.components.workable:SetOnFinishCallback(function(door2) 70 SpawnPrefab("collapse_big").Transform:SetPosition(door2.Transform:GetWorldPosition()) 71 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 72 door2:Remove() 73 end ) 74 door2:AddComponent( "playerprox" ) 75 door2.components.playerprox:SetDist(2,3) 76 door2.components.playerprox:SetOnPlayerNear(function(door2) 77 door2.Transform:SetScale(0.1, 0.7, 1) 78 door2.Physics:SetActive(false) 79 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") 80 end ) 81 door2.components.playerprox:SetOnPlayerFar(function(door2) 82 door2.Transform:SetScale(1, 0.7, 1) 83 door2.Physics:SetActive(true) 84 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") 85 end ) 86 door2.components.inspectable.getstatus = function(door2) 87 door2.Transform:SetScale(0.1, 0.7, 1) 88 door2.Physics:SetActive(false) 89 door2:DoTaskInTime(3, function(door2) 90 door2.Transform:SetScale(1, 0.7, 1) 91 door2.Physics:SetActive(true) 92 end ) 93 end 94 door2:AddTag("doors") 95 inst:Remove() 96end 97 inst:AddComponent("deployable") 98 inst.components.deployable.ondeploy = OnDeploy 99local function onsave(inst, data) 100 if inst:HasTag("doors") then 101 data.doors = true 102 end 103end 104local function onload(inst, data) 105 if data and data.doors then 106 inst.AnimState:SetBank("winter_meter") 107 inst.AnimState:SetBuild("winter_meter") 108 inst.AnimState:SetPercent("meter", 1) 109 inst.Transform:SetScale(1, 0.7, 1) 110 MakeObstaclePhysics(inst, 0.48) 111 inst:RemoveComponent("inventoryitem") 112 inst:RemoveComponent("fuel") 113 inst:RemoveComponent("armor") 114 inst:RemoveComponent("equippable") 115 inst:RemoveComponent("burnable") 116 inst:RemoveComponent("propagator") 117 inst:RemoveComponent("deployable") 118 inst:RemoveTag("wood") 119 inst:AddComponent("workable") 120 inst.components.workable:SetWorkAction(ACTIONS.HAMMER) 121 inst.components.workable:SetWorkLeft(2) 122 inst.components.workable:SetOnFinishCallback(function(inst) 123 SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) 124 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 125 inst:Remove() 126 end ) 127 inst:AddComponent( "playerprox" ) 128 inst.components.playerprox:SetDist(2,3) 129 inst.components.playerprox:SetOnPlayerNear(function(inst) 130 inst.Transform:SetScale(0.1, 0.7, 1) 131 inst.Physics:SetActive(false) 132 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") 133 end ) 134 inst.components.playerprox:SetOnPlayerFar(function(inst) 135 inst.Transform:SetScale(1, 0.7, 1) 136 inst.Physics:SetActive(true) 137 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") 138 end ) 139 inst.components.inspectable.getstatus = function(inst) 140 inst.Transform:SetScale(0.1, 0.7, 1) 141 inst.Physics:SetActive(false) 142 inst:DoTaskInTime(3, function(inst) 143 inst.Transform:SetScale(1, 0.7, 1) 144 inst.Physics:SetActive(true) 145 end ) 146 end 147 inst:AddTag("doors") 148 end 149end 150 inst.OnSave = onsave 151 inst.OnLoad = onload 152 153 即可用木盔甲种自动门,进出时自动开关,为方便宠物进出,也可以手动开关,鼠标左键点击可开门,3秒后自动关门。种门时,可先建好一排墙,然后砸掉其中2堵,在留下的空地正中间种下自动门,即可与墙完美契合。自动门有方向的限制,只可种在正面的墙之间(进入游戏默认的方向),不能种在侧面的墙之间。不需要自动门时,用锤子砸毁即可。木盔甲在战斗选项(画着两把剑)下,用8个木头、2个绳子制造

2025/04/23 · Bny

YN243-新移民(白天石头营火附近出现新移民,自动打怪,可与他们做买卖)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二四三.新移民(白天石头营火附近出现新移民,自动打怪,可与他们做买卖) 3 4 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/firepit.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function createnpc(inst) 7 for k = 1,math.random(10,25) do 8 local pt = inst:GetPosition() 9 local npc = SpawnPrefab("frog") 10 npc.Transform:SetPosition(pt.x+(math.random(50)-math.random(50)), 0, pt.z+(math.random(50)-math.random(50))) 11 npc.AnimState:SetBank("wilson") 12 local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} 13 local buildname = names[math.random(#names)] 14 npc.AnimState:SetBuild(buildname) 15 local hats = {"hat_bee","hat_beefalo","hat_bush","hat_earmuffs","hat_feather","hat_flower","hat_football","hat_miner","hat_ruins","hat_slurper","hat_slurtle","hat_spider","hat_straw","hat_top","hat_walrus","hat_winter","hat_rain","hat_watermelon","hat_ice","hat_catcoon","hat_wathgrithr"} 16 local hat = hats[math.random(#hats)] 17 npc.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") 18 local armors = {"armor_grass","armor_marble","armor_onemanband","armor_ruins","armor_sanity","armor_slurper","armor_slurtleshell","armor_sweatervest","armor_trunkvest_summer","armor_trunkvest_winter","armor_wood","torso_rain"} 19 local armor = armors[math.random(#armors)] 20 npc.AnimState:OverrideSymbol("swap_body", armor, "swap_body") 21 npc.AnimState:Show("HAT") 22 npc.AnimState:Show("HAT_HAIR") 23 npc.AnimState:Hide("HAIR_NOHAT") 24 npc.AnimState:Hide("HAIR") 25 npc.AnimState:Hide("ARM_carry") 26 npc.AnimState:Show("ARM_normal") 27 npc.AnimState:PlayAnimation("idle") 28 MakeCharacterPhysics(npc, 75, .5) 29 local minimap = npc.entity:AddMiniMapEntity() 30 minimap:SetIcon( "lighter.png" ) 31 npc:RemoveComponent("sleeper") 32 npc:RemoveComponent("thief") 33 npc:RemoveComponent("lootdropper") 34 npc:RemoveTag("animal") 35 npc:RemoveTag("prey") 36 npc:RemoveTag("smallcreature") 37 npc:RemoveTag("frog") 38 npc:RemoveTag("canbetrapped") 39 npc:RemoveAllEventCallbacks() 40 npc:SetStateGraph("SGshadowwaxwell") 41 npc.components.health:SetMaxHealth(1000) 42 npc:RemoveComponent("combat") 43 npc:AddComponent("combat") 44 npc.components.combat:SetDefaultDamage(10) 45 npc.components.combat:SetAttackPeriod(1) 46 npc.components.combat:SetRetargetFunction(3, function(npc) 47 if not npc.components.health:IsDead() then 48 return FindEntity(npc, 20, function(guy) 49 if guy.components.combat and guy.components.health and not guy.components.health:IsDead() then 50 return guy.components.combat.target == npc or npc.components.combat.target == guy or guy:HasTag("monster") 51 end 52 end ) 53 end 54 end ) 55 npc.components.combat:SetKeepTargetFunction(function(npc, target) return target and target:IsValid() end ) 56 npc:ListenForEvent("attacked", function(npc, data) 57 npc.components.combat:SetTarget(data.attacker) 58 npc.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("npcs") and not dude.components.health:IsDead() end, 5) 59 end ) 60 npc:AddComponent("trader") 61 npc.components.trader:SetAcceptTest(function(npc, item) 62 if item.prefab == "cave_banana" or item.prefab == "carrot" or item.prefab == "corn" or item.prefab == "pumpkin" or item.prefab == "eggplant" or item.prefab == "durian" or item.prefab == "pomegranate" or item.prefab == "dragonfruit" or item.prefab == "berries" or item.prefab == "cactus_meat" or item.prefab == "watermelon" or item.prefab == "acorn" or item.prefab == "meat" or item.prefab == "smallmeat" or item.prefab == "fish" or item.prefab == "eel" or item.prefab == "drumstick" or item.prefab == "bird_egg" or item.prefab == "froglegs" or item.prefab == "monstermeat" or item.prefab == "butter" or item.prefab == "butterflywings" or item.prefab == "cutlichen" or item.prefab == "foliage" or item.prefab == "honey" or item.prefab == "lightbulb" or item.prefab == "red_cap" or item.prefab == "green_cap" or item.prefab == "blue_cap" or item.prefab == "petals" or item.prefab == "petals_evil" or item.prefab == "redgem" or item.prefab == "bluegem" or item.prefab == "purplegem" or item.prefab == "greengem" or item.prefab == "orangegem" or item.prefab == "yellowgem" then 63 return true 64 end 65 return false 66 end ) 67 npc.components.trader.onaccept = function(npc, giver, item) 68 for k = 1, 2 do 69 local goldnugget = SpawnPrefab("goldnugget") 70 GetPlayer().components.inventory:GiveItem(goldnugget) 71 end 72 end 73 npc:ListenForEvent( "nighttime", function() npc:Remove() end , GetWorld()) 74 npc:AddComponent("talker") 75 npc:DoPeriodicTask(math.random(30,60), function() 76 local words = {"Good day","I'm happy","I like here","Thank you","Where's the enemy","I'm hungry","Too hot","Too cold","Hello","Bye","Sorry","Good morning","Good afternoon","Good evening","I'll go home","I want to go hunting","I'm going to mining","I want to go to the farm","I want to pick","I want to go fishing","I'm going to catch","I want to fight","I want to have a rest","I was a good man","I want to be rich","I was lucky","I want to make friends"} 77 local word = words[math.random(#words)] 78 npc.components.talker:Say(word, 4, false) 79 end) 80 npc:AddTag("npcs") 81 end 82end 83 inst:ListenForEvent( "daytime", function() createnpc(inst) end , GetWorld()) 84 85 86 2.用MT管理器打开游戏目录/assets/scripts/prefabs/frog.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 87 88local names = {"swap_axe","swap_batbat","swap_cane","swap_diviningrod","swap_ruins_bat","swap_fishingrod","swap_goldenaxe","swap_goldenpickaxe","swap_goldenshovel","swap_ham_bat","swap_hammer","swap_lucy_axe","swap_nightmaresword","swap_pickaxe","swap_pitchfork","swap_ruins_bat","swap_shovel","swap_spear","swap_spike","swap_umbrella","swap_spear_wathgrithr","swap_parasol"} 89local weapon = names[math.random(#names)] 90local items = { SWORD = weapon } 91local function EquipItem(inst, item) 92 if item then 93 inst.AnimState:OverrideSymbol("swap_object", item, item) 94 inst.AnimState:Show("ARM_carry") 95 inst.AnimState:Hide("ARM_normal") 96 end 97end 98 inst.items = items 99 inst.equipfn = EquipItem 100 EquipItem(inst) 101local function onsave(inst, data) 102 if inst:HasTag("npcs") then 103 data.npcs = true 104 end 105end 106local function onload(inst, data) 107 if data and data.npcs then 108 inst.AnimState:SetBank("wilson") 109 local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} 110 local buildname = names[math.random(#names)] 111 inst.AnimState:SetBuild(buildname) 112 local hats = {"hat_bee","hat_beefalo","hat_bush","hat_earmuffs","hat_feather","hat_flower","hat_football","hat_miner","hat_ruins","hat_slurper","hat_slurtle","hat_spider","hat_straw","hat_top","hat_walrus","hat_winter","hat_rain","hat_watermelon","hat_ice","hat_catcoon","hat_wathgrithr"} 113 local hat = hats[math.random(#hats)] 114 inst.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") 115 local armors = {"armor_grass","armor_marble","armor_onemanband","armor_ruins","armor_sanity","armor_slurper","armor_slurtleshell","armor_sweatervest","armor_trunkvest_summer","armor_trunkvest_winter","armor_wood","torso_rain"} 116 local armor = armors[math.random(#armors)] 117 inst.AnimState:OverrideSymbol("swap_body", armor, "swap_body") 118 inst.AnimState:Show("HAT") 119 inst.AnimState:Show("HAT_HAIR") 120 inst.AnimState:Hide("HAIR_NOHAT") 121 inst.AnimState:Hide("HAIR") 122 inst.AnimState:Hide("ARM_carry") 123 inst.AnimState:Show("ARM_normal") 124 inst.AnimState:PlayAnimation("idle") 125 MakeCharacterPhysics(inst, 75, .5) 126 local minimap = inst.entity:AddMiniMapEntity() 127 minimap:SetIcon( "lighter.png" ) 128 inst:RemoveComponent("sleeper") 129 inst:RemoveComponent("thief") 130 inst:RemoveComponent("lootdropper") 131 inst:RemoveTag("animal") 132 inst:RemoveTag("prey") 133 inst:RemoveTag("smallcreature") 134 inst:RemoveTag("frog") 135 inst:RemoveTag("canbetrapped") 136 inst:RemoveAllEventCallbacks() 137 inst:SetStateGraph("SGshadowwaxwell") 138 inst.components.health:SetMaxHealth(1000) 139 inst:RemoveComponent("combat") 140 inst:AddComponent("combat") 141 inst.components.combat:SetDefaultDamage(10) 142 inst.components.combat:SetAttackPeriod(1) 143 inst.components.combat:SetRetargetFunction(3, function(inst) 144 if not inst.components.health:IsDead() then 145 return FindEntity(inst, 20, function(guy) 146 if guy.components.combat and guy.components.health and not guy.components.health:IsDead() then 147 return guy.components.combat.target == inst or inst.components.combat.target == guy or guy:HasTag("monster") 148 end 149 end ) 150 end 151 end ) 152 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) 153 inst:ListenForEvent("attacked", function(inst, data) 154 inst.components.combat:SetTarget(data.attacker) 155 inst.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("npcs") and not dude.components.health:IsDead() end, 5) 156 end ) 157 inst:AddComponent("trader") 158 inst.components.trader:SetAcceptTest(function(inst, item) 159 if item.prefab == "cave_banana" or item.prefab == "carrot" or item.prefab == "corn" or item.prefab == "pumpkin" or item.prefab == "eggplant" or item.prefab == "durian" or item.prefab == "pomegranate" or item.prefab == "dragonfruit" or item.prefab == "berries" or item.prefab == "cactus_meat" or item.prefab == "watermelon" or item.prefab == "acorn" or item.prefab == "meat" or item.prefab == "smallmeat" or item.prefab == "fish" or item.prefab == "eel" or item.prefab == "drumstick" or item.prefab == "bird_egg" or item.prefab == "froglegs" or item.prefab == "monstermeat" or item.prefab == "butter" or item.prefab == "butterflywings" or item.prefab == "cutlichen" or item.prefab == "foliage" or item.prefab == "honey" or item.prefab == "lightbulb" or item.prefab == "red_cap" or item.prefab == "green_cap" or item.prefab == "blue_cap" or item.prefab == "petals" or item.prefab == "petals_evil" or item.prefab == "redgem" or item.prefab == "bluegem" or item.prefab == "purplegem" or item.prefab == "greengem" or item.prefab == "orangegem" or item.prefab == "yellowgem" then 160 return true 161 end 162 return false 163 end ) 164 inst.components.trader.onaccept = function(inst, giver, item) 165 for k = 1, 2 do 166 local goldnugget = SpawnPrefab("goldnugget") 167 GetPlayer().components.inventory:GiveItem(goldnugget) 168 end 169 end 170 inst:ListenForEvent( "nighttime", function() inst:Remove() end , GetWorld()) 171 inst:AddComponent("talker") 172 inst:DoPeriodicTask(math.random(30,60), function() 173 local words = {"Good day","I'm happy","I like here","Thank you","Where's the enemy","I'm hungry","Too hot","Too cold","Hello","Bye","Sorry","Good morning","Good afternoon","Good evening","I'll go home","I want to go hunting","I'm going to mining","I want to go to the farm","I want to pick","I want to go fishing","I'm going to catch","I want to fight","I want to have a rest","I was a good man","I want to be rich","I was lucky","I want to make friends"} 174 local word = words[math.random(#words)] 175 inst.components.talker:Say(word, 4, false) 176 end) 177 inst:AddTag("npcs") 178 end 179end 180 inst.OnSave = onsave 181 inst.OnLoad = onload 182 183 即可在白天时,石头营火附近有新移民走动,黑夜离去,会主动攻击怪物,有他们的地方是安全的。他们愿意购买你的肉类、蔬菜和宝石(拿着物品对新移民点鼠标左键),每个物品可以卖2个黄金。如果你攻击新移民,附近的其他人将围殴你。新移民会自言自语,听听他们都说了些什么吧。在地图各处建造石头营火及其他建筑,就会形成许多小镇,饥荒世界从此不再冷清。新移民在小地图上显示为打火机图标(代表着希望),通过查看小地图,可以了解各个小镇的人口情况

2025/04/23 · Bny

YN244-神奇跳跃(按键盘R键主角可向前跳跃)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二四四.神奇跳跃(按键盘R键主角可向前跳跃) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("resurrectable")的下一行插入以下内容: 5 6TheInput:AddKeyUpHandler(KEY_R, function() 7 inst.Physics:SetCollides(false) 8 inst:DoTaskInTime(0, function() 9 inst.AnimState:PlayAnimation("give") 10 inst.components.playercontroller:Enable(false) 11 inst.components.locomotor:Stop() 12 inst.Physics:SetMotorVelOverride(50,45,0) end ) 13 inst:DoTaskInTime(0.2, function() 14 inst.Physics:ClearMotorVelOverride() 15 inst.Physics:SetMotorVelOverride(50,0,0) end ) 16 inst:DoTaskInTime(0.3, function() 17 inst.Physics:ClearMotorVelOverride() 18 inst.Physics:SetMotorVelOverride(50,-25,0) end ) 19 inst:DoTaskInTime(0.5, function() 20 inst.Physics:ClearMotorVelOverride() 21 inst.components.locomotor:Stop() 22 local pt = inst:GetPosition() 23 inst.Transform:SetPosition(pt.x, 0, pt.z) 24 inst.components.playercontroller:Enable(true) 25 inst.Physics:SetCollides(true) 26 inst.AnimState:PlayAnimation("idle") 27 inst.SoundEmitter:PlaySound("dontstarve/movement/bodyfall_dirt", "bodyfall") end ) 28end ) 29 30 即可按键盘R键,让主角向前跳跃,用以方便地越过沟壑、墙等障碍,也可以跳到海面上,渡海而行。当身边有障碍物时,会影响跳跃高度。将其中KEY_R替换为其他键,比如KEY_C,就可以按键盘C键跳跃

2025/04/23 · Bny

YN245-如来神掌(按键盘J键,主角飞起并砸向地面,引发威力巨大的地震)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二四五.如来神掌(按键盘J键,主角飞起并砸向地面,引发威力巨大的地震) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playeractionpicker")的下一行插入以下内容: 5 6TheInput:AddKeyUpHandler(KEY_J, function() 7 if not inst:HasTag("jump") then 8 inst.components.hunger:DoDelta(-50) 9 inst.components.playercontroller:Enable(false) 10 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 11 shadow:SetSize( 0, 0 ) 12 inst:AddTag("jump") 13 inst.jump = inst:DoPeriodicTask(.01, function() inst.Physics:SetMotorVelOverride(0,15,0) end) 14 inst:DoTaskInTime(5, function() 15 if inst.jump then inst.jump:Cancel() inst.jump = nil end 16 local pos = inst:GetPosition() 17 GetSeasonManager():DoLightningStrike(pos) 18 inst.sg:GoToState("hit") 19 inst.jump2 = inst:DoPeriodicTask(.01, function() inst.Physics:SetMotorVelOverride(0,-55,0) end) 20 end ) 21 inst:DoTaskInTime(6.35, function() 22 if inst.jump2 then inst.jump2:Cancel() inst.jump2 = nil end 23 inst.sg:GoToState("hit") 24 inst.AnimState:SetBloomEffectHandle("") 25 shadow:SetSize( 1.3, .6 ) 26 SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) 27 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 28 for k = 1,math.random(5) do 29 local pt = Vector3(inst.Transform:GetWorldPosition()) 30 SpawnPrefab("rocks").Transform:SetPosition(pt.x+(math.random(3)-math.random(3)), 0, pt.z+(math.random(3)-math.random(3))) 31 end 32 inst.components.playercontroller:ShakeCamera(inst, "FULL", 2.5, 0.03, 2, 30) 33 end ) 34 inst:DoTaskInTime(6.5, function() 35 local pos = Vector3(inst.Transform:GetWorldPosition()) 36 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 30) 37 for k,v in pairs(ents) do 38 if v.components.workable and v.components.workable.workleft > 0 and not v.components.inventoryitem then 39 v.components.workable:Destroy(inst) 40 end 41 if v:HasTag("monster") or v.prefab == "beefalo" or v.prefab == "babybeefalo" or v.prefab == "bunnyman" or v.prefab == "pigman" or v.prefab == "pigguard" 42 or v.prefab == "merm" or v.prefab == "monkey" or v.prefab == "tallbird" or v.prefab == "walrus" or v.prefab == "little_walrus" or v.prefab == "wasphive" 43 or v.prefab == "beehive" or v.prefab == "koalefant_summer" or v.prefab == "koalefant_winter" or v.prefab == "lureplant" or v.prefab == "penguin" 44 or v.prefab == "perd" or v.prefab == "rocky" or v.prefab == "slurper" or v.prefab == "snurtle" or v.prefab == "slurtle" or v.prefab == "slurtlehole" 45 or v.prefab == "spiderden" or v.prefab == "spiderden_2" or v.prefab == "spiderden_3" then 46 v.components.health:DoDelta(-3000) 47 end 48 end 49 inst:RemoveTag("jump") 50 inst.components.playercontroller:Enable(true) 51 end ) 52 end 53end ) 54 55 即可按下键盘J键使出如来神掌,你将腾空而起并砸向地面(不会伤血),引发剧烈的地震,震毁周围一切建筑、石头、树木,并震死绝大多数动物(不伤宠物等同伴)。如来神掌是迄今为止威力最大的武林绝学,追求和谐游戏的玩家请慎用。每次发功消耗50点饥饿值

2025/04/23 · Bny

YN246-警戒模式(按键盘F8键主角自动巡逻并战斗,再按F8键恢复手动控制)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二四六.警戒模式(按键盘F8键主角自动巡逻并战斗,再按F8键恢复手动控制) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playercontroller")的下一行插入以下内容: 5 6local items = { SWORD = "swap_spear" } 7local function EquipItem(inst, item) 8 if item then 9 inst.AnimState:OverrideSymbol("swap_object", item, item) 10 inst.AnimState:Show("ARM_carry") 11 inst.AnimState:Hide("ARM_normal") 12 end 13end 14 inst.items = items 15 inst.equipfn = EquipItem 16 EquipItem(inst) 17TheInput:AddKeyUpHandler(KEY_F8, function() 18 if not inst:HasTag("patrol") then 19 inst.components.locomotor:Stop() 20 inst:SetBrain(nil) 21 inst.components.talker:ShutUp() 22 inst.components.playercontroller:Enable(false) 23 inst:DoTaskInTime(0.3, function() 24 inst:AddTag("patrol") 25 inst.SoundEmitter:PlaySound("dontstarve/HUD/research_available") 26 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 27 inst:AddComponent("knownlocations") 28 local brain = require "brains/frogbrain" 29 inst:SetBrain(brain) 30 inst:RestartBrain() 31 local head = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) 32 inst.components.inventory:DropItem(head) 33 local hands = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) 34 inst.components.inventory:DropItem(hands) 35 local body = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.BODY) 36 inst.components.inventory:DropItem(body) 37 inst.AnimState:OverrideSymbol("swap_object", "swap_spear", "swap_spear") 38 inst.AnimState:Show("ARM_carry") 39 inst.AnimState:Hide("ARM_normal") 40 inst.HUD.controls.crafttabs:Hide() 41 inst.HUD.controls.inv:Hide() 42 local light = inst.entity:AddLight() 43 light:SetIntensity(.8) 44 light:SetRadius(20) 45 light:SetFalloff(.6) 46 light:Enable(true) 47 light:SetColour(255/255,255/255,0/255) 48 inst.components.locomotor.walkspeed = 10 49 inst.components.locomotor.runspeed = 15 50 inst:SetStateGraph("SGshadowwaxwell") 51 inst.components.health:SetInvincible(true) 52 inst.components.hunger:Pause() 53 inst.components.sanity.ignore = true 54 inst.components.temperature:SetTemp(20) 55 inst.components.combat:SetDefaultDamage(200) 56 inst.components.combat:SetAttackPeriod(0.25) 57 inst.components.combat:SetRange(3) 58 inst.components.combat:SetRetargetFunction(1, function(inst) 59 if not inst.components.health:IsDead() then 60 return FindEntity(inst, 50, function(guy) 61 if guy.components.health and not guy.components.health:IsDead() then 62 return guy.components.combat.target == inst or inst.components.combat.target == guy or guy:HasTag("monster") 63 end 64 end ) 65 end 66 end ) 67 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) 68 end ) 69 else 70 inst.components.locomotor:Stop() 71 inst:SetBrain(nil) 72 inst.components.talker:ShutUp() 73 inst:DoTaskInTime(0.3, function() 74 inst:RemoveTag("patrol") 75 inst.SoundEmitter:PlaySound("dontstarve/HUD/research_available") 76 inst.AnimState:SetBloomEffectHandle("") 77 local brain = require "brains/wilsonbrain" 78 inst:SetBrain(brain) 79 inst:RestartBrain() 80 inst:RemoveComponent("knownlocations") 81 inst.AnimState:Hide("ARM_carry") 82 inst.AnimState:Show("ARM_normal") 83 inst.HUD.controls.crafttabs:Show() 84 inst.HUD.controls.inv:Show() 85 inst.Light:Enable(false) 86 inst.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED 87 inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED 88 inst:SetStateGraph("SGwilson") 89 inst.components.health:SetInvincible(false) 90 inst.components.hunger:Resume() 91 inst.components.sanity.ignore = false 92 inst.components.temperature:SetTemp(nil) 93 inst.components.hunger:DoDelta(-inst.components.hunger.max*.5) 94 inst.components.combat:SetDefaultDamage(TUNING.UNARMED_DAMAGE) 95 inst.components.combat:SetAttackPeriod(TUNING.WILSON_ATTACK_PERIOD) 96 inst.components.combat:SetRange(2) 97 inst.components.combat:SetTarget(nil) 98 inst.components.combat:SetRetargetFunction(nil, nil ) 99 inst.components.combat:SetKeepTargetFunction(nil) 100 inst.components.playercontroller:Enable(true) 101 end ) 102 end 103end ) 104 105 即可按键盘F8键,开启主角警戒模式,CPU将接管你对主角的控制权,让主角自动巡逻并保护所在地区(夜晚站岗),一旦发现敌人,会自行战斗,由于主角的生命、脑、饥饿值已全部锁死,并且无惧寒冷和黑暗,所以你无须担心主角的安全。再次按键盘F8键即可恢复手动操作,并扣减一半饥饿值,注意及时补充食物。开启警戒模式前,请将身上的装备全部卸下,否则将掉落在地上

2025/04/23 · Bny

YN247-观赏秃鹫(用蛛丝种笼中的秃鹫,喂腐烂食物产种子,喂肉生高鸟蛋)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二四七.观赏秃鹫(用蛛丝种笼中的秃鹫,喂腐烂食物产种子,喂肉生高鸟蛋) 3 4 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/spoiledfood.lua文件,在inst:AddComponent("inspectable")的下一行插入inst:AddComponent("tradable") 5 6 7 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/silk.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 8 9local function makecage(inst) 10 local pt = inst:GetPosition() 11 local cage = SpawnPrefab("silk") 12 cage.Transform:SetPosition(pt.x, pt.y, pt.z) 13 cage.AnimState:SetBank("birdcage") 14 cage.AnimState:SetBuild("bird_cage") 15 cage.AnimState:PlayAnimation("idle") 16 cage.AnimState:SetMultColour(0/255,255/255,0/255,1) 17 MakeObstaclePhysics(cage, .5 ) 18 cage:RemoveComponent("tradable") 19 cage:RemoveComponent("stackable") 20 cage:RemoveComponent("inventoryitem") 21 cage:RemoveComponent("upgrader") 22 cage:RemoveComponent("deployable") 23 cage:RemoveTag("cattoy") 24 cage:AddComponent("named") 25 cage.components.named:SetName("Buzzard") 26 cage:AddComponent("lootdropper") 27 cage:AddComponent("workable") 28 cage.components.workable:SetWorkAction(ACTIONS.HAMMER) 29 cage.components.workable:SetWorkLeft(3) 30 cage.components.workable:SetOnFinishCallback(function(cage, worker) 31 SpawnPrefab("collapse_big").Transform:SetPosition(cage.Transform:GetWorldPosition()) 32 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 33 local pos = Vector3(cage.Transform:GetWorldPosition()) 34 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 2) 35 for k,v in pairs(ents) do 36 if v:HasTag("cageanimal") then 37 v:Remove() 38 end 39 end 40 cage:Remove() 41 end ) 42 cage:AddComponent("trader") 43 cage.components.trader:SetAcceptTest(function(cage, item) 44 if item.prefab == "spoiled_food" or item.prefab == "meat" or item.prefab == "smallmeat" then 45 return true 46 end 47 return false 48 end ) 49 cage.components.trader.onaccept = function(cage, giver, item) 50 GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/buzzard/taunt") 51 if item.prefab == "spoiled_food" then 52 for k = 1, math.random(5) do 53 local names = {"carrot_seeds","corn_seeds","pumpkin_seeds","eggplant_seeds","durian_seeds","pomegranate_seeds","dragonfruit_seeds","watermelon_seeds","seeds"} 54 local name = names[math.random(#names)] 55 cage.components.lootdropper:SpawnLootPrefab(name) 56 end 57 end 58 if item.prefab == "meat" or item.prefab == "smallmeat" then 59 cage.components.lootdropper:SpawnLootPrefab("tallbirdegg") 60 end 61 end 62 cage:AddTag("cages") 63 local animal = SpawnPrefab("silk") 64 animal.AnimState:SetBank("buzzard") 65 animal.AnimState:SetBuild("buzzard_build") 66 animal.AnimState:PlayAnimation("idle", true) 67 animal.Transform:SetFourFaced() 68 animal.Physics:SetActive(false) 69 animal.entity:AddSoundEmitter() 70 animal:AddTag("NOCLICK") 71 animal:RemoveComponent("tradable") 72 animal:RemoveComponent("stackable") 73 animal:RemoveComponent("inventoryitem") 74 animal:RemoveComponent("upgrader") 75 animal:RemoveComponent("deployable") 76 animal:RemoveTag("cattoy") 77 local follower = animal.entity:AddFollower() 78 follower:FollowSymbol( cage.GUID, "swap_object", -10, -220, -0.1 ) 79 animal:DoPeriodicTask(10, function(animal) 80 animal.AnimState:PlayAnimation("caw") 81 animal.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/buzzard/taunt") 82 animal:DoTaskInTime(1.5, function() animal.AnimState:PlayAnimation("idle", true) end ) 83 end ) 84 animal:AddTag("cageanimal") 85end 86local function OnDeploy (inst, pt) 87 makecage(inst) 88 inst.components.stackable:Get():Remove() 89end 90 inst:AddComponent("deployable") 91 inst.components.deployable.ondeploy = OnDeploy 92local function onsave(inst, data) 93 if inst:HasTag("cages") then 94 data.cages = true 95 end 96 if inst:HasTag("cageanimal") then 97 data.cageanimal = true 98 end 99end 100local function onload(inst, data) 101 if data and data.cages then 102 makecage(inst) 103 inst:Remove() 104 end 105 if data and data.cageanimal then 106 inst:Remove() 107 end 108end 109 inst.OnSave = onsave 110 inst.OnLoad = onload 111 112 即可用蛛丝种关在笼中的秃鹫(拿着1个蛛丝对地面点鼠标右键,如果拿着多个,则不会种出来),喂它腐烂食物,会掉落随机品种的植物种子,喂大肉、小肉会生高鸟蛋。不想要观赏秃鹫了,用锤子砸掉即可

2025/04/23 · Bny

YN248-迷你花坛(用燧石种花坛,给种子长出花朵,每晚招来萤火虫)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二四八.迷你花坛(用燧石种花坛,给种子长出花朵,每晚招来萤火虫) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/flint.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local names = {"f1","f2","f3","f4","f5","f6","f7","f8","f9","f10"} 7local function OnDeploy (inst, pt) 8 local flowerpot = SpawnPrefab("flint") 9 flowerpot.Transform:SetPosition(pt.x, pt.y, pt.z) 10 flowerpot.AnimState:SetBank("firepit") 11 flowerpot.AnimState:SetBuild("firepit") 12 flowerpot.AnimState:PlayAnimation("idle",false) 13 flowerpot.Transform:SetScale(0.5, 0.8, 0.5) 14 flowerpot:RemoveComponent("edible") 15 flowerpot:RemoveComponent("tradable") 16 flowerpot:RemoveComponent("stackable") 17 flowerpot:RemoveComponent("inventoryitem") 18 flowerpot:RemoveComponent("bait") 19 flowerpot:RemoveTag("molebait") 20 flowerpot:AddTag("flowerpot") 21 flowerpot:AddComponent("workable") 22 flowerpot.components.workable:SetWorkAction(ACTIONS.HAMMER) 23 flowerpot.components.workable:SetWorkLeft(3) 24 flowerpot.components.workable:SetOnFinishCallback(function(flowerpot) 25 SpawnPrefab("collapse_big").Transform:SetPosition(flowerpot.Transform:GetWorldPosition()) 26 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/rock_break") 27 local pos1 = Vector3(flowerpot.Transform:GetWorldPosition()) 28 local ents = TheSim:FindEntities(pos1.x,pos1.y,pos1.z, 0.5) 29 for k,v in pairs(ents) do 30 if v:HasTag("newflower") then 31 v:Remove() 32 end 33 end 34 flowerpot:Remove() 35 end ) 36 flowerpot:ListenForEvent( "dusktime", function() 37 if flowerpot:HasTag("flowering") then 38 for k = 1,math.random(2,5) do 39 local pt1 = flowerpot:GetPosition() 40 local fireflies = SpawnPrefab("fireflies") 41 fireflies.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) 42 end 43 end 44 end , GetWorld() ) 45 flowerpot:ListenForEvent( "daytime", function() 46 local pos = Vector3(flowerpot.Transform:GetWorldPosition()) 47 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 5) 48 for k,v in pairs(ents) do 49 if v.prefab == "fireflies" and not v.components.inventoryitem:IsHeld() then 50 v:Remove() 51 end 52 end 53 end , GetWorld() ) 54 flowerpot:AddComponent("trader") 55 flowerpot.components.trader:SetAcceptTest(function(flowerpot, item) 56 if not flowerpot:HasTag("flowering") then 57 if item.prefab == "seeds" then 58 return true 59 end 60 end 61 return false 62 end ) 63 flowerpot.components.trader.onaccept = function(flowerpot, giver, item) 64 local flower = SpawnPrefab("flint") 65 flower.AnimState:SetBank("flowers") 66 flower.AnimState:SetBuild("flowers") 67 flower.animname = names[math.random(#names)] 68 flower.AnimState:PlayAnimation(flower.animname) 69 flower.AnimState:SetRayTestOnBB(true) 70 flower.Transform:SetScale(1.5, 1.5, 1.5) 71 flower.Physics:SetActive(false) 72 local follower = flower.entity:AddFollower() 73 follower:FollowSymbol( flowerpot.GUID, "swap_object", 0, -50, 0 ) 74 flower:RemoveComponent("edible") 75 flower:RemoveComponent("tradable") 76 flower:RemoveComponent("stackable") 77 flower:RemoveComponent("inventoryitem") 78 flower:RemoveComponent("bait") 79 flower:RemoveTag("molebait") 80 flower:AddComponent("sanityaura") 81 flower.components.sanityaura.aura = TUNING.SANITYAURA_SMALL 82 flower:AddComponent("pickable") 83 flower.components.pickable.picksound = "dontstarve/wilson/pickup_plants" 84 flower.components.pickable:SetUp("petals", 0.1) 85 flower.components.pickable.onpickedfn = function(flower) 86 flower:Remove() 87 flower = nil 88 flowerpot:RemoveTag("flowering") 89 end 90 flower:AddTag("newflower") 91 flower:AddTag("goodbye") 92 flowerpot:AddTag("flowering") 93 end 94 inst.components.stackable:Get():Remove() 95end 96 inst:AddComponent("deployable") 97 inst.components.deployable.ondeploy = OnDeploy 98local function onsave(inst, data) 99 if inst:HasTag("goodbye") then 100 data.goodbye = true 101 end 102 if inst:HasTag("flowerpot") then 103 data.flowerpot = true 104 end 105 if inst:HasTag("flowering") then 106 data.flowering = true 107 end 108end 109local function onload(inst, data) 110 if data and data.goodbye then 111 inst:Remove() 112 end 113 if data and data.flowerpot then 114 inst.AnimState:SetBank("firepit") 115 inst.AnimState:SetBuild("firepit") 116 inst.AnimState:PlayAnimation("idle",false) 117 inst.Transform:SetScale(0.5, 0.8, 0.5) 118 inst:RemoveComponent("edible") 119 inst:RemoveComponent("tradable") 120 inst:RemoveComponent("stackable") 121 inst:RemoveComponent("inventoryitem") 122 inst:RemoveComponent("bait") 123 inst:RemoveTag("molebait") 124 inst:AddTag("flowerpot") 125 inst:AddComponent("workable") 126 inst.components.workable:SetWorkAction(ACTIONS.HAMMER) 127 inst.components.workable:SetWorkLeft(3) 128 inst.components.workable:SetOnFinishCallback(function(inst) 129 SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) 130 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/rock_break") 131 local pos1 = Vector3(inst.Transform:GetWorldPosition()) 132 local ents = TheSim:FindEntities(pos1.x,pos1.y,pos1.z, 0.5) 133 for k,v in pairs(ents) do 134 if v:HasTag("newflower") then 135 v:Remove() 136 end 137 end 138 inst:Remove() 139 end ) 140 inst:ListenForEvent( "dusktime", function() 141 if inst:HasTag("flowering") then 142 for k = 1,math.random(2,5) do 143 local pt1 = inst:GetPosition() 144 local fireflies = SpawnPrefab("fireflies") 145 fireflies.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) 146 end 147 end 148 end , GetWorld() ) 149 inst:ListenForEvent( "daytime", function() 150 local pos = Vector3(inst.Transform:GetWorldPosition()) 151 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 5) 152 for k,v in pairs(ents) do 153 if v.prefab == "fireflies" and not v.components.inventoryitem:IsHeld() then 154 v:Remove() 155 end 156 end 157 end , GetWorld() ) 158 inst:AddComponent("trader") 159 inst.components.trader:SetAcceptTest(function(inst, item) 160 if not inst:HasTag("flowering") then 161 if item.prefab == "seeds" then 162 return true 163 end 164 end 165 return false 166 end ) 167 inst.components.trader.onaccept = function(inst, giver, item) 168 local flower = SpawnPrefab("flint") 169 flower.AnimState:SetBank("flowers") 170 flower.AnimState:SetBuild("flowers") 171 flower.animname = names[math.random(#names)] 172 flower.AnimState:PlayAnimation(flower.animname) 173 flower.AnimState:SetRayTestOnBB(true) 174 flower.Transform:SetScale(1.5, 1.5, 1.5) 175 flower.Physics:SetActive(false) 176 local follower = flower.entity:AddFollower() 177 follower:FollowSymbol( inst.GUID, "swap_object", 0, -50, 0 ) 178 flower:RemoveComponent("edible") 179 flower:RemoveComponent("tradable") 180 flower:RemoveComponent("stackable") 181 flower:RemoveComponent("inventoryitem") 182 flower:RemoveComponent("bait") 183 flower:RemoveTag("molebait") 184 flower:AddComponent("sanityaura") 185 flower.components.sanityaura.aura = TUNING.SANITYAURA_SMALL 186 flower:AddComponent("pickable") 187 flower.components.pickable.picksound = "dontstarve/wilson/pickup_plants" 188 flower.components.pickable:SetUp("petals", 0.1) 189 flower.components.pickable.onpickedfn = function(flower) 190 flower:Remove() 191 flower = nil 192 inst:RemoveTag("flowering") 193 end 194 flower:AddTag("newflower") 195 flower:AddTag("goodbye") 196 inst:AddTag("flowering") 197 end 198 end 199 if data and data.flowering then 200 local flower = SpawnPrefab("flint") 201 flower.AnimState:SetBank("flowers") 202 flower.AnimState:SetBuild("flowers") 203 flower.animname = names[math.random(#names)] 204 flower.AnimState:PlayAnimation(flower.animname) 205 flower.AnimState:SetRayTestOnBB(true) 206 flower.Transform:SetScale(1.5, 1.5, 1.5) 207 flower.Physics:SetActive(false) 208 local follower = flower.entity:AddFollower() 209 follower:FollowSymbol( inst.GUID, "swap_object", 0, -50, 0 ) 210 flower:RemoveComponent("edible") 211 flower:RemoveComponent("tradable") 212 flower:RemoveComponent("stackable") 213 flower:RemoveComponent("inventoryitem") 214 flower:RemoveComponent("bait") 215 flower:RemoveTag("molebait") 216 flower:AddComponent("sanityaura") 217 flower.components.sanityaura.aura = TUNING.SANITYAURA_SMALL 218 flower:AddComponent("pickable") 219 flower.components.pickable.picksound = "dontstarve/wilson/pickup_plants" 220 flower.components.pickable:SetUp("petals", 0.1) 221 flower.components.pickable.onpickedfn = function(flower) 222 flower:Remove() 223 flower = nil 224 inst:RemoveTag("flowering") 225 end 226 flower:AddTag("newflower") 227 flower:AddTag("goodbye") 228 inst:AddTag("flowering") 229 end 230end 231 inst.OnSave = onsave 232 inst.OnLoad = onload 233 234 即可用燧石种迷你花坛,在花坛中放入1个种子(拿着种子对花坛点鼠标左键),可开一朵花,品种随机。鼠标左键点花朵,可摘花(获得花瓣)。当花坛中有花时,靠近可以补脑,并且每晚都会招来萤火虫(天亮时消失),尽情捕捉吧。如果同时修改了“网上宠宠店”,就可以将抓到的萤火虫在线卖掉换黄金。不想要迷你花坛时,用锤子砸掉即可

2025/04/23 · Bny

YN249-橡树盆栽(用化肥种橡树盆栽,每天掉落橡果,靠近可补脑,鼠标左键点击树叶可变色)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二四九.橡树盆栽(用化肥种橡树盆栽,每天掉落橡果,靠近可补脑,鼠标左键点击树叶可变色) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/fertilizer.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function createoak(inst) 7 local pt = inst:GetPosition() 8 local oak = SpawnPrefab("fertilizer") 9 oak.Transform:SetPosition(pt.x, pt.y, pt.z) 10 oak.AnimState:SetBank("fertilizer") 11 oak.AnimState:SetBuild("fertilizer") 12 oak.AnimState:PlayAnimation("idle") 13 oak.Transform:SetScale(1.2, 1.2, 1.2) 14 oak:RemoveComponent("inventoryitem") 15 oak:RemoveComponent("finiteuses") 16 oak:RemoveComponent("fertilizer") 17 oak:RemoveComponent("smotherer") 18 oak:RemoveComponent("deployable") 19 oak:AddTag("NOCLICK") 20 oak:ListenForEvent( "daytime", function() 21 local pos = Vector3(oak.Transform:GetWorldPosition()) 22 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 2) 23 for k,v in pairs(ents) do 24 if v.components.inventoryitem and not v.components.inventoryitem:IsHeld() then 25 if v.prefab == "acorn" then 26 v:Remove() 27 end 28 end 29 end 30 oak:DoTaskInTime(0.3, function(oak) 31 oak:StartThread(function() 32 for k = 1,math.random(3,6) do 33 local pt1 = oak:GetPosition() 34 local acorn = SpawnPrefab("acorn") 35 acorn.Transform:SetPosition(pt1.x+(math.random(2)-math.random(2)), 5, pt1.z+(math.random(2)-math.random(2))) 36 Sleep(0.3) 37 end 38 end ) 39 end ) 40 end , GetWorld() ) 41 oak:AddTag("oak") 42 oak.tree = SpawnPrefab("fertilizer") 43 oak.tree.AnimState:SetBank("tree_leaf") 44 oak.tree.AnimState:SetBuild("tree_leaf_trunk_build") 45 local names = {"tree_leaf_green_build","tree_leaf_red_build","tree_leaf_orange_build","tree_leaf_yellow_build"} 46 local name = names[math.random(#names)] 47 oak.tree.AnimState:OverrideSymbol("swap_leaves", name, "swap_leaves") 48 oak.tree.AnimState:PlayAnimation("idle_tall") 49 oak.tree.Transform:SetScale(0.8, 0.8, 0.8) 50 oak.tree.Physics:SetActive(false) 51 oak.tree:RemoveComponent("inventoryitem") 52 oak.tree:RemoveComponent("finiteuses") 53 oak.tree:RemoveComponent("fertilizer") 54 oak.tree:RemoveComponent("smotherer") 55 oak.tree:RemoveComponent("deployable") 56 local follower = oak.tree.entity:AddFollower() 57 follower:FollowSymbol( oak.GUID, "swap_object", -1, -115, 0 ) 58 oak.tree:AddComponent("sanityaura") 59 oak.tree.components.sanityaura.aura = TUNING.SANITYAURA_MED 60 oak.tree:AddComponent("workable") 61 oak.tree.components.workable:SetWorkAction(ACTIONS.CHOP) 62 oak.tree.components.workable:SetWorkLeft(1) 63 oak.tree.components.workable:SetOnFinishCallback(function() 64 SpawnPrefab("collapse_big").Transform:SetPosition(oak.tree.Transform:GetWorldPosition()) 65 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 66 local pos = Vector3(oak.tree.Transform:GetWorldPosition()) 67 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 1) 68 for k,v in pairs(ents) do 69 if v:HasTag("oak") then 70 v:Remove() 71 end 72 end 73 oak.tree:Remove() 74 end ) 75 oak.tree.components.inspectable.getstatus = function() 76 local names = {"tree_leaf_green_build","tree_leaf_red_build","tree_leaf_orange_build","tree_leaf_yellow_build"} 77 local name = names[math.random(#names)] 78 oak.tree.AnimState:OverrideSymbol("swap_leaves", name, "swap_leaves") 79 end 80 oak.tree:AddTag("goodbye") 81end 82local function OnDeploy (inst, pt) 83 createoak(inst) 84 inst:Remove() 85end 86 inst:AddComponent("deployable") 87 inst.components.deployable.ondeploy = OnDeploy 88local function onsave(inst, data) 89 if inst:HasTag("goodbye") then 90 data.goodbye = true 91 end 92 if inst:HasTag("oak") then 93 data.oak = true 94 end 95end 96local function onload(inst, data) 97 if data and data.goodbye then 98 inst:Remove() 99 end 100 if data and data.oak then 101 createoak(inst) 102 inst:Remove() 103 end 104end 105 inst.OnSave = onsave 106 inst.OnLoad = onload 107 108 即可用化肥种橡树盆栽,四季常青,每天清晨掉落橡果,靠近可补脑。鼠标左键点橡树,可改变树叶的颜色。不想要橡树盆栽了,用斧子砍掉即可。化肥在种植选项(画着胡萝卜)下,用3个便便、2个硬骨头、4个木头制造

2025/04/23 · Bny

YN250-小油灯(用蜘蛛腺体种小油灯,放在地上自动点燃,无限燃烧,可烧炭、烤食物、取暖、照明)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二五0.小油灯(用蜘蛛腺体种小油灯,放在地上自动点燃,无限燃烧,可烧炭、烤食物、取暖、照明) 3 4 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/log.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6 inst:AddComponent("cookable") 7 inst.components.cookable.product = "charcoal" 8 9 10 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/spidergland.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 11 12local colours= 13{ 14 {198/255,43/255,43/255}, 15 {79/255,153/255,68/255}, 16 {35/255,105/255,235/255}, 17 {233/255,208/255,69/255}, 18 {109/255,50/255,163/255}, 19 {222/255,126/255,39/255}, 20} 21local function OnDeploy (inst, pt) 22 local lamp = SpawnPrefab("spidergland") 23 lamp.Transform:SetPosition(pt.x, pt.y, pt.z) 24 lamp.AnimState:SetBank("trinkets") 25 lamp.AnimState:SetBuild("trinkets") 26 lamp.AnimState:PlayAnimation(tostring(2)) 27 lamp.components.inventoryitem:ChangeImageName("trinket_2") 28 lamp.entity:AddSoundEmitter() 29 lamp.Transform:SetScale(1.2,1.2,1.2) 30 lamp.colour_idx = math.random(#colours) 31 lamp.AnimState:SetMultColour(colours[lamp.colour_idx][1],colours[lamp.colour_idx][2],colours[lamp.colour_idx][3],1) 32 lamp:RemoveComponent("stackable") 33 lamp:RemoveComponent("tradable") 34 lamp:RemoveComponent("healer") 35 lamp:RemoveComponent("burnable") 36 lamp:RemoveComponent("propagator") 37 lamp:RemoveComponent("deployable") 38 lamp:RemoveTag("cattoy") 39 lamp:AddComponent("cooker") 40 lamp:AddComponent("burnable") 41 lamp.components.burnable:SetFXLevel(3) 42 lamp.components.burnable:AddBurnFX("campfirefire", Vector3(0,0.5,0) ) 43 lamp.components.burnable:Ignite(true) 44 lamp.components.inventoryitem:SetOnDroppedFn(function() lamp.components.burnable:Ignite(true) lamp:AddTag("ontheground") end ) 45 lamp.components.inventoryitem:SetOnPickupFn(function() lamp.components.burnable:Extinguish() lamp:RemoveTag("ontheground") end ) 46 lamp.components.inventoryitem:SetOnPutInInventoryFn(function() lamp.components.burnable:Extinguish() lamp:RemoveTag("ontheground") end ) 47 lamp:ListenForEvent("onignite", function() 48 if not lamp.components.cooker then lamp:AddComponent("cooker") end 49 end ) 50 lamp:ListenForEvent("onextinguish", function() 51 lamp.SoundEmitter:PlaySound("dontstarve/common/fireOut") 52 if lamp.components.cooker then lamp:RemoveComponent("cooker") end 53 end ) 54 lamp:AddComponent("workable") 55 lamp.components.workable:SetWorkAction(ACTIONS.HAMMER) 56 lamp.components.workable:SetWorkLeft(3) 57 lamp.components.workable:SetOnFinishCallback(function(lamp) 58 SpawnPrefab("ground_chunks_breaking").Transform:SetPosition(lamp.Transform:GetWorldPosition()) 59 lamp:Remove() 60 end ) 61 lamp:AddTag("ontheground") 62 lamp:AddTag("light") 63 lamp:AddTag("lamps") 64 inst.components.stackable:Get():Remove() 65end 66 inst:AddComponent("deployable") 67 inst.components.deployable.ondeploy = OnDeploy 68 69local function onsave(inst, data) 70 if inst:HasTag("lamps") then 71 data.lamps = true 72 end 73 if inst:HasTag("ontheground") then 74 data.ontheground = true 75 end 76 data.colour_idx = inst.colour_idx 77end 78local function onload(inst, data) 79 if data and data.lamps then 80 inst.AnimState:SetBank("trinkets") 81 inst.AnimState:SetBuild("trinkets") 82 inst.AnimState:PlayAnimation(tostring(2)) 83 inst.components.inventoryitem:ChangeImageName("trinket_2") 84 inst.entity:AddSoundEmitter() 85 inst.Transform:SetScale(1.2,1.2,1.2) 86 inst.colour_idx = math.random(#colours) 87 inst.AnimState:SetMultColour(colours[inst.colour_idx][1],colours[inst.colour_idx][2],colours[inst.colour_idx][3],1) 88 inst:RemoveComponent("stackable") 89 inst:RemoveComponent("tradable") 90 inst:RemoveComponent("healer") 91 inst:RemoveComponent("burnable") 92 inst:RemoveComponent("propagator") 93 inst:RemoveComponent("deployable") 94 inst:RemoveTag("cattoy") 95 inst:AddComponent("burnable") 96 inst.components.burnable:SetFXLevel(3) 97 inst.components.burnable:AddBurnFX("campfirefire", Vector3(0,0.5,0) ) 98 inst.components.inventoryitem:SetOnDroppedFn(function() inst.components.burnable:Ignite(true) inst:AddTag("ontheground") end ) 99 inst.components.inventoryitem:SetOnPickupFn(function() inst.components.burnable:Extinguish() inst:RemoveTag("ontheground") end ) 100 inst.components.inventoryitem:SetOnPutInInventoryFn(function() inst.components.burnable:Extinguish() inst:RemoveTag("ontheground") end ) 101 inst:ListenForEvent("onignite", function() 102 if not inst.components.cooker then inst:AddComponent("cooker") end 103 end ) 104 inst:ListenForEvent("onextinguish", function() 105 inst.SoundEmitter:PlaySound("dontstarve/common/fireOut") 106 if inst.components.cooker then inst:RemoveComponent("cooker") end 107 end ) 108 inst:AddComponent("workable") 109 inst.components.workable:SetWorkAction(ACTIONS.HAMMER) 110 inst.components.workable:SetWorkLeft(3) 111 inst.components.workable:SetOnFinishCallback(function(inst) 112 SpawnPrefab("ground_chunks_breaking").Transform:SetPosition(inst.Transform:GetWorldPosition()) 113 inst:Remove() 114 end ) 115 inst:AddTag("light") 116 inst:AddTag("lamps") 117 end 118 if data and data.ontheground then 119 inst.components.burnable:Ignite(true) 120 inst:AddComponent("cooker") 121 inst:AddTag("ontheground") 122 end 123 if data and data.colour_idx then 124 inst.colour_idx = math.min(#colours, data.colour_idx) 125 inst.AnimState:SetMultColour(colours[inst.colour_idx][1],colours[inst.colour_idx][2],colours[inst.colour_idx][3],1) 126 end 127end 128 inst.OnSave = onsave 129 inst.OnLoad = onload 130 131 即可用蜘蛛腺体种小油灯(颜色随机),无须任何燃料,放在地上自动点燃,拿起来自动熄灭。拿着木头对油灯按鼠标左键,可将木头烧成炭。也可烤食物、取暖、照明,出行必备。不想要小油灯时,用锤子砸掉即可

2025/04/23 · Bny

YN251-我的王国(用远古短棒种国王雕像,可获得税收,有警察巡逻并听你调遣)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二五一.我的王国(用远古短棒种国王雕像,可获得税收,有警察巡逻并听你调遣) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/ruins_bat.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local items = { SWORD = "swap_spear" } 7local function EquipItem(inst, item) 8 if item then 9 inst.AnimState:OverrideSymbol("swap_object", item, item) 10 inst.AnimState:Show("ARM_carry") 11 inst.AnimState:Hide("ARM_normal") 12 end 13end 14 inst.items = items 15 inst.equipfn = EquipItem 16 EquipItem(inst) 17local function createguru(inst) 18 local pt = inst:GetPosition() 19 local guru = SpawnPrefab("ruins_bat") 20 guru.Transform:SetPosition(pt.x, pt.y, pt.z) 21 guru.AnimState:SetBank("wilson") 22 if GetPlayer().prefab == "wilson" then guru.AnimState:SetBuild("wilson") end 23 if GetPlayer().prefab == "wendy" then guru.AnimState:SetBuild("wendy") end 24 if GetPlayer().prefab == "wes" then guru.AnimState:SetBuild("wes") end 25 if GetPlayer().prefab == "wickerbottom" then guru.AnimState:SetBuild("wickerbottom") end 26 if GetPlayer().prefab == "willow" then guru.AnimState:SetBuild("willow") end 27 if GetPlayer().prefab == "wolfgang" then guru.AnimState:SetBuild("wolfgang") end 28 if GetPlayer().prefab == "wx78" then guru.AnimState:SetBuild("wx78") end 29 if GetPlayer().prefab == "woodie" then guru.AnimState:SetBuild("woodie") end 30 if GetPlayer().prefab == "waxwell" then guru.AnimState:SetBuild("waxwell") end 31 if GetPlayer().prefab == "wathgrithr" then guru.AnimState:SetBuild("wathgrithr") end 32 if GetPlayer().prefab == "webber" then guru.AnimState:SetBuild("webber") end 33 guru.AnimState:PlayAnimation("idle") 34 guru.AnimState:OverrideSymbol("swap_object", "swap_cane", "swap_cane") 35 guru.AnimState:Hide("ARM_normal") 36 guru.AnimState:Show("ARM_carry") 37 guru.AnimState:OverrideSymbol("swap_hat", "hat_ruins", "swap_hat") 38 guru.AnimState:Show("HAT") 39 guru.AnimState:Show("HAT_HAIR") 40 guru.AnimState:Hide("HAIR_NOHAT") 41 guru.AnimState:Hide("HAIR") 42 guru.Transform:SetFourFaced() 43 guru.Transform:SetRotation( 0 ) 44 guru.Transform:SetScale(3.5, 3.5, 3.5) 45 local shadow = guru.entity:AddDynamicShadow() 46 shadow:SetSize( 6, 3.5 ) 47 local minimap = guru.entity:AddMiniMapEntity() 48 minimap:SetIcon( "obelisk.png" ) 49 guru.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 50 guru:AddTag("guru") 51 guru:RemoveTag("sharp") 52 guru:RemoveComponent("weapon") 53 guru:RemoveComponent("finiteuses") 54 guru:RemoveComponent("inventoryitem") 55 guru:RemoveComponent("equippable") 56 guru:RemoveComponent("deployable") 57 local light = guru.entity:AddLight() 58 light:SetFalloff(1) 59 light:SetIntensity(.8) 60 light:SetRadius(10) 61 light:SetColour(180/255, 195/255, 50/255) 62 light:Enable(true) 63 guru:AddComponent("workable") 64 guru.components.workable:SetWorkAction(ACTIONS.HAMMER) 65 guru.components.workable:SetWorkLeft(5) 66 guru.components.workable:SetOnFinishCallback(function(guru) 67 SpawnPrefab("collapse_big").Transform:SetPosition(guru.Transform:GetWorldPosition()) 68 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 69 guru:Remove() 70 end ) 71 guru:AddComponent("pickable") 72 guru.components.pickable:SetUp("goldnugget", 480, math.random(15,25)) 73 guru.components.pickable:SetOnPickedFn(function(guru) guru.AnimState:SetBloomEffectHandle("") end ) 74 guru.components.pickable:SetOnRegenFn(function(guru) guru.AnimState:SetBloomEffectHandle("shaders/anim.ksh") end ) 75 guru:ListenForEvent( "daytime", function() 76 for k = 1,math.random(10,25) do 77 local pt0 = guru:GetPosition() 78 local ground = GetWorld() 79 local x = pt0.x+(math.random(50)-math.random(50)) 80 local z = pt0.z+(math.random(50)-math.random(50)) 81 local tile = ground.Map:GetTileAtPoint(x,0, z) 82 if tile ~= GROUND.IMPASSABLE and tile ~= GROUND.INVALID then 83 local militia = SpawnPrefab("ruins_bat") 84 militia.Transform:SetPosition(x,0,z) 85 militia.AnimState:SetBank("wilson") 86 local buildnames = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} 87 local buildname = buildnames[math.random(#buildnames)] 88 militia.AnimState:SetBuild(buildname) 89 militia.AnimState:OverrideSymbol("swap_hat", "hat_walrus", "swap_hat") 90 militia.AnimState:OverrideSymbol("swap_body", "armor_wood", "swap_body") 91 militia.AnimState:OverrideSymbol("swap_object", "swap_spear", "swap_spear") 92 militia.AnimState:Show("HAT") 93 militia.AnimState:Show("HAT_HAIR") 94 militia.AnimState:Hide("HAIR_NOHAT") 95 militia.AnimState:Hide("HAIR") 96 militia.AnimState:Hide("ARM_normal") 97 militia.AnimState:Show("ARM_carry") 98 militia.AnimState:PlayAnimation("idle") 99 militia.Transform:SetFourFaced() 100 local shadow = militia.entity:AddDynamicShadow() 101 shadow:SetSize( 1.3, .6 ) 102 MakeCharacterPhysics(militia, 75, .5) 103 local minimap = militia.entity:AddMiniMapEntity() 104 minimap:SetIcon( "statue_small.png" ) 105 militia:AddTag("militia") 106 militia:AddComponent("locomotor") 107 militia.components.locomotor.walkspeed = 5 108 militia.components.locomotor.runspeed = 10 109 militia:SetStateGraph("SGshadowwaxwell") 110 local brain = require "brains/frogbrain" 111 militia:SetBrain(brain) 112 militia:RemoveTag("sharp") 113 militia:RemoveComponent("weapon") 114 militia:RemoveComponent("finiteuses") 115 militia:RemoveComponent("inventoryitem") 116 militia:RemoveComponent("equippable") 117 militia:RemoveComponent("deployable") 118 militia:AddComponent("follower") 119 militia:AddComponent("knownlocations") 120 militia:AddComponent("health") 121 militia.components.health:SetMaxHealth(1200) 122 militia.components.health.nofadeout = true 123 militia:AddComponent("combat") 124 militia.components.combat:SetDefaultDamage(20) 125 militia.components.combat:SetAttackPeriod(1) 126 militia.components.combat.hiteffectsymbol = "torso" 127 militia.components.combat:SetRange(2, 3) 128 militia.components.combat:SetRetargetFunction(2, function(militia) 129 if not militia.components.health:IsDead() then 130 return FindEntity(militia, 25, function(guy) 131 if guy.components.health and not guy.components.health:IsDead() then 132 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 133 end 134 end ) 135 end 136 end ) 137 militia.components.combat:SetKeepTargetFunction(function(militia, target) return target and target:IsValid() end ) 138 militia:ListenForEvent("attacked", function(militia, data) 139 militia.components.combat:SetTarget(data.attacker) 140 end ) 141 militia.components.inspectable.getstatus = function(militia) 142 if not militia:HasTag("letsgo") then 143 local brain = require "brains/abigailbrain" 144 militia:SetBrain(brain) 145 militia:RestartBrain() 146 militia.components.follower:SetLeader(GetPlayer()) 147 militia:AddTag("letsgo") 148 else 149 local brain = require "brains/frogbrain" 150 militia:SetBrain(brain) 151 militia:RestartBrain() 152 militia.components.follower:SetLeader(nil) 153 militia:RemoveTag("letsgo") 154 end 155 end 156 militia:ListenForEvent( "nighttime", function() militia:Remove() end , GetWorld()) 157 end 158 end 159 end , GetWorld()) 160end 161local function OnDeploy (inst, pt) 162 if GetPlayer().components.inventory:Has("goldnugget", 1000) then 163 GetPlayer().components.inventory:ConsumeByName("goldnugget", 1000) 164 createguru(inst) 165 inst:Remove() 166 end 167end 168 inst:AddComponent("deployable") 169 inst.components.deployable.ondeploy = OnDeploy 170local function onsave(inst, data) 171 if inst:HasTag("guru") then 172 data.guru = true 173 end 174 if inst:HasTag("militia") then 175 data.militia = true 176 end 177 if inst:HasTag("letsgo") then 178 data.letsgo = true 179 end 180end 181local function onload(inst, data) 182 if data and data.guru then 183 createguru(inst) 184 inst:Remove() 185 end 186 if data and data.militia then 187 inst.AnimState:SetBank("wilson") 188 local buildnames = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} 189 local buildname = buildnames[math.random(#buildnames)] 190 inst.AnimState:SetBuild(buildname) 191 inst.AnimState:OverrideSymbol("swap_hat", "hat_walrus", "swap_hat") 192 inst.AnimState:OverrideSymbol("swap_body", "armor_wood", "swap_body") 193 inst.AnimState:OverrideSymbol("swap_object", "swap_spear", "swap_spear") 194 inst.AnimState:Show("HAT") 195 inst.AnimState:Show("HAT_HAIR") 196 inst.AnimState:Hide("HAIR_NOHAT") 197 inst.AnimState:Hide("HAIR") 198 inst.AnimState:Hide("ARM_normal") 199 inst.AnimState:Show("ARM_carry") 200 inst.AnimState:PlayAnimation("idle") 201 inst.Transform:SetFourFaced() 202 local shadow = inst.entity:AddDynamicShadow() 203 shadow:SetSize( 1.3, .6 ) 204 MakeCharacterPhysics(inst, 75, .5) 205 local minimap = inst.entity:AddMiniMapEntity() 206 minimap:SetIcon( "statue_small.png" ) 207 inst:AddTag("militia") 208 inst:AddComponent("locomotor") 209 inst.components.locomotor.walkspeed = 5 210 inst.components.locomotor.runspeed = 10 211 inst:SetStateGraph("SGshadowwaxwell") 212 local brain = require "brains/frogbrain" 213 inst:SetBrain(brain) 214 inst:RemoveTag("sharp") 215 inst:RemoveComponent("weapon") 216 inst:RemoveComponent("finiteuses") 217 inst:RemoveComponent("inventoryitem") 218 inst:RemoveComponent("equippable") 219 inst:RemoveComponent("deployable") 220 inst:AddComponent("follower") 221 inst:AddComponent("knownlocations") 222 inst:AddComponent("health") 223 inst.components.health:SetMaxHealth(1200) 224 inst.components.health.nofadeout = true 225 inst:AddComponent("combat") 226 inst.components.combat:SetDefaultDamage(20) 227 inst.components.combat:SetAttackPeriod(1) 228 inst.components.combat.hiteffectsymbol = "torso" 229 inst.components.combat:SetRange(2, 3) 230 inst.components.combat:SetRetargetFunction(2, function(inst) 231 if not inst.components.health:IsDead() then 232 return FindEntity(inst, 25, function(guy) 233 if guy.components.health and not guy.components.health:IsDead() then 234 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 235 end 236 end ) 237 end 238 end ) 239 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) 240 inst:ListenForEvent("attacked", function(inst, data) 241 inst.components.combat:SetTarget(data.attacker) 242 end ) 243 inst.components.inspectable.getstatus = function(inst) 244 if not inst:HasTag("letsgo") then 245 local brain = require "brains/abigailbrain" 246 inst:SetBrain(brain) 247 inst:RestartBrain() 248 inst.components.follower:SetLeader(GetPlayer()) 249 inst:AddTag("letsgo") 250 else 251 local brain = require "brains/frogbrain" 252 inst:SetBrain(brain) 253 inst:RestartBrain() 254 inst.components.follower:SetLeader(nil) 255 inst:RemoveTag("letsgo") 256 end 257 end 258 inst:ListenForEvent( "nighttime", function() inst:Remove() end , GetWorld()) 259 end 260 if data and data.letsgo then 261 local brain = require "brains/abigailbrain" 262 inst:SetBrain(brain) 263 inst:RestartBrain() 264 inst.components.follower:SetLeader(GetPlayer()) 265 inst:AddTag("letsgo") 266 end 267end 268 inst.OnSave = onsave 269 inst.OnLoad = onload 270 271 即可在身上有1000个黄金时,用远古短棒种国王雕像(你自己的形象),宣誓你在这块大陆上的主权,将消费1000个黄金,身上黄金数不足时,不会种出雕像。当雕像发光时,代表当地的税收已经上缴(每日一次),用鼠标左键点雕像,可收到税款。每天白天,雕像周围会有警察巡逻,黑夜将离去,他们会攻击任何来犯的敌人。鼠标左键点警察(不要拿武器,以免误伤),可让他跟随你(黑夜离去),再次点击可解除跟随。在大陆各地树起国王雕像,建立你的王国,统治整块大陆吧。可通过小地图查看你的势力范围,国王雕像在小地图上显示为方尖碑图标,警察显示为天使雕像图标。不想要国王雕像时,用锤子砸掉即可。远古短棒在远古选项(画着远古祭坛)下,用3个活木头、4个铥矿石、4个噩梦燃料制造,制造时须靠近远古祭坛

2025/04/23 · Bny