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

YN160-神之矛(矛攻击时召唤闪电雷击敌人)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一六0.神之矛(矛攻击时召唤闪电雷击敌人) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/spear.lua文件, 5 6 1.在local function onequip(inst, owner)的下一行插入以下内容: 7 8 if owner.components.playerlightningtarget then 9 owner:AddTag("nolightning") 10 owner:RemoveComponent("playerlightningtarget") 11 end 12 13 14 2.在local function onunequip(inst, owner)的下一行插入以下内容: 15 16 if owner:HasTag("nolightning") then 17 owner:RemoveTag("nolightning") 18 owner:AddComponent("playerlightningtarget") 19 end 20 21 22 3.将inst:AddComponent("weapon")替换为以下内容: 23 24local function onattack(inst, attacker, target) 25 inst:StartThread(function() 26 for k = 1, 5 do 27 local pos = target:GetPosition() 28 GetSeasonManager():DoLightningStrike(pos) 29 target.components.health:DoDelta(-100) 30 Sleep(0.3) 31 end 32 end) 33end 34 inst:AddComponent("weapon") 35 inst.components.weapon:SetRange(20, 25) 36 inst.components.weapon:SetOnAttack(onattack) 37 inst.components.weapon:SetProjectile("bishop_charge") 38 39 即可让矛在攻击时召唤5道闪电,连续雷击敌人,会烧着附近的敌人。因为神之矛太过凶猛,请远离自己的基地使用,也千万不要在带同伴时使用

2025/04/23 · Bny

YN161-钓金龟(用鱼竿将敌人变成黄金雕像)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一六一.钓金龟(用鱼竿将敌人变成黄金雕像) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/fishingrod.lua文件,将下列内容: 5 6 inst:AddComponent("weapon") 7 inst.components.weapon:SetDamage(TUNING.FISHINGROD_DAMAGE) 8 inst.components.weapon.attackwear = 4 9 10 替换为: 11 12local function onattack(inst, attacker, target) 13 SpawnPrefab("ruins_statue_mage").Transform:SetPosition(target.Transform:GetWorldPosition()) 14 SpawnPrefab("collapse_small").Transform:SetPosition(target.Transform:GetWorldPosition()) 15 target:Remove() 16end 17 inst:AddComponent("weapon") 18 inst.components.weapon:SetDamage(0) 19 inst.components.weapon:SetRange(12, 15) 20 inst.components.weapon:SetOnAttack(onattack) 21 inst.components.weapon:SetProjectile("bishop_charge") 22 23 即可用鱼竿远距离攻击敌人时,把敌人变成黄金雕像,用锤子砸碎雕像可得宝石和铥矿石。鱼竿在生存选项(画着绳套)下,用2个树杈、2个蛛丝制造

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一六四.高爆地雷(指南针放在地上作地雷) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/compass.lua文件,在inst:AddComponent("inventoryitem")的下一行插入以下内容 5 6 inst.components.inventoryitem:SetOnDroppedFn(function() 7 inst:RemoveTag("startkill") 8 if inst.task then inst.task:Cancel() inst.task = nil end 9 end ) 10 inst.components.inventoryitem:SetOnPickupFn(function() 11 inst:RemoveTag("startkill") 12 if inst.task then inst.task:Cancel() inst.task = nil end 13 end ) 14 inst.components.inventoryitem:SetOnPutInInventoryFn(function() 15 inst:RemoveTag("startkill") 16 if inst.task then inst.task:Cancel() inst.task = nil end 17 end ) 18local function OnDeploy (inst, pt) 19 inst:AddTag("startkill") 20 inst.Physics:Teleport(pt:Get()) 21 inst.task = inst:DoPeriodicTask(0.1, function(inst) 22 local target = FindEntity(inst, 2, function(guy) 23 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") 24 end ) 25 if target then 26 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 27 SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) 28 SpawnPrefab("explode_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) 29 local pos = Vector3(inst.Transform:GetWorldPosition()) 30 GetClock():DoLightningLighting() 31 GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.7, 0.02, .5, 40) 32 target.components.health:DoDelta(-3000) 33 inst:Remove() 34 end 35 end ) 36end 37 inst:AddComponent("deployable") 38 inst.components.deployable.ondeploy = OnDeploy 39 inst.components.deployable.min_spacing = 2 40 inst:AddComponent("stackable") 41 inst.components.stackable.maxsize = 999 42local function onsave(inst, data) 43 if inst:HasTag("startkill") then 44 data.startkill = true 45 end 46end 47local function onload(inst, data) 48 if data and data.startkill then 49 inst:AddTag("startkill") 50 inst.task = inst:DoPeriodicTask(0.1, function(inst) 51 local target = FindEntity(inst, 2, function(guy) 52 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") 53 end ) 54 if target then 55 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 56 SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) 57 SpawnPrefab("explode_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) 58 local pos = Vector3(inst.Transform:GetWorldPosition()) 59 GetClock():DoLightningLighting() 60 GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.7, 0.02, .5, 40) 61 target.components.health:DoDelta(-3000) 62 inst:Remove() 63 end 64 end ) 65 end 66end 67 inst.OnSave = onsave 68 inst.OnLoad = onload 69 70 即可拿起指南针用鼠标右键部署在空地上,敌人踩上后会爆炸,主角、自养高鸟、狗箱不会触发。指南针在生存选项(画着绳套)下,用1个黄金、1张纸制造

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

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

2025/04/23 · Bny