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

YN290-逝者的赌局(绳子种人骨,用黄金下注猪拳击手生死战)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二九0.逝者的赌局(绳子种人骨,用黄金下注猪拳击手生死战) 3 4 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/rope.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function OnDeploy (inst, pt) 7 local skeleton = SpawnPrefab("skeleton") 8 if skeleton then 9 skeleton:PushEvent("growfromrope") 10 skeleton.Transform:SetPosition(pt.x, pt.y, pt.z) 11 inst.components.stackable:Get():Remove() 12 end 13end 14 inst:AddComponent("deployable") 15 inst.components.deployable.ondeploy = OnDeploy 16 17 18 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/skeleton.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 19 20local function game(inst) 21 local light = inst.entity:AddLight() 22 light:Enable(true) 23 local num_found = 0 24 for k,v in pairs(inst.components.container.slots) do 25 if v and v.prefab == "goldnugget" then 26 num_found = num_found + v.components.stackable:StackSize() 27 end 28 end 29 inst.components.container:Close(GetPlayer()) 30 inst.components.container.canbeopened = false 31 GetPlayer().components.playercontroller:Enable(false) 32 local bonuspoint1 = math.random(5) 33 local bonuspoint2 = math.random(5) 34 local pt = Vector3(inst.Transform:GetWorldPosition()) 35 local red = SpawnPrefab("pigman") 36 red.Transform:SetPosition(pt.x+4+3, 0, pt.z+4-3) 37 red.components.health:SetMaxHealth(100 * bonuspoint1) 38 red.components.health:DoDelta(200 * bonuspoint1) 39 red.AnimState:SetMultColour(255/255,0/255,0/255,1) 40 red.AnimState:OverrideSymbol("swap_hat", "hat_football", "swap_hat") 41 red.AnimState:Show("hat") 42 local blue = SpawnPrefab("pigman") 43 blue.Transform:SetPosition(pt.x+4-3, 0, pt.z+4+3) 44 blue.components.health:SetMaxHealth(100 * bonuspoint2) 45 blue.components.health:DoDelta(200 * bonuspoint2) 46 blue.AnimState:SetMultColour(0/255,100/255,255/255,1) 47 blue.AnimState:OverrideSymbol("swap_hat", "hat_football", "swap_hat") 48 blue.AnimState:Show("hat") 49 red.components.combat.target = blue 50 blue.components.combat.target = red 51 TheCamera:SetTarget(red) 52 red:ListenForEvent("death", function() 53 inst:DoTaskInTime(3, function() blue:Remove() 54 GetPlayer().components.sanity:DoDelta(-10) 55 GetPlayer().AnimState:PlayAnimation("hit") 56 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 57 inst.components.container:DestroyContents() 58 inst.components.container.canbeopened = true 59 GetPlayer().components.playercontroller:Enable(true) 60 TheCamera:SetTarget(GetPlayer()) 61 light:Enable(false) 62 end ) 63 end ) 64 blue:ListenForEvent("death", function() 65 inst:DoTaskInTime(3, function() red:Remove() 66 GetPlayer().components.sanity:DoDelta(10) 67 for k = 1, num_found do 68 inst.components.container:ConsumeByName("goldnugget", -1) 69 end 70 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") 71 inst.components.container.canbeopened = true 72 GetPlayer().components.playercontroller:Enable(true) 73 TheCamera:SetTarget(GetPlayer()) 74 light:Enable(false) 75 end ) 76 end ) 77end 78local slotpos = { Vector3(0,-75,0)} 79local widgetbuttoninfo = { text = "GO", 80 position = Vector3(0, -165, 0), 81 fn = function(inst) if not inst.components.container:IsEmpty() then game(inst) end 82end } 83local function itemtest(inst, item, slot) 84 if item.prefab == "goldnugget" then 85 return true 86 end 87 return false 88end 89 inst:AddComponent("container") 90 inst.components.container:SetNumSlots(#slotpos) 91 inst.components.container.widgetslotpos = slotpos 92 inst.components.container.widgetpos = Vector3(0,200,0) 93 inst.components.container.side_align_tip = 160 94 inst.components.container.itemtestfn = itemtest 95 inst.components.container.widgetbuttoninfo = widgetbuttoninfo 96 local light = inst.entity:AddLight() 97 light:SetFalloff(1) 98 light:SetIntensity(.8) 99 light:SetRadius(50) 100 light:Enable(false) 101 light:SetColour(180/255, 195/255, 50/255) 102 MakeMediumBurnable(inst) 103 104 即可用绳子种人骨头,鼠标左键点人骨,出现1个格子及GO按钮,在格子中放入黄金后(赌金随意)按GO按钮,红、蓝两个猪拳手出击对战,如果红方获胜,你就赢得1倍奖金(在人骨的格子里领取),并增加10点脑。如果蓝方获胜,格子里的赌金将被收走(逝者获胜),同时减10点脑。平局(双方同时死)判定为逝者获胜。比赛中主角无法走动及攻击(防止作弊),但可以边吃东西边看比赛。人骨最好种在远离猪房、兔房的空旷处,以免干扰比赛。不想要人骨了,烧掉即可。逝者的赌局全天开放,不要沉迷赌博哦

2025/04/23 · Bny

YN291-小酒馆(用剃刀种小酒馆,听音乐、喝烧酒、吃料理、小憩一下)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二九一.小酒馆(用剃刀种小酒馆,听音乐、喝烧酒、吃料理、小憩一下) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/razor.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function bar(inst) 7 local pt = inst:GetPosition() 8 local waiter = SpawnPrefab("razor") 9 waiter.Transform:SetPosition(pt.x, pt.y, pt.z) 10 waiter.AnimState:SetBank("wilson") 11 waiter.AnimState:SetBuild("wes") 12 waiter.AnimState:Hide("ARM_carry") 13 waiter.AnimState:Show("ARM_normal") 14 waiter.Transform:SetFourFaced() 15 waiter.AnimState:PlayAnimation("idle") 16 waiter:AddTag("waiter") 17 waiter:RemoveComponent("inventoryitem") 18 waiter:RemoveComponent("shaver") 19 waiter:RemoveComponent("deployable") 20 waiter:AddComponent("trader") 21 waiter.components.trader:SetAcceptTest(function(waiter, item) 22 if GetPlayer().components.inventory:Has("goldnugget", 1) then 23 if item.prefab == "goldnugget" then 24 return true 25 end 26 end 27 return false 28 end ) 29 waiter.components.trader.onaccept = function(waiter, giver, item) 30 waiter.AnimState:PlayAnimation("idle_onemanband1_loop",true) 31 waiter:DoTaskInTime(5, function() waiter.AnimState:PlayAnimation("idle") end ) 32 GetPlayer().components.sanity:DoDelta(3) 33 end 34 local bar = SpawnPrefab("razor") 35 bar.Transform:SetPosition(pt.x+0.8, 0, pt.z+0.8) 36 bar.AnimState:SetBank("ruins_table") 37 bar.AnimState:SetBuild("ruins_table") 38 bar.AnimState:PlayAnimation("idle") 39 bar:AddTag("goodbye") 40 bar:RemoveComponent("inventoryitem") 41 bar:RemoveComponent("shaver") 42 bar:RemoveComponent("deployable") 43 bar:AddComponent("trader") 44 bar.components.trader:SetAcceptTest(function(bar, item) 45 if GetPlayer().components.inventory:Has("goldnugget", 5) then 46 if item.prefab == "goldnugget" then 47 return true 48 end 49 end 50 return false 51 end ) 52 bar.components.trader.onaccept = function(bar, giver, item) 53 GetPlayer().components.inventory:ConsumeByName("goldnugget", 4) 54 waiter.AnimState:PlayAnimation("give") 55 local wine = SpawnPrefab("razor") 56 wine.AnimState:SetBank("ruins_vase") 57 wine.AnimState:SetBuild("ruins_vase") 58 wine.AnimState:PlayAnimation("idle") 59 wine.Transform:SetScale(0.5, 0.5, 0.5) 60 wine.Physics:SetActive(false) 61 wine:AddTag("goodbye") 62 wine.components.inventoryitem.canbepickedup = false 63 local follower = wine.entity:AddFollower() 64 follower:FollowSymbol( bar.GUID, "swap_object", -100, -170, 0 ) 65 wine.components.inspectable.getstatus = function(wine) 66 wine:Remove() 67 wine = nil 68 GetPlayer().sg:GoToState("eat") 69 GetPlayer().components.sanity:DoDelta(-5) 70 GetPlayer().components.health:DoDelta(20) 71 end 72 end 73 local icebox = SpawnPrefab("razor") 74 icebox.Transform:SetPosition(pt.x-1.6+0.8, 0, pt.z+1.6+0.8) 75 icebox.AnimState:SetBank("icebox") 76 icebox.AnimState:SetBuild("ice_box") 77 icebox.AnimState:PlayAnimation("closed") 78 icebox.AnimState:SetMultColour(255/255,255/255,255/255,1) 79 icebox:AddTag("goodbye") 80 icebox:RemoveComponent("inventoryitem") 81 icebox:RemoveComponent("shaver") 82 icebox:RemoveComponent("deployable") 83 icebox:AddComponent("trader") 84 icebox.components.trader:SetAcceptTest(function(icebox, item) 85 if GetPlayer().components.inventory:Has("goldnugget", 5) then 86 if item.prefab == "goldnugget" then 87 return true 88 end 89 end 90 return false 91 end ) 92 icebox.components.trader.onaccept = function(icebox, giver, item) 93 GetPlayer().components.inventory:ConsumeByName("goldnugget", 4) 94 waiter.AnimState:PlayAnimation("give") 95 local names = {"butterflymuffin","frogglebunwich","taffy","pumpkincookie","stuffedeggplant","fishsticks","honeynuggets","honeyham","dragonpie","kabobs","mandrakesoup","baconeggs","meatballs","bonestew","perogies","turkeydinner","ratatouille","jammypreserves","fruitmedley","fishtacos","waffles","unagi","flowersalad","icecream","watermelonicle","trailmix","hotchili","guacamole"} 96 local name = names[math.random(#names)] 97 local snack = SpawnPrefab(name) 98 giver.components.inventory:GiveItem(snack) 99 end 100 local chair = SpawnPrefab("razor") 101 chair.Transform:SetPosition(pt.x+1.5+0.8, 0, pt.z-1.5+0.8) 102 chair.AnimState:SetBank("ruins_chair") 103 chair.AnimState:SetBuild("ruins_chair") 104 chair.AnimState:PlayAnimation("idle") 105 chair:AddTag("goodbye") 106 chair:RemoveComponent("inventoryitem") 107 chair:RemoveComponent("shaver") 108 chair:RemoveComponent("deployable") 109 chair.components.inspectable.getstatus = function() 110 TheFrontEnd:Fade(true,1) 111 GetClock():NextPhase() 112 GetPlayer().components.hunger:DoDelta(-10) 113 GetPlayer().components.sanity:DoDelta(25) 114 end 115 local music = SpawnPrefab("razor") 116 music.Transform:SetPosition(pt.x+1.5-0.8, 0, pt.z-1.5-0.8) 117 music.AnimState:SetBank("phonograph") 118 music.AnimState:SetBuild("phonograph") 119 music.AnimState:PlayAnimation("idle") 120 music:AddTag("goodbye") 121 music:RemoveComponent("inventoryitem") 122 music:RemoveComponent("shaver") 123 music:RemoveComponent("deployable") 124 music.entity:AddSoundEmitter() 125 music:AddComponent("machine") 126 music.components.machine.turnonfn = function(music) 127 music.AnimState:PlayAnimation("play_loop", true) 128 music.SoundEmitter:PlaySound("dontstarve/maxwell/ragtime", "ragtime") 129 end 130 music.components.machine.turnofffn = function(music) 131 music.AnimState:PlayAnimation("idle") 132 music.SoundEmitter:KillSound("ragtime") 133 music.SoundEmitter:PlaySound("dontstarve/music/gramaphone_end") 134 end 135 music.components.machine:TurnOff() 136 local pot = SpawnPrefab("razor") 137 pot.Transform:SetPosition(pt.x-1.5-1.1, 0, pt.z+1.5-1.1) 138 pot.AnimState:SetBank("cook_pot") 139 pot.AnimState:SetBuild("cook_pot") 140 pot.Transform:SetScale(0.8, 0.8, 0.8) 141 pot.AnimState:PlayAnimation("cooking_loop", true) 142 pot:AddTag("goodbye") 143 pot:RemoveComponent("inventoryitem") 144 pot:RemoveComponent("shaver") 145 pot:RemoveComponent("deployable") 146 pot.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 147 local light = pot.entity:AddLight() 148 light:SetFalloff(1) 149 light:SetIntensity(.8) 150 light:SetRadius(10) 151 light:SetColour(180/255, 195/255, 50/255) 152 light:Enable(true) 153end 154local function OnDeploy (inst, pt) 155 bar(inst) 156 inst:Remove() 157end 158 inst:AddComponent("deployable") 159 inst.components.deployable.ondeploy = OnDeploy 160local function onsave(inst, data) 161 if inst:HasTag("waiter") then 162 data.waiter = true 163 end 164 if inst:HasTag("goodbye") then 165 data.goodbye = true 166 end 167end 168local function onload(inst, data) 169 if data and data.waiter then 170 bar(inst) 171 inst:Remove() 172 end 173 if data and data.goodbye then 174 inst:Remove() 175 end 176end 177 inst.OnSave = onsave 178 inst.OnLoad = onload 179MakeLargeBurnable(inst) 180MakeLargePropagator(inst) 181 182 即可用剃刀种小酒馆,给桌子5个黄金(拿着黄金对桌子点鼠标左键),服务员会为你热1瓶烧酒,左键点桌上的酒瓶即可喝掉,补20点血,但会减5点脑(喝多了会头晕)。给冰箱5个黄金,可以购买料理(直接放入物品栏)。如果你满意酒馆的服务,可以向服务员支付小费(拿着黄金对服务员点鼠标左键),每次1个黄金,补3点脑。如果想休息一下,就用左键点椅子,时间会跳到下一时段,补25点脑,减少10点饥饿。鼠标右键点留声机,可以开关音乐。冬天天冷时,靠近锅会很暖和。不想要小酒馆时,烧掉即可。剃刀在工具选项(画着斧子和镐)下,用2个树枝、2个燧石制造

2025/04/23 · Bny

YN292-野球拳赌场(用火腿短棍种野球拳赌场,与庄家玩剪刀、石头、布赢奖金)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二九二.野球拳赌场(用火腿短棍种野球拳赌场,与庄家玩剪刀、石头、布赢奖金) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/hambat.lua文件, 5 6 1.在Asset("ANIM", "anim/swap_ham_bat.zip"),的下一行插入以下内容: 7 8 Asset("ANIM", "anim/wolfgang.zip"), 9 Asset("ANIM", "anim/wolfgang_skinny.zip"), 10 Asset("ANIM", "anim/wolfgang_mighty.zip"), 11 Asset("ANIM", "anim/player_wolfgang.zip"), 12 13 14 2.将inst.OnLoad = OnLoad替换为以下内容: 15 16local function game(inst) 17 local pt = inst:GetPosition() 18 local makers = SpawnPrefab("hambat") 19 makers.Transform:SetPosition(pt.x, pt.y, pt.z) 20 makers.AnimState:SetBank("wilson") 21 makers.AnimState:SetBuild("wolfgang") 22 makers.AnimState:Hide("ARM_carry") 23 makers.AnimState:Show("ARM_normal") 24 makers.Transform:SetFourFaced() 25 makers.AnimState:PlayAnimation("idle") 26 makers:RemoveComponent("weapon") 27 makers:RemoveComponent("edible") 28 makers:RemoveComponent("perishable") 29 makers:RemoveComponent("inventoryitem") 30 makers:RemoveComponent("equippable") 31 makers:RemoveTag("show_spoilage") 32 makers:AddTag("makers") 33 local light = makers.entity:AddLight() 34 light:SetFalloff(1) 35 light:SetIntensity(.8) 36 light:SetRadius(10) 37 light:SetColour(180/255, 195/255, 50/255) 38 light:Enable(true) 39 local chest1 = SpawnPrefab("hambat") 40 chest1.Transform:SetPosition(pt.x-1+2, pt.y, pt.z-1-2) 41 chest1.AnimState:SetBank("pandoras_chest_large") 42 chest1.AnimState:SetBuild("pandoras_chest_large") 43 chest1.AnimState:PlayAnimation("closed") 44 chest1.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 45 chest1:RemoveComponent("weapon") 46 chest1:RemoveComponent("edible") 47 chest1:RemoveComponent("perishable") 48 chest1:RemoveComponent("inventoryitem") 49 chest1:RemoveComponent("equippable") 50 chest1:RemoveTag("show_spoilage") 51 chest1:AddTag("goodbye") 52 local chest2 = SpawnPrefab("hambat") 53 chest2.Transform:SetPosition(pt.x-1-2, pt.y, pt.z-1+2) 54 chest2.AnimState:SetBank("pandoras_chest_large") 55 chest2.AnimState:SetBuild("pandoras_chest_large") 56 chest2.AnimState:PlayAnimation("closed") 57 chest2.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 58 chest2:RemoveComponent("weapon") 59 chest2:RemoveComponent("edible") 60 chest2:RemoveComponent("perishable") 61 chest2:RemoveComponent("inventoryitem") 62 chest2:RemoveComponent("equippable") 63 chest2:RemoveTag("show_spoilage") 64 chest2:AddTag("goodbye") 65 local carpet = SpawnPrefab("hambat") 66 carpet.Transform:SetPosition(pt.x+2.5, 0, pt.z+2.5) 67 carpet.AnimState:SetBuild("staff_purple_base_ground") 68 carpet.AnimState:SetBank("staff_purple_base_ground") 69 carpet.AnimState:PlayAnimation("idle") 70 carpet.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround ) 71 carpet.AnimState:SetLayer( LAYER_BACKGROUND ) 72 carpet.AnimState:SetSortOrder( 3 ) 73 carpet.Transform:SetRotation( 45 ) 74 carpet.AnimState:SetMultColour(255/255,0/255,0/255,1) 75 carpet.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 76 carpet:RemoveComponent("weapon") 77 carpet:RemoveComponent("edible") 78 carpet:RemoveComponent("perishable") 79 carpet:RemoveComponent("inventoryitem") 80 carpet:RemoveComponent("equippable") 81 carpet:RemoveTag("show_spoilage") 82 carpet:AddTag("goodbye") 83 carpet:AddComponent("trader") 84 carpet.components.trader:SetAcceptTest(function(carpet, item) 85 if GetPlayer().components.inventory:Has("goldnugget", 11) then 86 if item.prefab == "goldnugget" then 87 return true 88 end 89 end 90 return false 91 end ) 92 carpet.components.trader.onaccept = function(carpet, giver, item) 93 GetPlayer().components.inventory:ConsumeByName("goldnugget", 9) 94 makers.AnimState:PlayAnimation("give") 95 local gold = SpawnPrefab("hambat") 96 gold.Transform:SetPosition(pt.x+2.5, 0, pt.z+2.5) 97 gold.AnimState:SetBank("goldnugget") 98 gold.AnimState:SetBuild("gold_nugget") 99 gold.AnimState:PlayAnimation("idle") 100 gold.AnimState:PlayAnimation("sparkle") 101 gold.AnimState:PushAnimation("idle") 102 gold:RemoveComponent("weapon") 103 gold:RemoveComponent("edible") 104 gold:RemoveComponent("perishable") 105 gold:RemoveComponent("inventoryitem") 106 gold:RemoveComponent("equippable") 107 gold:RemoveTag("show_spoilage") 108 gold:AddTag("goodbye") 109 local rock = SpawnPrefab("hambat") 110 rock.Transform:SetPosition(pt.x+4+1.8, 0, pt.z+4-1.8) 111 rock.AnimState:SetBank("rocks") 112 rock.AnimState:SetBuild("rocks") 113 rock.AnimState:PlayAnimation("f1") 114 rock:RemoveComponent("weapon") 115 rock:RemoveComponent("edible") 116 rock:RemoveComponent("perishable") 117 rock:RemoveComponent("inventoryitem") 118 rock:RemoveComponent("equippable") 119 rock:RemoveTag("show_spoilage") 120 rock:AddTag("goodbye") 121 rock.Transform:SetScale(1.2, 1.2, 1.2) 122 rock.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 123 local shears = SpawnPrefab("hambat") 124 shears.Transform:SetPosition(pt.x+4, 0, pt.z+4) 125 shears.AnimState:SetBank("razor") 126 shears.AnimState:SetBuild("razor") 127 shears.AnimState:PlayAnimation("idle") 128 shears:RemoveComponent("weapon") 129 shears:RemoveComponent("edible") 130 shears:RemoveComponent("perishable") 131 shears:RemoveComponent("inventoryitem") 132 shears:RemoveComponent("equippable") 133 shears:RemoveTag("show_spoilage") 134 shears:AddTag("goodbye") 135 shears.Transform:SetScale(1.2, 1.2, 1.2) 136 shears.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 137 local colth = SpawnPrefab("hambat") 138 colth.Transform:SetPosition(pt.x+3.8-1.9, 0, pt.z+3.8+1.9) 139 colth.AnimState:SetBank("blueprint") 140 colth.AnimState:SetBuild("blueprint") 141 colth.AnimState:PlayAnimation("idle") 142 colth:RemoveComponent("weapon") 143 colth:RemoveComponent("edible") 144 colth:RemoveComponent("perishable") 145 colth:RemoveComponent("inventoryitem") 146 colth:RemoveComponent("equippable") 147 colth:RemoveTag("show_spoilage") 148 colth:AddTag("goodbye") 149 colth.Transform:SetScale(1.2, 1.2, 1.2) 150 colth.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 151 local names = {"rocks","razor","blueprint"} 152 local goldnugget = SpawnPrefab("goldnugget") 153 rock.components.inspectable.getstatus = function(rock) 154 makers.AnimState:PlayAnimation("give") 155 local name = names[math.random(#names)] 156 local fist = SpawnPrefab(name) 157 fist.Transform:SetPosition(pt.x+0.7, 0, pt.z+0.7) 158 fist:AddTag("goodbye") 159 fist.Transform:SetScale(1.2, 1.2, 1.2) 160 fist.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 161 fist.components.inventoryitem.canbepickedup = false 162 shears:Remove() colth:Remove() 163 GetPlayer():DoTaskInTime(3, function() rock:Remove() fist:Remove() gold:Remove() end ) 164 if fist.prefab == "rocks" then 165 makers.AnimState:SetBuild("wolfgang") 166 GetPlayer():DoTaskInTime(3, function() 167 for k = 1, 10 do 168 GetPlayer().components.inventory:GiveItem(goldnugget) 169 end 170 end ) 171 end 172 if fist.prefab == "razor" then 173 makers.AnimState:SetBuild("wolfgang_skinny") 174 makers.AnimState:PlayAnimation("hit") 175 GetPlayer():DoTaskInTime(3, function() 176 for k = 1, 20 do 177 GetPlayer().components.inventory:GiveItem(goldnugget) 178 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") 179 end 180 end ) 181 end 182 if fist.prefab == "blueprint" then 183 makers.AnimState:SetBuild("wolfgang_mighty") 184 makers.AnimState:PlayAnimation("idle_onemanband1_loop",true) 185 GetPlayer():DoTaskInTime(3, function() 186 makers.AnimState:PlayAnimation("idle") 187 SpawnPrefab("collapse_small").Transform:SetPosition(pt.x+2.5, 0, pt.z+2.5) 188 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 189 end ) 190 end 191 end 192 shears.components.inspectable.getstatus = function(shears) 193 makers.AnimState:PlayAnimation("give") 194 local name = names[math.random(#names)] 195 local fist = SpawnPrefab(name) 196 fist.Transform:SetPosition(pt.x+0.7, 0, pt.z+0.7) 197 fist:AddTag("goodbye") 198 fist.Transform:SetScale(1.2, 1.2, 1.2) 199 fist.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 200 fist.components.inventoryitem.canbepickedup = false 201 rock:Remove() colth:Remove() 202 GetPlayer():DoTaskInTime(3, function() shears:Remove() fist:Remove() gold:Remove() end ) 203 if fist.prefab == "razor" then 204 makers.AnimState:SetBuild("wolfgang") 205 GetPlayer():DoTaskInTime(3, function() 206 for k = 1, 10 do 207 GetPlayer().components.inventory:GiveItem(goldnugget) 208 end 209 end ) 210 end 211 if fist.prefab == "blueprint" then 212 makers.AnimState:SetBuild("wolfgang_skinny") 213 makers.AnimState:PlayAnimation("hit") 214 GetPlayer():DoTaskInTime(3, function() 215 for k = 1, 20 do 216 GetPlayer().components.inventory:GiveItem(goldnugget) 217 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") 218 end 219 end ) 220 end 221 if fist.prefab == "rocks" then 222 makers.AnimState:SetBuild("wolfgang_mighty") 223 makers.AnimState:PlayAnimation("idle_onemanband1_loop",true) 224 GetPlayer():DoTaskInTime(3, function() 225 makers.AnimState:PlayAnimation("idle") 226 SpawnPrefab("collapse_small").Transform:SetPosition(pt.x+2.5, 0, pt.z+2.5) 227 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 228 end ) 229 end 230 end 231 colth.components.inspectable.getstatus = function(colth) 232 makers.AnimState:PlayAnimation("give") 233 local name = names[math.random(#names)] 234 local fist = SpawnPrefab(name) 235 fist.Transform:SetPosition(pt.x+0.7, 0, pt.z+0.7) 236 fist:AddTag("goodbye") 237 fist.Transform:SetScale(1.2, 1.2, 1.2) 238 fist.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 239 fist.components.inventoryitem.canbepickedup = false 240 shears:Remove() rock:Remove() 241 GetPlayer():DoTaskInTime(3, function() colth:Remove() fist:Remove() gold:Remove() end ) 242 if fist.prefab == "blueprint" then 243 makers.AnimState:SetBuild("wolfgang") 244 GetPlayer():DoTaskInTime(3, function() 245 for k = 1, 10 do 246 GetPlayer().components.inventory:GiveItem(goldnugget) 247 end 248 end ) 249 end 250 if fist.prefab == "rocks" then 251 makers.AnimState:SetBuild("wolfgang_skinny") 252 makers.AnimState:PlayAnimation("hit") 253 GetPlayer():DoTaskInTime(3, function() 254 for k = 1, 20 do 255 GetPlayer().components.inventory:GiveItem(goldnugget) 256 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") 257 end 258 end ) 259 end 260 if fist.prefab == "razor" then 261 makers.AnimState:SetBuild("wolfgang_mighty") 262 makers.AnimState:PlayAnimation("idle_onemanband1_loop",true) 263 GetPlayer():DoTaskInTime(3, function() 264 makers.AnimState:PlayAnimation("idle") 265 SpawnPrefab("collapse_small").Transform:SetPosition(pt.x+2.5, 0, pt.z+2.5) 266 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 267 end ) 268 end 269 end 270 end 271end 272local function OnDeploy (inst, pt) 273 game(inst) 274 inst:Remove() 275end 276 inst:AddComponent("deployable") 277 inst.components.deployable.ondeploy = OnDeploy 278local function onsave(inst, data) 279 if inst:HasTag("makers") then 280 data.makers = true 281 end 282 if inst:HasTag("goodbye") then 283 data.goodbye = true 284 end 285end 286local function onload(inst, data) 287 if data and data.makers then 288 game(inst) 289 inst:Remove() 290 end 291 if data and data.goodbye then 292 inst:Remove() 293 end 294end 295 inst.OnSave = onsave 296 inst.OnLoad = onload 297MakeLargeBurnable(inst) 298MakeLargePropagator(inst) 299 300 即可用火腿短棍种野球拳赌场,给红色三角10个黄金(拿着黄金对红色三角点鼠标左键),会出现石头、剪子、布选项,用鼠标左键点击要出的选项(比如点石头),庄家会同时出拳。野球拳的规则是,石头赢剪子输布、剪子赢布输石头、布赢石头输剪子。如果胜利则获得本金加10个黄金(共20个黄金),打平退还本金,输了就输掉本金。庄家不会与穷光蛋对赌,在付了10个黄金的本金后,身上至少须保有1个黄金。不想要野球拳赌场时,烧掉即可。火腿短棍在战斗选项(画着两把剑)下,用1个猪皮、2个树枝、2个大肉制造

2025/04/23 · Bny

YN293-网上宠宠店(将鸟、兔子、昆虫、鼹鼠放入网店销售箱在线销售)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二九三.网上宠宠店(将鸟、兔子、昆虫、鼹鼠放入网店销售箱在线销售) 3 4 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/rabbit.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6 inst:AddComponent("stackable") 7 inst.components.stackable.maxsize = 999 8 9 10 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/birds.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 11 12 inst:AddComponent("stackable") 13 inst.components.stackable.maxsize = 999 14 15 16 3.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/mole.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 17 18 inst:AddComponent("stackable") 19 inst.components.stackable.maxsize = 999 20 21 22 4.用MT管理器打开游戏目录/assets/scripts/prefabs/bugnet.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 23 24local function netsell(inst) 25 inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" ) 26 inst:DoTaskInTime(3, function() inst.AnimState:SetBloomEffectHandle( "" ) end ) 27 if inst.components.container:Has("goldnugget", 10) then 28 if inst.components.container:Has("bee", 3) then 29 local sellnum = math.random(1,3) 30 inst.components.container:ConsumeByName("bee", sellnum) 31 inst.components.container:ConsumeByName("goldnugget", -sellnum) 32 end 33 if inst.components.container:Has("killerbee", 3) then 34 local sellnum = math.random(1,3) 35 inst.components.container:ConsumeByName("killerbee", sellnum) 36 inst.components.container:ConsumeByName("goldnugget", -sellnum*2) 37 end 38 if inst.components.container:Has("butterfly", 3) then 39 local sellnum = math.random(1,3) 40 inst.components.container:ConsumeByName("butterfly", sellnum) 41 inst.components.container:ConsumeByName("goldnugget", -sellnum) 42 end 43 if inst.components.container:Has("fireflies", 3) then 44 local sellnum = math.random(1,3) 45 inst.components.container:ConsumeByName("fireflies", sellnum) 46 inst.components.container:ConsumeByName("goldnugget", -sellnum*2) 47 end 48 if inst.components.container:Has("crow", 3) then 49 local sellnum = math.random(1,3) 50 inst.components.container:ConsumeByName("crow", sellnum) 51 inst.components.container:ConsumeByName("goldnugget", -sellnum*3) 52 end 53 if inst.components.container:Has("robin", 3) then 54 local sellnum = math.random(1,3) 55 inst.components.container:ConsumeByName("robin", sellnum) 56 inst.components.container:ConsumeByName("goldnugget", -sellnum*3) 57 end 58 if inst.components.container:Has("robin_winter", 3) then 59 local sellnum = math.random(1,3) 60 inst.components.container:ConsumeByName("robin_winter", sellnum) 61 inst.components.container:ConsumeByName("goldnugget", -sellnum*3) 62 end 63 if inst.components.container:Has("rabbit", 3) then 64 local sellnum = math.random(1,3) 65 inst.components.container:ConsumeByName("rabbit", sellnum) 66 inst.components.container:ConsumeByName("goldnugget", -sellnum*2) 67 end 68 if inst.components.container:Has("mole", 3) then 69 local sellnum = math.random(1,3) 70 inst.components.container:ConsumeByName("mole", sellnum) 71 inst.components.container:ConsumeByName("goldnugget", -sellnum*5) 72 end 73 end 74end 75local function OnDeploy (inst, pt) 76 if GetPlayer().components.inventory:Has("goldnugget", 200) then 77 GetPlayer().components.inventory:ConsumeByName("goldnugget", 200) 78 local sellbox = SpawnPrefab("bugnet") 79 sellbox.Transform:SetPosition(pt.x, pt.y, pt.z) 80 sellbox.AnimState:SetBank("bee_box") 81 sellbox.AnimState:SetBuild("bee_box") 82 sellbox.AnimState:PlayAnimation("idle") 83 sellbox.AnimState:SetMultColour(0/255,255/255,0/255,1) 84 sellbox.Transform:SetScale(1.2, 1.2, 1.2) 85 sellbox:AddTag("sellbox") 86 sellbox.components.container.canbeopened = true 87 sellbox:RemoveComponent("weapon") 88 sellbox:RemoveComponent("tool") 89 sellbox:RemoveComponent("finiteuses") 90 sellbox:RemoveComponent("inventoryitem") 91 sellbox:RemoveComponent("equippable") 92 sellbox:AddTag("fridge") 93 MakeLargeBurnable(sellbox) 94 inst:Remove() 95 end 96end 97 inst:AddComponent("deployable") 98 inst.components.deployable.ondeploy = OnDeploy 99local function onsave(inst, data) 100 if inst:HasTag("sellbox") then 101 data.sellbox = true 102 end 103end 104local function onload(inst, data) 105 if data and data.sellbox then 106 inst.AnimState:SetBank("bee_box") 107 inst.AnimState:SetBuild("bee_box") 108 inst.AnimState:PlayAnimation("idle") 109 inst.AnimState:SetMultColour(0/255,255/255,0/255,1) 110 inst.Transform:SetScale(1.2, 1.2, 1.2) 111 inst:AddTag("sellbox") 112 inst.components.container.canbeopened = true 113 inst:RemoveComponent("weapon") 114 inst:RemoveComponent("tool") 115 inst:RemoveComponent("finiteuses") 116 inst:RemoveComponent("inventoryitem") 117 inst:RemoveComponent("equippable") 118 inst:AddTag("fridge") 119 MakeLargeBurnable(inst) 120 end 121end 122local function itemtest(inst, item, slot) 123 if item.prefab == "goldnugget" or item.prefab == "bee" or item.prefab == "killerbee" or item.prefab == "butterfly" or item.prefab == "fireflies" or item.prefab == "crow" or item.prefab == "robin" or item.prefab == "robin_winter" or item.prefab == "rabbit" or item.prefab == "mole" then 124 return true 125 end 126 return false 127end 128local slotpos = {Vector3(75,150,0)} 129for y = 2, 0, -1 do 130 for x = 0, 4 do 131 table.insert(slotpos, Vector3(75*x-75*2+75, 75*y-75*2+75,0)) 132 end 133end 134 inst.OnSave = onsave 135 inst.OnLoad = onload 136 inst:AddComponent("container") 137 inst.components.container:SetNumSlots(#slotpos) 138 inst.components.container.widgetslotpos = slotpos 139 inst.components.container.widgetpos = Vector3(-100,200,0) 140 inst.components.container.side_align_tip = 160 141 inst.components.container.canbeopened = false 142 inst.components.container.itemtestfn = itemtest 143 inst:DoPeriodicTask(30, function() if inst:HasTag("sellbox") then netsell(inst) end end ) 144 145 即可用捕虫网种网店销售箱,将花费200个黄金,身上黄金数不足时,不给网店销售箱。左键点网店销售箱会打开格子,在箱子最顶上的格子里放入10个黄金的保证金,并放入小宠物后(几个品种都可以,但一个品种至少3只),即可在线销售。网店销售箱亮灯时,是在联网结算,打开箱子可看到商品库存的减少、黄金数量的上升,可以取出黄金用于消费,但最顶上的格子里必须保留至少10个黄金的保证金。鼹鼠定价5个黄金,鸟定价3个黄金,杀人蜂、萤火虫、兔子定价2个黄金,蜜蜂、蝴蝶定价1个黄金,当某种商品库存不足3只时,该品种将无人购买,请及时检查并补货。千万不要将黄金放在下面的商品格中,而将最顶上的保证金格子空着,这代表所有商品定价0个黄金,小心被哄抢哦。从此经营自己的网上宠宠店,捕捉小宠物在线销售吧。不需要网店销售箱时,烧掉即可,记得取出黄金和商品哦

2025/04/23 · Bny

YN294-采矿场(用多功能工具种采矿场,打工赚黄金,买卖宝石)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二九四.采矿场(用多功能工具种采矿场,打工赚黄金,买卖宝石) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/axe_pickaxe.lua文件, 5 6 1.在Asset("ANIM", "anim/swap_multitool_axe_pickaxe.zip"),的下一行插入以下内容: 7 8 Asset("ANIM", "anim/wolfgang.zip"), 9 Asset("ANIM", "anim/wolfgang_skinny.zip"), 10 Asset("ANIM", "anim/wolfgang_mighty.zip"), 11 Asset("ANIM", "anim/player_wolfgang.zip"), 12 Asset("SOUND", "sound/wolfgang.fsb"), 13 14 15 2.在inst:AddComponent("inspectable")的下一行插入以下内容: 16 17local function mining(inst) 18 local pt = inst:GetPosition() 19 local boss = SpawnPrefab("multitool_axe_pickaxe") 20 boss.Transform:SetPosition(pt.x, pt.y, pt.z) 21 boss.AnimState:SetBank("wilson") 22 boss.AnimState:SetBuild("wolfgang") 23 boss.AnimState:Hide("ARM_carry") 24 boss.AnimState:Show("ARM_normal") 25 boss.Transform:SetFourFaced() 26 boss.AnimState:OverrideSymbol("swap_hat", "hat_miner", "swap_hat") 27 boss.AnimState:Show("HAT") 28 boss.AnimState:Show("HAT_HAIR") 29 boss.AnimState:Hide("HAIR_NOHAT") 30 boss.AnimState:Hide("HAIR") 31 boss.AnimState:PlayAnimation("idle") 32 boss:AddTag("boss") 33 boss:RemoveComponent("weapon") 34 boss:RemoveComponent("tool") 35 boss:RemoveComponent("finiteuses") 36 boss:RemoveComponent("inventoryitem") 37 boss:RemoveComponent("equippable") 38 boss:RemoveComponent("deployable") 39 boss:RemoveTag("sharp") 40 local light = boss.entity:AddLight() 41 light:SetFalloff(1) 42 light:SetIntensity(.8) 43 light:SetRadius(5) 44 light:SetColour(180/255, 195/255, 50/255) 45 light:Enable(true) 46 boss:AddComponent("trader") 47 boss.components.trader:SetAcceptTest(function(boss, item) 48 if item.prefab == "goldnugget" then 49 return true 50 end 51 if item.prefab == "purplegem" or item.prefab == "bluegem" or item.prefab == "redgem" or item.prefab == "orangegem" or item.prefab == "yellowgem" or item.prefab == "greengem" then 52 return true 53 end 54 return false 55 end ) 56 boss.components.trader.onaccept = function(boss, giver, item) 57 boss.AnimState:PlayAnimation("give") 58 if item.prefab == "goldnugget" then 59 SpawnPrefab("pickaxe").Transform:SetPosition(pt.x+0.5, 0, pt.z+0.5) 60 end 61 if item.prefab == "purplegem" or item.prefab == "bluegem" or item.prefab == "redgem" or item.prefab == "orangegem" or item.prefab == "yellowgem" or item.prefab == "greengem" then 62 SpawnPrefab("goldnugget").Transform:SetPosition(pt.x+0.5, 0, pt.z+0.5) 63 end 64 end 65 boss.components.inspectable.getstatus = function(boss) 66 boss.AnimState:PlayAnimation("give") 67 local rock = SpawnPrefab("multitool_axe_pickaxe") 68 rock.Transform:SetPosition(pt.x+1.5, 0, pt.z+1.5) 69 rock.AnimState:SetBank("rock") 70 rock.AnimState:SetBuild("rock") 71 rock.AnimState:PlayAnimation("full") 72 rock.Transform:SetScale(0.5, 0.5, 0.5) 73 rock:AddTag("goodbye") 74 rock:RemoveComponent("weapon") 75 rock:RemoveComponent("tool") 76 rock:RemoveComponent("finiteuses") 77 rock:RemoveComponent("inventoryitem") 78 rock:RemoveComponent("equippable") 79 rock:RemoveComponent("deployable") 80 rock:RemoveTag("sharp") 81 rock:AddComponent("workable") 82 rock.components.workable:SetWorkAction(ACTIONS.MINE) 83 rock.components.workable:SetWorkLeft(30) 84 rock.components.workable:SetOnWorkCallback(function(rock, worker, workleft) 85 if rock.components.workable.workleft <= 0 then 86 rock.SoundEmitter:PlaySound("dontstarve/wilson/rock_break") 87 boss.AnimState:PlayAnimation("give") 88 for k = 1, 3 do 89 SpawnPrefab("goldnugget").Transform:SetPosition(pt.x+0.5, 0, pt.z-0.5) 90 end 91 rock:Remove() 92 else 93 if rock.components.workable.workleft < 10 then 94 rock.AnimState:PlayAnimation("low") 95 elseif rock.components.workable.workleft < 20 then 96 rock.AnimState:PlayAnimation("med") 97 else 98 rock.AnimState:PlayAnimation("full") 99 end 100 end 101 end) 102 end 103 local mountain = SpawnPrefab("multitool_axe_pickaxe") 104 mountain.Transform:SetPosition(pt.x-2, 0, pt.z-2) 105 mountain.AnimState:SetBank("rock2") 106 mountain.AnimState:SetBuild("rock2") 107 mountain.AnimState:PlayAnimation("full") 108 mountain.Transform:SetScale(2, 2, 2) 109 mountain:AddTag("goodbye") 110 mountain:RemoveComponent("weapon") 111 mountain:RemoveComponent("tool") 112 mountain:RemoveComponent("finiteuses") 113 mountain:RemoveComponent("inventoryitem") 114 mountain:RemoveComponent("equippable") 115 mountain:RemoveComponent("deployable") 116 mountain:RemoveTag("sharp") 117 local miner = SpawnPrefab("multitool_axe_pickaxe") 118 miner.Transform:SetPosition(pt.x+3-2, 0, pt.z-3-2) 119 miner.AnimState:SetBank("wilson") 120 miner.AnimState:SetBuild("wes") 121 miner.Transform:SetFourFaced() 122 miner.AnimState:OverrideSymbol("swap_hat", "hat_miner", "swap_hat") 123 miner.AnimState:Show("HAT") 124 miner.AnimState:Show("HAT_HAIR") 125 miner.AnimState:Hide("HAIR_NOHAT") 126 miner.AnimState:Hide("HAIR") 127 miner.AnimState:OverrideSymbol("swap_object", "swap_pickaxe", "swap_pickaxe") 128 miner.AnimState:Show("ARM_carry") 129 miner.AnimState:Hide("ARM_normal") 130 miner.AnimState:PlayAnimation("pickaxe_pre") 131 miner.AnimState:PlayAnimation("pickaxe_loop", true) 132 miner.Transform:SetRotation( 270 ) 133 miner:AddTag("goodbye") 134 miner:RemoveComponent("weapon") 135 miner:RemoveComponent("tool") 136 miner:RemoveComponent("finiteuses") 137 miner:RemoveComponent("inventoryitem") 138 miner:RemoveComponent("equippable") 139 miner:RemoveComponent("deployable") 140 miner:RemoveTag("sharp") 141 miner:DoPeriodicTask(30, function() 142 miner.AnimState:PlayAnimation("pickaxe_pre") 143 miner.AnimState:PlayAnimation("pickaxe_loop", true) 144 miner.Transform:SetRotation( 270 ) 145 end ) 146 miner:AddComponent("trader") 147 miner.components.trader:SetAcceptTest(function(miner, item) 148 if item.prefab == "goldnugget" then 149 return true 150 end 151 return false 152 end ) 153 miner.components.trader.onaccept = function(miner, giver, item) 154 miner.AnimState:PlayAnimation("give") 155 miner.Transform:SetRotation(GetPlayer().Transform:GetRotation() - 180) 156 local names = {"purplegem","bluegem","redgem","orangegem","yellowgem","greengem"} 157 local name = names[math.random(#names)] 158 local gem = SpawnPrefab(name) 159 GetPlayer().components.inventory:GiveItem(gem) 160 end 161end 162local function OnDeploy (inst, pt) 163 mining(inst) 164 inst:Remove() 165end 166 inst:AddComponent("deployable") 167 inst.components.deployable.ondeploy = OnDeploy 168local function onsave(inst, data) 169 if inst:HasTag("boss") then 170 data.boss = true 171 end 172 if inst:HasTag("goodbye") then 173 data.goodbye = true 174 end 175end 176local function onload(inst, data) 177 if data and data.boss then 178 mining(inst) 179 inst:Remove() 180 end 181 if data and data.goodbye then 182 inst:Remove() 183 end 184end 185 inst.OnSave = onsave 186 inst.OnLoad = onload 187MakeLargeBurnable(inst) 188MakeLargePropagator(inst) 189 190 即可用多功能工具种采矿场,鼠标左键点工头(大力士),他会拿出要你加工的石头,用镐将石头凿碎,即可获得3个黄金的工钱(工头会扔在地上)。可以向工头购买镐(拿着黄金对工头点鼠标左键),每把1个黄金。也可以将自己的宝石卖给工头(拿着宝石对工头点鼠标左键),每颗1个黄金。当然也可以私下向矿工(维斯)购买宝石(拿着黄金对矿工点鼠标左键),同样每颗1个黄金(宝石将直接放入主角物品栏),颜色随机。不想要采矿场时,烧掉即可。多功能工具在远古选项(画着远古祭坛)下,用1把黄金斧头、1把黄金镐、2个铥矿石制造,制造时需要靠近远古祭坛

2025/04/23 · Bny

YN295-雇佣兵工厂(用大理石盔甲种兵工厂,打工赚黄金,购买机械雇佣兵)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二九五.雇佣兵工厂(用大理石盔甲种兵工厂,打工赚黄金,购买机械雇佣兵) 3 4 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/rook.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function onsave(inst, data) 7 if inst:HasTag("retinue") then 8 data.retinue = true 9 end 10 if inst:HasTag("highretinue") then 11 data.highretinue = true 12 end 13 if inst:HasTag("letgo") then 14 data.letgo = true 15 end 16end 17local function onload(inst, data) 18 if data and data.retinue then 19 inst.components.health:SetMaxHealth(1000) 20 inst.components.combat:SetDefaultDamage(100) 21 inst:RemoveTag("monster") 22 inst:AddTag("retinue") 23 local minimap = inst.entity:AddMiniMapEntity() 24 minimap:SetIcon( "chessjunk.png" ) 25 inst.components.locomotor:Stop() 26 inst:SetBrain(nil) 27 inst.components.follower:SetLeader(nil) 28 inst.components.inspectable.getstatus = function(inst) 29 if not inst:HasTag("letgo") then 30 local brain = require "brains/rookbrain" 31 inst:SetBrain(brain) 32 inst:RestartBrain() 33 inst.components.follower:SetLeader(GetPlayer()) 34 inst:AddTag("letgo") 35 else 36 inst.components.locomotor:Stop() 37 inst:SetBrain(nil) 38 inst.components.follower:SetLeader(nil) 39 inst:RemoveTag("letgo") 40 end 41 end 42 inst:AddComponent("trader") 43 inst.components.trader:SetAcceptTest(function(inst, item) 44 if GetPlayer().components.inventory:Has("goldnugget", 50) then 45 if item.prefab == "goldnugget" then 46 return true 47 end 48 end 49 return false 50 end ) 51 inst.components.trader.onaccept = function(inst, giver, item) 52 GetPlayer().components.inventory:ConsumeByName("goldnugget", 49) 53 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") 54 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 55 inst.components.health:SetMaxHealth(2000) 56 inst.components.health:DoDelta(2000) 57 inst.components.combat:SetDefaultDamage(200) 58 inst:AddTag("highretinue") 59 inst.components.locomotor.walkspeed = 15 60 inst.components.locomotor.runspeed = 20 61 end 62 inst.Physics:SetCollisionCallback(function(inst, other) 63 if other and other.components.workable and other.components.workable.workleft > 0 then 64 SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get()) 65 other.components.workable:Destroy(inst) 66 end 67 end) 68 inst.components.locomotor.walkspeed = 10 69 inst.components.locomotor.runspeed = 15 70 inst.components.combat:SetAttackPeriod( 1 ) 71 inst.components.combat:SetRetargetFunction(3, function(inst) 72 if not inst.components.health:IsDead() then 73 return FindEntity(inst, 20, function(guy) 74 if guy.components.health and not guy.components.health:IsDead() then 75 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 76 end 77 end) 78 end 79 end ) 80 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) 81 if data and data.highretinue then 82 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 83 inst.components.health:SetMaxHealth(2000) 84 inst.components.combat:SetDefaultDamage(200) 85 inst:AddTag("highretinue") 86 inst.components.locomotor.walkspeed = 15 87 inst.components.locomotor.runspeed = 20 88 end 89 if data and data.letgo then 90 local brain = require "brains/rookbrain" 91 inst:SetBrain(brain) 92 inst:RestartBrain() 93 inst.components.follower:SetLeader(GetPlayer()) 94 inst:AddTag("letgo") 95 end 96 end 97end 98 inst.OnSave = onsave 99 inst.OnLoad = onload 100 101 102 2.用MT管理器打开游戏目录/assets/scripts/prefabs/bishop.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 103 104local function onsave(inst, data) 105 if inst:HasTag("retinue") then 106 data.retinue = true 107 end 108 if inst:HasTag("highretinue") then 109 data.highretinue = true 110 end 111 if inst:HasTag("letgo") then 112 data.letgo = true 113 end 114end 115local function onload(inst, data) 116 if data and data.retinue then 117 inst.components.health:SetMaxHealth(500) 118 inst.components.combat:SetDefaultDamage(30) 119 inst:RemoveTag("monster") 120 inst:AddTag("retinue") 121 local minimap = inst.entity:AddMiniMapEntity() 122 minimap:SetIcon( "chessjunk.png" ) 123 inst.components.locomotor:Stop() 124 inst:SetBrain(nil) 125 inst.components.follower:SetLeader(nil) 126 inst.components.inspectable.getstatus = function(inst) 127 if not inst:HasTag("letgo") then 128 local brain = require "brains/rookbrain" 129 inst:SetBrain(brain) 130 inst:RestartBrain() 131 inst.components.follower:SetLeader(GetPlayer()) 132 inst:AddTag("letgo") 133 else 134 inst.components.locomotor:Stop() 135 inst:SetBrain(nil) 136 inst.components.follower:SetLeader(nil) 137 inst:RemoveTag("letgo") 138 end 139 end 140 inst:AddComponent("trader") 141 inst.components.trader:SetAcceptTest(function(inst, item) 142 if GetPlayer().components.inventory:Has("goldnugget", 30) then 143 if item.prefab == "goldnugget" then 144 return true 145 end 146 end 147 return false 148 end ) 149 inst.components.trader.onaccept = function(inst, giver, item) 150 GetPlayer().components.inventory:ConsumeByName("goldnugget", 29) 151 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") 152 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 153 inst.components.health:SetMaxHealth(1000) 154 inst.components.health:DoDelta(1000) 155 inst.components.combat:SetDefaultDamage(60) 156 inst:AddTag("highretinue") 157 inst.components.locomotor.walkspeed = 15 158 end 159 inst.components.locomotor.walkspeed = 10 160 inst.components.combat:SetAttackPeriod( 0.5 ) 161 inst.components.combat:SetRetargetFunction(3, function(inst) 162 if not inst.components.health:IsDead() then 163 return FindEntity(inst, 20, function(guy) 164 if guy.components.health and not guy.components.health:IsDead() then 165 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 166 end 167 end) 168 end 169 end ) 170 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) 171 if data and data.highretinue then 172 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 173 inst.components.health:SetMaxHealth(1000) 174 inst.components.combat:SetDefaultDamage(60) 175 inst:AddTag("highretinue") 176 inst.components.locomotor.walkspeed = 15 177 end 178 if data and data.letgo then 179 local brain = require "brains/rookbrain" 180 inst:SetBrain(brain) 181 inst:RestartBrain() 182 inst.components.follower:SetLeader(GetPlayer()) 183 inst:AddTag("letgo") 184 end 185 end 186end 187 inst.OnSave = onsave 188 inst.OnLoad = onload 189 190 191 3.用MT管理器打开游戏目录/assets/scripts/prefabs/knight.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 192 193local function onsave(inst, data) 194 if inst:HasTag("retinue") then 195 data.retinue = true 196 end 197 if inst:HasTag("highretinue") then 198 data.highretinue = true 199 end 200 if inst:HasTag("letgo") then 201 data.letgo = true 202 end 203end 204local function onload(inst, data) 205 if data and data.retinue then 206 inst.components.health:SetMaxHealth(500) 207 inst.components.combat:SetDefaultDamage(15) 208 inst:RemoveTag("monster") 209 inst:AddTag("retinue") 210 local minimap = inst.entity:AddMiniMapEntity() 211 minimap:SetIcon( "chessjunk.png" ) 212 inst.components.locomotor:Stop() 213 inst:SetBrain(nil) 214 inst.components.follower:SetLeader(nil) 215 inst.components.inspectable.getstatus = function(inst) 216 if not inst:HasTag("letgo") then 217 local brain = require "brains/rookbrain" 218 inst:SetBrain(brain) 219 inst:RestartBrain() 220 inst.components.follower:SetLeader(GetPlayer()) 221 inst:AddTag("letgo") 222 else 223 inst.components.locomotor:Stop() 224 inst:SetBrain(nil) 225 inst.components.follower:SetLeader(nil) 226 inst:RemoveTag("letgo") 227 end 228 end 229 inst:AddComponent("trader") 230 inst.components.trader:SetAcceptTest(function(inst, item) 231 if GetPlayer().components.inventory:Has("goldnugget", 15) then 232 if item.prefab == "goldnugget" then 233 return true 234 end 235 end 236 return false 237 end ) 238 inst.components.trader.onaccept = function(inst, giver, item) 239 GetPlayer().components.inventory:ConsumeByName("goldnugget", 14) 240 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") 241 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 242 inst.components.health:SetMaxHealth(1000) 243 inst.components.health:DoDelta(1000) 244 inst.components.combat:SetDefaultDamage(30) 245 inst:AddTag("highretinue") 246 inst.components.locomotor.walkspeed = 15 247 end 248 inst.components.locomotor.walkspeed = 10 249 inst.components.combat:SetAttackPeriod( 0.5 ) 250 inst.components.combat:SetRetargetFunction(3, function(inst) 251 if not inst.components.health:IsDead() then 252 return FindEntity(inst, 20, function(guy) 253 if guy.components.health and not guy.components.health:IsDead() then 254 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 255 end 256 end) 257 end 258 end ) 259 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) 260 if data and data.highretinue then 261 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 262 inst.components.health:SetMaxHealth(1000) 263 inst.components.combat:SetDefaultDamage(30) 264 inst:AddTag("highretinue") 265 inst.components.locomotor.walkspeed = 15 266 end 267 if data and data.letgo then 268 local brain = require "brains/rookbrain" 269 inst:SetBrain(brain) 270 inst:RestartBrain() 271 inst.components.follower:SetLeader(GetPlayer()) 272 inst:AddTag("letgo") 273 end 274 end 275end 276 inst.OnSave = onsave 277 inst.OnLoad = onload 278 279 280 4.用MT管理器打开游戏目录/assets/scripts/prefabs/armor_marble.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 281 282local function repairshop(inst) 283 local pt = inst:GetPosition() 284 local repairboss = SpawnPrefab("armormarble") 285 repairboss.Transform:SetPosition(pt.x, pt.y, pt.z) 286 repairboss.AnimState:SetBank("wilson") 287 repairboss.AnimState:SetBuild("wx78") 288 repairboss.AnimState:OverrideSymbol("swap_hat", "hat_top", "swap_hat") 289 repairboss.AnimState:Show("HAT") 290 repairboss.AnimState:Show("HAT_HAIR") 291 repairboss.AnimState:Hide("HAIR_NOHAT") 292 repairboss.AnimState:Hide("HAIR") 293 repairboss.AnimState:OverrideSymbol("swap_body", "armor_marble", "swap_body") 294 repairboss.AnimState:OverrideSymbol("swap_object", "swap_hammer", "swap_hammer") 295 repairboss.AnimState:Show("ARM_carry") 296 repairboss.AnimState:Hide("ARM_normal") 297 repairboss.Transform:SetFourFaced() 298 repairboss.AnimState:PlayAnimation("idle") 299 repairboss:AddTag("repairboss") 300 repairboss.components.inventoryitem.canbepickedup = false 301 local light = repairboss.entity:AddLight() 302 light:SetFalloff(1) 303 light:SetIntensity(.8) 304 light:SetRadius(10) 305 light:SetColour(180/255, 195/255, 50/255) 306 light:Enable(true) 307 repairboss:AddComponent("trader") 308 repairboss.components.trader:SetAcceptTest(function(repairboss, item) 309 if item.prefab == "goldnugget" then 310 return true 311 end 312 return false 313 end ) 314 repairboss.components.trader.onaccept = function(repairboss, giver, item) 315 repairboss.AnimState:PlayAnimation("give") 316 SpawnPrefab("hammer").Transform:SetPosition(pt.x+0.5, 0, pt.z+0.5) 317 end 318 repairboss.components.inspectable.getstatus = function(repairboss) 319 repairboss.AnimState:PlayAnimation("give") 320 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_stone") 321 local chessjunk = SpawnPrefab("armormarble") 322 chessjunk.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1) 323 chessjunk.AnimState:SetBank("chessmonster_ruins") 324 chessjunk.AnimState:SetBuild("chessmonster_ruins") 325 chessjunk.AnimState:PlayAnimation("idle3") 326 chessjunk:AddTag("goodbye") 327 chessjunk.components.inventoryitem.canbepickedup = false 328 chessjunk:AddComponent("workable") 329 chessjunk.components.workable:SetWorkAction(ACTIONS.HAMMER) 330 chessjunk.components.workable:SetWorkLeft(30) 331 chessjunk.components.workable:SetOnWorkCallback(function(chessjunk, worker, workleft) 332 if chessjunk.components.workable.workleft <= 0 then 333 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/chessjunk_break") 334 chessjunk:Remove() 335 local goods = SpawnPrefab("armormarble") 336 goods.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1) 337 goods:AddTag("goodbye") 338 goods.components.inventoryitem.canbepickedup = false 339 if math.random()<.33 then 340 goods.AnimState:SetBank("rook") 341 goods.AnimState:SetBuild("rook_nightmare") 342 goods.AnimState:PlayAnimation("idle") 343 goods.Transform:SetScale(0.66, 0.66, 0.66) 344 elseif math.random()<.66 then 345 goods.AnimState:SetBank("bishop") 346 goods.AnimState:SetBuild("bishop_nightmare") 347 goods.AnimState:PlayAnimation("idle_loop", true) 348 else 349 goods.AnimState:SetBank("knight") 350 goods.AnimState:SetBuild("knight_nightmare") 351 goods.AnimState:PlayAnimation("idle_loop", true) 352 end 353 GetPlayer():DoTaskInTime(2, function() 354 repairboss.AnimState:PlayAnimation("give") 355 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") 356 for k = 1, 3 do 357 SpawnPrefab("goldnugget").Transform:SetPosition(pt.x+0.5, 0, pt.z-0.5) 358 end 359 goods:Remove() 360 end ) 361 else 362 if chessjunk.components.workable.workleft < 10 then 363 chessjunk.AnimState:PlayAnimation("idle1") 364 elseif chessjunk.components.workable.workleft < 20 then 365 chessjunk.AnimState:PlayAnimation("idle2") 366 else 367 chessjunk.AnimState:PlayAnimation("idle3") 368 end 369 end 370 end) 371 end 372 local chessjunk1 = SpawnPrefab("armormarble") 373 chessjunk1.Transform:SetPosition(pt.x-3, 0, pt.z-3) 374 chessjunk1.AnimState:SetBank("rook") 375 chessjunk1.AnimState:SetBuild("rook_nightmare") 376 chessjunk1.Transform:SetFourFaced() 377 chessjunk1.AnimState:PlayAnimation("idle") 378 chessjunk1.Transform:SetScale(0.66, 0.66, 0.66) 379 chessjunk1:AddTag("goodbye") 380 chessjunk1.components.inventoryitem.canbepickedup = false 381 chessjunk1:AddComponent("trader") 382 chessjunk1.components.trader:SetAcceptTest(function(chessjunk1, item) 383 if GetPlayer().components.inventory:Has("goldnugget", 50) then 384 if item.prefab == "goldnugget" then 385 return true 386 end 387 end 388 return false 389 end ) 390 chessjunk1.components.trader.onaccept = function(chessjunk1, giver, item) 391 GetPlayer().components.inventory:ConsumeByName("goldnugget", 49) 392 repairboss.AnimState:PlayAnimation("give") 393 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available") 394 local retinue1 = SpawnPrefab("rook_nightmare") 395 retinue1.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1) 396 retinue1.components.follower:SetLeader(GetPlayer()) 397 retinue1.components.health:SetMaxHealth(1000) 398 retinue1.components.combat:SetDefaultDamage(100) 399 retinue1:RemoveTag("monster") 400 retinue1:AddTag("retinue") 401 retinue1:AddTag("letgo") 402 local minimap = retinue1.entity:AddMiniMapEntity() 403 minimap:SetIcon( "chessjunk.png" ) 404 retinue1.components.inspectable.getstatus = function(retinue1) 405 if not retinue1:HasTag("letgo") then 406 local brain = require "brains/rookbrain" 407 retinue1:SetBrain(brain) 408 retinue1:RestartBrain() 409 retinue1.components.follower:SetLeader(GetPlayer()) 410 retinue1:AddTag("letgo") 411 else 412 retinue1.components.locomotor:Stop() 413 retinue1.components.follower:SetLeader(nil) 414 retinue1:SetBrain(nil) 415 retinue1:RemoveTag("letgo") 416 end 417 end 418 retinue1:AddComponent("trader") 419 retinue1.components.trader:SetAcceptTest(function(retinue1, item) 420 if GetPlayer().components.inventory:Has("goldnugget", 50) then 421 if item.prefab == "goldnugget" then 422 return true 423 end 424 end 425 return false 426 end ) 427 retinue1.components.trader.onaccept = function(retinue1, giver, item) 428 GetPlayer().components.inventory:ConsumeByName("goldnugget", 49) 429 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") 430 retinue1.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 431 retinue1.components.health:SetMaxHealth(2000) 432 retinue1.components.health:DoDelta(2000) 433 retinue1.components.combat:SetDefaultDamage(200) 434 retinue1:AddTag("highretinue") 435 retinue1.components.locomotor.walkspeed = 15 436 retinue1.components.locomotor.runspeed = 20 437 end 438 retinue1.Physics:SetCollisionCallback(function(retinue1, other) 439 if other and other.components.workable and other.components.workable.workleft > 0 then 440 SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get()) 441 other.components.workable:Destroy(retinue1) 442 end 443 end) 444 retinue1.components.locomotor.walkspeed = 10 445 retinue1.components.locomotor.runspeed = 15 446 retinue1.components.combat:SetAttackPeriod( 1 ) 447 retinue1.components.combat:SetRetargetFunction(3, function(retinue1) 448 if not retinue1.components.health:IsDead() then 449 return FindEntity(retinue1, 20, function(guy) 450 if guy.components.health and not guy.components.health:IsDead() then 451 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 452 end 453 end) 454 end 455 end ) 456 retinue1.components.combat:SetKeepTargetFunction(function(retinue1, target) return target and target:IsValid() end ) 457 end 458 local chessjunk2 = SpawnPrefab("armormarble") 459 chessjunk2.Transform:SetPosition(pt.x-3+2.3, 0, pt.z-3-2.3) 460 chessjunk2.AnimState:SetBank("bishop") 461 chessjunk2.AnimState:SetBuild("bishop_nightmare") 462 chessjunk2.Transform:SetFourFaced() 463 chessjunk2.AnimState:PlayAnimation("idle_loop", true) 464 chessjunk2:AddTag("goodbye") 465 chessjunk2.components.inventoryitem.canbepickedup = false 466 chessjunk2:AddComponent("trader") 467 chessjunk2.components.trader:SetAcceptTest(function(chessjunk2, item) 468 if GetPlayer().components.inventory:Has("goldnugget", 30) then 469 if item.prefab == "goldnugget" then 470 return true 471 end 472 end 473 return false 474 end ) 475 chessjunk2.components.trader.onaccept = function(chessjunk2, giver, item) 476 GetPlayer().components.inventory:ConsumeByName("goldnugget", 29) 477 repairboss.AnimState:PlayAnimation("give") 478 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available") 479 local retinue2 = SpawnPrefab("bishop_nightmare") 480 retinue2.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1) 481 retinue2.components.follower:SetLeader(GetPlayer()) 482 retinue2.components.health:SetMaxHealth(500) 483 retinue2.components.combat:SetDefaultDamage(30) 484 retinue2:RemoveTag("monster") 485 retinue2:AddTag("retinue") 486 retinue2:AddTag("letgo") 487 local minimap = retinue2.entity:AddMiniMapEntity() 488 minimap:SetIcon( "chessjunk.png" ) 489 retinue2.components.inspectable.getstatus = function(retinue2) 490 if not retinue2:HasTag("letgo") then 491 local brain = require "brains/rookbrain" 492 retinue2:SetBrain(brain) 493 retinue2:RestartBrain() 494 retinue2.components.follower:SetLeader(GetPlayer()) 495 retinue2:AddTag("letgo") 496 else 497 retinue2.components.locomotor:Stop() 498 retinue2.components.follower:SetLeader(nil) 499 retinue2:SetBrain(nil) 500 retinue2:RemoveTag("letgo") 501 end 502 end 503 retinue2:AddComponent("trader") 504 retinue2.components.trader:SetAcceptTest(function(retinue2, item) 505 if GetPlayer().components.inventory:Has("goldnugget", 30) then 506 if item.prefab == "goldnugget" then 507 return true 508 end 509 end 510 return false 511 end ) 512 retinue2.components.trader.onaccept = function(retinue2, giver, item) 513 GetPlayer().components.inventory:ConsumeByName("goldnugget", 29) 514 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") 515 retinue2.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 516 retinue2.components.health:SetMaxHealth(1000) 517 retinue2.components.health:DoDelta(1000) 518 retinue2.components.combat:SetDefaultDamage(60) 519 retinue2:AddTag("highretinue") 520 retinue2.components.locomotor.walkspeed = 15 521 end 522 retinue2.components.locomotor.walkspeed = 10 523 retinue2.components.combat:SetAttackPeriod( 0.5 ) 524 retinue2.components.combat:SetRetargetFunction(3, function(retinue2) 525 if not retinue2.components.health:IsDead() then 526 return FindEntity(retinue2, 20, function(guy) 527 if guy.components.health and not guy.components.health:IsDead() then 528 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 529 end 530 end) 531 end 532 end ) 533 retinue2.components.combat:SetKeepTargetFunction(function(retinue2, target) return target and target:IsValid() end ) 534 end 535 local chessjunk3 = SpawnPrefab("armormarble") 536 chessjunk3.Transform:SetPosition(pt.x-3-2, 0, pt.z-3+2) 537 chessjunk3.AnimState:SetBank("knight") 538 chessjunk3.AnimState:SetBuild("knight_nightmare") 539 chessjunk3.Transform:SetFourFaced() 540 chessjunk3.AnimState:PlayAnimation("idle_loop", true) 541 chessjunk3:AddTag("goodbye") 542 chessjunk3.components.inventoryitem.canbepickedup = false 543 chessjunk3:AddComponent("trader") 544 chessjunk3.components.trader:SetAcceptTest(function(chessjunk3, item) 545 if GetPlayer().components.inventory:Has("goldnugget", 15) then 546 if item.prefab == "goldnugget" then 547 return true 548 end 549 end 550 return false 551 end ) 552 chessjunk3.components.trader.onaccept = function(chessjunk3, giver, item) 553 GetPlayer().components.inventory:ConsumeByName("goldnugget", 14) 554 repairboss.AnimState:PlayAnimation("give") 555 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available") 556 local retinue3 = SpawnPrefab("knight_nightmare") 557 retinue3.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1) 558 retinue3.components.follower:SetLeader(GetPlayer()) 559 retinue3.components.health:SetMaxHealth(500) 560 retinue3.components.combat:SetDefaultDamage(15) 561 retinue3:RemoveTag("monster") 562 retinue3:AddTag("retinue") 563 retinue3:AddTag("letgo") 564 local minimap = retinue3.entity:AddMiniMapEntity() 565 minimap:SetIcon( "chessjunk.png" ) 566 retinue3.components.inspectable.getstatus = function(retinue3) 567 if not retinue3:HasTag("letgo") then 568 local brain = require "brains/rookbrain" 569 retinue3:SetBrain(brain) 570 retinue3:RestartBrain() 571 retinue3.components.follower:SetLeader(GetPlayer()) 572 retinue3:AddTag("letgo") 573 else 574 retinue3.components.locomotor:Stop() 575 retinue3.components.follower:SetLeader(nil) 576 retinue3:SetBrain(nil) 577 retinue3:RemoveTag("letgo") 578 end 579 end 580 retinue3:AddComponent("trader") 581 retinue3.components.trader:SetAcceptTest(function(retinue3, item) 582 if GetPlayer().components.inventory:Has("goldnugget", 15) then 583 if item.prefab == "goldnugget" then 584 return true 585 end 586 end 587 return false 588 end ) 589 retinue3.components.trader.onaccept = function(retinue3, giver, item) 590 GetPlayer().components.inventory:ConsumeByName("goldnugget", 14) 591 GetPlayer().SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") 592 retinue3.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 593 retinue3.components.health:SetMaxHealth(1000) 594 retinue3.components.health:DoDelta(1000) 595 retinue3.components.combat:SetDefaultDamage(30) 596 retinue3:AddTag("highretinue") 597 retinue3.components.locomotor.walkspeed = 15 598 end 599 retinue3.components.locomotor.walkspeed = 10 600 retinue3.components.combat:SetAttackPeriod( 0.5 ) 601 retinue3.components.combat:SetRetargetFunction(3, function(retinue3) 602 if not retinue3.components.health:IsDead() then 603 return FindEntity(retinue3, 20, function(guy) 604 if guy.components.health and not guy.components.health:IsDead() then 605 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 606 end 607 end) 608 end 609 end ) 610 retinue3.components.combat:SetKeepTargetFunction(function(retinue3, target) return target and target:IsValid() end ) 611 end 612 local garbage1 = SpawnPrefab("armormarble") 613 garbage1.Transform:SetPosition(pt.x+4-1, 0, pt.z-4-1) 614 garbage1.AnimState:SetBank("researchlab2") 615 garbage1.AnimState:SetBuild("researchlab2") 616 garbage1.AnimState:PlayAnimation("proximity_loop", true) 617 garbage1:AddTag("goodbye") 618 garbage1.components.inventoryitem.canbepickedup = false 619 local garbage2 = SpawnPrefab("armormarble") 620 garbage2.Transform:SetPosition(pt.x+4+1, 0, pt.z-4+1) 621 garbage2.AnimState:SetBank("researchlab2") 622 garbage2.AnimState:SetBuild("researchlab2") 623 garbage2.AnimState:PlayAnimation("proximity_loop", true) 624 garbage2:AddTag("goodbye") 625 garbage2.components.inventoryitem.canbepickedup = false 626 local garbage3 = SpawnPrefab("armormarble") 627 garbage3.Transform:SetPosition(pt.x+4+3, 0, pt.z-4+3) 628 garbage3.AnimState:SetBank("researchlab2") 629 garbage3.AnimState:SetBuild("researchlab2") 630 garbage3.AnimState:PlayAnimation("proximity_loop", true) 631 garbage3:AddTag("goodbye") 632 garbage3.components.inventoryitem.canbepickedup = false 633end 634local function OnDeploy (inst, pt) 635 repairshop(inst) 636 inst:Remove() 637end 638 inst:AddComponent("deployable") 639 inst.components.deployable.ondeploy = OnDeploy 640local function onsave(inst, data) 641 if inst:HasTag("repairboss") then 642 data.repairboss = true 643 end 644 if inst:HasTag("goodbye") then 645 data.goodbye = true 646 end 647end 648local function onload(inst, data) 649 if data and data.repairboss then 650 repairshop(inst) 651 inst:Remove() 652 end 653 if data and data.goodbye then 654 inst:Remove() 655 end 656end 657 inst.OnSave = onsave 658 inst.OnLoad = onload 659MakeLargeBurnable(inst) 660MakeLargePropagator(inst) 661 662 即可用大理石盔甲种雇佣兵工厂,鼠标左键点老板(机器人),他会拿出要你加工的零件,用锤子将零件砸成机械兵,即可获得3个黄金的工钱(老板会扔在地上)。可以向老板购买锤子(拿着黄金对老板点鼠标左键),每把1个黄金。拿着黄金对老板背后的机械兵点鼠标左键,可以购买相应品种的机械雇佣兵,其中机械犀牛每只50个黄金,机械主教每只30个黄金,机械马每只15个黄金,打造你的铁甲战团吧。鼠标左键点雇佣兵,可停止跟随,再次点击可继续跟随,点击时手中不要拿武器,以免误伤。忘记将雇佣军驻扎在何处时,可以打开小地图查找,将显示为机器零件的图标。拥有机械雇佣兵后,可以进一步为它们升级,拿着黄金对自己的机械兵点鼠标左键(同样犀牛50个黄金、主教30个黄金、马15个黄金),可将它们升级为超级机械雇佣兵(身上发亮),攻防及行军速度都将大幅提高。大战之后,给雇佣兵黄金(数量同上),可以将它们的血补满。不想要雇佣兵工厂时,烧掉即可。大理石盔甲在战斗选项(画着两把剑)下,用12块大理石、4条绳子制造

