YN162-萌时代(扔蜂蜜将怪物变回童年)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一六二.萌时代(扔蜂蜜将怪物变回童年) 用MT管理器打开游戏目录/assets/scripts/prefabs/honey.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function onhit(inst, attacker, target) inst:Remove() SpawnPrefab("collapse_small").Transform:SetPosition(target.Transform:GetWorldPosition()) target.Transform:SetScale(0.7, 0.7, 0.7) if target.components.health then target.components.health.currenthealth = 1 target.components.health.maxhealth = 1 end if target.components.combat then target.components.combat:SetDefaultDamage(0) target.components.combat.target = nil end if target.components.locomotor then target.components.locomotor.runspeed = 1 target.components.locomotor.walkspeed = 1 end end local function onthrown(inst, data) inst.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround ) end inst:AddComponent("weapon") inst.components.weapon:SetDamage(0) inst.components.weapon:SetRange(20, 25) inst:AddComponent("equippable") inst.components.equippable.equipstack = true inst:AddComponent("projectile") inst.components.projectile:SetSpeed(60) inst.components.projectile:SetOnHitFn(onhit) inst:ListenForEvent("onthrown", onthrown) 即可扔蜂蜜将怪物变成无害的童年怪物,怪物体型变小、生命值为1、没有攻击力、行走缓慢。因为蜂蜜可装备,如果主角也想吃蜂蜜,请拿起蜂蜜对主角按鼠标右键

2025/04/23 · Bny

YN163-犬牙手雷(扔犬牙炸倒一大片)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一六三.犬牙手雷(扔犬牙炸倒一大片) 用MT管理器打开游戏目录/assets/scripts/prefabs/houndstooth.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function onhit(inst, attacker, target) SpawnPrefab("collapse_small").Transform:SetPosition(target.Transform:GetWorldPosition()) SpawnPrefab("explode_small").Transform:SetPosition(target.Transform:GetWorldPosition()) local pos = Vector3(target.Transform:GetWorldPosition()) GetClock():DoLightningLighting() GetPlayer().components.playercontroller:ShakeCamera(target, "FULL", 0.7, 0.02, .5, 40) inst.components.combat:DoAreaAttack(target, 8) inst:Remove() end local function onthrown(inst, data) inst.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround ) end inst:AddComponent("weapon") inst.components.weapon:SetDamage(3000) inst.components.weapon:SetRange(15, 18) inst:AddComponent("combat") inst.components.combat:SetDefaultDamage(3000) inst.components.combat.playerdamagepercent = 0 inst:AddComponent("equippable") inst.components.equippable.equipstack = true inst:AddComponent("projectile") inst.components.projectile:SetSpeed(60) inst.components.projectile:SetOnHitFn(onhit) inst:ListenForEvent("onthrown", onthrown) 即可在装备犬牙时,对一群敌人扔出(远距离对敌人按鼠标左键)炸倒一大片。犬牙手雷不会伤到主角

2025/04/23 · Bny

