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

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

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

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二一三.红胡子强盗团(强盗团通过冒险之门入侵,烧杀抢掠,打死强盗可得黄金、武器) 3 4 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/forest.lua文件,在"puppet_wes",的下一行插入"puppet_woodie", 5 6 7 2.用MT管理器打开游戏目录/assets/scripts/prefabs/adventure_portal.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 8 9local function createbandit(inst) 10 for k = 1,math.random(20,35) do 11 local pt = inst:GetPosition() 12 local bandit = SpawnPrefab("beardhair") 13 bandit.Transform:SetPosition(pt.x+(math.random(50)-math.random(50)), 0, pt.z+(math.random(50)-math.random(50))) 14 bandit.AnimState:SetBank("wilson") 15 bandit.AnimState:SetBuild("woodie") 16 bandit.AnimState:OverrideSymbol("swap_hat", "hat_feather", "swap_hat") 17 bandit.AnimState:OverrideSymbol("swap_body", "armor_slurper", "swap_body") 18 bandit.AnimState:Show("HAT") 19 bandit.AnimState:Show("HAT_HAIR") 20 bandit.AnimState:Hide("HAIR_NOHAT") 21 bandit.AnimState:Hide("HAIR") 22 bandit.AnimState:Hide("ARM_carry") 23 bandit.AnimState:Show("ARM_normal") 24 bandit.AnimState:PlayAnimation("idle") 25 local sound = bandit.entity:AddSoundEmitter() 26 local shadow = bandit.entity:AddDynamicShadow() 27 shadow:SetSize( 1.3, .6 ) 28 bandit.Transform:SetFourFaced() 29 local brain = require "brains/frogbrain" 30 bandit:SetBrain(brain) 31 bandit:AddComponent("locomotor") 32 bandit.components.locomotor.walkspeed = 5 33 bandit.components.locomotor.runspeed = 10 34 bandit:SetStateGraph("SGshadowwaxwell") 35 MakeCharacterPhysics(bandit, 75, .5) 36 bandit:RemoveComponent("inventoryitem") 37 bandit:RemoveComponent("stackable") 38 bandit:RemoveComponent("fuel") 39 bandit:RemoveComponent("burnable") 40 bandit:RemoveComponent("propagator") 41 bandit:AddComponent("inventory") 42 bandit:AddComponent("thief") 43 bandit:AddComponent("knownlocations") 44 bandit:AddComponent("health") 45 bandit.components.health:SetMaxHealth(1500) 46 bandit:ListenForEvent("death", function() 47 local pt1 = bandit:GetPosition() 48 for k = 1,math.random(15,25) do 49 local gold = SpawnPrefab("goldnugget") 50 gold.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) 51 end 52 if math.random() < 0.1 then 53 local weapons = {"goldenaxe","spear","tentaclespike","batbat","ruins_bat"} 54 local weapon = weapons[math.random(#weapons)] 55 SpawnPrefab(weapon).Transform:SetPosition(pt1.x, 0, pt1.z) 56 end 57 end ) 58 bandit:AddComponent("combat") 59 bandit.components.combat:SetDefaultDamage(20) 60 bandit.components.combat:SetAttackPeriod(1) 61 bandit.components.combat:SetRetargetFunction(2, function(bandit) 62 if not bandit.components.health:IsDead() then 63 return FindEntity(bandit, 20, function(guy) 64 return bandit.components.combat:CanTarget(guy) and not guy:HasTag("bandits") 65 end ) 66 end 67 end ) 68 bandit.components.combat.onhitotherfn = function(bandit, other, damage) bandit.components.thief:StealItem(other) end 69 bandit:ListenForEvent("attacked", function(bandit, data) 70 bandit.components.combat:SetTarget(data.attacker) 71 bandit.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("bandits") and not dude.components.health:IsDead() end, 5) 72 end ) 73 bandit.Physics:SetCollisionCallback(function(bandit, other) 74 if other and other.components.workable and other.components.workable.workleft > 0 then 75 other.components.workable:Destroy(bandit) 76 end 77 end) 78 bandit:DoPeriodicTask(1, function(bandit) 79 local pos = Vector3(bandit.Transform:GetWorldPosition()) 80 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3) 81 for k,v in pairs(ents) do 82 if v.components.pickable and v.components.pickable:CanBePicked() then 83 v.components.pickable:Pick(bandit) 84 end 85 if v.components.crop then 86 v.components.crop:Harvest(bandit) 87 end 88 end 89 end ) 90 local minimap = bandit.entity:AddMiniMapEntity() 91 minimap:SetIcon( "lucy_axe.png" ) 92 bandit:AddTag("monster") 93 bandit:AddTag("bandits") 94 end 95end 96local function delbandit(inst) 97 local range = 3000 98 local pos = Vector3(inst.Transform:GetWorldPosition()) 99 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, range) 100 for k,v in pairs(ents) do 101 if v:HasTag("bandits") then 102 v:Remove() 103 end 104 end 105end 106 inst:ListenForEvent( "daytime", function() createbandit(inst) end , GetWorld()) 107 inst:ListenForEvent( "nighttime", function() delbandit(inst) end , GetWorld()) 108 109 110 3.用MT管理器打开游戏目录/assets/scripts/prefabs/beardhair.lua文件,在Asset("ANIM", "anim/beardhair.zip"),的下一行插入以下内容: 111 112 Asset("ANIM", "anim/woodie.zip"), 113 Asset("SOUND", "sound/woodie.fsb"), 114 115 116 4.在inst:AddComponent("inspectable")的下一行插入以下内容: 117 118local names = {"swap_goldenaxe","swap_spear","swap_spike","swap_batbat","swap_ruins_bat"} 119local weapon = names[math.random(#names)] 120local items = { SWORD = weapon } 121local function EquipItem(inst, item) 122 if item then 123 inst.AnimState:OverrideSymbol("swap_object", item, item) 124 inst.AnimState:Show("ARM_carry") 125 inst.AnimState:Hide("ARM_normal") 126 end 127end 128 inst.items = items 129 inst.equipfn = EquipItem 130 EquipItem(inst) 131local function onsave(inst, data) 132 if inst:HasTag("bandits") then 133 data.bandits = true 134 end 135end 136local function onload(inst, data) 137 if data and data.bandits then 138 inst.AnimState:SetBank("wilson") 139 inst.AnimState:SetBuild("woodie") 140 inst.AnimState:OverrideSymbol("swap_hat", "hat_feather", "swap_hat") 141 inst.AnimState:OverrideSymbol("swap_body", "armor_slurper", "swap_body") 142 inst.AnimState:Show("HAT") 143 inst.AnimState:Show("HAT_HAIR") 144 inst.AnimState:Hide("HAIR_NOHAT") 145 inst.AnimState:Hide("HAIR") 146 inst.AnimState:Hide("ARM_carry") 147 inst.AnimState:Show("ARM_normal") 148 inst.AnimState:PlayAnimation("idle") 149 local sound = inst.entity:AddSoundEmitter() 150 local shadow = inst.entity:AddDynamicShadow() 151 shadow:SetSize( 1.3, .6 ) 152 inst.Transform:SetFourFaced() 153 local brain = require "brains/frogbrain" 154 inst:SetBrain(brain) 155 inst:AddComponent("locomotor") 156 inst.components.locomotor.walkspeed = 5 157 inst.components.locomotor.runspeed = 10 158 inst:SetStateGraph("SGshadowwaxwell") 159 MakeCharacterPhysics(inst, 75, .5) 160 inst:RemoveComponent("inventoryitem") 161 inst:RemoveComponent("stackable") 162 inst:RemoveComponent("fuel") 163 inst:RemoveComponent("burnable") 164 inst:RemoveComponent("propagator") 165 inst:AddComponent("inventory") 166 inst:AddComponent("thief") 167 inst:AddComponent("knownlocations") 168 inst:AddComponent("health") 169 inst.components.health:SetMaxHealth(1500) 170 inst:ListenForEvent("death", function() 171 local pt1 = inst:GetPosition() 172 for k = 1,math.random(15,25) do 173 local gold = SpawnPrefab("goldnugget") 174 gold.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) 175 end 176 if math.random() < 0.1 then 177 local weapons = {"goldenaxe","spear","tentaclespike","batbat","ruins_bat"} 178 local weapon = weapons[math.random(#weapons)] 179 SpawnPrefab(weapon).Transform:SetPosition(pt1.x, 0, pt1.z) 180 end 181 end ) 182 inst:AddComponent("combat") 183 inst.components.combat:SetDefaultDamage(20) 184 inst.components.combat:SetAttackPeriod(1) 185 inst.components.combat:SetRetargetFunction(2, function(inst) 186 if not inst.components.health:IsDead() then 187 return FindEntity(inst, 20, function(guy) 188 return inst.components.combat:CanTarget(guy) and not guy:HasTag("bandits") 189 end ) 190 end 191 end ) 192 inst.components.combat.onhitotherfn = function(inst, other, damage) inst.components.thief:StealItem(other) end 193 inst:ListenForEvent("attacked", function(inst, data) 194 inst.components.combat:SetTarget(data.attacker) 195 inst.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("bandits") and not dude.components.health:IsDead() end, 5) 196 end ) 197 inst.Physics:SetCollisionCallback(function(inst, other) 198 if other and other.components.workable and other.components.workable.workleft > 0 then 199 other.components.workable:Destroy(inst) 200 end 201 end) 202 inst:DoPeriodicTask(1, function(inst) 203 local pos = Vector3(inst.Transform:GetWorldPosition()) 204 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3) 205 for k,v in pairs(ents) do 206 if v.components.pickable and v.components.pickable:CanBePicked() then 207 v.components.pickable:Pick(inst) 208 end 209 if v.components.crop then 210 v.components.crop:Harvest(inst) 211 end 212 end 213 end ) 214 local minimap = inst.entity:AddMiniMapEntity() 215 minimap:SetIcon( "lucy_axe.png" ) 216 inst:AddTag("monster") 217 inst:AddTag("bandits") 218 end 219end 220 inst.OnSave = onsave 221 inst.OnLoad = onload 222 223 即可有红胡子强盗通过冒险之门入侵你的大陆(修改后第2天早晨出现),他们将盘踞在冒险之门附近,毁坏森林、拆毁建筑、抢掠农作物,所到之处没有活口。通过小地图可查询强盗所在位置,显示为红斧子图标。与强盗交战时,他们会抢掠你身上的物品,并且附近的强盗将一起来围攻你,蛮干无异于送死,争取各个击破吧。从此在冒险之门周围,白天和傍晚都是危险的,只有漆黑的夜里,才是你可以喘息之际。打死强盗可获得战利品(不菲的黄金和他们抢来的赃物),还有一定概率掉落武器。如果同时修改了“雇佣兵工厂”,你的铁甲战团终于有了用武之地。同胞们,饥荒世界正遭遇重大危机,亿万苍生期盼着你,起兵去攻打强盗吧,这是旷日持久的反抗,也是正义而光荣的战争,用你的每一滴鲜血去证明,新一代的救世主,从此诞生了

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二一四.饥饿的儿童(不时有孤儿向你乞讨,施舍黄金后离开,否则跟随你直到午夜冻饿而死) 3 4 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/forest.lua文件,在inst:AddComponent("clock")的下一行插入以下内容: 5 6local function createbeggar(inst) 7 for k = 1,math.random(3,7) do 8 local pt = GetPlayer():GetPosition() 9 local beggar = SpawnPrefab("foliage") 10 beggar.Transform:SetPosition(pt.x+(math.random(50)-math.random(50)), 0, pt.z+(math.random(50)-math.random(50))) 11 beggar.AnimState:SetBank("wilson") 12 local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} 13 local buildname = names[math.random(#names)] 14 beggar.AnimState:SetBuild(buildname) 15 beggar.Transform:SetScale(0.8, 0.8, 0.8) 16 beggar.AnimState:OverrideSymbol("swap_body", "armor_grass", "swap_body") 17 beggar.AnimState:Hide("ARM_carry") 18 beggar.AnimState:Show("ARM_normal") 19 beggar.AnimState:PlayAnimation("idle") 20 local sound = beggar.entity:AddSoundEmitter() 21 local shadow = beggar.entity:AddDynamicShadow() 22 shadow:SetSize( 1.3, .6 ) 23 beggar.Transform:SetFourFaced() 24 local brain = require "brains/chesterbrain" 25 beggar:SetBrain(brain) 26 beggar:AddComponent("knownlocations") 27 beggar:AddComponent("locomotor") 28 beggar.components.locomotor.walkspeed = 5 29 beggar.components.locomotor.runspeed = 15 30 beggar:SetStateGraph("SGshadowwaxwell") 31 MakeCharacterPhysics(beggar, 50, .5) 32 beggar:RemoveComponent("stackable") 33 beggar:RemoveComponent("tradable") 34 beggar:RemoveComponent("fuel") 35 beggar:RemoveComponent("inventoryitem") 36 beggar:RemoveComponent("edible") 37 beggar:RemoveComponent("perishable") 38 beggar:RemoveComponent("burnable") 39 beggar:RemoveComponent("propagator") 40 beggar:RemoveTag("cattoy") 41 beggar:AddComponent("follower") 42 beggar.components.follower:SetLeader(GetPlayer()) 43 beggar:AddComponent("health") 44 beggar.components.health:SetMaxHealth(500) 45 beggar.components.health:SetInvincible(true) 46 beggar.components.health.nofadeout = true 47 beggar:AddComponent("combat") 48 beggar:DoPeriodicTask(math.random(10,60), function(beggar) 49 beggar.SoundEmitter:PlaySound("dontstarve/characters/willow/hurt") 50 beggar.AnimState:PlayAnimation("hungry") 51 end ) 52 beggar:AddComponent("trader") 53 beggar.components.trader:SetAcceptTest(function(beggar, item) 54 if GetPlayer().components.inventory:Has("goldnugget", 10) then 55 if item.prefab == "goldnugget" then 56 return true 57 end 58 end 59 return false 60 end ) 61 beggar.components.trader.onaccept = function(beggar, giver, item) 62 GetPlayer().components.inventory:ConsumeByName("goldnugget", 9) 63 GetPlayer().components.sanity:DoDelta(5) 64 beggar.components.locomotor:Stop() 65 beggar:SetBrain(nil) 66 beggar.components.follower:SetLeader(nil) 67 beggar.AnimState:PlayAnimation("idle_onemanband1_loop",true) 68 beggar:DoTaskInTime(5, function() beggar:Remove() end ) 69 end 70 beggar:ListenForEvent( "nighttime", function() 71 beggar.components.locomotor:Stop() 72 beggar:SetBrain(nil) 73 beggar.components.follower:SetLeader(nil) 74 beggar.AnimState:PlayAnimation("idle_shiver_pre") 75 beggar.AnimState:PushAnimation("idle_shiver_loop") 76 beggar.AnimState:PushAnimation("idle_shiver_pst", false) 77 beggar:RemoveComponent("trader") 78 beggar:DoTaskInTime(math.random(1,6), function() 79 beggar.components.health:SetInvincible(false) 80 beggar.components.health:Kill() 81 end ) 82 end, GetWorld()) 83 beggar:ListenForEvent("death", function() 84 GetPlayer():DoTaskInTime(2, function() 85 GetPlayer().components.sanity:DoDelta(-10) 86 end ) 87 end ) 88 beggar:AddTag("beggars") 89 end 90end 91 inst:ListenForEvent( "daytime", function() if math.random()<.3 then createbeggar(inst) end end , GetWorld()) 92 93 94 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/foliage.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 95 96local function onsave(inst, data) 97 if inst:HasTag("beggars") then 98 data.beggars = true 99 end 100end 101local function onload(inst, data) 102 if data and data.beggars then 103 inst.AnimState:SetBank("wilson") 104 local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} 105 local buildname = names[math.random(#names)] 106 inst.AnimState:SetBuild(buildname) 107 inst.Transform:SetScale(0.8, 0.8, 0.8) 108 inst.AnimState:OverrideSymbol("swap_body", "armor_grass", "swap_body") 109 inst.AnimState:Hide("ARM_carry") 110 inst.AnimState:Show("ARM_normal") 111 inst.AnimState:PlayAnimation("idle") 112 local sound = inst.entity:AddSoundEmitter() 113 local shadow = inst.entity:AddDynamicShadow() 114 shadow:SetSize( 1.3, .6 ) 115 inst.Transform:SetFourFaced() 116 local brain = require "brains/chesterbrain" 117 inst:SetBrain(brain) 118 inst:AddComponent("knownlocations") 119 inst:AddComponent("locomotor") 120 inst.components.locomotor.walkspeed = 5 121 inst.components.locomotor.runspeed = 15 122 inst:SetStateGraph("SGshadowwaxwell") 123 MakeCharacterPhysics(inst, 50, .5) 124 inst:RemoveComponent("stackable") 125 inst:RemoveComponent("tradable") 126 inst:RemoveComponent("fuel") 127 inst:RemoveComponent("inventoryitem") 128 inst:RemoveComponent("edible") 129 inst:RemoveComponent("perishable") 130 inst:RemoveComponent("burnable") 131 inst:RemoveComponent("propagator") 132 inst:RemoveTag("cattoy") 133 inst:AddComponent("follower") 134 inst.components.follower:SetLeader(GetPlayer()) 135 inst:AddComponent("health") 136 inst.components.health:SetMaxHealth(500) 137 inst.components.health:SetInvincible(true) 138 inst.components.health.nofadeout = true 139 inst:AddComponent("combat") 140 inst:DoPeriodicTask(math.random(10,60), function(inst) 141 inst.SoundEmitter:PlaySound("dontstarve/characters/willow/hurt") 142 inst.AnimState:PlayAnimation("hungry") 143 end ) 144 inst:AddComponent("trader") 145 inst.components.trader:SetAcceptTest(function(inst, item) 146 if GetPlayer().components.inventory:Has("goldnugget", 10) then 147 if item.prefab == "goldnugget" then 148 return true 149 end 150 end 151 return false 152 end ) 153 inst.components.trader.onaccept = function(inst, giver, item) 154 GetPlayer().components.inventory:ConsumeByName("goldnugget", 9) 155 GetPlayer().components.sanity:DoDelta(5) 156 inst.components.locomotor:Stop() 157 inst:SetBrain(nil) 158 inst.components.follower:SetLeader(nil) 159 inst.AnimState:PlayAnimation("idle_onemanband1_loop",true) 160 inst:DoTaskInTime(5, function() inst:Remove() end ) 161 end 162 inst:ListenForEvent( "nighttime", function() 163 inst.components.locomotor:Stop() 164 inst:SetBrain(nil) 165 inst.components.follower:SetLeader(nil) 166 inst.AnimState:PlayAnimation("idle_shiver_pre") 167 inst.AnimState:PushAnimation("idle_shiver_loop") 168 inst.AnimState:PushAnimation("idle_shiver_pst", false) 169 inst:RemoveComponent("trader") 170 inst:DoTaskInTime(math.random(1,6), function() 171 inst.components.health:SetInvincible(false) 172 inst.components.health:Kill() 173 end ) 174 end, GetWorld()) 175 inst:ListenForEvent("death", function() 176 GetPlayer():DoTaskInTime(2, function() 177 GetPlayer().components.sanity:DoDelta(-10) 178 end ) 179 end ) 180 inst:AddTag("beggars") 181 end 182end 183 inst.OnSave = onsave 184 inst.OnLoad = onload 185 186 即可开启一个独特的游戏模式,在饥荒世界这苦寒之地,有许多失去亲人的儿童正在忍饥挨饿,已经站稳脚跟的你,有责任帮助他们。不时会有孤儿向你乞讨,只要10个黄金(拿着黄金对儿童点鼠标左键),就能给予他们几天的温饱(儿童将离开),你也会获得心灵的宁静(补5点脑)。如果你不愿付出,他们也不会给你添任何麻烦,只是默默地跟随,期盼着一点点施舍。当黑夜来临时,他们将在你眼前冻饿而死,苍天为之动容(你将降10点脑),痛惜一个幼小生命的逝去。何去何从,由你自己决定。不要与“荒野之狼”一同修改

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二一五.猪族崛起(大陆上不定期出现猪族部落,他们将与你争夺资源,如何与之相处呢?) 3 4 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/forest.lua文件,在inst:AddComponent("clock")的下一行插入以下内容: 5 6local function createpigtent(inst) 7 local pt = Vector3(GetPlayer().Transform:GetWorldPosition()) 8 local ground = GetWorld() 9 local result_offset = FindValidPositionByFan(math.random()*2*PI, math.random(50, 80), 100, function(offset) 10 local x,y,z = (pt + offset):Get() 11 local ents = TheSim:FindEntities(x,y,z , 1) 12 return not next(ents) 13 end) 14 if result_offset and ground.Map:GetTileAtPoint((pt + result_offset):Get()) ~= GROUND.IMPASSABLE then 15 local pigtent = SpawnPrefab("mosquitosack") 16 pigtent.Transform:SetPosition((pt + result_offset):Get()) 17 pigtent.AnimState:SetBank("tent") 18 pigtent.AnimState:SetBuild("tent") 19 pigtent.AnimState:PlayAnimation("idle", true) 20 local minimap = pigtent.entity:AddMiniMapEntity() 21 minimap:SetIcon( "tent.png" ) 22 pigtent.AnimState:SetMultColour(255/255,0/255,0/255,1) 23 pigtent.Transform:SetScale(2, 2, 2) 24 pigtent:RemoveComponent("stackable") 25 pigtent:RemoveComponent("inventoryitem") 26 pigtent:RemoveComponent("healer") 27 pigtent:RemoveComponent("burnable") 28 pigtent:RemoveComponent("propagator") 29 pigtent:RemoveTag("cattoy") 30 pigtent:AddTag("pigtents") 31 pigtent:AddComponent("workable") 32 pigtent.components.workable:SetWorkAction(ACTIONS.HAMMER) 33 pigtent.components.workable:SetWorkLeft(15) 34 pigtent.components.workable:SetOnFinishCallback(function(pigtent) 35 SpawnPrefab("collapse_big").Transform:SetPosition(pigtent.Transform:GetWorldPosition()) 36 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 37 pigtent:Remove() 38 end ) 39 pigtent.components.workable:SetOnWorkCallback(function(pigtent, worker, workleft) 40 local pos = Vector3(pigtent.Transform:GetWorldPosition()) 41 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 100) 42 for k,v in pairs(ents) do 43 if v:HasTag("pignpcs") then 44 v.components.combat:SetTarget(worker) 45 end 46 end 47 end) 48 pigtent:ListenForEvent( "daytime", function() 49 for k = 1,math.random(7,15) do 50 local pt1 = pigtent:GetPosition() 51 local pignpc = SpawnPrefab("mosquitosack") 52 pignpc.Transform:SetPosition(pt1.x+(math.random(20)-math.random(20)), 0, pt1.z+(math.random(20)-math.random(20))) 53 pignpc.entity:AddSoundEmitter() 54 local shadow = pignpc.entity:AddDynamicShadow() 55 shadow:SetSize( 1.5, .75 ) 56 pignpc.AnimState:SetBank("pigman") 57 pignpc.AnimState:SetBuild("pig_guard_build") 58 pignpc.Transform:SetFourFaced() 59 pignpc.Transform:SetScale(1.2, 1.2, 1.2) 60 MakeCharacterPhysics(pignpc, 50, .5) 61 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"} 62 local hat = hats[math.random(#hats)] 63 pignpc.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") 64 pignpc.AnimState:Show("hat") 65 pignpc.AnimState:PlayAnimation("idle_loop") 66 local brain = require "brains/leifbrain" 67 pignpc:SetBrain(brain) 68 local minimap = pignpc.entity:AddMiniMapEntity() 69 minimap:SetIcon( "pigking.png" ) 70 pignpc:AddComponent("locomotor") 71 pignpc.components.locomotor.walkspeed = 5 72 pignpc.components.locomotor.runspeed = 10 73 pignpc:SetStateGraph("SGpig") 74 pignpc:RemoveComponent("stackable") 75 pignpc:RemoveComponent("inventoryitem") 76 pignpc:RemoveComponent("healer") 77 pignpc:RemoveComponent("burnable") 78 pignpc:RemoveComponent("propagator") 79 pignpc:RemoveTag("cattoy") 80 pignpc:AddComponent("inventory") 81 pignpc:AddComponent("follower") 82 pignpc:AddComponent("knownlocations") 83 pignpc:AddComponent("lootdropper") 84 pignpc.components.lootdropper:SetLoot({"meat", "meat"}) 85 pignpc:AddComponent("health") 86 pignpc.components.health:SetMaxHealth(1000) 87 pignpc:AddComponent("combat") 88 pignpc.components.combat:SetDefaultDamage(20) 89 pignpc.components.combat:SetAttackPeriod(1) 90 pignpc.components.combat:SetRetargetFunction(3, function(pignpc) 91 if not pignpc.components.health:IsDead() then 92 return FindEntity(pignpc, 20, function(guy) 93 if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("npcs") then 94 return guy:HasTag("monster") or guy:HasTag("smallcreature") 95 end 96 end ) 97 end 98 end ) 99 pignpc.components.combat:SetKeepTargetFunction(function(pignpc, target) return target and target:IsValid() end ) 100 pignpc:ListenForEvent("attacked", function(pignpc, data) 101 pignpc.components.combat:SetTarget(data.attacker) 102 pignpc.components.combat:ShareTarget(data.attacker, 50, function(dude) return dude:HasTag("pignpcs") and not dude.components.health:IsDead() end, 10) 103 end ) 104 pignpc:DoPeriodicTask(1, function(pignpc) 105 if not pignpc.components.health:IsDead() then 106 local pos = Vector3(pignpc.Transform:GetWorldPosition()) 107 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3) 108 for k,v in pairs(ents) do 109 if v.components.pickable and v.components.pickable:CanBePicked() then 110 v.components.pickable:Pick(pignpc) 111 end 112 if v.components.crop then 113 v.components.crop:Harvest(pignpc) 114 end 115 if v:HasTag("tree") and v.components.workable and v.components.workable.workleft > 0 then 116 v.components.workable:Destroy(pignpc) 117 end 118 if v.components.edible and v.components.inventoryitem and not v.components.inventoryitem:IsHeld() then 119 v:Remove() 120 end 121 end 122 end 123 end ) 124 pignpc:ListenForEvent("death", function() 125 for k = 1,math.random(1,3) do 126 local pt2 = pignpc:GetPosition() 127 local gold = SpawnPrefab("goldnugget") 128 gold.Transform:SetPosition(pt2.x+(math.random(3)-math.random(3)), 0, pt2.z+(math.random(3)-math.random(3))) 129 end 130 end ) 131 pignpc:ListenForEvent( "daytime", function() pignpc:Remove() end , GetWorld()) 132 pignpc:AddTag("pignpcs") 133 end 134 end , GetWorld()) 135 end 136end 137 inst:ListenForEvent( "nighttime", function() if math.random()<0.2 then createpigtent(inst) end end , GetWorld()) 138 139 140 2.用MT管理器打开游戏目录/assets/scripts/prefabs/mosquitosack.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 141 142local function onsave(inst, data) 143 if inst:HasTag("pigtents") then 144 data.pigtents = true 145 end 146 if inst:HasTag("pignpcs") then 147 data.pignpcs = true 148 end 149end 150local function onload(inst, data) 151 if data and data.pigtents then 152 inst.AnimState:SetBank("tent") 153 inst.AnimState:SetBuild("tent") 154 inst.AnimState:PlayAnimation("idle", true) 155 local minimap = inst.entity:AddMiniMapEntity() 156 minimap:SetIcon( "tent.png" ) 157 inst.AnimState:SetMultColour(255/255,0/255,0/255,1) 158 inst.Transform:SetScale(2, 2, 2) 159 inst:RemoveComponent("stackable") 160 inst:RemoveComponent("inventoryitem") 161 inst:RemoveComponent("healer") 162 inst:RemoveComponent("burnable") 163 inst:RemoveComponent("propagator") 164 inst:RemoveTag("cattoy") 165 inst:AddTag("pigtents") 166 inst:AddComponent("workable") 167 inst.components.workable:SetWorkAction(ACTIONS.HAMMER) 168 inst.components.workable:SetWorkLeft(15) 169 inst.components.workable:SetOnFinishCallback(function(inst) 170 SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) 171 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 172 inst:Remove() 173 end ) 174 inst.components.workable:SetOnWorkCallback(function(inst, worker, workleft) 175 local pos = Vector3(inst.Transform:GetWorldPosition()) 176 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 100) 177 for k,v in pairs(ents) do 178 if v:HasTag("pignpcs") then 179 v.components.combat:SetTarget(worker) 180 end 181 end 182 end) 183 inst:ListenForEvent( "daytime", function() 184 for k = 1,math.random(7,15) do 185 local pt1 = inst:GetPosition() 186 local pignpc = SpawnPrefab("mosquitosack") 187 pignpc.Transform:SetPosition(pt1.x+(math.random(20)-math.random(20)), 0, pt1.z+(math.random(20)-math.random(20))) 188 pignpc.entity:AddSoundEmitter() 189 local shadow = pignpc.entity:AddDynamicShadow() 190 shadow:SetSize( 1.5, .75 ) 191 pignpc.AnimState:SetBank("pigman") 192 pignpc.AnimState:SetBuild("pig_guard_build") 193 pignpc.Transform:SetFourFaced() 194 pignpc.Transform:SetScale(1.2, 1.2, 1.2) 195 MakeCharacterPhysics(pignpc, 50, .5) 196 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"} 197 local hat = hats[math.random(#hats)] 198 pignpc.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") 199 pignpc.AnimState:Show("hat") 200 pignpc.AnimState:PlayAnimation("idle_loop") 201 local brain = require "brains/leifbrain" 202 pignpc:SetBrain(brain) 203 local minimap = pignpc.entity:AddMiniMapEntity() 204 minimap:SetIcon( "pigking.png" ) 205 pignpc:AddComponent("locomotor") 206 pignpc.components.locomotor.walkspeed = 5 207 pignpc.components.locomotor.runspeed = 10 208 pignpc:SetStateGraph("SGpig") 209 pignpc:RemoveComponent("stackable") 210 pignpc:RemoveComponent("inventoryitem") 211 pignpc:RemoveComponent("healer") 212 pignpc:RemoveComponent("burnable") 213 pignpc:RemoveComponent("propagator") 214 pignpc:RemoveTag("cattoy") 215 pignpc:AddComponent("inventory") 216 pignpc:AddComponent("follower") 217 pignpc:AddComponent("knownlocations") 218 pignpc:AddComponent("lootdropper") 219 pignpc.components.lootdropper:SetLoot({"meat", "meat"}) 220 pignpc:AddComponent("health") 221 pignpc.components.health:SetMaxHealth(1000) 222 pignpc:AddComponent("combat") 223 pignpc.components.combat:SetDefaultDamage(20) 224 pignpc.components.combat:SetAttackPeriod(1) 225 pignpc.components.combat:SetRetargetFunction(3, function(pignpc) 226 if not pignpc.components.health:IsDead() then 227 return FindEntity(pignpc, 20, function(guy) 228 if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("npcs") then 229 return guy:HasTag("monster") or guy:HasTag("smallcreature") 230 end 231 end ) 232 end 233 end ) 234 pignpc.components.combat:SetKeepTargetFunction(function(pignpc, target) return target and target:IsValid() end ) 235 pignpc:ListenForEvent("attacked", function(pignpc, data) 236 pignpc.components.combat:SetTarget(data.attacker) 237 pignpc.components.combat:ShareTarget(data.attacker, 50, function(dude) return dude:HasTag("pignpcs") and not dude.components.health:IsDead() end, 10) 238 end ) 239 pignpc:DoPeriodicTask(1, function(pignpc) 240 if not pignpc.components.health:IsDead() then 241 local pos = Vector3(pignpc.Transform:GetWorldPosition()) 242 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3) 243 for k,v in pairs(ents) do 244 if v.components.pickable and v.components.pickable:CanBePicked() then 245 v.components.pickable:Pick(pignpc) 246 end 247 if v.components.crop then 248 v.components.crop:Harvest(pignpc) 249 end 250 if v:HasTag("tree") and v.components.workable and v.components.workable.workleft > 0 then 251 v.components.workable:Destroy(pignpc) 252 end 253 if v.components.edible and v.components.inventoryitem and not v.components.inventoryitem:IsHeld() then 254 v:Remove() 255 end 256 end 257 end 258 end ) 259 pignpc:ListenForEvent("death", function() 260 for k = 1,math.random(1,3) do 261 local pt2 = pignpc:GetPosition() 262 local gold = SpawnPrefab("goldnugget") 263 gold.Transform:SetPosition(pt2.x+(math.random(3)-math.random(3)), 0, pt2.z+(math.random(3)-math.random(3))) 264 end 265 end ) 266 pignpc:ListenForEvent( "daytime", function() pignpc:Remove() end , GetWorld()) 267 pignpc:AddTag("pignpcs") 268 end 269 end , GetWorld()) 270 end 271 if data and data.pignpcs then 272 inst.entity:AddSoundEmitter() 273 local shadow = inst.entity:AddDynamicShadow() 274 shadow:SetSize( 1.5, .75 ) 275 inst.AnimState:SetBank("pigman") 276 inst.AnimState:SetBuild("pig_guard_build") 277 inst.Transform:SetFourFaced() 278 inst.Transform:SetScale(1.2, 1.2, 1.2) 279 MakeCharacterPhysics(inst, 50, .5) 280 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"} 281 local hat = hats[math.random(#hats)] 282 inst.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") 283 inst.AnimState:Show("hat") 284 inst.AnimState:PlayAnimation("idle_loop") 285 local brain = require "brains/leifbrain" 286 inst:SetBrain(brain) 287 local minimap = inst.entity:AddMiniMapEntity() 288 minimap:SetIcon( "pigking.png" ) 289 inst:AddComponent("locomotor") 290 inst.components.locomotor.walkspeed = 5 291 inst.components.locomotor.runspeed = 10 292 inst:SetStateGraph("SGpig") 293 inst:RemoveComponent("stackable") 294 inst:RemoveComponent("inventoryitem") 295 inst:RemoveComponent("healer") 296 inst:RemoveComponent("burnable") 297 inst:RemoveComponent("propagator") 298 inst:RemoveTag("cattoy") 299 inst:AddComponent("inventory") 300 inst:AddComponent("follower") 301 inst:AddComponent("knownlocations") 302 inst:AddComponent("lootdropper") 303 inst.components.lootdropper:SetLoot({"meat", "meat"}) 304 inst:AddComponent("health") 305 inst.components.health:SetMaxHealth(1000) 306 inst:AddComponent("combat") 307 inst.components.combat:SetDefaultDamage(20) 308 inst.components.combat:SetAttackPeriod(1) 309 inst.components.combat:SetRetargetFunction(3, function(inst) 310 if not inst.components.health:IsDead() then 311 return FindEntity(inst, 20, function(guy) 312 if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("npcs") then 313 return guy:HasTag("monster") or guy:HasTag("smallcreature") 314 end 315 end ) 316 end 317 end ) 318 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) 319 inst:ListenForEvent("attacked", function(inst, data) 320 inst.components.combat:SetTarget(data.attacker) 321 inst.components.combat:ShareTarget(data.attacker, 50, function(dude) return dude:HasTag("pignpcs") and not dude.components.health:IsDead() end, 10) 322 end ) 323 inst:DoPeriodicTask(1, function(inst) 324 if not inst.components.health:IsDead() then 325 local pos = Vector3(inst.Transform:GetWorldPosition()) 326 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3) 327 for k,v in pairs(ents) do 328 if v.components.pickable and v.components.pickable:CanBePicked() then 329 v.components.pickable:Pick(inst) 330 end 331 if v.components.crop then 332 v.components.crop:Harvest(inst) 333 end 334 if v:HasTag("tree") and v.components.workable and v.components.workable.workleft > 0 then 335 v.components.workable:Destroy(inst) 336 end 337 if v.components.edible and v.components.inventoryitem and not v.components.inventoryitem:IsHeld() then 338 v:Remove() 339 end 340 end 341 end 342 end ) 343 inst:ListenForEvent("death", function() 344 for k = 1,math.random(1,3) do 345 local pt2 = inst:GetPosition() 346 local gold = SpawnPrefab("goldnugget") 347 gold.Transform:SetPosition(pt2.x+(math.random(3)-math.random(3)), 0, pt2.z+(math.random(3)-math.random(3))) 348 end 349 end ) 350 inst:ListenForEvent( "daytime", function() inst:Remove() end , GetWorld()) 351 inst:AddTag("pignpcs") 352 end 353end 354 inst.OnSave = onsave 355 inst.OnLoad = onload 356 357 即可在大陆上不定期出现猪族人的营地(红色的大帐篷),他们是新进化的亚人类,不会主动攻击你(会攻击怪物),但会与你争夺大陆上的资源,他们会砍伐森林、打猎、采集一切可以采集的植物(包括你的农田)。如果你进攻他们,将遭到抵抗,如果你拆毁他们的营地,也将被视为敌人,如果你用围墙将他们圈起来,猪族人也将毫不犹豫地拆毁它。是与猪族人和平相处,任由他们的不断壮大,还是与他们为敌,不断地进行猎杀,是摆在你面前的一道选择题。猪族营地在小地图上显示为帐篷图标,猪族人显示为猪王图标。用锤子砸15下可拆毁红色帐篷,被拆毁了帐篷的猪族部落,将在第二天天亮时离去

