YN220-象之树(用紫色护身符种象之树,白天周围有巨象群活动,狩猎它们吧)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二二0.象之树(用紫色护身符种象之树,白天周围有巨象群活动,狩猎它们吧) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/amulet.lua文件,在inst.AnimState:PlayAnimation("purpleamulet")的下一行插入以下内容: local function makebananatree(inst) local pt = inst:GetPosition() local bananatree = SpawnPrefab("purpleamulet") bananatree.Transform:SetPosition(pt.x, pt.y, pt.z) bananatree.AnimState:SetBank("cave_banana_tree") bananatree.AnimState:SetBuild("cave_banana_tree") bananatree.AnimState:PlayAnimation("idle_loop",true) bananatree.Transform:SetScale(1.5, 1.5, 1.5) bananatree:AddComponent("named") bananatree.components.named:SetName("Banana Tree") bananatree:RemoveComponent("equippable") bananatree:RemoveComponent("inventoryitem") bananatree:RemoveComponent("fueled") bananatree:RemoveComponent("deployable") bananatree:AddComponent("workable") bananatree.components.workable:SetWorkAction(ACTIONS.CHOP) bananatree.components.workable:SetWorkLeft(10) bananatree.components.workable:SetOnFinishCallback(function() SpawnPrefab("collapse_big").Transform:SetPosition(bananatree.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") bananatree:Remove() end ) bananatree:ListenForEvent( "daytime", function() local pos = Vector3(bananatree.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 5) for k,v in pairs(ents) do if v.components.inventoryitem and not v.components.inventoryitem:IsHeld() then if v.prefab == "cave_banana" then v:Remove() end end end bananatree:DoTaskInTime(0.3, function(bananatree) bananatree:StartThread(function() for k = 1,math.random(4,8) do local pt1 = bananatree:GetPosition() local banana = SpawnPrefab("cave_banana") banana.Transform:SetPosition(pt1.x+(math.random(5)-math.random(5)), 5, pt1.z+(math.random(5)-math.random(5))) Sleep(0.3) end end ) end ) for k = 1,math.random(5,10) do local elephant = SpawnPrefab("purpleamulet") elephant.Transform:SetPosition(pt.x+(math.random(30)-math.random(30)), 0, pt.z+(math.random(30)-math.random(30))) elephant.AnimState:SetBank("koalefant") elephant.AnimState:SetBuild("koalefant_winter_build") elephant.AnimState:PlayAnimation("idle_loop", true) local sound = elephant.entity:AddSoundEmitter() local shadow = elephant.entity:AddDynamicShadow() shadow:SetSize( 4.5, 2 ) elephant.Transform:SetFourFaced() MakeCharacterPhysics(elephant, 500, 1.5) elephant:AddComponent("named") elephant.components.named:SetName("Elephant") elephant.Transform:SetScale(1.5, 1.5, 1.5) local minimap = elephant.entity:AddMiniMapEntity() minimap:SetIcon( "cave_banana_tree.png" ) elephant:RemoveComponent("equippable") elephant:RemoveComponent("inventoryitem") elephant:RemoveComponent("fueled") elephant:RemoveComponent("deployable") elephant:AddComponent("knownlocations") elephant:AddComponent("health") elephant.components.health:SetMaxHealth(1000) elephant:AddComponent("combat") elephant.components.combat.hiteffectsymbol = "beefalo_body" elephant.components.combat:SetDefaultDamage(30) elephant.components.combat:SetAttackPeriod(2) elephant.components.combat:SetRetargetFunction(3, function(elephant) if not elephant.components.health:IsDead() then return FindEntity(elephant, 25, function(guy) return guy:HasTag("monster") end ) end end ) elephant.components.combat:SetKeepTargetFunction(function(elephant, target) return target and target:IsValid() end ) elephant:ListenForEvent("attacked", function(elephant, data) elephant.components.combat:SetTarget(data.attacker) elephant.components.combat:ShareTarget(data.attacker, 10, function(dude) return dude:HasTag("elephants") and not dude.components.health:IsDead() end, 1) end ) elephant:AddComponent("lootdropper") elephant.components.lootdropper:SetLoot({"meat","meat","meat","meat","meat","meat","meat","meat","meat","meat","trunk_winter"}) elephant:AddComponent("locomotor") elephant.components.locomotor.walkspeed = 2 elephant.components.locomotor.runspeed = 4 elephant:SetStateGraph("SGkoalefant") local brain = require "brains/frogbrain" elephant:SetBrain(brain) elephant:ListenForEvent( "nighttime", function() elephant:Remove() end , GetWorld()) elephant:DoPeriodicTask(math.random(30, 60), function(elephant) if not elephant.components.combat.target then local sgnames = {"bellow","graze","alert","shake"} local sgname = sgnames[math.random(#sgnames)] elephant.sg:GoToState(sgname) end end ) elephant:DoPeriodicTask(math.random(120, 240), function(inst) SpawnPrefab("poop").Transform:SetPosition(elephant.Transform:GetWorldPosition()) end ) if math.random() < 0.5 then elephant:AddTag("redelephants") elephant.AnimState:SetBuild("koalefant_summer_build") elephant.components.lootdropper:SetLoot({"meat","meat","meat","meat","meat","meat","meat","meat","meat","meat","trunk_summer"}) end elephant:AddTag("elephants") end end , GetWorld()) bananatree:AddTag("bananatree") end local function OnDeploy (inst, pt) makebananatree(inst) inst:Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("bananatree") then data.bananatree = true end if inst:HasTag("elephants") then data.elephants = true end if inst:HasTag("redelephants") then data.redelephants = true end end local function onload(inst, data) if data and data.bananatree then makebananatree(inst) inst:Remove() end if data and data.elephants then inst.AnimState:SetBank("koalefant") inst.AnimState:SetBuild("koalefant_winter_build") inst.AnimState:PlayAnimation("idle_loop", true) local sound = inst.entity:AddSoundEmitter() local shadow = inst.entity:AddDynamicShadow() shadow:SetSize( 4.5, 2 ) inst.Transform:SetFourFaced() MakeCharacterPhysics(inst, 500, 1.5) inst:AddComponent("named") inst.components.named:SetName("Elephant") inst.Transform:SetScale(1.5, 1.5, 1.5) local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon( "cave_banana_tree.png" ) inst:RemoveComponent("equippable") inst:RemoveComponent("inventoryitem") inst:RemoveComponent("fueled") inst:RemoveComponent("deployable") inst:AddComponent("knownlocations") inst:AddComponent("health") inst.components.health:SetMaxHealth(1000) inst:AddComponent("combat") inst.components.combat.hiteffectsymbol = "beefalo_body" inst.components.combat:SetDefaultDamage(30) inst.components.combat:SetAttackPeriod(2) inst.components.combat:SetRetargetFunction(3, function(inst) if not inst.components.health:IsDead() then return FindEntity(inst, 25, function(guy) return guy:HasTag("monster") end ) end end ) inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) inst:ListenForEvent("attacked", function(inst, data) inst.components.combat:SetTarget(data.attacker) inst.components.combat:ShareTarget(data.attacker, 10, function(dude) return dude:HasTag("elephants") and not dude.components.health:IsDead() end, 1) end ) inst:AddComponent("lootdropper") inst.components.lootdropper:SetLoot({"meat","meat","meat","meat","meat","meat","meat","meat","meat","meat","trunk_winter"}) inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 2 inst.components.locomotor.runspeed = 4 inst:SetStateGraph("SGkoalefant") local brain = require "brains/frogbrain" inst:SetBrain(brain) inst:ListenForEvent( "nighttime", function() inst:Remove() end , GetWorld()) inst:DoPeriodicTask(math.random(30, 60), function(inst) if not inst.components.combat.target then local sgnames = {"bellow","graze","alert","shake"} local sgname = sgnames[math.random(#sgnames)] inst.sg:GoToState(sgname) end end ) inst:DoPeriodicTask(math.random(120, 240), function(inst) SpawnPrefab("poop").Transform:SetPosition(inst.Transform:GetWorldPosition()) end ) inst:AddTag("elephants") end if data and data.redelephants then inst:AddTag("redelephants") inst.AnimState:SetBuild("koalefant_summer_build") inst.components.lootdropper:SetLoot({"meat","meat","meat","meat","meat","meat","meat","meat","meat","meat","trunk_summer"}) end end inst.OnSave = onsave inst.OnLoad = onload 即可用紫色护身符种象之树,白天会掉落香蕉,并有巨象群在周围活动,夜晚离开。巨象不会主动攻击你,想狩猎它们时,尽量选择落单的巨象,否则其他巨象会一起反击。巨象在小地图上显示为香蕉图标,它们是天然的肉库,杀死一只可获得10块大肉及象鼻,并且会不断产便便,缺少肥料的话,可以在象之树附近拾取。不想要象之树了,砍掉即可,象群会在黑夜离去。紫色护身符在魔法选项(画着红骷髅)下,用6个黄金、4个噩梦燃料、2个紫宝石制造

2025/04/23 · Bny

YN221-变身传奇(主角吃疯肉变身其他主角)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二二一.变身传奇(主角吃疯肉变身其他主角) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/meats.lua文件,在inst.components.edible.sanityvalue = -TUNING.SANITY_MED的下一句插入以下内容: local function item_oneaten(inst, eater) local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} inst.animname = names[math.random(#names)] if eater:HasTag("player") then eater.AnimState:SetBuild(inst.animname) SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) end end inst.components.edible:SetOnEatenFn(item_oneaten) 即可无须开新档,靠吃疯肉就让主角随机变成其他主角的形象,变身后小地图显示不变,原主角技能也不变,该长胡子的还是会长胡子哦。想恢复原主角形象,存档退出后再读档即可。变身不会变成麦斯威尔和伍迪。不要与“荒野之狼”一同修改

2025/04/23 · Bny

YN222-我是巨鹿(按键盘HOME键主角变身巨鹿,按END键还原)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二二二.我是巨鹿(按键盘HOME键主角变身巨鹿,按END键还原) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playercontroller")的下一行插入以下内容: TheInput:AddKeyUpHandler(KEY_HOME, function() if inst.components.inventory:Has("goldnugget", 30) then inst.components.inventory:ConsumeByName("goldnugget", 30) inst.components.locomotor:Stop() inst.components.playercontroller:Enable(false) inst.AnimState:PlayAnimation("idle_shiver_pre") inst.AnimState:PushAnimation("idle_shiver_loop") inst.AnimState:PushAnimation("idle_shiver_pst", false) inst:DoTaskInTime(1, function() inst.AnimState:SetBank("deerclops") inst.AnimState:SetBuild("deerclops_build") inst:SetStateGraph("SGdeerclops") inst.AnimState:PlayAnimation("idle_loop", true) inst.Transform:SetScale(1.5,1.5,1.5) shadow:SetSize( 6, 3.5 ) local pos = GetPlayer():GetPosition() GetSeasonManager():DoLightningStrike(pos) inst.components.health:SetInvincible(true) inst.components.hunger:Pause() inst.components.combat:SetDefaultDamage(500) inst.components.combat.hiteffectsymbol = "deerclops_body" inst.components.combat.onhitotherfn = function() inst.SoundEmitter:PlaySound("dontstarve/creatures/deerclops/attack") inst.components.playercontroller:ShakeCamera(inst, "FULL", 0.5, 0.05, 2, 40) end inst.components.combat.playerdamagepercent = 0 inst.components.combat:SetAreaDamage(10, 1) inst.components.temperature:SetTemp(20) inst.components.playercontroller:Enable(true) end ) end end ) TheInput:AddKeyUpHandler(KEY_END, function() inst.components.locomotor:Stop() inst.components.playercontroller:Enable(false) inst.AnimState:PlayAnimation("taunt") inst:DoTaskInTime(1, function() inst.AnimState:SetBank("wilson") inst.AnimState:SetBuild(name) inst:SetStateGraph("SGwilson") inst.AnimState:PlayAnimation("idle") inst.Transform:SetScale(1,1,1) shadow:SetSize( 1.3, .6 ) local pos = GetPlayer():GetPosition() GetSeasonManager():DoLightningStrike(pos) inst.components.health:SetInvincible(false) inst.components.hunger:Resume() inst.components.combat:SetDefaultDamage(TUNING.UNARMED_DAMAGE) inst.components.combat.hiteffectsymbol = "torso" inst.components.combat.onhitotherfn = nil inst.components.combat:SetAreaDamage(0, 0) inst.components.temperature:SetTemp(nil) inst.components.playercontroller:Enable(true) end ) end ) 即可在你深陷绝境之时,对电脑屏幕大喊“我是巨鹿”,并同时按下键盘HOME键,主角将变身无敌巨鹿(锁血、锁饥饿、不怕冷),对敌人展开恐怖的报复吧(按Ctrl + 鼠标左键攻击)。每次变身将消耗30个黄金,身上黄金数不足时不会变身。想要变回主角时,按键盘END键即可。注意,由于巨鹿变身时会招来闪电,并且本身具备大面积杀伤的能力,所以请远离基地变身,且尽量不要带同伴。修改过“神奇跳跃”的话,不要在变身巨鹿时跳跃

2025/04/23 · Bny

YN223-我是神龙(按键盘L键主角变身神龙,能吐火,再按L键变回人)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二二三.我是神龙(按键盘L键主角变身神龙,能吐火,再按L键变回人) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playercontroller")的下一行插入以下内容: TheInput:AddKeyUpHandler(KEY_L, function() if not inst:HasTag("dragon") then if inst.components.inventory:Has("goldnugget", 30) then inst.components.inventory:ConsumeByName("goldnugget", 30) inst.components.locomotor:Stop() inst.components.playercontroller:Enable(false) inst.AnimState:PlayAnimation("idle_shiver_pre") inst.AnimState:PushAnimation("idle_shiver_loop") inst.AnimState:PushAnimation("idle_shiver_pst", false) inst:DoTaskInTime(1, function() inst:AddTag("dragon") inst.AnimState:SetBank("krampus") inst.AnimState:SetBuild("krampus_build") inst:SetStateGraph("SGkrampus") inst.AnimState:PlayAnimation("idle", true) inst.AnimState:Hide("SACK") inst.AnimState:Show("ARM") inst.Transform:SetScale(1.8,1.8,1.8) shadow:SetSize( 6, 3.5 ) local light = inst.entity:AddLight() light:SetIntensity(.8) light:SetRadius(20) light:SetFalloff(.6) light:Enable(true) light:SetColour(255/255, 0/255, 0/255) inst.components.locomotor.walkspeed = 10 inst.components.locomotor.runspeed = 15 local pos = GetPlayer():GetPosition() GetSeasonManager():DoLightningStrike(pos) inst.components.health:SetInvincible(true) inst.components.hunger:Pause() inst.components.combat:SetDefaultDamage(500) inst.components.combat.hiteffectsymbol = "krampus_torso" local pearl = SpawnPrefab("dragonfruit") pearl.entity:AddSoundEmitter() RemovePhysicsColliders(pearl) pearl:AddTag("projectile") pearl:AddTag("pearl") pearl:RemoveComponent("edible") pearl:RemoveComponent("stackable") pearl:RemoveComponent("tradable") pearl:RemoveComponent("perishable") pearl:RemoveComponent("cookable") pearl:RemoveComponent("bait") pearl:RemoveComponent("plantable") pearl:RemoveComponent("burnable") pearl:RemoveComponent("propagator") pearl:AddComponent("burnable") pearl.components.burnable:SetFXLevel(3) pearl.components.burnable:AddBurnFX("character_fire", Vector3(0,0,0) ) pearl:AddComponent("weapon") pearl.components.weapon:SetDamage(500) pearl.components.weapon:SetRange(20, 25) pearl:AddComponent("equippable") pearl.components.equippable.equipslot = EQUIPSLOTS.HANDS pearl.components.equippable:SetOnEquip(function(pearl) pearl.components.burnable:Extinguish() end ) pearl:AddComponent("projectile") pearl.components.projectile:SetSpeed(50) pearl.components.projectile:SetOnHitFn(function(pearl, owner, target) inst.SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") SpawnPrefab("collapse_small").Transform:SetPosition(target.Transform:GetWorldPosition()) SpawnPrefab("explode_small").Transform:SetPosition(target.Transform:GetWorldPosition()) inst.components.playercontroller:ShakeCamera(inst, "FULL", 0.2, 0.02, .5, 40) if target.components.burnable then target.components.burnable:Ignite() end owner.components.inventory:Equip(pearl) end ) pearl.components.projectile:SetOnMissFn(function(pearl, owner) owner.components.inventory:Equip(pearl) end ) pearl:ListenForEvent("onthrown", function(pearl) local pt = pearl:GetPosition() pearl.Transform:SetPosition(pt.x, 2, pt.z) pearl.SoundEmitter:PlaySound("dontstarve/common/blackpowder_explo") pearl.components.burnable:Ignite(true) end ) inst.components.inventory:Equip(pearl) inst.components.temperature:SetTemp(20) inst.components.playercontroller:Enable(true) end ) end else inst.components.locomotor:Stop() inst.components.playercontroller:Enable(false) inst.AnimState:PlayAnimation("taunt") inst:DoTaskInTime(1, function() inst:RemoveTag("dragon") inst.AnimState:SetBank("wilson") inst.AnimState:SetBuild(name) inst:SetStateGraph("SGwilson") inst.AnimState:PlayAnimation("idle") inst.Transform:SetScale(1,1,1) shadow:SetSize( 1.3, .6 ) inst.Light:Enable(false) inst.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED local pos = GetPlayer():GetPosition() GetSeasonManager():DoLightningStrike(pos) inst.components.health:SetInvincible(false) inst.components.hunger:Resume() inst.components.combat:SetDefaultDamage(TUNING.UNARMED_DAMAGE) inst.components.combat.hiteffectsymbol = "torso" local pos0 = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos0.x,pos0.y,pos0.z, 3000) for k,v in pairs(ents) do if v:HasTag("pearl") then v:Remove() end end inst.components.temperature:SetTemp(nil) inst.components.playercontroller:Enable(true) end ) end end ) 即可在身上有30个黄金时,按键盘L键,主角随即变身神龙,将消耗30个黄金,身上黄金数不足时不会变身。变身神龙后,自动装备龙果,对敌人按鼠标左键,可发射龙果火球,如果卸载龙果,则改为近身格斗(按Ctrl + 鼠标左键攻击,或按住F键反击),防止点燃附近植物。神龙可夜视,不会饥饿,且锁血,对地上的物品点鼠标左键可捡起。想要变回主角时,再次按键盘L键即可,龙果将消失