YN164-高爆地雷(指南针放在地上作地雷)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一六四.高爆地雷(指南针放在地上作地雷) 用MT管理器打开游戏目录/assets/scripts/prefabs/compass.lua文件,在inst:AddComponent("inventoryitem")的下一行插入以下内容 inst.components.inventoryitem:SetOnDroppedFn(function() inst:RemoveTag("startkill") if inst.task then inst.task:Cancel() inst.task = nil end end ) inst.components.inventoryitem:SetOnPickupFn(function() inst:RemoveTag("startkill") if inst.task then inst.task:Cancel() inst.task = nil end end ) inst.components.inventoryitem:SetOnPutInInventoryFn(function() inst:RemoveTag("startkill") if inst.task then inst.task:Cancel() inst.task = nil end end ) local function OnDeploy (inst, pt) inst:AddTag("startkill") inst.Physics:Teleport(pt:Get()) inst.task = inst:DoPeriodicTask(0.1, function(inst) local target = FindEntity(inst, 2, function(guy) return guy.components.combat and guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("player") and not guy:HasTag("smallbird") and not guy:HasTag("chester") end ) if target then GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) SpawnPrefab("explode_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) local pos = Vector3(inst.Transform:GetWorldPosition()) GetClock():DoLightningLighting() GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.7, 0.02, .5, 40) target.components.health:DoDelta(-3000) inst:Remove() end end ) end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy inst.components.deployable.min_spacing = 2 inst:AddComponent("stackable") inst.components.stackable.maxsize = 999 local function onsave(inst, data) if inst:HasTag("startkill") then data.startkill = true end end local function onload(inst, data) if data and data.startkill then inst:AddTag("startkill") inst.task = inst:DoPeriodicTask(0.1, function(inst) local target = FindEntity(inst, 2, function(guy) return guy.components.combat and guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("player") and not guy:HasTag("smallbird") and not guy:HasTag("chester") end ) if target then GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) SpawnPrefab("explode_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) local pos = Vector3(inst.Transform:GetWorldPosition()) GetClock():DoLightningLighting() GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.7, 0.02, .5, 40) target.components.health:DoDelta(-3000) inst:Remove() end end ) end end inst.OnSave = onsave inst.OnLoad = onload 即可拿起指南针用鼠标右键部署在空地上,敌人踩上后会爆炸,主角、自养高鸟、狗箱不会触发。指南针在生存选项(画着绳套)下,用1个黄金、1张纸制造

2025/04/23 · Bny

YN165-死神之光(拿提灯时右键点空地,满屏敌人通杀)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一六五.死神之光(拿提灯时右键点空地,满屏敌人通杀) 用MT管理器打开游戏目录/assets/scripts/prefabs/mininglantern.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function cancreatelight(staff, caster, target, pos) local fuelpercent = inst.components.fueled:GetPercent() if fuelpercent > 0.5 then return true else return false end end local function createlight(staff, target, pos) local SHAKE_DIST = 40 local player = GetClosestInstWithTag("player", inst, SHAKE_DIST) if player then player.components.playercontroller:ShakeCamera(inst, "VERTICAL", 1, 0.03, 2, SHAKE_DIST) end inst:DoTaskInTime(0, function() inst.components.combat:DoAreaAttack(inst, 30) end) GetClock():DoLightningLighting() inst.components.fueled.currentfuel = 50 end inst:AddComponent("spellcaster") inst.components.spellcaster:SetSpellFn(createlight) inst.components.spellcaster:SetSpellTestFn(cancreatelight) inst.components.spellcaster.canuseonpoint = true inst.components.spellcaster.canusefrominventory = false inst:AddComponent("combat") inst.components.combat:SetDefaultDamage(3000) inst.components.combat.playerdamagepercent = 0 即可拿提灯时右键点空地,满屏敌人通杀。注意提灯燃料超过50%时,才能释放死神之光,释放后提灯燃料接近耗尽,想再释放需要向提灯中填充荧光果(拿荧光果对装备格中的提灯按右键),大约3颗即可

2025/04/23 · Bny

YN166-魔之双臂(狼牙棒左键抓来敌人并致死、右键抓地移动主角)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一六六.魔之双臂(狼牙棒左键抓来敌人并致死、右键抓地移动主角) 用MT管理器打开游戏目录/assets/scripts/prefabs/tentaclespike.lua文件,将下列内容: inst:AddComponent("weapon") inst.components.weapon:SetDamage(TUNING.SPIKE_DAMAGE) ------- inst:AddComponent("finiteuses") inst.components.finiteuses:SetMaxUses(TUNING.SPIKE_USES) inst.components.finiteuses:SetUses(TUNING.SPIKE_USES) inst.components.finiteuses:SetOnFinished( onfinished ) 替换为: local function onattack(inst, owner, target) local pt = owner:GetPosition() if target.components.health then target.Transform:SetPosition(pt.x+1, pt.y, pt.z) end inst:DoTaskInTime(0.1, function() target.components.health:DoDelta(-3000) end) end inst:AddComponent("weapon") inst.components.weapon:SetDamage(0) inst.components.weapon:SetRange(20, 25) inst.components.weapon:SetOnAttack(onattack) inst.components.weapon:SetProjectile("bishop_charge") inst:AddComponent("blinkstaff") 即可在装备狼牙棒时,对敌人点左键将其抓过来并致死;对空地点右键,抓地移动主角,使狼牙棒既可杀伤敌人,又可有效闪避。用来抓鸟、兔、火鸡、大象等会逃跑的动物也很实用哦。狼牙棒靠打沼泽里的触手获得

