YN291-小酒馆(用剃刀种小酒馆,听音乐、喝烧酒、吃料理、小憩一下)
代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二九一.小酒馆(用剃刀种小酒馆,听音乐、喝烧酒、吃料理、小憩一下) 用MT管理器打开游戏目录/assets/scripts/prefabs/razor.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function bar(inst) local pt = inst:GetPosition() local waiter = SpawnPrefab("razor") waiter.Transform:SetPosition(pt.x, pt.y, pt.z) waiter.AnimState:SetBank("wilson") waiter.AnimState:SetBuild("wes") waiter.AnimState:Hide("ARM_carry") waiter.AnimState:Show("ARM_normal") waiter.Transform:SetFourFaced() waiter.AnimState:PlayAnimation("idle") waiter:AddTag("waiter") waiter:RemoveComponent("inventoryitem") waiter:RemoveComponent("shaver") waiter:RemoveComponent("deployable") waiter:AddComponent("trader") waiter.components.trader:SetAcceptTest(function(waiter, item) if GetPlayer().components.inventory:Has("goldnugget", 1) then if item.prefab == "goldnugget" then return true end end return false end ) waiter.components.trader.onaccept = function(waiter, giver, item) waiter.AnimState:PlayAnimation("idle_onemanband1_loop",true) waiter:DoTaskInTime(5, function() waiter.AnimState:PlayAnimation("idle") end ) GetPlayer().components.sanity:DoDelta(3) end local bar = SpawnPrefab("razor") bar.Transform:SetPosition(pt.x+0.8, 0, pt.z+0.8) bar.AnimState:SetBank("ruins_table") bar.AnimState:SetBuild("ruins_table") bar.AnimState:PlayAnimation("idle") bar:AddTag("goodbye") bar:RemoveComponent("inventoryitem") bar:RemoveComponent("shaver") bar:RemoveComponent("deployable") bar:AddComponent("trader") bar.components.trader:SetAcceptTest(function(bar, item) if GetPlayer().components.inventory:Has("goldnugget", 5) then if item.prefab == "goldnugget" then return true end end return false end ) bar.components.trader.onaccept = function(bar, giver, item) GetPlayer().components.inventory:ConsumeByName("goldnugget", 4) waiter.AnimState:PlayAnimation("give") local wine = SpawnPrefab("razor") wine.AnimState:SetBank("ruins_vase") wine.AnimState:SetBuild("ruins_vase") wine.AnimState:PlayAnimation("idle") wine.Transform:SetScale(0.5, 0.5, 0.5) wine.Physics:SetActive(false) wine:AddTag("goodbye") wine.components.inventoryitem.canbepickedup = false local follower = wine.entity:AddFollower() follower:FollowSymbol( bar.GUID, "swap_object", -100, -170, 0 ) wine.components.inspectable.getstatus = function(wine) wine:Remove() wine = nil GetPlayer().sg:GoToState("eat") GetPlayer().components.sanity:DoDelta(-5) GetPlayer().components.health:DoDelta(20) end end local icebox = SpawnPrefab("razor") icebox.Transform:SetPosition(pt.x-1.6+0.8, 0, pt.z+1.6+0.8) icebox.AnimState:SetBank("icebox") icebox.AnimState:SetBuild("ice_box") icebox.AnimState:PlayAnimation("closed") icebox.AnimState:SetMultColour(255/255,255/255,255/255,1) icebox:AddTag("goodbye") icebox:RemoveComponent("inventoryitem") icebox:RemoveComponent("shaver") icebox:RemoveComponent("deployable") icebox:AddComponent("trader") icebox.components.trader:SetAcceptTest(function(icebox, item) if GetPlayer().components.inventory:Has("goldnugget", 5) then if item.prefab == "goldnugget" then return true end end return false end ) icebox.components.trader.onaccept = function(icebox, giver, item) GetPlayer().components.inventory:ConsumeByName("goldnugget", 4) waiter.AnimState:PlayAnimation("give") 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"} local name = names[math.random(#names)] local snack = SpawnPrefab(name) giver.components.inventory:GiveItem(snack) end local chair = SpawnPrefab("razor") chair.Transform:SetPosition(pt.x+1.5+0.8, 0, pt.z-1.5+0.8) chair.AnimState:SetBank("ruins_chair") chair.AnimState:SetBuild("ruins_chair") chair.AnimState:PlayAnimation("idle") chair:AddTag("goodbye") chair:RemoveComponent("inventoryitem") chair:RemoveComponent("shaver") chair:RemoveComponent("deployable") chair.components.inspectable.getstatus = function() TheFrontEnd:Fade(true,1) GetClock():NextPhase() GetPlayer().components.hunger:DoDelta(-10) GetPlayer().components.sanity:DoDelta(25) end local music = SpawnPrefab("razor") music.Transform:SetPosition(pt.x+1.5-0.8, 0, pt.z-1.5-0.8) music.AnimState:SetBank("phonograph") music.AnimState:SetBuild("phonograph") music.AnimState:PlayAnimation("idle") music:AddTag("goodbye") music:RemoveComponent("inventoryitem") music:RemoveComponent("shaver") music:RemoveComponent("deployable") music.entity:AddSoundEmitter() music:AddComponent("machine") music.components.machine.turnonfn = function(music) music.AnimState:PlayAnimation("play_loop", true) music.SoundEmitter:PlaySound("dontstarve/maxwell/ragtime", "ragtime") end music.components.machine.turnofffn = function(music) music.AnimState:PlayAnimation("idle") music.SoundEmitter:KillSound("ragtime") music.SoundEmitter:PlaySound("dontstarve/music/gramaphone_end") end music.components.machine:TurnOff() local pot = SpawnPrefab("razor") pot.Transform:SetPosition(pt.x-1.5-1.1, 0, pt.z+1.5-1.1) pot.AnimState:SetBank("cook_pot") pot.AnimState:SetBuild("cook_pot") pot.Transform:SetScale(0.8, 0.8, 0.8) pot.AnimState:PlayAnimation("cooking_loop", true) pot:AddTag("goodbye") pot:RemoveComponent("inventoryitem") pot:RemoveComponent("shaver") pot:RemoveComponent("deployable") pot.AnimState:SetBloomEffectHandle("shaders/anim.ksh") local light = pot.entity:AddLight() light:SetFalloff(1) light:SetIntensity(.8) light:SetRadius(10) light:SetColour(180/255, 195/255, 50/255) light:Enable(true) end local function OnDeploy (inst, pt) bar(inst) inst:Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("waiter") then data.waiter = true end if inst:HasTag("goodbye") then data.goodbye = true end end local function onload(inst, data) if data and data.waiter then bar(inst) inst:Remove() end if data and data.goodbye then inst:Remove() end end inst.OnSave = onsave inst.OnLoad = onload MakeLargeBurnable(inst) MakeLargePropagator(inst) 即可用剃刀种小酒馆,给桌子5个黄金(拿着黄金对桌子点鼠标左键),服务员会为你热1瓶烧酒,左键点桌上的酒瓶即可喝掉,补20点血,但会减5点脑(喝多了会头晕)。给冰箱5个黄金,可以购买料理(直接放入物品栏)。如果你满意酒馆的服务,可以向服务员支付小费(拿着黄金对服务员点鼠标左键),每次1个黄金,补3点脑。如果想休息一下,就用左键点椅子,时间会跳到下一时段,补25点脑,减少10点饥饿。鼠标右键点留声机,可以开关音乐。冬天天冷时,靠近锅会很暖和。不想要小酒馆时,烧掉即可。剃刀在工具选项(画着斧子和镐)下,用2个树枝、2个燧石制造