2025/04/23 · Bny

YN224-我是龙卷风(按键盘U键主角变身龙卷风,掠过之处尽毁,敌人靠近会被冻伤,再按U键变回人)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二二四.我是龙卷风(按键盘U键主角变身龙卷风,掠过之处尽毁,敌人靠近会被冻伤,再按U键变回人) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playercontroller")的下一行插入以下内容: TheInput:AddKeyUpHandler(KEY_U, function() if not inst:HasTag("windman") then inst.components.locomotor:Stop() inst.components.playercontroller:Enable(false) inst.AnimState:PlayAnimation("idle_shiver_pre") inst.AnimState:PushAnimation("idle_shiver_loop") inst.AnimState:PushAnimation("idle_shiver_pst", false) GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") inst:DoTaskInTime(0.3, function() inst:AddTag("windman") inst.AnimState:SetBank("tornado") inst.AnimState:SetBuild("tornado") inst:SetStateGraph("SGtornado") inst.AnimState:PlayAnimation("tornado_pre") inst.AnimState:PushAnimation("tornado_loop") inst.Transform:SetScale(1.8,1.8,1.8) local light = inst.entity:AddLight() light:SetIntensity(.8) light:SetRadius(10) light:SetFalloff(.6) light:Enable(true) light:SetColour(255/255,255/255,255/255) inst.components.locomotor.walkspeed = 20 inst.components.locomotor.runspeed = 30 inst.components.health:SetInvincible(true) inst.components.hunger:Pause() inst.components.temperature:SetTemp(20) inst.Physics:SetCollisionCallback(function(inst, other) if other and other.components.health and other.components.combat then if other.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == other or other:HasTag("monster") then other.components.health:DoDelta(-100) if other.components.freezable then other.components.freezable:AddColdness(10) other.components.freezable:SpawnShatterFX() end end end if other and other.components.workable and other.components.workable.workleft > 0 then GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") other.components.workable:Destroy(inst) end end ) inst.components.playercontroller:Enable(true) end ) else inst.components.locomotor:Stop() inst.components.playercontroller:Enable(false) GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") inst.AnimState:PlayAnimation("tornado_pst") inst:DoTaskInTime(0.3, function() inst:RemoveTag("windman") inst.AnimState:SetBank("wilson") inst.AnimState:SetBuild(name) inst:SetStateGraph("SGwilson") inst.AnimState:PlayAnimation("idle") inst.Transform:SetScale(1,1,1) inst.Light:Enable(false) inst.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED inst.components.health:SetInvincible(false) inst.components.hunger:Resume() inst.components.temperature:SetTemp(nil) inst.Physics:SetCollisionCallback( nil ) inst.components.playercontroller:Enable(true) end ) end end ) 即可按键盘U键,主角变身龙卷风,掠过之处一切建筑、植物尽毁,敌人靠近将被冻伤。龙卷风可夜视,不会饥饿,且锁血,去席卷大陆吧。再次按键盘U键可变回人

