模组文件免费下载和使用,谨防上当受骗。

YN196-口袋浣熊(用纸种口袋浣熊,捕猎、战斗好帮手,喂鱼变身超级浣熊)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一九六.口袋浣熊(用纸种口袋浣熊,捕猎、战斗好帮手,喂鱼变身超级浣熊) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/papyrus.lua文件,在inst:AddComponent("inventoryitem")的下一行插入以下内容: local function OnDeploy (inst, pt) local coon = SpawnPrefab("papyrus") coon.Transform:SetPosition(pt.x, pt.y, pt.z) coon.AnimState:SetBank("catcoon") coon.AnimState:SetBuild("catcoon_build") coon.AnimState:PlayAnimation("idle_loop") coon.Transform:SetFourFaced() coon.Transform:SetScale(0.8, 0.8, 0.8) coon.entity:AddSoundEmitter() local shadow = coon.entity:AddDynamicShadow() shadow:SetSize(2,0.75) coon:RemoveComponent("stackable") coon:RemoveComponent("fuel") coon:RemoveComponent("tradable") coon:RemoveComponent("burnable") coon:RemoveComponent("propagator") coon:RemoveComponent("deployable") coon:RemoveTag("cattoy") coon.components.inventoryitem:ChangeImageName("catcoonhat") coon:AddComponent("named") coon.components.named:SetName("Catcoon") coon:AddComponent("follower") coon.components.follower:SetLeader(GetPlayer()) coon:AddComponent("locomotor") coon.components.locomotor.walkspeed = 12 coon:SetStateGraph("SGcatcoon") local brain = require "brains/abigailbrain" coon:SetBrain(brain) coon:AddComponent("health") coon.components.health:SetMaxHealth(3000) coon:AddComponent("lootdropper") coon.components.lootdropper:SetLoot({"smallmeat"}) coon:AddComponent("combat") coon.components.combat:SetDefaultDamage(50) coon.components.combat:SetRange(4) coon.components.combat:SetAttackPeriod(0.5) coon.components.combat:SetHurtSound("dontstarve_DLC001/creatures/catcoon/hurt") coon.components.combat.battlecryinterval = 20 coon.components.combat:SetRetargetFunction(1, function(coon) if not coon.components.health:IsDead() then return FindEntity(GetPlayer(), 20, function(guy) if guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") or guy:HasTag("smallcreature") end end) end end ) coon.components.combat:SetKeepTargetFunction(function(coon, target) return target and target:IsValid() end ) coon:ListenForEvent("attacked", function(coon, data) if data.attacker ~= GetPlayer() then coon.components.combat:SetTarget(data.attacker) else coon.components.health:Kill() end end ) coon:AddComponent( "playerprox" ) coon.components.playerprox:SetDist(3,5) coon.components.playerprox:SetOnPlayerNear(function(coon) coon.components.locomotor.walkspeed = 5 end ) coon.components.playerprox:SetOnPlayerFar(function(coon) coon.components.locomotor.walkspeed = 12 end ) coon:AddComponent("trader") coon.components.trader:SetAcceptTest(function(coon, item) if not coon:HasTag("supercoon") then if item.prefab == "fish" then return true end if item.prefab == "smallmeat" then return coon.components.health:GetPercent() < 1 end end return false end ) coon.components.trader.onaccept = function(coon, giver, item) if item.prefab == "fish" then coon:AddTag("supercoon") coon.components.named:SetName("SuperCatcoon") SpawnPrefab("collapse_big").Transform:SetPosition(coon.Transform:GetWorldPosition()) coon.AnimState:SetBloomEffectHandle("shaders/anim.ksh") coon.Transform:SetScale(1.3, 1.3, 1.3) coon.components.inventoryitem.canbepickedup = false coon.components.health:SetInvincible(true) coon.components.combat:SetDefaultDamage(500) coon:DoTaskInTime(60, function(coon) coon:RemoveTag("supercoon") coon.components.named:SetName("Catcoon") SpawnPrefab("collapse_big").Transform:SetPosition(coon.Transform:GetWorldPosition()) coon.AnimState:SetBloomEffectHandle("") coon.Transform:SetScale(0.8, 0.8, 0.8) coon.components.inventoryitem.canbepickedup = true coon.components.health:SetInvincible(false) coon.components.combat:SetDefaultDamage(50) end ) end if item.prefab == "smallmeat" then coon.components.health:DoDelta(1000) end end coon:AddTag("coons") inst.components.stackable:Get():Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("coons") then data.coons = true end end local function onload(inst, data) if data and data.coons then inst.AnimState:SetBank("catcoon") inst.AnimState:SetBuild("catcoon_build") inst.AnimState:PlayAnimation("idle_loop") inst.Transform:SetFourFaced() inst.Transform:SetScale(0.8, 0.8, 0.8) inst.entity:AddSoundEmitter() local shadow = inst.entity:AddDynamicShadow() shadow:SetSize(2,0.75) inst:RemoveComponent("stackable") inst:RemoveComponent("fuel") inst:RemoveComponent("tradable") inst:RemoveComponent("burnable") inst:RemoveComponent("propagator") inst:RemoveComponent("deployable") inst:RemoveTag("cattoy") inst.components.inventoryitem:ChangeImageName("catcoonhat") inst:AddComponent("named") inst.components.named:SetName("Catcoon") inst:AddComponent("follower") inst.components.follower:SetLeader(GetPlayer()) inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 12 inst:SetStateGraph("SGcatcoon") local brain = require "brains/abigailbrain" inst:SetBrain(brain) inst:AddComponent("health") inst.components.health:SetMaxHealth(3000) inst:AddComponent("lootdropper") inst.components.lootdropper:SetLoot({"smallmeat"}) inst:AddComponent("combat") inst.components.combat:SetDefaultDamage(50) inst.components.combat:SetRange(4) inst.components.combat:SetAttackPeriod(0.5) inst.components.combat:SetHurtSound("dontstarve_DLC001/creatures/catcoon/hurt") inst.components.combat.battlecryinterval = 20 inst.components.combat:SetRetargetFunction(1, function(inst) if not inst.components.health:IsDead() then return FindEntity(GetPlayer(), 20, function(guy) if guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") or guy:HasTag("smallcreature") end end) end end ) inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) inst:ListenForEvent("attacked", function(inst, data) if data.attacker ~= GetPlayer() then inst.components.combat:SetTarget(data.attacker) else inst.components.health:Kill() end end ) inst:AddComponent( "playerprox" ) inst.components.playerprox:SetDist(3,5) inst.components.playerprox:SetOnPlayerNear(function(inst) inst.components.locomotor.walkspeed = 5 end ) inst.components.playerprox:SetOnPlayerFar(function(inst) inst.components.locomotor.walkspeed = 12 end ) inst:AddComponent("trader") inst.components.trader:SetAcceptTest(function(inst, item) if not inst:HasTag("supercoon") then if item.prefab == "fish" then return true end if item.prefab == "smallmeat" then return inst.components.health:GetPercent() < 1 end end return false end ) inst.components.trader.onaccept = function(inst, giver, item) if item.prefab == "fish" then inst:AddTag("supercoon") inst.components.named:SetName("SuperCatcoon") SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") inst.Transform:SetScale(1.3, 1.3, 1.3) inst.components.inventoryitem.canbepickedup = false inst.components.health:SetInvincible(true) inst.components.combat:SetDefaultDamage(500) inst:DoTaskInTime(60, function(inst) inst:RemoveTag("supercoon") inst.components.named:SetName("Catcoon") SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst.AnimState:SetBloomEffectHandle("") inst.Transform:SetScale(0.8, 0.8, 0.8) inst.components.inventoryitem.canbepickedup = true inst.components.health:SetInvincible(false) inst.components.combat:SetDefaultDamage(50) end ) end if item.prefab == "smallmeat" then inst.components.health:DoDelta(1000) end end inst:AddTag("coons") end end inst.OnSave = onsave inst.OnLoad = onload 即可用纸种口袋浣熊,帮你捕猎、战斗。鼠标左键点浣熊,可将其放入物品栏(显示为浣熊帽的图标)。喂浣熊小肉,可为其补血(3块可补满),如果喂浣熊鱼,则变身超级浣熊,不会受伤,攻击力提高10倍,60秒后变回来。在超级浣熊状态下,口袋浣熊无法被拿起,也不接受食物。不想要口袋浣熊了,在物品栏中对其按鼠标右键即可。纸在精炼选项(画着白色宝石)下,用4个芦苇制造

2025/04/23 · Bny

