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

YN206-糖豆敢死队(按键盘T键召唤糖豆敢死队,对敌发动自杀式爆炸,鼠标左键点击可退钱)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二0六.糖豆敢死队(按键盘T键召唤糖豆敢死队,对敌发动自杀式爆炸,鼠标左键点击可退钱) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playercontroller")的下一行插入以下内容: TheInput:AddKeyUpHandler(KEY_T, function() if inst.components.inventory:Has("goldnugget", 2) then inst.components.inventory:ConsumeByName("goldnugget", 2) inst.AnimState:PlayAnimation("give") inst.SoundEmitter:PlaySound("dontstarve/HUD/research_available") local bean = SpawnPrefab("goatmilk") local pt = GetPlayer():GetPosition() bean.Transform:SetPosition(pt.x+(math.random(3)-math.random(3)), 0, pt.z+(math.random(3)-math.random(3))) SpawnPrefab("collapse_small").Transform:SetPosition(bean.Transform:GetWorldPosition()) bean.AnimState:SetBank("treedrake") bean.AnimState:SetBuild("treedrake_build") bean.AnimState:PlayAnimation("enter") bean.AnimState:SetBloomEffectHandle("shaders/anim.ksh") bean.Transform:SetScale(1.2, 1.2, 1.2) bean.Transform:SetFourFaced() local sound = bean.entity:AddSoundEmitter() local shadow = bean.entity:AddDynamicShadow() shadow:SetSize(1.25, .75) MakeCharacterPhysics(bean, 1, .25) local colours= { {198/255,43/255,43/255}, {79/255,153/255,68/255}, {35/255,105/255,235/255}, {233/255,208/255,69/255}, {109/255,50/255,163/255}, {222/255,126/255,39/255} } bean.colour_idx = math.random(#colours) bean.AnimState:SetMultColour(colours[bean.colour_idx][1],colours[bean.colour_idx][2],colours[bean.colour_idx][3],1) bean:RemoveComponent("edible") bean:RemoveComponent("perishable") bean:RemoveComponent("stackable") bean:RemoveComponent("inventoryitem") bean:RemoveTag("catfood") bean.persists = false bean:AddComponent("named") bean.components.named:SetName("Jelly Bean") bean:AddComponent("follower") bean.components.follower:SetLeader(GetPlayer()) bean:AddComponent("health") bean.components.health:SetMaxHealth(10) bean.components.health:SetInvincible(true) bean:AddComponent("combat") bean.components.combat:SetDefaultDamage(1) bean.components.combat:SetAttackPeriod(2) bean.components.combat:SetRange(0.5) bean.components.combat:SetRetargetFunction(1, function(bean) if not bean.components.health:IsDead() then return FindEntity(bean, 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 ) bean.components.combat:SetKeepTargetFunction(function(bean, target) return target and target:IsValid() end ) bean:AddComponent("locomotor") bean.components.locomotor.walkspeed = 15 bean:SetStateGraph("SGbirchnutdrake") local brain = require "brains/abigailbrain" bean:SetBrain(brain) bean:DoPeriodicTask(0.25, function() local pos = Vector3(bean.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 2) for k,v in pairs(ents) do if v and v.components.combat and v.components.health and not v.components.health:IsDead() then if v.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == v or v.components.combat.target == bean or bean.components.combat.target == v or v:HasTag("monster") then GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition()) SpawnPrefab("explode_small").Transform:SetPosition(v.Transform:GetWorldPosition()) GetClock():DoLightningLighting() GetPlayer().components.playercontroller:ShakeCamera(v, "FULL", 0.7, 0.02, .5, 40) v.components.health:Kill() bean:Remove() end end end end ) bean.components.inspectable.getstatus = function(bean) inst.SoundEmitter:PlaySound("dontstarve/HUD/research_available") SpawnPrefab("collapse_small").Transform:SetPosition(bean.Transform:GetWorldPosition()) for k = 1, 2 do local goldnugget = SpawnPrefab("goldnugget") inst.components.inventory:GiveItem(goldnugget) end bean:Remove() end bean:AddTag("companion") bean:AddTag("beans") end end ) 即可按键盘T键召唤糖豆敢死队,花费2个黄金,身上黄金数不足时无法召唤。糖豆敢死队员将冲向你的敌人,对其发动自杀式爆炸,并杀伤周边敌人。鼠标点击多余的糖豆敢死队员,可清退它们,换回2个黄金(放入主角物品栏)。存档退出后再读档,糖豆敢死队将离开,在之前将它们都清退掉吧