2025/04/23 · Bny

YN225-荒野之狼(吃蜗牛龟粘液变成狼,打败别的狼成为领袖)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二二五.荒野之狼(吃蜗牛龟粘液变成狼,打败别的狼成为领袖) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/slurtleslime.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function item_oneaten(inst, eater) if eater:HasTag("player") then local pos = GetPlayer():GetPosition() GetSeasonManager():DoLightningStrike(pos) eater.components.locomotor:Stop() eater.components.playercontroller:Enable(false) eater:DoTaskInTime(1, function() eater.AnimState:SetBank("hound") eater.AnimState:SetBuild("hound_red") eater.AnimState:PlayAnimation("idle") eater:SetStateGraph("SGhound") eater:RemoveTag("scarytoprey") eater:AddTag("monster") local light = eater.entity:AddLight() light:SetFalloff(1) light:SetIntensity(.8) light:SetRadius(20) light:Enable(true) light:SetColour(0/255, 255/255, 0/255) eater:ListenForEvent("attacked", function(eater) local pt = eater:GetPosition() eater.Transform:SetPosition(pt.x+(math.random(5)-math.random(5)), 0, pt.z+(math.random(5)-math.random(5))) end ) eater.components.locomotor.runspeed = 25 eater.components.sanity:DoDelta(eater.components.sanity.max) eater.components.sanity.ignore = true eater.components.health:StartRegen(100, 10) eater.components.combat:SetDefaultDamage(500) eater.components.combat:SetAttackPeriod(0.1) eater.components.eater:SetCarnivore() eater.components.temperature:SetTemp(20) eater.components.playercontroller:Enable(true) GetPlayer().HUD.controls.crafttabs:Hide() GetPlayer().HUD.controls.inv:Hide() GetPlayer().HUD.controls.mapcontrols.minimapBtn:Hide() local head = GetPlayer().components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) GetPlayer().components.inventory:DropItem(head) local hands = GetPlayer().components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) GetPlayer().components.inventory:DropItem(hands) local body = GetPlayer().components.inventory:GetEquippedItem(EQUIPSLOTS.BODY) GetPlayer().components.inventory:DropItem(body) eater.components.playeractionpicker.leftclickoverride = function(eater, target_ent, pos) if eater.components.combat:CanTarget(target_ent) then return eater.components.playeractionpicker:SortActionList({ACTIONS.ATTACK}, target_ent, nil) end if target_ent and target_ent.components.edible and eater.components.eater:CanEat(target_ent) then return eater.components.playeractionpicker:SortActionList({ACTIONS.EAT}, target_ent, nil) end end eater:DoPeriodicTask(3, function(eater) if math.random() < 0.05 then if eater.components.hunger:GetPercent() > 0.995 then local pt1 = eater:GetPosition() local wolf = SpawnPrefab("slurtleslime") wolf.Transform:SetPosition(pt1.x+(math.random(10)-math.random(10)), 0, pt1.z+(math.random(10)-math.random(10))) wolf.AnimState:SetBank("hound") wolf.AnimState:SetBuild("hound") wolf.AnimState:PlayAnimation("idle") wolf.Transform:SetFourFaced() local sound = wolf.entity:AddSoundEmitter() local shadow = wolf.entity:AddDynamicShadow() shadow:SetSize( 2.5, 1.5 ) MakeCharacterPhysics(wolf, 10, .5) wolf:AddComponent("locomotor") wolf.components.locomotor.runspeed = 25 wolf:SetStateGraph("SGhound") local brain = require "brains/frogbrain" wolf:SetBrain(brain) wolf:RemoveComponent("stackable") wolf:RemoveComponent("fuel") wolf:RemoveComponent("inventoryitem") wolf:RemoveComponent("explosive") wolf:RemoveComponent("burnable") wolf:RemoveComponent("propagator") wolf:RemoveComponent("edible") wolf:AddComponent("follower") wolf:AddComponent("knownlocations") wolf:AddComponent("lootdropper") wolf.components.lootdropper:SetLoot({"meat", "meat"}) wolf:AddComponent("health") wolf.components.health:SetMaxHealth(2000) wolf.components.health:StartRegen(100, 10) wolf:AddComponent("combat") wolf.components.combat:SetDefaultDamage(20) wolf.components.combat:SetAttackPeriod(0.1) wolf.components.combat:SetTarget(eater) wolf.AnimState:SetMultColour(255/255,0/255,0/255,1) wolf.components.combat:SetRetargetFunction(1, function(wolf) if not wolf.components.health:IsDead() then return FindEntity(wolf, 300, function(guy) return guy:HasTag("player") end ) end end ) wolf.components.combat:SetKeepTargetFunction(function(wolf, target) return target and target:IsValid() end ) wolf.task = wolf:DoPeriodicTask(1, function(customer) if wolf.components.health.currenthealth < 1000 then wolf.components.combat:SetTarget(nil) wolf:RemoveTag("goodbye") local brain = require "brains/abigailbrain" wolf:SetBrain(brain) wolf:RestartBrain() wolf.components.follower:SetLeader(GetPlayer()) wolf.AnimState:SetMultColour(255/255,255/255,255/255,1) wolf.components.combat:SetRetargetFunction(2, function(wolf) if not wolf.components.health:IsDead() then return FindEntity(wolf, 20, function(guy) if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("wolfs") then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy end end ) end end ) wolf.components.combat:SetKeepTargetFunction(function(wolf, target) return target and target:IsValid() end ) if wolf.task then wolf.task:Cancel() wolf.task = nil end end end ) wolf:AddTag("monster") wolf:AddTag("wolfs") wolf:AddTag("goodbye") end end end ) end ) end end inst:AddComponent("edible") inst.components.edible:SetOnEatenFn(item_oneaten) inst.components.edible.hungervalue = 1 inst.components.edible.foodtype = "VEGGIE" local function onsave(inst, data) if inst:HasTag("wolfs") then data.wolfs = true end if inst:HasTag("goodbye") then data.goodbye = true end end local function onload(inst, data) if data and data.goodbye then inst:Remove() end if data and data.wolfs then inst.AnimState:SetBank("hound") inst.AnimState:SetBuild("hound") inst.AnimState:PlayAnimation("idle") inst.Transform:SetFourFaced() local sound = inst.entity:AddSoundEmitter() local shadow = inst.entity:AddDynamicShadow() shadow:SetSize( 2.5, 1.5 ) MakeCharacterPhysics(inst, 10, .5) inst:AddComponent("locomotor") inst.components.locomotor.runspeed = 25 inst:SetStateGraph("SGhound") inst:RemoveComponent("stackable") inst:RemoveComponent("fuel") inst:RemoveComponent("inventoryitem") inst:RemoveComponent("explosive") inst:RemoveComponent("burnable") inst:RemoveComponent("propagator") inst:RemoveComponent("edible") inst:AddComponent("follower") inst:AddComponent("knownlocations") inst:AddComponent("lootdropper") inst.components.lootdropper:SetLoot({"meat", "meat"}) inst:AddComponent("health") inst.components.health:SetMaxHealth(2000) inst.components.health:StartRegen(100, 10) inst:AddComponent("combat") inst.components.combat:SetDefaultDamage(20) inst.components.combat:SetAttackPeriod(0.1) local brain = require "brains/abigailbrain" inst:SetBrain(brain) inst.components.follower:SetLeader(GetPlayer()) inst.components.combat:SetRetargetFunction(2, 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() and not guy:HasTag("wolfs") 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:AddTag("monster") inst:AddTag("wolfs") end end inst.OnSave = onsave inst.OnLoad = onload 即可吃蜗牛龟粘液让主角变成狼,体验野生动物的生活。可喜的是,你将拥有强大的生命力(自动回血),超快的跑动速度和恐怖的咬合能力,黑夜也不会影响你看清前方,甚至由于没有了人的味道,一些小动物将无法躲避你。可悲的是,你必须告别之前所有的伙伴,连“新移民”都会主动攻击你,离开人类的生活,流浪在荒郊野外。战斗中,由于你的体重变轻,被打时会被甩出去,因此要学会扬长避短,发挥速度和攻击力的优势,跑过去咬上一口就躲,千万不要与敌人原地肉搏。当你进食到最饱时,有一定概率出现别的狼(全身红色)挑战你,打败它(它身上不再呈红色),则将成为你的小弟,用锋利的牙齿发展起你的狼群吧。如果实在受不了荒野的生活了,存档退出再读档,即可变回人,但狼小弟将继续跟随你。使用大力士、伍迪作主角时,不适用此项,不要与“变身传奇”、“饥饿的儿童”一同修改。蜗牛龟粘液可打蜗牛龟和蜗牛窝获得

2025/04/23 · Bny

YN226-遁形术(按键盘I键主角变身随机小动物,敌人会失去攻击目标,再按I键变回人)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二二六.遁形术(按键盘I键主角变身随机小动物,敌人会失去攻击目标,再按I键变回人) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playercontroller")的下一行插入以下内容: TheInput:AddKeyUpHandler(KEY_I, function() if not inst:HasTag("chameleon") then inst.components.locomotor:Stop() inst.components.talker:ShutUp() inst.components.playercontroller:Enable(false) local head = GetPlayer().components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) GetPlayer().components.inventory:DropItem(head) local hands = GetPlayer().components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) GetPlayer().components.inventory:DropItem(hands) local body = GetPlayer().components.inventory:GetEquippedItem(EQUIPSLOTS.BODY) GetPlayer().components.inventory:DropItem(body) inst.components.health:SetInvincible(true) inst.components.hunger:Pause() inst.components.sanity.ignore = true inst.components.temperature:SetTemp(20) SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst:DoTaskInTime(0.3, function() inst:AddTag("chameleon") inst.chameleon = inst:DoPeriodicTask(.5, function() local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 25) for k,v in pairs(ents) do if v.components.combat and v.components.combat.target and v.components.combat.target == inst then v.components.combat:SetTarget(nil) end end end ) if math.random()<.18 then inst.AnimState:SetBank("rabbit") inst.AnimState:SetBuild("rabbit_build") inst.AnimState:PlayAnimation("idle") local rabbitsounds = { scream = "dontstarve/rabbit/scream", hurt = "dontstarve/rabbit/scream_short", } inst.sounds = rabbitsounds inst.data = {} inst:SetStateGraph("SGrabbit") shadow:SetSize( 1, .75 ) elseif math.random()<.36 then inst.AnimState:SetBank("perd") inst.AnimState:SetBuild("perd") inst.AnimState:PlayAnimation("idle_loop") inst:SetStateGraph("SGperd") shadow:SetSize( 1.5, .75 ) elseif math.random()<.54 then inst.AnimState:SetBank("frog") inst.AnimState:SetBuild("frog") inst.AnimState:PlayAnimation("idle") inst:SetStateGraph("SGfrog") shadow:SetSize( 1.5, .75 ) elseif math.random()<.72 then inst.AnimState:SetBank("butterfly") inst.AnimState:SetBuild("butterfly_basic") inst.AnimState:PlayAnimation("idle") inst:SetStateGraph("SGbutterfly") shadow:SetSize( .8, .5 ) else inst.AnimState:SetBank("bee") inst.AnimState:SetBuild("bee_build") inst.AnimState:PlayAnimation("idle") local workersounds = { takeoff = "dontstarve/bee/bee_takeoff", attack = "dontstarve/bee/bee_attack", buzz = "dontstarve/bee/bee_fly_LP", hit = "dontstarve/bee/bee_hurt", death = "dontstarve/bee/bee_death", } inst.sounds = workersounds inst:SetStateGraph("SGbee") shadow:SetSize( .8, .5 ) end inst.components.playercontroller:Enable(true) end ) else inst.components.locomotor:Stop() inst.components.talker:ShutUp() inst.components.playercontroller:Enable(false) SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst:DoTaskInTime(0.3, function() inst:RemoveTag("chameleon") if inst.chameleon then inst.chameleon:Cancel() inst.chameleon = nil end inst.AnimState:SetBank("wilson") inst.AnimState:SetBuild(name) inst.AnimState:PlayAnimation("idle") inst:SetStateGraph("SGwilson") shadow:SetSize( 1.3, .6 ) inst.components.health:SetInvincible(false) inst.components.hunger:Resume() inst.components.sanity.ignore = false inst.components.temperature:SetTemp(nil) inst.components.playercontroller:Enable(true) end ) end end ) 即可在被敌人追得穷途末路时,大声喊出咒语“哎呀妈呀”(请使用东北口音),并按键盘I键,主角随机变身为兔子、火鸡、青蛙、蝴蝶、蜜蜂等小动物,敌人会被迷惑,从而失去攻击目标,让你可以成功脱身。每种小动物各有特色,火鸡可以快速采摘植物、蜜蜂可以蛰敌人等,体验一下作小动物的感觉吧。运用遁形术变身时,血、饥饿、脑会锁死,穿戴的装备会掉在地上,不想让其掉落,就提前卸下。再次按键盘I键,可变回主角

2025/04/23 · Bny

YN227-人工降水(开关雨量计夏天下雨、冬天下雪,可以灭火)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二二七.人工降水(开关雨量计夏天下雨、冬天下雪,可以灭火) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/rainometer.lua文件,将inst:AddComponent("inspectable")替换为以下内容: function firefn(inst) local range = 3000 local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, range) for k,v in pairs(ents) do local pt = v:GetPosition() if v.components.burnable and v.components.burnable:IsBurning() then if v.prefab == "grass" then v:Remove() SpawnPrefab("grass").Transform:SetPosition(pt.x, pt.y, pt.z) end if v.prefab == "sapling" then v:Remove() SpawnPrefab("sapling").Transform:SetPosition(pt.x, pt.y, pt.z) end if v.prefab == "reeds" then v:Remove() SpawnPrefab("reeds").Transform:SetPosition(pt.x, pt.y, pt.z) end if v.prefab == "berrybush" then v:Remove() SpawnPrefab("berrybush").Transform:SetPosition(pt.x, pt.y, pt.z) end if v.prefab == "marsh_bush" then v:Remove() SpawnPrefab("marsh_bush").Transform:SetPosition(pt.x, pt.y, pt.z) end if v.prefab == "flower_cave_triple" then v:Remove() SpawnPrefab("flower_cave_triple").Transform:SetPosition(pt.x, pt.y, pt.z) end if v.prefab == "lichen" then v:Remove() SpawnPrefab("lichen").Transform:SetPosition(pt.x, pt.y, pt.z) end end end end local function GetStatus(inst, viewer) if GetWorld().components.seasonmanager.precip then GetWorld().components.seasonmanager:StopPrecip() if inst.fire then inst.fire:Cancel() inst.fire = nil end else GetWorld().components.seasonmanager:ForcePrecip() inst.fire = inst:DoPeriodicTask(8, function() firefn(inst) end) end end inst:AddComponent("inspectable") inst.components.inspectable.getstatus = GetStatus 即可在雨量计上按鼠标左键开始降水,再按一次鼠标左键停止降水,夏天下雨、冬天下雪。可以浇灭大部分植物着的火,包括草、树枝、芦苇、果树丛、尖刺灌木、三朵洞穴花、苔藓