2025/04/23 · Bny

YN296-企鹅养殖场(用蜂巢种企鹅养殖场,买小企鹅,养大后卖出赚黄金)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二九六.企鹅养殖场(用蜂巢种企鹅养殖场,买小企鹅,养大后卖出赚黄金) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/honeycomb.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function penguinshop(inst) 7 local pt = inst:GetPosition() 8 local peddler = SpawnPrefab("honeycomb") 9 peddler.Transform:SetPosition(pt.x, pt.y, pt.z) 10 peddler.AnimState:SetBank("wilson") 11 peddler.AnimState:SetBuild("willow") 12 peddler.AnimState:OverrideSymbol("swap_hat", "hat_straw", "swap_hat") 13 peddler.AnimState:Show("HAT") 14 peddler.AnimState:Show("HAT_HAIR") 15 peddler.AnimState:Hide("HAIR_NOHAT") 16 peddler.AnimState:Hide("HAIR") 17 peddler.AnimState:OverrideSymbol("swap_body", "armor_grass", "swap_body") 18 peddler.AnimState:Hide("ARM_carry") 19 peddler.AnimState:Show("ARM_normal") 20 peddler.Transform:SetFourFaced() 21 peddler.AnimState:PlayAnimation("idle") 22 peddler:AddTag("peddler") 23 peddler:RemoveComponent("stackable") 24 peddler:RemoveComponent("tradable") 25 peddler:RemoveComponent("inventoryitem") 26 local light = peddler.entity:AddLight() 27 light:SetFalloff(1) 28 light:SetIntensity(.8) 29 light:SetRadius(10) 30 light:SetColour(180/255, 195/255, 50/255) 31 light:Enable(true) 32 MakeLargeBurnable(peddler) 33 MakeLargePropagator(peddler) 34 peddler.components.inspectable.getstatus = function(peddler) 35 peddler.AnimState:PlayAnimation("give") 36 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") 37 local pos = Vector3(peddler.Transform:GetWorldPosition()) 38 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 10) 39 for k,v in pairs(ents) do 40 if v:HasTag("penguin_2") then 41 for k = 1, 20 do 42 SpawnPrefab("goldnugget").Transform:SetPosition(v.Transform:GetWorldPosition()) 43 end 44 v:Remove() 45 end 46 end 47 end 48 peddler:AddComponent("trader") 49 peddler.components.trader:SetAcceptTest(function(peddler, item) 50 if GetPlayer().components.inventory:Has("goldnugget", 10) then 51 if item.prefab == "goldnugget" then 52 return true 53 end 54 end 55 return false 56 end ) 57 peddler.components.trader.onaccept = function(peddler, giver, item) 58 peddler.AnimState:PlayAnimation("give") 59 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available") 60 GetPlayer().components.inventory:ConsumeByName("goldnugget", 9) 61 local penguin = SpawnPrefab("honeycomb") 62 penguin.Transform:SetPosition(pt.x+3.1, 0, pt.z+3.1) 63 penguin.AnimState:SetBank("penguin") 64 penguin.AnimState:SetBuild("penguin_build") 65 penguin.Transform:SetFourFaced() 66 penguin.AnimState:PlayAnimation("idle_loop", true) 67 penguin.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 68 penguin.entity:AddSoundEmitter() 69 local minimap = penguin.entity:AddMiniMapEntity() 70 minimap:SetIcon( "penguin.png" ) 71 MakeCharacterPhysics(penguin, 50, .5) 72 penguin:AddComponent("follower") 73 penguin.components.follower:SetLeader(GetPlayer()) 74 local brain = require "brains/abigailbrain" 75 penguin:SetBrain(brain) 76 penguin:AddComponent("locomotor") 77 penguin.components.locomotor.walkspeed = 0.75 78 penguin.components.locomotor.directdrive = false 79 penguin:SetStateGraph("SGpenguin") 80 penguin:AddComponent("combat") 81 penguin.components.combat.hiteffectsymbol = "body" 82 penguin.components.combat:SetAttackPeriod(1) 83 penguin.components.combat:SetRange(2.5) 84 penguin.components.combat:SetDefaultDamage(1) 85 penguin:ListenForEvent("attacked", function(penguin, data) penguin.components.combat:SetTarget(data.attacker) end ) 86 penguin:AddComponent("health") 87 penguin.components.health:SetMaxHealth(50) 88 penguin.Transform:SetScale(0.7, 0.7, 0.7) 89 penguin:RemoveComponent("stackable") 90 penguin:RemoveComponent("tradable") 91 penguin:RemoveComponent("inventoryitem") 92 penguin:AddTag("retinue") 93 penguin:AddTag("penguin_1") 94 penguin:AddComponent("lootdropper") 95 penguin.components.lootdropper:SetLoot({"smallmeat", "smallmeat"}) 96 penguin.components.inspectable.getstatus = function(penguin) 97 if not penguin:HasTag("retinue") then 98 local brain = require "brains/abigailbrain" 99 penguin:SetBrain(brain) 100 penguin.components.follower:SetLeader(GetPlayer()) 101 penguin.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 102 penguin:AddTag("retinue") 103 else 104 local brain = require "brains/leifbrain" 105 penguin:SetBrain(brain) 106 penguin.components.follower:SetLeader(nil) 107 penguin.AnimState:SetBloomEffectHandle("") 108 penguin:RemoveTag("retinue") 109 end 110 end 111 penguin:DoTaskInTime(math.random(480,560), function() 112 if not penguin:HasTag("penguin_2") then 113 penguin.AnimState:PlayAnimation("taunt") 114 penguin.Transform:SetScale(1, 1, 1) 115 penguin:AddTag("penguin_2") 116 penguin.components.lootdropper:SetLoot({"meat", "meat", "drumstick", "drumstick"}) 117 end 118 end ) 119 penguin:DoPeriodicTask(math.random(120,180), function() 120 if penguin:HasTag("penguin_2") then 121 SpawnPrefab("bird_egg").Transform:SetPosition(penguin.Transform:GetWorldPosition()) 122 end 123 end) 124 end 125 local ice = SpawnPrefab("honeycomb") 126 ice.Transform:SetPosition(pt.x+1, 0, pt.z+1) 127 ice.AnimState:SetBank("penguin_ice") 128 ice.AnimState:SetBuild("penguin_ice") 129 ice.AnimState:PlayAnimation("idle") 130 ice.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround ) 131 ice.AnimState:SetLayer( LAYER_BACKGROUND ) 132 ice.AnimState:SetSortOrder( 1 ) 133 ice.Transform:SetRotation( 225 ) 134 ice:RemoveComponent("stackable") 135 ice:RemoveComponent("tradable") 136 ice:RemoveComponent("inventoryitem") 137 ice:AddTag("goodbye") 138 ice:AddTag("NOCLICK") 139 MakeLargeBurnable(ice) 140 MakeLargePropagator(ice) 141 local model1 = SpawnPrefab("honeycomb") 142 model1.Transform:SetPosition(pt.x+2-1, 0, pt.z-2-1) 143 model1.AnimState:SetBank("penguin") 144 model1.AnimState:SetBuild("penguin_build") 145 model1.Transform:SetFourFaced() 146 model1.AnimState:PlayAnimation("idle_loop", true) 147 model1.Transform:SetRotation( 270 ) 148 model1.Transform:SetScale(2, 2, 2) 149 model1:RemoveComponent("stackable") 150 model1:RemoveComponent("tradable") 151 model1:RemoveComponent("inventoryitem") 152 model1.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 153 model1:AddTag("goodbye") 154 MakeLargeBurnable(model1) 155 MakeLargePropagator(model1) 156 local model2 = SpawnPrefab("honeycomb") 157 model2.Transform:SetPosition(pt.x-2-1, 0, pt.z+2-1) 158 model2.AnimState:SetBank("penguin") 159 model2.AnimState:SetBuild("penguin_build") 160 model2.Transform:SetFourFaced() 161 model2.AnimState:PlayAnimation("idle_loop", true) 162 model2.Transform:SetRotation( 90 ) 163 model2.Transform:SetScale(2, 2, 2) 164 model2:RemoveComponent("stackable") 165 model2:RemoveComponent("tradable") 166 model2:RemoveComponent("inventoryitem") 167 model2.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 168 model2:AddTag("goodbye") 169 MakeLargeBurnable(model2) 170 MakeLargePropagator(model2) 171end 172 173local function OnDeploy (inst, pt) 174 penguinshop(inst) 175 inst.components.stackable:Get():Remove() 176end 177 inst:AddComponent("deployable") 178 inst.components.deployable.ondeploy = OnDeploy 179local function onsave(inst, data) 180 if inst:HasTag("peddler") then data.peddler = true end 181 if inst:HasTag("goodbye") then data.goodbye = true end 182 if inst:HasTag("penguin_1") then data.penguin_1 = true end 183 if inst:HasTag("penguin_2") then data.penguin_2 = true end 184 if inst:HasTag("retinue") then data.retinue = true end 185end 186local function onload(inst, data) 187 if data and data.peddler then 188 penguinshop(inst) 189 inst:Remove() 190 end 191 if data and data.goodbye then 192 inst:Remove() 193 end 194 if data and data.penguin_1 then 195 inst.AnimState:SetBank("penguin") 196 inst.AnimState:SetBuild("penguin_build") 197 inst.Transform:SetFourFaced() 198 inst.AnimState:PlayAnimation("idle_loop", true) 199 inst.entity:AddSoundEmitter() 200 local minimap = inst.entity:AddMiniMapEntity() 201 minimap:SetIcon( "penguin.png" ) 202 MakeCharacterPhysics(inst, 50, .5) 203 inst:AddComponent("follower") 204 inst.components.follower:SetLeader(nil) 205 local brain = require "brains/leifbrain" 206 inst:SetBrain(brain) 207 inst:AddComponent("locomotor") 208 inst.components.locomotor.walkspeed = 0.75 209 inst.components.locomotor.directdrive = false 210 inst:SetStateGraph("SGpenguin") 211 inst:AddComponent("combat") 212 inst.components.combat.hiteffectsymbol = "body" 213 inst.components.combat:SetAttackPeriod(1) 214 inst.components.combat:SetRange(2.5) 215 inst.components.combat:SetDefaultDamage(1) 216 inst:ListenForEvent("attacked", function(inst, data) inst.components.combat:SetTarget(data.attacker) end ) 217 inst:AddComponent("health") 218 inst.components.health:SetMaxHealth(50) 219 inst.Transform:SetScale(0.7, 0.7, 0.7) 220 inst:RemoveComponent("stackable") 221 inst:RemoveComponent("tradable") 222 inst:RemoveComponent("inventoryitem") 223 inst:AddTag("penguin_1") 224 inst:AddComponent("lootdropper") 225 inst.components.lootdropper:SetLoot({"smallmeat", "smallmeat"}) 226 inst.components.inspectable.getstatus = function(inst) 227 if not inst:HasTag("retinue") then 228 local brain = require "brains/abigailbrain" 229 inst:SetBrain(brain) 230 inst.components.follower:SetLeader(GetPlayer()) 231 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 232 inst:AddTag("retinue") 233 else 234 local brain = require "brains/leifbrain" 235 inst:SetBrain(brain) 236 inst.components.follower:SetLeader(nil) 237 inst.AnimState:SetBloomEffectHandle("") 238 inst:RemoveTag("retinue") 239 end 240 end 241 inst:DoTaskInTime(math.random(480,560), function() 242 if not inst:HasTag("penguin_2") then 243 inst.AnimState:PlayAnimation("taunt") 244 inst.Transform:SetScale(1, 1, 1) 245 inst:AddTag("penguin_2") 246 inst.components.lootdropper:SetLoot({"meat", "meat", "drumstick", "drumstick"}) 247 end 248 end ) 249 inst:DoPeriodicTask(math.random(120,180), function() 250 if inst:HasTag("penguin_2") then 251 SpawnPrefab("bird_egg").Transform:SetPosition(inst.Transform:GetWorldPosition()) 252 end 253 end) 254 end 255 if data and data.penguin_2 then 256 inst.Transform:SetScale(1, 1, 1) 257 inst:AddTag("penguin_2") 258 inst.components.lootdropper:SetLoot({"meat", "meat", "drumstick", "drumstick"}) 259 end 260 if data and data.retinue then 261 local brain = require "brains/abigailbrain" 262 inst:SetBrain(brain) 263 inst.components.follower:SetLeader(GetPlayer()) 264 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 265 inst:AddTag("retinue") 266 end 267end 268 inst.OnSave = onsave 269 inst.OnLoad = onload 270 271 即可用蜂巢种企鹅养殖场(手里拿着1个蜂巢对地面点鼠标右键,如果拿着多个蜂巢,则不会种出来),拿着黄金对老板点鼠标左键,可以购买小企鹅,每只10个黄金。小企鹅会跟着你,鼠标左键点企鹅可停止跟随,再点则继续跟随(手里不要拿武器,以免误杀)。把它们带到你建造的企鹅圈,圈养起来吧,如果有淘气的企鹅啄墙,把它带离墙边即可。1-2天后,小企鹅长成大企鹅,并会下蛋,你可以继续养它们获得企鹅蛋,也可以带它们去企鹅养殖场,让它们停在冰面上,鼠标左键点老板,即可卖掉冰面上的大企鹅,收购价每只20个黄金。保护好你的企鹅群,从此作一个快乐的养鹅人吧。如果企鹅走失,可以打开小地图查找,将显示企鹅图标。杀掉小企鹅,会掉2个小肉(修改过“巨型超市”则增加掉落1-2个黄金),杀掉大企鹅会掉2个大肉和2个企鹅腿。不想要企鹅养殖场时烧掉即可

