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

YN180-芦苇吹出催眠曲(在携带的芦苇上按鼠标右键,可催眠怪物)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一八0.芦苇吹出催眠曲(在携带的芦苇上按鼠标右键,可催眠怪物) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/cutreeds.lua文件,在inst:AddComponent("inventoryitem")的下一行插入以下内容: 5 6 inst:AddTag("flute") 7local function HearPanFlute(inst, musician, instrument) 8 if inst.components.sleeper then 9 inst.components.sleeper:AddSleepiness(10, TUNING.PANFLUTE_SLEEPTIME*1) 10 end 11end 12 inst:AddComponent("tool") 13 inst.components.tool:SetAction(ACTIONS.PLAY) 14 inst:AddComponent("instrument") 15 inst.components.instrument.range = TUNING.PANFLUTE_SLEEPRANGE*2 16 inst.components.instrument:SetOnHeardFn(HearPanFlute) 17 18 即可在携带的芦苇上按鼠标右键,可催眠一片怪物。其中*1为催眠时间20秒,想催眠60秒就*3即可。其中*2为催眠范围30格,想扩大至60格就*4即可

2025/04/23 · Bny

YN181-隐身背心(穿小巧背心可隐身)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一八一.隐身背心(穿小巧背心可隐身) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/sweatervest.lua文件,将下列内容: 5 6local function onequip(inst, owner) 7 owner.AnimState:OverrideSymbol("swap_body", "armor_sweatervest", "swap_body") 8 inst.components.fueled:StartConsuming() 9end 10 11local function onunequip(inst, owner) 12 owner.AnimState:ClearOverrideSymbol("swap_body") 13 inst.components.fueled:StopConsuming() 14end 15 16 替换为: 17 18local function onequip(inst, owner) 19 owner.AnimState:OverrideSymbol("swap_body", "armor_sweatervest", "swap_body") 20 inst.components.equippable.walkspeedmult = TUNING.CANE_SPEED_MULT*2 21 owner:Hide() 22 local shadow = GetPlayer().entity:AddDynamicShadow() 23 shadow:SetSize( 0, 0 ) 24end 25local function onunequip(inst, owner) 26 owner.AnimState:ClearOverrideSymbol("swap_body") 27 owner:Show() 28 local shadow = GetPlayer().entity:AddDynamicShadow() 29 shadow:SetSize( 1.3, .6 ) 30end 31 32 即可穿上小巧背心隐身,你可以攻击敌人,敌人找不到你,连鸟、兔子都可以直接攻击哦。小巧背心在穿戴选项(画着礼帽)下,用8个犬牙、6个蛛丝制造

2025/04/23 · Bny

YN182-泡泡糖(吃黄油吹个保护泡泡)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一八二.泡泡糖(吃黄油吹个保护泡泡) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/butter.lua文件,在inst.components.edible.hungervalue = TUNING.CALORIES_MED的下一行插入以下内容: 5 6 local function proc(inst, eater) 7 eater.components.health:SetInvincible(true) 8 inst:AddTag("forcefield") 9 local fx = SpawnPrefab("forcefieldfx") 10 fx.entity:SetParent(eater.entity) 11 fx.Transform:SetPosition(0, 0.2, 0) 12 local fx_hitanim = function() 13 fx.AnimState:PlayAnimation("hit") 14 fx.AnimState:PushAnimation("idle_loop") 15 end 16 fx:ListenForEvent("blocked", fx_hitanim, eater) 17 inst.active = true 18 eater:DoTaskInTime(60, function() 19 fx:RemoveEventCallback("blocked", fx_hitanim, eater) 20 fx.kill_fx(fx) 21 if inst:IsValid() then 22 eater.components.health:SetInvincible(false) 23 inst:RemoveTag("forcefield") 24 eater:DoTaskInTime(5, function() inst.active = false end) 25 end 26 end) 27 end 28local function oneaten(inst, eater) 29 proc(inst, eater) 30end 31 inst.components.edible:SetOnEatenFn(oneaten) 32 33 即可吃黄油后60秒内身边环绕一个保护泡,敌人无法伤到主角。黄油可以靠杀蝴蝶掉落,也可以用本修改技巧的“栽种尖刺灌木产黄油”得到

2025/04/23 · Bny

YN183-迷魂花阵(戴花环周围出现食人花眼睛保护主角)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一八三.迷魂花阵(戴花环周围出现食人花眼睛保护主角) 3 4 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/hats.lua文件,将下列内容: 5 6 inst:AddComponent("perishable") 7 inst.components.perishable:SetPerishTime(TUNING.PERISH_FAST) 8 inst.components.perishable:StartPerishing() 9 inst.components.perishable:SetOnPerishFn(generic_perish) 10 inst.components.equippable:SetOnEquip( opentop_onequip ) 11 12 替换为: 13 14local function flower_equip(inst, owner) 15 opentop_onequip(inst, owner) 16 inst:AddComponent("minionspawner") 17 inst.components.minionspawner.miniontype = "eyeplant" 18 inst.components.minionspawner.maxminions = 27 19 inst.components.minionspawner.minionspawntime = {min = 0.01, max = 0.01} 20 inst.components.minionspawner.numminions = 10 21 inst.components.minionspawner.shouldspawn = true 22 inst.components.minionspawner:StartNextSpawn() 23end 24local function flower_unequip(inst, owner) 25 onunequip(inst, owner) 26 inst.components.minionspawner.shouldspawn = false 27 inst.components.minionspawner:KillAllMinions() 28 inst:RemoveComponent("minionspawner") 29end 30 inst.components.equippable:SetOnEquip( flower_equip ) 31 inst.components.equippable:SetOnUnequip( flower_unequip ) 32 33 34 2.用MT管理器打开游戏目录/assets/scripts/prefabs/eyeplant.lua文件,将下列内容: 35 36 return (guy:HasTag("character") or guy:HasTag("monster") or guy:HasTag("animal") or guy:HasTag("prey") or guy:HasTag("eyeplant") or guy:HasTag("lureplant")) and not checkmaster(guy, inst) 37 38 替换为: 39 40 return (guy:HasTag("character") or guy:HasTag("monster") or guy:HasTag("animal") or guy:HasTag("prey") or guy:HasTag("eyeplant") or guy:HasTag("lureplant")) and not guy:HasTag("player") and not checkmaster(guy, inst) 41 42 即可戴花环周围出现食人花眼睛保护主角,食人花眼睛被敌人打死一个又会再生一个。摘下花环,食人花眼睛立即消失