2025/04/23 · Bny

YN228-人工换季(鼠标左键点寒冬温度计切换季节)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二二八.人工换季(鼠标左键点寒冬温度计切换季节) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/winterometer.lua文件,将inst:AddComponent("inspectable")替换为以下内容: local function GetStatus(inst, viewer) if GetWorld().components.seasonmanager:IsWinter() then GetWorld().components.seasonmanager:StartSpring() elseif GetWorld().components.seasonmanager:IsSpring() then GetWorld().components.seasonmanager:StartSummer() elseif GetWorld().components.seasonmanager:IsSummer() then GetWorld().components.seasonmanager:StartAutumn() else GetWorld().components.seasonmanager:StartWinter() end GetWorld().components.seasonmanager:UpdateSegs() end inst:AddComponent("inspectable") inst.components.inspectable.getstatus = GetStatus 即可鼠标左键点寒冬温度计切换季节,每按一次切换到下个季节

2025/04/23 · Bny

YN229-光阴似箭(对指南针按右键跳到下个时段)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二二九.光阴似箭(对指南针按右键跳到下个时段) 用MT管理器打开游戏目录/assets/scripts/prefabs/compass.lua文件,在local function GetStatus(inst, viewer)的下一行插入GetClock():NextPhase() 即可对指南针按右键跳到下个时段,即白天变傍晚、傍晚变黑夜、黑夜变白天,采蘑菇、捉萤火虫等有时段要求的事情,无须再等待了

2025/04/23 · Bny