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

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

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一八三.迷魂花阵(戴花环周围出现食人花眼睛保护主角) 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/hats.lua文件,将下列内容: inst:AddComponent("perishable") inst.components.perishable:SetPerishTime(TUNING.PERISH_FAST) inst.components.perishable:StartPerishing() inst.components.perishable:SetOnPerishFn(generic_perish) inst.components.equippable:SetOnEquip( opentop_onequip ) 替换为: local function flower_equip(inst, owner) opentop_onequip(inst, owner) inst:AddComponent("minionspawner") inst.components.minionspawner.miniontype = "eyeplant" inst.components.minionspawner.maxminions = 27 inst.components.minionspawner.minionspawntime = {min = 0.01, max = 0.01} inst.components.minionspawner.numminions = 10 inst.components.minionspawner.shouldspawn = true inst.components.minionspawner:StartNextSpawn() end local function flower_unequip(inst, owner) onunequip(inst, owner) inst.components.minionspawner.shouldspawn = false inst.components.minionspawner:KillAllMinions() inst:RemoveComponent("minionspawner") end inst.components.equippable:SetOnEquip( flower_equip ) inst.components.equippable:SetOnUnequip( flower_unequip ) 2.用MT管理器打开游戏目录/assets/scripts/prefabs/eyeplant.lua文件,将下列内容: 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) 替换为: 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) 即可戴花环周围出现食人花眼睛保护主角,食人花眼睛被敌人打死一个又会再生一个。摘下花环,食人花眼睛立即消失

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一八五.音浪太强(戴兔耳罩周围形成音浪,敌人被弹开) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/hats.lua文件,将下列内容: local function earmuffs() local inst = simple() inst:AddComponent("insulator") inst.components.insulator.insulation = TUNING.INSULATION_SMALL inst.components.equippable:SetOnEquip( opentop_onequip ) inst:AddComponent("fueled") inst.components.fueled.fueltype = "USAGE" inst.components.fueled:InitializeFuelLevel(TUNING.EARMUFF_PERISHTIME) inst.components.fueled:SetDepletedFn(generic_perish) inst.AnimState:SetRayTestOnBB(true) return inst end 替换为: local colours= { {198/255,43/255,43/255}, {79/255,153/255,68/255}, {35/255,105/255,235/255}, {233/255,208/255,69/255}, {109/255,50/255,163/255}, {222/255,126/255,39/255}, } local function pickup(inst, owner) inst.colour_idx = math.random(#colours) local light = inst.entity:AddLight() light:SetIntensity(.8) light:SetRadius(3) light:SetFalloff(1) light:Enable(true) light:SetColour(colours[inst.colour_idx][1],colours[inst.colour_idx][2],colours[inst.colour_idx][3]) local pt = Vector3(owner.Transform:GetWorldPosition()) local result_offset = FindValidPositionByFan(math.random()*2*PI, 10, 75, function(offset) local x,y,z = (pt + offset):Get() local ents = TheSim:FindEntities(x,y,z , 1) return not next(ents) end) local ents2 = TheSim:FindEntities(pt.x,pt.y,pt.z, 8) for k,v in pairs(ents2) do 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 v.Transform:SetPosition((pt + result_offset):Get()) end end end local function earmuffs_onequip(inst, owner) inst.task = inst:DoPeriodicTask(.033, function() pickup(inst, owner) end) GetPlayer().SoundEmitter:PlaySound("dontstarve/music/music_hoedown", "beavermusic") opentop_onequip(inst, owner) end local function earmuffs_onunequip(inst, owner) if inst.task then inst.task:Cancel() inst.task = nil end GetPlayer().SoundEmitter:KillSound("beavermusic") onunequip(inst, owner) inst.Light:Enable(false) end local function earmuffs() local inst = simple() inst:AddComponent("insulator") inst.components.insulator.insulation = TUNING.INSULATION_SMALL inst.components.equippable:SetOnEquip( earmuffs_onequip ) inst.components.equippable:SetOnUnequip( earmuffs_onunequip ) inst.AnimState:SetRayTestOnBB(true) return inst end 即可在戴兔耳罩时,周围形成音浪,敌人靠近会被弹开,拆杀人蜂窝、偷高鸟蛋毫发无伤。兔耳罩在穿戴选项(画着礼帽)下,用2个兔子、1个树枝制造

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一八八.口袋蜂箱(用噩梦燃料种口袋蜂箱,放在地上飞出杀人蜂攻击敌人) 用MT管理器打开游戏目录/assets/scripts/prefabs/nightmarefuel.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local killersounds = { takeoff = "dontstarve/bee/killerbee_takeoff", attack = "dontstarve/bee/killerbee_attack", buzz = "dontstarve/bee/killerbee_fly_LP", hit = "dontstarve/bee/killerbee_hurt", death = "dontstarve/bee/killerbee_death", } local function OnDeploy (inst, pt) if GetPlayer().components.inventory:Has("goldnugget", 500) then GetPlayer().components.inventory:ConsumeByName("goldnugget", 500) local box = SpawnPrefab("nightmarefuel") box.Transform:SetPosition(pt.x, pt.y, pt.z) box.AnimState:SetBank("bee_box") box.AnimState:SetBuild("bee_box") box.AnimState:PlayAnimation("idle") box.AnimState:SetMultColour(255/255,0/255,0/255,1) box.Transform:SetScale(0.5, 0.5, 0.5) local sound = box.entity:AddSoundEmitter() local minimap = box.entity:AddMiniMapEntity() minimap:SetIcon( "beebox.png" ) box.components.inventoryitem:ChangeImageName("beebox") box:RemoveComponent("stackable") box:RemoveComponent("fuel") box:RemoveComponent("deployable") box:AddComponent("workable") box.components.workable:SetWorkAction(ACTIONS.HAMMER) box.components.workable:SetWorkLeft(3) box.components.workable:SetOnFinishCallback(function(box) SpawnPrefab("collapse_small").Transform:SetPosition(box.Transform:GetWorldPosition()) box.SoundEmitter:PlaySound("dontstarve/common/destroy_wood") box:Remove() end ) box.task = box:DoPeriodicTask(2, function(box) box.AnimState:SetBloomEffectHandle("shaders/anim.ksh") box:DoTaskInTime(1, function() box.AnimState:SetBloomEffectHandle("") end ) local pos = Vector3(box.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 30) for k,v in pairs(ents) do if v.components.health and not v.components.health:IsDead() and not v:HasTag("player") then 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 local pt1 = box:GetPosition() local killerbee = SpawnPrefab("nightmarefuel") killerbee.Transform:SetPosition(pt1.x, pt1.y, pt1.z) killerbee.AnimState:SetBank("bee") killerbee.AnimState:SetBuild("bee_angry_build") killerbee.AnimState:PlayAnimation("idle") killerbee.AnimState:SetRayTestOnBB(true) killerbee.AnimState:SetMultColour(255/255,255/255,255/255,1) killerbee.entity:AddSoundEmitter() killerbee.entity:AddLightWatcher() killerbee.entity:AddDynamicShadow() killerbee.DynamicShadow:SetSize( .8, .5 ) killerbee.Transform:SetFourFaced() MakeCharacterPhysics(killerbee, 1, .3) killerbee.Physics:SetCollisionGroup(COLLISION.FLYERS) killerbee.Physics:ClearCollisionMask() killerbee.Physics:CollidesWith(COLLISION.WORLD) killerbee.Physics:CollidesWith(COLLISION.FLYERS) killerbee:AddTag("killerbee") killerbee:AddComponent("locomotor") killerbee.components.locomotor:EnableGroundSpeedMultiplier(false) killerbee.components.locomotor:SetTriggersCreep(false) killerbee:SetStateGraph("SGbee") killerbee:AddComponent("health") killerbee.components.health:SetMaxHealth(200) killerbee:AddComponent("combat") killerbee.components.combat:SetTarget(v) killerbee.components.combat:SetDefaultDamage(20) killerbee.components.combat:SetAttackPeriod(0.1) killerbee.components.combat.hiteffectsymbol = "body" killerbee.components.combat:SetRetargetFunction(1, function(killerbee) if not killerbee.components.health:IsDead() then return FindEntity(box, 30, function(guy) if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("player") then 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" end end) end end ) local killerbrain = require("brains/killerbeebrain") killerbee:SetBrain(killerbrain) killerbee.sounds = killersounds killerbee:AddComponent("knownlocations") killerbee:ListenForEvent("attacked", function(killerbee, data) killerbee.components.combat:SetTarget(data.attacker) end ) killerbee:RemoveComponent("stackable") killerbee:RemoveComponent("fuel") killerbee:RemoveComponent("deployable") killerbee:RemoveComponent("inventoryitem") killerbee:DoTaskInTime(30, function() killerbee:Remove() end ) v:ListenForEvent("death", function() killerbee:Remove() end ) end end end end ) box.components.inventoryitem:SetOnPutInInventoryFn(function(box) box:RemoveTag("doings") if box.task then box.task:Cancel() box.task = nil end local pos = Vector3(box.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) for k,v in pairs(ents) do if v:HasTag("killerbee") then v:Remove() end end end ) box.components.inventoryitem:SetOnDroppedFn(function(box) box:AddTag("doings") box.task = box:DoPeriodicTask(2, function(box) box.AnimState:SetBloomEffectHandle("shaders/anim.ksh") box:DoTaskInTime(1, function() box.AnimState:SetBloomEffectHandle("") end ) local pos = Vector3(box.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 30) for k,v in pairs(ents) do if v.components.health and not v.components.health:IsDead() and not v:HasTag("player") then 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 local pt1 = box:GetPosition() local killerbee = SpawnPrefab("nightmarefuel") killerbee.Transform:SetPosition(pt1.x, pt1.y, pt1.z) killerbee.AnimState:SetBank("bee") killerbee.AnimState:SetBuild("bee_angry_build") killerbee.AnimState:PlayAnimation("idle") killerbee.AnimState:SetRayTestOnBB(true) killerbee.AnimState:SetMultColour(255/255,255/255,255/255,1) killerbee.entity:AddSoundEmitter() killerbee.entity:AddLightWatcher() killerbee.entity:AddDynamicShadow() killerbee.DynamicShadow:SetSize( .8, .5 ) killerbee.Transform:SetFourFaced() MakeCharacterPhysics(killerbee, 1, .3) killerbee.Physics:SetCollisionGroup(COLLISION.FLYERS) killerbee.Physics:ClearCollisionMask() killerbee.Physics:CollidesWith(COLLISION.WORLD) killerbee.Physics:CollidesWith(COLLISION.FLYERS) killerbee:AddTag("killerbee") killerbee:AddComponent("locomotor") killerbee.components.locomotor:EnableGroundSpeedMultiplier(false) killerbee.components.locomotor:SetTriggersCreep(false) killerbee:SetStateGraph("SGbee") killerbee:AddComponent("health") killerbee.components.health:SetMaxHealth(200) killerbee:AddComponent("combat") killerbee.components.combat:SetTarget(v) killerbee.components.combat:SetDefaultDamage(20) killerbee.components.combat:SetAttackPeriod(0.1) killerbee.components.combat.hiteffectsymbol = "body" killerbee.components.combat:SetRetargetFunction(1, function(killerbee) if not killerbee.components.health:IsDead() then return FindEntity(box, 30, function(guy) if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("player") then 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" end end) end end ) local killerbrain = require("brains/killerbeebrain") killerbee:SetBrain(killerbrain) killerbee.sounds = killersounds killerbee:AddComponent("knownlocations") killerbee:ListenForEvent("attacked", function(killerbee, data) killerbee.components.combat:SetTarget(data.attacker) end ) killerbee:RemoveComponent("stackable") killerbee:RemoveComponent("fuel") killerbee:RemoveComponent("deployable") killerbee:RemoveComponent("inventoryitem") killerbee:DoTaskInTime(30, function() killerbee:Remove() end ) v:ListenForEvent("death", function() killerbee:Remove() end ) end end end end ) end ) box:AddTag("doings") box:AddTag("boxs") end inst.components.stackable:Get():Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("boxs") then data.boxs = true end if inst:HasTag("doings") then data.doings = true end if inst:HasTag("killerbee") then data.killerbee = true end end local function onload(inst, data) if data and data.boxs then inst.AnimState:SetBank("bee_box") inst.AnimState:SetBuild("bee_box") inst.AnimState:PlayAnimation("idle") inst.AnimState:SetMultColour(255/255,0/255,0/255,1) inst.Transform:SetScale(0.5, 0.5, 0.5) local sound = inst.entity:AddSoundEmitter() local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon( "beebox.png" ) inst.components.inventoryitem:ChangeImageName("beebox") inst:RemoveComponent("stackable") inst:RemoveComponent("fuel") inst:RemoveComponent("deployable") inst:AddComponent("workable") inst.components.workable:SetWorkAction(ACTIONS.HAMMER) inst.components.workable:SetWorkLeft(3) inst.components.workable:SetOnFinishCallback(function(inst) SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst.SoundEmitter:PlaySound("dontstarve/common/destroy_wood") inst:Remove() end ) inst.components.inventoryitem:SetOnPutInInventoryFn(function(inst) inst:RemoveTag("doings") if inst.task then inst.task:Cancel() inst.task = nil end local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) for k,v in pairs(ents) do if v:HasTag("killerbee") then v:Remove() end end end ) inst.components.inventoryitem:SetOnDroppedFn(function(inst) inst:AddTag("doings") inst.task = inst:DoPeriodicTask(2, function(inst) inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") inst:DoTaskInTime(1, function() inst.AnimState:SetBloomEffectHandle("") end ) local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 30) for k,v in pairs(ents) do if v.components.health and not v.components.health:IsDead() and not v:HasTag("player") then 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 local pt1 = inst:GetPosition() local killerbee = SpawnPrefab("nightmarefuel") killerbee.Transform:SetPosition(pt1.x, pt1.y, pt1.z) killerbee.AnimState:SetBank("bee") killerbee.AnimState:SetBuild("bee_angry_build") killerbee.AnimState:PlayAnimation("idle") killerbee.AnimState:SetRayTestOnBB(true) killerbee.AnimState:SetMultColour(255/255,255/255,255/255,1) killerbee.entity:AddSoundEmitter() killerbee.entity:AddLightWatcher() killerbee.entity:AddDynamicShadow() killerbee.DynamicShadow:SetSize( .8, .5 ) killerbee.Transform:SetFourFaced() MakeCharacterPhysics(killerbee, 1, .3) killerbee.Physics:SetCollisionGroup(COLLISION.FLYERS) killerbee.Physics:ClearCollisionMask() killerbee.Physics:CollidesWith(COLLISION.WORLD) killerbee.Physics:CollidesWith(COLLISION.FLYERS) killerbee:AddTag("killerbee") killerbee:AddComponent("locomotor") killerbee.components.locomotor:EnableGroundSpeedMultiplier(false) killerbee.components.locomotor:SetTriggersCreep(false) killerbee:SetStateGraph("SGbee") killerbee:AddComponent("health") killerbee.components.health:SetMaxHealth(200) killerbee:AddComponent("combat") killerbee.components.combat:SetTarget(v) killerbee.components.combat:SetDefaultDamage(20) killerbee.components.combat:SetAttackPeriod(0.1) killerbee.components.combat.hiteffectsymbol = "body" killerbee.components.combat:SetRetargetFunction(1, function(killerbee) if not killerbee.components.health:IsDead() then return FindEntity(inst, 30, function(guy) if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("player") then 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" end end) end end ) local killerbrain = require("brains/killerbeebrain") killerbee:SetBrain(killerbrain) killerbee.sounds = killersounds killerbee:AddComponent("knownlocations") killerbee:ListenForEvent("attacked", function(killerbee, data) killerbee.components.combat:SetTarget(data.attacker) end ) killerbee:RemoveComponent("stackable") killerbee:RemoveComponent("fuel") killerbee:RemoveComponent("deployable") killerbee:RemoveComponent("inventoryitem") killerbee:DoTaskInTime(30, function() killerbee:Remove() end ) v:ListenForEvent("death", function() killerbee:Remove() end ) end end end end ) end ) inst:AddTag("boxs") end if data and data.doings then inst.task = inst:DoPeriodicTask(2, function(inst) inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") inst:DoTaskInTime(1, function() inst.AnimState:SetBloomEffectHandle("") end ) local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 30) for k,v in pairs(ents) do if v.components.health and not v.components.health:IsDead() and not v:HasTag("player") then 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 local pt1 = inst:GetPosition() local killerbee = SpawnPrefab("nightmarefuel") killerbee.Transform:SetPosition(pt1.x, pt1.y, pt1.z) killerbee.AnimState:SetBank("bee") killerbee.AnimState:SetBuild("bee_angry_build") killerbee.AnimState:PlayAnimation("idle") killerbee.AnimState:SetRayTestOnBB(true) killerbee.AnimState:SetMultColour(255/255,255/255,255/255,1) killerbee.entity:AddSoundEmitter() killerbee.entity:AddLightWatcher() killerbee.entity:AddDynamicShadow() killerbee.DynamicShadow:SetSize( .8, .5 ) killerbee.Transform:SetFourFaced() MakeCharacterPhysics(killerbee, 1, .3) killerbee.Physics:SetCollisionGroup(COLLISION.FLYERS) killerbee.Physics:ClearCollisionMask() killerbee.Physics:CollidesWith(COLLISION.WORLD) killerbee.Physics:CollidesWith(COLLISION.FLYERS) killerbee:AddTag("killerbee") killerbee:AddComponent("locomotor") killerbee.components.locomotor:EnableGroundSpeedMultiplier(false) killerbee.components.locomotor:SetTriggersCreep(false) killerbee:SetStateGraph("SGbee") killerbee:AddComponent("health") killerbee.components.health:SetMaxHealth(200) killerbee:AddComponent("combat") killerbee.components.combat:SetTarget(v) killerbee.components.combat:SetDefaultDamage(20) killerbee.components.combat:SetAttackPeriod(0.1) killerbee.components.combat.hiteffectsymbol = "body" killerbee.components.combat:SetRetargetFunction(1, function(killerbee) if not killerbee.components.health:IsDead() then return FindEntity(inst, 30, function(guy) if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("player") then 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" end end) end end ) local killerbrain = require("brains/killerbeebrain") killerbee:SetBrain(killerbrain) killerbee.sounds = killersounds killerbee:AddComponent("knownlocations") killerbee:ListenForEvent("attacked", function(killerbee, data) killerbee.components.combat:SetTarget(data.attacker) end ) killerbee:RemoveComponent("stackable") killerbee:RemoveComponent("fuel") killerbee:RemoveComponent("deployable") killerbee:RemoveComponent("inventoryitem") killerbee:DoTaskInTime(30, function() killerbee:Remove() end ) v:ListenForEvent("death", function() killerbee:Remove() end ) end end end end ) inst:AddTag("doings") end if data and data.killerbee then inst:Remove() end end inst.OnSave = onsave inst.OnLoad = onload 即可在攒够500个黄金时,用噩梦燃料种口袋蜂箱,将消费500个黄金,身上黄金数不足时不会种出来。蜂箱放在地上时,如果周围有敌人,会不断飞出杀人蜂攻击敌人,直至敌人死亡为止,且杀人蜂不会攻击主角及同伴(不包括猪人、兔人)。鼠标左键点口袋蜂箱,可将其放入物品栏,显示为蜂箱的图标,所有飞出的杀人蜂将消失。口袋蜂箱类似于导弹防御系统,既可以帮助主角作战,也可以保护基地,无论周围有多少敌人,都会派出足够数量的杀人蜂去攻击,因此只种一个即可,否则对电脑硬件要求较高。可以通过小地图查询口袋蜂箱的位置,显示为蜂箱的图标。不想要口袋蜂箱时,用锤子砸掉即可

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一八九.避魔圈(按键盘F9键在地上画避魔圈,任何生物靠近都将被弹开,再按F9键取消) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playeractionpicker")的下一行插入以下内容: TheInput:AddKeyUpHandler(KEY_F9, function() if not inst:HasTag("havelifebuoy") then inst:AddTag("havelifebuoy") inst.components.locomotor:Stop() inst.AnimState:PlayAnimation("give") inst.components.health:DoDelta(-10) GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.7, 0.02, .5, 40) GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") SpawnPrefab("groundpoundring_fx").Transform:SetPosition(inst.Transform:GetWorldPosition()) SpawnPrefab("tauntfire_fx").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst:DoTaskInTime(0.5, function() local pt = inst:GetPosition() local lifebuoy = SpawnPrefab("firesuppressor_placer") lifebuoy.Transform:SetPosition(pt.x, 0, pt.z) lifebuoy.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround ) lifebuoy.AnimState:SetLayer( LAYER_BACKGROUND ) lifebuoy.AnimState:SetSortOrder( 1 ) lifebuoy.Transform:SetScale(1.1, 1.1, 1.1) lifebuoy.AnimState:SetBloomEffectHandle("shaders/anim.ksh") lifebuoy.AnimState:SetMultColour(255/255,0/255,0/255,1) lifebuoy.persists = false lifebuoy:DoPeriodicTask(0.3, function() local pos = Vector3(lifebuoy.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 10) for k,v in pairs(ents) do 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 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") SpawnPrefab("explode_small").Transform:SetPosition(v.Transform:GetWorldPosition()) v.components.health:DoDelta(-200) local pt1 = lifebuoy:GetPosition() local pt2 = v:GetPosition() v.Transform:SetPosition((pt2.x-pt1.x)*1.5+pt2.x, 0, (pt2.z-pt1.z)*1.5+pt2.z) end end end ) lifebuoy:AddTag("NOCLICK") lifebuoy:AddTag("lifebuoy") end ) else inst:RemoveTag("havelifebuoy") inst.components.locomotor:Stop() inst.AnimState:PlayAnimation("give") GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") SpawnPrefab("tauntfire_fx").Transform:SetPosition(inst.Transform:GetWorldPosition()) local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) for k,v in pairs(ents) do if v:HasTag("lifebuoy") then v:Remove() end end end end ) 即可按键盘F9键在地上画避魔圈,主角站在圈中,任何生物靠近都将被弹开,并杀伤其生命值,再次按键盘F9键收掉避魔圈。避魔圈是一种血魔法,每画一次,主角将消耗10点生命,在生命值较低时,请勿施法

2025/04/23 · Bny