2025/04/23 · Bny

YN184-家园防御系统(暗夜照明灯自动向靠近的敌人发射炮弹)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一八四.家园防御系统(暗夜照明灯自动向靠近的敌人发射炮弹) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/nightlight.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function onattack(inst) 7 local pos = Vector3(inst.Transform:GetWorldPosition()) 8 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 30) 9 for k,v in pairs(ents) do 10 if v.components.health and v.components.combat and not v.components.health:IsDead() then 11 if v.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == v or v:HasTag("monster") then 12 inst.components.weapon:LaunchProjectile(inst, v) 13 v.components.health:DoDelta(-5000) 14 inst.SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 15 SpawnPrefab("collapse_small").Transform:SetPosition(v.Transform:GetWorldPosition()) 16 SpawnPrefab("explode_small").Transform:SetPosition(v.Transform:GetWorldPosition()) 17 GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.7, 0.02, .5, 40) 18 inst.components.fueled:InitializeFuelLevel(1000) 19 end 20 end 21 end 22end 23local function turnon(inst) 24 inst.components.machine.ison = true 25 inst.task = inst:DoPeriodicTask(.5, function() onattack(inst) end) 26 inst.components.burnable:IsBurning() 27 inst.components.fueled:InitializeFuelLevel(1000) 28 end 29local function turnoff(inst) 30 inst.components.machine.ison = false 31 if inst.task then inst.task:Cancel() inst.task = nil end 32 inst.components.burnable:Extinguish() 33 inst.components.fueled:InitializeFuelLevel(0) 34end 35 inst:AddComponent("machine") 36 inst.components.machine.turnonfn = turnon 37 inst.components.machine.turnofffn = turnoff 38 inst:AddComponent("weapon") 39 inst.components.weapon:SetDamage(0) 40 inst.components.weapon:SetProjectile("eye_charge") 41 42 即可对暗夜照明灯按鼠标右键开启家园防御系统,自动向靠近的敌人发射炮弹(不会攻击同伴),再按鼠标右键关闭。建在基地附近,无惧任何敌人。暗影照明灯在魔法选项(画着红骷髅)下,用8个黄金、2个噩梦燃料、1个红宝石建造

2025/04/23 · Bny

