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

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

YN212-许愿池(给池塘黄金消顽皮值,天上有机会下黄金雨,接到就是你的)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二一二.许愿池(给池塘黄金消顽皮值,天上有机会下黄金雨,接到就是你的) 用MT管理器打开游戏目录/assets/scripts/prefabs/pond.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function ShouldAcceptItem(inst, item) if item.prefab == "goldnugget" then return true end return false end local function OnGetItemFromPlayer(inst, giver, item) if GetPlayer().components.kramped and GetPlayer().components.kramped.threshold > 0 then GetPlayer().components.kramped.threshold = GetPlayer().components.kramped.threshold -1 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/krampus/beenbad_lvl3") end if math.random()<.1 then GetPlayer().SoundEmitter:PlaySound("dontstarve/music/music_hoedown", "beavermusic") inst:StartThread(function() for k = 1, 50 do local pt = Vector3(giver.Transform:GetWorldPosition()) local gold = SpawnPrefab("goldnugget") gold.Transform:SetPosition(pt.x+(math.random(5)-math.random(5)), 20, pt.z+(math.random(5)-math.random(5))) gold.components.inventoryitem.canbepickedup = false inst:DoTaskInTime(1.8, function() local pos = Vector3(gold.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 2) for k,v in pairs(ents) do if v:HasTag("player") then v.components.inventory:GiveItem(gold) end end end) inst:DoTaskInTime(2, function() local pt2 = gold:GetPosition() if not gold.components.inventoryitem:IsHeld() then GetPlayer().SoundEmitter:PlaySound("dontstarve/common/stone_drop") SpawnPrefab("ground_chunks_breaking").Transform:SetPosition(pt2.x, 0, pt2.z) gold:Remove() else gold.components.inventoryitem.canbepickedup = true end end) Sleep(1) end GetPlayer().SoundEmitter:KillSound("beavermusic") end) end end inst:AddComponent("trader") inst.components.trader.onaccept = OnGetItemFromPlayer inst.components.trader:SetAcceptTest(ShouldAcceptItem) 即可拿着黄金对池塘点左键,每次消减一点顽皮值(杀小动物的惩罚点数),并发出喘息声,如果没有喘息声,表示你的顽皮值已经为零,罪已经赎清了。许愿的过程中,天上有一定概率下起黄金雨(50个黄金),黄金落地弹起的刹那,如果你接到就归你了(跑到黄金掉落位置),否则会摔碎,试试你的反应能力吧

2025/04/23 · Bny