2025/04/23 · Bny

YN167-致命的毒箭(中吹箭的敌人不知不觉流血至死)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一六七.致命的毒箭(中吹箭的敌人不知不觉流血至死) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/blowdart.lua文件,在inst.components.weapon:SetDamage(TUNING.PIPE_DART_DAMAGE)的下一行插入以下内容: local function pipeonhit(inst, attacker, target) target.components.health:StartRegen(-100, 1) target.components.combat.target = nil target.AnimState:SetMultColour(255/255,0/255,0/255,1) attacker.components.inventory:Equip(inst) end inst.components.weapon:SetRange(20, 25) inst.components.projectile:SetOnHitFn(pipeonhit) 即可让中吹箭的敌人变成红色,每秒减100点血直至死亡,被射中的敌人不会反击主角。吹箭为无限使用,吹出后自动回到手中

2025/04/23 · Bny

YN168-电击枪(用橙色魔杖远程电晕敌人,使其任你宰割)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一六八.电击枪(用橙色魔杖远程电晕敌人,使其任你宰割) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/staff.lua文件,将inst.components.blinkstaff.onblinkfn = onblink替换为以下内容: local function onattack_orange(inst, owner, target) if target.brain then target.brain:Stop() end if target.components.combat then target.components.combat:SetTarget(nil) end if target.components.locomotor then target.components.locomotor:Stop() end target.AnimState:SetMultColour(125/255,125/255,125/255,1) SpawnPrefab("lightning_rod_fx").Transform:SetPosition(target.Transform:GetWorldPosition()) end inst:AddComponent("weapon") inst.components.weapon:SetDamage(10) inst.components.weapon:SetRange(20, 25) inst.components.weapon:SetOnAttack(onattack_orange) inst.components.weapon:SetProjectile("bishop_charge") 即可在装备橙色魔杖时,对敌人按鼠标左键将其电晕,其会失去行动能力,任你处置。对猴子、青蛙等比较讨厌的敌人很适用。橙色魔杖在远古选项(画着远古祭坛)下,用2个噩梦燃料、1个步行手杖、2个橙色宝石制造,制造时需要靠近远古祭坛

2025/04/23 · Bny

YN169-速射步枪(黄色魔杖左键点射、右键连射蜂刺子弹)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一六九.速射步枪(黄色魔杖左键点射、右键连射蜂刺子弹) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/staff.lua文件,将下列内容: local function yellow() local inst = commonfn("yellow") inst.fxcolour = {223/255, 208/255, 69/255} inst.castsound = "dontstarve/common/staffteleport" inst:AddComponent("spellcaster") inst.components.spellcaster:SetSpellFn(createlight) inst.components.spellcaster:SetSpellTestFn(cancreatelight) inst.components.spellcaster.canuseonpoint = true inst.components.spellcaster.canusefrominventory = false inst:AddComponent("reticule") inst.components.reticule.targetfn = function() return Vector3(GetPlayer().entity:LocalToWorldSpace(5,0,0)) end inst.components.reticule.ease = true inst.components.finiteuses:SetMaxUses(TUNING.YELLOWSTAFF_USES) inst.components.finiteuses:SetUses(TUNING.YELLOWSTAFF_USES) inst:AddTag("nopunch") return inst end 替换为: local function yellow() local inst = commonfn("yellow") inst.fxcolour = {223/255, 208/255, 69/255} inst.castsound = "dontstarve/common/staffteleport" local function canattack(inst, target) if GetPlayer().components.inventory:Has("stinger", 1) and TheInput:IsMouseDown(MOUSEBUTTON_RIGHT) then inst.components.weapon:LaunchProjectile(inst, target) end if GetPlayer().components.inventory:Has("stinger", 1) then return true end end local function onattack_yellow(inst, owner, target) owner.SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") SpawnPrefab("die_fx").Transform:SetPosition(target.Transform:GetWorldPosition()) TheCamera:Shake("FULL", 0.2, 0.02, .5, 40) owner.components.inventory:ConsumeByName("stinger", 1) end inst:AddComponent("weapon") inst.components.weapon:SetDamage(100) inst.components.weapon:SetRange(25, 30) inst.components.weapon:SetOnAttack(onattack_yellow) inst.components.weapon:SetCanAttack(canattack) inst.components.weapon:SetProjectile("fire_projectile") inst.components.finiteuses:SetMaxUses(TUNING.YELLOWSTAFF_USES*1000) inst.components.finiteuses:SetUses(TUNING.YELLOWSTAFF_USES*1000) return inst end 即可在装备黄色魔杖时,对敌人按鼠标左键点射,按鼠标右键连射,身上没有蜂刺时无法射击(不要光顾着按住右键扫射,时不时关注一下还有多少子弹)。黄色魔杖在远古选项(画着远古祭坛)下,用4个噩梦燃料、2个活木头、2个黄色宝石制造,制造时需要靠近远古祭坛。黄色魔杖原有种小星星功能取消