YN185-音浪太强(戴兔耳罩周围形成音浪,敌人被弹开)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一八五.音浪太强(戴兔耳罩周围形成音浪,敌人被弹开) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/hats.lua文件,将下列内容: 5 6 local function earmuffs() 7 local inst = simple() 8 inst:AddComponent("insulator") 9 inst.components.insulator.insulation = TUNING.INSULATION_SMALL 10 inst.components.equippable:SetOnEquip( opentop_onequip ) 11 inst:AddComponent("fueled") 12 inst.components.fueled.fueltype = "USAGE" 13 inst.components.fueled:InitializeFuelLevel(TUNING.EARMUFF_PERISHTIME) 14 inst.components.fueled:SetDepletedFn(generic_perish) 15 inst.AnimState:SetRayTestOnBB(true) 16 return inst 17 end 18 19 替换为: 20 21local colours= 22{ 23 {198/255,43/255,43/255}, 24 {79/255,153/255,68/255}, 25 {35/255,105/255,235/255}, 26 {233/255,208/255,69/255}, 27 {109/255,50/255,163/255}, 28 {222/255,126/255,39/255}, 29} 30local function pickup(inst, owner) 31 inst.colour_idx = math.random(#colours) 32 local light = inst.entity:AddLight() 33 light:SetIntensity(.8) 34 light:SetRadius(3) 35 light:SetFalloff(1) 36 light:Enable(true) 37 light:SetColour(colours[inst.colour_idx][1],colours[inst.colour_idx][2],colours[inst.colour_idx][3]) 38 local pt = Vector3(owner.Transform:GetWorldPosition()) 39 local result_offset = FindValidPositionByFan(math.random()*2*PI, 10, 75, function(offset) 40 local x,y,z = (pt + offset):Get() 41 local ents = TheSim:FindEntities(x,y,z , 1) 42 return not next(ents) 43 end) 44 local ents2 = TheSim:FindEntities(pt.x,pt.y,pt.z, 8) 45 for k,v in pairs(ents2) do 46 if v.components.health and not v.components.health:IsDead() and not v:HasTag("player") and not v:HasTag("smallbird") and not v:HasTag("chester") and not v:HasTag("wall") and not v:HasTag("structure") then 47 v.Transform:SetPosition((pt + result_offset):Get()) 48 end 49 end 50end 51local function earmuffs_onequip(inst, owner) 52 inst.task = inst:DoPeriodicTask(.033, function() pickup(inst, owner) end) 53 GetPlayer().SoundEmitter:PlaySound("dontstarve/music/music_hoedown", "beavermusic") 54 opentop_onequip(inst, owner) 55end 56local function earmuffs_onunequip(inst, owner) 57 if inst.task then inst.task:Cancel() inst.task = nil end 58 GetPlayer().SoundEmitter:KillSound("beavermusic") 59 onunequip(inst, owner) 60 inst.Light:Enable(false) 61end 62local function earmuffs() 63 local inst = simple() 64 inst:AddComponent("insulator") 65 inst.components.insulator.insulation = TUNING.INSULATION_SMALL 66 inst.components.equippable:SetOnEquip( earmuffs_onequip ) 67 inst.components.equippable:SetOnUnequip( earmuffs_onunequip ) 68 inst.AnimState:SetRayTestOnBB(true) 69 return inst 70end 71 72 即可在戴兔耳罩时,周围形成音浪,敌人靠近会被弹开,拆杀人蜂窝、偷高鸟蛋毫发无伤。兔耳罩在穿戴选项(画着礼帽)下,用2个兔子、1个树枝制造

2025/04/23 · Bny

YN186-智能围墙(按键盘F11键造一圈大理石围墙,点围墙可开门,5秒自动关门,夜晚启动照明)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一八六.智能围墙(按键盘F11键造一圈大理石围墙,点围墙可开门,5秒自动关门,夜晚启动照明) 3 4 1.用MT管理器打开游戏目录/assets/scripts/prefabs/marblepillar.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function GetStatus(inst, viewer) 7 local pt = inst:GetPosition() 8 inst:Remove() 9 inst:DoTaskInTime(5, function() 10 SpawnPrefab("marblepillar").Transform:SetPosition(pt.x, pt.y, pt.z) 11 inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") 12 end) 13end 14local function LightsOn(inst) 15 inst.Light:Enable(true) 16end 17local function LightsOff(inst) 18 inst.Light:Enable(false) 19end 20 local light = inst.entity:AddLight() 21 light:SetFalloff(1) 22 light:SetIntensity(.8) 23 light:SetRadius(10) 24 light:Enable(false) 25 light:SetColour(180/255, 195/255, 50/255) 26 inst.components.inspectable.getstatus = GetStatus 27 inst:ListenForEvent( "daytime", function() LightsOff(inst) end, GetWorld()) 28 inst:ListenForEvent( "dusktime", function() LightsOn(inst) end, GetWorld()) 29 30 31 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playercontroller")的下一行插入以下内容: 32 33TheInput:AddKeyUpHandler(KEY_F11, function() 34 local player = GetPlayer() 35 local pt = Vector3(player.Transform:GetWorldPosition()) 36 for k = 1, 75 do 37 local theta = 1 * 2 * PI 38 local radius = 18 39 local result_offset = FindValidPositionByFan(theta, radius, 75, function(offset) 40 local x,y,z = (pt + offset):Get() 41 local ents = TheSim:FindEntities(x,y,z , 1) 42 return not next(ents) 43 end) 44 if result_offset then 45 local tentacle = SpawnPrefab("marblepillar") 46 tentacle.Transform:SetPosition((pt + result_offset):Get()) 47 GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) 48 end 49 inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") 50 end 51end) 52TheInput:AddKeyUpHandler(KEY_F12, function() 53 local player = GetPlayer() 54 local range = 30 55 local pos = Vector3(player.Transform:GetWorldPosition()) 56 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, range) 57 for k,v in pairs(ents) do 58 if v.prefab == "marblepillar" then 59 v:Remove() 60 end 61 end 62 inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") 63end) 64 65 即可在开阔的空地上按键盘F11键,建造一圈大理石围墙,按F12键可消去。对围墙按鼠标左键可开门,5秒后自动关门,夜晚自动启动照明系统,用作自宅围墙或圈养动物都适宜。注意不要拿着镐点围墙,除非你想获得大理石

2025/04/23 · Bny