YN213-红胡子强盗团(强盗团通过冒险之门入侵,烧杀抢掠,打死强盗可得黄金、武器)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二一三.红胡子强盗团(强盗团通过冒险之门入侵,烧杀抢掠,打死强盗可得黄金、武器) 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/forest.lua文件,在"puppet_wes",的下一行插入"puppet_woodie", 2.用MT管理器打开游戏目录/assets/scripts/prefabs/adventure_portal.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function createbandit(inst) for k = 1,math.random(20,35) do local pt = inst:GetPosition() local bandit = SpawnPrefab("beardhair") bandit.Transform:SetPosition(pt.x+(math.random(50)-math.random(50)), 0, pt.z+(math.random(50)-math.random(50))) bandit.AnimState:SetBank("wilson") bandit.AnimState:SetBuild("woodie") bandit.AnimState:OverrideSymbol("swap_hat", "hat_feather", "swap_hat") bandit.AnimState:OverrideSymbol("swap_body", "armor_slurper", "swap_body") bandit.AnimState:Show("HAT") bandit.AnimState:Show("HAT_HAIR") bandit.AnimState:Hide("HAIR_NOHAT") bandit.AnimState:Hide("HAIR") bandit.AnimState:Hide("ARM_carry") bandit.AnimState:Show("ARM_normal") bandit.AnimState:PlayAnimation("idle") local sound = bandit.entity:AddSoundEmitter() local shadow = bandit.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) bandit.Transform:SetFourFaced() local brain = require "brains/frogbrain" bandit:SetBrain(brain) bandit:AddComponent("locomotor") bandit.components.locomotor.walkspeed = 5 bandit.components.locomotor.runspeed = 10 bandit:SetStateGraph("SGshadowwaxwell") MakeCharacterPhysics(bandit, 75, .5) bandit:RemoveComponent("inventoryitem") bandit:RemoveComponent("stackable") bandit:RemoveComponent("fuel") bandit:RemoveComponent("burnable") bandit:RemoveComponent("propagator") bandit:AddComponent("inventory") bandit:AddComponent("thief") bandit:AddComponent("knownlocations") bandit:AddComponent("health") bandit.components.health:SetMaxHealth(1500) bandit:ListenForEvent("death", function() local pt1 = bandit:GetPosition() for k = 1,math.random(15,25) do local gold = SpawnPrefab("goldnugget") gold.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) end if math.random() < 0.1 then local weapons = {"goldenaxe","spear","tentaclespike","batbat","ruins_bat"} local weapon = weapons[math.random(#weapons)] SpawnPrefab(weapon).Transform:SetPosition(pt1.x, 0, pt1.z) end end ) bandit:AddComponent("combat") bandit.components.combat:SetDefaultDamage(20) bandit.components.combat:SetAttackPeriod(1) bandit.components.combat:SetRetargetFunction(2, function(bandit) if not bandit.components.health:IsDead() then return FindEntity(bandit, 20, function(guy) return bandit.components.combat:CanTarget(guy) and not guy:HasTag("bandits") end ) end end ) bandit.components.combat.onhitotherfn = function(bandit, other, damage) bandit.components.thief:StealItem(other) end bandit:ListenForEvent("attacked", function(bandit, data) bandit.components.combat:SetTarget(data.attacker) bandit.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("bandits") and not dude.components.health:IsDead() end, 5) end ) bandit.Physics:SetCollisionCallback(function(bandit, other) if other and other.components.workable and other.components.workable.workleft > 0 then other.components.workable:Destroy(bandit) end end) bandit:DoPeriodicTask(1, function(bandit) local pos = Vector3(bandit.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3) for k,v in pairs(ents) do if v.components.pickable and v.components.pickable:CanBePicked() then v.components.pickable:Pick(bandit) end if v.components.crop then v.components.crop:Harvest(bandit) end end end ) local minimap = bandit.entity:AddMiniMapEntity() minimap:SetIcon( "lucy_axe.png" ) bandit:AddTag("monster") bandit:AddTag("bandits") end end local function delbandit(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 if v:HasTag("bandits") then v:Remove() end end end inst:ListenForEvent( "daytime", function() createbandit(inst) end , GetWorld()) inst:ListenForEvent( "nighttime", function() delbandit(inst) end , GetWorld()) 3.用MT管理器打开游戏目录/assets/scripts/prefabs/beardhair.lua文件,在Asset("ANIM", "anim/beardhair.zip"),的下一行插入以下内容: Asset("ANIM", "anim/woodie.zip"), Asset("SOUND", "sound/woodie.fsb"), 4.在inst:AddComponent("inspectable")的下一行插入以下内容: local names = {"swap_goldenaxe","swap_spear","swap_spike","swap_batbat","swap_ruins_bat"} local weapon = names[math.random(#names)] local items = { SWORD = weapon } local function EquipItem(inst, item) if item then inst.AnimState:OverrideSymbol("swap_object", item, item) inst.AnimState:Show("ARM_carry") inst.AnimState:Hide("ARM_normal") end end inst.items = items inst.equipfn = EquipItem EquipItem(inst) local function onsave(inst, data) if inst:HasTag("bandits") then data.bandits = true end end local function onload(inst, data) if data and data.bandits then inst.AnimState:SetBank("wilson") inst.AnimState:SetBuild("woodie") inst.AnimState:OverrideSymbol("swap_hat", "hat_feather", "swap_hat") inst.AnimState:OverrideSymbol("swap_body", "armor_slurper", "swap_body") inst.AnimState:Show("HAT") inst.AnimState:Show("HAT_HAIR") inst.AnimState:Hide("HAIR_NOHAT") inst.AnimState:Hide("HAIR") inst.AnimState:Hide("ARM_carry") inst.AnimState:Show("ARM_normal") inst.AnimState:PlayAnimation("idle") local sound = inst.entity:AddSoundEmitter() local shadow = inst.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) inst.Transform:SetFourFaced() local brain = require "brains/frogbrain" inst:SetBrain(brain) inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 5 inst.components.locomotor.runspeed = 10 inst:SetStateGraph("SGshadowwaxwell") MakeCharacterPhysics(inst, 75, .5) inst:RemoveComponent("inventoryitem") inst:RemoveComponent("stackable") inst:RemoveComponent("fuel") inst:RemoveComponent("burnable") inst:RemoveComponent("propagator") inst:AddComponent("inventory") inst:AddComponent("thief") inst:AddComponent("knownlocations") inst:AddComponent("health") inst.components.health:SetMaxHealth(1500) inst:ListenForEvent("death", function() local pt1 = inst:GetPosition() for k = 1,math.random(15,25) do local gold = SpawnPrefab("goldnugget") gold.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) end if math.random() < 0.1 then local weapons = {"goldenaxe","spear","tentaclespike","batbat","ruins_bat"} local weapon = weapons[math.random(#weapons)] SpawnPrefab(weapon).Transform:SetPosition(pt1.x, 0, pt1.z) end end ) inst:AddComponent("combat") inst.components.combat:SetDefaultDamage(20) inst.components.combat:SetAttackPeriod(1) inst.components.combat:SetRetargetFunction(2, function(inst) if not inst.components.health:IsDead() then return FindEntity(inst, 20, function(guy) return inst.components.combat:CanTarget(guy) and not guy:HasTag("bandits") end ) end end ) inst.components.combat.onhitotherfn = function(inst, other, damage) inst.components.thief:StealItem(other) end inst:ListenForEvent("attacked", function(inst, data) inst.components.combat:SetTarget(data.attacker) inst.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("bandits") and not dude.components.health:IsDead() end, 5) end ) inst.Physics:SetCollisionCallback(function(inst, other) if other and other.components.workable and other.components.workable.workleft > 0 then other.components.workable:Destroy(inst) end end) inst:DoPeriodicTask(1, function(inst) local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3) for k,v in pairs(ents) do if v.components.pickable and v.components.pickable:CanBePicked() then v.components.pickable:Pick(inst) end if v.components.crop then v.components.crop:Harvest(inst) end end end ) local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon( "lucy_axe.png" ) inst:AddTag("monster") inst:AddTag("bandits") end end inst.OnSave = onsave inst.OnLoad = onload 即可有红胡子强盗通过冒险之门入侵你的大陆(修改后第2天早晨出现),他们将盘踞在冒险之门附近,毁坏森林、拆毁建筑、抢掠农作物,所到之处没有活口。通过小地图可查询强盗所在位置,显示为红斧子图标。与强盗交战时,他们会抢掠你身上的物品,并且附近的强盗将一起来围攻你,蛮干无异于送死,争取各个击破吧。从此在冒险之门周围,白天和傍晚都是危险的,只有漆黑的夜里,才是你可以喘息之际。打死强盗可获得战利品(不菲的黄金和他们抢来的赃物),还有一定概率掉落武器。如果同时修改了“雇佣兵工厂”,你的铁甲战团终于有了用武之地。同胞们,饥荒世界正遭遇重大危机,亿万苍生期盼着你,起兵去攻打强盗吧,这是旷日持久的反抗,也是正义而光荣的战争,用你的每一滴鲜血去证明,新一代的救世主,从此诞生了

2025/04/23 · Bny

YN214-饥饿的儿童(不时有孤儿向你乞讨,施舍黄金后离开,否则跟随你直到午夜冻饿而死)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二一四.饥饿的儿童(不时有孤儿向你乞讨,施舍黄金后离开,否则跟随你直到午夜冻饿而死) 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/forest.lua文件,在inst:AddComponent("clock")的下一行插入以下内容: local function createbeggar(inst) for k = 1,math.random(3,7) do local pt = GetPlayer():GetPosition() local beggar = SpawnPrefab("foliage") beggar.Transform:SetPosition(pt.x+(math.random(50)-math.random(50)), 0, pt.z+(math.random(50)-math.random(50))) beggar.AnimState:SetBank("wilson") local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} local buildname = names[math.random(#names)] beggar.AnimState:SetBuild(buildname) beggar.Transform:SetScale(0.8, 0.8, 0.8) beggar.AnimState:OverrideSymbol("swap_body", "armor_grass", "swap_body") beggar.AnimState:Hide("ARM_carry") beggar.AnimState:Show("ARM_normal") beggar.AnimState:PlayAnimation("idle") local sound = beggar.entity:AddSoundEmitter() local shadow = beggar.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) beggar.Transform:SetFourFaced() local brain = require "brains/chesterbrain" beggar:SetBrain(brain) beggar:AddComponent("knownlocations") beggar:AddComponent("locomotor") beggar.components.locomotor.walkspeed = 5 beggar.components.locomotor.runspeed = 15 beggar:SetStateGraph("SGshadowwaxwell") MakeCharacterPhysics(beggar, 50, .5) beggar:RemoveComponent("stackable") beggar:RemoveComponent("tradable") beggar:RemoveComponent("fuel") beggar:RemoveComponent("inventoryitem") beggar:RemoveComponent("edible") beggar:RemoveComponent("perishable") beggar:RemoveComponent("burnable") beggar:RemoveComponent("propagator") beggar:RemoveTag("cattoy") beggar:AddComponent("follower") beggar.components.follower:SetLeader(GetPlayer()) beggar:AddComponent("health") beggar.components.health:SetMaxHealth(500) beggar.components.health:SetInvincible(true) beggar.components.health.nofadeout = true beggar:AddComponent("combat") beggar:DoPeriodicTask(math.random(10,60), function(beggar) beggar.SoundEmitter:PlaySound("dontstarve/characters/willow/hurt") beggar.AnimState:PlayAnimation("hungry") end ) beggar:AddComponent("trader") beggar.components.trader:SetAcceptTest(function(beggar, item) if GetPlayer().components.inventory:Has("goldnugget", 10) then if item.prefab == "goldnugget" then return true end end return false end ) beggar.components.trader.onaccept = function(beggar, giver, item) GetPlayer().components.inventory:ConsumeByName("goldnugget", 9) GetPlayer().components.sanity:DoDelta(5) beggar.components.locomotor:Stop() beggar:SetBrain(nil) beggar.components.follower:SetLeader(nil) beggar.AnimState:PlayAnimation("idle_onemanband1_loop",true) beggar:DoTaskInTime(5, function() beggar:Remove() end ) end beggar:ListenForEvent( "nighttime", function() beggar.components.locomotor:Stop() beggar:SetBrain(nil) beggar.components.follower:SetLeader(nil) beggar.AnimState:PlayAnimation("idle_shiver_pre") beggar.AnimState:PushAnimation("idle_shiver_loop") beggar.AnimState:PushAnimation("idle_shiver_pst", false) beggar:RemoveComponent("trader") beggar:DoTaskInTime(math.random(1,6), function() beggar.components.health:SetInvincible(false) beggar.components.health:Kill() end ) end, GetWorld()) beggar:ListenForEvent("death", function() GetPlayer():DoTaskInTime(2, function() GetPlayer().components.sanity:DoDelta(-10) end ) end ) beggar:AddTag("beggars") end end inst:ListenForEvent( "daytime", function() if math.random()<.3 then createbeggar(inst) end end , GetWorld()) 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/foliage.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function onsave(inst, data) if inst:HasTag("beggars") then data.beggars = true end end local function onload(inst, data) if data and data.beggars then inst.AnimState:SetBank("wilson") local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} local buildname = names[math.random(#names)] inst.AnimState:SetBuild(buildname) inst.Transform:SetScale(0.8, 0.8, 0.8) inst.AnimState:OverrideSymbol("swap_body", "armor_grass", "swap_body") inst.AnimState:Hide("ARM_carry") inst.AnimState:Show("ARM_normal") inst.AnimState:PlayAnimation("idle") local sound = inst.entity:AddSoundEmitter() local shadow = inst.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) inst.Transform:SetFourFaced() local brain = require "brains/chesterbrain" inst:SetBrain(brain) inst:AddComponent("knownlocations") inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 5 inst.components.locomotor.runspeed = 15 inst:SetStateGraph("SGshadowwaxwell") MakeCharacterPhysics(inst, 50, .5) inst:RemoveComponent("stackable") inst:RemoveComponent("tradable") inst:RemoveComponent("fuel") inst:RemoveComponent("inventoryitem") inst:RemoveComponent("edible") inst:RemoveComponent("perishable") inst:RemoveComponent("burnable") inst:RemoveComponent("propagator") inst:RemoveTag("cattoy") inst:AddComponent("follower") inst.components.follower:SetLeader(GetPlayer()) inst:AddComponent("health") inst.components.health:SetMaxHealth(500) inst.components.health:SetInvincible(true) inst.components.health.nofadeout = true inst:AddComponent("combat") inst:DoPeriodicTask(math.random(10,60), function(inst) inst.SoundEmitter:PlaySound("dontstarve/characters/willow/hurt") inst.AnimState:PlayAnimation("hungry") end ) inst:AddComponent("trader") inst.components.trader:SetAcceptTest(function(inst, item) if GetPlayer().components.inventory:Has("goldnugget", 10) then if item.prefab == "goldnugget" then return true end end return false end ) inst.components.trader.onaccept = function(inst, giver, item) GetPlayer().components.inventory:ConsumeByName("goldnugget", 9) GetPlayer().components.sanity:DoDelta(5) inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.follower:SetLeader(nil) inst.AnimState:PlayAnimation("idle_onemanband1_loop",true) inst:DoTaskInTime(5, function() inst:Remove() end ) end inst:ListenForEvent( "nighttime", function() inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.follower:SetLeader(nil) inst.AnimState:PlayAnimation("idle_shiver_pre") inst.AnimState:PushAnimation("idle_shiver_loop") inst.AnimState:PushAnimation("idle_shiver_pst", false) inst:RemoveComponent("trader") inst:DoTaskInTime(math.random(1,6), function() inst.components.health:SetInvincible(false) inst.components.health:Kill() end ) end, GetWorld()) inst:ListenForEvent("death", function() GetPlayer():DoTaskInTime(2, function() GetPlayer().components.sanity:DoDelta(-10) end ) end ) inst:AddTag("beggars") end end inst.OnSave = onsave inst.OnLoad = onload 即可开启一个独特的游戏模式,在饥荒世界这苦寒之地,有许多失去亲人的儿童正在忍饥挨饿,已经站稳脚跟的你,有责任帮助他们。不时会有孤儿向你乞讨,只要10个黄金(拿着黄金对儿童点鼠标左键),就能给予他们几天的温饱(儿童将离开),你也会获得心灵的宁静(补5点脑)。如果你不愿付出,他们也不会给你添任何麻烦,只是默默地跟随,期盼着一点点施舍。当黑夜来临时,他们将在你眼前冻饿而死,苍天为之动容(你将降10点脑),痛惜一个幼小生命的逝去。何去何从,由你自己决定。不要与“荒野之狼”一同修改

2025/04/23 · Bny

YN215-猪族崛起(大陆上不定期出现猪族部落,他们将与你争夺资源,如何与之相处呢?)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二一五.猪族崛起(大陆上不定期出现猪族部落,他们将与你争夺资源,如何与之相处呢?) 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/forest.lua文件,在inst:AddComponent("clock")的下一行插入以下内容: local function createpigtent(inst) local pt = Vector3(GetPlayer().Transform:GetWorldPosition()) local ground = GetWorld() local result_offset = FindValidPositionByFan(math.random()*2*PI, math.random(50, 80), 100, 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 pigtent = SpawnPrefab("mosquitosack") pigtent.Transform:SetPosition((pt + result_offset):Get()) pigtent.AnimState:SetBank("tent") pigtent.AnimState:SetBuild("tent") pigtent.AnimState:PlayAnimation("idle", true) local minimap = pigtent.entity:AddMiniMapEntity() minimap:SetIcon( "tent.png" ) pigtent.AnimState:SetMultColour(255/255,0/255,0/255,1) pigtent.Transform:SetScale(2, 2, 2) pigtent:RemoveComponent("stackable") pigtent:RemoveComponent("inventoryitem") pigtent:RemoveComponent("healer") pigtent:RemoveComponent("burnable") pigtent:RemoveComponent("propagator") pigtent:RemoveTag("cattoy") pigtent:AddTag("pigtents") pigtent:AddComponent("workable") pigtent.components.workable:SetWorkAction(ACTIONS.HAMMER) pigtent.components.workable:SetWorkLeft(15) pigtent.components.workable:SetOnFinishCallback(function(pigtent) SpawnPrefab("collapse_big").Transform:SetPosition(pigtent.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") pigtent:Remove() end ) pigtent.components.workable:SetOnWorkCallback(function(pigtent, worker, workleft) local pos = Vector3(pigtent.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 100) for k,v in pairs(ents) do if v:HasTag("pignpcs") then v.components.combat:SetTarget(worker) end end end) pigtent:ListenForEvent( "daytime", function() for k = 1,math.random(7,15) do local pt1 = pigtent:GetPosition() local pignpc = SpawnPrefab("mosquitosack") pignpc.Transform:SetPosition(pt1.x+(math.random(20)-math.random(20)), 0, pt1.z+(math.random(20)-math.random(20))) pignpc.entity:AddSoundEmitter() local shadow = pignpc.entity:AddDynamicShadow() shadow:SetSize( 1.5, .75 ) pignpc.AnimState:SetBank("pigman") pignpc.AnimState:SetBuild("pig_guard_build") pignpc.Transform:SetFourFaced() pignpc.Transform:SetScale(1.2, 1.2, 1.2) MakeCharacterPhysics(pignpc, 50, .5) 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"} local hat = hats[math.random(#hats)] pignpc.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") pignpc.AnimState:Show("hat") pignpc.AnimState:PlayAnimation("idle_loop") local brain = require "brains/leifbrain" pignpc:SetBrain(brain) local minimap = pignpc.entity:AddMiniMapEntity() minimap:SetIcon( "pigking.png" ) pignpc:AddComponent("locomotor") pignpc.components.locomotor.walkspeed = 5 pignpc.components.locomotor.runspeed = 10 pignpc:SetStateGraph("SGpig") pignpc:RemoveComponent("stackable") pignpc:RemoveComponent("inventoryitem") pignpc:RemoveComponent("healer") pignpc:RemoveComponent("burnable") pignpc:RemoveComponent("propagator") pignpc:RemoveTag("cattoy") pignpc:AddComponent("inventory") pignpc:AddComponent("follower") pignpc:AddComponent("knownlocations") pignpc:AddComponent("lootdropper") pignpc.components.lootdropper:SetLoot({"meat", "meat"}) pignpc:AddComponent("health") pignpc.components.health:SetMaxHealth(1000) pignpc:AddComponent("combat") pignpc.components.combat:SetDefaultDamage(20) pignpc.components.combat:SetAttackPeriod(1) pignpc.components.combat:SetRetargetFunction(3, function(pignpc) if not pignpc.components.health:IsDead() then return FindEntity(pignpc, 20, function(guy) if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("npcs") then return guy:HasTag("monster") or guy:HasTag("smallcreature") end end ) end end ) pignpc.components.combat:SetKeepTargetFunction(function(pignpc, target) return target and target:IsValid() end ) pignpc:ListenForEvent("attacked", function(pignpc, data) pignpc.components.combat:SetTarget(data.attacker) pignpc.components.combat:ShareTarget(data.attacker, 50, function(dude) return dude:HasTag("pignpcs") and not dude.components.health:IsDead() end, 10) end ) pignpc:DoPeriodicTask(1, function(pignpc) if not pignpc.components.health:IsDead() then local pos = Vector3(pignpc.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3) for k,v in pairs(ents) do if v.components.pickable and v.components.pickable:CanBePicked() then v.components.pickable:Pick(pignpc) end if v.components.crop then v.components.crop:Harvest(pignpc) end if v:HasTag("tree") and v.components.workable and v.components.workable.workleft > 0 then v.components.workable:Destroy(pignpc) end if v.components.edible and v.components.inventoryitem and not v.components.inventoryitem:IsHeld() then v:Remove() end end end end ) pignpc:ListenForEvent("death", function() for k = 1,math.random(1,3) do local pt2 = pignpc:GetPosition() local gold = SpawnPrefab("goldnugget") gold.Transform:SetPosition(pt2.x+(math.random(3)-math.random(3)), 0, pt2.z+(math.random(3)-math.random(3))) end end ) pignpc:ListenForEvent( "daytime", function() pignpc:Remove() end , GetWorld()) pignpc:AddTag("pignpcs") end end , GetWorld()) end end inst:ListenForEvent( "nighttime", function() if math.random()<0.2 then createpigtent(inst) end end , GetWorld()) 2.用MT管理器打开游戏目录/assets/scripts/prefabs/mosquitosack.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function onsave(inst, data) if inst:HasTag("pigtents") then data.pigtents = true end if inst:HasTag("pignpcs") then data.pignpcs = true end end local function onload(inst, data) if data and data.pigtents then inst.AnimState:SetBank("tent") inst.AnimState:SetBuild("tent") inst.AnimState:PlayAnimation("idle", true) local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon( "tent.png" ) inst.AnimState:SetMultColour(255/255,0/255,0/255,1) inst.Transform:SetScale(2, 2, 2) inst:RemoveComponent("stackable") inst:RemoveComponent("inventoryitem") inst:RemoveComponent("healer") inst:RemoveComponent("burnable") inst:RemoveComponent("propagator") inst:RemoveTag("cattoy") inst:AddTag("pigtents") inst:AddComponent("workable") inst.components.workable:SetWorkAction(ACTIONS.HAMMER) inst.components.workable:SetWorkLeft(15) inst.components.workable:SetOnFinishCallback(function(inst) SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") inst:Remove() end ) inst.components.workable:SetOnWorkCallback(function(inst, worker, workleft) local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 100) for k,v in pairs(ents) do if v:HasTag("pignpcs") then v.components.combat:SetTarget(worker) end end end) inst:ListenForEvent( "daytime", function() for k = 1,math.random(7,15) do local pt1 = inst:GetPosition() local pignpc = SpawnPrefab("mosquitosack") pignpc.Transform:SetPosition(pt1.x+(math.random(20)-math.random(20)), 0, pt1.z+(math.random(20)-math.random(20))) pignpc.entity:AddSoundEmitter() local shadow = pignpc.entity:AddDynamicShadow() shadow:SetSize( 1.5, .75 ) pignpc.AnimState:SetBank("pigman") pignpc.AnimState:SetBuild("pig_guard_build") pignpc.Transform:SetFourFaced() pignpc.Transform:SetScale(1.2, 1.2, 1.2) MakeCharacterPhysics(pignpc, 50, .5) 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"} local hat = hats[math.random(#hats)] pignpc.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") pignpc.AnimState:Show("hat") pignpc.AnimState:PlayAnimation("idle_loop") local brain = require "brains/leifbrain" pignpc:SetBrain(brain) local minimap = pignpc.entity:AddMiniMapEntity() minimap:SetIcon( "pigking.png" ) pignpc:AddComponent("locomotor") pignpc.components.locomotor.walkspeed = 5 pignpc.components.locomotor.runspeed = 10 pignpc:SetStateGraph("SGpig") pignpc:RemoveComponent("stackable") pignpc:RemoveComponent("inventoryitem") pignpc:RemoveComponent("healer") pignpc:RemoveComponent("burnable") pignpc:RemoveComponent("propagator") pignpc:RemoveTag("cattoy") pignpc:AddComponent("inventory") pignpc:AddComponent("follower") pignpc:AddComponent("knownlocations") pignpc:AddComponent("lootdropper") pignpc.components.lootdropper:SetLoot({"meat", "meat"}) pignpc:AddComponent("health") pignpc.components.health:SetMaxHealth(1000) pignpc:AddComponent("combat") pignpc.components.combat:SetDefaultDamage(20) pignpc.components.combat:SetAttackPeriod(1) pignpc.components.combat:SetRetargetFunction(3, function(pignpc) if not pignpc.components.health:IsDead() then return FindEntity(pignpc, 20, function(guy) if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("npcs") then return guy:HasTag("monster") or guy:HasTag("smallcreature") end end ) end end ) pignpc.components.combat:SetKeepTargetFunction(function(pignpc, target) return target and target:IsValid() end ) pignpc:ListenForEvent("attacked", function(pignpc, data) pignpc.components.combat:SetTarget(data.attacker) pignpc.components.combat:ShareTarget(data.attacker, 50, function(dude) return dude:HasTag("pignpcs") and not dude.components.health:IsDead() end, 10) end ) pignpc:DoPeriodicTask(1, function(pignpc) if not pignpc.components.health:IsDead() then local pos = Vector3(pignpc.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3) for k,v in pairs(ents) do if v.components.pickable and v.components.pickable:CanBePicked() then v.components.pickable:Pick(pignpc) end if v.components.crop then v.components.crop:Harvest(pignpc) end if v:HasTag("tree") and v.components.workable and v.components.workable.workleft > 0 then v.components.workable:Destroy(pignpc) end if v.components.edible and v.components.inventoryitem and not v.components.inventoryitem:IsHeld() then v:Remove() end end end end ) pignpc:ListenForEvent("death", function() for k = 1,math.random(1,3) do local pt2 = pignpc:GetPosition() local gold = SpawnPrefab("goldnugget") gold.Transform:SetPosition(pt2.x+(math.random(3)-math.random(3)), 0, pt2.z+(math.random(3)-math.random(3))) end end ) pignpc:ListenForEvent( "daytime", function() pignpc:Remove() end , GetWorld()) pignpc:AddTag("pignpcs") end end , GetWorld()) end if data and data.pignpcs then inst.entity:AddSoundEmitter() local shadow = inst.entity:AddDynamicShadow() shadow:SetSize( 1.5, .75 ) inst.AnimState:SetBank("pigman") inst.AnimState:SetBuild("pig_guard_build") inst.Transform:SetFourFaced() inst.Transform:SetScale(1.2, 1.2, 1.2) MakeCharacterPhysics(inst, 50, .5) 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"} local hat = hats[math.random(#hats)] inst.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") inst.AnimState:Show("hat") inst.AnimState:PlayAnimation("idle_loop") local brain = require "brains/leifbrain" inst:SetBrain(brain) local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon( "pigking.png" ) inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 5 inst.components.locomotor.runspeed = 10 inst:SetStateGraph("SGpig") inst:RemoveComponent("stackable") inst:RemoveComponent("inventoryitem") inst:RemoveComponent("healer") inst:RemoveComponent("burnable") inst:RemoveComponent("propagator") inst:RemoveTag("cattoy") inst:AddComponent("inventory") inst:AddComponent("follower") inst:AddComponent("knownlocations") inst:AddComponent("lootdropper") inst.components.lootdropper:SetLoot({"meat", "meat"}) inst:AddComponent("health") inst.components.health:SetMaxHealth(1000) inst:AddComponent("combat") inst.components.combat:SetDefaultDamage(20) inst.components.combat:SetAttackPeriod(1) inst.components.combat:SetRetargetFunction(3, function(inst) if not inst.components.health:IsDead() then return FindEntity(inst, 20, function(guy) if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("npcs") then return guy:HasTag("monster") or guy:HasTag("smallcreature") end end ) end end ) inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) inst:ListenForEvent("attacked", function(inst, data) inst.components.combat:SetTarget(data.attacker) inst.components.combat:ShareTarget(data.attacker, 50, function(dude) return dude:HasTag("pignpcs") and not dude.components.health:IsDead() end, 10) end ) inst:DoPeriodicTask(1, function(inst) if not inst.components.health:IsDead() then local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3) for k,v in pairs(ents) do if v.components.pickable and v.components.pickable:CanBePicked() then v.components.pickable:Pick(inst) end if v.components.crop then v.components.crop:Harvest(inst) end if v:HasTag("tree") and v.components.workable and v.components.workable.workleft > 0 then v.components.workable:Destroy(inst) end if v.components.edible and v.components.inventoryitem and not v.components.inventoryitem:IsHeld() then v:Remove() end end end end ) inst:ListenForEvent("death", function() for k = 1,math.random(1,3) do local pt2 = inst:GetPosition() local gold = SpawnPrefab("goldnugget") gold.Transform:SetPosition(pt2.x+(math.random(3)-math.random(3)), 0, pt2.z+(math.random(3)-math.random(3))) end end ) inst:ListenForEvent( "daytime", function() inst:Remove() end , GetWorld()) inst:AddTag("pignpcs") end end inst.OnSave = onsave inst.OnLoad = onload 即可在大陆上不定期出现猪族人的营地(红色的大帐篷),他们是新进化的亚人类,不会主动攻击你(会攻击怪物),但会与你争夺大陆上的资源,他们会砍伐森林、打猎、采集一切可以采集的植物(包括你的农田)。如果你进攻他们,将遭到抵抗,如果你拆毁他们的营地,也将被视为敌人,如果你用围墙将他们圈起来,猪族人也将毫不犹豫地拆毁它。是与猪族人和平相处,任由他们的不断壮大,还是与他们为敌,不断地进行猎杀,是摆在你面前的一道选择题。猪族营地在小地图上显示为帐篷图标,猪族人显示为猪王图标。用锤子砸15下可拆毁红色帐篷,被拆毁了帐篷的猪族部落,将在第二天天亮时离去

2025/04/23 · Bny