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

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二00.养育孩子(主角逝去则孩子接班,一代一代生存下去) 3 4 1.用MT管理器打开游戏目录/assets/scripts/prefabs/minotaurhorn.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function getson (inst) 7 TheFrontEnd:Fade(false,1) 8 GetPlayer():DoTaskInTime(1.5, function() 9 TheFrontEnd:Fade(true,1) 10 local pt = GetPlayer():GetPosition() 11 local son = SpawnPrefab("resurrectionstatue") 12 son.Transform:SetPosition(pt.x, pt.y, pt.z) 13 son.AnimState:SetBank("wilson") 14 if GetPlayer().prefab == "wilson" then son.AnimState:SetBuild("wilson") end 15 if GetPlayer().prefab == "wendy" then son.AnimState:SetBuild("wendy") end 16 if GetPlayer().prefab == "wes" then son.AnimState:SetBuild("wes") end 17 if GetPlayer().prefab == "wickerbottom" then son.AnimState:SetBuild("wickerbottom") end 18 if GetPlayer().prefab == "willow" then son.AnimState:SetBuild("willow") end 19 if GetPlayer().prefab == "wolfgang" then son.AnimState:SetBuild("wolfgang_skinny") end 20 if GetPlayer().prefab == "wx78" then son.AnimState:SetBuild("wx78") end 21 if GetPlayer().prefab == "woodie" then son.AnimState:SetBuild("woodie") end 22 if GetPlayer().prefab == "waxwell" then son.AnimState:SetBuild("waxwell") end 23 if GetPlayer().prefab == "wathgrithr" then son.AnimState:SetBuild("wathgrithr") end 24 if GetPlayer().prefab == "webber" then son.AnimState:SetBuild("webber") end 25 local hats = {"hat_beefalo","hat_feather","hat_flower","hat_top","hat_walrus","hat_winter"} 26 local hat = hats[math.random(#hats)] 27 son.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") 28 local armors = {"armor_sanity","armor_slurper","armor_sweatervest","armor_trunkvest_summer","armor_trunkvest_winter"} 29 local armor = armors[math.random(#armors)] 30 son.AnimState:OverrideSymbol("swap_body", armor, "swap_body") 31 son.AnimState:Show("HAT") 32 son.AnimState:Show("HAT_HAIR") 33 son.AnimState:Hide("HAIR_NOHAT") 34 son.AnimState:Hide("HAIR") 35 son.AnimState:Hide("ARM_carry") 36 son.AnimState:Show("ARM_normal") 37 son.AnimState:PlayAnimation("idle") 38 son.AnimState:Hide("snow") 39 son.Transform:SetFourFaced() 40 son.Transform:SetScale(0.8,0.8,0.8) 41 son:AddComponent("combat") 42 son.components.combat.hiteffectsymbol = "torso" 43 son.components.combat:SetRetargetFunction(3, function(son) 44 if not son.components.health:IsDead() then 45 return FindEntity(son, 20, function(guy) 46 if guy.components.health and not guy.components.health:IsDead() then 47 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy 48 end 49 end) 50 end 51 end ) 52 son.components.combat:SetKeepTargetFunction(function(son, target) return target and target:IsValid() end ) 53 son.components.combat:SetAttackPeriod(1) 54 son.components.combat:SetRange(2, 3) 55 son.components.combat:SetDefaultDamage(10) 56 son:AddComponent("health") 57 son.components.health:SetMaxHealth(1000) 58 son.components.health.nofadeout = true 59 son:AddComponent("inventory") 60 son.components.inventory.dropondeath = false 61 son:AddComponent("locomotor") 62 son.components.locomotor.pathcaps = { ignorecreep = true } 63 son.components.locomotor.runspeed = 12 64 local brain = require"brains/shadowwaxwellbrain" 65 son:SetBrain(brain) 66 son:SetStateGraph("SGshadowwaxwell") 67 son:RemoveComponent("lootdropper") 68 son:RemoveComponent("workable") 69 son:RemoveComponent("burnable") 70 son:RemoveComponent("propagator") 71 MakeCharacterPhysics(son, 75, .5) 72 son:RemoveTag("structure") 73 son:AddComponent("follower") 74 son.components.follower.leader = GetPlayer() 75 son:AddComponent("trader") 76 son.components.trader:SetAcceptTest(function(son, item) 77 if GetPlayer().components.inventory:Has("goldnugget", 5) then 78 if item.prefab == "goldnugget" and son.components.health and not son.components.health:IsDead() then 79 return son.components.health:GetPercent() < .99 80 end 81 end 82 return false 83 end ) 84 son.components.trader.onaccept = function(son, giver, item) 85 GetPlayer().components.inventory:ConsumeByName("goldnugget", 4) 86 son.components.health:DoDelta(1000) 87 end 88 son:AddComponent("machine") 89 son.components.machine.turnonfn = function() son.components.locomotor:Stop() son.brain:Stop() end 90 son.components.machine.turnofffn = function() son.brain:Start() end 91 son:ListenForEvent("death", function() 92 GetPlayer().components.sanity:DoDelta(-100) 93 SpawnPrefab("trinket_1").Transform:SetPosition(son.Transform:GetWorldPosition()) 94 end ) 95 son:AddTag("companion") 96 son:AddTag("sons") 97 inst:Remove() 98 end ) 99end 100local function OnDeploy (inst, pt) 101 if GetPlayer().components.inventory:Has("goldnugget", 100) then 102 GetPlayer().components.inventory:ConsumeByName("goldnugget", 100) 103 local egg1 = SpawnPrefab("minotaurhorn") 104 egg1.AnimState:SetBuild("tallbird_egg") 105 egg1.AnimState:SetBank("egg") 106 egg1.AnimState:PlayAnimation("egg") 107 egg1.Transform:SetPosition(pt.x+2+3, pt.y, pt.z+2-3) 108 egg1.AnimState:SetMultColour(0/255,255/255,0/255,1) 109 egg1.Transform:SetScale(1.5,1.5,1.5) 110 egg1:AddComponent("health") 111 egg1.components.health:SetMaxHealth(1) 112 egg1:AddComponent("combat") 113 egg1:RemoveComponent("edible") 114 egg1.components.inventoryitem.canbepickedup = false 115 local egg2 = SpawnPrefab("minotaurhorn") 116 egg2.AnimState:SetBuild("tallbird_egg") 117 egg2.AnimState:SetBank("egg") 118 egg2.AnimState:PlayAnimation("egg") 119 egg2.Transform:SetPosition(pt.x+2-3, pt.y, pt.z+2+3) 120 egg2.AnimState:SetMultColour(0/255,255/255,0/255,1) 121 egg2.Transform:SetScale(1.5,1.5,1.5) 122 egg2:AddComponent("health") 123 egg2.components.health:SetMaxHealth(1) 124 egg2:AddComponent("combat") 125 egg2:RemoveComponent("edible") 126 egg2.components.inventoryitem.canbepickedup = false 127 egg1:ListenForEvent("death", function() egg1.AnimState:PlayAnimation("crack") egg2:Remove() 128 if math.random()<.5 then 129 local pt = GetPlayer():GetPosition() 130 GetSeasonManager():DoLightningStrike(pt) 131 inst:DoTaskInTime(1, function() getson(inst) end ) 132 else 133 SpawnPrefab("collapse_small").Transform:SetPosition(egg1.Transform:GetWorldPosition()) 134 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 135 end 136 end ) 137 egg2:ListenForEvent("death", function() egg2.AnimState:PlayAnimation("crack") egg1:Remove() 138 if math.random()<.5 then 139 local pt = GetPlayer():GetPosition() 140 GetSeasonManager():DoLightningStrike(pt) 141 inst:DoTaskInTime(2, function() getson(inst) end ) 142 else 143 SpawnPrefab("collapse_small").Transform:SetPosition(egg2.Transform:GetWorldPosition()) 144 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 145 end 146 end ) 147 end 148end 149 inst:AddComponent("deployable") 150 inst.components.deployable.ondeploy = OnDeploy 151 152 153 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/resurrectionstatue.lua文件,将下列内容: 154 155 inst.OnSave = onsave 156 inst.OnLoad = onload 157 158 替换为: 159 160local items = { AXE = "swap_axe", PICK = "swap_pickaxe", SWORD = "swap_spear" } 161local function EquipItem(inst, item) 162 if item then 163 inst.AnimState:OverrideSymbol("swap_object", item, item) 164 inst.AnimState:Show("ARM_carry") 165 inst.AnimState:Hide("ARM_normal") 166 end 167end 168 inst.items = items 169 inst.equipfn = EquipItem 170 EquipItem(inst) 171local function onsave2(inst, data) 172 if inst:HasTag("sons") then 173 data.sons = true 174 end 175end 176local function onload2(inst, data) 177 if data and data.sons then 178 inst.AnimState:SetBank("wilson") 179 if GetPlayer().prefab == "wilson" then inst.AnimState:SetBuild("wilson") end 180 if GetPlayer().prefab == "wendy" then inst.AnimState:SetBuild("wendy") end 181 if GetPlayer().prefab == "wes" then inst.AnimState:SetBuild("wes") end 182 if GetPlayer().prefab == "wickerbottom" then inst.AnimState:SetBuild("wickerbottom") end 183 if GetPlayer().prefab == "willow" then inst.AnimState:SetBuild("willow") end 184 if GetPlayer().prefab == "wolfgang" then inst.AnimState:SetBuild("wolfgang_skinny") end 185 if GetPlayer().prefab == "wx78" then inst.AnimState:SetBuild("wx78") end 186 if GetPlayer().prefab == "woodie" then inst.AnimState:SetBuild("woodie") end 187 if GetPlayer().prefab == "waxwell" then inst.AnimState:SetBuild("waxwell") end 188 if GetPlayer().prefab == "wathgrithr" then inst.AnimState:SetBuild("wathgrithr") end 189 if GetPlayer().prefab == "webber" then inst.AnimState:SetBuild("webber") end 190 local hats = {"hat_beefalo","hat_feather","hat_flower","hat_top","hat_walrus","hat_winter"} 191 local hat = hats[math.random(#hats)] 192 inst.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") 193 local armors = {"armor_sanity","armor_slurper","armor_sweatervest","armor_trunkvest_summer","armor_trunkvest_winter"} 194 local armor = armors[math.random(#armors)] 195 inst.AnimState:OverrideSymbol("swap_body", armor, "swap_body") 196 inst.AnimState:Show("HAT") 197 inst.AnimState:Show("HAT_HAIR") 198 inst.AnimState:Hide("HAIR_NOHAT") 199 inst.AnimState:Hide("HAIR") 200 inst.AnimState:Hide("ARM_carry") 201 inst.AnimState:Show("ARM_normal") 202 inst.AnimState:PlayAnimation("idle") 203 inst.AnimState:Hide("snow") 204 inst.Transform:SetFourFaced() 205 inst.Transform:SetScale(0.8,0.8,0.8) 206 inst:AddComponent("combat") 207 inst.components.combat.hiteffectsymbol = "torso" 208 inst.components.combat:SetRetargetFunction(3, function(inst) 209 if not inst.components.health:IsDead() then 210 return FindEntity(inst, 20, function(guy) 211 if guy.components.health and not guy.components.health:IsDead() then 212 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy 213 end 214 end) 215 end 216 end ) 217 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) 218 inst.components.combat:SetAttackPeriod(1) 219 inst.components.combat:SetRange(2, 3) 220 inst.components.combat:SetDefaultDamage(10) 221 inst:AddComponent("health") 222 inst.components.health:SetMaxHealth(1000) 223 inst.components.health.nofadeout = true 224 inst:AddComponent("inventory") 225 inst.components.inventory.dropondeath = false 226 inst:AddComponent("locomotor") 227 inst.components.locomotor.pathcaps = { ignorecreep = true } 228 inst.components.locomotor.runspeed = 12 229 local brain = require"brains/shadowwaxwellbrain" 230 inst:SetBrain(brain) 231 inst:SetStateGraph("SGshadowwaxwell") 232 inst:RemoveComponent("lootdropper") 233 inst:RemoveComponent("workable") 234 inst:RemoveComponent("burnable") 235 inst:RemoveComponent("propagator") 236 MakeCharacterPhysics(inst, 75, .5) 237 inst:RemoveTag("structure") 238 inst:AddComponent("follower") 239 inst.components.follower.leader = GetPlayer() 240 inst:AddComponent("trader") 241 inst.components.trader:SetAcceptTest(function(inst, item) 242 if GetPlayer().components.inventory:Has("goldnugget", 5) then 243 if item.prefab == "goldnugget" and inst.components.health and not inst.components.health:IsDead() then 244 return inst.components.health:GetPercent() < .99 245 end 246 end 247 return false 248 end ) 249 inst.components.trader.onaccept = function(inst, giver, item) 250 GetPlayer().components.inventory:ConsumeByName("goldnugget", 4) 251 inst.components.health:DoDelta(1000) 252 end 253 inst:AddComponent("machine") 254 inst.components.machine.turnonfn = function() inst.components.locomotor:Stop() inst.brain:Stop() end 255 inst.components.machine.turnofffn = function() inst.brain:Start() end 256 inst:ListenForEvent("death", function() 257 GetPlayer().components.sanity:DoDelta(-100) 258 SpawnPrefab("trinket_1").Transform:SetPosition(inst.Transform:GetWorldPosition()) 259 end ) 260 inst:AddTag("companion") 261 inst:AddTag("sons") 262 end 263end 264 inst.OnSave = onsave2 265 inst.OnLoad = onload2 266 267 即可在你攒够100个黄金时,将远古守护者角种在地上,向上天求子,会赐予你2个蛋(身上黄金数不足时,只收走远古守护者角,不给蛋),选一个打破,如果中了(屏幕黑一下),就会获得孩子,如果没中(生一团烟),就只能下次再试了。使用不同主角,将获得不同的孩子,可以带着他打仗、砍树、开矿。如果你死了,他将长大成人,继承你的事业,一代一代在饥荒世界里生存下去。如果他不幸夭折了,对你而言无疑是晴天霹雳(减100点脑),他将为你留下一件小小的遗物,让你永远不要忘记他。当遇到危险时,可以对他点鼠标右键,让他停留在原地,等危险排除了,再对他按右键,即可继续跟随。可以通过给零花钱为他补血(拿着黄金对他点鼠标左键),一次5个黄金,身上黄金数不足或孩子满血时拒收。注意未成年人是不会跟着你下地洞的,把他安顿好后再去刷怪吧

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二0一.私家军(用火药种私家军,可装备盔甲、帽子,需要支付工资) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/gunpowder.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function itemtest(inst, item, slot) 7 if item.prefab == "armorgrass" or item.prefab == "armorwood" or item.prefab == "armormarble" or item.prefab == "armor_sanity" or item.prefab == "armorruins" or item.prefab == "footballhat" or item.prefab == "ruinshat" or item.prefab == "beefalohat" or item.prefab == "featherhat" or item.prefab == "goldnugget" then 8 return true 9 end 10 return false 11end 12local slotpos = { Vector3(0,32+4,0), Vector3(0,-(32+4),0), Vector3(0,-(64+32+8+4),0)} 13local widgetbuttoninfo = { 14 text = "Go", 15 position = Vector3(0, -165, 0), 16 fn = function(inst) 17 if inst:HasTag("mercenary") then 18 if inst.components.container:Has("goldnugget", 20) then inst:AddTag("cango") end 19 inst.components.container:Close(GetPlayer()) 20 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available") 21 inst.AnimState:Hide("HAT") 22 inst.AnimState:Hide("HAT_HAIR") 23 inst.AnimState:Show("HAIR_NOHAT") 24 inst.AnimState:Show("HAIR") 25 inst.AnimState:ClearOverrideSymbol("swap_body") 26 for k,v in pairs(inst.components.container.slots) do 27 if v.prefab == "footballhat" or v.prefab == "ruinshat" or v.prefab == "beefalohat" or v.prefab == "featherhat" then 28 inst.AnimState:Show("HAT") 29 inst.AnimState:Show("HAT_HAIR") 30 inst.AnimState:Hide("HAIR_NOHAT") 31 inst.AnimState:Hide("HAIR") 32 end 33 if v and v.prefab == "armorgrass" then 34 inst.AnimState:OverrideSymbol("swap_body", "armor_grass", "swap_body") 35 inst:ListenForEvent("attacked", function(inst, data) 36 inst.components.health:DoDelta(15) 37 end ) 38 end 39 if v and v.prefab == "armorwood" then 40 inst.AnimState:OverrideSymbol("swap_body", "armor_wood", "swap_body") 41 inst:ListenForEvent("attacked", function(inst, data) 42 inst.components.health:DoDelta(20) 43 end ) 44 end 45 if v and v.prefab == "armormarble" then 46 inst.AnimState:OverrideSymbol("swap_body", "armor_marble", "swap_body") 47 inst:ListenForEvent("attacked", function(inst, data) 48 inst.components.health:DoDelta(25) 49 end ) 50 end 51 if v and v.prefab == "armor_sanity" then 52 inst.AnimState:OverrideSymbol("swap_body", "armor_sanity", "swap_body") 53 inst:ListenForEvent("attacked", function(inst, data) 54 inst.components.health:DoDelta(30) 55 end ) 56 end 57 if v and v.prefab == "armorruins" then 58 inst.AnimState:OverrideSymbol("swap_body", "armor_ruins", "swap_body") 59 inst:ListenForEvent("attacked", function(inst, data) 60 inst.components.health:DoDelta(35) 61 end ) 62 end 63 if v and v.prefab == "footballhat" then 64 inst.AnimState:OverrideSymbol("swap_hat", "hat_football", "swap_hat") 65 end 66 if v and v.prefab == "ruinshat" then 67 inst.AnimState:OverrideSymbol("swap_hat", "hat_ruins", "swap_hat") 68 end 69 if v and v.prefab == "beefalohat" then 70 inst.AnimState:OverrideSymbol("swap_hat", "hat_beefalo", "swap_hat") 71 end 72 if v and v.prefab == "featherhat" then 73 inst.AnimState:OverrideSymbol("swap_hat", "hat_feather", "swap_hat") 74 end 75 end 76 end 77 end } 78 inst:AddComponent("container") 79 inst.components.container.widgetbuttoninfo = widgetbuttoninfo 80 inst.components.container:SetNumSlots(#slotpos) 81 inst.components.container.widgetslotpos = slotpos 82 inst.components.container.widgetpos = Vector3(0,180,0) 83 inst.components.container.side_align_tip = 160 84 inst.components.container.canbeopened = false 85 inst.components.container.itemtestfn = itemtest 86 inst.components.container.onopenfn = function(inst) inst:RemoveTag("cango") end 87local items = { SWORD = "swap_spear" } 88local function EquipItem(inst, item) 89 if item then 90 inst.AnimState:OverrideSymbol("swap_object", item, item) 91 inst.AnimState:Show("ARM_carry") 92 inst.AnimState:Hide("ARM_normal") 93 end 94end 95 inst.items = items 96 inst.equipfn = EquipItem 97 EquipItem(inst) 98local function OnDeploy (inst, pt) 99 if GetPlayer().components.inventory:Has("goldnugget", 100) then 100 GetPlayer().components.inventory:ConsumeByName("goldnugget", 100) 101 local mercenary = SpawnPrefab("gunpowder") 102 mercenary.Transform:SetPosition(pt.x, pt.y, pt.z) 103 mercenary.AnimState:SetBank("wilson") 104 mercenary.AnimState:SetBuild("wilson") 105 mercenary.AnimState:PlayAnimation("idle") 106 mercenary.AnimState:OverrideSymbol("swap_object", "swap_spear", "swap_spear") 107 mercenary.AnimState:Show("ARM_carry") 108 mercenary.AnimState:Hide("ARM_normal") 109 mercenary.Transform:SetFourFaced() 110 local shadow = mercenary.entity:AddDynamicShadow() 111 shadow:SetSize( 1.3, .6 ) 112 MakeCharacterPhysics(mercenary, 75, .5) 113 local minimap = mercenary.entity:AddMiniMapEntity() 114 minimap:SetIcon( "researchlab.png" ) 115 mercenary:AddTag("mercenary") 116 mercenary:AddComponent("locomotor") 117 mercenary.components.locomotor.walkspeed = 8 118 mercenary.components.locomotor.runspeed = 15 119 mercenary:SetStateGraph("SGshadowwaxwell") 120 mercenary:RemoveComponent("stackable") 121 mercenary:RemoveComponent("explosive") 122 mercenary:RemoveComponent("inventoryitem") 123 mercenary:RemoveComponent("burnable") 124 mercenary:RemoveComponent("propagator") 125 mercenary:RemoveComponent("deployable") 126 mercenary:RemoveComponent("bait") 127 mercenary:RemoveTag("molebait") 128 mercenary:AddComponent("follower") 129 mercenary:AddComponent("inventory") 130 mercenary.components.container.canbeopened = true 131 mercenary:AddComponent("combat") 132 mercenary.components.combat.hiteffectsymbol = "torso" 133 mercenary.components.combat:SetDefaultDamage(50) 134 mercenary.components.combat:SetRange(2, 3) 135 mercenary.components.combat:SetAttackPeriod(0.5) 136 mercenary.components.combat:SetRetargetFunction(2, function(mercenary) 137 if not mercenary.components.health:IsDead() then 138 return FindEntity(mercenary, 25, function(guy) 139 if guy.components.health and not guy.components.health:IsDead() then 140 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 141 end 142 end) 143 end 144 end ) 145 mercenary.components.combat:SetKeepTargetFunction(function(mercenary, target) return target and target:IsValid() end ) 146 mercenary:AddComponent("health") 147 mercenary.components.health:SetMaxHealth(1500) 148 mercenary.components.health.nofadeout = true 149 mercenary:DoPeriodicTask(1, function(mercenary) 150 if mercenary:HasTag("cango") then 151 if not mercenary.components.container:Has("goldnugget", 20) then 152 mercenary.AnimState:SetBloomEffectHandle("") 153 mercenary.components.locomotor:Stop() 154 mercenary:SetBrain(nil) 155 mercenary.components.follower:SetLeader(nil) 156 else 157 mercenary.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 158 local brain = require "brains/abigailbrain" 159 mercenary:SetBrain(brain) 160 mercenary:RestartBrain() 161 mercenary.components.follower:SetLeader(GetPlayer()) 162 end 163 else 164 mercenary.AnimState:SetBloomEffectHandle("") 165 mercenary.components.locomotor:Stop() 166 mercenary:SetBrain(nil) 167 mercenary.components.follower:SetLeader(nil) 168 end 169 end ) 170 mercenary:DoPeriodicTask(480, function(mercenary) 171 if mercenary.components.container:Has("goldnugget", 20) then 172 mercenary.components.container:ConsumeByName("goldnugget", 20) 173 mercenary.components.health:DoDelta(500) 174 end 175 end ) 176 mercenary:AddComponent( "playerprox" ) 177 mercenary.components.playerprox:SetDist(3,5) 178 mercenary.components.playerprox:SetOnPlayerNear(function(mercenary) 179 mercenary.components.locomotor.walkspeed = 1 180 mercenary.components.locomotor.runspeed = 2 181 end ) 182 mercenary.components.playerprox:SetOnPlayerFar(function(mercenary) 183 mercenary.components.locomotor.walkspeed = 8 184 mercenary.components.locomotor.runspeed = 15 185 end ) 186 end 187 inst.components.stackable:Get():Remove() 188end 189 inst:AddComponent("deployable") 190 inst.components.deployable.ondeploy = OnDeploy 191local function onsave(inst, data) 192 if inst:HasTag("mercenary") then 193 data.mercenary = true 194 end 195 if inst:HasTag("cango") then 196 data.cango = true 197 end 198end 199local function onload(inst, data) 200 if data and data.mercenary then 201 inst.AnimState:SetBank("wilson") 202 inst.AnimState:SetBuild("wilson") 203 inst.AnimState:PlayAnimation("idle") 204 inst.AnimState:OverrideSymbol("swap_object", "swap_spear", "swap_spear") 205 inst.AnimState:Show("ARM_carry") 206 inst.AnimState:Hide("ARM_normal") 207 inst.Transform:SetFourFaced() 208 local shadow = inst.entity:AddDynamicShadow() 209 shadow:SetSize( 1.3, .6 ) 210 MakeCharacterPhysics(inst, 75, .5) 211 local minimap = inst.entity:AddMiniMapEntity() 212 minimap:SetIcon( "researchlab.png" ) 213 inst:AddTag("mercenary") 214 inst:AddComponent("locomotor") 215 inst.components.locomotor.walkspeed = 8 216 inst.components.locomotor.runspeed = 15 217 inst:SetStateGraph("SGshadowwaxwell") 218 inst:RemoveComponent("stackable") 219 inst:RemoveComponent("explosive") 220 inst:RemoveComponent("inventoryitem") 221 inst:RemoveComponent("burnable") 222 inst:RemoveComponent("propagator") 223 inst:RemoveComponent("deployable") 224 inst:RemoveComponent("bait") 225 inst:RemoveTag("molebait") 226 inst:AddComponent("follower") 227 inst:AddComponent("inventory") 228 inst.components.container.canbeopened = true 229 inst:AddComponent("combat") 230 inst.components.combat.hiteffectsymbol = "torso" 231 inst.components.combat:SetDefaultDamage(50) 232 inst.components.combat:SetRange(2, 3) 233 inst.components.combat:SetAttackPeriod(0.5) 234 inst.components.combat:SetRetargetFunction(2, function(inst) 235 if not inst.components.health:IsDead() then 236 return FindEntity(inst, 25, function(guy) 237 if guy.components.health and not guy.components.health:IsDead() then 238 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 239 end 240 end) 241 end 242 end ) 243 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) 244 inst:AddComponent("health") 245 inst.components.health:SetMaxHealth(1500) 246 inst.components.health.nofadeout = true 247 inst:DoPeriodicTask(1, function(inst) 248 if inst:HasTag("cango") then 249 if not inst.components.container:Has("goldnugget", 20) then 250 inst.AnimState:SetBloomEffectHandle("") 251 inst.components.locomotor:Stop() 252 inst:SetBrain(nil) 253 inst.components.follower:SetLeader(nil) 254 else 255 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 256 local brain = require "brains/abigailbrain" 257 inst:SetBrain(brain) 258 inst:RestartBrain() 259 inst.components.follower:SetLeader(GetPlayer()) 260 end 261 else 262 inst.AnimState:SetBloomEffectHandle("") 263 inst.components.locomotor:Stop() 264 inst:SetBrain(nil) 265 inst.components.follower:SetLeader(nil) 266 end 267 end ) 268 inst:DoPeriodicTask(480, function(inst) 269 if inst.components.container:Has("goldnugget", 20) then 270 inst.components.container:ConsumeByName("goldnugget", 20) 271 inst.components.health:DoDelta(500) 272 end 273 end ) 274 inst:AddComponent( "playerprox" ) 275 inst.components.playerprox:SetDist(3,5) 276 inst.components.playerprox:SetOnPlayerNear(function(inst) 277 inst.components.locomotor.walkspeed = 1 278 inst.components.locomotor.runspeed = 2 279 end ) 280 inst.components.playerprox:SetOnPlayerFar(function(inst) 281 inst.components.locomotor.walkspeed = 8 282 inst.components.locomotor.runspeed = 15 283 end ) 284 inst.AnimState:Hide("HAT") 285 inst.AnimState:Hide("HAT_HAIR") 286 inst.AnimState:Show("HAIR_NOHAT") 287 inst.AnimState:Show("HAIR") 288 inst.AnimState:ClearOverrideSymbol("swap_body") 289 for k,v in pairs(inst.components.container.slots) do 290 if v.prefab == "footballhat" or v.prefab == "ruinshat" or v.prefab == "beefalohat" or v.prefab == "featherhat" then 291 inst.AnimState:Show("HAT") 292 inst.AnimState:Show("HAT_HAIR") 293 inst.AnimState:Hide("HAIR_NOHAT") 294 inst.AnimState:Hide("HAIR") 295 end 296 if v and v.prefab == "armorgrass" then 297 inst.AnimState:OverrideSymbol("swap_body", "armor_grass", "swap_body") 298 inst:ListenForEvent("attacked", function(inst, data) 299 inst.components.health:DoDelta(15) 300 end ) 301 end 302 if v and v.prefab == "armorwood" then 303 inst.AnimState:OverrideSymbol("swap_body", "armor_wood", "swap_body") 304 inst:ListenForEvent("attacked", function(inst, data) 305 inst.components.health:DoDelta(20) 306 end ) 307 end 308 if v and v.prefab == "armormarble" then 309 inst.AnimState:OverrideSymbol("swap_body", "armor_marble", "swap_body") 310 inst:ListenForEvent("attacked", function(inst, data) 311 inst.components.health:DoDelta(25) 312 end ) 313 end 314 if v and v.prefab == "armor_sanity" then 315 inst.AnimState:OverrideSymbol("swap_body", "armor_sanity", "swap_body") 316 inst:ListenForEvent("attacked", function(inst, data) 317 inst.components.health:DoDelta(30) 318 end ) 319 end 320 if v and v.prefab == "armorruins" then 321 inst.AnimState:OverrideSymbol("swap_body", "armor_ruins", "swap_body") 322 inst:ListenForEvent("attacked", function(inst, data) 323 inst.components.health:DoDelta(35) 324 end ) 325 end 326 if v and v.prefab == "footballhat" then 327 inst.AnimState:OverrideSymbol("swap_hat", "hat_football", "swap_hat") 328 end 329 if v and v.prefab == "ruinshat" then 330 inst.AnimState:OverrideSymbol("swap_hat", "hat_ruins", "swap_hat") 331 end 332 if v and v.prefab == "beefalohat" then 333 inst.AnimState:OverrideSymbol("swap_hat", "hat_beefalo", "swap_hat") 334 end 335 if v and v.prefab == "featherhat" then 336 inst.AnimState:OverrideSymbol("swap_hat", "hat_feather", "swap_hat") 337 end 338 end 339 end 340 if data and data.cango then 341 inst:AddTag("cango") 342 end 343end 344 inst.OnSave = onsave 345 inst.OnLoad = onload 346 347 即可在身上有100个黄金时,用火药种私家军,将花费100个黄金,身上黄金数不足时不会种出来。鼠标左键点击他可打开格子,放入至少20个黄金后,点Go按钮,会跟随你打仗。追上他用鼠标左键再次点击,可让他停在原地,想让他继续跟随,就再点Go按钮即可。私家军士兵每天的工资是20个黄金,自动从他身上的黄金中扣除(并同时回补三分之一的血),如果他身上的黄金数不足20个时,将罢工,请及时续费。如果私家军的格子中有盔甲、帽子,点Go按钮会自动装备。装备盔甲可提高私家军的防御力,按防御力由低到高排序为草盔甲、木盔甲、大理石盔甲、夜魔盔甲、远古盔甲。装备帽子只起到装饰作用,可装备的帽子有猪皮帽、远古帽、牛毛帽、羽毛帽。不要在他的格子里放2个盔甲或2个帽子,他只会选择1个装备。私家军在小地图上显示为科学机器的图标,可以方便地找到他们的位置。火药在科学选项(画着原子)下,用1个烂鸡蛋、1个木炭、1个硝石制造

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二0二.天使蝴蝶(用雨衣种天使蝴蝶,为你照亮,电击来犯之敌,可收入物品栏) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/raincoat.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function OnDeploy (inst, pt) 7 local scalewing = SpawnPrefab("raincoat") 8 scalewing.Transform:SetPosition(pt.x, pt.y, pt.z) 9 scalewing.AnimState:SetBank("butterfly") 10 scalewing.AnimState:SetBuild("butterfly_basic") 11 scalewing.AnimState:PlayAnimation("idle") 12 scalewing.AnimState:SetRayTestOnBB(true); 13 scalewing.Transform:SetTwoFaced() 14 scalewing.Transform:SetScale(1.5, 1.5, 1.5) 15 scalewing.AnimState:SetMultColour(255/255,0/255,115/255,0.8) 16 scalewing.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 17 scalewing.entity:AddSoundEmitter() 18 local shadow = scalewing.entity:AddDynamicShadow() 19 shadow:SetSize(.8, .5) 20 RemovePhysicsColliders(scalewing) 21 scalewing.entity:AddLight() 22 scalewing.Light:SetFalloff(1) 23 scalewing.Light:SetIntensity(.8) 24 scalewing.Light:SetRadius(12) 25 scalewing.Light:SetColour(180/255, 195/255, 50/255) 26 scalewing.Light:Enable(true) 27 scalewing:RemoveComponent("inventoryitem") 28 scalewing:RemoveComponent("equippable") 29 scalewing:RemoveComponent("waterproofer") 30 scalewing:RemoveComponent("fueled") 31 scalewing:RemoveComponent("insulator") 32 scalewing:RemoveComponent("deployable") 33 scalewing:AddComponent("inventoryitem") 34 scalewing.components.inventoryitem:ChangeImageName("butterfly") 35 scalewing:AddComponent("named") 36 scalewing.components.named:SetName("Butterfly") 37 scalewing:AddComponent("follower") 38 scalewing.components.follower:SetLeader(GetPlayer()) 39 scalewing:AddComponent("locomotor") 40 scalewing.components.locomotor.walkspeed = 8 41 scalewing:SetStateGraph("SGbutterfly") 42 local brain = require "brains/abigailbrain" 43 scalewing:SetBrain(brain) 44 scalewing:AddComponent("health") 45 scalewing.components.health:SetMaxHealth(10) 46 scalewing.components.health:SetInvincible(true) 47 scalewing:AddComponent("combat") 48 scalewing.components.combat:SetDefaultDamage(0) 49 scalewing.components.combat:SetRange(2) 50 scalewing.components.combat:SetAttackPeriod(0.5) 51 scalewing.components.combat:SetRetargetFunction(1, function(scalewing) 52 if not scalewing.components.health:IsDead() then 53 return FindEntity(GetPlayer(), 20, function(guy) 54 if guy.components.health and not guy.components.health:IsDead() then 55 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy.components.combat.target == scalewing or scalewing.components.combat.target == guy or guy:HasTag("monster") 56 end 57 end) 58 end 59 end ) 60 scalewing.components.combat:SetKeepTargetFunction(function(scalewing, target) return target and target:IsValid() end ) 61 scalewing:AddTag("duty") 62 scalewing.task = scalewing:DoPeriodicTask(0.5, function(scalewing) 63 local target = FindEntity(scalewing, 3, function(guy) 64 if guy.components.health and not guy.components.health:IsDead() then 65 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy.components.combat.target == scalewing or scalewing.components.combat.target == guy or guy:HasTag("monster") 66 end 67 end ) 68 if target then 69 if target.components.combat then target.components.combat:SetTarget(scalewing) end 70 if target.components.locomotor then target.components.locomotor:Stop() end 71 SpawnPrefab("lightning_rod_fx").Transform:SetPosition(target.Transform:GetWorldPosition()) 72 scalewing.SoundEmitter:PlaySound("dontstarve/common/lightningrod") 73 target.components.health:DoDelta(-100) 74 end 75 end ) 76 scalewing.components.inventoryitem:SetOnDroppedFn(function(scalewing) 77 scalewing:AddTag("duty") 78 scalewing.Light:Enable(true) 79 scalewing.task = scalewing:DoPeriodicTask(0.5, function(scalewing) 80 local target = FindEntity(scalewing, 3, function(guy) 81 if guy.components.health and not guy.components.health:IsDead() then 82 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy.components.combat.target == scalewing or scalewing.components.combat.target == guy or guy:HasTag("monster") 83 end 84 end ) 85 if target then 86 if target.components.combat then target.components.combat:SetTarget(scalewing) end 87 if target.components.locomotor then target.components.locomotor:Stop() end 88 SpawnPrefab("lightning_rod_fx").Transform:SetPosition(target.Transform:GetWorldPosition()) 89 scalewing.SoundEmitter:PlaySound("dontstarve/common/lightningrod") 90 target.components.health:DoDelta(-100) 91 end 92 end ) 93 end ) 94 scalewing.components.inventoryitem:SetOnPickupFn(function(scalewing) 95 scalewing:RemoveTag("duty") 96 scalewing.Light:Enable(false) 97 if scalewing.task then scalewing.task:Cancel() scalewing.task = nil end 98 end ) 99 scalewing.components.inventoryitem:SetOnPutInInventoryFn(function(scalewing) 100 scalewing:RemoveTag("duty") 101 scalewing.Light:Enable(false) 102 if scalewing.task then scalewing.task:Cancel() scalewing.task = nil end 103 end ) 104 scalewing:AddTag("scalewings") 105 inst:Remove() 106end 107 inst:AddComponent("deployable") 108 inst.components.deployable.ondeploy = OnDeploy 109local function onsave(inst, data) 110 if inst:HasTag("scalewings") then 111 data.scalewings = true 112 end 113 if inst:HasTag("duty") then 114 data.duty = true 115 end 116end 117local function onload(inst, data) 118 if data and data.scalewings then 119 inst.AnimState:SetBank("butterfly") 120 inst.AnimState:SetBuild("butterfly_basic") 121 inst.AnimState:PlayAnimation("idle") 122 inst.AnimState:SetRayTestOnBB(true); 123 inst.Transform:SetTwoFaced() 124 inst.Transform:SetScale(1.5, 1.5, 1.5) 125 inst.AnimState:SetMultColour(255/255,0/255,115/255,0.8) 126 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 127 inst.entity:AddSoundEmitter() 128 local shadow = inst.entity:AddDynamicShadow() 129 shadow:SetSize(.8, .5) 130 RemovePhysicsColliders(inst) 131 inst.entity:AddLight() 132 inst.Light:SetFalloff(1) 133 inst.Light:SetIntensity(.8) 134 inst.Light:SetRadius(12) 135 inst.Light:SetColour(180/255, 195/255, 50/255) 136 inst.Light:Enable(true) 137 inst:RemoveComponent("inventoryitem") 138 inst:RemoveComponent("equippable") 139 inst:RemoveComponent("waterproofer") 140 inst:RemoveComponent("fueled") 141 inst:RemoveComponent("insulator") 142 inst:RemoveComponent("deployable") 143 inst:AddComponent("inventoryitem") 144 inst.components.inventoryitem:ChangeImageName("butterfly") 145 inst:AddComponent("named") 146 inst.components.named:SetName("Butterfly") 147 inst:AddComponent("follower") 148 inst.components.follower:SetLeader(GetPlayer()) 149 inst:AddComponent("locomotor") 150 inst.components.locomotor.walkspeed = 8 151 inst:SetStateGraph("SGbutterfly") 152 local brain = require "brains/abigailbrain" 153 inst:SetBrain(brain) 154 inst:AddComponent("health") 155 inst.components.health:SetMaxHealth(10) 156 inst.components.health:SetInvincible(true) 157 inst:AddComponent("combat") 158 inst.components.combat:SetDefaultDamage(0) 159 inst.components.combat:SetRange(2) 160 inst.components.combat:SetAttackPeriod(0.5) 161 inst.components.combat:SetRetargetFunction(1, function(inst) 162 if not inst.components.health:IsDead() then 163 return FindEntity(GetPlayer(), 20, function(guy) 164 if guy.components.health and not guy.components.health:IsDead() then 165 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy.components.combat.target == inst or inst.components.combat.target == guy or guy:HasTag("monster") 166 end 167 end) 168 end 169 end ) 170 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) 171 inst.components.inventoryitem:SetOnDroppedFn(function(inst) 172 inst:AddTag("duty") 173 inst.Light:Enable(true) 174 inst.task = inst:DoPeriodicTask(0.5, function(inst) 175 local target = FindEntity(inst, 3, function(guy) 176 if guy.components.health and not guy.components.health:IsDead() then 177 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy.components.combat.target == inst or inst.components.combat.target == guy or guy:HasTag("monster") 178 end 179 end ) 180 if target then 181 if target.components.combat then target.components.combat:SetTarget(inst) end 182 if target.components.locomotor then target.components.locomotor:Stop() end 183 SpawnPrefab("lightning_rod_fx").Transform:SetPosition(target.Transform:GetWorldPosition()) 184 inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod") 185 target.components.health:DoDelta(-100) 186 end 187 end ) 188 end ) 189 inst.components.inventoryitem:SetOnPickupFn(function(inst) 190 inst:RemoveTag("duty") 191 inst.Light:Enable(false) 192 if inst.task then inst.task:Cancel() inst.task = nil end 193 end ) 194 inst.components.inventoryitem:SetOnPutInInventoryFn(function(inst) 195 inst:RemoveTag("duty") 196 inst.Light:Enable(false) 197 if inst.task then inst.task:Cancel() inst.task = nil end 198 end ) 199 inst:AddTag("scalewings") 200 end 201 if data and data.duty then 202 inst:AddTag("duty") 203 inst.task = inst:DoPeriodicTask(0.5, function(inst) 204 local target = FindEntity(inst, 3, function(guy) 205 if guy.components.health and not guy.components.health:IsDead() then 206 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy.components.combat.target == inst or inst.components.combat.target == guy or guy:HasTag("monster") 207 end 208 end ) 209 if target then 210 if target.components.combat then target.components.combat:SetTarget(inst) end 211 if target.components.locomotor then target.components.locomotor:Stop() end 212 SpawnPrefab("lightning_rod_fx").Transform:SetPosition(target.Transform:GetWorldPosition()) 213 inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod") 214 target.components.health:DoDelta(-100) 215 end 216 end ) 217 end 218end 219 inst.OnSave = onsave 220 inst.OnLoad = onload 221 222 即可用雨衣种天使蝴蝶,会跟随你,为你照亮。任何企图攻击你的敌人,都会遭到天使蝴蝶的电击,杀伤其生命值,并阻止其靠近你。鼠标左键点击天使蝴蝶,可收入物品栏,显示为蝴蝶图标。不想要天使蝴蝶了,在物品栏中对其按鼠标右键即可。雨衣在穿戴选项(画着礼帽)下,用2个触手皮、2个绳子、2个硬骨头制造

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二0三.宠物熊(用黄色护身符种宠物熊,是战场好帮手,左键点击可停在原地,喂大肉可补血) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/amulet.lua文件,在inst.AnimState:PlayAnimation("yellowamulet")的下一行插入以下内容: 5 6local function SetStandState(inst, state) 7 inst.StandState = string.lower(state) 8end 9local function OnDeploy (inst, pt) 10 local mybear = SpawnPrefab("yellowamulet") 11 mybear.Transform:SetPosition(pt.x, pt.y, pt.z) 12 mybear.AnimState:SetBank("bearger") 13 mybear.AnimState:SetBuild("bearger_build") 14 mybear.AnimState:PlayAnimation("idle_loop", true) 15 mybear.Transform:SetScale(0.5, 0.5, 0.5) 16 mybear.Transform:SetFourFaced() 17 local sound = mybear.entity:AddSoundEmitter() 18 local shadow = mybear.entity:AddDynamicShadow() 19 shadow:SetSize(3, 1.8) 20 MakeCharacterPhysics(mybear, 500, 1) 21 mybear:RemoveComponent("equippable") 22 mybear:RemoveComponent("inventoryitem") 23 mybear:RemoveComponent("fueled") 24 mybear:RemoveComponent("deployable") 25 SetStandState(mybear, "QUAD") 26 mybear.CanGroundPound = false 27 mybear.SetStandState = SetStandState 28 mybear.IsStandState = function(mybear, state) 29 return mybear.StandState == string.lower(state) 30 end 31 mybear.WorkEntities = function(mybear) 32 mybear.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") 33 GetPlayer().components.playercontroller:ShakeCamera(mybear, "FULL", 0.5, 0.05, 2, 40) 34 end 35 mybear:AddComponent("groundpounder") 36 mybear.components.groundpounder.destroyer = true 37 mybear.components.groundpounder.damageRings = 3 38 mybear.components.groundpounder.destructionRings = 4 39 mybear.components.groundpounder.numRings = 5 40 mybear:AddComponent("named") 41 mybear.components.named:SetName("My Bear") 42 mybear:AddComponent("inventory") 43 mybear:AddComponent("knownlocations") 44 mybear:AddComponent("timer") 45 mybear:AddComponent("eater") 46 mybear.components.eater.foodprefs = {"MEAT"} 47 mybear:AddComponent("follower") 48 mybear.components.follower:SetLeader(GetPlayer()) 49 mybear:AddComponent("lootdropper") 50 mybear.components.lootdropper:SetLoot({"meat", "meat", "meat", "meat", "bearger_fur"}) 51 mybear:AddComponent("health") 52 mybear.components.health:SetMaxHealth(10000) 53 mybear:AddComponent("combat") 54 mybear.components.combat:SetDefaultDamage(300) 55 mybear.components.combat:SetAttackPeriod(0.5) 56 mybear.components.combat.hiteffectsymbol = "bearger_body" 57 mybear.components.combat:SetAreaDamage(4, 1) 58 mybear.components.combat.playerdamagepercent = 0 59 mybear.components.combat:SetRange(2, 4) 60 mybear.components.combat:SetHurtSound("dontstarve_DLC001/creatures/bearger/hurt") 61 mybear.components.combat:SetRetargetFunction(1, function(mybear) 62 if not mybear.components.health:IsDead() then 63 return FindEntity(mybear, 25, function(guy) 64 if guy.components.combat then 65 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 66 end 67 end ) 68 end 69 end ) 70 mybear.components.combat:SetKeepTargetFunction(function(mybear, target) return target and target:IsValid() end ) 71 mybear:ListenForEvent("attacked", function(mybear, data) 72 if data.attacker ~= GetPlayer() then 73 mybear.components.combat:SetTarget(data.attacker) 74 else 75 mybear.components.combat:SetTarget(nil) 76 end 77 end ) 78 mybear:AddComponent("locomotor") 79 mybear.components.locomotor.walkspeed = 15 80 mybear.components.locomotor.runspeed = 20 81 mybear.components.locomotor:SetShouldRun(true) 82 mybear:SetStateGraph("SGbearger") 83 local brain = require "brains/abigailbrain" 84 mybear:SetBrain(brain) 85 mybear:AddComponent("trader") 86 mybear.components.trader:SetAcceptTest(function(mybear, item) 87 if item.prefab == "meat" then 88 return mybear.components.health:GetPercent() < 1 89 end 90 return false 91 end ) 92 mybear.components.trader.onaccept = function(mybear, giver, item) 93 if item.prefab == "meat" then 94 mybear.components.health:DoDelta(2000) 95 end 96 end 97 mybear.components.inspectable.getstatus = function(mybear) 98 if not mybear:HasTag("stophere") then 99 mybear:AddTag("stophere") 100 mybear.components.locomotor:Stop() 101 mybear:SetBrain(nil) 102 mybear.components.follower:SetLeader(nil) 103 mybear.AnimState:PlayAnimation("sleep_loop",true) 104 else 105 mybear:RemoveTag("stophere") 106 local brain = require "brains/abigailbrain" 107 mybear:SetBrain(brain) 108 mybear:RestartBrain() 109 mybear.components.follower:SetLeader(GetPlayer()) 110 end 111 end 112 mybear:AddTag("companion") 113 mybear:AddTag("mybears") 114 inst:Remove() 115end 116 inst:AddComponent("deployable") 117 inst.components.deployable.ondeploy = OnDeploy 118local function onsave(inst, data) 119 if inst:HasTag("mybears") then 120 data.mybears = true 121 end 122 if inst:HasTag("stophere") then 123 data.stophere = true 124 end 125end 126local function onload(inst, data) 127 if data and data.mybears then 128 inst.AnimState:SetBank("bearger") 129 inst.AnimState:SetBuild("bearger_build") 130 inst.AnimState:PlayAnimation("idle_loop", true) 131 inst.Transform:SetScale(0.5, 0.5, 0.5) 132 inst.Transform:SetFourFaced() 133 local sound = inst.entity:AddSoundEmitter() 134 local shadow = inst.entity:AddDynamicShadow() 135 shadow:SetSize(3, 1.8) 136 MakeCharacterPhysics(inst, 500, 1) 137 inst:RemoveComponent("equippable") 138 inst:RemoveComponent("inventoryitem") 139 inst:RemoveComponent("fueled") 140 inst:RemoveComponent("deployable") 141 SetStandState(inst, "QUAD") 142 inst.CanGroundPound = false 143 inst.SetStandState = SetStandState 144 inst.IsStandState = function(inst, state) 145 return inst.StandState == string.lower(state) 146 end 147 inst.WorkEntities = function(inst) 148 inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") 149 GetPlayer().components.playercontroller:ShakeCamera(inst, "FULL", 0.5, 0.05, 2, 40) 150 end 151 inst:AddComponent("groundpounder") 152 inst.components.groundpounder.destroyer = true 153 inst.components.groundpounder.damageRings = 3 154 inst.components.groundpounder.destructionRings = 4 155 inst.components.groundpounder.numRings = 5 156 inst:AddComponent("named") 157 inst.components.named:SetName("My Bear") 158 inst:AddComponent("inventory") 159 inst:AddComponent("knownlocations") 160 inst:AddComponent("timer") 161 inst:AddComponent("eater") 162 inst.components.eater.foodprefs = {"MEAT"} 163 inst:AddComponent("follower") 164 inst.components.follower:SetLeader(GetPlayer()) 165 inst:AddComponent("lootdropper") 166 inst.components.lootdropper:SetLoot({"meat", "meat", "meat", "meat", "bearger_fur"}) 167 inst:AddComponent("health") 168 inst.components.health:SetMaxHealth(10000) 169 inst:AddComponent("combat") 170 inst.components.combat:SetDefaultDamage(300) 171 inst.components.combat:SetAttackPeriod(0.5) 172 inst.components.combat.hiteffectsymbol = "bearger_body" 173 inst.components.combat:SetAreaDamage(4, 1) 174 inst.components.combat.playerdamagepercent = 0 175 inst.components.combat:SetRange(2, 4) 176 inst.components.combat:SetHurtSound("dontstarve_DLC001/creatures/bearger/hurt") 177 inst.components.combat:SetRetargetFunction(1, function(inst) 178 if not inst.components.health:IsDead() then 179 return FindEntity(inst, 25, function(guy) 180 if guy.components.combat then 181 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 182 end 183 end ) 184 end 185 end ) 186 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) 187 inst:ListenForEvent("attacked", function(inst, data) 188 if data.attacker ~= GetPlayer() then 189 inst.components.combat:SetTarget(data.attacker) 190 else 191 inst.components.combat:SetTarget(nil) 192 end 193 end ) 194 inst:AddComponent("locomotor") 195 inst.components.locomotor.walkspeed = 15 196 inst.components.locomotor.runspeed = 20 197 inst.components.locomotor:SetShouldRun(true) 198 inst:SetStateGraph("SGbearger") 199 local brain = require "brains/abigailbrain" 200 inst:SetBrain(brain) 201 inst:AddComponent("trader") 202 inst.components.trader:SetAcceptTest(function(inst, item) 203 if item.prefab == "meat" then 204 return inst.components.health:GetPercent() < 1 205 end 206 return false 207 end ) 208 inst.components.trader.onaccept = function(inst, giver, item) 209 if item.prefab == "meat" then 210 inst.components.health:DoDelta(2000) 211 end 212 end 213 inst.components.inspectable.getstatus = function(inst) 214 if not inst:HasTag("stophere") then 215 inst:AddTag("stophere") 216 inst.components.locomotor:Stop() 217 inst:SetBrain(nil) 218 inst.components.follower:SetLeader(nil) 219 inst.AnimState:PlayAnimation("sleep_loop",true) 220 else 221 inst:RemoveTag("stophere") 222 local brain = require "brains/abigailbrain" 223 inst:SetBrain(brain) 224 inst:RestartBrain() 225 inst.components.follower:SetLeader(GetPlayer()) 226 end 227 end 228 inst:AddTag("companion") 229 inst:AddTag("mybears") 230 end 231 if data and data.stophere then 232 inst:AddTag("stophere") 233 inst.components.locomotor:Stop() 234 inst:SetBrain(nil) 235 inst.components.follower:SetLeader(nil) 236 inst.AnimState:PlayAnimation("sleep_loop",true) 237 end 238end 239 inst.OnSave = onsave 240 inst.OnLoad = onload 241 242 即可用黄色护身符种宠物熊,它身强力壮,是战斗时的好帮手。鼠标左键点熊,可让它停在原地,再次点击可继续跟随。给宠物熊大肉(拿着大肉对其点鼠标左键),可为它补血,最多5块可补满。不想要宠物熊了,杀死即可(按Ctrl + 鼠标左键攻击),它不会还手。宠物熊行走时会撞碎阻挡的建筑、植物,所以不要让它离你的基地太近。黄色护身符在远古选项(画着远古祭坛)下,用2个铥矿石、3个噩梦燃料、1个黄色宝石制造

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二0四.宠物蜻蜓(用蜻蜓盔甲种宠物蜻蜓,攻击力超强,鼠标右键点击可帮你捡地上的物品) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/armor_dragonfly.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function OnDeploy (inst, pt) 7 local myfly = SpawnPrefab("armordragonfly") 8 myfly.Transform:SetPosition(pt.x, pt.y, pt.z) 9 myfly.AnimState:SetBank("dragonfly") 10 myfly.AnimState:SetBuild("dragonfly_build") 11 myfly.AnimState:PlayAnimation("idle", true) 12 myfly.Transform:SetScale(0.5, 0.5, 0.5) 13 myfly.Transform:SetFourFaced() 14 local sound = myfly.entity:AddSoundEmitter() 15 local shadow = myfly.entity:AddDynamicShadow() 16 shadow:SetSize(3, 1.8) 17 MakeCharacterPhysics(myfly, 50, 0.7) 18 local light = myfly.entity:AddLight() 19 myfly.Light:Enable(false) 20 myfly.Light:SetRadius(2) 21 myfly.Light:SetFalloff(0.5) 22 myfly.Light:SetIntensity(.75) 23 myfly.Light:SetColour(235/255,121/255,12/255) 24 myfly:RemoveComponent("inventoryitem") 25 myfly:RemoveComponent("armor") 26 myfly:RemoveComponent("equippable") 27 myfly:RemoveComponent("deployable") 28 MakeLargePropagator(myfly) 29 myfly.components.propagator.decayrate = 0 30 myfly:AddComponent("groundpounder") 31 myfly.components.groundpounder.numRings = 2 32 myfly.components.groundpounder.burner = true 33 myfly.components.groundpounder.groundpoundfx = "firesplash_fx" 34 myfly.components.groundpounder.groundpounddamagemult = .5 35 myfly.components.groundpounder.groundpoundringfx = "firering_fx" 36 myfly:AddComponent("named") 37 myfly.components.named:SetName("My Dragonfly") 38 myfly:AddComponent("inventory") 39 myfly:AddComponent("knownlocations") 40 myfly:AddComponent("follower") 41 myfly.components.follower:SetLeader(GetPlayer()) 42 myfly:AddComponent("lootdropper") 43 myfly.components.lootdropper:SetLoot({"meat", "meat", "meat", "meat", "dragon_scales"}) 44 myfly:AddComponent("health") 45 myfly.components.health:SetMaxHealth(5000) 46 myfly:AddComponent("combat") 47 myfly.components.combat:SetDefaultDamage(300) 48 myfly.components.combat:SetAttackPeriod(0.5) 49 myfly.components.combat.hiteffectsymbol = "dragonfly_body" 50 myfly.components.combat:SetAreaDamage(6, 0.8) 51 myfly.components.combat.playerdamagepercent = 0 52 myfly.components.combat:SetRange(4) 53 myfly.components.combat.battlecryenabled = false 54 myfly.components.combat:SetHurtSound("dontstarve_DLC001/creatures/dragonfly/hurt") 55 myfly.components.combat:SetRetargetFunction(1, function(myfly) 56 if not myfly.components.health:IsDead() then 57 return FindEntity(myfly, 25, function(guy) 58 if guy.components.combat then 59 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 60 end 61 end ) 62 end 63 end ) 64 myfly.components.combat:SetKeepTargetFunction(function(myfly, target) return target and target:IsValid() end ) 65 myfly:ListenForEvent("attacked", function(myfly, data) 66 if data.attacker ~= GetPlayer() then 67 if not data.attacker:HasTag("myflys") then 68 myfly.components.combat:SetTarget(data.attacker) 69 end 70 else 71 myfly.components.health:Kill() 72 end 73 end ) 74 myfly:AddComponent("locomotor") 75 myfly.components.locomotor.walkspeed = 25 76 myfly:SetStateGraph("SGdragonfly") 77 local brain = require "brains/abigailbrain" 78 myfly:SetBrain(brain) 79 myfly:DoPeriodicTask(5, function() 80 if myfly.components.combat and not myfly.components.combat.target then 81 if myfly.fire_build then 82 myfly.sg:GoToState("flameoff") 83 end 84 if myfly.components.health and myfly.components.health:GetPercent() < 1 then 85 myfly.components.health:DoDelta(200) 86 end 87 end 88 end ) 89 myfly:AddComponent("machine") 90 myfly.components.machine.turnonfn = function() 91 myfly:AddTag("inhaling") 92 myfly.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 93 myfly.task = myfly:DoPeriodicTask(.5, function(myfly) 94 local pos = Vector3(myfly.Transform:GetWorldPosition()) 95 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 15) 96 for k,v in pairs(ents) do 97 local pt1 = v:GetPosition() 98 if v.components.inventoryitem and v.components.inventoryitem.canbepickedup and v.components.inventoryitem.cangoincontainer 99 and not v.components.inventoryitem:IsHeld() and not v:HasTag("trap") and not v:HasTag("light") and not v:HasTag("blowdart") 100 and not v:HasTag("projectile") then 101 if not GetPlayer().components.inventory:IsFull() then 102 SpawnPrefab("small_puff").Transform:SetPosition(pt1.x, pt1.y, pt1.z) 103 GetPlayer().components.inventory:GiveItem(v) 104 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available") 105 end 106 end 107 end 108 end ) 109 end 110 myfly.components.machine.turnofffn = function() 111 myfly:RemoveTag("inhaling") 112 myfly.AnimState:SetBloomEffectHandle( "" ) 113 if myfly.task then myfly.task:Cancel() myfly.task = nil end 114 end 115 myfly.components.inspectable.getstatus = function(myfly) 116 if not myfly:HasTag("stophere") then 117 myfly:AddTag("stophere") 118 myfly.components.locomotor:Stop() 119 myfly:SetBrain(nil) 120 myfly.components.follower:SetLeader(nil) 121 myfly.sg:GoToState("flameoff") 122 else 123 myfly:RemoveTag("stophere") 124 local brain = require "brains/abigailbrain" 125 myfly:SetBrain(brain) 126 myfly:RestartBrain() 127 myfly.components.follower:SetLeader(GetPlayer()) 128 end 129 end 130 myfly:ListenForEvent("death", function() 131 myfly.components.machine:TurnOff() 132 end ) 133 myfly:AddTag("companion") 134 myfly:AddTag("myflys") 135 inst:Remove() 136end 137 inst:AddComponent("deployable") 138 inst.components.deployable.ondeploy = OnDeploy 139local function onsave(inst, data) 140 if inst:HasTag("myflys") then 141 data.myflys = true 142 end 143 if inst:HasTag("stophere") then 144 data.stophere = true 145 end 146 if inst:HasTag("inhaling") then 147 data.inhaling = true 148 end 149end 150local function onload(inst, data) 151 if data and data.myflys then 152 inst.AnimState:SetBank("dragonfly") 153 inst.AnimState:SetBuild("dragonfly_build") 154 inst.AnimState:PlayAnimation("idle", true) 155 inst.Transform:SetScale(0.5, 0.5, 0.5) 156 inst.Transform:SetFourFaced() 157 local sound = inst.entity:AddSoundEmitter() 158 local shadow = inst.entity:AddDynamicShadow() 159 shadow:SetSize(3, 1.8) 160 MakeCharacterPhysics(inst, 50, 0.7) 161 local light = inst.entity:AddLight() 162 inst.Light:Enable(false) 163 inst.Light:SetRadius(2) 164 inst.Light:SetFalloff(0.5) 165 inst.Light:SetIntensity(.75) 166 inst.Light:SetColour(235/255,121/255,12/255) 167 inst:RemoveComponent("inventoryitem") 168 inst:RemoveComponent("armor") 169 inst:RemoveComponent("equippable") 170 inst:RemoveComponent("deployable") 171 MakeLargePropagator(inst) 172 inst.components.propagator.decayrate = 0 173 inst:AddComponent("groundpounder") 174 inst.components.groundpounder.numRings = 2 175 inst.components.groundpounder.burner = true 176 inst.components.groundpounder.groundpoundfx = "firesplash_fx" 177 inst.components.groundpounder.groundpounddamagemult = .5 178 inst.components.groundpounder.groundpoundringfx = "firering_fx" 179 inst:AddComponent("named") 180 inst.components.named:SetName("My Dragonfly") 181 inst:AddComponent("inventory") 182 inst:AddComponent("knownlocations") 183 inst:AddComponent("follower") 184 inst.components.follower:SetLeader(GetPlayer()) 185 inst:AddComponent("lootdropper") 186 inst.components.lootdropper:SetLoot({"meat", "meat", "meat", "meat", "dragon_scales"}) 187 inst:AddComponent("health") 188 inst.components.health:SetMaxHealth(5000) 189 inst:AddComponent("combat") 190 inst.components.combat:SetDefaultDamage(300) 191 inst.components.combat:SetAttackPeriod(0.5) 192 inst.components.combat.hiteffectsymbol = "dragonfly_body" 193 inst.components.combat:SetAreaDamage(6, 0.8) 194 inst.components.combat.playerdamagepercent = 0 195 inst.components.combat:SetRange(4) 196 inst.components.combat.battlecryenabled = false 197 inst.components.combat:SetHurtSound("dontstarve_DLC001/creatures/dragonfly/hurt") 198 inst.components.combat:SetRetargetFunction(1, function(inst) 199 if not inst.components.health:IsDead() then 200 return FindEntity(inst, 25, function(guy) 201 if guy.components.combat then 202 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 203 end 204 end ) 205 end 206 end ) 207 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) 208 inst:ListenForEvent("attacked", function(inst, data) 209 if data.attacker ~= GetPlayer() then 210 if not data.attacker:HasTag("myflys") then 211 inst.components.combat:SetTarget(data.attacker) 212 end 213 else 214 inst.components.health:Kill() 215 end 216 end ) 217 inst:AddComponent("locomotor") 218 inst.components.locomotor.walkspeed = 25 219 inst:SetStateGraph("SGdragonfly") 220 local brain = require "brains/abigailbrain" 221 inst:SetBrain(brain) 222 inst:DoPeriodicTask(5, function() 223 if inst.components.combat and not inst.components.combat.target then 224 if inst.fire_build then 225 inst.sg:GoToState("flameoff") 226 end 227 if inst.components.health and inst.components.health:GetPercent() < 1 then 228 inst.components.health:DoDelta(200) 229 end 230 end 231 end ) 232 inst:AddComponent("machine") 233 inst.components.machine.turnonfn = function() 234 inst:AddTag("inhaling") 235 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 236 inst.task = inst:DoPeriodicTask(.5, function(inst) 237 local pos = Vector3(inst.Transform:GetWorldPosition()) 238 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 15) 239 for k,v in pairs(ents) do 240 local pt1 = v:GetPosition() 241 if v.components.inventoryitem and v.components.inventoryitem.canbepickedup and v.components.inventoryitem.cangoincontainer 242 and not v.components.inventoryitem:IsHeld() and not v:HasTag("trap") and not v:HasTag("light") and not v:HasTag("blowdart") 243 and not v:HasTag("projectile") then 244 if not GetPlayer().components.inventory:IsFull() then 245 SpawnPrefab("small_puff").Transform:SetPosition(pt1.x, pt1.y, pt1.z) 246 GetPlayer().components.inventory:GiveItem(v) 247 GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/research_available") 248 end 249 end 250 end 251 end ) 252 end 253 inst.components.machine.turnofffn = function() 254 inst:RemoveTag("inhaling") 255 inst.AnimState:SetBloomEffectHandle( "" ) 256 if inst.task then inst.task:Cancel() inst.task = nil end 257 end 258 inst.components.inspectable.getstatus = function(inst) 259 if not inst:HasTag("stophere") then 260 inst:AddTag("stophere") 261 inst.components.locomotor:Stop() 262 inst:SetBrain(nil) 263 inst.components.follower:SetLeader(nil) 264 inst.sg:GoToState("flameoff") 265 else 266 inst:RemoveTag("stophere") 267 local brain = require "brains/abigailbrain" 268 inst:SetBrain(brain) 269 inst:RestartBrain() 270 inst.components.follower:SetLeader(GetPlayer()) 271 end 272 end 273 inst:ListenForEvent("death", function() 274 inst.components.machine:TurnOff() 275 end ) 276 inst:AddTag("companion") 277 inst:AddTag("myflys") 278 end 279 if data and data.stophere then 280 inst:AddTag("stophere") 281 inst.components.locomotor:Stop() 282 inst:SetBrain(nil) 283 inst.components.follower:SetLeader(nil) 284 inst.sg:GoToState("flameoff") 285 end 286 if data and data.inhaling then 287 inst.components.machine.ison = true 288 inst.components.machine:TurnOn() 289 end 290end 291 inst.OnSave = onsave 292 inst.OnLoad = onload 293 294 即可用蜻蜓盔甲种宠物蜻蜓,攻击力超强,并自动补血,是战斗时的好帮手。鼠标左键点蜻蜓,可让它停在原地,再次点击可继续跟随。鼠标右键点蜻蜓,可让它帮你捡地上的东西(快速吸取至主角物品栏),再次点击可停止捡东西。不想要宠物蜻蜓了,杀死即可(按Ctrl + 鼠标左键攻击),打一下即死。宠物蜻蜓攻击时会引发火灾,所以带它战斗时不要离基地太近,也不要同时带1个以上的宠物蜻蜓去战斗,否则容易互殴。蜻蜓盔甲在战斗选项(画着两把剑)下,用1个蜻蜓鳞片、1个木盔甲、3个猪皮制造

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二0五.统御战狼(按键盘X键召唤战狼,誓死护卫你,给5块疯肉升级为金刚战狼) 3 4 1.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/player_common.lua文件,在inst:AddComponent("playercontroller")的下一行插入以下内容: 5 6TheInput:AddKeyUpHandler(KEY_X, function() 7 if inst.components.inventory:Has("goldnugget", 20) then 8 inst.components.inventory:ConsumeByName("goldnugget", 20) 9 inst.AnimState:PlayAnimation("give") 10 inst.SoundEmitter:PlaySound("dontstarve/common/horn_beefalo") 11 local mywolf = SpawnPrefab("greenamulet") 12 local pt = GetPlayer():GetPosition() 13 mywolf.Transform:SetPosition(pt.x+(math.random(3)-math.random(3)), 0, pt.z+(math.random(3)-math.random(3))) 14 mywolf.AnimState:SetBank("warg") 15 mywolf.AnimState:SetBuild("warg_build") 16 mywolf.AnimState:PlayAnimation("idle") 17 mywolf.Transform:SetScale(0.6, 0.6, 0.6) 18 mywolf.Transform:SetFourFaced() 19 local sound = mywolf.entity:AddSoundEmitter() 20 local shadow = mywolf.entity:AddDynamicShadow() 21 shadow:SetSize(1.2, 0.7) 22 MakeCharacterPhysics(mywolf, 100, 1) 23 mywolf:RemoveComponent("equippable") 24 mywolf:RemoveComponent("inventoryitem") 25 mywolf:RemoveComponent("finiteuses") 26 mywolf:RemoveComponent("deployable") 27 mywolf:AddComponent("named") 28 mywolf.components.named:SetName("Wolf") 29 mywolf:AddComponent("follower") 30 mywolf.components.follower:SetLeader(GetPlayer()) 31 mywolf:AddComponent("lootdropper") 32 mywolf.components.lootdropper:SetLoot({"monstermeat", "houndstooth"}) 33 mywolf:AddComponent("health") 34 mywolf.components.health:SetMaxHealth(1000) 35 mywolf.components.health:StartRegen(50, 10) 36 mywolf:AddComponent("combat") 37 mywolf.components.combat:SetDefaultDamage(50) 38 mywolf.components.combat:SetAttackPeriod(0.5) 39 mywolf.components.combat:SetRange(3) 40 mywolf.components.combat:SetRetargetFunction(1, function(mywolf) 41 if not mywolf.components.health:IsDead() then 42 return FindEntity(mywolf, 25, function(guy) 43 if guy.components.combat then 44 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 45 end 46 end ) 47 end 48 end ) 49 mywolf.components.combat:SetKeepTargetFunction(function(mywolf, target) return target and target:IsValid() end ) 50 mywolf:ListenForEvent("attacked", function(mywolf, data) 51 if data.attacker ~= GetPlayer() then 52 mywolf.components.combat:SetTarget(data.attacker) 53 mywolf.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("mywolfs") and not dude.components.health:IsDead() end, 10) 54 else 55 mywolf.components.health:Kill() 56 end 57 end ) 58 mywolf:AddComponent("locomotor") 59 mywolf.components.locomotor.runspeed = 18 60 mywolf.components.locomotor:SetShouldRun(true) 61 mywolf:SetStateGraph("SGwarg") 62 local brain = require "brains/abigailbrain" 63 mywolf:SetBrain(brain) 64 mywolf:AddComponent("trader") 65 mywolf.components.trader:SetAcceptTest(function(mywolf, item) 66 if GetPlayer().components.inventory:Has("monstermeat", 5) then 67 if item.prefab == "monstermeat" then 68 if not mywolf:HasTag("superwolf") then 69 return true 70 end 71 end 72 end 73 return false 74 end ) 75 mywolf.components.trader.onaccept = function(mywolf, giver, item) 76 if item.prefab == "monstermeat" then 77 giver.components.inventory:ConsumeByName("monstermeat", 4) 78 mywolf:AddTag("superwolf") 79 mywolf.components.named:SetName("Super Wolf") 80 mywolf.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 81 mywolf.Transform:SetScale(0.7, 0.7, 0.7) 82 mywolf.components.health:SetMaxHealth(2000) 83 mywolf.components.health:DoDelta(2000) 84 mywolf.components.combat:SetDefaultDamage(100) 85 mywolf.components.locomotor.runspeed = 25 86 end 87 end 88 mywolf.components.inspectable.getstatus = function(mywolf) 89 if not mywolf:HasTag("stophere") then 90 mywolf:AddTag("stophere") 91 mywolf.components.locomotor:Stop() 92 mywolf:SetBrain(nil) 93 mywolf.components.follower:SetLeader(nil) 94 else 95 mywolf:RemoveTag("stophere") 96 local brain = require "brains/abigailbrain" 97 mywolf:SetBrain(brain) 98 mywolf:RestartBrain() 99 mywolf.components.follower:SetLeader(GetPlayer()) 100 end 101 end 102 mywolf:AddTag("companion") 103 mywolf:AddTag("mywolfs") 104 end 105end ) 106 107 108 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/amulet.lua文件,在inst.AnimState:PlayAnimation("greenamulet")的下一行插入以下内容: 109 110local function onsave(inst, data) 111 if inst:HasTag("mywolfs") then 112 data.mywolfs = true 113 end 114 if inst:HasTag("superwolf") then 115 data.superwolf = true 116 end 117 if inst:HasTag("stophere") then 118 data.stophere = true 119 end 120end 121local function onload(inst, data) 122 if data and data.mywolfs then 123 inst.AnimState:SetBank("warg") 124 inst.AnimState:SetBuild("warg_build") 125 inst.AnimState:PlayAnimation("idle") 126 inst.Transform:SetScale(0.6, 0.6, 0.6) 127 inst.Transform:SetFourFaced() 128 local sound = inst.entity:AddSoundEmitter() 129 local shadow = inst.entity:AddDynamicShadow() 130 shadow:SetSize(1.2, 0.7) 131 MakeCharacterPhysics(inst, 100, 1) 132 inst:RemoveComponent("equippable") 133 inst:RemoveComponent("inventoryitem") 134 inst:RemoveComponent("finiteuses") 135 inst:RemoveComponent("deployable") 136 inst:AddComponent("named") 137 inst.components.named:SetName("Wolf") 138 inst:AddComponent("follower") 139 inst.components.follower:SetLeader(GetPlayer()) 140 inst:AddComponent("lootdropper") 141 inst.components.lootdropper:SetLoot({"monstermeat", "houndstooth"}) 142 inst:AddComponent("health") 143 inst.components.health:SetMaxHealth(1000) 144 inst.components.health:StartRegen(50, 10) 145 inst:AddComponent("combat") 146 inst.components.combat:SetDefaultDamage(50) 147 inst.components.combat:SetAttackPeriod(0.5) 148 inst.components.combat:SetRange(3) 149 inst.components.combat:SetRetargetFunction(1, function(inst) 150 if not inst.components.health:IsDead() then 151 return FindEntity(inst, 25, function(guy) 152 if guy.components.combat then 153 return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") 154 end 155 end ) 156 end 157 end ) 158 inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) 159 inst:ListenForEvent("attacked", function(inst, data) 160 if data.attacker ~= GetPlayer() then 161 inst.components.combat:SetTarget(data.attacker) 162 inst.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("mywolfs") and not dude.components.health:IsDead() end, 10) 163 else 164 inst.components.health:Kill() 165 end 166 end ) 167 inst:AddComponent("locomotor") 168 inst.components.locomotor.runspeed = 18 169 inst.components.locomotor:SetShouldRun(true) 170 inst:SetStateGraph("SGwarg") 171 local brain = require "brains/abigailbrain" 172 inst:SetBrain(brain) 173 inst:AddComponent("trader") 174 inst.components.trader:SetAcceptTest(function(inst, item) 175 if GetPlayer().components.inventory:Has("monstermeat", 5) then 176 if item.prefab == "monstermeat" then 177 if not inst:HasTag("superwolf") then 178 return true 179 end 180 end 181 end 182 return false 183 end ) 184 inst.components.trader.onaccept = function(inst, giver, item) 185 if item.prefab == "monstermeat" then 186 giver.components.inventory:ConsumeByName("monstermeat", 4) 187 inst:AddTag("superwolf") 188 inst.components.named:SetName("Super Wolf") 189 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 190 inst.Transform:SetScale(0.7, 0.7, 0.7) 191 inst.components.health:SetMaxHealth(2000) 192 inst.components.health:DoDelta(2000) 193 inst.components.combat:SetDefaultDamage(100) 194 inst.components.locomotor.runspeed = 25 195 end 196 end 197 inst.components.inspectable.getstatus = function(inst) 198 if not inst:HasTag("stophere") then 199 inst:AddTag("stophere") 200 inst.components.locomotor:Stop() 201 inst:SetBrain(nil) 202 inst.components.follower:SetLeader(nil) 203 else 204 inst:RemoveTag("stophere") 205 local brain = require "brains/abigailbrain" 206 inst:SetBrain(brain) 207 inst:RestartBrain() 208 inst.components.follower:SetLeader(GetPlayer()) 209 end 210 end 211 inst:AddTag("companion") 212 inst:AddTag("mywolfs") 213 end 214 if data and data.superwolf then 215 inst:AddTag("superwolf") 216 inst.components.named:SetName("Super Wolf") 217 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 218 inst.Transform:SetScale(0.7, 0.7, 0.7) 219 inst.components.health:SetMaxHealth(2000) 220 inst.components.health:DoDelta(2000) 221 inst.components.combat:SetDefaultDamage(100) 222 inst.components.locomotor.runspeed = 25 223 end 224 if data and data.stophere then 225 inst:AddTag("stophere") 226 inst.components.locomotor:Stop() 227 inst:SetBrain(nil) 228 inst.components.follower:SetLeader(nil) 229 end 230end 231 inst.OnSave = onsave 232 inst.OnLoad = onload 233 234 即可按键盘X键召唤战狼,每只花费20个黄金,身上黄金数不足时无法召唤。战狼极其忠诚,会誓死护卫你,鼠标左键点击可停在原地,再次点击则继续跟随。如果想赐战狼死,用任何武器打击一下即可(按Ctrl + 鼠标左键攻击),它不会还击。战狼生命力顽强,会自动回血。当一只战狼遭到攻击时,其他战狼会围攻敌人。给战狼5块疯肉(拿着疯肉对战狼点鼠标左键),可将其升级为金刚战狼,生命值、攻击力、速度会大幅提升。统御你的战狼部队,横扫大陆吧

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2二0七.斗牛场(用牛角种斗牛场,与公牛搏斗赢奖金,观众会向场内扔额外赏金) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/horn.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local sounds = 7{ 8 walk = "dontstarve/beefalo/walk", 9 grunt = "dontstarve/beefalo/grunt", 10 yell = "dontstarve/beefalo/yell", 11 swish = "dontstarve/beefalo/tail_swish", 12 curious = "dontstarve/beefalo/curious", 13 angry = "dontstarve/beefalo/angry", 14} 15local function makebullring(inst) 16 local pt = inst:GetPosition() 17 local bullring0 = SpawnPrefab("horn") 18 bullring0.Transform:SetPosition(pt.x, pt.y, pt.z) 19 bullring0.AnimState:SetBank("marble_trees") 20 bullring0.AnimState:SetBuild("marble_trees") 21 bullring0.AnimState:PlayAnimation("full_4") 22 bullring0.Transform:SetScale(1.5, 1.5, 1.5) 23 bullring0:RemoveComponent("instrument") 24 bullring0:RemoveComponent("tool") 25 bullring0:RemoveComponent("finiteuses") 26 bullring0:RemoveComponent("inventoryitem") 27 bullring0:RemoveComponent("deployable") 28 bullring0:RemoveTag("horn") 29 bullring0:AddComponent("named") 30 bullring0.components.named:SetName("Bullring") 31 local light = bullring0.entity:AddLight() 32 light:SetFalloff(1) 33 light:SetIntensity(.8) 34 light:SetRadius(15) 35 light:SetColour(180/255, 195/255, 50/255) 36 light:Enable(true) 37 bullring0:AddComponent("workable") 38 bullring0.components.workable:SetWorkAction(ACTIONS.HAMMER) 39 bullring0.components.workable:SetWorkLeft(3) 40 bullring0.components.workable:SetOnFinishCallback(function() 41 SpawnPrefab("collapse_big").Transform:SetPosition(bullring0.Transform:GetWorldPosition()) 42 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") 43 local pos = Vector3(bullring0.Transform:GetWorldPosition()) 44 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 10) 45 for k,v in pairs(ents) do 46 if v:HasTag("nobullring") then 47 v:Remove() 48 end 49 end 50 bullring0:Remove() 51 end ) 52 bullring0.components.inspectable.getstatus = function(bullring0) 53 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/horn_beefalo") 54 local bullfighting = SpawnPrefab("horn") 55 bullfighting.Transform:SetPosition(pt.x+2, 0, pt.z+2) 56 bullfighting.AnimState:SetBank("beefalo") 57 bullfighting.AnimState:SetBuild("beefalo_build") 58 bullfighting.AnimState:PlayAnimation("idle_loop", true) 59 bullfighting.Transform:SetFourFaced() 60 bullfighting.Transform:SetScale(1.3, 1.3, 1.3) 61 local sound = bullfighting.entity:AddSoundEmitter() 62 bullfighting.sounds = sounds 63 local shadow = bullfighting.entity:AddDynamicShadow() 64 shadow:SetSize( 3, 1.25 ) 65 MakeCharacterPhysics(bullfighting, 200, 1.3) 66 bullfighting:RemoveComponent("instrument") 67 bullfighting:RemoveComponent("tool") 68 bullfighting:RemoveComponent("finiteuses") 69 bullfighting:RemoveComponent("inventoryitem") 70 bullfighting:RemoveComponent("deployable") 71 bullfighting:RemoveTag("horn") 72 bullfighting:AddComponent("named") 73 bullfighting.components.named:SetName("Bullfighting") 74 bullfighting:AddComponent("locomotor") 75 bullfighting.components.locomotor.walkspeed = math.random(4,6) 76 bullfighting.components.locomotor.runspeed = math.random(8,10) 77 bullfighting:SetStateGraph("SGBeefalo") 78 local brain = require "brains/leifbrain" 79 bullfighting:SetBrain(brain) 80 bullfighting:AddComponent("follower") 81 bullfighting:AddComponent("knownlocations") 82 bullfighting:AddComponent("lootdropper") 83 bullfighting.components.lootdropper:SetLoot({"meat","meat","meat","meat","meat","meat","beefalowool","beefalowool","beefalowool","beefalowool"}) 84 bullfighting.components.lootdropper:AddChanceLoot("horn", 0.1) 85 bullfighting:AddComponent("health") 86 bullfighting.components.health:SetMaxHealth(math.random(3000,7000)) 87 bullfighting:AddComponent("combat") 88 bullfighting.components.combat:SetTarget(GetPlayer()) 89 bullfighting.components.combat.hiteffectsymbol = "beefalo_body" 90 bullfighting.components.combat:SetDefaultDamage(math.random(30,70)) 91 bullfighting.components.combat:SetAttackPeriod(math.random(1,3)) 92 bullfighting.components.combat:SetRetargetFunction(1, function(bullfighting) 93 if not bullfighting.components.health:IsDead() then 94 return FindEntity(bullfighting, 200, function(guy) 95 if guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("bullfighting") then 96 return guy:HasTag("player") 97 end 98 end ) 99 end 100 end ) 101 bullfighting.components.combat:SetKeepTargetFunction(function(bullfighting, target) return target and target:IsValid() end ) 102 bullfighting:ListenForEvent("death", function() 103 for k = 1, 30 do 104 local goldnugget = SpawnPrefab("goldnugget") 105 GetPlayer().components.inventory:GiveItem(goldnugget) 106 end 107 GetPlayer():StartThread(function() 108 for k = 1, math.random(3,10) do 109 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") 110 local bounty = SpawnPrefab("goldnugget") 111 bounty.Transform:SetPosition(pt.x, pt.y, pt.z) 112 bounty.components.inventoryitem.canbepickedup = false 113 bounty:AddComponent("complexprojectile") 114 bounty.components.complexprojectile.yOffset = 2.5 115 bounty.components.complexprojectile:Launch(Point(pt.x+(math.random(6,10)-math.random(5)), 0, pt.z+(math.random(6,10)-math.random(5)))) 116 bounty.components.complexprojectile:SetOnHit(function() 117 bounty:RemoveComponent("complexprojectile") 118 bounty.components.inventoryitem.canbepickedup = true 119 end ) 120 Sleep(0.15) 121 end 122 end ) 123 end ) 124 bullfighting:DoTaskInTime(60, function() 125 if not bullfighting.components.health:IsDead() then 126 SpawnPrefab("die_fx").Transform:SetPosition(bullfighting.Transform:GetWorldPosition()) 127 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 128 bullfighting:Remove() 129 end 130 end ) 131 bullfighting:AddTag("bullfighting") 132 end 133 bullring0:AddTag("bullring0") 134 local bullring1 = SpawnPrefab("horn") 135 bullring1.Transform:SetPosition(pt.x+2.5, 0, pt.z-2.5) 136 bullring1.AnimState:SetBank("marble_trees") 137 bullring1.AnimState:SetBuild("marble_trees") 138 bullring1.AnimState:PlayAnimation("full_4") 139 bullring1.Transform:SetScale(0.8, 0.8, 0.8) 140 bullring1:RemoveComponent("instrument") 141 bullring1:RemoveComponent("tool") 142 bullring1:RemoveComponent("finiteuses") 143 bullring1:RemoveComponent("inventoryitem") 144 bullring1:RemoveComponent("deployable") 145 bullring1:RemoveTag("horn") 146 bullring1:AddTag("NOCLICK") 147 bullring1:AddTag("nobullring") 148 local bullring2 = SpawnPrefab("horn") 149 bullring2.Transform:SetPosition(pt.x-2.5, 0, pt.z+2.5) 150 bullring2.AnimState:SetBank("marble_trees") 151 bullring2.AnimState:SetBuild("marble_trees") 152 bullring2.AnimState:PlayAnimation("full_4") 153 bullring2.Transform:SetScale(0.8, 0.8, 0.8) 154 bullring2:RemoveComponent("instrument") 155 bullring2:RemoveComponent("tool") 156 bullring2:RemoveComponent("finiteuses") 157 bullring2:RemoveComponent("inventoryitem") 158 bullring2:RemoveComponent("deployable") 159 bullring2:RemoveTag("horn") 160 bullring2:AddTag("NOCLICK") 161 bullring2:AddTag("nobullring") 162 for k = 0,6 do 163 local audience = SpawnPrefab("horn") 164 audience.Transform:SetPosition(pt.x-2+6-k*2, 0, pt.z-2-6+k*2) 165 audience.AnimState:SetBank("wilson") 166 local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} 167 local buildname = names[math.random(#names)] 168 audience.AnimState:SetBuild(buildname) 169 local hats = {"hat_bee","hat_beefalo","hat_bush","hat_earmuffs","hat_feather","hat_flower","hat_football","hat_miner","hat_ruins","hat_slurper","hat_slurtle","hat_spider","hat_straw","hat_top","hat_walrus","hat_winter","hat_rain","hat_watermelon","hat_ice","hat_catcoon","hat_wathgrithr"} 170 local hat = hats[math.random(#hats)] 171 audience.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") 172 local armors = {"armor_grass","armor_marble","armor_onemanband","armor_ruins","armor_sanity","armor_slurper","armor_slurtleshell","armor_sweatervest","armor_trunkvest_summer","armor_trunkvest_winter","armor_wood","torso_rain"} 173 local armor = armors[math.random(#armors)] 174 audience.AnimState:OverrideSymbol("swap_body", armor, "swap_body") 175 audience.AnimState:Show("HAT") 176 audience.AnimState:Show("HAT_HAIR") 177 audience.AnimState:Hide("HAIR_NOHAT") 178 audience.AnimState:Hide("HAIR") 179 audience.AnimState:Hide("ARM_carry") 180 audience.AnimState:Show("ARM_normal") 181 local stories = {"idle","hungry","eat","dart","throw","atk","idle_onemanband1_loop","run_pst","item_hat","give"} 182 local story = stories[math.random(#stories)] 183 audience.AnimState:PlayAnimation(story,true) 184 audience.Transform:SetFourFaced() 185 audience:RemoveComponent("instrument") 186 audience:RemoveComponent("tool") 187 audience:RemoveComponent("finiteuses") 188 audience:RemoveComponent("inventoryitem") 189 audience:RemoveComponent("deployable") 190 audience:RemoveTag("horn") 191 audience:AddTag("NOCLICK") 192 audience:AddTag("nobullring") 193 end 194end 195local function OnDeploy (inst, pt) 196 makebullring(inst) 197 inst:Remove() 198end 199 inst:AddComponent("deployable") 200 inst.components.deployable.ondeploy = OnDeploy 201local function onsave(inst, data) 202 if inst:HasTag("bullring0") then 203 data.bullring0 = true 204 end 205 if inst:HasTag("bullfighting") then 206 data.bullfighting = true 207 end 208 if inst:HasTag("nobullring") then 209 data.nobullring = true 210 end 211end 212local function onload(inst, data) 213 if data and data.bullring0 then 214 makebullring(inst) 215 inst:Remove() 216 end 217 if data and data.bullfighting then 218 inst:Remove() 219 end 220 if data and data.nobullring then 221 inst:Remove() 222 end 223end 224 inst.OnSave = onsave 225 inst.OnLoad = onload 226 227 即可用牛角种斗牛场,鼠标左键点中间的大理石树,会冲出公牛,1分钟内战胜它,可获得30个黄金的奖金(直接放入主角物品栏),和大肉、牛毛等战利品。如未能获胜,1分钟后公牛将消失。每次冲出的公牛,血量、攻击力、攻击节奏、速度都不同,这次打不赢,不代表下次不会胜利哦。场外会有观众为你喝彩,如果你获胜,他们会向场内扔黄金(数量不等),作为你额外的奖励。不想要斗牛场了,用锤子砸掉中间的大理石树即可

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

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

2025/04/23 · Bny