2025/04/23 · Bny

YN216-鬼影重重(夜晚墓地有大量亡魂游荡,购买亡魂之心让主角变身亡魂)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二一六.鬼影重重(夜晚墓地有大量亡魂游荡,购买亡魂之心让主角变身亡魂) 3 4 1.用MT管理器打开游戏目录/assets/scripts/prefabs/gravestone.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function createghostnpc(inst) 7 for k = 1,math.random(3,7) do 8 local pt = inst:GetPosition() 9 local ghostnpc = SpawnPrefab("deadlyfeast") 10 ghostnpc.Transform:SetPosition(pt.x+(math.random(20)-math.random(20)), 0, pt.z+(math.random(20)-math.random(20))) 11 ghostnpc.entity:AddSoundEmitter() 12 ghostnpc.AnimState:SetBank("ghost") 13 ghostnpc.AnimState:SetBuild("ghost_build") 14 ghostnpc.AnimState:PlayAnimation("idle", true) 15 ghostnpc.Transform:SetFourFaced() 16 MakeGhostPhysics(ghostnpc, 1, .5) 17 local minimap = ghostnpc.entity:AddMiniMapEntity() 18 minimap:SetIcon("whitespider_den.png") 19 ghostnpc.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 20 local light = ghostnpc.entity:AddLight() 21 light:SetIntensity(.6) 22 light:SetRadius(.5) 23 light:SetFalloff(.6) 24 light:Enable(true) 25 light:SetColour(180/255, 195/255, 225/255) 26 local brain = require "brains/leifbrain" 27 ghostnpc:SetBrain(brain) 28 ghostnpc:AddComponent("locomotor") 29 ghostnpc.components.locomotor.walkspeed = 5 30 ghostnpc.components.locomotor.runspeed = 5 31 ghostnpc:SetStateGraph("SGghost") 32 ghostnpc:AddTag("ghostnpcs") 33 ghostnpc:RemoveComponent("edible") 34 ghostnpc:RemoveComponent("inventoryitem") 35 ghostnpc:RemoveTag("meat") 36 ghostnpc:AddComponent("sanityaura") 37 ghostnpc.components.sanityaura.aura = -TUNING.SANITYAURA_SMALL 38 ghostnpc:AddComponent("health") 39 ghostnpc.components.health:SetMaxHealth(500) 40 ghostnpc:AddComponent("trader") 41 ghostnpc.components.trader:SetAcceptTest(function(ghostnpc, item) 42 if GetPlayer().components.inventory:Has("goldnugget", 30) then 43 if item.prefab == "goldnugget" then 44 return true 45 end 46 end 47 return false 48 end ) 49 ghostnpc.components.trader.onaccept = function(ghostnpc, giver, item) 50 GetPlayer().components.inventory:ConsumeByName("goldnugget", 29) 51 local ghostheart = SpawnPrefab("deadlyfeast") 52 ghostheart.AnimState:SetBank("egg") 53 ghostheart.AnimState:SetBuild("tallbird_egg") 54 ghostheart.AnimState:PlayAnimation("cooked") 55 ghostheart.components.inventoryitem:ChangeImageName("tallbirdegg_cooked") 56 ghostheart:RemoveComponent("edible") 57 ghostheart:RemoveTag("meat") 58 ghostheart:AddComponent("equippable") 59 ghostheart.components.equippable:SetOnEquip( function(ghostheart, owner) 60 if owner == GetPlayer() and not GetPlayer():HasTag("poisoning") and not GetPlayer():HasTag("fever") then 61 owner.components.locomotor:Stop() 62 owner.components.playercontroller:Enable(false) 63 owner:DoTaskInTime(0.3, function() 64 SpawnPrefab("collapse_big").Transform:SetPosition(owner.Transform:GetWorldPosition()) 65 owner.AnimState:SetBank("ghost") 66 owner.AnimState:SetBuild("ghost_build") 67 owner:SetStateGraph("SGghost") 68 owner.AnimState:PlayAnimation("idle", true) 69 owner.Transform:SetScale(1.2,1.2,1.2) 70 local shadow = owner.entity:AddDynamicShadow() 71 shadow:SetSize( 0, 0 ) 72 owner.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 73 local light = owner.entity:AddLight() 74 light:SetIntensity(.6) 75 light:SetRadius(20) 76 light:SetFalloff(.6) 77 light:Enable(true) 78 light:SetColour(180/255, 195/255, 225/255) 79 owner.components.locomotor.walkspeed = 20 80 owner.components.locomotor.runspeed = 20 81 owner.components.health:DoDelta(owner.components.health.maxhealth) 82 owner.components.health:SetInvincible(true) 83 owner.components.hunger:DoDelta(owner.components.hunger.max) 84 owner.components.hunger:Pause() 85 owner.components.sanity:DoDelta(owner.components.sanity.max) 86 owner.components.sanity.ignore = true 87 owner.components.combat:SetDefaultDamage(1000) 88 owner:AddComponent("aura") 89 owner.components.aura.radius = 3 90 owner.components.aura.tickperiod = 0.5 91 owner.components.aura.ignoreallies = true 92 owner.components.aura.auratestfn = function(ghostnpc, target) 93 if target.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == target then 94 return true 95 end 96 return false 97 end 98 owner.components.temperature:SetTemp(20) 99 owner.components.playercontroller:Enable(true) 100 end ) 101 end 102 end ) 103 ghostheart.components.equippable:SetOnUnequip( function(ghostheart, owner) 104 SpawnPrefab("collapse_big").Transform:SetPosition(owner.Transform:GetWorldPosition()) 105 owner.components.locomotor:Stop() 106 owner.components.playercontroller:Enable(false) 107 owner:DoTaskInTime(0.3, function() 108 owner.AnimState:SetBank("wilson") 109 if GetPlayer().prefab == "wilson" then owner.AnimState:SetBuild("wilson") end 110 if GetPlayer().prefab == "wendy" then owner.AnimState:SetBuild("wendy") end 111 if GetPlayer().prefab == "wes" then owner.AnimState:SetBuild("wes") end 112 if GetPlayer().prefab == "wickerbottom" then owner.AnimState:SetBuild("wickerbottom") end 113 if GetPlayer().prefab == "willow" then owner.AnimState:SetBuild("willow") end 114 if GetPlayer().prefab == "wolfgang" then owner.AnimState:SetBuild("wolfgang") end 115 if GetPlayer().prefab == "wx78" then owner.AnimState:SetBuild("wx78") end 116 if GetPlayer().prefab == "woodie" then owner.AnimState:SetBuild("woodie") end 117 if GetPlayer().prefab == "waxwell" then owner.AnimState:SetBuild("waxwell") end 118 if GetPlayer().prefab == "wathgrithr" then owner.AnimState:SetBuild("wathgrithr") end 119 if GetPlayer().prefab == "webber" then owner.AnimState:SetBuild("webber") end 120 owner:SetStateGraph("SGwilson") 121 owner.AnimState:PlayAnimation("idle") 122 owner.Transform:SetScale(1,1,1) 123 local shadow = owner.entity:AddDynamicShadow() 124 shadow:SetSize( 1.3, .6 ) 125 owner.AnimState:SetBloomEffectHandle("") 126 owner.Light:Enable(false) 127 owner.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED 128 owner.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED 129 owner.components.health:SetInvincible(false) 130 owner.components.hunger:Resume() 131 owner.components.sanity.ignore = false 132 owner.components.combat:SetDefaultDamage(TUNING.UNARMED_DAMAGE) 133 owner.components.combat.hiteffectsymbol = "torso" 134 owner:RemoveComponent("aura") 135 owner.components.temperature:SetTemp(nil) 136 owner.components.playercontroller:Enable(true) 137 ghostheart:Remove() 138 end ) 139 end ) 140 ghostheart.components.equippable.equipslot = EQUIPSLOTS.HANDS 141 ghostheart:AddTag("ghostheart") 142 GetPlayer().components.inventory:GiveItem(ghostheart) 143 end 144 ghostnpc:AddComponent("combat") 145 ghostnpc.components.combat:SetDefaultDamage(3) 146 ghostnpc.components.combat:SetAttackPeriod(1) 147 ghostnpc.components.combat:SetRetargetFunction(2, function(ghostnpc) 148 if not ghostnpc.components.health:IsDead() then 149 return FindEntity(ghostnpc, 25, function(guy) 150 if guy:HasTag("monster") then return guy end 151 if guy:HasTag("player") and guy.components.inventory and not guy.components.inventory:FindItem(function(item) return item.prefab == "nightmarefuel" end ) then return guy end 152 end ) 153 end 154 end ) 155 ghostnpc:ListenForEvent("attacked", function(ghostnpc, data) 156 ghostnpc.components.combat:SetTarget(data.attacker) 157 ghostnpc.components.combat:ShareTarget(data.attacker, 35, function(dude) return dude:HasTag("ghostnpcs") and not dude.components.health:IsDead() end, 5) 158 end ) 159 ghostnpc:AddComponent("aura") 160 ghostnpc.components.aura.radius = 2 161 ghostnpc.components.aura.tickperiod = 1 162 ghostnpc.components.aura.ignoreallies = true 163 ghostnpc.components.aura.auratestfn = function(ghostnpc, target) 164 if target:HasTag("ghostnpcs") then return false end 165 if target.components.combat.target == ghostnpc or ghostnpc.components.combat.target == target then 166 return true 167 end 168 end 169 ghostnpc:ListenForEvent("death", function() 170 local gems = {"purplegem","bluegem","redgem","orangegem","yellowgem","greengem","thulecite","goldnugget"} 171 local gem = gems[math.random(#gems)] 172 SpawnPrefab(gem).Transform:SetPosition(ghostnpc.Transform:GetWorldPosition()) 173 end ) 174 ghostnpc:ListenForEvent( "daytime", function() ghostnpc:Remove() end , GetWorld()) 175 end 176end 177 inst:ListenForEvent( "dusktime", function() createghostnpc(inst) end , GetWorld()) 178 179 180 2.用MT管理器打开游戏目录/assets/scripts/prefabs/deadlyfeast.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 181 182local function onsave(inst, data) 183 if inst:HasTag("ghostnpcs") then 184 data.ghostnpcs = true 185 end 186 if inst:HasTag("ghostheart") then 187 data.ghostheart = true 188 end 189end 190local function onload(inst, data) 191 if data and data.ghostnpcs then 192 inst.entity:AddSoundEmitter() 193 inst.AnimState:SetBank("ghost") 194 inst.AnimState:SetBuild("ghost_build") 195 inst.AnimState:PlayAnimation("idle", true) 196 inst.Transform:SetFourFaced() 197 MakeGhostPhysics(inst, 1, .5) 198 local minimap = inst.entity:AddMiniMapEntity() 199 minimap:SetIcon("whitespider_den.png") 200 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 201 local light = inst.entity:AddLight() 202 light:SetIntensity(.6) 203 light:SetRadius(.5) 204 light:SetFalloff(.6) 205 light:Enable(true) 206 light:SetColour(180/255, 195/255, 225/255) 207 local brain = require "brains/leifbrain" 208 inst:SetBrain(brain) 209 inst:AddComponent("locomotor") 210 inst.components.locomotor.walkspeed = 5 211 inst.components.locomotor.runspeed = 5 212 inst:SetStateGraph("SGghost") 213 inst:AddTag("ghostnpcs") 214 inst:RemoveComponent("edible") 215 inst:RemoveComponent("inventoryitem") 216 inst:RemoveTag("meat") 217 inst:AddComponent("sanityaura") 218 inst.components.sanityaura.aura = -TUNING.SANITYAURA_SMALL 219 inst:AddComponent("health") 220 inst.components.health:SetMaxHealth(500) 221 inst:AddComponent("trader") 222 inst.components.trader:SetAcceptTest(function(inst, item) 223 if GetPlayer().components.inventory:Has("goldnugget", 30) then 224 if item.prefab == "goldnugget" then 225 return true 226 end 227 end 228 return false 229 end ) 230 inst.components.trader.onaccept = function(inst, giver, item) 231 GetPlayer().components.inventory:ConsumeByName("goldnugget", 29) 232 local ghostheart = SpawnPrefab("deadlyfeast") 233 ghostheart.AnimState:SetBank("egg") 234 ghostheart.AnimState:SetBuild("tallbird_egg") 235 ghostheart.AnimState:PlayAnimation("cooked") 236 ghostheart.components.inventoryitem:ChangeImageName("tallbirdegg_cooked") 237 ghostheart:RemoveComponent("edible") 238 ghostheart:RemoveTag("meat") 239 ghostheart:AddComponent("equippable") 240 ghostheart.components.equippable:SetOnEquip( function(ghostheart, owner) 241 if owner == GetPlayer() and not GetPlayer():HasTag("poisoning") and not GetPlayer():HasTag("fever") then 242 owner.components.locomotor:Stop() 243 owner.components.playercontroller:Enable(false) 244 owner:DoTaskInTime(0.3, function() 245 SpawnPrefab("collapse_big").Transform:SetPosition(owner.Transform:GetWorldPosition()) 246 owner.AnimState:SetBank("ghost") 247 owner.AnimState:SetBuild("ghost_build") 248 owner:SetStateGraph("SGghost") 249 owner.AnimState:PlayAnimation("idle", true) 250 owner.Transform:SetScale(1.2,1.2,1.2) 251 local shadow = owner.entity:AddDynamicShadow() 252 shadow:SetSize( 0, 0 ) 253 owner.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 254 local light = owner.entity:AddLight() 255 light:SetIntensity(.6) 256 light:SetRadius(20) 257 light:SetFalloff(.6) 258 light:Enable(true) 259 light:SetColour(180/255, 195/255, 225/255) 260 owner.components.locomotor.walkspeed = 20 261 owner.components.locomotor.runspeed = 20 262 owner.components.health:DoDelta(owner.components.health.maxhealth) 263 owner.components.health:SetInvincible(true) 264 owner.components.hunger:DoDelta(owner.components.hunger.max) 265 owner.components.hunger:Pause() 266 owner.components.sanity:DoDelta(owner.components.sanity.max) 267 owner.components.sanity.ignore = true 268 owner.components.combat:SetDefaultDamage(1000) 269 owner:AddComponent("aura") 270 owner.components.aura.radius = 3 271 owner.components.aura.tickperiod = 0.5 272 owner.components.aura.ignoreallies = true 273 owner.components.aura.auratestfn = function(inst, target) 274 if target.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == target then 275 return true 276 end 277 return false 278 end 279 owner.components.temperature:SetTemp(20) 280 owner.components.playercontroller:Enable(true) 281 end ) 282 end 283 end ) 284 ghostheart.components.equippable:SetOnUnequip( function(ghostheart, owner) 285 SpawnPrefab("collapse_big").Transform:SetPosition(owner.Transform:GetWorldPosition()) 286 owner.components.locomotor:Stop() 287 owner.components.playercontroller:Enable(false) 288 owner:DoTaskInTime(0.3, function() 289 owner.AnimState:SetBank("wilson") 290 if GetPlayer().prefab == "wilson" then owner.AnimState:SetBuild("wilson") end 291 if GetPlayer().prefab == "wendy" then owner.AnimState:SetBuild("wendy") end 292 if GetPlayer().prefab == "wes" then owner.AnimState:SetBuild("wes") end 293 if GetPlayer().prefab == "wickerbottom" then owner.AnimState:SetBuild("wickerbottom") end 294 if GetPlayer().prefab == "willow" then owner.AnimState:SetBuild("willow") end 295 if GetPlayer().prefab == "wolfgang" then owner.AnimState:SetBuild("wolfgang") end 296 if GetPlayer().prefab == "wx78" then owner.AnimState:SetBuild("wx78") end 297 if GetPlayer().prefab == "woodie" then owner.AnimState:SetBuild("woodie") end 298 if GetPlayer().prefab == "waxwell" then owner.AnimState:SetBuild("waxwell") end 299 if GetPlayer().prefab == "wathgrithr" then owner.AnimState:SetBuild("wathgrithr") end 300 if GetPlayer().prefab == "webber" then owner.AnimState:SetBuild("webber") end 301 owner:SetStateGraph("SGwilson") 302 owner.AnimState:PlayAnimation("idle") 303 owner.Transform:SetScale(1,1,1) 304 local shadow = owner.entity:AddDynamicShadow() 305 shadow:SetSize( 1.3, .6 ) 306 owner.AnimState:SetBloomEffectHandle("") 307 owner.Light:Enable(false) 308 owner.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED 309 owner.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED 310 owner.components.health:SetInvincible(false) 311 owner.components.hunger:Resume() 312 owner.components.sanity.ignore = false 313 owner.components.combat:SetDefaultDamage(TUNING.UNARMED_DAMAGE) 314 owner.components.combat.hiteffectsymbol = "torso" 315 owner:RemoveComponent("aura") 316 owner.components.temperature:SetTemp(nil) 317 owner.components.playercontroller:Enable(true) 318 ghostheart:Remove() 319 end ) 320 end ) 321 ghostheart.components.equippable.equipslot = EQUIPSLOTS.HANDS 322 ghostheart:AddTag("ghostheart") 323 GetPlayer().components.inventory:GiveItem(ghostheart) 324 end 325 inst:AddComponent("combat") 326 inst.components.combat:SetDefaultDamage(3) 327 inst.components.combat:SetAttackPeriod(1) 328 inst.components.combat:SetRetargetFunction(2, function(inst) 329 if not inst.components.health:IsDead() then 330 return FindEntity(inst, 25, function(guy) 331 if guy:HasTag("monster") then return guy end 332 if guy:HasTag("player") and guy.components.inventory and not guy.components.inventory:FindItem(function(item) return item.prefab == "nightmarefuel" end ) then return guy end 333 end ) 334 end 335 end ) 336 inst:ListenForEvent("attacked", function(inst, data) 337 inst.components.combat:SetTarget(data.attacker) 338 inst.components.combat:ShareTarget(data.attacker, 35, function(dude) return dude:HasTag("ghostnpcs") and not dude.components.health:IsDead() end, 5) 339 end ) 340 inst:AddComponent("aura") 341 inst.components.aura.radius = 2 342 inst.components.aura.tickperiod = 1 343 inst.components.aura.ignoreallies = true 344 inst.components.aura.auratestfn = function(inst, target) 345 if target:HasTag("ghostnpcs") then return false end 346 if target.components.combat.target == inst or inst.components.combat.target == target then 347 return true 348 end 349 end 350 inst:ListenForEvent("death", function() 351 local gems = {"purplegem","bluegem","redgem","orangegem","yellowgem","greengem","thulecite","goldnugget"} 352 local gem = gems[math.random(#gems)] 353 SpawnPrefab(gem).Transform:SetPosition(inst.Transform:GetWorldPosition()) 354 end ) 355 inst:ListenForEvent( "daytime", function() inst:Remove() end , GetWorld()) 356 end 357 if data and data.ghostheart then 358 inst.AnimState:SetBank("egg") 359 inst.AnimState:SetBuild("tallbird_egg") 360 inst.AnimState:PlayAnimation("cooked") 361 inst.components.inventoryitem:ChangeImageName("tallbirdegg_cooked") 362 inst:RemoveComponent("edible") 363 inst:RemoveTag("meat") 364 inst:AddComponent("equippable") 365 inst.components.equippable:SetOnEquip( function(inst, owner) 366 if owner == GetPlayer() and not GetPlayer():HasTag("poisoning") and not GetPlayer():HasTag("fever") then 367 owner.components.locomotor:Stop() 368 owner.components.playercontroller:Enable(false) 369 owner:DoTaskInTime(0.3, function() 370 SpawnPrefab("collapse_big").Transform:SetPosition(owner.Transform:GetWorldPosition()) 371 owner.AnimState:SetBank("ghost") 372 owner.AnimState:SetBuild("ghost_build") 373 owner:SetStateGraph("SGghost") 374 owner.AnimState:PlayAnimation("idle", true) 375 owner.Transform:SetScale(1.2,1.2,1.2) 376 local shadow = owner.entity:AddDynamicShadow() 377 shadow:SetSize( 0, 0 ) 378 owner.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 379 local light = owner.entity:AddLight() 380 light:SetIntensity(.6) 381 light:SetRadius(20) 382 light:SetFalloff(.6) 383 light:Enable(true) 384 light:SetColour(180/255, 195/255, 225/255) 385 owner.components.locomotor.walkspeed = 20 386 owner.components.locomotor.runspeed = 20 387 owner.components.health:DoDelta(owner.components.health.maxhealth) 388 owner.components.health:SetInvincible(true) 389 owner.components.hunger:DoDelta(owner.components.hunger.max) 390 owner.components.hunger:Pause() 391 owner.components.sanity:DoDelta(owner.components.sanity.max) 392 owner.components.sanity.ignore = true 393 owner.components.combat:SetDefaultDamage(1000) 394 owner:AddComponent("aura") 395 owner.components.aura.radius = 3 396 owner.components.aura.tickperiod = 0.5 397 owner.components.aura.ignoreallies = true 398 owner.components.aura.auratestfn = function(ghostnpc, target) 399 if target.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == target then 400 return true 401 end 402 return false 403 end 404 owner.components.temperature:SetTemp(20) 405 owner.components.playercontroller:Enable(true) 406 end ) 407 end 408 end ) 409 inst.components.equippable:SetOnUnequip( function(inst, owner) 410 SpawnPrefab("collapse_big").Transform:SetPosition(owner.Transform:GetWorldPosition()) 411 owner.components.locomotor:Stop() 412 owner.components.playercontroller:Enable(false) 413 owner:DoTaskInTime(0.3, function() 414 owner.AnimState:SetBank("wilson") 415 if GetPlayer().prefab == "wilson" then owner.AnimState:SetBuild("wilson") end 416 if GetPlayer().prefab == "wendy" then owner.AnimState:SetBuild("wendy") end 417 if GetPlayer().prefab == "wes" then owner.AnimState:SetBuild("wes") end 418 if GetPlayer().prefab == "wickerbottom" then owner.AnimState:SetBuild("wickerbottom") end 419 if GetPlayer().prefab == "willow" then owner.AnimState:SetBuild("willow") end 420 if GetPlayer().prefab == "wolfgang" then owner.AnimState:SetBuild("wolfgang") end 421 if GetPlayer().prefab == "wx78" then owner.AnimState:SetBuild("wx78") end 422 if GetPlayer().prefab == "woodie" then owner.AnimState:SetBuild("woodie") end 423 if GetPlayer().prefab == "waxwell" then owner.AnimState:SetBuild("waxwell") end 424 if GetPlayer().prefab == "wathgrithr" then owner.AnimState:SetBuild("wathgrithr") end 425 if GetPlayer().prefab == "webber" then owner.AnimState:SetBuild("webber") end 426 owner:SetStateGraph("SGwilson") 427 owner.AnimState:PlayAnimation("idle") 428 owner.Transform:SetScale(1,1,1) 429 local shadow = owner.entity:AddDynamicShadow() 430 shadow:SetSize( 1.3, .6 ) 431 owner.AnimState:SetBloomEffectHandle("") 432 owner.Light:Enable(false) 433 owner.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED 434 owner.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED 435 owner.components.health:SetInvincible(false) 436 owner.components.hunger:Resume() 437 owner.components.sanity.ignore = false 438 owner.components.combat:SetDefaultDamage(TUNING.UNARMED_DAMAGE) 439 owner.components.combat.hiteffectsymbol = "torso" 440 owner:RemoveComponent("aura") 441 owner.components.temperature:SetTemp(nil) 442 owner.components.playercontroller:Enable(true) 443 inst:Remove() 444 end ) 445 end ) 446 inst.components.equippable.equipslot = EQUIPSLOTS.HANDS 447 inst:AddTag("ghostheart") 448 end 449end 450 inst.OnSave = onsave 451 inst.OnLoad = onload 452 453 即可在夜晚时,墓地有大量亡魂游荡,会主动攻击你,且靠近它们会降脑,消灭亡魂可获得宝石、铥矿石、黄金。亡魂在小地图上显示为白蜘蛛的图标。如果身上携带了噩梦燃料,亡魂就不会主动攻击你,给亡魂30个黄金(拿着黄金对亡魂点鼠标左键),可购买亡魂之心,装备它即可变身亡魂,生命、饥饿、脑全部锁死,按Ctrl + 鼠标左键攻击,且任何攻击你的敌人都会被自动烫死。卸载亡魂之心即可变回人,同时亡魂之心消失,想再变身就多买一些吧。如果修改了“小病小灾”,在主角感冒和食物中毒时,装备亡魂之心也不会变身

2025/04/23 · Bny

YN217-角斗场(用铥矿石种角斗场,参与生死角斗赚奖金,也可观看比赛)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二一七.角斗场(用铥矿石种角斗场,参与生死角斗赚奖金,也可观看比赛) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/thulecite.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local names = {"swap_goldenaxe","swap_spear","swap_spike","swap_batbat","swap_ruins_bat"} 7local weapon = names[math.random(#names)] 8local items = { SWORD = weapon } 9local function EquipItem(inst, item) 10 if item then 11 inst.AnimState:OverrideSymbol("swap_object", item, item) 12 inst.AnimState:Show("ARM_carry") 13 inst.AnimState:Hide("ARM_normal") 14 end 15end 16 inst.items = items 17 inst.equipfn = EquipItem 18 EquipItem(inst) 19local function fightgame(inst) 20 local pt = inst:GetPosition() 21 local gamehost = SpawnPrefab("thulecite") 22 gamehost.Transform:SetPosition(pt.x, pt.y, pt.z) 23 gamehost.AnimState:SetBank("wilson") 24 gamehost.AnimState:SetBuild("wolfgang") 25 gamehost.AnimState:OverrideSymbol("swap_hat", "hat_top", "swap_hat") 26 gamehost.AnimState:Show("HAT") 27 gamehost.AnimState:Show("HAT_HAIR") 28 gamehost.AnimState:Hide("HAIR_NOHAT") 29 gamehost.AnimState:Hide("HAIR") 30 gamehost.AnimState:Hide("ARM_carry") 31 gamehost.AnimState:Show("ARM_normal") 32 gamehost.Transform:SetFourFaced() 33 gamehost.AnimState:PlayAnimation("idle") 34 gamehost:RemoveComponent("repairer") 35 gamehost:RemoveComponent("edible") 36 gamehost:RemoveComponent("tradable") 37 gamehost:RemoveComponent("inventoryitem") 38 gamehost:RemoveComponent("stackable") 39 gamehost:RemoveComponent("deployable") 40 gamehost:RemoveComponent("bait") 41 gamehost:RemoveTag("molebait") 42 gamehost:AddTag("gamehost") 43 gamehost:AddComponent("workable") 44 gamehost.components.workable:SetWorkAction(ACTIONS.HAMMER) 45 gamehost.components.workable:SetWorkLeft(3) 46 gamehost.components.workable:SetOnFinishCallback(function(gamehost) 47 local pos = Vector3(gamehost.Transform:GetWorldPosition()) 48 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 50) 49 for k,v in pairs(ents) do 50 if v:HasTag("candel") then 51 SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition()) 52 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 53 v:Remove() 54 end 55 end 56 gamehost:Remove() 57 end ) 58 local fountain = SpawnPrefab("thulecite") 59 fountain.Transform:SetPosition(pt.x-11, 0, pt.z-11) 60 fountain.AnimState:SetBank("staff_purple_base") 61 fountain.AnimState:SetBuild("staff_purple_base") 62 fountain.AnimState:PlayAnimation("idle_full_loop") 63 fountain.Transform:SetScale(1.5, 1.5, 1.5) 64 fountain.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround ) 65 fountain.AnimState:SetLayer( LAYER_BACKGROUND ) 66 fountain.AnimState:SetSortOrder( 1 ) 67 fountain.Transform:SetRotation( 45 ) 68 fountain:AddTag("NOCLICK") 69 fountain:RemoveComponent("repairer") 70 fountain:RemoveComponent("edible") 71 fountain:RemoveComponent("tradable") 72 fountain:RemoveComponent("inventoryitem") 73 fountain:RemoveComponent("stackable") 74 fountain:RemoveComponent("deployable") 75 fountain:RemoveComponent("bait") 76 fountain:RemoveTag("molebait") 77 local light = fountain.entity:AddLight() 78 light:SetFalloff(1) 79 light:SetIntensity(.8) 80 light:SetRadius(18) 81 light:SetColour(180/255, 195/255, 50/255) 82 light:Enable(true) 83 fountain:AddTag("candel") 84 local pt0 = Vector3(fountain.Transform:GetWorldPosition()) 85 for k = 1, 60 do 86 local result_offset = FindValidPositionByFan(1 * 2 * PI, 12, 60, function(offset) 87 local x,y,z = (pt0 + offset):Get() 88 local ents = TheSim:FindEntities(x,y,z , 1) 89 return not next(ents) 90 end) 91 if result_offset then 92 local fence = SpawnPrefab("thulecite") 93 fence.AnimState:SetBank("marble_pillar") 94 fence.AnimState:SetBuild("marble_pillar") 95 fence.AnimState:PlayAnimation("full") 96 MakeObstaclePhysics(fence, 1) 97 fence:RemoveComponent("repairer") 98 fence:RemoveComponent("edible") 99 fence:RemoveComponent("tradable") 100 fence:RemoveComponent("inventoryitem") 101 fence:RemoveComponent("stackable") 102 fence:RemoveComponent("deployable") 103 fence:RemoveComponent("bait") 104 fence:RemoveTag("molebait") 105 fence:AddTag("candel") 106 fence.Transform:SetPosition((pt0 + result_offset):Get()) 107 end 108 end 109 gamehost:AddComponent("trader") 110 gamehost.components.trader:SetAcceptTest(function(gamehost, item) 111 if not gamehost:HasTag("startgame") then 112 if GetPlayer().components.inventory:Has("goldnugget", 100) then 113 if item.prefab == "goldnugget" then 114 return true 115 end 116 end 117 end 118 return false 119 end ) 120 gamehost.components.trader.onaccept = function(gamehost, giver, item) 121 GetPlayer().components.inventory:ConsumeByName("goldnugget", 99) 122 GetPlayer().components.locomotor:Stop() 123 GetPlayer().Transform:SetPosition(pt.x-11+5, 0, pt.z-11-5) 124 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/horn_beefalo") 125 gamehost:AddTag("startgame") 126 local warrior0 = SpawnPrefab("thulecite") 127 warrior0.Transform:SetPosition(pt.x-11-5, 0, pt.z-11+5) 128 warrior0.AnimState:SetBank("wilson") 129 local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} 130 local buildname = names[math.random(#names)] 131 warrior0.AnimState:SetBuild(buildname) 132 local hats = {"hat_beefalo","hat_feather","hat_football","hat_ruins","hat_slurper","hat_slurtle","hat_spider"} 133 local hat = hats[math.random(#hats)] 134 warrior0.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") 135 local armors = {"armor_grass","armor_marble","armor_ruins","armor_sanity","armor_slurper","armor_wood"} 136 local armor = armors[math.random(#armors)] 137 warrior0.AnimState:OverrideSymbol("swap_body", armor, "swap_body") 138 warrior0.AnimState:Show("HAT") 139 warrior0.AnimState:Show("HAT_HAIR") 140 warrior0.AnimState:Hide("HAIR_NOHAT") 141 warrior0.AnimState:Hide("HAIR") 142 warrior0.AnimState:Hide("ARM_carry") 143 warrior0.AnimState:Show("ARM_normal") 144 warrior0.AnimState:PlayAnimation("idle") 145 warrior0.Transform:SetFourFaced() 146 local sound = warrior0.entity:AddSoundEmitter() 147 local shadow = warrior0.entity:AddDynamicShadow() 148 shadow:SetSize( 1.3, .6 ) 149 local brain = require "brains/frogbrain" 150 warrior0:SetBrain(brain) 151 warrior0:AddComponent("locomotor") 152 warrior0.components.locomotor.walkspeed = 5 153 warrior0.components.locomotor.runspeed = 10 154 warrior0:SetStateGraph("SGshadowwaxwell") 155 MakeCharacterPhysics(warrior0, 75, .5) 156 warrior0:RemoveComponent("repairer") 157 warrior0:RemoveComponent("edible") 158 warrior0:RemoveComponent("tradable") 159 warrior0:RemoveComponent("inventoryitem") 160 warrior0:RemoveComponent("stackable") 161 warrior0:RemoveComponent("deployable") 162 warrior0:RemoveComponent("bait") 163 warrior0:RemoveTag("molebait") 164 warrior0:AddComponent("inventory") 165 warrior0:AddComponent("knownlocations") 166 warrior0:AddComponent("health") 167 warrior0.components.health:SetMaxHealth(math.random(2500,5000)) 168 warrior0:AddComponent("combat") 169 warrior0.components.combat:SetDefaultDamage(math.random(25,50)) 170 warrior0.components.combat:SetAttackPeriod(2) 171 warrior0.components.combat:SetRetargetFunction(1, function(warrior0) 172 if not warrior0.components.health:IsDead() then 173 return FindEntity(warrior0, 30, function(guy) 174 return guy:HasTag("player") 175 end ) 176 end 177 end ) 178 warrior0:DoPeriodicTask(1, function(warrior0) 179 if not warrior0:HasTag("noplay") then 180 if warrior0.components.health.currenthealth <= 100 then 181 warrior0:AddTag("noplay") 182 warrior0.components.combat:SetTarget(nil) 183 warrior0.components.combat:SetRetargetFunction(100, nil ) 184 end 185 if GetPlayer().components.health.currenthealth <= 51 then 186 warrior0.components.locomotor:Stop() 187 warrior0:SetBrain(nil) 188 warrior0:AddTag("noplay") 189 warrior0.components.combat:SetTarget(nil) 190 warrior0.components.combat:SetRetargetFunction(100, nil ) 191 warrior0.components.health:SetInvincible(true) 192 warrior0.AnimState:PlayAnimation("idle_onemanband1_loop",true) 193 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") 194 gamehost:DoTaskInTime(3, function() 195 warrior0:Remove() 196 GetPlayer().components.locomotor:Stop() 197 GetPlayer().Transform:SetPosition(pt.x-1, 0, pt.z+1) 198 if gamehost.task then gamehost.task:Cancel() gamehost.task = nil end 199 gamehost:RemoveTag("startgame") 200 end ) 201 end 202 end 203 end ) 204 warrior0:ListenForEvent("death", function() 205 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") 206 gamehost:DoTaskInTime(3, function() 207 GetPlayer().components.locomotor:Stop() 208 GetPlayer().Transform:SetPosition(pt.x-1, 0, pt.z+1) 209 for k = 1, 200 do 210 local goldnugget = SpawnPrefab("goldnugget") 211 GetPlayer().components.inventory:GiveItem(goldnugget) 212 end 213 if gamehost.task then gamehost.task:Cancel() gamehost.task = nil end 214 gamehost:RemoveTag("startgame") 215 end ) 216 end ) 217 warrior0:AddTag("candel") 218 gamehost.task = gamehost:DoPeriodicTask(1, function(gamehost) 219 local target = FindEntity(fountain, 13, function(guy) 220 return guy:HasTag("player") 221 end ) 222 if not target then 223 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") 224 warrior0:Remove() 225 if gamehost.task then gamehost.task:Cancel() gamehost.task = nil end 226 gamehost:RemoveTag("startgame") 227 end 228 end ) 229 end 230 gamehost.components.inspectable.getstatus = function(gamehost) 231 if not gamehost:HasTag("startgame") then 232 if GetPlayer().components.inventory:Has("goldnugget", 20) then 233 GetPlayer().components.inventory:ConsumeByName("goldnugget", 20) 234 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/horn_beefalo") 235 gamehost:AddTag("startgame") 236 local warrior1 = SpawnPrefab("thulecite") 237 warrior1.Transform:SetPosition(pt.x-11+5, 0, pt.z-11-5) 238 warrior1.AnimState:SetBank("wilson") 239 local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} 240 local buildname = names[math.random(#names)] 241 warrior1.AnimState:SetBuild(buildname) 242 local hats = {"hat_beefalo","hat_feather","hat_football","hat_ruins","hat_slurper","hat_slurtle","hat_spider"} 243 local hat = hats[math.random(#hats)] 244 warrior1.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") 245 local armors = {"armor_grass","armor_marble","armor_ruins","armor_sanity","armor_slurper","armor_wood"} 246 local armor = armors[math.random(#armors)] 247 warrior1.AnimState:OverrideSymbol("swap_body", armor, "swap_body") 248 warrior1.AnimState:Show("HAT") 249 warrior1.AnimState:Show("HAT_HAIR") 250 warrior1.AnimState:Hide("HAIR_NOHAT") 251 warrior1.AnimState:Hide("HAIR") 252 warrior1.AnimState:Hide("ARM_carry") 253 warrior1.AnimState:Show("ARM_normal") 254 warrior1.AnimState:PlayAnimation("idle") 255 warrior1.Transform:SetFourFaced() 256 local sound = warrior1.entity:AddSoundEmitter() 257 local shadow = warrior1.entity:AddDynamicShadow() 258 shadow:SetSize( 1.3, .6 ) 259 local brain = require "brains/frogbrain" 260 warrior1:SetBrain(brain) 261 warrior1:AddComponent("locomotor") 262 warrior1.components.locomotor.walkspeed = 5 263 warrior1.components.locomotor.runspeed = 10 264 warrior1:SetStateGraph("SGshadowwaxwell") 265 MakeCharacterPhysics(warrior1, 75, .5) 266 warrior1:RemoveComponent("repairer") 267 warrior1:RemoveComponent("edible") 268 warrior1:RemoveComponent("tradable") 269 warrior1:RemoveComponent("inventoryitem") 270 warrior1:RemoveComponent("stackable") 271 warrior1:RemoveComponent("deployable") 272 warrior1:RemoveComponent("bait") 273 warrior1:RemoveTag("molebait") 274 warrior1:AddComponent("inventory") 275 warrior1:AddComponent("knownlocations") 276 warrior1:AddComponent("health") 277 warrior1.components.health:SetMaxHealth(math.random(200,500)) 278 warrior1:AddComponent("combat") 279 warrior1.components.combat:SetDefaultDamage(math.random(25,100)) 280 warrior1.components.combat:SetAttackPeriod(3) 281 warrior1.components.combat:SetRetargetFunction(1, function(warrior1) 282 if not warrior1.components.health:IsDead() then 283 return FindEntity(warrior1, 30, function(guy) 284 return guy:HasTag("warrior2") 285 end ) 286 end 287 end ) 288 warrior1:AddTag("warrior1") 289 warrior1:AddTag("candel") 290 local warrior2 = SpawnPrefab("thulecite") 291 warrior2.Transform:SetPosition(pt.x-11-5, 0, pt.z-11+5) 292 warrior2.AnimState:SetBank("wilson") 293 local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} 294 local buildname = names[math.random(#names)] 295 warrior2.AnimState:SetBuild(buildname) 296 local hats = {"hat_beefalo","hat_feather","hat_football","hat_ruins","hat_slurper","hat_slurtle","hat_spider"} 297 local hat = hats[math.random(#hats)] 298 warrior2.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") 299 local armors = {"armor_grass","armor_marble","armor_ruins","armor_sanity","armor_slurper","armor_wood"} 300 local armor = armors[math.random(#armors)] 301 warrior2.AnimState:OverrideSymbol("swap_body", armor, "swap_body") 302 warrior2.AnimState:Show("HAT") 303 warrior2.AnimState:Show("HAT_HAIR") 304 warrior2.AnimState:Hide("HAIR_NOHAT") 305 warrior2.AnimState:Hide("HAIR") 306 warrior2.AnimState:Hide("ARM_carry") 307 warrior2.AnimState:Show("ARM_normal") 308 warrior2.AnimState:PlayAnimation("idle") 309 warrior2.Transform:SetFourFaced() 310 local sound = warrior2.entity:AddSoundEmitter() 311 local shadow = warrior2.entity:AddDynamicShadow() 312 shadow:SetSize( 1.3, .6 ) 313 local brain = require "brains/frogbrain" 314 warrior2:SetBrain(brain) 315 warrior2:AddComponent("locomotor") 316 warrior2.components.locomotor.walkspeed = 5 317 warrior2.components.locomotor.runspeed = 10 318 warrior2:SetStateGraph("SGshadowwaxwell") 319 MakeCharacterPhysics(warrior2, 75, .5) 320 warrior2:RemoveComponent("repairer") 321 warrior2:RemoveComponent("edible") 322 warrior2:RemoveComponent("tradable") 323 warrior2:RemoveComponent("inventoryitem") 324 warrior2:RemoveComponent("stackable") 325 warrior2:RemoveComponent("deployable") 326 warrior2:RemoveComponent("bait") 327 warrior2:RemoveTag("molebait") 328 warrior2:AddComponent("inventory") 329 warrior2:AddComponent("knownlocations") 330 warrior2:AddComponent("health") 331 warrior2.components.health:SetMaxHealth(math.random(200,500)) 332 warrior2:AddComponent("combat") 333 warrior2.components.combat:SetDefaultDamage(math.random(25,100)) 334 warrior2.components.combat:SetAttackPeriod(3) 335 warrior2.components.combat:SetRetargetFunction(1, function(warrior2) 336 if not warrior2.components.health:IsDead() then 337 return FindEntity(warrior2, 30, function(guy) 338 return guy:HasTag("warrior1") 339 end ) 340 end 341 end ) 342 warrior2:AddTag("warrior2") 343 warrior2:AddTag("candel") 344 warrior1:DoPeriodicTask(1, function(warrior1) 345 if not warrior1:HasTag("noplay") and not warrior2:HasTag("noplay") then 346 if warrior1.components.health.currenthealth <= 100 then 347 warrior1:AddTag("noplay") 348 warrior1.components.combat:SetTarget(nil) 349 warrior1.components.combat:SetRetargetFunction(100, nil ) 350 end 351 end 352 end ) 353 warrior2:DoPeriodicTask(1, function(warrior2) 354 if not warrior2:HasTag("noplay") and not warrior1:HasTag("noplay") then 355 if warrior2.components.health.currenthealth <= 100 then 356 warrior2:AddTag("noplay") 357 warrior2.components.combat:SetTarget(nil) 358 warrior2.components.combat:SetRetargetFunction(100, nil ) 359 end 360 end 361 end ) 362 warrior1:ListenForEvent("death", function() 363 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") 364 warrior2.components.locomotor:Stop() 365 warrior2:SetBrain(nil) 366 warrior2.AnimState:PlayAnimation("idle_onemanband1_loop",true) 367 gamehost:DoTaskInTime(3, function() warrior2:Remove() gamehost:RemoveTag("startgame") end ) 368 end ) 369 warrior2:ListenForEvent("death", function() 370 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") 371 warrior1.components.locomotor:Stop() 372 warrior1:SetBrain(nil) 373 warrior1.AnimState:PlayAnimation("idle_onemanband1_loop",true) 374 gamehost:DoTaskInTime(3, function() warrior1:Remove() gamehost:RemoveTag("startgame") end ) 375 end ) 376 end 377 end 378 end 379end 380local function OnDeploy (inst, pt) 381 fightgame(inst) 382 inst.components.stackable:Get():Remove() 383end 384 inst:AddComponent("deployable") 385 inst.components.deployable.ondeploy = OnDeploy 386local function onsave(inst, data) 387 if inst:HasTag("candel") then 388 data.candel = true 389 end 390 if inst:HasTag("gamehost") then 391 data.gamehost = true 392 end 393end 394local function onload(inst, data) 395 if data and data.candel then 396 inst:Remove() 397 end 398 if data and data.gamehost then 399 fightgame(inst) 400 inst:Remove() 401 end 402end 403 inst.OnSave = onsave 404 inst.OnLoad = onload 405 406 即可在开阔的空地上,用铥矿石种角斗场,(拿着1个铥矿石对地面点鼠标右键,如果拿着多个铥矿石,则不会种出来)。当身上有20个黄金时,鼠标左键点老板,可以观看一场角斗。如果想参加角斗,就给老板100个黄金(拿着黄金对老板点鼠标左键),你将进入角斗场与其他角斗士对战。如果击败对手,将获得本金加奖金共200个黄金;如果你的血量小于50,则判定你失败,对手会饶你不死,但本金将不会退回;如果你逃出围墙,同样判定你失败。每次与你对战的对手都不同,如果上一次失败,不代表下次不会胜利哦,作个职业的角斗士吧

2025/04/23 · Bny

YN218-潘多拉魔盒(用硬骨头种潘多拉魔盒,每60秒有一批怪物来袭,展开塔防吧)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二一八.潘多拉魔盒(用硬骨头种潘多拉魔盒,每60秒有一批怪物来袭,展开塔防吧) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/boneshard.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function makemagicbox(inst) 7 local pt = inst:GetPosition() 8 local magicbox = SpawnPrefab("boneshard") 9 magicbox.Transform:SetPosition(pt.x, pt.y, pt.z) 10 magicbox.AnimState:SetBank("pandoras_chest") 11 magicbox.AnimState:SetBuild("pandoras_chest") 12 magicbox.AnimState:PlayAnimation("closed") 13 magicbox.AnimState:SetMultColour(255/255,0/255,0/255,1) 14 magicbox.Transform:SetScale(0.8, 0.8, 0.8) 15 magicbox.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 16 local minimap = magicbox.entity:AddMiniMapEntity() 17 minimap:SetIcon( "pandoras_chest.png" ) 18 magicbox:RemoveComponent("inventoryitem") 19 magicbox:RemoveComponent("stackable") 20 magicbox:RemoveComponent("deployable") 21 magicbox:AddTag("magicbox") 22 magicbox:AddComponent("workable") 23 magicbox.components.workable:SetWorkAction(ACTIONS.HAMMER) 24 magicbox.components.workable:SetWorkLeft(3) 25 magicbox.components.workable:SetOnFinishCallback(function(magicbox) 26 local pos = Vector3(magicbox.Transform:GetWorldPosition()) 27 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) 28 for k,v in pairs(ents) do 29 if v:HasTag("bogey") then 30 SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition()) 31 v:Remove() 32 end 33 end 34 SpawnPrefab("collapse_big").Transform:SetPosition(magicbox.Transform:GetWorldPosition()) 35 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 36 magicbox:Remove() 37 end ) 38 magicbox.components.inspectable.getstatus = function(magicbox) 39 if not magicbox:HasTag("makebogey") then 40 magicbox:AddTag("makebogey") 41 magicbox.AnimState:PlayAnimation("open") 42 magicbox:DoTaskInTime(0.5, function(magicbox) 43 SpawnPrefab("collapse_small").Transform:SetPosition(magicbox.Transform:GetWorldPosition()) 44 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/horn_beefalo") 45 GetPlayer().components.playercontroller:ShakeCamera(magicbox, "FULL", 2.5, 0.03, 2, 30) 46 local pos = Vector3(magicbox.Transform:GetWorldPosition()) 47 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) 48 for k,v in pairs(ents) do 49 if v:HasTag("bogey") then 50 SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition()) 51 v:Remove() 52 end 53 end 54 local names = {"spiderqueen","hound","firehound","icehound","killerbee","walrus","leif","leif_sparse","koalefant_summer","koalefant_winter","deerclops","merm","knight","bishop","bat"} 55 magicbox.name = names[math.random(#names)] 56 for k = 1,math.random(10,30) do 57 local pt0 = magicbox:GetPosition() 58 local ground = GetWorld() 59 local x = pt0.x+(math.random(50)-math.random(50)) 60 local z = pt0.z+(math.random(50)-math.random(50)) 61 local tile = ground.Map:GetTileAtPoint(x,0, z) 62 if tile ~= GROUND.IMPASSABLE and tile ~= GROUND.INVALID then 63 local bogey = SpawnPrefab(magicbox.name) 64 bogey.Transform:SetPosition(x,0,z) 65 bogey:AddTag("bogey") 66 bogey.components.combat:SetRetargetFunction(1, function(bogey) 67 if not bogey.components.health:IsDead() then 68 return FindEntity(bogey, 100, function(guy) 69 if guy.components.health and not guy.components.health:IsDead() then 70 return guy:HasTag("player") 71 end 72 end ) 73 end 74 end ) 75 bogey.components.combat:SetKeepTargetFunction(function(bogey, target) return target and target:IsValid() end ) 76 bogey:ListenForEvent("attacked", function(bogey, data) 77 bogey.components.combat:SetTarget(GetPlayer()) 78 end ) 79 end 80 end 81 end ) 82 magicbox.task = magicbox:DoPeriodicTask(60, function(magicbox) 83 SpawnPrefab("collapse_small").Transform:SetPosition(magicbox.Transform:GetWorldPosition()) 84 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/horn_beefalo") 85 GetPlayer().components.playercontroller:ShakeCamera(magicbox, "FULL", 2.5, 0.03, 2, 30) 86 local pos = Vector3(magicbox.Transform:GetWorldPosition()) 87 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) 88 for k,v in pairs(ents) do 89 if v:HasTag("bogey") then 90 SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition()) 91 v:Remove() 92 end 93 end 94 local names = {"spiderqueen","hound","firehound","icehound","killerbee","walrus","leif","leif_sparse","koalefant_summer","koalefant_winter","deerclops","merm","knight","bishop","bat"} 95 magicbox.name = names[math.random(#names)] 96 for k = 1,math.random(10,30) do 97 local pt0 = magicbox:GetPosition() 98 local ground = GetWorld() 99 local x = pt0.x+(math.random(50)-math.random(50)) 100 local z = pt0.z+(math.random(50)-math.random(50)) 101 local tile = ground.Map:GetTileAtPoint(x,0, z) 102 if tile ~= GROUND.IMPASSABLE and tile ~= GROUND.INVALID then 103 local bogey = SpawnPrefab(magicbox.name) 104 bogey.Transform:SetPosition(x,0,z) 105 bogey:AddTag("bogey") 106 bogey.components.combat:SetRetargetFunction(1, function(bogey) 107 if not bogey.components.health:IsDead() then 108 return FindEntity(bogey, 100, function(guy) 109 if guy.components.health and not guy.components.health:IsDead() then 110 return guy:HasTag("player") 111 end 112 end ) 113 end 114 end ) 115 bogey.components.combat:SetKeepTargetFunction(function(bogey, target) return target and target:IsValid() end ) 116 bogey:ListenForEvent("attacked", function(bogey, data) 117 bogey.components.combat:SetTarget(GetPlayer()) 118 end ) 119 end 120 end 121 end ) 122 else 123 magicbox:RemoveTag("makebogey") 124 magicbox.AnimState:PlayAnimation("close") 125 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") 126 if magicbox.task then magicbox.task:Cancel() magicbox.task = nil end 127 local pos = Vector3(magicbox.Transform:GetWorldPosition()) 128 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) 129 for k,v in pairs(ents) do 130 if v:HasTag("bogey") then 131 SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition()) 132 v:Remove() 133 end 134 end 135 end 136 end 137end 138local function OnDeploy (inst, pt) 139 makemagicbox(inst) 140 inst.components.stackable:Get():Remove() 141end 142 inst:AddComponent("deployable") 143 inst.components.deployable.ondeploy = OnDeploy 144local function onsave(inst, data) 145 if inst:HasTag("magicbox") then 146 data.magicbox = true 147 end 148end 149local function onload(inst, data) 150 if data and data.magicbox then 151 makemagicbox(inst) 152 inst:Remove() 153 end 154end 155 inst.OnSave = onsave 156 inst.OnLoad = onload 157 158 即可用硬骨头种潘多拉魔盒,(拿着1个硬骨头对地面点鼠标右键,如果拿着多个,则不会种出来)。鼠标左键点魔盒,可打开盒子,每60秒将吹响一次号角,预示着新一批怪物来袭,且源源不绝,充分满足你求死不得的需要。鼠标左键再次点击魔盒,可让怪物回到盒中。建议围绕魔盒修建防御设施(如牙齿陷阱、眼睛炮塔等),否则你挺不过几个60秒的。潘多拉魔盒在小地图上显示为远古箱子图标,不想要潘多拉魔盒了,用锤子砸掉即可。硬骨头靠砸碎地图上的骨架获得

2025/04/23 · Bny

YN219-铁血蛮族(蛮族霸占虫洞,打死可得肉类、装备,带瓦丝格雷斯帽不被攻击,用大肉收买蛮族做手下)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二一九.铁血蛮族(蛮族霸占虫洞,打死可得肉类、装备,带瓦丝格雷斯帽不被攻击,用大肉收买蛮族做手下) 3 4 1.用MT管理器打开游戏目录/assets/scripts/prefabs/wormhole.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function createsavage(inst) 7 for k = 1,math.random(10,15) do 8 local pt = inst:GetPosition() 9 local savage = SpawnPrefab("hammer") 10 savage.Transform:SetPosition(pt.x+(math.random(30)-math.random(30)), 0, pt.z+(math.random(30)-math.random(30))) 11 savage.AnimState:SetBank("wilson") 12 savage.AnimState:SetBuild("wolfgang") 13 savage.AnimState:OverrideSymbol("swap_hat", "hat_wathgrithr", "swap_hat") 14 savage.AnimState:OverrideSymbol("swap_body", "torso_rain", "swap_body") 15 savage.AnimState:OverrideSymbol("swap_object", "swap_spear_wathgrithr", "swap_spear_wathgrithr") 16 savage.AnimState:Show("HAT") 17 savage.AnimState:Show("HAT_HAIR") 18 savage.AnimState:Hide("HAIR_NOHAT") 19 savage.AnimState:Hide("HAIR") 20 savage.AnimState:Hide("ARM_normal") 21 savage.AnimState:Show("ARM_carry") 22 savage.AnimState:PlayAnimation("idle") 23 savage.Transform:SetScale(1.2, 1.2, 1.2) 24 local sound = savage.entity:AddSoundEmitter() 25 local shadow = savage.entity:AddDynamicShadow() 26 shadow:SetSize( 1.3, .6 ) 27 savage.Transform:SetFourFaced() 28 MakeCharacterPhysics(savage, 100, .5) 29 local minimap = savage.entity:AddMiniMapEntity() 30 minimap:SetIcon( "wolfgang.png" ) 31 savage:AddComponent("locomotor") 32 savage.components.locomotor.walkspeed = 4 33 savage.components.locomotor.runspeed = 8 34 savage:SetStateGraph("SGshadowwaxwell") 35 local brain = require "brains/leifbrain" 36 savage:SetBrain(brain) 37 savage:RemoveComponent("weapon") 38 savage:RemoveComponent("tool") 39 savage:RemoveComponent("finiteuses") 40 savage:RemoveComponent("inventoryitem") 41 savage:RemoveComponent("equippable") 42 savage:RemoveTag("hammer") 43 savage:AddComponent("inventory") 44 savage:AddComponent("health") 45 savage.components.health:SetMaxHealth(2000) 46 savage:ListenForEvent("death", function() 47 local pt1 = savage:GetPosition() 48 for k = 1,math.random(5,10) do 49 local meatnames = {"meat","smallmeat","drumstick"} 50 local meatname = meatnames[math.random(#meatnames)] 51 local meat = SpawnPrefab(meatname) 52 meat.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) 53 end 54 if math.random() < 0.01 then 55 local lootnames = {"spear_wathgrithr","wathgrithrhat"} 56 local lootname = lootnames[math.random(#lootnames)] 57 local loot = SpawnPrefab(lootname) 58 loot.Transform:SetPosition(pt1.x, 0, pt1.z) 59 end 60 end ) 61 savage:AddComponent("combat") 62 savage.components.combat:SetDefaultDamage(30) 63 savage.components.combat:SetAttackPeriod(1.5) 64 savage.components.combat:SetRetargetFunction(3, function(savage) 65 if not savage.components.health:IsDead() then 66 return FindEntity(savage, 20, function(guy) 67 return savage.components.combat:CanTarget(guy) and not guy:HasTag("savages") and not guy:HasTag("goodsavages") 68 end ) 69 end 70 end ) 71 savage.components.combat:SetKeepTargetFunction(function(savage, target) return target and target:IsValid() end ) 72 savage:ListenForEvent("attacked", function(savage, data) 73 savage.components.combat:SetTarget(data.attacker) 74 savage.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("savages") and not dude:HasTag("mysavage") and not dude.components.health:IsDead() end, 5) 75 end ) 76 savage.Physics:SetCollisionCallback(function(savage, other) 77 if other and other.components.workable and other.components.workable.workleft > 0 then 78 other.components.workable:Destroy(savage) 79 end 80 end) 81 savage:ListenForEvent( "nighttime", function() savage:Remove() end , GetWorld()) 82 savage:AddComponent("trader") 83 savage.components.trader:SetAcceptTest(function(savage, item) 84 if GetPlayer():HasTag("goodsavages") then 85 if GetPlayer().components.inventory:Has("meat", 10) then 86 if item.prefab == "meat" then 87 return true 88 end 89 end 90 end 91 return false 92 end ) 93 savage.components.trader.onaccept = function(savage, giver, item) 94 GetPlayer().components.inventory:ConsumeByName("meat", 9) 95 savage:AddTag("mysavage") 96 savage.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 97 savage:AddComponent("follower") 98 savage.components.follower:SetLeader(GetPlayer()) 99 local brain = require "brains/abigailbrain" 100 savage:SetBrain(brain) 101 savage:RestartBrain() 102 savage.components.combat:SetAttackPeriod(1) 103 savage.components.combat:SetRetargetFunction(1, function(savage) 104 if not savage.components.health:IsDead() then 105 return FindEntity(GetPlayer(), 20, function(guy) 106 if guy.components.combat and guy.components.health and not guy.components.health:IsDead() then 107 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 108 end 109 end ) 110 end 111 end ) 112 savage:RemoveAllEventCallbacks() 113 savage:RemoveComponent("trader") 114 savage:ListenForEvent( "daytime", function() savage.components.health:DoDelta(2000) end , GetWorld()) 115 savage:ListenForEvent("attacked", function(savage, data) 116 savage.components.combat:SetTarget(data.attacker) 117 end ) 118 savage.Physics:SetCollisionCallback( nil ) 119 savage.components.inspectable.getstatus = function(savage) 120 if not savage:HasTag("stophere") then 121 savage:AddTag("stophere") 122 savage.components.locomotor:Stop() 123 savage:SetBrain(nil) 124 savage.components.follower:SetLeader(nil) 125 savage.AnimState:SetBloomEffectHandle("") 126 else 127 savage:RemoveTag("stophere") 128 local brain = require "brains/abigailbrain" 129 savage:SetBrain(brain) 130 savage:RestartBrain() 131 savage.components.follower:SetLeader(GetPlayer()) 132 savage.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 133 end 134 end 135 end 136 savage:AddTag("savages") 137 end 138end 139 inst:ListenForEvent( "daytime", function() createsavage(inst) end , GetWorld()) 140 141 142 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/hammer.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 143 144local items = { SWORD = "swap_spear_wathgrithr" } 145local function EquipItem(inst, item) 146 if item then 147 inst.AnimState:OverrideSymbol("swap_object", item, item) 148 inst.AnimState:Show("ARM_carry") 149 inst.AnimState:Hide("ARM_normal") 150 end 151end 152 inst.items = items 153 inst.equipfn = EquipItem 154 EquipItem(inst) 155local function onsave(inst, data) 156 if inst:HasTag("savages") then 157 data.savages = true 158 end 159 if inst:HasTag("mysavage") then 160 data.mysavage = true 161 end 162 if inst:HasTag("stophere") then 163 data.stophere = true 164 end 165end 166local function onload(inst, data) 167 if data and data.savages then 168 inst.AnimState:SetBank("wilson") 169 inst.AnimState:SetBuild("wolfgang") 170 inst.AnimState:OverrideSymbol("swap_hat", "hat_wathgrithr", "swap_hat") 171 inst.AnimState:OverrideSymbol("swap_body", "torso_rain", "swap_body") 172 inst.AnimState:OverrideSymbol("swap_object", "swap_spear_wathgrithr", "swap_spear_wathgrithr") 173 inst.AnimState:Show("HAT") 174 inst.AnimState:Show("HAT_HAIR") 175 inst.AnimState:Hide("HAIR_NOHAT") 176 inst.AnimState:Hide("HAIR") 177 inst.AnimState:Hide("ARM_normal") 178 inst.AnimState:Show("ARM_carry") 179 inst.AnimState:PlayAnimation("idle") 180 inst.Transform:SetScale(1.2, 1.2, 1.2) 181 local sound = inst.entity:AddSoundEmitter() 182 local shadow = inst.entity:AddDynamicShadow() 183 shadow:SetSize( 1.3, .6 ) 184 inst.Transform:SetFourFaced() 185 MakeCharacterPhysics(inst, 100, .5) 186 local minimap = inst.entity:AddMiniMapEntity() 187 minimap:SetIcon( "wolfgang.png" ) 188 inst:AddComponent("locomotor") 189 inst.components.locomotor.walkspeed = 4 190 inst.components.locomotor.runspeed = 8 191 inst:SetStateGraph("SGshadowwaxwell") 192 local brain = require "brains/leifbrain" 193 inst:SetBrain(brain) 194 inst:RemoveComponent("weapon") 195 inst:RemoveComponent("tool") 196 inst:RemoveComponent("finiteuses") 197 inst:RemoveComponent("inventoryitem") 198 inst:RemoveComponent("equippable") 199 inst:RemoveTag("hammer") 200 inst:AddComponent("inventory") 201 inst:AddComponent("health") 202 inst.components.health:SetMaxHealth(2000) 203 inst:ListenForEvent("death", function() 204 local pt1 = inst:GetPosition() 205 for k = 1,math.random(5,10) do 206 local meatnames = {"meat","smallmeat","drumstick"} 207 local meatname = meatnames[math.random(#meatnames)] 208 local meat = SpawnPrefab(meatname) 209 meat.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) 210 end 211 if math.random() < 0.01 then 212 local lootnames = {"spear_wathgrithr","wathgrithrhat"} 213 local lootname = lootnames[math.random(#lootnames)] 214 local loot = SpawnPrefab(lootname) 215 loot.Transform:SetPosition(pt1.x, 0, pt1.z) 216 end 217 end ) 218 inst:AddComponent("combat") 219 inst.components.combat:SetDefaultDamage(30) 220 inst.components.combat:SetAttackPeriod(1.5) 221 inst.components.combat:SetRetargetFunction(3, function(inst) 222 if not inst.components.health:IsDead() then 223 return FindEntity(inst, 20, function(guy) 224 return inst.components.combat:CanTarget(guy) and not guy:HasTag("savages") and not guy:HasTag("goodsavages") 225 end ) 226 end 227 end ) 228 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) 229 inst:ListenForEvent("attacked", function(inst, data) 230 inst.components.combat:SetTarget(data.attacker) 231 inst.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("savages") and not dude:HasTag("mysavage") and not dude.components.health:IsDead() end, 5) 232 end ) 233 inst.Physics:SetCollisionCallback(function(inst, other) 234 if other and other.components.workable and other.components.workable.workleft > 0 then 235 other.components.workable:Destroy(inst) 236 end 237 end) 238 inst:ListenForEvent( "nighttime", function() inst:Remove() end , GetWorld()) 239 inst:AddComponent("trader") 240 inst.components.trader:SetAcceptTest(function(inst, item) 241 if GetPlayer():HasTag("goodsavages") then 242 if GetPlayer().components.inventory:Has("meat", 10) then 243 if item.prefab == "meat" then 244 return true 245 end 246 end 247 end 248 return false 249 end ) 250 inst.components.trader.onaccept = function(inst, giver, item) 251 GetPlayer().components.inventory:ConsumeByName("meat", 9) 252 inst:AddTag("mysavage") 253 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 254 inst:AddComponent("follower") 255 inst.components.follower:SetLeader(GetPlayer()) 256 local brain = require "brains/abigailbrain" 257 inst:SetBrain(brain) 258 inst:RestartBrain() 259 inst.components.combat:SetAttackPeriod(1) 260 inst.components.combat:SetRetargetFunction(1, function(inst) 261 if not inst.components.health:IsDead() then 262 return FindEntity(GetPlayer(), 20, function(guy) 263 if guy.components.combat and guy.components.health and not guy.components.health:IsDead() then 264 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 265 end 266 end ) 267 end 268 end ) 269 inst:RemoveAllEventCallbacks() 270 inst:RemoveComponent("trader") 271 inst:ListenForEvent( "daytime", function() inst.components.health:DoDelta(2000) end , GetWorld()) 272 inst:ListenForEvent("attacked", function(inst, data) 273 inst.components.combat:SetTarget(data.attacker) 274 end ) 275 inst.Physics:SetCollisionCallback( nil ) 276 inst.components.inspectable.getstatus = function(inst) 277 if not inst:HasTag("stophere") then 278 inst:AddTag("stophere") 279 inst.components.locomotor:Stop() 280 inst:SetBrain(nil) 281 inst.components.follower:SetLeader(nil) 282 inst.AnimState:SetBloomEffectHandle("") 283 else 284 inst:RemoveTag("stophere") 285 local brain = require "brains/abigailbrain" 286 inst:SetBrain(brain) 287 inst:RestartBrain() 288 inst.components.follower:SetLeader(GetPlayer()) 289 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 290 end 291 end 292 end 293 inst:AddTag("savages") 294 end 295 if data and data.mysavage then 296 inst:AddTag("mysavage") 297 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 298 inst:AddComponent("follower") 299 inst.components.follower:SetLeader(GetPlayer()) 300 local brain = require "brains/abigailbrain" 301 inst:SetBrain(brain) 302 inst:RestartBrain() 303 inst.components.combat:SetAttackPeriod(1) 304 inst.components.combat:SetRetargetFunction(1, function(inst) 305 if not inst.components.health:IsDead() then 306 return FindEntity(GetPlayer(), 20, function(guy) 307 if guy.components.combat and guy.components.health and not guy.components.health:IsDead() then 308 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 309 end 310 end ) 311 end 312 end ) 313 inst:RemoveAllEventCallbacks() 314 inst:RemoveComponent("trader") 315 inst:ListenForEvent( "daytime", function() inst.components.health:DoDelta(2000) end , GetWorld()) 316 inst:ListenForEvent("attacked", function(inst, data) 317 inst.components.combat:SetTarget(data.attacker) 318 end ) 319 inst.Physics:SetCollisionCallback( nil ) 320 inst.components.inspectable.getstatus = function(inst) 321 if not inst:HasTag("stophere") then 322 inst:AddTag("stophere") 323 inst.components.locomotor:Stop() 324 inst:SetBrain(nil) 325 inst.components.follower:SetLeader(nil) 326 inst.AnimState:SetBloomEffectHandle("") 327 else 328 inst:RemoveTag("stophere") 329 local brain = require "brains/abigailbrain" 330 inst:SetBrain(brain) 331 inst:RestartBrain() 332 inst.components.follower:SetLeader(GetPlayer()) 333 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 334 end 335 end 336 end 337 if data and data.stophere then 338 inst:AddTag("stophere") 339 inst.components.locomotor:Stop() 340 inst:SetBrain(nil) 341 inst.components.follower:SetLeader(nil) 342 inst.AnimState:SetBloomEffectHandle("") 343 end 344end 345 inst.OnSave = onsave 346 inst.OnLoad = onload 347 348 349 3.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/hats.lua文件,在inst.components.armor:InitCondition(TUNING.ARMOR_WATHGRITHRHAT, TUNING.ARMOR_WATHGRITHRHAT_ABSORPTION)的下一行插入以下内容: 350 351 inst.components.equippable:SetOnEquip(function(inst, owner) 352 onequip(inst, owner) 353 if owner == GetPlayer() then 354 owner:AddTag("goodsavages") 355 end 356 end ) 357 inst.components.equippable:SetOnUnequip(function(inst, owner) 358 onunequip(inst, owner) 359 owner:RemoveTag("goodsavages") 360 end ) 361 362 即可有蛮族霸占虫洞附近的区域,白天和傍晚活动,黑夜消失。他们会攻击一切生物,拆毁建筑,通过小地图可查询蛮族所在位置,显示为沃尔夫冈图标。与蛮族对战时,他们会围攻你,打死蛮族可获得他们携带的肉类,还有一定概率获得瓦丝格雷斯帽和瓦丝格雷斯矛。装备瓦丝格雷斯帽,将被蛮族视为同类,从而免受攻击,并可以用10个大肉收买蛮族作手下(拿着大肉对蛮族点鼠标左键)。蛮族手下不会破坏建筑,无论受多重的伤,每天清晨都会恢复健康,鼠标左键点击(不要拿武器)蛮族手下可让其停留在原地,再次点击可继续跟随。从此开启与铁血蛮族共处的时代,作他们望而生畏的敌人,或带领他们征霸天下吧

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二二0.象之树(用紫色护身符种象之树,白天周围有巨象群活动,狩猎它们吧) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/amulet.lua文件,在inst.AnimState:PlayAnimation("purpleamulet")的下一行插入以下内容: 5 6local function makebananatree(inst) 7 local pt = inst:GetPosition() 8 local bananatree = SpawnPrefab("purpleamulet") 9 bananatree.Transform:SetPosition(pt.x, pt.y, pt.z) 10 bananatree.AnimState:SetBank("cave_banana_tree") 11 bananatree.AnimState:SetBuild("cave_banana_tree") 12 bananatree.AnimState:PlayAnimation("idle_loop",true) 13 bananatree.Transform:SetScale(1.5, 1.5, 1.5) 14 bananatree:AddComponent("named") 15 bananatree.components.named:SetName("Banana Tree") 16 bananatree:RemoveComponent("equippable") 17 bananatree:RemoveComponent("inventoryitem") 18 bananatree:RemoveComponent("fueled") 19 bananatree:RemoveComponent("deployable") 20 bananatree:AddComponent("workable") 21 bananatree.components.workable:SetWorkAction(ACTIONS.CHOP) 22 bananatree.components.workable:SetWorkLeft(10) 23 bananatree.components.workable:SetOnFinishCallback(function() 24 SpawnPrefab("collapse_big").Transform:SetPosition(bananatree.Transform:GetWorldPosition()) 25 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 26 bananatree:Remove() 27 end ) 28 bananatree:ListenForEvent( "daytime", function() 29 local pos = Vector3(bananatree.Transform:GetWorldPosition()) 30 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 5) 31 for k,v in pairs(ents) do 32 if v.components.inventoryitem and not v.components.inventoryitem:IsHeld() then 33 if v.prefab == "cave_banana" then 34 v:Remove() 35 end 36 end 37 end 38 bananatree:DoTaskInTime(0.3, function(bananatree) 39 bananatree:StartThread(function() 40 for k = 1,math.random(4,8) do 41 local pt1 = bananatree:GetPosition() 42 local banana = SpawnPrefab("cave_banana") 43 banana.Transform:SetPosition(pt1.x+(math.random(5)-math.random(5)), 5, pt1.z+(math.random(5)-math.random(5))) 44 Sleep(0.3) 45 end 46 end ) 47 end ) 48 for k = 1,math.random(5,10) do 49 local elephant = SpawnPrefab("purpleamulet") 50 elephant.Transform:SetPosition(pt.x+(math.random(30)-math.random(30)), 0, pt.z+(math.random(30)-math.random(30))) 51 elephant.AnimState:SetBank("koalefant") 52 elephant.AnimState:SetBuild("koalefant_winter_build") 53 elephant.AnimState:PlayAnimation("idle_loop", true) 54 local sound = elephant.entity:AddSoundEmitter() 55 local shadow = elephant.entity:AddDynamicShadow() 56 shadow:SetSize( 4.5, 2 ) 57 elephant.Transform:SetFourFaced() 58 MakeCharacterPhysics(elephant, 500, 1.5) 59 elephant:AddComponent("named") 60 elephant.components.named:SetName("Elephant") 61 elephant.Transform:SetScale(1.5, 1.5, 1.5) 62 local minimap = elephant.entity:AddMiniMapEntity() 63 minimap:SetIcon( "cave_banana_tree.png" ) 64 elephant:RemoveComponent("equippable") 65 elephant:RemoveComponent("inventoryitem") 66 elephant:RemoveComponent("fueled") 67 elephant:RemoveComponent("deployable") 68 elephant:AddComponent("knownlocations") 69 elephant:AddComponent("health") 70 elephant.components.health:SetMaxHealth(1000) 71 elephant:AddComponent("combat") 72 elephant.components.combat.hiteffectsymbol = "beefalo_body" 73 elephant.components.combat:SetDefaultDamage(30) 74 elephant.components.combat:SetAttackPeriod(2) 75 elephant.components.combat:SetRetargetFunction(3, function(elephant) 76 if not elephant.components.health:IsDead() then 77 return FindEntity(elephant, 25, function(guy) 78 return guy:HasTag("monster") 79 end ) 80 end 81 end ) 82 elephant.components.combat:SetKeepTargetFunction(function(elephant, target) return target and target:IsValid() end ) 83 elephant:ListenForEvent("attacked", function(elephant, data) 84 elephant.components.combat:SetTarget(data.attacker) 85 elephant.components.combat:ShareTarget(data.attacker, 10, function(dude) return dude:HasTag("elephants") and not dude.components.health:IsDead() end, 1) 86 end ) 87 elephant:AddComponent("lootdropper") 88 elephant.components.lootdropper:SetLoot({"meat","meat","meat","meat","meat","meat","meat","meat","meat","meat","trunk_winter"}) 89 elephant:AddComponent("locomotor") 90 elephant.components.locomotor.walkspeed = 2 91 elephant.components.locomotor.runspeed = 4 92 elephant:SetStateGraph("SGkoalefant") 93 local brain = require "brains/frogbrain" 94 elephant:SetBrain(brain) 95 elephant:ListenForEvent( "nighttime", function() elephant:Remove() end , GetWorld()) 96 elephant:DoPeriodicTask(math.random(30, 60), function(elephant) 97 if not elephant.components.combat.target then 98 local sgnames = {"bellow","graze","alert","shake"} 99 local sgname = sgnames[math.random(#sgnames)] 100 elephant.sg:GoToState(sgname) 101 end 102 end ) 103 elephant:DoPeriodicTask(math.random(120, 240), function(inst) 104 SpawnPrefab("poop").Transform:SetPosition(elephant.Transform:GetWorldPosition()) 105 end ) 106 if math.random() < 0.5 then 107 elephant:AddTag("redelephants") 108 elephant.AnimState:SetBuild("koalefant_summer_build") 109 elephant.components.lootdropper:SetLoot({"meat","meat","meat","meat","meat","meat","meat","meat","meat","meat","trunk_summer"}) 110 end 111 elephant:AddTag("elephants") 112 end 113 end , GetWorld()) 114 bananatree:AddTag("bananatree") 115end 116local function OnDeploy (inst, pt) 117 makebananatree(inst) 118 inst:Remove() 119end 120 inst:AddComponent("deployable") 121 inst.components.deployable.ondeploy = OnDeploy 122local function onsave(inst, data) 123 if inst:HasTag("bananatree") then 124 data.bananatree = true 125 end 126 if inst:HasTag("elephants") then 127 data.elephants = true 128 end 129 if inst:HasTag("redelephants") then 130 data.redelephants = true 131 end 132end 133local function onload(inst, data) 134 if data and data.bananatree then 135 makebananatree(inst) 136 inst:Remove() 137 end 138 if data and data.elephants then 139 inst.AnimState:SetBank("koalefant") 140 inst.AnimState:SetBuild("koalefant_winter_build") 141 inst.AnimState:PlayAnimation("idle_loop", true) 142 local sound = inst.entity:AddSoundEmitter() 143 local shadow = inst.entity:AddDynamicShadow() 144 shadow:SetSize( 4.5, 2 ) 145 inst.Transform:SetFourFaced() 146 MakeCharacterPhysics(inst, 500, 1.5) 147 inst:AddComponent("named") 148 inst.components.named:SetName("Elephant") 149 inst.Transform:SetScale(1.5, 1.5, 1.5) 150 local minimap = inst.entity:AddMiniMapEntity() 151 minimap:SetIcon( "cave_banana_tree.png" ) 152 inst:RemoveComponent("equippable") 153 inst:RemoveComponent("inventoryitem") 154 inst:RemoveComponent("fueled") 155 inst:RemoveComponent("deployable") 156 inst:AddComponent("knownlocations") 157 inst:AddComponent("health") 158 inst.components.health:SetMaxHealth(1000) 159 inst:AddComponent("combat") 160 inst.components.combat.hiteffectsymbol = "beefalo_body" 161 inst.components.combat:SetDefaultDamage(30) 162 inst.components.combat:SetAttackPeriod(2) 163 inst.components.combat:SetRetargetFunction(3, function(inst) 164 if not inst.components.health:IsDead() then 165 return FindEntity(inst, 25, function(guy) 166 return guy:HasTag("monster") 167 end ) 168 end 169 end ) 170 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) 171 inst:ListenForEvent("attacked", function(inst, data) 172 inst.components.combat:SetTarget(data.attacker) 173 inst.components.combat:ShareTarget(data.attacker, 10, function(dude) return dude:HasTag("elephants") and not dude.components.health:IsDead() end, 1) 174 end ) 175 inst:AddComponent("lootdropper") 176 inst.components.lootdropper:SetLoot({"meat","meat","meat","meat","meat","meat","meat","meat","meat","meat","trunk_winter"}) 177 inst:AddComponent("locomotor") 178 inst.components.locomotor.walkspeed = 2 179 inst.components.locomotor.runspeed = 4 180 inst:SetStateGraph("SGkoalefant") 181 local brain = require "brains/frogbrain" 182 inst:SetBrain(brain) 183 inst:ListenForEvent( "nighttime", function() inst:Remove() end , GetWorld()) 184 inst:DoPeriodicTask(math.random(30, 60), function(inst) 185 if not inst.components.combat.target then 186 local sgnames = {"bellow","graze","alert","shake"} 187 local sgname = sgnames[math.random(#sgnames)] 188 inst.sg:GoToState(sgname) 189 end 190 end ) 191 inst:DoPeriodicTask(math.random(120, 240), function(inst) 192 SpawnPrefab("poop").Transform:SetPosition(inst.Transform:GetWorldPosition()) 193 end ) 194 inst:AddTag("elephants") 195 end 196 if data and data.redelephants then 197 inst:AddTag("redelephants") 198 inst.AnimState:SetBuild("koalefant_summer_build") 199 inst.components.lootdropper:SetLoot({"meat","meat","meat","meat","meat","meat","meat","meat","meat","meat","trunk_summer"}) 200 end 201end 202 inst.OnSave = onsave 203 inst.OnLoad = onload 204 205 即可用紫色护身符种象之树,白天会掉落香蕉,并有巨象群在周围活动,夜晚离开。巨象不会主动攻击你,想狩猎它们时,尽量选择落单的巨象,否则其他巨象会一起反击。巨象在小地图上显示为香蕉图标,它们是天然的肉库,杀死一只可获得10块大肉及象鼻,并且会不断产便便,缺少肥料的话,可以在象之树附近拾取。不想要象之树了,砍掉即可,象群会在黑夜离去。紫色护身符在魔法选项(画着红骷髅)下,用6个黄金、4个噩梦燃料、2个紫宝石制造

2025/04/23 · Bny

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

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

2025/04/23 · Bny