2025/04/23 · Bny

YN297-临时工市场(用噩梦花瓣种临时工市场,雇临时工帮你采摘、收获、砍树、开矿)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二九七.临时工市场(用噩梦花瓣种临时工市场,雇临时工帮你采摘、收获、砍树、开矿) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/petals_evil.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function createworker(inst) 7 local pt = inst:GetPosition() 8 local shopsign = SpawnPrefab("petals_evil") 9 shopsign.Transform:SetPosition(pt.x, pt.y, pt.z) 10 shopsign.AnimState:SetBank("sign_home") 11 shopsign.AnimState:SetBuild("sign_home") 12 shopsign.AnimState:PlayAnimation("idle") 13 shopsign.Transform:SetScale(2, 2, 2) 14 shopsign:AddTag("shopsign") 15 shopsign:RemoveComponent("stackable") 16 shopsign:RemoveComponent("tradable") 17 shopsign:RemoveComponent("fuel") 18 shopsign:RemoveComponent("inventoryitem") 19 shopsign:RemoveComponent("edible") 20 shopsign:RemoveComponent("perishable") 21 shopsign:RemoveComponent("burnable") 22 shopsign:RemoveComponent("propagator") 23 shopsign:RemoveComponent("deployable") 24 MakeLargeBurnable(shopsign) 25 MakeLargePropagator(shopsign) 26 local light = shopsign.entity:AddLight() 27 light:SetFalloff(1) 28 light:SetIntensity(.8) 29 light:SetRadius(5) 30 light:SetColour(180/255, 195/255, 50/255) 31 light:Enable(true) 32 shopsign:DoPeriodicTask(6, function(shopsign) 33 shopsign.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 34 shopsign:DoTaskInTime(3, function() shopsign.AnimState:SetBloomEffectHandle("") end ) 35 end ) 36 shopsign.components.inspectable.getstatus = function(shopsign) 37 local pos = Vector3(shopsign.Transform:GetWorldPosition()) 38 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) 39 for k,v in pairs(ents) do 40 if v:HasTag("workerman") then 41 v:Remove() 42 end 43 end 44 local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} 45 local worker1 = SpawnPrefab("petals_evil") 46 worker1.Transform:SetPosition(pt.x+1+3, 0, pt.z+1-3) 47 worker1.AnimState:SetBank("wilson") 48 worker1.buildname = names[math.random(#names)] 49 worker1.AnimState:SetBuild(worker1.buildname) 50 worker1.Transform:SetFourFaced() 51 worker1.AnimState:OverrideSymbol("swap_hat", "hat_bee", "swap_hat") 52 worker1.AnimState:Show("HAT") 53 worker1.AnimState:Show("HAT_HAIR") 54 worker1.AnimState:Hide("HAIR_NOHAT") 55 worker1.AnimState:Hide("HAIR") 56 worker1.AnimState:Show("ARM_normal") 57 worker1.AnimState:Hide("ARM_carry") 58 worker1.AnimState:PlayAnimation("idle") 59 local minimap = worker1.entity:AddMiniMapEntity() 60 minimap:SetIcon( "mushroom_tree_med.png" ) 61 local sound = worker1.entity:AddSoundEmitter() 62 local shadow = worker1.entity:AddDynamicShadow() 63 MakeCharacterPhysics(worker1, 75, .5) 64 shadow:SetSize( 1.3, .6 ) 65 worker1:AddComponent("health") 66 worker1.components.health:SetMaxHealth(1000) 67 worker1.components.health:SetInvincible(true) 68 worker1.components.health.nofadeout = true 69 worker1:AddComponent("combat") 70 worker1:AddComponent("follower") 71 worker1:AddComponent("knownlocations") 72 worker1:AddComponent("locomotor") 73 worker1.components.locomotor.walkspeed = 5 74 worker1.components.locomotor.runspeed = 12 75 worker1:SetStateGraph("SGshadowwaxwell") 76 worker1:RemoveComponent("stackable") 77 worker1:RemoveComponent("tradable") 78 worker1:RemoveComponent("fuel") 79 worker1:RemoveComponent("inventoryitem") 80 worker1:RemoveComponent("edible") 81 worker1:RemoveComponent("perishable") 82 worker1:RemoveComponent("burnable") 83 worker1:RemoveComponent("propagator") 84 worker1:RemoveComponent("deployable") 85 MakeLargeBurnable(worker1) 86 MakeLargePropagator(worker1) 87 worker1:AddTag("workerman") 88 worker1:AddComponent("trader") 89 worker1.components.trader:SetAcceptTest(function(worker1, item) 90 if GetPlayer().components.inventory:Has("goldnugget", 20) then 91 if item.prefab == "goldnugget" then 92 return true 93 end 94 end 95 return false 96 end ) 97 worker1.components.trader.onaccept = function(worker1, giver, item) 98 worker1:AddTag("myworker") 99 worker1:RemoveTag("workerman") 100 worker1:RemoveComponent("burnable") 101 worker1:RemoveComponent("propagator") 102 GetPlayer().components.inventory:ConsumeByName("goldnugget", 19) 103 worker1.task1 = worker1:DoPeriodicTask(0.5, function(worker1) 104 local target = FindEntity(worker1, 10, function(guy) 105 return guy.components.pickable and guy.components.pickable:CanBePicked() and guy.prefab ~= "flower" and guy.prefab ~= "red_mushroom" and guy.prefab ~= "green_mushroom" and guy.prefab ~= "blue_mushroom" and guy.prefab ~= "flint" 106 end ) 107 if target then 108 worker1.components.locomotor:Stop() 109 worker1:SetBrain(nil) 110 worker1.components.follower:SetLeader(nil) 111 local pt1 = target:GetPosition() 112 worker1.components.locomotor:GoToPoint(pt1) 113 worker1.task2 = worker1:DoPeriodicTask(.25, function(worker1) 114 local target2 = FindEntity(worker1, 0.8, function(guy) 115 return guy.components.pickable and guy.components.pickable:CanBePicked() and guy.prefab ~= "flower" and guy.prefab ~= "red_mushroom" and guy.prefab ~= "green_mushroom" and guy.prefab ~= "blue_mushroom" and guy.prefab ~= "flint" 116 end ) 117 if target2 then 118 worker1.AnimState:PlayAnimation("pickup") 119 target2.components.pickable:Pick(GetPlayer()) 120 end 121 end ) 122 else 123 worker1.components.follower:SetLeader(GetPlayer()) 124 local brain = require "brains/chesterbrain" 125 worker1:SetBrain(brain) 126 worker1:RestartBrain() 127 if worker1.task2 then worker1.task2:Cancel() worker1.task2 = nil end 128 end 129 end ) 130 end 131 worker1:ListenForEvent( "nighttime", function() worker1:Remove() end, GetWorld()) 132 local worker2 = SpawnPrefab("petals_evil") 133 worker2.Transform:SetPosition(pt.x+1+1, 0, pt.z+1-1) 134 worker2.AnimState:SetBank("wilson") 135 worker2.buildname = names[math.random(#names)] 136 worker2.AnimState:SetBuild(worker2.buildname) 137 worker2.Transform:SetFourFaced() 138 worker2.AnimState:OverrideSymbol("swap_hat", "hat_straw", "swap_hat") 139 worker2.AnimState:Show("HAT") 140 worker2.AnimState:Show("HAT_HAIR") 141 worker2.AnimState:Hide("HAIR_NOHAT") 142 worker2.AnimState:Hide("HAIR") 143 worker2.AnimState:Show("ARM_normal") 144 worker2.AnimState:Hide("ARM_carry") 145 worker2.AnimState:PlayAnimation("idle") 146 local minimap = worker2.entity:AddMiniMapEntity() 147 minimap:SetIcon( "mushroom_tree_med.png" ) 148 local sound = worker2.entity:AddSoundEmitter() 149 local shadow = worker2.entity:AddDynamicShadow() 150 MakeCharacterPhysics(worker2, 75, .5) 151 shadow:SetSize( 1.3, .6 ) 152 worker2:AddComponent("health") 153 worker2.components.health:SetMaxHealth(1000) 154 worker2.components.health:SetInvincible(true) 155 worker2.components.health.nofadeout = true 156 worker2:AddComponent("combat") 157 worker2:AddComponent("follower") 158 worker2:AddComponent("knownlocations") 159 worker2:AddComponent("locomotor") 160 worker2.components.locomotor.walkspeed = 5 161 worker2.components.locomotor.runspeed = 12 162 worker2:SetStateGraph("SGshadowwaxwell") 163 worker2:RemoveComponent("stackable") 164 worker2:RemoveComponent("tradable") 165 worker2:RemoveComponent("fuel") 166 worker2:RemoveComponent("inventoryitem") 167 worker2:RemoveComponent("edible") 168 worker2:RemoveComponent("perishable") 169 worker2:RemoveComponent("burnable") 170 worker2:RemoveComponent("propagator") 171 worker2:RemoveComponent("deployable") 172 MakeLargeBurnable(worker2) 173 MakeLargePropagator(worker2) 174 worker2:AddTag("workerman") 175 worker2:AddComponent("trader") 176 worker2.components.trader:SetAcceptTest(function(worker2, item) 177 if GetPlayer().components.inventory:Has("goldnugget", 20) then 178 if item.prefab == "goldnugget" then 179 return true 180 end 181 end 182 return false 183 end ) 184 worker2.components.trader.onaccept = function(worker2, giver, item) 185 worker2:AddTag("myworker") 186 worker2:RemoveTag("workerman") 187 worker2:RemoveComponent("burnable") 188 worker2:RemoveComponent("propagator") 189 GetPlayer().components.inventory:ConsumeByName("goldnugget", 19) 190 worker2.task1 = worker2:DoPeriodicTask(0.5, function(worker2) 191 local target = FindEntity(worker2, 10, function(guy) 192 return guy.components.crop and guy.components.crop.matured 193 end ) 194 if target then 195 worker2.components.locomotor:Stop() 196 worker2:SetBrain(nil) 197 worker2.components.follower:SetLeader(nil) 198 local pt1 = target:GetPosition() 199 worker2.components.locomotor:GoToPoint(pt1) 200 worker2.task2 = worker2:DoPeriodicTask(.25, function(worker2) 201 local target2 = FindEntity(worker2, 0.8, function(guy) 202 return guy.components.crop and guy.components.crop.matured 203 end ) 204 if target2 then 205 worker2.AnimState:PlayAnimation("pickup") 206 target2.components.crop:Harvest(GetPlayer()) 207 end 208 local target3 = FindEntity(worker2, 0.8, function(guy) 209 return guy.components.grower and guy.components.grower:IsEmpty() 210 end ) 211 if target3 then 212 target3.components.grower.cycles_left = target3.components.grower.max_cycles_left 213 end 214 end ) 215 else 216 worker2.components.follower:SetLeader(GetPlayer()) 217 local brain = require "brains/chesterbrain" 218 worker2:SetBrain(brain) 219 worker2:RestartBrain() 220 if worker2.task2 then worker2.task2:Cancel() worker2.task2 = nil end 221 if worker2.task3 then worker2.task3:Cancel() worker2.task3 = nil end 222 end 223 end ) 224 end 225 worker2:ListenForEvent( "nighttime", function() worker2:Remove() end, GetWorld()) 226 local worker3 = SpawnPrefab("petals_evil") 227 worker3.Transform:SetPosition(pt.x+1-1, 0, pt.z+1+1) 228 worker3.AnimState:SetBank("wilson") 229 worker3.buildname = names[math.random(#names)] 230 worker3.AnimState:SetBuild(worker3.buildname) 231 worker3.Transform:SetFourFaced() 232 worker3.AnimState:OverrideSymbol("swap_object", "swap_axe", "swap_axe") 233 worker3.AnimState:Show("ARM_carry") 234 worker3.AnimState:Hide("ARM_normal") 235 worker3.AnimState:PlayAnimation("idle") 236 local minimap = worker3.entity:AddMiniMapEntity() 237 minimap:SetIcon( "mushroom_tree_med.png" ) 238 local sound = worker3.entity:AddSoundEmitter() 239 local shadow = worker3.entity:AddDynamicShadow() 240 MakeCharacterPhysics(worker3, 75, .5) 241 shadow:SetSize( 1.3, .6 ) 242 worker3:AddComponent("health") 243 worker3.components.health:SetMaxHealth(1000) 244 worker3.components.health:SetInvincible(true) 245 worker3.components.health.nofadeout = true 246 worker3:AddComponent("combat") 247 worker3:AddComponent("follower") 248 worker3:AddComponent("knownlocations") 249 worker3:AddComponent("locomotor") 250 worker3.components.locomotor.walkspeed = 5 251 worker3.components.locomotor.runspeed = 12 252 worker3:SetStateGraph("SGshadowwaxwell") 253 worker3:RemoveComponent("stackable") 254 worker3:RemoveComponent("tradable") 255 worker3:RemoveComponent("fuel") 256 worker3:RemoveComponent("inventoryitem") 257 worker3:RemoveComponent("edible") 258 worker3:RemoveComponent("perishable") 259 worker3:RemoveComponent("burnable") 260 worker3:RemoveComponent("propagator") 261 worker3:RemoveComponent("deployable") 262 MakeLargeBurnable(worker3) 263 MakeLargePropagator(worker3) 264 worker3:AddTag("workerman") 265 worker3:AddComponent("trader") 266 worker3.components.trader:SetAcceptTest(function(worker3, item) 267 if GetPlayer().components.inventory:Has("goldnugget", 20) then 268 if item.prefab == "goldnugget" then 269 return true 270 end 271 end 272 return false 273 end ) 274 worker3.components.trader.onaccept = function(worker3, giver, item) 275 worker3:AddTag("myworker") 276 worker3:RemoveTag("workerman") 277 worker3:RemoveComponent("burnable") 278 worker3:RemoveComponent("propagator") 279 GetPlayer().components.inventory:ConsumeByName("goldnugget", 19) 280 worker3.task1 = worker3:DoPeriodicTask(0.5, function(worker3) 281 local target = FindEntity(worker3, 15, function(guy) 282 return guy:HasTag("tree") and guy.components.workable and guy.components.workable.workleft > 0 283 end ) 284 if target then 285 worker3.components.locomotor:Stop() 286 worker3:SetBrain(nil) 287 worker3.components.follower:SetLeader(nil) 288 local pt1 = target:GetPosition() 289 worker3.components.locomotor:GoToPoint(pt1) 290 worker3.task2 = worker3:DoPeriodicTask(.25, function(worker3) 291 local target2 = FindEntity(worker3, 2, function(guy) 292 return guy:HasTag("tree") and guy.components.workable and guy.components.workable.workleft > 0 293 end ) 294 if target2 then 295 worker3.AnimState:PlayAnimation("pickup") 296 target2.components.workable:Destroy(worker3) 297 end 298 end ) 299 else 300 worker3.components.follower:SetLeader(GetPlayer()) 301 local brain = require "brains/chesterbrain" 302 worker3:SetBrain(brain) 303 worker3:RestartBrain() 304 if worker3.task2 then worker3.task2:Cancel() worker3.task2 = nil end 305 end 306 end ) 307 end 308 worker3:ListenForEvent( "nighttime", function() worker3:Remove() end, GetWorld()) 309 local worker4 = SpawnPrefab("petals_evil") 310 worker4.Transform:SetPosition(pt.x+1-3, 0, pt.z+1+3) 311 worker4.AnimState:SetBank("wilson") 312 worker4.buildname = names[math.random(#names)] 313 worker4.AnimState:SetBuild(worker4.buildname) 314 worker4.Transform:SetFourFaced() 315 worker4.AnimState:OverrideSymbol("swap_hat", "hat_miner", "swap_hat") 316 worker4.AnimState:Show("HAT") 317 worker4.AnimState:Show("HAT_HAIR") 318 worker4.AnimState:Hide("HAIR_NOHAT") 319 worker4.AnimState:Hide("HAIR") 320 worker4.AnimState:OverrideSymbol("swap_object", "swap_pickaxe", "swap_pickaxe") 321 worker4.AnimState:Show("ARM_carry") 322 worker4.AnimState:Hide("ARM_normal") 323 worker4.AnimState:PlayAnimation("idle") 324 local minimap = worker4.entity:AddMiniMapEntity() 325 minimap:SetIcon( "mushroom_tree_med.png" ) 326 local sound = worker4.entity:AddSoundEmitter() 327 local shadow = worker4.entity:AddDynamicShadow() 328 MakeCharacterPhysics(worker4, 75, .5) 329 shadow:SetSize( 1.3, .6 ) 330 worker4:AddComponent("health") 331 worker4.components.health:SetMaxHealth(1000) 332 worker4.components.health:SetInvincible(true) 333 worker4.components.health.nofadeout = true 334 worker4:AddComponent("combat") 335 worker4:AddComponent("follower") 336 worker4:AddComponent("knownlocations") 337 worker4:AddComponent("locomotor") 338 worker4.components.locomotor.walkspeed = 5 339 worker4.components.locomotor.runspeed = 12 340 worker4:SetStateGraph("SGshadowwaxwell") 341 worker4:RemoveComponent("stackable") 342 worker4:RemoveComponent("tradable") 343 worker4:RemoveComponent("fuel") 344 worker4:RemoveComponent("inventoryitem") 345 worker4:RemoveComponent("edible") 346 worker4:RemoveComponent("perishable") 347 worker4:RemoveComponent("burnable") 348 worker4:RemoveComponent("propagator") 349 worker4:RemoveComponent("deployable") 350 MakeLargeBurnable(worker4) 351 MakeLargePropagator(worker4) 352 worker4:AddTag("workerman") 353 worker4:AddComponent("trader") 354 worker4.components.trader:SetAcceptTest(function(worker4, item) 355 if GetPlayer().components.inventory:Has("goldnugget", 20) then 356 if item.prefab == "goldnugget" then 357 return true 358 end 359 end 360 return false 361 end ) 362 worker4.components.trader.onaccept = function(worker4, giver, item) 363 worker4:AddTag("myworker") 364 worker4:RemoveTag("workerman") 365 worker4:RemoveComponent("burnable") 366 worker4:RemoveComponent("propagator") 367 GetPlayer().components.inventory:ConsumeByName("goldnugget", 19) 368 worker4.task1 = worker4:DoPeriodicTask(0.5, function(worker4) 369 local target = FindEntity(worker4, 15, function(guy) 370 return guy.prefab == "rock1" or guy.prefab == "rock2" or guy.prefab == "rock_flintless" or guy.prefab == "rock_flintless_med" or guy.prefab == "rock_flintless_low" or guy.prefab == "rock_ice" 371 end ) 372 if target then 373 worker4.components.locomotor:Stop() 374 worker4:SetBrain(nil) 375 worker4.components.follower:SetLeader(nil) 376 local pt1 = target:GetPosition() 377 worker4.components.locomotor:GoToPoint(pt1) 378 worker4.task2 = worker4:DoPeriodicTask(.25, function(worker4) 379 local target2 = FindEntity(worker4, 2, function(guy) 380 return guy.prefab == "rock1" or guy.prefab == "rock2" or guy.prefab == "rock_flintless" or guy.prefab == "rock_flintless_med" or guy.prefab == "rock_flintless_low" or guy.prefab == "rock_ice" 381 end ) 382 if target2 then 383 worker4.AnimState:PlayAnimation("pickup") 384 target2.components.workable:Destroy(worker4) 385 end 386 end ) 387 else 388 worker4.components.follower:SetLeader(GetPlayer()) 389 local brain = require "brains/chesterbrain" 390 worker4:SetBrain(brain) 391 worker4:RestartBrain() 392 if worker4.task2 then worker4.task2:Cancel() worker4.task2 = nil end 393 end 394 end ) 395 end 396 worker4:ListenForEvent( "nighttime", function() worker4:Remove() end, GetWorld()) 397 end 398 local shopsign1 = SpawnPrefab("petals_evil") 399 shopsign1.Transform:SetPosition(pt.x+2+3, 0, pt.z+2-3) 400 shopsign1.AnimState:SetBank("sign_home") 401 shopsign1.AnimState:SetBuild("sign_home") 402 shopsign1.AnimState:PlayAnimation("idle") 403 shopsign1.Transform:SetScale(0.5, 0.5, 0.5) 404 shopsign1:RemoveComponent("stackable") 405 shopsign1:RemoveComponent("tradable") 406 shopsign1:RemoveComponent("fuel") 407 shopsign1:RemoveComponent("inventoryitem") 408 shopsign1:RemoveComponent("edible") 409 shopsign1:RemoveComponent("perishable") 410 shopsign1:RemoveComponent("burnable") 411 shopsign1:RemoveComponent("propagator") 412 shopsign1:RemoveComponent("deployable") 413 MakeLargeBurnable(shopsign1) 414 MakeLargePropagator(shopsign1) 415 shopsign1:AddTag("goodbye") 416 local shopsign2 = SpawnPrefab("petals_evil") 417 shopsign2.Transform:SetPosition(pt.x+2+1, 0, pt.z+2-1) 418 shopsign2.AnimState:SetBank("sign_home") 419 shopsign2.AnimState:SetBuild("sign_home") 420 shopsign2.AnimState:PlayAnimation("idle") 421 shopsign2.Transform:SetScale(0.5, 0.5, 0.5) 422 shopsign2:RemoveComponent("stackable") 423 shopsign2:RemoveComponent("tradable") 424 shopsign2:RemoveComponent("fuel") 425 shopsign2:RemoveComponent("inventoryitem") 426 shopsign2:RemoveComponent("edible") 427 shopsign2:RemoveComponent("perishable") 428 shopsign2:RemoveComponent("burnable") 429 shopsign2:RemoveComponent("propagator") 430 shopsign2:RemoveComponent("deployable") 431 MakeLargeBurnable(shopsign2) 432 MakeLargePropagator(shopsign2) 433 shopsign2:AddTag("goodbye") 434 local shopsign3 = SpawnPrefab("petals_evil") 435 shopsign3.Transform:SetPosition(pt.x+2-1, 0, pt.z+2+1) 436 shopsign3.AnimState:SetBank("sign_home") 437 shopsign3.AnimState:SetBuild("sign_home") 438 shopsign3.AnimState:PlayAnimation("idle") 439 shopsign3.Transform:SetScale(0.5, 0.5, 0.5) 440 shopsign3:RemoveComponent("stackable") 441 shopsign3:RemoveComponent("tradable") 442 shopsign3:RemoveComponent("fuel") 443 shopsign3:RemoveComponent("inventoryitem") 444 shopsign3:RemoveComponent("edible") 445 shopsign3:RemoveComponent("perishable") 446 shopsign3:RemoveComponent("burnable") 447 shopsign3:RemoveComponent("propagator") 448 shopsign3:RemoveComponent("deployable") 449 MakeLargeBurnable(shopsign3) 450 MakeLargePropagator(shopsign3) 451 shopsign3:AddTag("goodbye") 452 local shopsign4 = SpawnPrefab("petals_evil") 453 shopsign4.Transform:SetPosition(pt.x+2-3, 0, pt.z+2+3) 454 shopsign4.AnimState:SetBank("sign_home") 455 shopsign4.AnimState:SetBuild("sign_home") 456 shopsign4.AnimState:PlayAnimation("idle") 457 shopsign4.Transform:SetScale(0.5, 0.5, 0.5) 458 shopsign4:RemoveComponent("stackable") 459 shopsign4:RemoveComponent("tradable") 460 shopsign4:RemoveComponent("fuel") 461 shopsign4:RemoveComponent("inventoryitem") 462 shopsign4:RemoveComponent("edible") 463 shopsign4:RemoveComponent("perishable") 464 shopsign4:RemoveComponent("burnable") 465 shopsign4:RemoveComponent("propagator") 466 shopsign4:RemoveComponent("deployable") 467 MakeLargeBurnable(shopsign4) 468 MakeLargePropagator(shopsign4) 469 shopsign4:AddTag("goodbye") 470end 471local function OnDeploy (inst, pt) 472 createworker(inst) 473 inst.components.stackable:Get():Remove() 474end 475 inst:AddComponent("deployable") 476 inst.components.deployable.ondeploy = OnDeploy 477local function onsave(inst, data) 478 if inst:HasTag("shopsign") then 479 data.shopsign = true 480 end 481 if inst:HasTag("workerman") then 482 data.workerman = true 483 end 484 if inst:HasTag("myworker") then 485 data.myworker = true 486 end 487 if inst:HasTag("goodbye") then 488 data.goodbye = true 489 end 490end 491local function onload(inst, data) 492 if data and data.shopsign then 493 createworker(inst) 494 inst:Remove() 495 end 496 if data and data.workerman then 497 inst:Remove() 498 end 499 if data and data.myworker then 500 inst:Remove() 501 end 502 if data and data.goodbye then 503 inst:Remove() 504 end 505end 506 inst.OnSave = onsave 507 inst.OnLoad = onload 508 509 即可用噩梦花瓣种临时工市场(拿着1个噩梦花瓣对地面点鼠标右键,如果拿着多个噩梦花瓣,则不会种出来),鼠标左键点击大招牌,会有4种临时工来应聘,从左到右分别是采摘工(采摘植物)、农民(收获农田并施肥)、伐木工(砍树)、矿工(开矿),想雇佣什么工种,就拿着黄金对他点鼠标左键,每人每天20个黄金。再次点大招牌,可以换不同的应聘人员供你选择。雇佣临时工后,他会跟随你,把他带到工作场所,会自动开始干活,干完后继续跟随。可打开小地图查询临时工的位置,显示为红色蘑菇树的图标。临时工会在每天黑夜来临时下班,想让你花费的工资更值得,就尽可能早点雇佣他们。如果想提早解雇临时工,就存档退出再读档,他们就被遣散了。不想要临时工市场时,烧掉即可

2025/04/23 · Bny

YN298-我的果汁店(用治疗药膏种果汁店,自己制作果汁,顾客上门购买)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二九八.我的果汁店(用治疗药膏种果汁店,自己制作果汁,顾客上门购买) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/healingsalve.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function itemtest(inst, item, slot) 7 if item.prefab == "cave_banana" or item.prefab == "pomegranate" or item.prefab == "dragonfruit" then 8 return true 9 end 10 return false 11end 12local slotpos = { Vector3(0,32+4,0), Vector3(0,-(32+4),0), Vector3(0,-(64+32+8+4),0)} 13local widgetbuttoninfo = { 14 text = "Start", 15 position = Vector3(0, -165, 0), 16 fn = function(inst) 17 if inst:HasTag("juicer") and inst.components.container:Has("cave_banana", 1) and inst.components.container:Has("pomegranate", 1) and inst.components.container:Has("dragonfruit", 1) then 18 inst.components.container:ConsumeByName("cave_banana", 1) 19 inst.components.container:ConsumeByName("pomegranate", 1) 20 inst.components.container:ConsumeByName("dragonfruit", 1) 21 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available") 22 local sweets = SpawnPrefab("healingsalve") 23 sweets.AnimState:SetBank("food") 24 sweets.AnimState:SetBuild("cook_pot_food") 25 sweets.AnimState:PlayAnimation("fruitmedley", false) 26 sweets:RemoveComponent("stackable") 27 sweets:RemoveComponent("deployable") 28 sweets.components.healer:SetHealthAmount(TUNING.HEALING_SUPERHUGE) 29 sweets.components.inventoryitem:ChangeImageName("fruitmedley") 30 sweets.Transform:SetScale(1.2, 1.2, 1.2) 31 sweets:AddTag("sweets") 32 GetPlayer().components.inventory:GiveItem(sweets) 33 end 34 end } 35 inst:AddComponent("container") 36 inst.components.container.widgetbuttoninfo = widgetbuttoninfo 37 inst.components.container:SetNumSlots(#slotpos) 38 inst.components.container.widgetslotpos = slotpos 39 inst.components.container.widgetpos = Vector3(0,180,0) 40 inst.components.container.side_align_tip = 160 41 inst.components.container.itemtestfn = itemtest 42 inst.components.container.canbeopened = false 43local function sweetshop(inst) 44 local pt = inst:GetPosition() 45 local shop = SpawnPrefab("healingsalve") 46 shop.Transform:SetPosition(pt.x, pt.y, pt.z) 47 shop.AnimState:SetBank("rabbithouse") 48 shop.AnimState:SetBuild("rabbit_house") 49 shop.AnimState:PlayAnimation("idle", true) 50 shop.Transform:SetScale(0.8, 0.8, 0.8) 51 shop:RemoveComponent("stackable") 52 shop:RemoveComponent("inventoryitem") 53 shop:RemoveComponent("healer") 54 shop:RemoveComponent("deployable") 55 local light = shop.entity:AddLight() 56 light:SetFalloff(1) 57 light:SetIntensity(.8) 58 light:SetRadius(5) 59 light:SetColour(180/255, 195/255, 50/255) 60 light:Enable(true) 61 MakeLargeBurnable(shop) 62 MakeLargePropagator(shop) 63 shop:AddTag("shop") 64 shop:DoPeriodicTask(2, function(shop) 65 shop.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 66 shop:DoTaskInTime(1, function() shop.AnimState:SetBloomEffectHandle("") end ) 67 end ) 68 shop:AddComponent("trader") 69 shop.components.trader:SetAcceptTest(function(shop, item) 70 if item.prefab == "goldnugget" then 71 return true 72 end 73 return false 74 end ) 75 shop.components.trader.onaccept = function(shop, giver, item) 76 local names = {"cave_banana","pomegranate","dragonfruit"} 77 local name = names[math.random(#names)] 78 local veggie = SpawnPrefab(name) 79 if item.prefab == "goldnugget" then 80 giver.components.inventory:GiveItem(veggie) 81 end 82 end 83 local counter = SpawnPrefab("healingsalve") 84 counter.Transform:SetPosition(pt.x+2+1.8, 0, pt.z+2-1.8) 85 counter.AnimState:SetBank("winter_meter") 86 counter.AnimState:SetBuild("winter_meter") 87 counter.AnimState:SetPercent("meter", 0) 88 counter.Transform:SetScale(1.2, 1.2, 1.2) 89 counter.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround ) 90 counter.AnimState:SetLayer( LAYER_BACKGROUND ) 91 counter.AnimState:SetSortOrder( 1 ) 92 counter.Transform:SetRotation( 135 ) 93 counter.AnimState:SetMultColour(255/255,255/255,255/255,0) 94 counter:RemoveComponent("stackable") 95 counter:RemoveComponent("inventoryitem") 96 counter:RemoveComponent("healer") 97 counter:RemoveComponent("deployable") 98 MakeLargeBurnable(counter) 99 MakeLargePropagator(counter) 100 counter:AddTag("NOCLICK") 101 counter:AddTag("goodbye") 102 local juicer = SpawnPrefab("healingsalve") 103 juicer.Transform:SetPosition(pt.x+1-2, 0, pt.z+1+2) 104 juicer.AnimState:SetBank("researchlab2") 105 juicer.AnimState:SetBuild("researchlab2") 106 juicer.AnimState:PlayAnimation("idle") 107 juicer.Transform:SetScale(0.8, 0.8, 0.8) 108 juicer.AnimState:SetMultColour(255/255,105/255,0/255,1) 109 juicer:RemoveComponent("stackable") 110 juicer:RemoveComponent("inventoryitem") 111 juicer:RemoveComponent("healer") 112 juicer:RemoveComponent("deployable") 113 juicer.components.container.canbeopened = true 114 MakeLargeBurnable(juicer) 115 MakeLargePropagator(juicer) 116 juicer:AddTag("juicer") 117 juicer:AddTag("goodbye") 118 local sweetsign = SpawnPrefab("healingsalve") 119 sweetsign.Transform:SetPosition(pt.x+1+2, 0, pt.z+1-2) 120 sweetsign.AnimState:SetBank("sign_home") 121 sweetsign.AnimState:SetBuild("sign_home") 122 sweetsign.AnimState:PlayAnimation("idle") 123 sweetsign.Transform:SetScale(0.8, 0.8, 0.8) 124 sweetsign.AnimState:SetMultColour(255/255,0/255,0/255,1) 125 MakeLargeBurnable(sweetsign) 126 MakeLargePropagator(sweetsign) 127 sweetsign:AddTag("goodbye") 128 sweetsign:RemoveComponent("stackable") 129 sweetsign:RemoveComponent("inventoryitem") 130 sweetsign:RemoveComponent("healer") 131 sweetsign:RemoveComponent("deployable") 132 sweetsign:ListenForEvent( "nighttime", function() 133 sweetsign:RemoveTag("openshop") 134 GetPlayer().SoundEmitter:KillSound("beavermusic") 135 sweetsign.AnimState:SetMultColour(255/255,0/255,0/255,1) 136 local pos = Vector3(sweetsign.Transform:GetWorldPosition()) 137 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) 138 for k,v in pairs(ents) do 139 if v:HasTag("customers") then 140 v:Remove() 141 end 142 end 143 end, GetWorld()) 144 sweetsign.components.inspectable.getstatus = function(sweetsign) 145 if not sweetsign:HasTag("openshop") then 146 local target0 = FindEntity(sweetsign, 10, function(guy) 147 return guy:HasTag("sweets") and guy.components.inventoryitem and not guy.components.inventoryitem:IsHeld() 148 end ) 149 if target0 then 150 sweetsign:AddTag("openshop") 151 GetPlayer().SoundEmitter:PlaySound("dontstarve/music/music_hoedown", "beavermusic") 152 sweetsign.AnimState:SetMultColour(0/255,255/255,0/255,1) 153 for k = 1, math.random(8,16) do 154 local pt1 = sweetsign:GetPosition() 155 local customer = SpawnPrefab("healingsalve") 156 customer.Transform:SetPosition(pt1.x+(math.random(30)-math.random(30)), 0, pt1.z+(math.random(30)-math.random(30))) 157 customer.AnimState:SetBank("wilson") 158 local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} 159 local buildname = names[math.random(#names)] 160 customer.AnimState:SetBuild(buildname) 161 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"} 162 local hat = hats[math.random(#hats)] 163 customer.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") 164 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"} 165 local armor = armors[math.random(#armors)] 166 customer.AnimState:OverrideSymbol("swap_body", armor, "swap_body") 167 customer.AnimState:Show("HAT") 168 customer.AnimState:Show("HAT_HAIR") 169 customer.AnimState:Hide("HAIR_NOHAT") 170 customer.AnimState:Hide("HAIR") 171 customer.AnimState:Hide("ARM_carry") 172 customer.AnimState:Show("ARM_normal") 173 customer.AnimState:PlayAnimation("idle") 174 customer.Transform:SetFourFaced() 175 local sound = customer.entity:AddSoundEmitter() 176 local shadow = customer.entity:AddDynamicShadow() 177 shadow:SetSize( 1.3, .6 ) 178 customer:RemoveComponent("stackable") 179 customer:RemoveComponent("inventoryitem") 180 customer:RemoveComponent("healer") 181 customer:RemoveComponent("deployable") 182 customer:AddComponent("locomotor") 183 customer.components.locomotor.walkspeed = 4 184 customer.components.locomotor.runspeed = 8 185 customer:SetStateGraph("SGshadowwaxwell") 186 local brain = require "brains/frogbrain" 187 customer:SetBrain(brain) 188 customer:AddComponent("health") 189 customer.components.health:SetMaxHealth(1000) 190 customer.components.health:SetInvincible(true) 191 customer.components.health.nofadeout = true 192 customer:AddComponent("combat") 193 customer:AddComponent("knownlocations") 194 customer:AddTag("customers") 195 customer:AddTag("goodbye") 196 customer.task1 = customer:DoPeriodicTask(3, function(customer) 197 if math.random() < 0.1 then 198 local target = FindEntity(customer, 100, function(guy) 199 return guy:HasTag("sweets") and guy.components.inventoryitem and not guy.components.inventoryitem:IsHeld() 200 end ) 201 if target then 202 customer.components.locomotor:Stop() 203 customer:SetBrain(nil) 204 customer.components.locomotor:GoToEntity(target) 205 customer.task2 = customer:DoPeriodicTask(.25, function(customer) 206 local target2 = FindEntity(customer, 1, function(guy) 207 return guy:HasTag("sweets") and guy.components.inventoryitem and not guy.components.inventoryitem:IsHeld() 208 end ) 209 if target2 then 210 customer.AnimState:PlayAnimation("pickup") 211 for k = 1, 6 do 212 SpawnPrefab("goldnugget").Transform:SetPosition(target2.Transform:GetWorldPosition()) 213 end 214 target2:Remove() 215 local brain = require "brains/frogbrain" 216 customer:SetBrain(brain) 217 customer:RestartBrain() 218 if customer.task2 then customer.task2:Cancel() customer.task2 = nil end 219 end 220 end ) 221 customer:DoTaskInTime(8, function(customer) 222 local brain = require "brains/frogbrain" 223 customer:SetBrain(brain) 224 customer:RestartBrain() 225 if customer.task2 then customer.task2:Cancel() customer.task2 = nil end 226 end ) 227 else 228 local brain = require "brains/frogbrain" 229 customer:SetBrain(brain) 230 customer:RestartBrain() 231 if customer.task2 then customer.task2:Cancel() customer.task2 = nil end 232 end 233 end 234 end ) 235 end 236 end 237 else 238 sweetsign:RemoveTag("openshop") 239 GetPlayer().SoundEmitter:KillSound("beavermusic") 240 sweetsign.AnimState:SetMultColour(255/255,0/255,0/255,1) 241 local pos = Vector3(sweetsign.Transform:GetWorldPosition()) 242 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) 243 for k,v in pairs(ents) do 244 if v:HasTag("customers") then 245 v:Remove() 246 end 247 end 248 end 249 end 250end 251local function OnDeploy (inst, pt) 252 sweetshop(inst) 253 inst.components.stackable:Get():Remove() 254end 255 inst:AddComponent("deployable") 256 inst.components.deployable.ondeploy = OnDeploy 257local function onsave(inst, data) 258 if inst:HasTag("shop") then 259 data.shop = true 260 end 261 if inst:HasTag("goodbye") then 262 data.goodbye = true 263 end 264 if inst:HasTag("sweets") then 265 data.sweets = true 266 end 267end 268local function onload(inst, data) 269 if data and data.shop then 270 sweetshop(inst) 271 inst:Remove() 272 end 273 if data and data.goodbye then 274 inst:Remove() 275 end 276 if data and data.sweets then 277 inst.AnimState:SetBank("food") 278 inst.AnimState:SetBuild("cook_pot_food") 279 inst.AnimState:PlayAnimation("fruitmedley", false) 280 inst:RemoveComponent("stackable") 281 inst:RemoveComponent("deployable") 282 inst.components.healer:SetHealthAmount(TUNING.HEALING_SUPERHUGE) 283 inst.components.inventoryitem:ChangeImageName("fruitmedley") 284 inst.Transform:SetScale(1.2, 1.2, 1.2) 285 inst:AddTag("sweets") 286 end 287end 288 inst.OnSave = onsave 289 inst.OnLoad = onload 290 291 即可用治疗药膏种我的果汁店(手里拿着1个治疗药膏对地面点鼠标右键,如果拿着多个治疗药膏,则不会种出来),拿着黄金对库房(大胡萝卜)点鼠标左键,可以购入果汁原料,分别是火龙果、香蕉、石榴,每个水果1个黄金,当然你也可以用自己种的水果。将三种水果放入右边的榨汁机(拿着水果对榨汁机点鼠标左键),然后按Start按钮,将开始榨汁,榨完后果汁自动装入主角物品栏。将果汁放在柜台上(地上半透明的长方形),点左边的牌子就可以开张了(柜台上没有果汁则无法开张),会有顾客上门购买,每份售价6个黄金。想打烊,就再次点击牌子即可。黑夜来临时会自动打烊,回家休息吧,当然你也可以再次点牌子开张,但夜里的顾客都昏昏欲睡。出售的果汁自己也可以喝(在物品栏里对果汁点鼠标右键),可大幅补充生命值。不想要果汁店时,烧掉即可,记得先打烊哦。治疗药膏在生存选项(画着绳套)下,用2个灰、1个石头、1个蜘蛛腺体制造

2025/04/23 · Bny

YN299-跳蚤市场(用木炭种跳蚤市场摊位,上百种商品30秒刷新一次,全场一律3个黄金)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二九九.跳蚤市场(用木炭种跳蚤市场摊位,上百种商品30秒刷新一次,全场一律3个黄金) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/charcoal.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function createfleashop(inst) 7 local pt = inst:GetPosition() 8 local seller = SpawnPrefab("charcoal") 9 seller.Transform:SetPosition(pt.x, pt.y, pt.z) 10 seller.AnimState:SetBank("wilson") 11 local buildnames = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} 12 local buildname = buildnames[math.random(#buildnames)] 13 seller.AnimState:SetBuild(buildname) 14 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"} 15 local hat = hats[math.random(#hats)] 16 seller.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") 17 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"} 18 local armor = armors[math.random(#armors)] 19 seller.AnimState:OverrideSymbol("swap_body", armor, "swap_body") 20 seller.AnimState:Show("HAT") 21 seller.AnimState:Show("HAT_HAIR") 22 seller.AnimState:Hide("HAIR_NOHAT") 23 seller.AnimState:Hide("HAIR") 24 seller.AnimState:Hide("ARM_carry") 25 seller.AnimState:Show("ARM_normal") 26 seller.AnimState:PlayAnimation("idle") 27 seller.Transform:SetFourFaced() 28 seller:RemoveComponent("stackable") 29 seller:RemoveComponent("fuel") 30 seller:RemoveComponent("inventoryitem") 31 seller:RemoveComponent("burnable") 32 seller:RemoveComponent("propagator") 33 seller:RemoveComponent("deployable") 34 seller:RemoveComponent("bait") 35 seller:RemoveTag("molebait") 36 seller:AddComponent("talker") 37 seller:AddComponent("workable") 38 seller.components.workable:SetWorkAction(ACTIONS.HAMMER) 39 seller.components.workable:SetWorkLeft(3) 40 seller.components.workable:SetOnFinishCallback(function(seller) 41 SpawnPrefab("collapse_big").Transform:SetPosition(seller.Transform:GetWorldPosition()) 42 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 43 local pos = Vector3(seller.Transform:GetWorldPosition()) 44 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 6) 45 for k,v in pairs(ents) do 46 if v:HasTag("commodity") then 47 v:Remove() 48 end 49 if v:HasTag("fleas") then 50 v:Remove() 51 end 52 end 53 seller:Remove() 54 end ) 55 seller:AddTag("sellers") 56 local flea = SpawnPrefab("charcoal") 57 flea.Transform:SetPosition(pt.x+2.8+1.2, 0, pt.z-2.8+1.2) 58 flea.AnimState:SetBank("winter_meter") 59 flea.AnimState:SetBuild("winter_meter") 60 flea.AnimState:SetPercent("meter", 0) 61 flea.Transform:SetScale(1.5, 1.5, 1.5) 62 flea.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround ) 63 flea.AnimState:SetLayer( LAYER_BACKGROUND ) 64 flea.AnimState:SetSortOrder( 1 ) 65 flea.Transform:SetRotation( 135 ) 66 flea.AnimState:SetMultColour(255/255,255/255,255/255,0) 67 flea:RemoveComponent("stackable") 68 flea:RemoveComponent("fuel") 69 flea:RemoveComponent("inventoryitem") 70 flea:RemoveComponent("burnable") 71 flea:RemoveComponent("propagator") 72 flea:RemoveComponent("deployable") 73 flea:RemoveComponent("bait") 74 flea:RemoveTag("molebait") 75 flea:AddTag("NOCLICK") 76 flea:AddTag("fleas") 77 local light = flea.entity:AddLight() 78 light:SetFalloff(1) 79 light:SetIntensity(.8) 80 light:SetRadius(5) 81 light:SetColour(180/255, 195/255, 50/255) 82 light:Enable(true) 83 for k = 0,4 do 84 local names = {"amulet","blueamulet","purpleamulet","orangeamulet","greenamulet","yellowamulet","armorgrass","armormarble","armorruins","armor_sanity","armorslurper","armorsnurtleshell","armorwood","axe","goldenaxe","multitool_axe_pickaxe","bandage","batbat","bedroll_furry","bedroll_straw","trunkvest_summer","blowdart_sleep","blowdart_fire","blowdart_pipe","boomerang","bugnet","butter","cane","compass","deerclops_eyeball","diviningrod","eyeturret_item","fishingrod","gunpowder","hambat","hammer","footballhat","strawhat","tophat","flowerhat","beefalohat","featherhat","beehat","walrushat","earmuffshat","winterhat","minerhat","spiderhat","bushhat","slurtlehat","ruinshat","healingsalve","heatrock","nightsword","lantern","panflute","pickaxe","goldenpickaxe","pitchfork","razor","ruins_bat","shovel","goldenshovel","spear","icestaff","firestaff","telestaff","orangestaff","greenstaff","yellowstaff","sweatervest","teleportato_ring","teleportato_box","teleportato_crank","teleportato_potato","tentaclespike","torch","trunkvest_winter","umbrella","fertilizer","bell","spear_wathgrithr","grass_umbrella","rainhat","icehat","watermelonhat","catcoonhat","wathgrithrhat","raincoat","molehat","armordragonfly","beargervest","featherfan","staff_tornado","nightstick","eyebrellahat","reflectivevest","hawaiianshirt"} 85 local name = names[math.random(#names)] 86 local commodity = SpawnPrefab(name) 87 commodity.Transform:SetPosition(pt.x+2+1.3-k*1, 0, pt.z-2+1.3+k*1) 88 commodity.components.inventoryitem.canbepickedup = false 89 commodity.persists = false 90 commodity:AddComponent("trader") 91 commodity.components.trader:SetAcceptTest(function(commodity, item) 92 if GetPlayer().components.inventory:Has("goldnugget", 3) then 93 if item.prefab == "goldnugget" then 94 return true 95 end 96 end 97 return false 98 end ) 99 commodity.components.trader.onaccept = function(commodity, giver, item) 100 GetPlayer().components.inventory:ConsumeByName("goldnugget", 2) 101 commodity.components.inventoryitem.canbepickedup = true 102 commodity:RemoveTag("commodity") 103 GetPlayer().components.inventory:GiveItem(commodity) 104 commodity:RemoveComponent("trader") 105 commodity.persists = true 106 end 107 commodity:AddTag("commodity") 108 end 109 seller:DoPeriodicTask(30, function(seller) 110 seller.components.talker:Say("everythings, 3 golds", 5, false) 111 seller.AnimState:PlayAnimation("give") 112 local pos = Vector3(seller.Transform:GetWorldPosition()) 113 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 6) 114 for k,v in pairs(ents) do 115 if v:HasTag("commodity") then 116 v:Remove() 117 end 118 end 119 for k = 0,4 do 120 local names = {"amulet","blueamulet","purpleamulet","orangeamulet","greenamulet","yellowamulet","armorgrass","armormarble","armorruins","armor_sanity","armorslurper","armorsnurtleshell","armorwood","axe","goldenaxe","multitool_axe_pickaxe","bandage","batbat","bedroll_furry","bedroll_straw","trunkvest_summer","blowdart_sleep","blowdart_fire","blowdart_pipe","boomerang","bugnet","butter","cane","compass","deerclops_eyeball","diviningrod","eyeturret_item","fishingrod","gunpowder","hambat","hammer","footballhat","strawhat","tophat","flowerhat","beefalohat","featherhat","beehat","walrushat","earmuffshat","winterhat","minerhat","spiderhat","bushhat","slurtlehat","ruinshat","healingsalve","heatrock","nightsword","lantern","panflute","pickaxe","goldenpickaxe","pitchfork","razor","ruins_bat","shovel","goldenshovel","spear","icestaff","firestaff","telestaff","orangestaff","greenstaff","yellowstaff","sweatervest","teleportato_ring","teleportato_box","teleportato_crank","teleportato_potato","tentaclespike","torch","trunkvest_winter","umbrella","fertilizer","bell","spear_wathgrithr","grass_umbrella","rainhat","icehat","watermelonhat","catcoonhat","wathgrithrhat","raincoat","molehat","armordragonfly","beargervest","featherfan","staff_tornado","nightstick","eyebrellahat","reflectivevest","hawaiianshirt"} 121 local name = names[math.random(#names)] 122 local commodity = SpawnPrefab(name) 123 commodity.Transform:SetPosition(pt.x+2+1.3-k*1, 0, pt.z-2+1.3+k*1) 124 commodity.components.inventoryitem.canbepickedup = false 125 commodity.persists = false 126 commodity:AddTag("commodity") 127 commodity:AddComponent("trader") 128 commodity.components.trader:SetAcceptTest(function(commodity, item) 129 if GetPlayer().components.inventory:Has("goldnugget", 3) then 130 if item.prefab == "goldnugget" then 131 return true 132 end 133 end 134 return false 135 end ) 136 commodity.components.trader.onaccept = function(commodity, giver, item) 137 GetPlayer().components.inventory:ConsumeByName("goldnugget", 2) 138 commodity.components.inventoryitem.canbepickedup = true 139 commodity:RemoveTag("commodity") 140 GetPlayer().components.inventory:GiveItem(commodity) 141 commodity:RemoveComponent("trader") 142 commodity.persists = true 143 end 144 end 145 end) 146end 147local function OnDeploy (inst, pt) 148 createfleashop(inst) 149 inst.components.stackable:Get():Remove() 150end 151 inst:AddComponent("deployable") 152 inst.components.deployable.ondeploy = OnDeploy 153local function onsave(inst, data) 154 if inst:HasTag("sellers") then 155 data.sellers = true 156 end 157 if inst:HasTag("fleas") then 158 data.fleas = true 159 end 160end 161local function onload(inst, data) 162 if data and data.sellers then 163 createfleashop(inst) 164 inst:Remove() 165 end 166 if data and data.fleas then 167 inst:Remove() 168 end 169end 170 inst.OnSave = onsave 171 inst.OnLoad = onload 172 173 即可拿着1个木炭对空地点鼠标右键,种出跳蚤市场的摊位(手里拿多个木炭不会种出来),每30秒展示5种商品,看上哪件,就拿着黄金对那件商品点鼠标左键购买,全场一律3个黄金。店主为随机人物,可以种多个跳蚤市场摊位,形成商品一条街(摊位间不要太近,否则影响展示商品)。不想要跳蚤市场时,用锤子砸店主即可(暴力拆迁)

2025/04/23 · Bny