2025/04/23 · Bny

YN170-反物质制造机(绿魔杖左键点敌人,生成敌人反物质分身自相残杀)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一七0.反物质制造机(绿魔杖左键点敌人,生成敌人反物质分身自相残杀) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/staff.lua文件,在local inst = commonfn("green")的下一行插入以下内容: local function onattack_green(inst, owner, target) if target.prefab == "bee" or target.prefab == "killerbee" or target.prefab == "flies" or target.prefab == "mosquito" or target.prefab == "frog" or target.prefab == "beefalo" or target.prefab == "lightninggoat" or target.prefab == "pigman" or target.prefab == "pigguard" or target.prefab == "bunnyman" or target.prefab == "merm" or target.prefab == "spider_hider" or target.prefab == "spider_spitter" or target.prefab == "spider" or target.prefab == "spider_warrior" or target.prefab == "spiderqueen" or target.prefab == "spider_dropper" or target.prefab == "hound" or target.prefab == "firehound" or target.prefab == "icehound" or target.prefab == "leif" or target.prefab == "leif_sparse" or target.prefab == "walrus" or target.prefab == "little_walrus" or target.prefab == "smallbird" or target.prefab == "teenbird" or target.prefab == "tallbird" or target.prefab == "koalefant_summer" or target.prefab == "koalefant_winter" or target.prefab == "penguin" or target.prefab == "slurtle" or target.prefab == "snurtle" or target.prefab == "bat" or target.prefab == "rocky" or target.prefab == "monkey" or target.prefab == "buzzard" or target.prefab == "catcoon" or target.prefab == "knight" or target.prefab == "bishop" or target.prefab == "rook" or target.prefab == "crawlinghorror" or target.prefab == "terrorbeak" or target.prefab == "deerclops" or target.prefab == "minotaur" or target.prefab == "worm" or target.prefab == "abigail" or target.prefab == "ghost" or target.prefab == "krampus" or target.prefab == "moose" or target.prefab == "dragonfly" or target.prefab == "warg" or target.prefab == "bearger" then local copy = SpawnPrefab(target.prefab) copy.Transform:SetPosition(target.Transform:GetWorldPosition()) copy.AnimState:SetMultColour(0/255,0/255,0/255,0.5) if copy:HasTag("monster") then copy:RemoveTag("monster") end copy.task = copy:DoPeriodicTask(1, function() copy.components.combat.target = target end) target:ListenForEvent("death", function() if not copy.components.health:IsDead() then copy:Remove() end end ) copy:DoTaskInTime(60, function() if not copy.components.health:IsDead() then copy:Remove() end end ) else local copy = SpawnPrefab("leif") copy.Transform:SetPosition(target.Transform:GetWorldPosition()) copy.AnimState:SetMultColour(0/255,0/255,0/255,0.5) copy.Transform:SetScale(0.5, 0.5, 0.5) copy:RemoveTag("monster") copy.components.combat:SetAttackPeriod(1) copy.task = copy:DoPeriodicTask(1, function() copy.components.combat.target = target end) target:ListenForEvent("death", function() if not copy.components.health:IsDead() then copy:Remove() end end ) copy:DoTaskInTime(60, function() if not copy.components.health:IsDead() then copy:Remove() end end ) end end inst:AddComponent("weapon") inst.components.weapon:SetDamage(0) inst.components.weapon:SetRange(30, 35) inst.components.weapon:SetOnAttack(onattack_green) inst.components.weapon:SetProjectile("bishop_charge") 即可装备绿魔杖时,按鼠标左键点敌人,生成敌人的反物质分身,与敌人自相残杀。敌人有多强大,其反物质分身就有多强大,主角只须观战即可。反物质分身最多存在60秒,当敌人死去时,反物质分身也将消失。中立的小动物、修改技巧创生的生物,将生成反物质树精