YN197-吸地牛(用大理石种吸地牛,地面物品自动吸入肚中,可开矿、砍树)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一九七.吸地牛(用大理石种吸地牛,地面物品自动吸入肚中,可开矿、砍树) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/inv_marble.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local slotpos = {} for y = 4, 0, -1 do for x = 0, 14 do table.insert(slotpos, Vector3(75*x-75*2+75, 75*y-75*2+75,0)) end end local sounds = { walk = "dontstarve/beefalo/walk", grunt = "dontstarve/beefalo/grunt", yell = "dontstarve/beefalo/yell", swish = "dontstarve/beefalo/tail_swish", curious = "dontstarve/beefalo/curious", angry = "dontstarve/beefalo/angry", } local function OnDeploy (inst, pt) local bull = SpawnPrefab("marble") bull.Transform:SetPosition(pt.x, pt.y, pt.z) bull.AnimState:SetBank("beefalo") bull.AnimState:SetBuild("beefalo_build") bull.AnimState:PlayAnimation("idle_loop", true) bull.Transform:SetFourFaced() bull.Transform:SetScale(0.8, 0.8, 0.8) local sound = bull.entity:AddSoundEmitter() bull.sounds = sounds local shadow = bull.entity:AddDynamicShadow() shadow:SetSize( 3, 1.25 ) MakeCharacterPhysics(bull, 100, 1.5) bull:AddTag("bull") bull:AddTag("companion") bull:AddComponent("locomotor") bull.components.locomotor.walkspeed = 1.5 bull.components.locomotor.runspeed = 15 bull:SetStateGraph("SGBeefalo") bull:AddComponent("follower") bull:AddComponent("knownlocations") bull.components.container.canbeopened = true bull:AddComponent("combat") bull:AddComponent("health") bull.components.health:SetMaxHealth(10000) bull.components.health:SetInvincible(true) bull.components.health.nofadeout = true bull:RemoveComponent("stackable") bull:RemoveComponent("inventoryitem") bull:RemoveComponent("bait") bull:RemoveTag("molebait") bull:AddComponent("workable") bull.components.workable:SetWorkAction(ACTIONS.CHOP) bull.components.workable:SetWorkLeft(3) bull.components.workable:SetOnFinishCallback(function(bull) bull.AnimState:PlayAnimation("death") bull.SoundEmitter:PlaySound("dontstarve/beefalo/yell") bull:DoTaskInTime(1.5, function() bull.components.container:DropEverything() bull:Remove() end) end ) bull:DoPeriodicTask(1, function(bull) if not bull.components.container:Has("cutgrass", 1) then bull.components.locomotor:Stop() bull:SetBrain(nil) bull.components.follower:SetLeader(nil) bull:RemoveTag("letgo") else local brain = require "brains/chesterbrain" bull:SetBrain(brain) bull:RestartBrain() bull.components.follower:SetLeader(GetPlayer()) bull:AddTag("letgo") end end ) bull:DoPeriodicTask(180, function(bull) if bull.components.container:Has("cutgrass", 1) then bull.components.container:ConsumeByName("cutgrass", 1) bull.AnimState:PlayAnimation("graze_loop") end end ) bull:DoPeriodicTask(.1, function(bull) if bull:HasTag("letgo") then local pos = Vector3(bull.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 15) for k,v in pairs(ents) do local pt1 = v:GetPosition() if v.components.inventoryitem and v.components.inventoryitem.canbepickedup and v.components.inventoryitem.cangoincontainer and not v.components.inventoryitem:IsHeld() and not v:HasTag("trap") and not v:HasTag("light") and not v:HasTag("blowdart") and not v:HasTag("projectile") and not v:HasTag("helpers") then if not bull.components.container:IsFull() then SpawnPrefab("small_puff").Transform:SetPosition(pt1.x, pt1.y, pt1.z) bull.components.container:GiveItem(v) bull.SoundEmitter:PlaySound("dontstarve/HUD/research_available") end end end end end ) bull.Physics:SetCollisionCallback(function(bull, other) if other and other.components.workable and other.components.workable.workleft > 0 and not other:HasTag("bull") then SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get()) other.components.workable:Destroy(bull) end end) inst.components.stackable:Get():Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("bull") then data.bull = true end end local function onload(inst, data) if data and data.bull then inst.AnimState:SetBank("beefalo") inst.AnimState:SetBuild("beefalo_build") inst.AnimState:PlayAnimation("idle_loop", true) inst.Transform:SetFourFaced() inst.Transform:SetScale(0.8, 0.8, 0.8) local sound = inst.entity:AddSoundEmitter() inst.sounds = sounds local shadow = inst.entity:AddDynamicShadow() shadow:SetSize( 3, 1.25 ) MakeCharacterPhysics(inst, 100, 1.5) inst:AddTag("bull") inst:AddTag("companion") inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 1.5 inst.components.locomotor.runspeed = 15 inst:SetStateGraph("SGBeefalo") inst:AddComponent("follower") inst:AddComponent("knownlocations") inst.components.container.canbeopened = true inst:AddComponent("combat") inst:AddComponent("health") inst.components.health:SetMaxHealth(10000) inst.components.health:SetInvincible(true) inst.components.health.nofadeout = true inst:RemoveComponent("stackable") inst:RemoveComponent("inventoryitem") inst:RemoveComponent("bait") inst:RemoveTag("molebait") inst:AddComponent("workable") inst.components.workable:SetWorkAction(ACTIONS.CHOP) inst.components.workable:SetWorkLeft(3) inst.components.workable:SetOnFinishCallback(function(inst) inst.AnimState:PlayAnimation("death") inst.SoundEmitter:PlaySound("dontstarve/beefalo/yell") inst:DoTaskInTime(1.5, function() inst.components.container:DropEverything() inst:Remove() end) end ) inst:DoPeriodicTask(1, function(inst) if not inst.components.container:Has("cutgrass", 1) then inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.follower:SetLeader(nil) inst:RemoveTag("letgo") else local brain = require "brains/chesterbrain" inst:SetBrain(brain) inst:RestartBrain() inst.components.follower:SetLeader(GetPlayer()) inst:AddTag("letgo") end end ) inst:DoPeriodicTask(180, function(inst) if inst.components.container:Has("cutgrass", 1) then inst.components.container:ConsumeByName("cutgrass", 1) inst.AnimState:PlayAnimation("graze_loop") end end ) inst:DoPeriodicTask(.1, function(inst) if inst:HasTag("letgo") then local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 15) for k,v in pairs(ents) do local pt1 = v:GetPosition() if v.components.inventoryitem and v.components.inventoryitem.canbepickedup and v.components.inventoryitem.cangoincontainer and not v.components.inventoryitem:IsHeld() and not v:HasTag("trap") and not v:HasTag("light") and not v:HasTag("blowdart") and not v:HasTag("projectile") and not v:HasTag("helpers") then if not inst.components.container:IsFull() then SpawnPrefab("small_puff").Transform:SetPosition(pt1.x, pt1.y, pt1.z) inst.components.container:GiveItem(v) inst.SoundEmitter:PlaySound("dontstarve/HUD/research_available") end end end end end ) inst.Physics:SetCollisionCallback(function(inst, other) if other and other.components.workable and other.components.workable.workleft > 0 and not other:HasTag("bull") then SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get()) other.components.workable:Destroy(inst) end end) end end inst.OnSave = onsave inst.OnLoad = onload inst:AddComponent("container") inst.components.container:SetNumSlots(#slotpos) inst.components.container.widgetslotpos = slotpos inst.components.container.widgetpos = Vector3(-300,200,0) inst.components.container.side_align_tip = 160 inst.components.container.canbeopened = false inst:AddTag("fridge") 即可用大理石种吸地牛,鼠标左键点它可开启格子,放入草后会跟随你,吸取沿路所有物品(吸进肚中的格子里,鼠标左键点击可拿取)。拿出草后即停止跟随,在原地等待。吸地牛会消化肚中的草,每天消化2-3根,如果格子中的草被吃完了,就不会跟随你,直到再给它草为止。吸地牛可撞碎石头、撞倒树,并将掉落物品直接吸入肚中,带着它去开矿、砍树吧。不要让吸地牛靠近你的建筑物,它会将其撞毁,除非你想用它拆迁。不想要吸地牛时,用斧子砍它三下即可,肚中物品会掉在地上

2025/04/23 · Bny

YN198-找矿蜗牛(用蜗牛龟盔甲种找矿蜗牛,为你勘探新石矿)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一九八.找矿蜗牛(用蜗牛龟盔甲种找矿蜗牛,为你勘探新石矿) 用MT管理器打开游戏目录/assets/scripts/prefabs/armor_snurtleshell.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function OnDeploy (inst, pt) local snail = SpawnPrefab("armorsnurtleshell") snail.Transform:SetPosition(pt.x, pt.y, pt.z) snail.AnimState:SetBank("slurtle") snail.AnimState:SetBuild("slurtle") snail.AnimState:PlayAnimation("idle", true) snail.Transform:SetFourFaced() local sound = snail.entity:AddSoundEmitter() local brain = require "brains/leifbrain" snail:SetBrain(brain) snail:AddComponent("locomotor") snail.components.locomotor.walkspeed = 7 snail:SetStateGraph("SGslurtle") local minimap = snail.entity:AddMiniMapEntity() minimap:SetIcon( "slurtle_den.png" ) snail.components.inventoryitem:ChangeImageName("armorsnurtleshell") snail:RemoveComponent("armor") snail:RemoveComponent("equippable") snail:RemoveComponent("useableitem") snail:RemoveComponent("deployable") snail:RemoveTag("shell") snail:RemoveComponent("inventoryitem") snail:AddComponent("combat") snail:AddComponent("health") snail.components.health:SetMaxHealth(1000) snail.components.health:SetInvincible(true) snail.components.health.nofadeout = true snail.task = snail:DoPeriodicTask(math.random(8,12), function(snail) local pt1 = snail:GetPosition() local rocks = {"rock1","rock2","rock_flintless","rock_ice"} local rock = rocks[math.random(#rocks)] local newrock = SpawnPrefab(rock) newrock.Transform:SetPosition(pt1.x, 0, pt1.z) newrock.Physics:SetActive(false) newrock:DoTaskInTime(3, function(newrock) newrock.Physics:SetActive(true) end ) SpawnPrefab("splash_ocean").Transform:SetPosition(pt1.x, 0, pt1.z) snail.SoundEmitter:PlaySound("dontstarve/wilson/rock_break") GetPlayer().components.playercontroller:ShakeCamera(snail, "FULL", 0.2, 0.02, .25, 40) end ) snail:AddComponent("inventoryitem") snail.components.inventoryitem:SetOnPutInInventoryFn(function(snail) snail:RemoveTag("sports") snail.components.locomotor:Stop() snail:SetBrain(nil) if snail.task then snail.task:Cancel() snail.task = nil end end ) snail.components.inventoryitem:SetOnDroppedFn(function(snail) snail:AddTag("sports") local brain = require "brains/leifbrain" snail:SetBrain(brain) snail:RestartBrain() snail.task = snail:DoPeriodicTask(math.random(8,12), function(snail) local pt1 = snail:GetPosition() local rocks = {"rock1","rock2","rock_flintless","rock_ice"} local rock = rocks[math.random(#rocks)] local newrock = SpawnPrefab(rock) newrock.Transform:SetPosition(pt1.x, 0, pt1.z) newrock.Physics:SetActive(false) newrock:DoTaskInTime(3, function(newrock) newrock.Physics:SetActive(true) end ) SpawnPrefab("splash_ocean").Transform:SetPosition(pt1.x, 0, pt1.z) snail.SoundEmitter:PlaySound("dontstarve/wilson/rock_break") GetPlayer().components.playercontroller:ShakeCamera(snail, "FULL", 0.2, 0.02, .25, 40) end ) end ) snail:AddTag("sports") snail:AddTag("companion") snail:AddTag("snails") inst:Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("snails") then data.snails = true end if inst:HasTag("sports") then data.sports = true end end local function onload(inst, data) if data and data.snails then inst.AnimState:SetBank("slurtle") inst.AnimState:SetBuild("slurtle") inst.AnimState:PlayAnimation("idle", true) inst.Transform:SetFourFaced() local sound = inst.entity:AddSoundEmitter() inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 7 inst:SetStateGraph("SGslurtle") local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon( "slurtle_den.png" ) inst.components.inventoryitem:ChangeImageName("armorsnurtleshell") inst:RemoveComponent("armor") inst:RemoveComponent("equippable") inst:RemoveComponent("useableitem") inst:RemoveComponent("deployable") inst:RemoveTag("shell") inst:RemoveComponent("inventoryitem") inst:AddComponent("combat") inst:AddComponent("health") inst.components.health:SetMaxHealth(1000) inst.components.health:SetInvincible(true) inst.components.health.nofadeout = true inst:AddComponent("inventoryitem") inst.components.inventoryitem:SetOnPutInInventoryFn(function(inst) inst:RemoveTag("sports") inst.components.locomotor:Stop() inst:SetBrain(nil) if inst.task then inst.task:Cancel() inst.task = nil end end ) inst.components.inventoryitem:SetOnDroppedFn(function(inst) inst:AddTag("sports") local brain = require "brains/leifbrain" inst:SetBrain(brain) inst:RestartBrain() inst.task = inst:DoPeriodicTask(math.random(8,12), function(inst) local pt1 = inst:GetPosition() local rocks = {"rock1","rock2","rock_flintless","rock_ice"} local rock = rocks[math.random(#rocks)] local newrock = SpawnPrefab(rock) newrock.Transform:SetPosition(pt1.x, 0, pt1.z) newrock.Physics:SetActive(false) newrock:DoTaskInTime(3, function(newrock) newrock.Physics:SetActive(true) end ) SpawnPrefab("splash_ocean").Transform:SetPosition(pt1.x, 0, pt1.z) inst.SoundEmitter:PlaySound("dontstarve/wilson/rock_break") GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) end ) end ) inst:AddTag("companion") inst:AddTag("snails") end if data and data.sports then local brain = require "brains/leifbrain" inst:SetBrain(brain) inst:RestartBrain() inst.task = inst:DoPeriodicTask(math.random(8,12), function(inst) local pt1 = inst:GetPosition() local rocks = {"rock1","rock2","rock_flintless","rock_ice"} local rock = rocks[math.random(#rocks)] local newrock = SpawnPrefab(rock) newrock.Transform:SetPosition(pt1.x, 0, pt1.z) newrock.Physics:SetActive(false) newrock:DoTaskInTime(3, function(newrock) newrock.Physics:SetActive(true) end ) SpawnPrefab("splash_ocean").Transform:SetPosition(pt1.x, 0, pt1.z) inst.SoundEmitter:PlaySound("dontstarve/wilson/rock_break") GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) end ) inst:AddTag("sports") local pt2 = GetPlayer():GetPosition() inst.Transform:SetPosition(pt2.x+1, 0, pt2.z+1) end end inst.OnSave = onsave inst.OnLoad = onload 即可用蜗牛龟盔甲种找矿蜗牛,鼠标左键点蜗牛,可将其放入物品栏(显示为蜗牛龟盔甲的图标)。在空旷的地上放下找矿蜗牛,它会为你勘探出新的石矿,石头从此成为可再生资源。找矿蜗牛只会专注于找矿,不会跟随你,别把它弄丢了,如果真找不到了,存档退出后再读档,它会出现在你身边。不想要找矿蜗牛时,在物品栏中对其按鼠标右键即可。蜗牛龟盔甲可在地下一层打蜗牛龟时获得,如果修改了“巨型超市”,也可以花9-11个黄金购买

2025/04/23 · Bny

YN199-人工女友(用蜂刺种三个女友之一,可背东西、做饭、换衣帽)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 一九九.人工女友(用蜂刺种三个女友之一,可背东西、做饭、换衣帽) 用MT管理器打开游戏目录/assets/scripts/prefabs/stinger.lua文件, 1.在Asset("ANIM", "anim/stinger.zip"),的下一行插入以下内容: Asset("ANIM", "anim/wathgrithr.zip"), Asset("SOUND", "sound/wathgrithr.fsb"), 2.在inst:AddComponent("inspectable")的下一行插入以下内容: local slotpos = {} for y = 5, 0, -1 do for x = 0, 2 do table.insert(slotpos, Vector3(75*x-75*2+75, 75*y-75*2+75,0)) end end local widgetbuttoninfo = { text = "Do", position = Vector3(68, 361, 0), fn = function(inst) GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") if not inst:HasTag("withme") then inst:AddTag("withme") local brain = require "brains/chesterbrain" inst:SetBrain(brain) inst:RestartBrain() inst.components.follower:SetLeader(GetPlayer()) else inst:RemoveTag("withme") inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.follower:SetLeader(nil) end end } local function OnDeploy (inst, pt) local girl = SpawnPrefab("stinger") girl.Transform:SetPosition(pt.x, pt.y, pt.z) girl.AnimState:SetBank("wilson") local girlnames = {"wendy","willow","wathgrithr"} girl.buildname = girlnames[math.random(#girlnames)] girl.AnimState:SetBuild(girl.buildname) girl.AnimState:PlayAnimation("idle") girl.AnimState:Show("ARM_normal") girl.AnimState:Hide("ARM_carry") girl.Transform:SetFourFaced() girl.entity:AddSoundEmitter() local shadow = girl.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) MakeCharacterPhysics(girl, 75, .5) local minimap = girl.entity:AddMiniMapEntity() minimap:SetIcon( "wendy.png" ) girl:RemoveComponent("stackable") girl:RemoveComponent("inventoryitem") girl:RemoveComponent("deployable") girl:AddComponent("named") girl.components.named:SetName("My Baby") girl:AddComponent("knownlocations") girl:AddComponent("follower") girl.components.follower:SetLeader(GetPlayer()) girl:AddComponent("inventory") girl.components.container.canbeopened = true girl:AddComponent("locomotor") girl.components.locomotor.walkspeed = 8 girl.components.locomotor.runspeed = 12 girl:SetStateGraph("SGshadowwaxwell") local brain = require "brains/chesterbrain" girl:SetBrain(brain) girl:AddComponent("combat") girl:AddComponent("health") girl.components.health:SetMaxHealth(2000) girl:ListenForEvent("death", function() girl.components.container:DropEverything() end ) girl:AddComponent("talker") girl:DoPeriodicTask(60, function() local words = {"I love you","You are my love","I like you","I want stay with you","I miss you","you are my darling","I am your sweetheart","You have to love me","Don't go","Are you hungry"} local word = words[math.random(#words)] girl.components.talker:Say(word, 4, false) girl.components.health:DoDelta(2000) end) girl:DoPeriodicTask(400, function() local names = {"waffles","turkeydinner","baconeggs"} local name = names[math.random(#names)] local foods = SpawnPrefab(name) girl.components.container:GiveItem(foods) girl.components.talker:Say("Come to eat", 4, false) end) girl:AddComponent("machine") girl.components.machine.turnonfn = function(girl) girl.components.machine.ison = true girl:AddTag("neat") local hats = {"hat_flower","hat_earmuffs","hat_feather","hat_slurper","hat_spider","hat_straw","hat_top","hat_walrus","hat_winter","hat_beefalo","hat_rain","hat_catcoon"} girl.hat = hats[math.random(#hats)] local armors = {"armor_sweatervest","armor_trunkvest_summer","armor_trunkvest_winter","armor_sanity","armor_slurper","torso_rain"} girl.armor = armors[math.random(#armors)] girl.sg:GoToState("hit") girl.AnimState:OverrideSymbol("swap_hat", girl.hat, "swap_hat") girl.AnimState:OverrideSymbol("swap_body", girl.armor, "swap_body") girl.AnimState:Show("HAT") girl.AnimState:Show("HAT_HAIR") girl.AnimState:Hide("HAIR_NOHAT") girl.AnimState:Hide("HAIR") local words = {"I like it","I don't loke it"} local word = words[math.random(#words)] girl.components.talker:Say(word, 4, false) end girl.components.machine.turnofffn = function(girl) girl.components.machine.ison = false girl:RemoveTag("neat") girl.sg:GoToState("stunned") girl.AnimState:Hide("HAT") girl.AnimState:Hide("HAT_HAIR") girl.AnimState:Show("HAIR_NOHAT") girl.AnimState:Show("HAIR") girl.AnimState:ClearOverrideSymbol("swap_body") girl.SoundEmitter:PlaySound("dontstarve/characters/wendy/hurt") girl.components.talker:Say("Don't, Don't, Don't", 4, false) end girl:AddComponent("sanityaura") girl.components.sanityaura.aura = TUNING.SANITYAURA_HUGE girl:ListenForEvent("attacked", function(girl, data) girl.sg:GoToState("stunned") girl.SoundEmitter:PlaySound("dontstarve/characters/wendy/hurt") girl.components.talker:Say("Don't, Don't, Don't", 4, false) end ) girl:AddTag("fridge") girl:AddTag("withme") girl:AddTag("companion") girl:AddTag("girls") inst.components.stackable:Get():Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy inst:AddComponent("container") inst.components.container.widgetbuttoninfo = widgetbuttoninfo inst.components.container:SetNumSlots(#slotpos) inst.components.container.widgetslotpos = slotpos inst.components.container.widgetpos = Vector3(0,150,0) inst.components.container.side_align_tip = 160 inst.components.container.canbeopened = false local function onsave(inst, data) if inst:HasTag("girls") then data.girls = true end if inst:HasTag("withme") then data.withme = true end if inst:HasTag("neat") then data.neat = true end data.buildname = inst.buildname data.hat = inst.hat data.armor = inst.armor end local function onload(inst, data) if data and data.girls then inst.AnimState:SetBank("wilson") local girlnames = {"wendy","willow","wathgrithr"} inst.buildname = girlnames[math.random(#girlnames)] inst.AnimState:SetBuild(inst.buildname) inst.AnimState:PlayAnimation("idle") inst.AnimState:Show("ARM_normal") inst.AnimState:Hide("ARM_carry") inst.Transform:SetFourFaced() inst.entity:AddSoundEmitter() local shadow = inst.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) MakeCharacterPhysics(inst, 75, .5) local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon( "wendy.png" ) inst:RemoveComponent("stackable") inst:RemoveComponent("inventoryitem") inst:RemoveComponent("deployable") inst:AddComponent("named") inst.components.named:SetName("My Baby") inst:AddComponent("knownlocations") inst:AddComponent("follower") inst:AddComponent("inventory") inst.components.container.canbeopened = true inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 8 inst.components.locomotor.runspeed = 12 inst:SetStateGraph("SGshadowwaxwell") inst:AddComponent("combat") inst:AddComponent("health") inst.components.health:SetMaxHealth(2000) inst:ListenForEvent("death", function() inst.components.container:DropEverything() end ) inst:AddComponent("talker") inst:DoPeriodicTask(60, function() local words = {"I love you","You are my love","I like you","I want stay with you","I miss you","you are my darling","I am your sweetheart","You have to love me","Don't go","Are you hungry"} local word = words[math.random(#words)] inst.components.talker:Say(word, 4, false) inst.components.health:DoDelta(2000) end) inst:DoPeriodicTask(400, function() local names = {"waffles","turkeydinner","baconeggs"} local name = names[math.random(#names)] local foods = SpawnPrefab(name) inst.components.container:GiveItem(foods) inst.components.talker:Say("Come to eat", 4, false) end) inst:AddComponent("machine") inst.components.machine.turnonfn = function(inst) inst.components.machine.ison = true inst:AddTag("neat") local hats = {"hat_flower","hat_earmuffs","hat_feather","hat_slurper","hat_spider","hat_straw","hat_top","hat_walrus","hat_winter","hat_beefalo","hat_rain","hat_catcoon"} inst.hat = hats[math.random(#hats)] local armors = {"armor_sweatervest","armor_trunkvest_summer","armor_trunkvest_winter","armor_sanity","armor_slurper","torso_rain"} inst.armor = armors[math.random(#armors)] inst.sg:GoToState("hit") inst.AnimState:OverrideSymbol("swap_hat", inst.hat, "swap_hat") inst.AnimState:OverrideSymbol("swap_body", inst.armor, "swap_body") inst.AnimState:Show("HAT") inst.AnimState:Show("HAT_HAIR") inst.AnimState:Hide("HAIR_NOHAT") inst.AnimState:Hide("HAIR") local words = {"I like it","I don't loke it"} local word = words[math.random(#words)] inst.components.talker:Say(word, 4, false) end inst.components.machine.turnofffn = function(inst) inst.components.machine.ison = false inst:RemoveTag("neat") inst.sg:GoToState("stunned") inst.AnimState:Hide("HAT") inst.AnimState:Hide("HAT_HAIR") inst.AnimState:Show("HAIR_NOHAT") inst.AnimState:Show("HAIR") inst.AnimState:ClearOverrideSymbol("swap_body") inst.SoundEmitter:PlaySound("dontstarve/characters/wendy/hurt") inst.components.talker:Say("Don't, Don't, Don't", 4, false) end inst:AddComponent("sanityaura") inst.components.sanityaura.aura = TUNING.SANITYAURA_HUGE inst:ListenForEvent("attacked", function(inst, data) inst.sg:GoToState("stunned") inst.SoundEmitter:PlaySound("dontstarve/characters/wendy/hurt") inst.components.talker:Say("Don't, Don't, Don't", 4, false) end ) inst:AddTag("fridge") inst:AddTag("companion") inst:AddTag("girls") end if data and data.withme then inst:AddTag("withme") local brain = require "brains/chesterbrain" inst:SetBrain(brain) inst:RestartBrain() inst.components.follower:SetLeader(GetPlayer()) end if data and data.neat then inst.components.machine.ison = true inst:AddTag("neat") inst.AnimState:Show("HAT") inst.AnimState:Show("HAT_HAIR") inst.AnimState:Hide("HAIR_NOHAT") inst.AnimState:Hide("HAIR") if data and data.hat then inst.hat = data.hat inst.AnimState:OverrideSymbol("swap_hat", inst.hat, "swap_hat") end if data and data.armor then inst.armor = data.armor inst.AnimState:OverrideSymbol("swap_body", inst.armor, "swap_body") end end if data and data.buildname then inst.buildname = data.buildname inst.AnimState:SetBuild(inst.buildname) end end inst.OnSave = onsave inst.OnLoad = onload 即可用蜂刺种人工女友,随机为温蒂、薇洛、瓦丝格雷斯三人之一。鼠标左键点女友,可打开她的背包格(18格),让她帮你背东西,她的背包带有冷藏功能。点格子右上方的“Do”按钮,可让女友停留在原地,再次点“Do”按钮可继续跟随,如果你殴打她,她不再跟随你,也可通过点“Do”按钮让她继续跟随。鼠标右键点女友,可为她随机更换衣帽,再次点击可脱下衣帽,搭配好的衣帽会一直保留在她身上,不受存读档影响。每天女友会为你做一份料理,在她的背包格中拿取。女友会不时对你说话,与她紧紧依偎可以补脑(不再孤独了)。女友没有战斗能力,如果遇到敌人,要保护好她哦,你也可以选择逃跑,她会努力跟上你的,如果她遇难了,背包里的物品将掉在地上。不想要女友了,杀掉即可(按Ctrl + 鼠标左键攻击)。不要与“用蜂刺种杀人蜂窝”一同修改

2025/04/23 · Bny

YN200-养育孩子(主角逝去则孩子接班,一代一代生存下去)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二00.养育孩子(主角逝去则孩子接班,一代一代生存下去) 1.用MT管理器打开游戏目录/assets/scripts/prefabs/minotaurhorn.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function getson (inst) TheFrontEnd:Fade(false,1) GetPlayer():DoTaskInTime(1.5, function() TheFrontEnd:Fade(true,1) local pt = GetPlayer():GetPosition() local son = SpawnPrefab("resurrectionstatue") son.Transform:SetPosition(pt.x, pt.y, pt.z) son.AnimState:SetBank("wilson") if GetPlayer().prefab == "wilson" then son.AnimState:SetBuild("wilson") end if GetPlayer().prefab == "wendy" then son.AnimState:SetBuild("wendy") end if GetPlayer().prefab == "wes" then son.AnimState:SetBuild("wes") end if GetPlayer().prefab == "wickerbottom" then son.AnimState:SetBuild("wickerbottom") end if GetPlayer().prefab == "willow" then son.AnimState:SetBuild("willow") end if GetPlayer().prefab == "wolfgang" then son.AnimState:SetBuild("wolfgang_skinny") end if GetPlayer().prefab == "wx78" then son.AnimState:SetBuild("wx78") end if GetPlayer().prefab == "woodie" then son.AnimState:SetBuild("woodie") end if GetPlayer().prefab == "waxwell" then son.AnimState:SetBuild("waxwell") end if GetPlayer().prefab == "wathgrithr" then son.AnimState:SetBuild("wathgrithr") end if GetPlayer().prefab == "webber" then son.AnimState:SetBuild("webber") end local hats = {"hat_beefalo","hat_feather","hat_flower","hat_top","hat_walrus","hat_winter"} local hat = hats[math.random(#hats)] son.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") local armors = {"armor_sanity","armor_slurper","armor_sweatervest","armor_trunkvest_summer","armor_trunkvest_winter"} local armor = armors[math.random(#armors)] son.AnimState:OverrideSymbol("swap_body", armor, "swap_body") son.AnimState:Show("HAT") son.AnimState:Show("HAT_HAIR") son.AnimState:Hide("HAIR_NOHAT") son.AnimState:Hide("HAIR") son.AnimState:Hide("ARM_carry") son.AnimState:Show("ARM_normal") son.AnimState:PlayAnimation("idle") son.AnimState:Hide("snow") son.Transform:SetFourFaced() son.Transform:SetScale(0.8,0.8,0.8) son:AddComponent("combat") son.components.combat.hiteffectsymbol = "torso" son.components.combat:SetRetargetFunction(3, function(son) if not son.components.health:IsDead() then return FindEntity(son, 20, function(guy) if guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy end end) end end ) son.components.combat:SetKeepTargetFunction(function(son, target) return target and target:IsValid() end ) son.components.combat:SetAttackPeriod(1) son.components.combat:SetRange(2, 3) son.components.combat:SetDefaultDamage(10) son:AddComponent("health") son.components.health:SetMaxHealth(1000) son.components.health.nofadeout = true son:AddComponent("inventory") son.components.inventory.dropondeath = false son:AddComponent("locomotor") son.components.locomotor.pathcaps = { ignorecreep = true } son.components.locomotor.runspeed = 12 local brain = require"brains/shadowwaxwellbrain" son:SetBrain(brain) son:SetStateGraph("SGshadowwaxwell") son:RemoveComponent("lootdropper") son:RemoveComponent("workable") son:RemoveComponent("burnable") son:RemoveComponent("propagator") MakeCharacterPhysics(son, 75, .5) son:RemoveTag("structure") son:AddComponent("follower") son.components.follower.leader = GetPlayer() son:AddComponent("trader") son.components.trader:SetAcceptTest(function(son, item) if GetPlayer().components.inventory:Has("goldnugget", 5) then if item.prefab == "goldnugget" and son.components.health and not son.components.health:IsDead() then return son.components.health:GetPercent() < .99 end end return false end ) son.components.trader.onaccept = function(son, giver, item) GetPlayer().components.inventory:ConsumeByName("goldnugget", 4) son.components.health:DoDelta(1000) end son:AddComponent("machine") son.components.machine.turnonfn = function() son.components.locomotor:Stop() son.brain:Stop() end son.components.machine.turnofffn = function() son.brain:Start() end son:ListenForEvent("death", function() GetPlayer().components.sanity:DoDelta(-100) SpawnPrefab("trinket_1").Transform:SetPosition(son.Transform:GetWorldPosition()) end ) son:AddTag("companion") son:AddTag("sons") inst:Remove() end ) end local function OnDeploy (inst, pt) if GetPlayer().components.inventory:Has("goldnugget", 100) then GetPlayer().components.inventory:ConsumeByName("goldnugget", 100) local egg1 = SpawnPrefab("minotaurhorn") egg1.AnimState:SetBuild("tallbird_egg") egg1.AnimState:SetBank("egg") egg1.AnimState:PlayAnimation("egg") egg1.Transform:SetPosition(pt.x+2+3, pt.y, pt.z+2-3) egg1.AnimState:SetMultColour(0/255,255/255,0/255,1) egg1.Transform:SetScale(1.5,1.5,1.5) egg1:AddComponent("health") egg1.components.health:SetMaxHealth(1) egg1:AddComponent("combat") egg1:RemoveComponent("edible") egg1.components.inventoryitem.canbepickedup = false local egg2 = SpawnPrefab("minotaurhorn") egg2.AnimState:SetBuild("tallbird_egg") egg2.AnimState:SetBank("egg") egg2.AnimState:PlayAnimation("egg") egg2.Transform:SetPosition(pt.x+2-3, pt.y, pt.z+2+3) egg2.AnimState:SetMultColour(0/255,255/255,0/255,1) egg2.Transform:SetScale(1.5,1.5,1.5) egg2:AddComponent("health") egg2.components.health:SetMaxHealth(1) egg2:AddComponent("combat") egg2:RemoveComponent("edible") egg2.components.inventoryitem.canbepickedup = false egg1:ListenForEvent("death", function() egg1.AnimState:PlayAnimation("crack") egg2:Remove() if math.random()<.5 then local pt = GetPlayer():GetPosition() GetSeasonManager():DoLightningStrike(pt) inst:DoTaskInTime(1, function() getson(inst) end ) else SpawnPrefab("collapse_small").Transform:SetPosition(egg1.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") end end ) egg2:ListenForEvent("death", function() egg2.AnimState:PlayAnimation("crack") egg1:Remove() if math.random()<.5 then local pt = GetPlayer():GetPosition() GetSeasonManager():DoLightningStrike(pt) inst:DoTaskInTime(2, function() getson(inst) end ) else SpawnPrefab("collapse_small").Transform:SetPosition(egg2.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") end end ) end end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/resurrectionstatue.lua文件,将下列内容: inst.OnSave = onsave inst.OnLoad = onload 替换为: local items = { AXE = "swap_axe", PICK = "swap_pickaxe", SWORD = "swap_spear" } local function EquipItem(inst, item) if item then inst.AnimState:OverrideSymbol("swap_object", item, item) inst.AnimState:Show("ARM_carry") inst.AnimState:Hide("ARM_normal") end end inst.items = items inst.equipfn = EquipItem EquipItem(inst) local function onsave2(inst, data) if inst:HasTag("sons") then data.sons = true end end local function onload2(inst, data) if data and data.sons then inst.AnimState:SetBank("wilson") if GetPlayer().prefab == "wilson" then inst.AnimState:SetBuild("wilson") end if GetPlayer().prefab == "wendy" then inst.AnimState:SetBuild("wendy") end if GetPlayer().prefab == "wes" then inst.AnimState:SetBuild("wes") end if GetPlayer().prefab == "wickerbottom" then inst.AnimState:SetBuild("wickerbottom") end if GetPlayer().prefab == "willow" then inst.AnimState:SetBuild("willow") end if GetPlayer().prefab == "wolfgang" then inst.AnimState:SetBuild("wolfgang_skinny") end if GetPlayer().prefab == "wx78" then inst.AnimState:SetBuild("wx78") end if GetPlayer().prefab == "woodie" then inst.AnimState:SetBuild("woodie") end if GetPlayer().prefab == "waxwell" then inst.AnimState:SetBuild("waxwell") end if GetPlayer().prefab == "wathgrithr" then inst.AnimState:SetBuild("wathgrithr") end if GetPlayer().prefab == "webber" then inst.AnimState:SetBuild("webber") end local hats = {"hat_beefalo","hat_feather","hat_flower","hat_top","hat_walrus","hat_winter"} local hat = hats[math.random(#hats)] inst.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") local armors = {"armor_sanity","armor_slurper","armor_sweatervest","armor_trunkvest_summer","armor_trunkvest_winter"} local armor = armors[math.random(#armors)] inst.AnimState:OverrideSymbol("swap_body", armor, "swap_body") inst.AnimState:Show("HAT") inst.AnimState:Show("HAT_HAIR") inst.AnimState:Hide("HAIR_NOHAT") inst.AnimState:Hide("HAIR") inst.AnimState:Hide("ARM_carry") inst.AnimState:Show("ARM_normal") inst.AnimState:PlayAnimation("idle") inst.AnimState:Hide("snow") inst.Transform:SetFourFaced() inst.Transform:SetScale(0.8,0.8,0.8) inst:AddComponent("combat") inst.components.combat.hiteffectsymbol = "torso" inst.components.combat:SetRetargetFunction(3, function(inst) if not inst.components.health:IsDead() then return FindEntity(inst, 20, function(guy) if guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy end end) end end ) inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) inst.components.combat:SetAttackPeriod(1) inst.components.combat:SetRange(2, 3) inst.components.combat:SetDefaultDamage(10) inst:AddComponent("health") inst.components.health:SetMaxHealth(1000) inst.components.health.nofadeout = true inst:AddComponent("inventory") inst.components.inventory.dropondeath = false inst:AddComponent("locomotor") inst.components.locomotor.pathcaps = { ignorecreep = true } inst.components.locomotor.runspeed = 12 local brain = require"brains/shadowwaxwellbrain" inst:SetBrain(brain) inst:SetStateGraph("SGshadowwaxwell") inst:RemoveComponent("lootdropper") inst:RemoveComponent("workable") inst:RemoveComponent("burnable") inst:RemoveComponent("propagator") MakeCharacterPhysics(inst, 75, .5) inst:RemoveTag("structure") inst:AddComponent("follower") inst.components.follower.leader = GetPlayer() inst:AddComponent("trader") inst.components.trader:SetAcceptTest(function(inst, item) if GetPlayer().components.inventory:Has("goldnugget", 5) then if item.prefab == "goldnugget" and inst.components.health and not inst.components.health:IsDead() then return inst.components.health:GetPercent() < .99 end end return false end ) inst.components.trader.onaccept = function(inst, giver, item) GetPlayer().components.inventory:ConsumeByName("goldnugget", 4) inst.components.health:DoDelta(1000) end inst:AddComponent("machine") inst.components.machine.turnonfn = function() inst.components.locomotor:Stop() inst.brain:Stop() end inst.components.machine.turnofffn = function() inst.brain:Start() end inst:ListenForEvent("death", function() GetPlayer().components.sanity:DoDelta(-100) SpawnPrefab("trinket_1").Transform:SetPosition(inst.Transform:GetWorldPosition()) end ) inst:AddTag("companion") inst:AddTag("sons") end end inst.OnSave = onsave2 inst.OnLoad = onload2 即可在你攒够100个黄金时,将远古守护者角种在地上,向上天求子,会赐予你2个蛋(身上黄金数不足时,只收走远古守护者角,不给蛋),选一个打破,如果中了(屏幕黑一下),就会获得孩子,如果没中(生一团烟),就只能下次再试了。使用不同主角,将获得不同的孩子,可以带着他打仗、砍树、开矿。如果你死了,他将长大成人,继承你的事业,一代一代在饥荒世界里生存下去。如果他不幸夭折了,对你而言无疑是晴天霹雳(减100点脑),他将为你留下一件小小的遗物,让你永远不要忘记他。当遇到危险时,可以对他点鼠标右键,让他停留在原地,等危险排除了,再对他按右键,即可继续跟随。可以通过给零花钱为他补血(拿着黄金对他点鼠标左键),一次5个黄金,身上黄金数不足或孩子满血时拒收。注意未成年人是不会跟着你下地洞的,把他安顿好后再去刷怪吧

2025/04/23 · Bny

YN201-私家军(用火药种私家军,可装备盔甲、帽子,需要支付工资)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二0一.私家军(用火药种私家军,可装备盔甲、帽子,需要支付工资) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/gunpowder.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function itemtest(inst, item, slot) if item.prefab == "armorgrass" or item.prefab == "armorwood" or item.prefab == "armormarble" or item.prefab == "armor_sanity" or item.prefab == "armorruins" or item.prefab == "footballhat" or item.prefab == "ruinshat" or item.prefab == "beefalohat" or item.prefab == "featherhat" or item.prefab == "goldnugget" then return true end return false end local slotpos = { Vector3(0,32+4,0), Vector3(0,-(32+4),0), Vector3(0,-(64+32+8+4),0)} local widgetbuttoninfo = { text = "Go", position = Vector3(0, -165, 0), fn = function(inst) if inst:HasTag("mercenary") then if inst.components.container:Has("goldnugget", 20) then inst:AddTag("cango") end inst.components.container:Close(GetPlayer()) GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available") inst.AnimState:Hide("HAT") inst.AnimState:Hide("HAT_HAIR") inst.AnimState:Show("HAIR_NOHAT") inst.AnimState:Show("HAIR") inst.AnimState:ClearOverrideSymbol("swap_body") for k,v in pairs(inst.components.container.slots) do if v.prefab == "footballhat" or v.prefab == "ruinshat" or v.prefab == "beefalohat" or v.prefab == "featherhat" then inst.AnimState:Show("HAT") inst.AnimState:Show("HAT_HAIR") inst.AnimState:Hide("HAIR_NOHAT") inst.AnimState:Hide("HAIR") end if v and v.prefab == "armorgrass" then inst.AnimState:OverrideSymbol("swap_body", "armor_grass", "swap_body") inst:ListenForEvent("attacked", function(inst, data) inst.components.health:DoDelta(15) end ) end if v and v.prefab == "armorwood" then inst.AnimState:OverrideSymbol("swap_body", "armor_wood", "swap_body") inst:ListenForEvent("attacked", function(inst, data) inst.components.health:DoDelta(20) end ) end if v and v.prefab == "armormarble" then inst.AnimState:OverrideSymbol("swap_body", "armor_marble", "swap_body") inst:ListenForEvent("attacked", function(inst, data) inst.components.health:DoDelta(25) end ) end if v and v.prefab == "armor_sanity" then inst.AnimState:OverrideSymbol("swap_body", "armor_sanity", "swap_body") inst:ListenForEvent("attacked", function(inst, data) inst.components.health:DoDelta(30) end ) end if v and v.prefab == "armorruins" then inst.AnimState:OverrideSymbol("swap_body", "armor_ruins", "swap_body") inst:ListenForEvent("attacked", function(inst, data) inst.components.health:DoDelta(35) end ) end if v and v.prefab == "footballhat" then inst.AnimState:OverrideSymbol("swap_hat", "hat_football", "swap_hat") end if v and v.prefab == "ruinshat" then inst.AnimState:OverrideSymbol("swap_hat", "hat_ruins", "swap_hat") end if v and v.prefab == "beefalohat" then inst.AnimState:OverrideSymbol("swap_hat", "hat_beefalo", "swap_hat") end if v and v.prefab == "featherhat" then inst.AnimState:OverrideSymbol("swap_hat", "hat_feather", "swap_hat") end end end end } inst:AddComponent("container") inst.components.container.widgetbuttoninfo = widgetbuttoninfo inst.components.container:SetNumSlots(#slotpos) inst.components.container.widgetslotpos = slotpos inst.components.container.widgetpos = Vector3(0,180,0) inst.components.container.side_align_tip = 160 inst.components.container.canbeopened = false inst.components.container.itemtestfn = itemtest inst.components.container.onopenfn = function(inst) inst:RemoveTag("cango") end local items = { SWORD = "swap_spear" } local function EquipItem(inst, item) if item then inst.AnimState:OverrideSymbol("swap_object", item, item) inst.AnimState:Show("ARM_carry") inst.AnimState:Hide("ARM_normal") end end inst.items = items inst.equipfn = EquipItem EquipItem(inst) local function OnDeploy (inst, pt) if GetPlayer().components.inventory:Has("goldnugget", 100) then GetPlayer().components.inventory:ConsumeByName("goldnugget", 100) local mercenary = SpawnPrefab("gunpowder") mercenary.Transform:SetPosition(pt.x, pt.y, pt.z) mercenary.AnimState:SetBank("wilson") mercenary.AnimState:SetBuild("wilson") mercenary.AnimState:PlayAnimation("idle") mercenary.AnimState:OverrideSymbol("swap_object", "swap_spear", "swap_spear") mercenary.AnimState:Show("ARM_carry") mercenary.AnimState:Hide("ARM_normal") mercenary.Transform:SetFourFaced() local shadow = mercenary.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) MakeCharacterPhysics(mercenary, 75, .5) local minimap = mercenary.entity:AddMiniMapEntity() minimap:SetIcon( "researchlab.png" ) mercenary:AddTag("mercenary") mercenary:AddComponent("locomotor") mercenary.components.locomotor.walkspeed = 8 mercenary.components.locomotor.runspeed = 15 mercenary:SetStateGraph("SGshadowwaxwell") mercenary:RemoveComponent("stackable") mercenary:RemoveComponent("explosive") mercenary:RemoveComponent("inventoryitem") mercenary:RemoveComponent("burnable") mercenary:RemoveComponent("propagator") mercenary:RemoveComponent("deployable") mercenary:RemoveComponent("bait") mercenary:RemoveTag("molebait") mercenary:AddComponent("follower") mercenary:AddComponent("inventory") mercenary.components.container.canbeopened = true mercenary:AddComponent("combat") mercenary.components.combat.hiteffectsymbol = "torso" mercenary.components.combat:SetDefaultDamage(50) mercenary.components.combat:SetRange(2, 3) mercenary.components.combat:SetAttackPeriod(0.5) mercenary.components.combat:SetRetargetFunction(2, function(mercenary) if not mercenary.components.health:IsDead() then return FindEntity(mercenary, 25, function(guy) if guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") end end) end end ) mercenary.components.combat:SetKeepTargetFunction(function(mercenary, target) return target and target:IsValid() end ) mercenary:AddComponent("health") mercenary.components.health:SetMaxHealth(1500) mercenary.components.health.nofadeout = true mercenary:DoPeriodicTask(1, function(mercenary) if mercenary:HasTag("cango") then if not mercenary.components.container:Has("goldnugget", 20) then mercenary.AnimState:SetBloomEffectHandle("") mercenary.components.locomotor:Stop() mercenary:SetBrain(nil) mercenary.components.follower:SetLeader(nil) else mercenary.AnimState:SetBloomEffectHandle("shaders/anim.ksh") local brain = require "brains/abigailbrain" mercenary:SetBrain(brain) mercenary:RestartBrain() mercenary.components.follower:SetLeader(GetPlayer()) end else mercenary.AnimState:SetBloomEffectHandle("") mercenary.components.locomotor:Stop() mercenary:SetBrain(nil) mercenary.components.follower:SetLeader(nil) end end ) mercenary:DoPeriodicTask(480, function(mercenary) if mercenary.components.container:Has("goldnugget", 20) then mercenary.components.container:ConsumeByName("goldnugget", 20) mercenary.components.health:DoDelta(500) end end ) mercenary:AddComponent( "playerprox" ) mercenary.components.playerprox:SetDist(3,5) mercenary.components.playerprox:SetOnPlayerNear(function(mercenary) mercenary.components.locomotor.walkspeed = 1 mercenary.components.locomotor.runspeed = 2 end ) mercenary.components.playerprox:SetOnPlayerFar(function(mercenary) mercenary.components.locomotor.walkspeed = 8 mercenary.components.locomotor.runspeed = 15 end ) end inst.components.stackable:Get():Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("mercenary") then data.mercenary = true end if inst:HasTag("cango") then data.cango = true end end local function onload(inst, data) if data and data.mercenary then inst.AnimState:SetBank("wilson") inst.AnimState:SetBuild("wilson") inst.AnimState:PlayAnimation("idle") inst.AnimState:OverrideSymbol("swap_object", "swap_spear", "swap_spear") inst.AnimState:Show("ARM_carry") inst.AnimState:Hide("ARM_normal") inst.Transform:SetFourFaced() local shadow = inst.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) MakeCharacterPhysics(inst, 75, .5) local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon( "researchlab.png" ) inst:AddTag("mercenary") inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 8 inst.components.locomotor.runspeed = 15 inst:SetStateGraph("SGshadowwaxwell") inst:RemoveComponent("stackable") inst:RemoveComponent("explosive") inst:RemoveComponent("inventoryitem") inst:RemoveComponent("burnable") inst:RemoveComponent("propagator") inst:RemoveComponent("deployable") inst:RemoveComponent("bait") inst:RemoveTag("molebait") inst:AddComponent("follower") inst:AddComponent("inventory") inst.components.container.canbeopened = true inst:AddComponent("combat") inst.components.combat.hiteffectsymbol = "torso" inst.components.combat:SetDefaultDamage(50) inst.components.combat:SetRange(2, 3) inst.components.combat:SetAttackPeriod(0.5) inst.components.combat:SetRetargetFunction(2, function(inst) if not inst.components.health:IsDead() then return FindEntity(inst, 25, function(guy) if guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") end end) end end ) inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) inst:AddComponent("health") inst.components.health:SetMaxHealth(1500) inst.components.health.nofadeout = true inst:DoPeriodicTask(1, function(inst) if inst:HasTag("cango") then if not inst.components.container:Has("goldnugget", 20) then inst.AnimState:SetBloomEffectHandle("") inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.follower:SetLeader(nil) else inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") local brain = require "brains/abigailbrain" inst:SetBrain(brain) inst:RestartBrain() inst.components.follower:SetLeader(GetPlayer()) end else inst.AnimState:SetBloomEffectHandle("") inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.follower:SetLeader(nil) end end ) inst:DoPeriodicTask(480, function(inst) if inst.components.container:Has("goldnugget", 20) then inst.components.container:ConsumeByName("goldnugget", 20) inst.components.health:DoDelta(500) end end ) inst:AddComponent( "playerprox" ) inst.components.playerprox:SetDist(3,5) inst.components.playerprox:SetOnPlayerNear(function(inst) inst.components.locomotor.walkspeed = 1 inst.components.locomotor.runspeed = 2 end ) inst.components.playerprox:SetOnPlayerFar(function(inst) inst.components.locomotor.walkspeed = 8 inst.components.locomotor.runspeed = 15 end ) inst.AnimState:Hide("HAT") inst.AnimState:Hide("HAT_HAIR") inst.AnimState:Show("HAIR_NOHAT") inst.AnimState:Show("HAIR") inst.AnimState:ClearOverrideSymbol("swap_body") for k,v in pairs(inst.components.container.slots) do if v.prefab == "footballhat" or v.prefab == "ruinshat" or v.prefab == "beefalohat" or v.prefab == "featherhat" then inst.AnimState:Show("HAT") inst.AnimState:Show("HAT_HAIR") inst.AnimState:Hide("HAIR_NOHAT") inst.AnimState:Hide("HAIR") end if v and v.prefab == "armorgrass" then inst.AnimState:OverrideSymbol("swap_body", "armor_grass", "swap_body") inst:ListenForEvent("attacked", function(inst, data) inst.components.health:DoDelta(15) end ) end if v and v.prefab == "armorwood" then inst.AnimState:OverrideSymbol("swap_body", "armor_wood", "swap_body") inst:ListenForEvent("attacked", function(inst, data) inst.components.health:DoDelta(20) end ) end if v and v.prefab == "armormarble" then inst.AnimState:OverrideSymbol("swap_body", "armor_marble", "swap_body") inst:ListenForEvent("attacked", function(inst, data) inst.components.health:DoDelta(25) end ) end if v and v.prefab == "armor_sanity" then inst.AnimState:OverrideSymbol("swap_body", "armor_sanity", "swap_body") inst:ListenForEvent("attacked", function(inst, data) inst.components.health:DoDelta(30) end ) end if v and v.prefab == "armorruins" then inst.AnimState:OverrideSymbol("swap_body", "armor_ruins", "swap_body") inst:ListenForEvent("attacked", function(inst, data) inst.components.health:DoDelta(35) end ) end if v and v.prefab == "footballhat" then inst.AnimState:OverrideSymbol("swap_hat", "hat_football", "swap_hat") end if v and v.prefab == "ruinshat" then inst.AnimState:OverrideSymbol("swap_hat", "hat_ruins", "swap_hat") end if v and v.prefab == "beefalohat" then inst.AnimState:OverrideSymbol("swap_hat", "hat_beefalo", "swap_hat") end if v and v.prefab == "featherhat" then inst.AnimState:OverrideSymbol("swap_hat", "hat_feather", "swap_hat") end end end if data and data.cango then inst:AddTag("cango") end end inst.OnSave = onsave inst.OnLoad = onload 即可在身上有100个黄金时,用火药种私家军,将花费100个黄金,身上黄金数不足时不会种出来。鼠标左键点击他可打开格子,放入至少20个黄金后,点Go按钮,会跟随你打仗。追上他用鼠标左键再次点击,可让他停在原地,想让他继续跟随,就再点Go按钮即可。私家军士兵每天的工资是20个黄金,自动从他身上的黄金中扣除(并同时回补三分之一的血),如果他身上的黄金数不足20个时,将罢工,请及时续费。如果私家军的格子中有盔甲、帽子,点Go按钮会自动装备。装备盔甲可提高私家军的防御力,按防御力由低到高排序为草盔甲、木盔甲、大理石盔甲、夜魔盔甲、远古盔甲。装备帽子只起到装饰作用,可装备的帽子有猪皮帽、远古帽、牛毛帽、羽毛帽。不要在他的格子里放2个盔甲或2个帽子,他只会选择1个装备。私家军在小地图上显示为科学机器的图标,可以方便地找到他们的位置。火药在科学选项(画着原子)下,用1个烂鸡蛋、1个木炭、1个硝石制造

2025/04/23 · Bny

YN202-天使蝴蝶(用雨衣种天使蝴蝶,为你照亮,电击来犯之敌,可收入物品栏)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二0二.天使蝴蝶(用雨衣种天使蝴蝶,为你照亮,电击来犯之敌,可收入物品栏) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/raincoat.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function OnDeploy (inst, pt) local scalewing = SpawnPrefab("raincoat") scalewing.Transform:SetPosition(pt.x, pt.y, pt.z) scalewing.AnimState:SetBank("butterfly") scalewing.AnimState:SetBuild("butterfly_basic") scalewing.AnimState:PlayAnimation("idle") scalewing.AnimState:SetRayTestOnBB(true); scalewing.Transform:SetTwoFaced() scalewing.Transform:SetScale(1.5, 1.5, 1.5) scalewing.AnimState:SetMultColour(255/255,0/255,115/255,0.8) scalewing.AnimState:SetBloomEffectHandle("shaders/anim.ksh") scalewing.entity:AddSoundEmitter() local shadow = scalewing.entity:AddDynamicShadow() shadow:SetSize(.8, .5) RemovePhysicsColliders(scalewing) scalewing.entity:AddLight() scalewing.Light:SetFalloff(1) scalewing.Light:SetIntensity(.8) scalewing.Light:SetRadius(12) scalewing.Light:SetColour(180/255, 195/255, 50/255) scalewing.Light:Enable(true) scalewing:RemoveComponent("inventoryitem") scalewing:RemoveComponent("equippable") scalewing:RemoveComponent("waterproofer") scalewing:RemoveComponent("fueled") scalewing:RemoveComponent("insulator") scalewing:RemoveComponent("deployable") scalewing:AddComponent("inventoryitem") scalewing.components.inventoryitem:ChangeImageName("butterfly") scalewing:AddComponent("named") scalewing.components.named:SetName("Butterfly") scalewing:AddComponent("follower") scalewing.components.follower:SetLeader(GetPlayer()) scalewing:AddComponent("locomotor") scalewing.components.locomotor.walkspeed = 8 scalewing:SetStateGraph("SGbutterfly") local brain = require "brains/abigailbrain" scalewing:SetBrain(brain) scalewing:AddComponent("health") scalewing.components.health:SetMaxHealth(10) scalewing.components.health:SetInvincible(true) scalewing:AddComponent("combat") scalewing.components.combat:SetDefaultDamage(0) scalewing.components.combat:SetRange(2) scalewing.components.combat:SetAttackPeriod(0.5) scalewing.components.combat:SetRetargetFunction(1, function(scalewing) if not scalewing.components.health:IsDead() then return FindEntity(GetPlayer(), 20, function(guy) if guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy.components.combat.target == scalewing or scalewing.components.combat.target == guy or guy:HasTag("monster") end end) end end ) scalewing.components.combat:SetKeepTargetFunction(function(scalewing, target) return target and target:IsValid() end ) scalewing:AddTag("duty") scalewing.task = scalewing:DoPeriodicTask(0.5, function(scalewing) local target = FindEntity(scalewing, 3, function(guy) if guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy.components.combat.target == scalewing or scalewing.components.combat.target == guy or guy:HasTag("monster") end end ) if target then if target.components.combat then target.components.combat:SetTarget(scalewing) end if target.components.locomotor then target.components.locomotor:Stop() end SpawnPrefab("lightning_rod_fx").Transform:SetPosition(target.Transform:GetWorldPosition()) scalewing.SoundEmitter:PlaySound("dontstarve/common/lightningrod") target.components.health:DoDelta(-100) end end ) scalewing.components.inventoryitem:SetOnDroppedFn(function(scalewing) scalewing:AddTag("duty") scalewing.Light:Enable(true) scalewing.task = scalewing:DoPeriodicTask(0.5, function(scalewing) local target = FindEntity(scalewing, 3, function(guy) if guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy.components.combat.target == scalewing or scalewing.components.combat.target == guy or guy:HasTag("monster") end end ) if target then if target.components.combat then target.components.combat:SetTarget(scalewing) end if target.components.locomotor then target.components.locomotor:Stop() end SpawnPrefab("lightning_rod_fx").Transform:SetPosition(target.Transform:GetWorldPosition()) scalewing.SoundEmitter:PlaySound("dontstarve/common/lightningrod") target.components.health:DoDelta(-100) end end ) end ) scalewing.components.inventoryitem:SetOnPickupFn(function(scalewing) scalewing:RemoveTag("duty") scalewing.Light:Enable(false) if scalewing.task then scalewing.task:Cancel() scalewing.task = nil end end ) scalewing.components.inventoryitem:SetOnPutInInventoryFn(function(scalewing) scalewing:RemoveTag("duty") scalewing.Light:Enable(false) if scalewing.task then scalewing.task:Cancel() scalewing.task = nil end end ) scalewing:AddTag("scalewings") inst:Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("scalewings") then data.scalewings = true end if inst:HasTag("duty") then data.duty = true end end local function onload(inst, data) if data and data.scalewings then inst.AnimState:SetBank("butterfly") inst.AnimState:SetBuild("butterfly_basic") inst.AnimState:PlayAnimation("idle") inst.AnimState:SetRayTestOnBB(true); inst.Transform:SetTwoFaced() inst.Transform:SetScale(1.5, 1.5, 1.5) inst.AnimState:SetMultColour(255/255,0/255,115/255,0.8) inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") inst.entity:AddSoundEmitter() local shadow = inst.entity:AddDynamicShadow() shadow:SetSize(.8, .5) RemovePhysicsColliders(inst) inst.entity:AddLight() inst.Light:SetFalloff(1) inst.Light:SetIntensity(.8) inst.Light:SetRadius(12) inst.Light:SetColour(180/255, 195/255, 50/255) inst.Light:Enable(true) inst:RemoveComponent("inventoryitem") inst:RemoveComponent("equippable") inst:RemoveComponent("waterproofer") inst:RemoveComponent("fueled") inst:RemoveComponent("insulator") inst:RemoveComponent("deployable") inst:AddComponent("inventoryitem") inst.components.inventoryitem:ChangeImageName("butterfly") inst:AddComponent("named") inst.components.named:SetName("Butterfly") inst:AddComponent("follower") inst.components.follower:SetLeader(GetPlayer()) inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 8 inst:SetStateGraph("SGbutterfly") local brain = require "brains/abigailbrain" inst:SetBrain(brain) inst:AddComponent("health") inst.components.health:SetMaxHealth(10) inst.components.health:SetInvincible(true) inst:AddComponent("combat") inst.components.combat:SetDefaultDamage(0) inst.components.combat:SetRange(2) inst.components.combat:SetAttackPeriod(0.5) inst.components.combat:SetRetargetFunction(1, function(inst) if not inst.components.health:IsDead() then return FindEntity(GetPlayer(), 20, function(guy) if guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy.components.combat.target == inst or inst.components.combat.target == guy or guy:HasTag("monster") end end) end end ) inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) inst.components.inventoryitem:SetOnDroppedFn(function(inst) inst:AddTag("duty") inst.Light:Enable(true) inst.task = inst:DoPeriodicTask(0.5, function(inst) local target = FindEntity(inst, 3, function(guy) if guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy.components.combat.target == inst or inst.components.combat.target == guy or guy:HasTag("monster") end end ) if target then if target.components.combat then target.components.combat:SetTarget(inst) end if target.components.locomotor then target.components.locomotor:Stop() end SpawnPrefab("lightning_rod_fx").Transform:SetPosition(target.Transform:GetWorldPosition()) inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod") target.components.health:DoDelta(-100) end end ) end ) inst.components.inventoryitem:SetOnPickupFn(function(inst) inst:RemoveTag("duty") inst.Light:Enable(false) if inst.task then inst.task:Cancel() inst.task = nil end end ) inst.components.inventoryitem:SetOnPutInInventoryFn(function(inst) inst:RemoveTag("duty") inst.Light:Enable(false) if inst.task then inst.task:Cancel() inst.task = nil end end ) inst:AddTag("scalewings") end if data and data.duty then inst:AddTag("duty") inst.task = inst:DoPeriodicTask(0.5, function(inst) local target = FindEntity(inst, 3, function(guy) if guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy.components.combat.target == inst or inst.components.combat.target == guy or guy:HasTag("monster") end end ) if target then if target.components.combat then target.components.combat:SetTarget(inst) end if target.components.locomotor then target.components.locomotor:Stop() end SpawnPrefab("lightning_rod_fx").Transform:SetPosition(target.Transform:GetWorldPosition()) inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod") target.components.health:DoDelta(-100) end end ) end end inst.OnSave = onsave inst.OnLoad = onload 即可用雨衣种天使蝴蝶,会跟随你,为你照亮。任何企图攻击你的敌人,都会遭到天使蝴蝶的电击,杀伤其生命值,并阻止其靠近你。鼠标左键点击天使蝴蝶,可收入物品栏,显示为蝴蝶图标。不想要天使蝴蝶了,在物品栏中对其按鼠标右键即可。雨衣在穿戴选项(画着礼帽)下,用2个触手皮、2个绳子、2个硬骨头制造

2025/04/23 · Bny

YN203-宠物熊(用黄色护身符种宠物熊,是战场好帮手,左键点击可停在原地,喂大肉可补血)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二0三.宠物熊(用黄色护身符种宠物熊,是战场好帮手,左键点击可停在原地,喂大肉可补血) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/amulet.lua文件,在inst.AnimState:PlayAnimation("yellowamulet")的下一行插入以下内容: local function SetStandState(inst, state) inst.StandState = string.lower(state) end local function OnDeploy (inst, pt) local mybear = SpawnPrefab("yellowamulet") mybear.Transform:SetPosition(pt.x, pt.y, pt.z) mybear.AnimState:SetBank("bearger") mybear.AnimState:SetBuild("bearger_build") mybear.AnimState:PlayAnimation("idle_loop", true) mybear.Transform:SetScale(0.5, 0.5, 0.5) mybear.Transform:SetFourFaced() local sound = mybear.entity:AddSoundEmitter() local shadow = mybear.entity:AddDynamicShadow() shadow:SetSize(3, 1.8) MakeCharacterPhysics(mybear, 500, 1) mybear:RemoveComponent("equippable") mybear:RemoveComponent("inventoryitem") mybear:RemoveComponent("fueled") mybear:RemoveComponent("deployable") SetStandState(mybear, "QUAD") mybear.CanGroundPound = false mybear.SetStandState = SetStandState mybear.IsStandState = function(mybear, state) return mybear.StandState == string.lower(state) end mybear.WorkEntities = function(mybear) mybear.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") GetPlayer().components.playercontroller:ShakeCamera(mybear, "FULL", 0.5, 0.05, 2, 40) end mybear:AddComponent("groundpounder") mybear.components.groundpounder.destroyer = true mybear.components.groundpounder.damageRings = 3 mybear.components.groundpounder.destructionRings = 4 mybear.components.groundpounder.numRings = 5 mybear:AddComponent("named") mybear.components.named:SetName("My Bear") mybear:AddComponent("inventory") mybear:AddComponent("knownlocations") mybear:AddComponent("timer") mybear:AddComponent("eater") mybear.components.eater.foodprefs = {"MEAT"} mybear:AddComponent("follower") mybear.components.follower:SetLeader(GetPlayer()) mybear:AddComponent("lootdropper") mybear.components.lootdropper:SetLoot({"meat", "meat", "meat", "meat", "bearger_fur"}) mybear:AddComponent("health") mybear.components.health:SetMaxHealth(10000) mybear:AddComponent("combat") mybear.components.combat:SetDefaultDamage(300) mybear.components.combat:SetAttackPeriod(0.5) mybear.components.combat.hiteffectsymbol = "bearger_body" mybear.components.combat:SetAreaDamage(4, 1) mybear.components.combat.playerdamagepercent = 0 mybear.components.combat:SetRange(2, 4) mybear.components.combat:SetHurtSound("dontstarve_DLC001/creatures/bearger/hurt") mybear.components.combat:SetRetargetFunction(1, function(mybear) if not mybear.components.health:IsDead() then return FindEntity(mybear, 25, function(guy) if guy.components.combat then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") end end ) end end ) mybear.components.combat:SetKeepTargetFunction(function(mybear, target) return target and target:IsValid() end ) mybear:ListenForEvent("attacked", function(mybear, data) if data.attacker ~= GetPlayer() then mybear.components.combat:SetTarget(data.attacker) else mybear.components.combat:SetTarget(nil) end end ) mybear:AddComponent("locomotor") mybear.components.locomotor.walkspeed = 15 mybear.components.locomotor.runspeed = 20 mybear.components.locomotor:SetShouldRun(true) mybear:SetStateGraph("SGbearger") local brain = require "brains/abigailbrain" mybear:SetBrain(brain) mybear:AddComponent("trader") mybear.components.trader:SetAcceptTest(function(mybear, item) if item.prefab == "meat" then return mybear.components.health:GetPercent() < 1 end return false end ) mybear.components.trader.onaccept = function(mybear, giver, item) if item.prefab == "meat" then mybear.components.health:DoDelta(2000) end end mybear.components.inspectable.getstatus = function(mybear) if not mybear:HasTag("stophere") then mybear:AddTag("stophere") mybear.components.locomotor:Stop() mybear:SetBrain(nil) mybear.components.follower:SetLeader(nil) mybear.AnimState:PlayAnimation("sleep_loop",true) else mybear:RemoveTag("stophere") local brain = require "brains/abigailbrain" mybear:SetBrain(brain) mybear:RestartBrain() mybear.components.follower:SetLeader(GetPlayer()) end end mybear:AddTag("companion") mybear:AddTag("mybears") inst:Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("mybears") then data.mybears = true end if inst:HasTag("stophere") then data.stophere = true end end local function onload(inst, data) if data and data.mybears then inst.AnimState:SetBank("bearger") inst.AnimState:SetBuild("bearger_build") inst.AnimState:PlayAnimation("idle_loop", true) inst.Transform:SetScale(0.5, 0.5, 0.5) inst.Transform:SetFourFaced() local sound = inst.entity:AddSoundEmitter() local shadow = inst.entity:AddDynamicShadow() shadow:SetSize(3, 1.8) MakeCharacterPhysics(inst, 500, 1) inst:RemoveComponent("equippable") inst:RemoveComponent("inventoryitem") inst:RemoveComponent("fueled") inst:RemoveComponent("deployable") SetStandState(inst, "QUAD") inst.CanGroundPound = false inst.SetStandState = SetStandState inst.IsStandState = function(inst, state) return inst.StandState == string.lower(state) end inst.WorkEntities = function(inst) inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.5, 0.05, 2, 40) end inst:AddComponent("groundpounder") inst.components.groundpounder.destroyer = true inst.components.groundpounder.damageRings = 3 inst.components.groundpounder.destructionRings = 4 inst.components.groundpounder.numRings = 5 inst:AddComponent("named") inst.components.named:SetName("My Bear") inst:AddComponent("inventory") inst:AddComponent("knownlocations") inst:AddComponent("timer") inst:AddComponent("eater") inst.components.eater.foodprefs = {"MEAT"} inst:AddComponent("follower") inst.components.follower:SetLeader(GetPlayer()) inst:AddComponent("lootdropper") inst.components.lootdropper:SetLoot({"meat", "meat", "meat", "meat", "bearger_fur"}) inst:AddComponent("health") inst.components.health:SetMaxHealth(10000) inst:AddComponent("combat") inst.components.combat:SetDefaultDamage(300) inst.components.combat:SetAttackPeriod(0.5) inst.components.combat.hiteffectsymbol = "bearger_body" inst.components.combat:SetAreaDamage(4, 1) inst.components.combat.playerdamagepercent = 0 inst.components.combat:SetRange(2, 4) inst.components.combat:SetHurtSound("dontstarve_DLC001/creatures/bearger/hurt") inst.components.combat:SetRetargetFunction(1, function(inst) if not inst.components.health:IsDead() then return FindEntity(inst, 25, function(guy) if guy.components.combat then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") end end ) end end ) inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) inst:ListenForEvent("attacked", function(inst, data) if data.attacker ~= GetPlayer() then inst.components.combat:SetTarget(data.attacker) else inst.components.combat:SetTarget(nil) end end ) inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 15 inst.components.locomotor.runspeed = 20 inst.components.locomotor:SetShouldRun(true) inst:SetStateGraph("SGbearger") local brain = require "brains/abigailbrain" inst:SetBrain(brain) inst:AddComponent("trader") inst.components.trader:SetAcceptTest(function(inst, item) if item.prefab == "meat" then return inst.components.health:GetPercent() < 1 end return false end ) inst.components.trader.onaccept = function(inst, giver, item) if item.prefab == "meat" then inst.components.health:DoDelta(2000) end end inst.components.inspectable.getstatus = function(inst) if not inst:HasTag("stophere") then inst:AddTag("stophere") inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.follower:SetLeader(nil) inst.AnimState:PlayAnimation("sleep_loop",true) else inst:RemoveTag("stophere") local brain = require "brains/abigailbrain" inst:SetBrain(brain) inst:RestartBrain() inst.components.follower:SetLeader(GetPlayer()) end end inst:AddTag("companion") inst:AddTag("mybears") end if data and data.stophere then inst:AddTag("stophere") inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.follower:SetLeader(nil) inst.AnimState:PlayAnimation("sleep_loop",true) end end inst.OnSave = onsave inst.OnLoad = onload 即可用黄色护身符种宠物熊,它身强力壮,是战斗时的好帮手。鼠标左键点熊,可让它停在原地,再次点击可继续跟随。给宠物熊大肉(拿着大肉对其点鼠标左键),可为它补血,最多5块可补满。不想要宠物熊了,杀死即可(按Ctrl + 鼠标左键攻击),它不会还手。宠物熊行走时会撞碎阻挡的建筑、植物,所以不要让它离你的基地太近。黄色护身符在远古选项(画着远古祭坛)下,用2个铥矿石、3个噩梦燃料、1个黄色宝石制造

2025/04/23 · Bny

YN204-宠物蜻蜓(用蜻蜓盔甲种宠物蜻蜓,攻击力超强,鼠标右键点击可帮你捡地上的物品)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二0四.宠物蜻蜓(用蜻蜓盔甲种宠物蜻蜓,攻击力超强,鼠标右键点击可帮你捡地上的物品) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/armor_dragonfly.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function OnDeploy (inst, pt) local myfly = SpawnPrefab("armordragonfly") myfly.Transform:SetPosition(pt.x, pt.y, pt.z) myfly.AnimState:SetBank("dragonfly") myfly.AnimState:SetBuild("dragonfly_build") myfly.AnimState:PlayAnimation("idle", true) myfly.Transform:SetScale(0.5, 0.5, 0.5) myfly.Transform:SetFourFaced() local sound = myfly.entity:AddSoundEmitter() local shadow = myfly.entity:AddDynamicShadow() shadow:SetSize(3, 1.8) MakeCharacterPhysics(myfly, 50, 0.7) local light = myfly.entity:AddLight() myfly.Light:Enable(false) myfly.Light:SetRadius(2) myfly.Light:SetFalloff(0.5) myfly.Light:SetIntensity(.75) myfly.Light:SetColour(235/255,121/255,12/255) myfly:RemoveComponent("inventoryitem") myfly:RemoveComponent("armor") myfly:RemoveComponent("equippable") myfly:RemoveComponent("deployable") MakeLargePropagator(myfly) myfly.components.propagator.decayrate = 0 myfly:AddComponent("groundpounder") myfly.components.groundpounder.numRings = 2 myfly.components.groundpounder.burner = true myfly.components.groundpounder.groundpoundfx = "firesplash_fx" myfly.components.groundpounder.groundpounddamagemult = .5 myfly.components.groundpounder.groundpoundringfx = "firering_fx" myfly:AddComponent("named") myfly.components.named:SetName("My Dragonfly") myfly:AddComponent("inventory") myfly:AddComponent("knownlocations") myfly:AddComponent("follower") myfly.components.follower:SetLeader(GetPlayer()) myfly:AddComponent("lootdropper") myfly.components.lootdropper:SetLoot({"meat", "meat", "meat", "meat", "dragon_scales"}) myfly:AddComponent("health") myfly.components.health:SetMaxHealth(5000) myfly:AddComponent("combat") myfly.components.combat:SetDefaultDamage(300) myfly.components.combat:SetAttackPeriod(0.5) myfly.components.combat.hiteffectsymbol = "dragonfly_body" myfly.components.combat:SetAreaDamage(6, 0.8) myfly.components.combat.playerdamagepercent = 0 myfly.components.combat:SetRange(4) myfly.components.combat.battlecryenabled = false myfly.components.combat:SetHurtSound("dontstarve_DLC001/creatures/dragonfly/hurt") myfly.components.combat:SetRetargetFunction(1, function(myfly) if not myfly.components.health:IsDead() then return FindEntity(myfly, 25, function(guy) if guy.components.combat then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") end end ) end end ) myfly.components.combat:SetKeepTargetFunction(function(myfly, target) return target and target:IsValid() end ) myfly:ListenForEvent("attacked", function(myfly, data) if data.attacker ~= GetPlayer() then if not data.attacker:HasTag("myflys") then myfly.components.combat:SetTarget(data.attacker) end else myfly.components.health:Kill() end end ) myfly:AddComponent("locomotor") myfly.components.locomotor.walkspeed = 25 myfly:SetStateGraph("SGdragonfly") local brain = require "brains/abigailbrain" myfly:SetBrain(brain) myfly:DoPeriodicTask(5, function() if myfly.components.combat and not myfly.components.combat.target then if myfly.fire_build then myfly.sg:GoToState("flameoff") end if myfly.components.health and myfly.components.health:GetPercent() < 1 then myfly.components.health:DoDelta(200) end end end ) myfly:AddComponent("machine") myfly.components.machine.turnonfn = function() myfly:AddTag("inhaling") myfly.AnimState:SetBloomEffectHandle("shaders/anim.ksh") myfly.task = myfly:DoPeriodicTask(.5, function(myfly) local pos = Vector3(myfly.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 15) for k,v in pairs(ents) do local pt1 = v:GetPosition() if v.components.inventoryitem and v.components.inventoryitem.canbepickedup and v.components.inventoryitem.cangoincontainer and not v.components.inventoryitem:IsHeld() and not v:HasTag("trap") and not v:HasTag("light") and not v:HasTag("blowdart") and not v:HasTag("projectile") then if not GetPlayer().components.inventory:IsFull() then SpawnPrefab("small_puff").Transform:SetPosition(pt1.x, pt1.y, pt1.z) GetPlayer().components.inventory:GiveItem(v) GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available") end end end end ) end myfly.components.machine.turnofffn = function() myfly:RemoveTag("inhaling") myfly.AnimState:SetBloomEffectHandle( "" ) if myfly.task then myfly.task:Cancel() myfly.task = nil end end myfly.components.inspectable.getstatus = function(myfly) if not myfly:HasTag("stophere") then myfly:AddTag("stophere") myfly.components.locomotor:Stop() myfly:SetBrain(nil) myfly.components.follower:SetLeader(nil) myfly.sg:GoToState("flameoff") else myfly:RemoveTag("stophere") local brain = require "brains/abigailbrain" myfly:SetBrain(brain) myfly:RestartBrain() myfly.components.follower:SetLeader(GetPlayer()) end end myfly:ListenForEvent("death", function() myfly.components.machine:TurnOff() end ) myfly:AddTag("companion") myfly:AddTag("myflys") inst:Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("myflys") then data.myflys = true end if inst:HasTag("stophere") then data.stophere = true end if inst:HasTag("inhaling") then data.inhaling = true end end local function onload(inst, data) if data and data.myflys then inst.AnimState:SetBank("dragonfly") inst.AnimState:SetBuild("dragonfly_build") inst.AnimState:PlayAnimation("idle", true) inst.Transform:SetScale(0.5, 0.5, 0.5) inst.Transform:SetFourFaced() local sound = inst.entity:AddSoundEmitter() local shadow = inst.entity:AddDynamicShadow() shadow:SetSize(3, 1.8) MakeCharacterPhysics(inst, 50, 0.7) local light = inst.entity:AddLight() inst.Light:Enable(false) inst.Light:SetRadius(2) inst.Light:SetFalloff(0.5) inst.Light:SetIntensity(.75) inst.Light:SetColour(235/255,121/255,12/255) inst:RemoveComponent("inventoryitem") inst:RemoveComponent("armor") inst:RemoveComponent("equippable") inst:RemoveComponent("deployable") MakeLargePropagator(inst) inst.components.propagator.decayrate = 0 inst:AddComponent("groundpounder") inst.components.groundpounder.numRings = 2 inst.components.groundpounder.burner = true inst.components.groundpounder.groundpoundfx = "firesplash_fx" inst.components.groundpounder.groundpounddamagemult = .5 inst.components.groundpounder.groundpoundringfx = "firering_fx" inst:AddComponent("named") inst.components.named:SetName("My Dragonfly") inst:AddComponent("inventory") inst:AddComponent("knownlocations") inst:AddComponent("follower") inst.components.follower:SetLeader(GetPlayer()) inst:AddComponent("lootdropper") inst.components.lootdropper:SetLoot({"meat", "meat", "meat", "meat", "dragon_scales"}) inst:AddComponent("health") inst.components.health:SetMaxHealth(5000) inst:AddComponent("combat") inst.components.combat:SetDefaultDamage(300) inst.components.combat:SetAttackPeriod(0.5) inst.components.combat.hiteffectsymbol = "dragonfly_body" inst.components.combat:SetAreaDamage(6, 0.8) inst.components.combat.playerdamagepercent = 0 inst.components.combat:SetRange(4) inst.components.combat.battlecryenabled = false inst.components.combat:SetHurtSound("dontstarve_DLC001/creatures/dragonfly/hurt") inst.components.combat:SetRetargetFunction(1, function(inst) if not inst.components.health:IsDead() then return FindEntity(inst, 25, function(guy) if guy.components.combat then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") end end ) end end ) inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) inst:ListenForEvent("attacked", function(inst, data) if data.attacker ~= GetPlayer() then if not data.attacker:HasTag("myflys") then inst.components.combat:SetTarget(data.attacker) end else inst.components.health:Kill() end end ) inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 25 inst:SetStateGraph("SGdragonfly") local brain = require "brains/abigailbrain" inst:SetBrain(brain) inst:DoPeriodicTask(5, function() if inst.components.combat and not inst.components.combat.target then if inst.fire_build then inst.sg:GoToState("flameoff") end if inst.components.health and inst.components.health:GetPercent() < 1 then inst.components.health:DoDelta(200) end end end ) inst:AddComponent("machine") inst.components.machine.turnonfn = function() inst:AddTag("inhaling") inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") inst.task = inst:DoPeriodicTask(.5, function(inst) local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 15) for k,v in pairs(ents) do local pt1 = v:GetPosition() if v.components.inventoryitem and v.components.inventoryitem.canbepickedup and v.components.inventoryitem.cangoincontainer and not v.components.inventoryitem:IsHeld() and not v:HasTag("trap") and not v:HasTag("light") and not v:HasTag("blowdart") and not v:HasTag("projectile") then if not GetPlayer().components.inventory:IsFull() then SpawnPrefab("small_puff").Transform:SetPosition(pt1.x, pt1.y, pt1.z) GetPlayer().components.inventory:GiveItem(v) GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available") end end end end ) end inst.components.machine.turnofffn = function() inst:RemoveTag("inhaling") inst.AnimState:SetBloomEffectHandle( "" ) if inst.task then inst.task:Cancel() inst.task = nil end end inst.components.inspectable.getstatus = function(inst) if not inst:HasTag("stophere") then inst:AddTag("stophere") inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.follower:SetLeader(nil) inst.sg:GoToState("flameoff") else inst:RemoveTag("stophere") local brain = require "brains/abigailbrain" inst:SetBrain(brain) inst:RestartBrain() inst.components.follower:SetLeader(GetPlayer()) end end inst:ListenForEvent("death", function() inst.components.machine:TurnOff() end ) inst:AddTag("companion") inst:AddTag("myflys") end if data and data.stophere then inst:AddTag("stophere") inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.follower:SetLeader(nil) inst.sg:GoToState("flameoff") end if data and data.inhaling then inst.components.machine.ison = true inst.components.machine:TurnOn() end end inst.OnSave = onsave inst.OnLoad = onload 即可用蜻蜓盔甲种宠物蜻蜓,攻击力超强,并自动补血,是战斗时的好帮手。鼠标左键点蜻蜓,可让它停在原地,再次点击可继续跟随。鼠标右键点蜻蜓,可让它帮你捡地上的东西(快速吸取至主角物品栏),再次点击可停止捡东西。不想要宠物蜻蜓了,杀死即可(按Ctrl + 鼠标左键攻击),打一下即死。宠物蜻蜓攻击时会引发火灾,所以带它战斗时不要离基地太近,也不要同时带1个以上的宠物蜻蜓去战斗,否则容易互殴。蜻蜓盔甲在战斗选项(画着两把剑)下,用1个蜻蜓鳞片、1个木盔甲、3个猪皮制造

2025/04/23 · Bny

YN205-统御战狼(按键盘X键召唤战狼,誓死护卫你,给5块疯肉升级为金刚战狼)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二0五.统御战狼(按键盘X键召唤战狼,誓死护卫你,给5块疯肉升级为金刚战狼) 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playercontroller")的下一行插入以下内容: TheInput:AddKeyUpHandler(KEY_X, function() if inst.components.inventory:Has("goldnugget", 20) then inst.components.inventory:ConsumeByName("goldnugget", 20) inst.AnimState:PlayAnimation("give") inst.SoundEmitter:PlaySound("dontstarve/common/horn_beefalo") local mywolf = SpawnPrefab("greenamulet") local pt = GetPlayer():GetPosition() mywolf.Transform:SetPosition(pt.x+(math.random(3)-math.random(3)), 0, pt.z+(math.random(3)-math.random(3))) mywolf.AnimState:SetBank("warg") mywolf.AnimState:SetBuild("warg_build") mywolf.AnimState:PlayAnimation("idle") mywolf.Transform:SetScale(0.6, 0.6, 0.6) mywolf.Transform:SetFourFaced() local sound = mywolf.entity:AddSoundEmitter() local shadow = mywolf.entity:AddDynamicShadow() shadow:SetSize(1.2, 0.7) MakeCharacterPhysics(mywolf, 100, 1) mywolf:RemoveComponent("equippable") mywolf:RemoveComponent("inventoryitem") mywolf:RemoveComponent("finiteuses") mywolf:RemoveComponent("deployable") mywolf:AddComponent("named") mywolf.components.named:SetName("Wolf") mywolf:AddComponent("follower") mywolf.components.follower:SetLeader(GetPlayer()) mywolf:AddComponent("lootdropper") mywolf.components.lootdropper:SetLoot({"monstermeat", "houndstooth"}) mywolf:AddComponent("health") mywolf.components.health:SetMaxHealth(1000) mywolf.components.health:StartRegen(50, 10) mywolf:AddComponent("combat") mywolf.components.combat:SetDefaultDamage(50) mywolf.components.combat:SetAttackPeriod(0.5) mywolf.components.combat:SetRange(3) mywolf.components.combat:SetRetargetFunction(1, function(mywolf) if not mywolf.components.health:IsDead() then return FindEntity(mywolf, 25, function(guy) if guy.components.combat then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") end end ) end end ) mywolf.components.combat:SetKeepTargetFunction(function(mywolf, target) return target and target:IsValid() end ) mywolf:ListenForEvent("attacked", function(mywolf, data) if data.attacker ~= GetPlayer() then mywolf.components.combat:SetTarget(data.attacker) mywolf.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("mywolfs") and not dude.components.health:IsDead() end, 10) else mywolf.components.health:Kill() end end ) mywolf:AddComponent("locomotor") mywolf.components.locomotor.runspeed = 18 mywolf.components.locomotor:SetShouldRun(true) mywolf:SetStateGraph("SGwarg") local brain = require "brains/abigailbrain" mywolf:SetBrain(brain) mywolf:AddComponent("trader") mywolf.components.trader:SetAcceptTest(function(mywolf, item) if GetPlayer().components.inventory:Has("monstermeat", 5) then if item.prefab == "monstermeat" then if not mywolf:HasTag("superwolf") then return true end end end return false end ) mywolf.components.trader.onaccept = function(mywolf, giver, item) if item.prefab == "monstermeat" then giver.components.inventory:ConsumeByName("monstermeat", 4) mywolf:AddTag("superwolf") mywolf.components.named:SetName("Super Wolf") mywolf.AnimState:SetBloomEffectHandle("shaders/anim.ksh") mywolf.Transform:SetScale(0.7, 0.7, 0.7) mywolf.components.health:SetMaxHealth(2000) mywolf.components.health:DoDelta(2000) mywolf.components.combat:SetDefaultDamage(100) mywolf.components.locomotor.runspeed = 25 end end mywolf.components.inspectable.getstatus = function(mywolf) if not mywolf:HasTag("stophere") then mywolf:AddTag("stophere") mywolf.components.locomotor:Stop() mywolf:SetBrain(nil) mywolf.components.follower:SetLeader(nil) else mywolf:RemoveTag("stophere") local brain = require "brains/abigailbrain" mywolf:SetBrain(brain) mywolf:RestartBrain() mywolf.components.follower:SetLeader(GetPlayer()) end end mywolf:AddTag("companion") mywolf:AddTag("mywolfs") end end ) 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/amulet.lua文件,在inst.AnimState:PlayAnimation("greenamulet")的下一行插入以下内容: local function onsave(inst, data) if inst:HasTag("mywolfs") then data.mywolfs = true end if inst:HasTag("superwolf") then data.superwolf = true end if inst:HasTag("stophere") then data.stophere = true end end local function onload(inst, data) if data and data.mywolfs then inst.AnimState:SetBank("warg") inst.AnimState:SetBuild("warg_build") inst.AnimState:PlayAnimation("idle") inst.Transform:SetScale(0.6, 0.6, 0.6) inst.Transform:SetFourFaced() local sound = inst.entity:AddSoundEmitter() local shadow = inst.entity:AddDynamicShadow() shadow:SetSize(1.2, 0.7) MakeCharacterPhysics(inst, 100, 1) inst:RemoveComponent("equippable") inst:RemoveComponent("inventoryitem") inst:RemoveComponent("finiteuses") inst:RemoveComponent("deployable") inst:AddComponent("named") inst.components.named:SetName("Wolf") inst:AddComponent("follower") inst.components.follower:SetLeader(GetPlayer()) inst:AddComponent("lootdropper") inst.components.lootdropper:SetLoot({"monstermeat", "houndstooth"}) inst:AddComponent("health") inst.components.health:SetMaxHealth(1000) inst.components.health:StartRegen(50, 10) inst:AddComponent("combat") inst.components.combat:SetDefaultDamage(50) inst.components.combat:SetAttackPeriod(0.5) inst.components.combat:SetRange(3) inst.components.combat:SetRetargetFunction(1, function(inst) if not inst.components.health:IsDead() then return FindEntity(inst, 25, function(guy) if guy.components.combat then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") end end ) end end ) inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) inst:ListenForEvent("attacked", function(inst, data) if data.attacker ~= GetPlayer() then inst.components.combat:SetTarget(data.attacker) inst.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("mywolfs") and not dude.components.health:IsDead() end, 10) else inst.components.health:Kill() end end ) inst:AddComponent("locomotor") inst.components.locomotor.runspeed = 18 inst.components.locomotor:SetShouldRun(true) inst:SetStateGraph("SGwarg") local brain = require "brains/abigailbrain" inst:SetBrain(brain) inst:AddComponent("trader") inst.components.trader:SetAcceptTest(function(inst, item) if GetPlayer().components.inventory:Has("monstermeat", 5) then if item.prefab == "monstermeat" then if not inst:HasTag("superwolf") then return true end end end return false end ) inst.components.trader.onaccept = function(inst, giver, item) if item.prefab == "monstermeat" then giver.components.inventory:ConsumeByName("monstermeat", 4) inst:AddTag("superwolf") inst.components.named:SetName("Super Wolf") inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") inst.Transform:SetScale(0.7, 0.7, 0.7) inst.components.health:SetMaxHealth(2000) inst.components.health:DoDelta(2000) inst.components.combat:SetDefaultDamage(100) inst.components.locomotor.runspeed = 25 end end inst.components.inspectable.getstatus = function(inst) if not inst:HasTag("stophere") then inst:AddTag("stophere") inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.follower:SetLeader(nil) else inst:RemoveTag("stophere") local brain = require "brains/abigailbrain" inst:SetBrain(brain) inst:RestartBrain() inst.components.follower:SetLeader(GetPlayer()) end end inst:AddTag("companion") inst:AddTag("mywolfs") end if data and data.superwolf then inst:AddTag("superwolf") inst.components.named:SetName("Super Wolf") inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") inst.Transform:SetScale(0.7, 0.7, 0.7) inst.components.health:SetMaxHealth(2000) inst.components.health:DoDelta(2000) inst.components.combat:SetDefaultDamage(100) inst.components.locomotor.runspeed = 25 end if data and data.stophere then inst:AddTag("stophere") inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.follower:SetLeader(nil) end end inst.OnSave = onsave inst.OnLoad = onload 即可按键盘X键召唤战狼,每只花费20个黄金,身上黄金数不足时无法召唤。战狼极其忠诚,会誓死护卫你,鼠标左键点击可停在原地,再次点击则继续跟随。如果想赐战狼死,用任何武器打击一下即可(按Ctrl + 鼠标左键攻击),它不会还击。战狼生命力顽强,会自动回血。当一只战狼遭到攻击时,其他战狼会围攻敌人。给战狼5块疯肉(拿着疯肉对战狼点鼠标左键),可将其升级为金刚战狼,生命值、攻击力、速度会大幅提升。统御你的战狼部队,横扫大陆吧

2025/04/23 · Bny