YN187-高压电避难所(按小键盘加号键筑一圈带高压电的玄武岩墙,按减号键消失)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一八七.高压电避难所(按小键盘加号键筑一圈带高压电的玄武岩墙,按减号键消失) 3 4 1.用MT管理器打开游戏目录/assets/scripts/prefabs/basalt.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function OnExplode(inst, target) 7 if target and not target:HasTag("smallbird") and not target:HasTag("chester") then 8 SpawnPrefab("lightning_rod_fx").Transform:SetPosition(inst.Transform:GetWorldPosition()) 9 SpawnPrefab("lightning_rod_fx").Transform:SetPosition(target.Transform:GetWorldPosition()) 10 inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod") 11 target.components.health:DoDelta(-3000) 12 end 13 inst:DoTaskInTime(.1, function() inst.components.mine:Reset() end ) 14end 15 inst:AddComponent("mine") 16 inst.components.mine:SetRadius(4) 17 inst.components.mine:SetAlignment("player") 18 inst.components.mine:SetOnExplodeFn(OnExplode) 19 inst.components.mine:Reset() 20 21 22 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("catcher")的下一行插入以下内容: 23 24TheInput:AddKeyUpHandler(KEY_KP_PLUS, function() 25 local player = GetPlayer() 26 local pt = Vector3(player.Transform:GetWorldPosition()) 27 for k = 1, 50 do 28 local theta = 1 * 2 * PI 29 local radius = 8 30 local result_offset = FindValidPositionByFan(theta, radius, 50, function(offset) 31 local x,y,z = (pt + offset):Get() 32 local ents = TheSim:FindEntities(x,y,z , 1) 33 return not next(ents) 34 end) 35 if result_offset then 36 local tentacle = SpawnPrefab("basalt_pillar") 37 tentacle.Transform:SetPosition((pt + result_offset):Get()) 38 GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) 39 local fx = SpawnPrefab("lightning_rod_fx") 40 local pos = pt + result_offset 41 fx.Transform:SetPosition(pos.x, pos.y, pos.z) 42 end 43 inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod") 44 end 45end) 46TheInput:AddKeyUpHandler(KEY_KP_MINUS, function() 47 local player = GetPlayer() 48 local range = 15 49 local pos = Vector3(player.Transform:GetWorldPosition()) 50 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, range) 51 for k,v in pairs(ents) do 52 if v.prefab == "basalt_pillar" then 53 SpawnPrefab("lightning_rod_fx").Transform:SetPosition(v.Transform:GetWorldPosition()) 54 v:Remove() 55 end 56 end 57 inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod") 58end) 59 60 即可按小键盘加号键,在主角周围筑起一圈带高压电的玄武岩墙,怪物靠近会被电死,按小键盘减号键自动消失。注意不要离怪物太近时按加号键,会把怪物也圈进来或使墙有缺口。如果使用橙色魔杖或“瑞士手杖”(见本修改技巧),就可以自由出入各个避难所,把家具、农田放在里面,再也不怕狗和巨鹿了

2025/04/23 · Bny