2025/04/23 · Bny

YN171-收妖镜(装备铥矿奖章对敌人按右键,将其收入镜中)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一七一.收妖镜(装备铥矿奖章对敌人按右键,将其收入镜中) 用MT管理器打开游戏目录/assets/scripts/prefabs/nightmare_timepiece.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function onequip(inst, owner) owner.components.inventory:SetOverflow(inst) inst.components.container:Open(owner) end local function onunequip(inst, owner) owner.components.inventory:SetOverflow(nil) inst.components.container:Close(owner) end local function itemtest(inst, item, slot) if item:HasTag("catched") then return true end return false end local slotpos = {} for y = 0, 9 do table.insert(slotpos, Vector3(-162, -y*75 + 170 ,0)) end local function cancatchmonster(inst, caster, target) if target then return target.components.locomotor and target.components.health and not target.components.health:IsDead() and not target:HasTag("smallbird") and not target:HasTag("chester") end return true end local function catchmonster(staff, target, pos) if not inst.components.container:IsFull() then if target.components.stackable then target:RemoveComponent("stackable") end if target.components.inventoryitem then target:RemoveComponent("inventoryitem") end target:AddComponent("inventoryitem") target.components.inventoryitem.nobounce = true target.components.inventoryitem.canbepickedup = true target.components.inventoryitem:ChangeImageName("beard_monster") target.components.health.canmurder = true target:AddTag("catched") target.components.inventoryitem:SetOnDroppedFn(function(target) target:RemoveComponent("inventoryitem") target:RemoveTag("catched") if target.brain then target.brain:Start() end if target.sg then target.sg:Start() end end ) target.components.inventoryitem:SetOnPutInInventoryFn(function(target) if target.sg then target.sg:GoToState("idle") end if target.SoundEmitter then target.SoundEmitter:KillAllSounds() end end ) inst.components.container:GiveItem(target) end end inst:AddComponent("spellcaster") inst.components.spellcaster:SetSpellFn(catchmonster) inst.components.spellcaster:SetSpellTestFn(cancatchmonster) inst.components.spellcaster.canuseontargets = true inst.components.spellcaster.canusefrominventory = false inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.HANDS inst.components.equippable:SetOnEquip( onequip ) inst.components.equippable:SetOnUnequip( onunequip ) inst:AddComponent("container") inst.components.container:SetNumSlots(#slotpos) inst.components.container.widgetslotpos = slotpos inst.components.container.widgetpos = Vector3(18,50,0) inst.components.container.side_widget = true inst.components.container.itemtestfn = itemtest inst.components.container.acceptsstacks = false 即可在装备铥矿奖章时,对敌人按鼠标右键,将敌人收入镜中(画面右边的格子中,显示为烧焦的兔子),如果想杀死它,就对格子中的敌人按鼠标右键,会获得战利品;如果想释放它,就拿出敌人放在地上。“收妖镜”的格子全满后,无法再收新的敌人,可以将敌人放在物品栏或其他背包后再收妖。在存档退出前,请处置(杀掉或释放)全部收来的敌人,否则读档后,敌人将全部被放出。铥矿奖章在远古选项(画着远古祭坛)下,用2个铥矿石、2个噩梦燃料制造,制造时需要靠近远古祭坛

2025/04/23 · Bny