2025/04/23 · Bny

YN207-斗牛场(用牛角种斗牛场,与公牛搏斗赢奖金,观众会向场内扔额外赏金)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二0七.斗牛场(用牛角种斗牛场,与公牛搏斗赢奖金,观众会向场内扔额外赏金) 用MT管理器打开游戏目录/assets/scripts/prefabs/horn.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 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 makebullring(inst) local pt = inst:GetPosition() local bullring0 = SpawnPrefab("horn") bullring0.Transform:SetPosition(pt.x, pt.y, pt.z) bullring0.AnimState:SetBank("marble_trees") bullring0.AnimState:SetBuild("marble_trees") bullring0.AnimState:PlayAnimation("full_4") bullring0.Transform:SetScale(1.5, 1.5, 1.5) bullring0:RemoveComponent("instrument") bullring0:RemoveComponent("tool") bullring0:RemoveComponent("finiteuses") bullring0:RemoveComponent("inventoryitem") bullring0:RemoveComponent("deployable") bullring0:RemoveTag("horn") bullring0:AddComponent("named") bullring0.components.named:SetName("Bullring") local light = bullring0.entity:AddLight() light:SetFalloff(1) light:SetIntensity(.8) light:SetRadius(15) light:SetColour(180/255, 195/255, 50/255) light:Enable(true) bullring0:AddComponent("workable") bullring0.components.workable:SetWorkAction(ACTIONS.HAMMER) bullring0.components.workable:SetWorkLeft(3) bullring0.components.workable:SetOnFinishCallback(function() SpawnPrefab("collapse_big").Transform:SetPosition(bullring0.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") local pos = Vector3(bullring0.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 10) for k,v in pairs(ents) do if v:HasTag("nobullring") then v:Remove() end end bullring0:Remove() end ) bullring0.components.inspectable.getstatus = function(bullring0) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/horn_beefalo") local bullfighting = SpawnPrefab("horn") bullfighting.Transform:SetPosition(pt.x+2, 0, pt.z+2) bullfighting.AnimState:SetBank("beefalo") bullfighting.AnimState:SetBuild("beefalo_build") bullfighting.AnimState:PlayAnimation("idle_loop", true) bullfighting.Transform:SetFourFaced() bullfighting.Transform:SetScale(1.3, 1.3, 1.3) local sound = bullfighting.entity:AddSoundEmitter() bullfighting.sounds = sounds local shadow = bullfighting.entity:AddDynamicShadow() shadow:SetSize( 3, 1.25 ) MakeCharacterPhysics(bullfighting, 200, 1.3) bullfighting:RemoveComponent("instrument") bullfighting:RemoveComponent("tool") bullfighting:RemoveComponent("finiteuses") bullfighting:RemoveComponent("inventoryitem") bullfighting:RemoveComponent("deployable") bullfighting:RemoveTag("horn") bullfighting:AddComponent("named") bullfighting.components.named:SetName("Bullfighting") bullfighting:AddComponent("locomotor") bullfighting.components.locomotor.walkspeed = math.random(4,6) bullfighting.components.locomotor.runspeed = math.random(8,10) bullfighting:SetStateGraph("SGBeefalo") local brain = require "brains/leifbrain" bullfighting:SetBrain(brain) bullfighting:AddComponent("follower") bullfighting:AddComponent("knownlocations") bullfighting:AddComponent("lootdropper") bullfighting.components.lootdropper:SetLoot({"meat","meat","meat","meat","meat","meat","beefalowool","beefalowool","beefalowool","beefalowool"}) bullfighting.components.lootdropper:AddChanceLoot("horn", 0.1) bullfighting:AddComponent("health") bullfighting.components.health:SetMaxHealth(math.random(3000,7000)) bullfighting:AddComponent("combat") bullfighting.components.combat:SetTarget(GetPlayer()) bullfighting.components.combat.hiteffectsymbol = "beefalo_body" bullfighting.components.combat:SetDefaultDamage(math.random(30,70)) bullfighting.components.combat:SetAttackPeriod(math.random(1,3)) bullfighting.components.combat:SetRetargetFunction(1, function(bullfighting) if not bullfighting.components.health:IsDead() then return FindEntity(bullfighting, 200, function(guy) if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("bullfighting") then return guy:HasTag("player") end end ) end end ) bullfighting.components.combat:SetKeepTargetFunction(function(bullfighting, target) return target and target:IsValid() end ) bullfighting:ListenForEvent("death", function() for k = 1, 30 do local goldnugget = SpawnPrefab("goldnugget") GetPlayer().components.inventory:GiveItem(goldnugget) end GetPlayer():StartThread(function() for k = 1, math.random(3,10) do GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") local bounty = SpawnPrefab("goldnugget") bounty.Transform:SetPosition(pt.x, pt.y, pt.z) bounty.components.inventoryitem.canbepickedup = false bounty:AddComponent("complexprojectile") bounty.components.complexprojectile.yOffset = 2.5 bounty.components.complexprojectile:Launch(Point(pt.x+(math.random(6,10)-math.random(5)), 0, pt.z+(math.random(6,10)-math.random(5)))) bounty.components.complexprojectile:SetOnHit(function() bounty:RemoveComponent("complexprojectile") bounty.components.inventoryitem.canbepickedup = true end ) Sleep(0.15) end end ) end ) bullfighting:DoTaskInTime(60, function() if not bullfighting.components.health:IsDead() then SpawnPrefab("die_fx").Transform:SetPosition(bullfighting.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") bullfighting:Remove() end end ) bullfighting:AddTag("bullfighting") end bullring0:AddTag("bullring0") local bullring1 = SpawnPrefab("horn") bullring1.Transform:SetPosition(pt.x+2.5, 0, pt.z-2.5) bullring1.AnimState:SetBank("marble_trees") bullring1.AnimState:SetBuild("marble_trees") bullring1.AnimState:PlayAnimation("full_4") bullring1.Transform:SetScale(0.8, 0.8, 0.8) bullring1:RemoveComponent("instrument") bullring1:RemoveComponent("tool") bullring1:RemoveComponent("finiteuses") bullring1:RemoveComponent("inventoryitem") bullring1:RemoveComponent("deployable") bullring1:RemoveTag("horn") bullring1:AddTag("NOCLICK") bullring1:AddTag("nobullring") local bullring2 = SpawnPrefab("horn") bullring2.Transform:SetPosition(pt.x-2.5, 0, pt.z+2.5) bullring2.AnimState:SetBank("marble_trees") bullring2.AnimState:SetBuild("marble_trees") bullring2.AnimState:PlayAnimation("full_4") bullring2.Transform:SetScale(0.8, 0.8, 0.8) bullring2:RemoveComponent("instrument") bullring2:RemoveComponent("tool") bullring2:RemoveComponent("finiteuses") bullring2:RemoveComponent("inventoryitem") bullring2:RemoveComponent("deployable") bullring2:RemoveTag("horn") bullring2:AddTag("NOCLICK") bullring2:AddTag("nobullring") for k = 0,6 do local audience = SpawnPrefab("horn") audience.Transform:SetPosition(pt.x-2+6-k*2, 0, pt.z-2-6+k*2) audience.AnimState:SetBank("wilson") local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} local buildname = names[math.random(#names)] audience.AnimState:SetBuild(buildname) local hats = {"hat_bee","hat_beefalo","hat_bush","hat_earmuffs","hat_feather","hat_flower","hat_football","hat_miner","hat_ruins","hat_slurper","hat_slurtle","hat_spider","hat_straw","hat_top","hat_walrus","hat_winter","hat_rain","hat_watermelon","hat_ice","hat_catcoon","hat_wathgrithr"} local hat = hats[math.random(#hats)] audience.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") local armors = {"armor_grass","armor_marble","armor_onemanband","armor_ruins","armor_sanity","armor_slurper","armor_slurtleshell","armor_sweatervest","armor_trunkvest_summer","armor_trunkvest_winter","armor_wood","torso_rain"} local armor = armors[math.random(#armors)] audience.AnimState:OverrideSymbol("swap_body", armor, "swap_body") audience.AnimState:Show("HAT") audience.AnimState:Show("HAT_HAIR") audience.AnimState:Hide("HAIR_NOHAT") audience.AnimState:Hide("HAIR") audience.AnimState:Hide("ARM_carry") audience.AnimState:Show("ARM_normal") local stories = {"idle","hungry","eat","dart","throw","atk","idle_onemanband1_loop","run_pst","item_hat","give"} local story = stories[math.random(#stories)] audience.AnimState:PlayAnimation(story,true) audience.Transform:SetFourFaced() audience:RemoveComponent("instrument") audience:RemoveComponent("tool") audience:RemoveComponent("finiteuses") audience:RemoveComponent("inventoryitem") audience:RemoveComponent("deployable") audience:RemoveTag("horn") audience:AddTag("NOCLICK") audience:AddTag("nobullring") end end local function OnDeploy (inst, pt) makebullring(inst) inst:Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("bullring0") then data.bullring0 = true end if inst:HasTag("bullfighting") then data.bullfighting = true end if inst:HasTag("nobullring") then data.nobullring = true end end local function onload(inst, data) if data and data.bullring0 then makebullring(inst) inst:Remove() end if data and data.bullfighting then inst:Remove() end if data and data.nobullring then inst:Remove() end end inst.OnSave = onsave inst.OnLoad = onload 即可用牛角种斗牛场,鼠标左键点中间的大理石树,会冲出公牛,1分钟内战胜它,可获得30个黄金的奖金(直接放入主角物品栏),和大肉、牛毛等战利品。如未能获胜,1分钟后公牛将消失。每次冲出的公牛,血量、攻击力、攻击节奏、速度都不同,这次打不赢,不代表下次不会胜利哦。场外会有观众为你喝彩,如果你获胜,他们会向场内扔黄金(数量不等),作为你额外的奖励。不想要斗牛场了,用锤子砸掉中间的大理石树即可

2025/04/23 · Bny

YN208-鱼人入侵(每个傍晚都可能遭到众多鱼人的伏击)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二0八.鱼人入侵(每个傍晚都可能遭到众多鱼人的伏击) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/forest.lua文件,在inst:AddComponent("frograin")的下一行插入以下内容: local function OnNight(inst) local player = GetPlayer() local pt = Vector3(player.Transform:GetWorldPosition()) local nummerms = math.random(15) local ground = GetWorld() if math.random()< .2 then for k = 1, nummerms do local theta = 1 * 2 * PI local radius = 12 local result_offset = FindValidPositionByFan(theta, radius, nummerms, function(offset) local x,y,z = (pt + offset):Get() local ents = TheSim:FindEntities(x,y,z , 1) return not next(ents) end) if result_offset and ground.Map:GetTileAtPoint((pt + result_offset):Get()) ~= GROUND.IMPASSABLE then local merm = SpawnPrefab("merm") merm.Transform:SetPosition((pt + result_offset):Get()) merm.components.combat.target = player GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .25, 40) local fx = SpawnPrefab("collapse_small") local pos = pt + result_offset fx.Transform:SetPosition(pos.x, pos.y, pos.z) end end end end inst:ListenForEvent( "dusktime", function() OnNight( inst ) end, GetWorld()) 即可让主角在地面时,每天傍晚都有一定概率遭到众多鱼人(数字随机)的伏击。建议鱼人人数少时就和它们拼了,人数多时就跑,它们会暂时占据这个地区,等到白天它们睡着时再各个击破

2025/04/23 · Bny

YN209-宝物猎人(地面每天出宝贝,限时寻宝赢奖金)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二0九.宝物猎人(地面每天出宝贝,限时寻宝赢奖金) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/forest.lua文件,在inst:AddComponent("hunter")的下一行插入以下内容: local function OnDay(inst) local names = {"trinket_1","trinket_2","trinket_3","trinket_4","trinket_5","trinket_6","trinket_7","trinket_8","trinket_9","trinket_10","trinket_11","trinket_12"} inst.name = names[math.random(#names)] local player = GetPlayer() local pt = Vector3(player.Transform:GetWorldPosition()) local gold = SpawnPrefab(inst.name) gold.Transform:SetPosition(pt.x+(math.random(500)-math.random(500)), 0, pt.z+(math.random(500)-math.random(500))) gold:RemoveComponent("tradable") gold:RemoveComponent("stackable") local minimap = gold.entity:AddMiniMapEntity() minimap:SetIcon( "abigail_flower.png" ) inst:DoTaskInTime(60+math.random(5), function() if not gold.components.inventoryitem:IsHeld() then SpawnPrefab("collapse_small").Transform:SetPosition(gold.Transform:GetWorldPosition()) SpawnPrefab("collapse_small").Transform:SetPosition(player.Transform:GetWorldPosition()) player.SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") else for k = 1, 10+math.random(10) do SpawnPrefab("goldnugget").Transform:SetPosition(player.Transform:GetWorldPosition()) player.SoundEmitter:PlaySound("dontstarve/HUD/get_gold") end end gold:Remove() end) end inst:ListenForEvent( "daytime", function() OnDay(inst) end, GetWorld()) 即可在每天天亮时,地面随机出现宝物(12种收藏品之一),小地图上将显示红花的图标,在1分钟内捡到就可获得奖金,错过时间宝物将消失(生起一团烟就说明寻宝失败)。当寻宝计时结束,你也已经捡到宝物的话,将获得10-20个黄金的奖励(出现在脚下)。注意,宝物很有可能出现在海上,如果没有修改过“地图全开”、“主角可渡海”,就只能望洋兴叹了

2025/04/23 · Bny

YN210-无尽的任务(点路牌接任务,讨伐怪物赚赏金)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二一0.无尽的任务(点路牌接任务,讨伐怪物赚赏金) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/homesign.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function GetStatus(inst) if not inst:HasTag("westart") then GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available") inst:AddTag("westart") inst.AnimState:SetMultColour(255/255,0/255,0/255,1) local names = {"spiderqueen","deerclops","leif_sparse","minotaur","knight","bishop","rook","firehound"} local name = names[math.random(#names)] local bonuspoints = math.random(6) local pt = inst:GetPosition() local wanted = SpawnPrefab(name) wanted.Transform:SetPosition(pt.x+(math.random(300)-math.random(300)), 0, pt.z+(math.random(300)-math.random(300))) wanted.components.health:SetMaxHealth(1000 * bonuspoints) wanted.components.health:DoDelta(1000 * bonuspoints) wanted.AnimState:SetMultColour(255/255,0/255,0/255,1) wanted.Transform:SetScale(1.5, 1.5, 1.5) local minimap = wanted.entity:AddMiniMapEntity() minimap:SetIcon( "lucy_axe.png" ) wanted:ListenForEvent("death", function() inst:RemoveTag("westart") inst.AnimState:SetMultColour(35/255,105/255,235/255,1) for k = 1, 20*bonuspoints do SpawnPrefab("goldnugget").Transform:SetPosition(GetPlayer().Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") end end ) inst:DoTaskInTime(180, function() if not wanted.components.health:IsDead() then SpawnPrefab("die_fx").Transform:SetPosition(wanted.Transform:GetWorldPosition()) SpawnPrefab("die_fx").Transform:SetPosition(GetPlayer().Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") wanted:Remove() inst:RemoveTag("westart") inst.AnimState:SetMultColour(35/255,105/255,235/255,1) end end) end end inst.components.inspectable.getstatus = GetStatus inst.AnimState:SetMultColour(35/255,105/255,235/255,1) 即可点路牌接任务,地图随机位置将出现一个被通缉的怪物,全身红色,小地图上显示为红色斧子图标,血量随机在1000-6000点,不由怪物品种决定(1只狗可能拥有6000的血量)。在3分钟内(游戏中6个小时)找到并杀死它,即讨伐成功,赏金会出现在主角身边,错过时间则任务失败(升起黑烟),被通缉的怪物将人间蒸发。赏金为20-120个黄金,杀死的怪物血量越高,赏金越高。怪物有可能出现在海上,如果没有修改过“地图全开”、“主角可渡海”,就只能望洋兴叹了。这是一个无尽的任务系统,如果同时修改了“巨型超市”,则可以用赏金购买造装备的材料及补血料理,从此开始赏金猎人的生涯吧

2025/04/23 · Bny

YN211-无限进化(给远古祭坛500个黄金,升级主角血量、饥饿、脑最大值各100点)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二一一.无限进化(给远古祭坛500个黄金,升级主角血量、饥饿、脑最大值各100点) 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,将下列内容: inst:AddComponent("health") inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH) inst.components.health.nofadeout = true ------- inst:AddComponent("hunger") inst.components.hunger:SetMax(TUNING.WILSON_HUNGER) inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE) inst.components.hunger:SetKillRate(TUNING.WILSON_HEALTH/TUNING.STARVE_KILL_TIME) inst:AddComponent("sanity") inst.components.sanity:SetMax(TUNING.WILSON_SANITY) inst.components.sanity.onSane = OnSane inst.components.sanity.onInsane = OnInsane 替换为: local function newupgrades(inst) inst.components.health.maxhealth = TUNING.WILSON_HEALTH + inst.level_num*100 inst.components.hunger.max = TUNING.WILSON_HUNGER + inst.level_num*100 inst.components.sanity.max = TUNING.WILSON_SANITY + inst.level_num*100 end inst.level_num = 0 inst:AddComponent("health") inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH + inst.level_num*100) inst.components.health.nofadeout = true inst:AddComponent("hunger") inst.components.hunger:SetMax(TUNING.WILSON_HUNGER + inst.level_num*100) inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE) inst.components.hunger:SetKillRate(TUNING.WILSON_HEALTH/TUNING.STARVE_KILL_TIME) inst:AddComponent("sanity") inst.components.sanity:SetMax(TUNING.WILSON_SANITY + inst.level_num*100) inst.components.sanity.onSane = OnSane inst.components.sanity.onInsane = OnInsane newupgrades(inst) local function onsave(inst, data) data.level_num = inst.level_num end local function onload(inst, data) inst.level_num = data.level_num or 0 inst.components.health.maxhealth = TUNING.WILSON_HEALTH + inst.level_num*100 inst.components.hunger.max = TUNING.WILSON_HUNGER + inst.level_num*100 inst.components.sanity.max = TUNING.WILSON_SANITY + inst.level_num*100 if data.health and data.health.health then inst.components.health.currenthealth = data.health.health end if data.hunger and data.hunger.hunger then inst.components.hunger.current = data.hunger.hunger end if data.sanity and data.sanity.current then inst.components.sanity.current = data.sanity.current end end inst.OnSave = onsave inst.OnLoad = onload 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/altar_prototyper.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function ShouldAcceptItem(inst, item) local player = GetPlayer() if player.components.inventory:Has("goldnugget", 500) then if item.prefab == "goldnugget" then return true end end return false end local function OnGetItemFromPlayer(inst, giver, item) if item.prefab == "goldnugget" then giver.components.inventory:ConsumeByName("goldnugget", 499) giver.level_num = giver.level_num + 1 inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") giver.HUD.controls.status.heart:PulseGreen() giver.HUD.controls.status.stomach:PulseGreen() giver.HUD.controls.status.brain:PulseGreen() giver.HUD.controls.status.brain:ScaleTo(1.3,1,.7) giver.HUD.controls.status.heart:ScaleTo(1.3,1,.7) giver.HUD.controls.status.stomach:ScaleTo(1.3,1,.7) giver.components.health.maxhealth = TUNING.WILSON_HEALTH + giver.level_num*100 giver.components.hunger.max = TUNING.WILSON_HUNGER + giver.level_num*100 giver.components.sanity.max = TUNING.WILSON_SANITY + giver.level_num*100 giver.components.health:DoDelta(giver.components.health.maxhealth) giver.components.hunger:DoDelta(giver.components.hunger.max) giver.components.sanity:DoDelta(giver.components.sanity.max) end end inst:AddComponent("trader") inst.components.trader.onaccept = OnGetItemFromPlayer inst.components.trader:SetAcceptTest(ShouldAcceptItem) 即可给远古祭坛500个黄金(拿着黄金对远古祭坛按鼠标左键),升级主角血量、饥饿、脑最大值各100点,升级无上限,身上黄金不足500时不会升级。如果缺少黄金,可以修改“菜市场”、“肉食店”、“流动商贩”、“杂货收购行”、“收藏品黑市”、“收藏品期货市场”等交易系统赚取黄金(见本修改技巧)。用机器人(wx78)、大力士(沃尔夫冈)作主角时,不要修改此项

2025/04/23 · Bny