YN188-口袋蜂箱(用噩梦燃料种口袋蜂箱,放在地上飞出杀人蜂攻击敌人)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一八八.口袋蜂箱(用噩梦燃料种口袋蜂箱,放在地上飞出杀人蜂攻击敌人) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/nightmarefuel.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local killersounds = 7{ 8 takeoff = "dontstarve/bee/killerbee_takeoff", 9 attack = "dontstarve/bee/killerbee_attack", 10 buzz = "dontstarve/bee/killerbee_fly_LP", 11 hit = "dontstarve/bee/killerbee_hurt", 12 death = "dontstarve/bee/killerbee_death", 13} 14local function OnDeploy (inst, pt) 15 if GetPlayer().components.inventory:Has("goldnugget", 500) then 16 GetPlayer().components.inventory:ConsumeByName("goldnugget", 500) 17 local box = SpawnPrefab("nightmarefuel") 18 box.Transform:SetPosition(pt.x, pt.y, pt.z) 19 box.AnimState:SetBank("bee_box") 20 box.AnimState:SetBuild("bee_box") 21 box.AnimState:PlayAnimation("idle") 22 box.AnimState:SetMultColour(255/255,0/255,0/255,1) 23 box.Transform:SetScale(0.5, 0.5, 0.5) 24 local sound = box.entity:AddSoundEmitter() 25 local minimap = box.entity:AddMiniMapEntity() 26 minimap:SetIcon( "beebox.png" ) 27 box.components.inventoryitem:ChangeImageName("beebox") 28 box:RemoveComponent("stackable") 29 box:RemoveComponent("fuel") 30 box:RemoveComponent("deployable") 31 box:AddComponent("workable") 32 box.components.workable:SetWorkAction(ACTIONS.HAMMER) 33 box.components.workable:SetWorkLeft(3) 34 box.components.workable:SetOnFinishCallback(function(box) 35 SpawnPrefab("collapse_small").Transform:SetPosition(box.Transform:GetWorldPosition()) 36 box.SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 37 box:Remove() 38 end ) 39 box.task = box:DoPeriodicTask(2, function(box) 40 box.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 41 box:DoTaskInTime(1, function() box.AnimState:SetBloomEffectHandle("") end ) 42 local pos = Vector3(box.Transform:GetWorldPosition()) 43 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 30) 44 for k,v in pairs(ents) do 45 if v.components.health and not v.components.health:IsDead() and not v:HasTag("player") then 46 if v.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == v or v:HasTag("monster") or v.prefab == "beefalo" or v.prefab == "bunnyman" or v.prefab == "pigman" or v.prefab == "pigguard" or v.prefab == "merm" or v.prefab == "monkey" or v.prefab == "tallbird" or v.prefab == "walrus" or v.prefab == "little_walrus" or v.prefab == "wasphive" then 47 local pt1 = box:GetPosition() 48 local killerbee = SpawnPrefab("nightmarefuel") 49 killerbee.Transform:SetPosition(pt1.x, pt1.y, pt1.z) 50 killerbee.AnimState:SetBank("bee") 51 killerbee.AnimState:SetBuild("bee_angry_build") 52 killerbee.AnimState:PlayAnimation("idle") 53 killerbee.AnimState:SetRayTestOnBB(true) 54 killerbee.AnimState:SetMultColour(255/255,255/255,255/255,1) 55 killerbee.entity:AddSoundEmitter() 56 killerbee.entity:AddLightWatcher() 57 killerbee.entity:AddDynamicShadow() 58 killerbee.DynamicShadow:SetSize( .8, .5 ) 59 killerbee.Transform:SetFourFaced() 60 MakeCharacterPhysics(killerbee, 1, .3) 61 killerbee.Physics:SetCollisionGroup(COLLISION.FLYERS) 62 killerbee.Physics:ClearCollisionMask() 63 killerbee.Physics:CollidesWith(COLLISION.WORLD) 64 killerbee.Physics:CollidesWith(COLLISION.FLYERS) 65 killerbee:AddTag("killerbee") 66 killerbee:AddComponent("locomotor") 67 killerbee.components.locomotor:EnableGroundSpeedMultiplier(false) 68 killerbee.components.locomotor:SetTriggersCreep(false) 69 killerbee:SetStateGraph("SGbee") 70 killerbee:AddComponent("health") 71 killerbee.components.health:SetMaxHealth(200) 72 killerbee:AddComponent("combat") 73 killerbee.components.combat:SetTarget(v) 74 killerbee.components.combat:SetDefaultDamage(20) 75 killerbee.components.combat:SetAttackPeriod(0.1) 76 killerbee.components.combat.hiteffectsymbol = "body" 77 killerbee.components.combat:SetRetargetFunction(1, function(killerbee) 78 if not killerbee.components.health:IsDead() then 79 return FindEntity(box, 30, function(guy) 80 if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("player") then 81 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") or guy.prefab == "beefalo" or guy.prefab == "bunnyman" or guy.prefab == "pigman" or guy.prefab == "pigguard" or guy.prefab == "merm" or guy.prefab == "monkey" or guy.prefab == "tallbird" or guy.prefab == "walrus" or guy.prefab == "little_walrus" or guy.prefab == "wasphive" 82 end 83 end) 84 end 85 end ) 86 local killerbrain = require("brains/killerbeebrain") 87 killerbee:SetBrain(killerbrain) 88 killerbee.sounds = killersounds 89 killerbee:AddComponent("knownlocations") 90 killerbee:ListenForEvent("attacked", function(killerbee, data) killerbee.components.combat:SetTarget(data.attacker) end ) 91 killerbee:RemoveComponent("stackable") 92 killerbee:RemoveComponent("fuel") 93 killerbee:RemoveComponent("deployable") 94 killerbee:RemoveComponent("inventoryitem") 95 killerbee:DoTaskInTime(30, function() killerbee:Remove() end ) 96 v:ListenForEvent("death", function() killerbee:Remove() end ) 97 end 98 end 99 end 100 end ) 101 box.components.inventoryitem:SetOnPutInInventoryFn(function(box) 102 box:RemoveTag("doings") 103 if box.task then box.task:Cancel() box.task = nil end 104 local pos = Vector3(box.Transform:GetWorldPosition()) 105 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) 106 for k,v in pairs(ents) do 107 if v:HasTag("killerbee") then 108 v:Remove() 109 end 110 end 111 end ) 112 box.components.inventoryitem:SetOnDroppedFn(function(box) 113 box:AddTag("doings") 114 box.task = box:DoPeriodicTask(2, function(box) 115 box.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 116 box:DoTaskInTime(1, function() box.AnimState:SetBloomEffectHandle("") end ) 117 local pos = Vector3(box.Transform:GetWorldPosition()) 118 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 30) 119 for k,v in pairs(ents) do 120 if v.components.health and not v.components.health:IsDead() and not v:HasTag("player") then 121 if v.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == v or v:HasTag("monster") or v.prefab == "beefalo" or v.prefab == "bunnyman" or v.prefab == "pigman" or v.prefab == "pigguard" or v.prefab == "merm" or v.prefab == "monkey" or v.prefab == "tallbird" or v.prefab == "walrus" or v.prefab == "little_walrus" or v.prefab == "wasphive" then 122 local pt1 = box:GetPosition() 123 local killerbee = SpawnPrefab("nightmarefuel") 124 killerbee.Transform:SetPosition(pt1.x, pt1.y, pt1.z) 125 killerbee.AnimState:SetBank("bee") 126 killerbee.AnimState:SetBuild("bee_angry_build") 127 killerbee.AnimState:PlayAnimation("idle") 128 killerbee.AnimState:SetRayTestOnBB(true) 129 killerbee.AnimState:SetMultColour(255/255,255/255,255/255,1) 130 killerbee.entity:AddSoundEmitter() 131 killerbee.entity:AddLightWatcher() 132 killerbee.entity:AddDynamicShadow() 133 killerbee.DynamicShadow:SetSize( .8, .5 ) 134 killerbee.Transform:SetFourFaced() 135 MakeCharacterPhysics(killerbee, 1, .3) 136 killerbee.Physics:SetCollisionGroup(COLLISION.FLYERS) 137 killerbee.Physics:ClearCollisionMask() 138 killerbee.Physics:CollidesWith(COLLISION.WORLD) 139 killerbee.Physics:CollidesWith(COLLISION.FLYERS) 140 killerbee:AddTag("killerbee") 141 killerbee:AddComponent("locomotor") 142 killerbee.components.locomotor:EnableGroundSpeedMultiplier(false) 143 killerbee.components.locomotor:SetTriggersCreep(false) 144 killerbee:SetStateGraph("SGbee") 145 killerbee:AddComponent("health") 146 killerbee.components.health:SetMaxHealth(200) 147 killerbee:AddComponent("combat") 148 killerbee.components.combat:SetTarget(v) 149 killerbee.components.combat:SetDefaultDamage(20) 150 killerbee.components.combat:SetAttackPeriod(0.1) 151 killerbee.components.combat.hiteffectsymbol = "body" 152 killerbee.components.combat:SetRetargetFunction(1, function(killerbee) 153 if not killerbee.components.health:IsDead() then 154 return FindEntity(box, 30, function(guy) 155 if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("player") then 156 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") or guy.prefab == "beefalo" or guy.prefab == "bunnyman" or guy.prefab == "pigman" or guy.prefab == "pigguard" or guy.prefab == "merm" or guy.prefab == "monkey" or guy.prefab == "tallbird" or guy.prefab == "walrus" or guy.prefab == "little_walrus" or guy.prefab == "wasphive" 157 end 158 end) 159 end 160 end ) 161 local killerbrain = require("brains/killerbeebrain") 162 killerbee:SetBrain(killerbrain) 163 killerbee.sounds = killersounds 164 killerbee:AddComponent("knownlocations") 165 killerbee:ListenForEvent("attacked", function(killerbee, data) killerbee.components.combat:SetTarget(data.attacker) end ) 166 killerbee:RemoveComponent("stackable") 167 killerbee:RemoveComponent("fuel") 168 killerbee:RemoveComponent("deployable") 169 killerbee:RemoveComponent("inventoryitem") 170 killerbee:DoTaskInTime(30, function() killerbee:Remove() end ) 171 v:ListenForEvent("death", function() killerbee:Remove() end ) 172 end 173 end 174 end 175 end ) 176 end ) 177 box:AddTag("doings") 178 box:AddTag("boxs") 179 end 180 inst.components.stackable:Get():Remove() 181end 182 inst:AddComponent("deployable") 183 inst.components.deployable.ondeploy = OnDeploy 184local function onsave(inst, data) 185 if inst:HasTag("boxs") then 186 data.boxs = true 187 end 188 if inst:HasTag("doings") then 189 data.doings = true 190 end 191 if inst:HasTag("killerbee") then 192 data.killerbee = true 193 end 194end 195local function onload(inst, data) 196 if data and data.boxs then 197 inst.AnimState:SetBank("bee_box") 198 inst.AnimState:SetBuild("bee_box") 199 inst.AnimState:PlayAnimation("idle") 200 inst.AnimState:SetMultColour(255/255,0/255,0/255,1) 201 inst.Transform:SetScale(0.5, 0.5, 0.5) 202 local sound = inst.entity:AddSoundEmitter() 203 local minimap = inst.entity:AddMiniMapEntity() 204 minimap:SetIcon( "beebox.png" ) 205 inst.components.inventoryitem:ChangeImageName("beebox") 206 inst:RemoveComponent("stackable") 207 inst:RemoveComponent("fuel") 208 inst:RemoveComponent("deployable") 209 inst:AddComponent("workable") 210 inst.components.workable:SetWorkAction(ACTIONS.HAMMER) 211 inst.components.workable:SetWorkLeft(3) 212 inst.components.workable:SetOnFinishCallback(function(inst) 213 SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) 214 inst.SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 215 inst:Remove() 216 end ) 217 inst.components.inventoryitem:SetOnPutInInventoryFn(function(inst) 218 inst:RemoveTag("doings") 219 if inst.task then inst.task:Cancel() inst.task = nil end 220 local pos = Vector3(inst.Transform:GetWorldPosition()) 221 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) 222 for k,v in pairs(ents) do 223 if v:HasTag("killerbee") then 224 v:Remove() 225 end 226 end 227 end ) 228 inst.components.inventoryitem:SetOnDroppedFn(function(inst) 229 inst:AddTag("doings") 230 inst.task = inst:DoPeriodicTask(2, function(inst) 231 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 232 inst:DoTaskInTime(1, function() inst.AnimState:SetBloomEffectHandle("") end ) 233 local pos = Vector3(inst.Transform:GetWorldPosition()) 234 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 30) 235 for k,v in pairs(ents) do 236 if v.components.health and not v.components.health:IsDead() and not v:HasTag("player") then 237 if v.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == v or v:HasTag("monster") or v.prefab == "beefalo" or v.prefab == "bunnyman" or v.prefab == "pigman" or v.prefab == "pigguard" or v.prefab == "merm" or v.prefab == "monkey" or v.prefab == "tallbird" or v.prefab == "walrus" or v.prefab == "little_walrus" or v.prefab == "wasphive" then 238 local pt1 = inst:GetPosition() 239 local killerbee = SpawnPrefab("nightmarefuel") 240 killerbee.Transform:SetPosition(pt1.x, pt1.y, pt1.z) 241 killerbee.AnimState:SetBank("bee") 242 killerbee.AnimState:SetBuild("bee_angry_build") 243 killerbee.AnimState:PlayAnimation("idle") 244 killerbee.AnimState:SetRayTestOnBB(true) 245 killerbee.AnimState:SetMultColour(255/255,255/255,255/255,1) 246 killerbee.entity:AddSoundEmitter() 247 killerbee.entity:AddLightWatcher() 248 killerbee.entity:AddDynamicShadow() 249 killerbee.DynamicShadow:SetSize( .8, .5 ) 250 killerbee.Transform:SetFourFaced() 251 MakeCharacterPhysics(killerbee, 1, .3) 252 killerbee.Physics:SetCollisionGroup(COLLISION.FLYERS) 253 killerbee.Physics:ClearCollisionMask() 254 killerbee.Physics:CollidesWith(COLLISION.WORLD) 255 killerbee.Physics:CollidesWith(COLLISION.FLYERS) 256 killerbee:AddTag("killerbee") 257 killerbee:AddComponent("locomotor") 258 killerbee.components.locomotor:EnableGroundSpeedMultiplier(false) 259 killerbee.components.locomotor:SetTriggersCreep(false) 260 killerbee:SetStateGraph("SGbee") 261 killerbee:AddComponent("health") 262 killerbee.components.health:SetMaxHealth(200) 263 killerbee:AddComponent("combat") 264 killerbee.components.combat:SetTarget(v) 265 killerbee.components.combat:SetDefaultDamage(20) 266 killerbee.components.combat:SetAttackPeriod(0.1) 267 killerbee.components.combat.hiteffectsymbol = "body" 268 killerbee.components.combat:SetRetargetFunction(1, function(killerbee) 269 if not killerbee.components.health:IsDead() then 270 return FindEntity(inst, 30, function(guy) 271 if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("player") then 272 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") or guy.prefab == "beefalo" or guy.prefab == "bunnyman" or guy.prefab == "pigman" or guy.prefab == "pigguard" or guy.prefab == "merm" or guy.prefab == "monkey" or guy.prefab == "tallbird" or guy.prefab == "walrus" or guy.prefab == "little_walrus" or guy.prefab == "wasphive" 273 end 274 end) 275 end 276 end ) 277 local killerbrain = require("brains/killerbeebrain") 278 killerbee:SetBrain(killerbrain) 279 killerbee.sounds = killersounds 280 killerbee:AddComponent("knownlocations") 281 killerbee:ListenForEvent("attacked", function(killerbee, data) killerbee.components.combat:SetTarget(data.attacker) end ) 282 killerbee:RemoveComponent("stackable") 283 killerbee:RemoveComponent("fuel") 284 killerbee:RemoveComponent("deployable") 285 killerbee:RemoveComponent("inventoryitem") 286 killerbee:DoTaskInTime(30, function() killerbee:Remove() end ) 287 v:ListenForEvent("death", function() killerbee:Remove() end ) 288 end 289 end 290 end 291 end ) 292 end ) 293 inst:AddTag("boxs") 294 end 295 if data and data.doings then 296 inst.task = inst:DoPeriodicTask(2, function(inst) 297 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 298 inst:DoTaskInTime(1, function() inst.AnimState:SetBloomEffectHandle("") end ) 299 local pos = Vector3(inst.Transform:GetWorldPosition()) 300 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 30) 301 for k,v in pairs(ents) do 302 if v.components.health and not v.components.health:IsDead() and not v:HasTag("player") then 303 if v.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == v or v:HasTag("monster") or v.prefab == "beefalo" or v.prefab == "bunnyman" or v.prefab == "pigman" or v.prefab == "pigguard" or v.prefab == "merm" or v.prefab == "monkey" or v.prefab == "tallbird" or v.prefab == "walrus" or v.prefab == "little_walrus" or v.prefab == "wasphive" then 304 local pt1 = inst:GetPosition() 305 local killerbee = SpawnPrefab("nightmarefuel") 306 killerbee.Transform:SetPosition(pt1.x, pt1.y, pt1.z) 307 killerbee.AnimState:SetBank("bee") 308 killerbee.AnimState:SetBuild("bee_angry_build") 309 killerbee.AnimState:PlayAnimation("idle") 310 killerbee.AnimState:SetRayTestOnBB(true) 311 killerbee.AnimState:SetMultColour(255/255,255/255,255/255,1) 312 killerbee.entity:AddSoundEmitter() 313 killerbee.entity:AddLightWatcher() 314 killerbee.entity:AddDynamicShadow() 315 killerbee.DynamicShadow:SetSize( .8, .5 ) 316 killerbee.Transform:SetFourFaced() 317 MakeCharacterPhysics(killerbee, 1, .3) 318 killerbee.Physics:SetCollisionGroup(COLLISION.FLYERS) 319 killerbee.Physics:ClearCollisionMask() 320 killerbee.Physics:CollidesWith(COLLISION.WORLD) 321 killerbee.Physics:CollidesWith(COLLISION.FLYERS) 322 killerbee:AddTag("killerbee") 323 killerbee:AddComponent("locomotor") 324 killerbee.components.locomotor:EnableGroundSpeedMultiplier(false) 325 killerbee.components.locomotor:SetTriggersCreep(false) 326 killerbee:SetStateGraph("SGbee") 327 killerbee:AddComponent("health") 328 killerbee.components.health:SetMaxHealth(200) 329 killerbee:AddComponent("combat") 330 killerbee.components.combat:SetTarget(v) 331 killerbee.components.combat:SetDefaultDamage(20) 332 killerbee.components.combat:SetAttackPeriod(0.1) 333 killerbee.components.combat.hiteffectsymbol = "body" 334 killerbee.components.combat:SetRetargetFunction(1, function(killerbee) 335 if not killerbee.components.health:IsDead() then 336 return FindEntity(inst, 30, function(guy) 337 if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("player") then 338 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") or guy.prefab == "beefalo" or guy.prefab == "bunnyman" or guy.prefab == "pigman" or guy.prefab == "pigguard" or guy.prefab == "merm" or guy.prefab == "monkey" or guy.prefab == "tallbird" or guy.prefab == "walrus" or guy.prefab == "little_walrus" or guy.prefab == "wasphive" 339 end 340 end) 341 end 342 end ) 343 local killerbrain = require("brains/killerbeebrain") 344 killerbee:SetBrain(killerbrain) 345 killerbee.sounds = killersounds 346 killerbee:AddComponent("knownlocations") 347 killerbee:ListenForEvent("attacked", function(killerbee, data) killerbee.components.combat:SetTarget(data.attacker) end ) 348 killerbee:RemoveComponent("stackable") 349 killerbee:RemoveComponent("fuel") 350 killerbee:RemoveComponent("deployable") 351 killerbee:RemoveComponent("inventoryitem") 352 killerbee:DoTaskInTime(30, function() killerbee:Remove() end ) 353 v:ListenForEvent("death", function() killerbee:Remove() end ) 354 end 355 end 356 end 357 end ) 358 inst:AddTag("doings") 359 end 360 if data and data.killerbee then 361 inst:Remove() 362 end 363end 364 inst.OnSave = onsave 365 inst.OnLoad = onload 366 367 即可在攒够500个黄金时,用噩梦燃料种口袋蜂箱,将消费500个黄金,身上黄金数不足时不会种出来。蜂箱放在地上时,如果周围有敌人,会不断飞出杀人蜂攻击敌人,直至敌人死亡为止,且杀人蜂不会攻击主角及同伴(不包括猪人、兔人)。鼠标左键点口袋蜂箱,可将其放入物品栏,显示为蜂箱的图标,所有飞出的杀人蜂将消失。口袋蜂箱类似于导弹防御系统,既可以帮助主角作战,也可以保护基地,无论周围有多少敌人,都会派出足够数量的杀人蜂去攻击,因此只种一个即可,否则对电脑硬件要求较高。可以通过小地图查询口袋蜂箱的位置,显示为蜂箱的图标。不想要口袋蜂箱时,用锤子砸掉即可

2025/04/23 · Bny

YN189-避魔圈(按键盘F9键在地上画避魔圈,任何生物靠近都将被弹开,再按F9键取消)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一八九.避魔圈(按键盘F9键在地上画避魔圈,任何生物靠近都将被弹开,再按F9键取消) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playeractionpicker")的下一行插入以下内容: 5 6TheInput:AddKeyUpHandler(KEY_F9, function() 7 if not inst:HasTag("havelifebuoy") then 8 inst:AddTag("havelifebuoy") 9 inst.components.locomotor:Stop() 10 inst.AnimState:PlayAnimation("give") 11 inst.components.health:DoDelta(-10) 12 GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.7, 0.02, .5, 40) 13 GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") 14 SpawnPrefab("groundpoundring_fx").Transform:SetPosition(inst.Transform:GetWorldPosition()) 15 SpawnPrefab("tauntfire_fx").Transform:SetPosition(inst.Transform:GetWorldPosition()) 16 inst:DoTaskInTime(0.5, function() 17 local pt = inst:GetPosition() 18 local lifebuoy = SpawnPrefab("firesuppressor_placer") 19 lifebuoy.Transform:SetPosition(pt.x, 0, pt.z) 20 lifebuoy.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround ) 21 lifebuoy.AnimState:SetLayer( LAYER_BACKGROUND ) 22 lifebuoy.AnimState:SetSortOrder( 1 ) 23 lifebuoy.Transform:SetScale(1.1, 1.1, 1.1) 24 lifebuoy.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 25 lifebuoy.AnimState:SetMultColour(255/255,0/255,0/255,1) 26 lifebuoy.persists = false 27 lifebuoy:DoPeriodicTask(0.3, function() 28 local pos = Vector3(lifebuoy.Transform:GetWorldPosition()) 29 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 10) 30 for k,v in pairs(ents) do 31 if v.components.health and v.components.combat and not v.components.health:IsDead() and not v:HasTag("player") and not v:HasTag("wall") then 32 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 33 SpawnPrefab("explode_small").Transform:SetPosition(v.Transform:GetWorldPosition()) 34 v.components.health:DoDelta(-200) 35 local pt1 = lifebuoy:GetPosition() 36 local pt2 = v:GetPosition() 37 v.Transform:SetPosition((pt2.x-pt1.x)*1.5+pt2.x, 0, (pt2.z-pt1.z)*1.5+pt2.z) 38 end 39 end 40 end ) 41 lifebuoy:AddTag("NOCLICK") 42 lifebuoy:AddTag("lifebuoy") 43 end ) 44 else 45 inst:RemoveTag("havelifebuoy") 46 inst.components.locomotor:Stop() 47 inst.AnimState:PlayAnimation("give") 48 GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") 49 SpawnPrefab("tauntfire_fx").Transform:SetPosition(inst.Transform:GetWorldPosition()) 50 local pos = Vector3(inst.Transform:GetWorldPosition()) 51 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) 52 for k,v in pairs(ents) do 53 if v:HasTag("lifebuoy") then 54 v:Remove() 55 end 56 end 57 end 58end ) 59 60 即可按键盘F9键在地上画避魔圈,主角站在圈中,任何生物靠近都将被弹开,并杀伤其生命值,再次按键盘F9键收掉避魔圈。避魔圈是一种血魔法,每画一次,主角将消耗10点生命,在生命值较低时,请勿施法

2025/04/23 · Bny