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

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

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二一六.鬼影重重(夜晚墓地有大量亡魂游荡,购买亡魂之心让主角变身亡魂) 1.用MT管理器打开游戏目录/assets/scripts/prefabs/gravestone.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function createghostnpc(inst) for k = 1,math.random(3,7) do local pt = inst:GetPosition() local ghostnpc = SpawnPrefab("deadlyfeast") ghostnpc.Transform:SetPosition(pt.x+(math.random(20)-math.random(20)), 0, pt.z+(math.random(20)-math.random(20))) ghostnpc.entity:AddSoundEmitter() ghostnpc.AnimState:SetBank("ghost") ghostnpc.AnimState:SetBuild("ghost_build") ghostnpc.AnimState:PlayAnimation("idle", true) ghostnpc.Transform:SetFourFaced() MakeGhostPhysics(ghostnpc, 1, .5) local minimap = ghostnpc.entity:AddMiniMapEntity() minimap:SetIcon("whitespider_den.png") ghostnpc.AnimState:SetBloomEffectHandle("shaders/anim.ksh") local light = ghostnpc.entity:AddLight() light:SetIntensity(.6) light:SetRadius(.5) light:SetFalloff(.6) light:Enable(true) light:SetColour(180/255, 195/255, 225/255) local brain = require "brains/leifbrain" ghostnpc:SetBrain(brain) ghostnpc:AddComponent("locomotor") ghostnpc.components.locomotor.walkspeed = 5 ghostnpc.components.locomotor.runspeed = 5 ghostnpc:SetStateGraph("SGghost") ghostnpc:AddTag("ghostnpcs") ghostnpc:RemoveComponent("edible") ghostnpc:RemoveComponent("inventoryitem") ghostnpc:RemoveTag("meat") ghostnpc:AddComponent("sanityaura") ghostnpc.components.sanityaura.aura = -TUNING.SANITYAURA_SMALL ghostnpc:AddComponent("health") ghostnpc.components.health:SetMaxHealth(500) ghostnpc:AddComponent("trader") ghostnpc.components.trader:SetAcceptTest(function(ghostnpc, item) if GetPlayer().components.inventory:Has("goldnugget", 30) then if item.prefab == "goldnugget" then return true end end return false end ) ghostnpc.components.trader.onaccept = function(ghostnpc, giver, item) GetPlayer().components.inventory:ConsumeByName("goldnugget", 29) local ghostheart = SpawnPrefab("deadlyfeast") ghostheart.AnimState:SetBank("egg") ghostheart.AnimState:SetBuild("tallbird_egg") ghostheart.AnimState:PlayAnimation("cooked") ghostheart.components.inventoryitem:ChangeImageName("tallbirdegg_cooked") ghostheart:RemoveComponent("edible") ghostheart:RemoveTag("meat") ghostheart:AddComponent("equippable") ghostheart.components.equippable:SetOnEquip( function(ghostheart, owner) if owner == GetPlayer() and not GetPlayer():HasTag("poisoning") and not GetPlayer():HasTag("fever") then owner.components.locomotor:Stop() owner.components.playercontroller:Enable(false) owner:DoTaskInTime(0.3, function() SpawnPrefab("collapse_big").Transform:SetPosition(owner.Transform:GetWorldPosition()) owner.AnimState:SetBank("ghost") owner.AnimState:SetBuild("ghost_build") owner:SetStateGraph("SGghost") owner.AnimState:PlayAnimation("idle", true) owner.Transform:SetScale(1.2,1.2,1.2) local shadow = owner.entity:AddDynamicShadow() shadow:SetSize( 0, 0 ) owner.AnimState:SetBloomEffectHandle("shaders/anim.ksh") local light = owner.entity:AddLight() light:SetIntensity(.6) light:SetRadius(20) light:SetFalloff(.6) light:Enable(true) light:SetColour(180/255, 195/255, 225/255) owner.components.locomotor.walkspeed = 20 owner.components.locomotor.runspeed = 20 owner.components.health:DoDelta(owner.components.health.maxhealth) owner.components.health:SetInvincible(true) owner.components.hunger:DoDelta(owner.components.hunger.max) owner.components.hunger:Pause() owner.components.sanity:DoDelta(owner.components.sanity.max) owner.components.sanity.ignore = true owner.components.combat:SetDefaultDamage(1000) owner:AddComponent("aura") owner.components.aura.radius = 3 owner.components.aura.tickperiod = 0.5 owner.components.aura.ignoreallies = true owner.components.aura.auratestfn = function(ghostnpc, target) if target.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == target then return true end return false end owner.components.temperature:SetTemp(20) owner.components.playercontroller:Enable(true) end ) end end ) ghostheart.components.equippable:SetOnUnequip( function(ghostheart, owner) SpawnPrefab("collapse_big").Transform:SetPosition(owner.Transform:GetWorldPosition()) owner.components.locomotor:Stop() owner.components.playercontroller:Enable(false) owner:DoTaskInTime(0.3, function() owner.AnimState:SetBank("wilson") if GetPlayer().prefab == "wilson" then owner.AnimState:SetBuild("wilson") end if GetPlayer().prefab == "wendy" then owner.AnimState:SetBuild("wendy") end if GetPlayer().prefab == "wes" then owner.AnimState:SetBuild("wes") end if GetPlayer().prefab == "wickerbottom" then owner.AnimState:SetBuild("wickerbottom") end if GetPlayer().prefab == "willow" then owner.AnimState:SetBuild("willow") end if GetPlayer().prefab == "wolfgang" then owner.AnimState:SetBuild("wolfgang") end if GetPlayer().prefab == "wx78" then owner.AnimState:SetBuild("wx78") end if GetPlayer().prefab == "woodie" then owner.AnimState:SetBuild("woodie") end if GetPlayer().prefab == "waxwell" then owner.AnimState:SetBuild("waxwell") end if GetPlayer().prefab == "wathgrithr" then owner.AnimState:SetBuild("wathgrithr") end if GetPlayer().prefab == "webber" then owner.AnimState:SetBuild("webber") end owner:SetStateGraph("SGwilson") owner.AnimState:PlayAnimation("idle") owner.Transform:SetScale(1,1,1) local shadow = owner.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) owner.AnimState:SetBloomEffectHandle("") owner.Light:Enable(false) owner.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED owner.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED owner.components.health:SetInvincible(false) owner.components.hunger:Resume() owner.components.sanity.ignore = false owner.components.combat:SetDefaultDamage(TUNING.UNARMED_DAMAGE) owner.components.combat.hiteffectsymbol = "torso" owner:RemoveComponent("aura") owner.components.temperature:SetTemp(nil) owner.components.playercontroller:Enable(true) ghostheart:Remove() end ) end ) ghostheart.components.equippable.equipslot = EQUIPSLOTS.HANDS ghostheart:AddTag("ghostheart") GetPlayer().components.inventory:GiveItem(ghostheart) end ghostnpc:AddComponent("combat") ghostnpc.components.combat:SetDefaultDamage(3) ghostnpc.components.combat:SetAttackPeriod(1) ghostnpc.components.combat:SetRetargetFunction(2, function(ghostnpc) if not ghostnpc.components.health:IsDead() then return FindEntity(ghostnpc, 25, function(guy) if guy:HasTag("monster") then return guy end 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 end ) end end ) ghostnpc:ListenForEvent("attacked", function(ghostnpc, data) ghostnpc.components.combat:SetTarget(data.attacker) ghostnpc.components.combat:ShareTarget(data.attacker, 35, function(dude) return dude:HasTag("ghostnpcs") and not dude.components.health:IsDead() end, 5) end ) ghostnpc:AddComponent("aura") ghostnpc.components.aura.radius = 2 ghostnpc.components.aura.tickperiod = 1 ghostnpc.components.aura.ignoreallies = true ghostnpc.components.aura.auratestfn = function(ghostnpc, target) if target:HasTag("ghostnpcs") then return false end if target.components.combat.target == ghostnpc or ghostnpc.components.combat.target == target then return true end end ghostnpc:ListenForEvent("death", function() local gems = {"purplegem","bluegem","redgem","orangegem","yellowgem","greengem","thulecite","goldnugget"} local gem = gems[math.random(#gems)] SpawnPrefab(gem).Transform:SetPosition(ghostnpc.Transform:GetWorldPosition()) end ) ghostnpc:ListenForEvent( "daytime", function() ghostnpc:Remove() end , GetWorld()) end end inst:ListenForEvent( "dusktime", function() createghostnpc(inst) end , GetWorld()) 2.用MT管理器打开游戏目录/assets/scripts/prefabs/deadlyfeast.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function onsave(inst, data) if inst:HasTag("ghostnpcs") then data.ghostnpcs = true end if inst:HasTag("ghostheart") then data.ghostheart = true end end local function onload(inst, data) if data and data.ghostnpcs then inst.entity:AddSoundEmitter() inst.AnimState:SetBank("ghost") inst.AnimState:SetBuild("ghost_build") inst.AnimState:PlayAnimation("idle", true) inst.Transform:SetFourFaced() MakeGhostPhysics(inst, 1, .5) local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon("whitespider_den.png") inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") local light = inst.entity:AddLight() light:SetIntensity(.6) light:SetRadius(.5) light:SetFalloff(.6) light:Enable(true) light:SetColour(180/255, 195/255, 225/255) local brain = require "brains/leifbrain" inst:SetBrain(brain) inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 5 inst.components.locomotor.runspeed = 5 inst:SetStateGraph("SGghost") inst:AddTag("ghostnpcs") inst:RemoveComponent("edible") inst:RemoveComponent("inventoryitem") inst:RemoveTag("meat") inst:AddComponent("sanityaura") inst.components.sanityaura.aura = -TUNING.SANITYAURA_SMALL inst:AddComponent("health") inst.components.health:SetMaxHealth(500) inst:AddComponent("trader") inst.components.trader:SetAcceptTest(function(inst, item) if GetPlayer().components.inventory:Has("goldnugget", 30) then if item.prefab == "goldnugget" then return true end end return false end ) inst.components.trader.onaccept = function(inst, giver, item) GetPlayer().components.inventory:ConsumeByName("goldnugget", 29) local ghostheart = SpawnPrefab("deadlyfeast") ghostheart.AnimState:SetBank("egg") ghostheart.AnimState:SetBuild("tallbird_egg") ghostheart.AnimState:PlayAnimation("cooked") ghostheart.components.inventoryitem:ChangeImageName("tallbirdegg_cooked") ghostheart:RemoveComponent("edible") ghostheart:RemoveTag("meat") ghostheart:AddComponent("equippable") ghostheart.components.equippable:SetOnEquip( function(ghostheart, owner) if owner == GetPlayer() and not GetPlayer():HasTag("poisoning") and not GetPlayer():HasTag("fever") then owner.components.locomotor:Stop() owner.components.playercontroller:Enable(false) owner:DoTaskInTime(0.3, function() SpawnPrefab("collapse_big").Transform:SetPosition(owner.Transform:GetWorldPosition()) owner.AnimState:SetBank("ghost") owner.AnimState:SetBuild("ghost_build") owner:SetStateGraph("SGghost") owner.AnimState:PlayAnimation("idle", true) owner.Transform:SetScale(1.2,1.2,1.2) local shadow = owner.entity:AddDynamicShadow() shadow:SetSize( 0, 0 ) owner.AnimState:SetBloomEffectHandle("shaders/anim.ksh") local light = owner.entity:AddLight() light:SetIntensity(.6) light:SetRadius(20) light:SetFalloff(.6) light:Enable(true) light:SetColour(180/255, 195/255, 225/255) owner.components.locomotor.walkspeed = 20 owner.components.locomotor.runspeed = 20 owner.components.health:DoDelta(owner.components.health.maxhealth) owner.components.health:SetInvincible(true) owner.components.hunger:DoDelta(owner.components.hunger.max) owner.components.hunger:Pause() owner.components.sanity:DoDelta(owner.components.sanity.max) owner.components.sanity.ignore = true owner.components.combat:SetDefaultDamage(1000) owner:AddComponent("aura") owner.components.aura.radius = 3 owner.components.aura.tickperiod = 0.5 owner.components.aura.ignoreallies = true owner.components.aura.auratestfn = function(inst, target) if target.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == target then return true end return false end owner.components.temperature:SetTemp(20) owner.components.playercontroller:Enable(true) end ) end end ) ghostheart.components.equippable:SetOnUnequip( function(ghostheart, owner) SpawnPrefab("collapse_big").Transform:SetPosition(owner.Transform:GetWorldPosition()) owner.components.locomotor:Stop() owner.components.playercontroller:Enable(false) owner:DoTaskInTime(0.3, function() owner.AnimState:SetBank("wilson") if GetPlayer().prefab == "wilson" then owner.AnimState:SetBuild("wilson") end if GetPlayer().prefab == "wendy" then owner.AnimState:SetBuild("wendy") end if GetPlayer().prefab == "wes" then owner.AnimState:SetBuild("wes") end if GetPlayer().prefab == "wickerbottom" then owner.AnimState:SetBuild("wickerbottom") end if GetPlayer().prefab == "willow" then owner.AnimState:SetBuild("willow") end if GetPlayer().prefab == "wolfgang" then owner.AnimState:SetBuild("wolfgang") end if GetPlayer().prefab == "wx78" then owner.AnimState:SetBuild("wx78") end if GetPlayer().prefab == "woodie" then owner.AnimState:SetBuild("woodie") end if GetPlayer().prefab == "waxwell" then owner.AnimState:SetBuild("waxwell") end if GetPlayer().prefab == "wathgrithr" then owner.AnimState:SetBuild("wathgrithr") end if GetPlayer().prefab == "webber" then owner.AnimState:SetBuild("webber") end owner:SetStateGraph("SGwilson") owner.AnimState:PlayAnimation("idle") owner.Transform:SetScale(1,1,1) local shadow = owner.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) owner.AnimState:SetBloomEffectHandle("") owner.Light:Enable(false) owner.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED owner.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED owner.components.health:SetInvincible(false) owner.components.hunger:Resume() owner.components.sanity.ignore = false owner.components.combat:SetDefaultDamage(TUNING.UNARMED_DAMAGE) owner.components.combat.hiteffectsymbol = "torso" owner:RemoveComponent("aura") owner.components.temperature:SetTemp(nil) owner.components.playercontroller:Enable(true) ghostheart:Remove() end ) end ) ghostheart.components.equippable.equipslot = EQUIPSLOTS.HANDS ghostheart:AddTag("ghostheart") GetPlayer().components.inventory:GiveItem(ghostheart) end inst:AddComponent("combat") inst.components.combat:SetDefaultDamage(3) inst.components.combat:SetAttackPeriod(1) inst.components.combat:SetRetargetFunction(2, function(inst) if not inst.components.health:IsDead() then return FindEntity(inst, 25, function(guy) if guy:HasTag("monster") then return guy end 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 end ) end end ) inst:ListenForEvent("attacked", function(inst, data) inst.components.combat:SetTarget(data.attacker) inst.components.combat:ShareTarget(data.attacker, 35, function(dude) return dude:HasTag("ghostnpcs") and not dude.components.health:IsDead() end, 5) end ) inst:AddComponent("aura") inst.components.aura.radius = 2 inst.components.aura.tickperiod = 1 inst.components.aura.ignoreallies = true inst.components.aura.auratestfn = function(inst, target) if target:HasTag("ghostnpcs") then return false end if target.components.combat.target == inst or inst.components.combat.target == target then return true end end inst:ListenForEvent("death", function() local gems = {"purplegem","bluegem","redgem","orangegem","yellowgem","greengem","thulecite","goldnugget"} local gem = gems[math.random(#gems)] SpawnPrefab(gem).Transform:SetPosition(inst.Transform:GetWorldPosition()) end ) inst:ListenForEvent( "daytime", function() inst:Remove() end , GetWorld()) end if data and data.ghostheart then inst.AnimState:SetBank("egg") inst.AnimState:SetBuild("tallbird_egg") inst.AnimState:PlayAnimation("cooked") inst.components.inventoryitem:ChangeImageName("tallbirdegg_cooked") inst:RemoveComponent("edible") inst:RemoveTag("meat") inst:AddComponent("equippable") inst.components.equippable:SetOnEquip( function(inst, owner) if owner == GetPlayer() and not GetPlayer():HasTag("poisoning") and not GetPlayer():HasTag("fever") then owner.components.locomotor:Stop() owner.components.playercontroller:Enable(false) owner:DoTaskInTime(0.3, function() SpawnPrefab("collapse_big").Transform:SetPosition(owner.Transform:GetWorldPosition()) owner.AnimState:SetBank("ghost") owner.AnimState:SetBuild("ghost_build") owner:SetStateGraph("SGghost") owner.AnimState:PlayAnimation("idle", true) owner.Transform:SetScale(1.2,1.2,1.2) local shadow = owner.entity:AddDynamicShadow() shadow:SetSize( 0, 0 ) owner.AnimState:SetBloomEffectHandle("shaders/anim.ksh") local light = owner.entity:AddLight() light:SetIntensity(.6) light:SetRadius(20) light:SetFalloff(.6) light:Enable(true) light:SetColour(180/255, 195/255, 225/255) owner.components.locomotor.walkspeed = 20 owner.components.locomotor.runspeed = 20 owner.components.health:DoDelta(owner.components.health.maxhealth) owner.components.health:SetInvincible(true) owner.components.hunger:DoDelta(owner.components.hunger.max) owner.components.hunger:Pause() owner.components.sanity:DoDelta(owner.components.sanity.max) owner.components.sanity.ignore = true owner.components.combat:SetDefaultDamage(1000) owner:AddComponent("aura") owner.components.aura.radius = 3 owner.components.aura.tickperiod = 0.5 owner.components.aura.ignoreallies = true owner.components.aura.auratestfn = function(ghostnpc, target) if target.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == target then return true end return false end owner.components.temperature:SetTemp(20) owner.components.playercontroller:Enable(true) end ) end end ) inst.components.equippable:SetOnUnequip( function(inst, owner) SpawnPrefab("collapse_big").Transform:SetPosition(owner.Transform:GetWorldPosition()) owner.components.locomotor:Stop() owner.components.playercontroller:Enable(false) owner:DoTaskInTime(0.3, function() owner.AnimState:SetBank("wilson") if GetPlayer().prefab == "wilson" then owner.AnimState:SetBuild("wilson") end if GetPlayer().prefab == "wendy" then owner.AnimState:SetBuild("wendy") end if GetPlayer().prefab == "wes" then owner.AnimState:SetBuild("wes") end if GetPlayer().prefab == "wickerbottom" then owner.AnimState:SetBuild("wickerbottom") end if GetPlayer().prefab == "willow" then owner.AnimState:SetBuild("willow") end if GetPlayer().prefab == "wolfgang" then owner.AnimState:SetBuild("wolfgang") end if GetPlayer().prefab == "wx78" then owner.AnimState:SetBuild("wx78") end if GetPlayer().prefab == "woodie" then owner.AnimState:SetBuild("woodie") end if GetPlayer().prefab == "waxwell" then owner.AnimState:SetBuild("waxwell") end if GetPlayer().prefab == "wathgrithr" then owner.AnimState:SetBuild("wathgrithr") end if GetPlayer().prefab == "webber" then owner.AnimState:SetBuild("webber") end owner:SetStateGraph("SGwilson") owner.AnimState:PlayAnimation("idle") owner.Transform:SetScale(1,1,1) local shadow = owner.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) owner.AnimState:SetBloomEffectHandle("") owner.Light:Enable(false) owner.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED owner.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED owner.components.health:SetInvincible(false) owner.components.hunger:Resume() owner.components.sanity.ignore = false owner.components.combat:SetDefaultDamage(TUNING.UNARMED_DAMAGE) owner.components.combat.hiteffectsymbol = "torso" owner:RemoveComponent("aura") owner.components.temperature:SetTemp(nil) owner.components.playercontroller:Enable(true) inst:Remove() end ) end ) inst.components.equippable.equipslot = EQUIPSLOTS.HANDS inst:AddTag("ghostheart") end end inst.OnSave = onsave inst.OnLoad = onload 即可在夜晚时,墓地有大量亡魂游荡,会主动攻击你,且靠近它们会降脑,消灭亡魂可获得宝石、铥矿石、黄金。亡魂在小地图上显示为白蜘蛛的图标。如果身上携带了噩梦燃料,亡魂就不会主动攻击你,给亡魂30个黄金(拿着黄金对亡魂点鼠标左键),可购买亡魂之心,装备它即可变身亡魂,生命、饥饿、脑全部锁死,按Ctrl + 鼠标左键攻击,且任何攻击你的敌人都会被自动烫死。卸载亡魂之心即可变回人,同时亡魂之心消失,想再变身就多买一些吧。如果修改了“小病小灾”,在主角感冒和食物中毒时,装备亡魂之心也不会变身

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二一七.角斗场(用铥矿石种角斗场,参与生死角斗赚奖金,也可观看比赛) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/thulecite.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local names = {"swap_goldenaxe","swap_spear","swap_spike","swap_batbat","swap_ruins_bat"} local weapon = names[math.random(#names)] local items = { SWORD = weapon } local function EquipItem(inst, item) if item then inst.AnimState:OverrideSymbol("swap_object", item, item) inst.AnimState:Show("ARM_carry") inst.AnimState:Hide("ARM_normal") end end inst.items = items inst.equipfn = EquipItem EquipItem(inst) local function fightgame(inst) local pt = inst:GetPosition() local gamehost = SpawnPrefab("thulecite") gamehost.Transform:SetPosition(pt.x, pt.y, pt.z) gamehost.AnimState:SetBank("wilson") gamehost.AnimState:SetBuild("wolfgang") gamehost.AnimState:OverrideSymbol("swap_hat", "hat_top", "swap_hat") gamehost.AnimState:Show("HAT") gamehost.AnimState:Show("HAT_HAIR") gamehost.AnimState:Hide("HAIR_NOHAT") gamehost.AnimState:Hide("HAIR") gamehost.AnimState:Hide("ARM_carry") gamehost.AnimState:Show("ARM_normal") gamehost.Transform:SetFourFaced() gamehost.AnimState:PlayAnimation("idle") gamehost:RemoveComponent("repairer") gamehost:RemoveComponent("edible") gamehost:RemoveComponent("tradable") gamehost:RemoveComponent("inventoryitem") gamehost:RemoveComponent("stackable") gamehost:RemoveComponent("deployable") gamehost:RemoveComponent("bait") gamehost:RemoveTag("molebait") gamehost:AddTag("gamehost") gamehost:AddComponent("workable") gamehost.components.workable:SetWorkAction(ACTIONS.HAMMER) gamehost.components.workable:SetWorkLeft(3) gamehost.components.workable:SetOnFinishCallback(function(gamehost) local pos = Vector3(gamehost.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 50) for k,v in pairs(ents) do if v:HasTag("candel") then SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") v:Remove() end end gamehost:Remove() end ) local fountain = SpawnPrefab("thulecite") fountain.Transform:SetPosition(pt.x-11, 0, pt.z-11) fountain.AnimState:SetBank("staff_purple_base") fountain.AnimState:SetBuild("staff_purple_base") fountain.AnimState:PlayAnimation("idle_full_loop") fountain.Transform:SetScale(1.5, 1.5, 1.5) fountain.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround ) fountain.AnimState:SetLayer( LAYER_BACKGROUND ) fountain.AnimState:SetSortOrder( 1 ) fountain.Transform:SetRotation( 45 ) fountain:AddTag("NOCLICK") fountain:RemoveComponent("repairer") fountain:RemoveComponent("edible") fountain:RemoveComponent("tradable") fountain:RemoveComponent("inventoryitem") fountain:RemoveComponent("stackable") fountain:RemoveComponent("deployable") fountain:RemoveComponent("bait") fountain:RemoveTag("molebait") local light = fountain.entity:AddLight() light:SetFalloff(1) light:SetIntensity(.8) light:SetRadius(18) light:SetColour(180/255, 195/255, 50/255) light:Enable(true) fountain:AddTag("candel") local pt0 = Vector3(fountain.Transform:GetWorldPosition()) for k = 1, 60 do local result_offset = FindValidPositionByFan(1 * 2 * PI, 12, 60, function(offset) local x,y,z = (pt0 + offset):Get() local ents = TheSim:FindEntities(x,y,z , 1) return not next(ents) end) if result_offset then local fence = SpawnPrefab("thulecite") fence.AnimState:SetBank("marble_pillar") fence.AnimState:SetBuild("marble_pillar") fence.AnimState:PlayAnimation("full") MakeObstaclePhysics(fence, 1) fence:RemoveComponent("repairer") fence:RemoveComponent("edible") fence:RemoveComponent("tradable") fence:RemoveComponent("inventoryitem") fence:RemoveComponent("stackable") fence:RemoveComponent("deployable") fence:RemoveComponent("bait") fence:RemoveTag("molebait") fence:AddTag("candel") fence.Transform:SetPosition((pt0 + result_offset):Get()) end end gamehost:AddComponent("trader") gamehost.components.trader:SetAcceptTest(function(gamehost, item) if not gamehost:HasTag("startgame") then if GetPlayer().components.inventory:Has("goldnugget", 100) then if item.prefab == "goldnugget" then return true end end end return false end ) gamehost.components.trader.onaccept = function(gamehost, giver, item) GetPlayer().components.inventory:ConsumeByName("goldnugget", 99) GetPlayer().components.locomotor:Stop() GetPlayer().Transform:SetPosition(pt.x-11+5, 0, pt.z-11-5) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/horn_beefalo") gamehost:AddTag("startgame") local warrior0 = SpawnPrefab("thulecite") warrior0.Transform:SetPosition(pt.x-11-5, 0, pt.z-11+5) warrior0.AnimState:SetBank("wilson") local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} local buildname = names[math.random(#names)] warrior0.AnimState:SetBuild(buildname) local hats = {"hat_beefalo","hat_feather","hat_football","hat_ruins","hat_slurper","hat_slurtle","hat_spider"} local hat = hats[math.random(#hats)] warrior0.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") local armors = {"armor_grass","armor_marble","armor_ruins","armor_sanity","armor_slurper","armor_wood"} local armor = armors[math.random(#armors)] warrior0.AnimState:OverrideSymbol("swap_body", armor, "swap_body") warrior0.AnimState:Show("HAT") warrior0.AnimState:Show("HAT_HAIR") warrior0.AnimState:Hide("HAIR_NOHAT") warrior0.AnimState:Hide("HAIR") warrior0.AnimState:Hide("ARM_carry") warrior0.AnimState:Show("ARM_normal") warrior0.AnimState:PlayAnimation("idle") warrior0.Transform:SetFourFaced() local sound = warrior0.entity:AddSoundEmitter() local shadow = warrior0.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) local brain = require "brains/frogbrain" warrior0:SetBrain(brain) warrior0:AddComponent("locomotor") warrior0.components.locomotor.walkspeed = 5 warrior0.components.locomotor.runspeed = 10 warrior0:SetStateGraph("SGshadowwaxwell") MakeCharacterPhysics(warrior0, 75, .5) warrior0:RemoveComponent("repairer") warrior0:RemoveComponent("edible") warrior0:RemoveComponent("tradable") warrior0:RemoveComponent("inventoryitem") warrior0:RemoveComponent("stackable") warrior0:RemoveComponent("deployable") warrior0:RemoveComponent("bait") warrior0:RemoveTag("molebait") warrior0:AddComponent("inventory") warrior0:AddComponent("knownlocations") warrior0:AddComponent("health") warrior0.components.health:SetMaxHealth(math.random(2500,5000)) warrior0:AddComponent("combat") warrior0.components.combat:SetDefaultDamage(math.random(25,50)) warrior0.components.combat:SetAttackPeriod(2) warrior0.components.combat:SetRetargetFunction(1, function(warrior0) if not warrior0.components.health:IsDead() then return FindEntity(warrior0, 30, function(guy) return guy:HasTag("player") end ) end end ) warrior0:DoPeriodicTask(1, function(warrior0) if not warrior0:HasTag("noplay") then if warrior0.components.health.currenthealth <= 100 then warrior0:AddTag("noplay") warrior0.components.combat:SetTarget(nil) warrior0.components.combat:SetRetargetFunction(100, nil ) end if GetPlayer().components.health.currenthealth <= 51 then warrior0.components.locomotor:Stop() warrior0:SetBrain(nil) warrior0:AddTag("noplay") warrior0.components.combat:SetTarget(nil) warrior0.components.combat:SetRetargetFunction(100, nil ) warrior0.components.health:SetInvincible(true) warrior0.AnimState:PlayAnimation("idle_onemanband1_loop",true) GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") gamehost:DoTaskInTime(3, function() warrior0:Remove() GetPlayer().components.locomotor:Stop() GetPlayer().Transform:SetPosition(pt.x-1, 0, pt.z+1) if gamehost.task then gamehost.task:Cancel() gamehost.task = nil end gamehost:RemoveTag("startgame") end ) end end end ) warrior0:ListenForEvent("death", function() GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") gamehost:DoTaskInTime(3, function() GetPlayer().components.locomotor:Stop() GetPlayer().Transform:SetPosition(pt.x-1, 0, pt.z+1) for k = 1, 200 do local goldnugget = SpawnPrefab("goldnugget") GetPlayer().components.inventory:GiveItem(goldnugget) end if gamehost.task then gamehost.task:Cancel() gamehost.task = nil end gamehost:RemoveTag("startgame") end ) end ) warrior0:AddTag("candel") gamehost.task = gamehost:DoPeriodicTask(1, function(gamehost) local target = FindEntity(fountain, 13, function(guy) return guy:HasTag("player") end ) if not target then GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") warrior0:Remove() if gamehost.task then gamehost.task:Cancel() gamehost.task = nil end gamehost:RemoveTag("startgame") end end ) end gamehost.components.inspectable.getstatus = function(gamehost) if not gamehost:HasTag("startgame") then if GetPlayer().components.inventory:Has("goldnugget", 20) then GetPlayer().components.inventory:ConsumeByName("goldnugget", 20) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/horn_beefalo") gamehost:AddTag("startgame") local warrior1 = SpawnPrefab("thulecite") warrior1.Transform:SetPosition(pt.x-11+5, 0, pt.z-11-5) warrior1.AnimState:SetBank("wilson") local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} local buildname = names[math.random(#names)] warrior1.AnimState:SetBuild(buildname) local hats = {"hat_beefalo","hat_feather","hat_football","hat_ruins","hat_slurper","hat_slurtle","hat_spider"} local hat = hats[math.random(#hats)] warrior1.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") local armors = {"armor_grass","armor_marble","armor_ruins","armor_sanity","armor_slurper","armor_wood"} local armor = armors[math.random(#armors)] warrior1.AnimState:OverrideSymbol("swap_body", armor, "swap_body") warrior1.AnimState:Show("HAT") warrior1.AnimState:Show("HAT_HAIR") warrior1.AnimState:Hide("HAIR_NOHAT") warrior1.AnimState:Hide("HAIR") warrior1.AnimState:Hide("ARM_carry") warrior1.AnimState:Show("ARM_normal") warrior1.AnimState:PlayAnimation("idle") warrior1.Transform:SetFourFaced() local sound = warrior1.entity:AddSoundEmitter() local shadow = warrior1.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) local brain = require "brains/frogbrain" warrior1:SetBrain(brain) warrior1:AddComponent("locomotor") warrior1.components.locomotor.walkspeed = 5 warrior1.components.locomotor.runspeed = 10 warrior1:SetStateGraph("SGshadowwaxwell") MakeCharacterPhysics(warrior1, 75, .5) warrior1:RemoveComponent("repairer") warrior1:RemoveComponent("edible") warrior1:RemoveComponent("tradable") warrior1:RemoveComponent("inventoryitem") warrior1:RemoveComponent("stackable") warrior1:RemoveComponent("deployable") warrior1:RemoveComponent("bait") warrior1:RemoveTag("molebait") warrior1:AddComponent("inventory") warrior1:AddComponent("knownlocations") warrior1:AddComponent("health") warrior1.components.health:SetMaxHealth(math.random(200,500)) warrior1:AddComponent("combat") warrior1.components.combat:SetDefaultDamage(math.random(25,100)) warrior1.components.combat:SetAttackPeriod(3) warrior1.components.combat:SetRetargetFunction(1, function(warrior1) if not warrior1.components.health:IsDead() then return FindEntity(warrior1, 30, function(guy) return guy:HasTag("warrior2") end ) end end ) warrior1:AddTag("warrior1") warrior1:AddTag("candel") local warrior2 = SpawnPrefab("thulecite") warrior2.Transform:SetPosition(pt.x-11-5, 0, pt.z-11+5) warrior2.AnimState:SetBank("wilson") local names = {"wilson","wendy","wes","wickerbottom","willow","wolfgang","wx78"} local buildname = names[math.random(#names)] warrior2.AnimState:SetBuild(buildname) local hats = {"hat_beefalo","hat_feather","hat_football","hat_ruins","hat_slurper","hat_slurtle","hat_spider"} local hat = hats[math.random(#hats)] warrior2.AnimState:OverrideSymbol("swap_hat", hat, "swap_hat") local armors = {"armor_grass","armor_marble","armor_ruins","armor_sanity","armor_slurper","armor_wood"} local armor = armors[math.random(#armors)] warrior2.AnimState:OverrideSymbol("swap_body", armor, "swap_body") warrior2.AnimState:Show("HAT") warrior2.AnimState:Show("HAT_HAIR") warrior2.AnimState:Hide("HAIR_NOHAT") warrior2.AnimState:Hide("HAIR") warrior2.AnimState:Hide("ARM_carry") warrior2.AnimState:Show("ARM_normal") warrior2.AnimState:PlayAnimation("idle") warrior2.Transform:SetFourFaced() local sound = warrior2.entity:AddSoundEmitter() local shadow = warrior2.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) local brain = require "brains/frogbrain" warrior2:SetBrain(brain) warrior2:AddComponent("locomotor") warrior2.components.locomotor.walkspeed = 5 warrior2.components.locomotor.runspeed = 10 warrior2:SetStateGraph("SGshadowwaxwell") MakeCharacterPhysics(warrior2, 75, .5) warrior2:RemoveComponent("repairer") warrior2:RemoveComponent("edible") warrior2:RemoveComponent("tradable") warrior2:RemoveComponent("inventoryitem") warrior2:RemoveComponent("stackable") warrior2:RemoveComponent("deployable") warrior2:RemoveComponent("bait") warrior2:RemoveTag("molebait") warrior2:AddComponent("inventory") warrior2:AddComponent("knownlocations") warrior2:AddComponent("health") warrior2.components.health:SetMaxHealth(math.random(200,500)) warrior2:AddComponent("combat") warrior2.components.combat:SetDefaultDamage(math.random(25,100)) warrior2.components.combat:SetAttackPeriod(3) warrior2.components.combat:SetRetargetFunction(1, function(warrior2) if not warrior2.components.health:IsDead() then return FindEntity(warrior2, 30, function(guy) return guy:HasTag("warrior1") end ) end end ) warrior2:AddTag("warrior2") warrior2:AddTag("candel") warrior1:DoPeriodicTask(1, function(warrior1) if not warrior1:HasTag("noplay") and not warrior2:HasTag("noplay") then if warrior1.components.health.currenthealth <= 100 then warrior1:AddTag("noplay") warrior1.components.combat:SetTarget(nil) warrior1.components.combat:SetRetargetFunction(100, nil ) end end end ) warrior2:DoPeriodicTask(1, function(warrior2) if not warrior2:HasTag("noplay") and not warrior1:HasTag("noplay") then if warrior2.components.health.currenthealth <= 100 then warrior2:AddTag("noplay") warrior2.components.combat:SetTarget(nil) warrior2.components.combat:SetRetargetFunction(100, nil ) end end end ) warrior1:ListenForEvent("death", function() GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") warrior2.components.locomotor:Stop() warrior2:SetBrain(nil) warrior2.AnimState:PlayAnimation("idle_onemanband1_loop",true) gamehost:DoTaskInTime(3, function() warrior2:Remove() gamehost:RemoveTag("startgame") end ) end ) warrior2:ListenForEvent("death", function() GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") warrior1.components.locomotor:Stop() warrior1:SetBrain(nil) warrior1.AnimState:PlayAnimation("idle_onemanband1_loop",true) gamehost:DoTaskInTime(3, function() warrior1:Remove() gamehost:RemoveTag("startgame") end ) end ) end end end end local function OnDeploy (inst, pt) fightgame(inst) inst.components.stackable:Get():Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("candel") then data.candel = true end if inst:HasTag("gamehost") then data.gamehost = true end end local function onload(inst, data) if data and data.candel then inst:Remove() end if data and data.gamehost then fightgame(inst) inst:Remove() end end inst.OnSave = onsave inst.OnLoad = onload 即可在开阔的空地上,用铥矿石种角斗场,(拿着1个铥矿石对地面点鼠标右键,如果拿着多个铥矿石,则不会种出来)。当身上有20个黄金时,鼠标左键点老板,可以观看一场角斗。如果想参加角斗,就给老板100个黄金(拿着黄金对老板点鼠标左键),你将进入角斗场与其他角斗士对战。如果击败对手,将获得本金加奖金共200个黄金;如果你的血量小于50,则判定你失败,对手会饶你不死,但本金将不会退回;如果你逃出围墙,同样判定你失败。每次与你对战的对手都不同,如果上一次失败,不代表下次不会胜利哦,作个职业的角斗士吧

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二一八.潘多拉魔盒(用硬骨头种潘多拉魔盒,每60秒有一批怪物来袭,展开塔防吧) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/boneshard.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function makemagicbox(inst) local pt = inst:GetPosition() local magicbox = SpawnPrefab("boneshard") magicbox.Transform:SetPosition(pt.x, pt.y, pt.z) magicbox.AnimState:SetBank("pandoras_chest") magicbox.AnimState:SetBuild("pandoras_chest") magicbox.AnimState:PlayAnimation("closed") magicbox.AnimState:SetMultColour(255/255,0/255,0/255,1) magicbox.Transform:SetScale(0.8, 0.8, 0.8) magicbox.AnimState:SetBloomEffectHandle("shaders/anim.ksh") local minimap = magicbox.entity:AddMiniMapEntity() minimap:SetIcon( "pandoras_chest.png" ) magicbox:RemoveComponent("inventoryitem") magicbox:RemoveComponent("stackable") magicbox:RemoveComponent("deployable") magicbox:AddTag("magicbox") magicbox:AddComponent("workable") magicbox.components.workable:SetWorkAction(ACTIONS.HAMMER) magicbox.components.workable:SetWorkLeft(3) magicbox.components.workable:SetOnFinishCallback(function(magicbox) local pos = Vector3(magicbox.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) for k,v in pairs(ents) do if v:HasTag("bogey") then SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition()) v:Remove() end end SpawnPrefab("collapse_big").Transform:SetPosition(magicbox.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/destroy_wood") magicbox:Remove() end ) magicbox.components.inspectable.getstatus = function(magicbox) if not magicbox:HasTag("makebogey") then magicbox:AddTag("makebogey") magicbox.AnimState:PlayAnimation("open") magicbox:DoTaskInTime(0.5, function(magicbox) SpawnPrefab("collapse_small").Transform:SetPosition(magicbox.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/horn_beefalo") GetPlayer().components.playercontroller:ShakeCamera(magicbox, "FULL", 2.5, 0.03, 2, 30) local pos = Vector3(magicbox.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) for k,v in pairs(ents) do if v:HasTag("bogey") then SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition()) v:Remove() end end local names = {"spiderqueen","hound","firehound","icehound","killerbee","walrus","leif","leif_sparse","koalefant_summer","koalefant_winter","deerclops","merm","knight","bishop","bat"} magicbox.name = names[math.random(#names)] for k = 1,math.random(10,30) do local pt0 = magicbox:GetPosition() local ground = GetWorld() local x = pt0.x+(math.random(50)-math.random(50)) local z = pt0.z+(math.random(50)-math.random(50)) local tile = ground.Map:GetTileAtPoint(x,0, z) if tile ~= GROUND.IMPASSABLE and tile ~= GROUND.INVALID then local bogey = SpawnPrefab(magicbox.name) bogey.Transform:SetPosition(x,0,z) bogey:AddTag("bogey") bogey.components.combat:SetRetargetFunction(1, function(bogey) if not bogey.components.health:IsDead() then return FindEntity(bogey, 100, function(guy) if guy.components.health and not guy.components.health:IsDead() then return guy:HasTag("player") end end ) end end ) bogey.components.combat:SetKeepTargetFunction(function(bogey, target) return target and target:IsValid() end ) bogey:ListenForEvent("attacked", function(bogey, data) bogey.components.combat:SetTarget(GetPlayer()) end ) end end end ) magicbox.task = magicbox:DoPeriodicTask(60, function(magicbox) SpawnPrefab("collapse_small").Transform:SetPosition(magicbox.Transform:GetWorldPosition()) GetPlayer().SoundEmitter:PlaySound("dontstarve/common/horn_beefalo") GetPlayer().components.playercontroller:ShakeCamera(magicbox, "FULL", 2.5, 0.03, 2, 30) local pos = Vector3(magicbox.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) for k,v in pairs(ents) do if v:HasTag("bogey") then SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition()) v:Remove() end end local names = {"spiderqueen","hound","firehound","icehound","killerbee","walrus","leif","leif_sparse","koalefant_summer","koalefant_winter","deerclops","merm","knight","bishop","bat"} magicbox.name = names[math.random(#names)] for k = 1,math.random(10,30) do local pt0 = magicbox:GetPosition() local ground = GetWorld() local x = pt0.x+(math.random(50)-math.random(50)) local z = pt0.z+(math.random(50)-math.random(50)) local tile = ground.Map:GetTileAtPoint(x,0, z) if tile ~= GROUND.IMPASSABLE and tile ~= GROUND.INVALID then local bogey = SpawnPrefab(magicbox.name) bogey.Transform:SetPosition(x,0,z) bogey:AddTag("bogey") bogey.components.combat:SetRetargetFunction(1, function(bogey) if not bogey.components.health:IsDead() then return FindEntity(bogey, 100, function(guy) if guy.components.health and not guy.components.health:IsDead() then return guy:HasTag("player") end end ) end end ) bogey.components.combat:SetKeepTargetFunction(function(bogey, target) return target and target:IsValid() end ) bogey:ListenForEvent("attacked", function(bogey, data) bogey.components.combat:SetTarget(GetPlayer()) end ) end end end ) else magicbox:RemoveTag("makebogey") magicbox.AnimState:PlayAnimation("close") GetPlayer().SoundEmitter:PlaySound("dontstarve/HUD/get_gold") if magicbox.task then magicbox.task:Cancel() magicbox.task = nil end local pos = Vector3(magicbox.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 3000) for k,v in pairs(ents) do if v:HasTag("bogey") then SpawnPrefab("collapse_big").Transform:SetPosition(v.Transform:GetWorldPosition()) v:Remove() end end end end end local function OnDeploy (inst, pt) makemagicbox(inst) inst.components.stackable:Get():Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("magicbox") then data.magicbox = true end end local function onload(inst, data) if data and data.magicbox then makemagicbox(inst) inst:Remove() end end inst.OnSave = onsave inst.OnLoad = onload 即可用硬骨头种潘多拉魔盒,(拿着1个硬骨头对地面点鼠标右键,如果拿着多个,则不会种出来)。鼠标左键点魔盒,可打开盒子,每60秒将吹响一次号角,预示着新一批怪物来袭,且源源不绝,充分满足你求死不得的需要。鼠标左键再次点击魔盒,可让怪物回到盒中。建议围绕魔盒修建防御设施(如牙齿陷阱、眼睛炮塔等),否则你挺不过几个60秒的。潘多拉魔盒在小地图上显示为远古箱子图标,不想要潘多拉魔盒了,用锤子砸掉即可。硬骨头靠砸碎地图上的骨架获得

2025/04/23 · Bny

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

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 二一九.铁血蛮族(蛮族霸占虫洞,打死可得肉类、装备,带瓦丝格雷斯帽不被攻击,用大肉收买蛮族做手下) 1.用MT管理器打开游戏目录/assets/scripts/prefabs/wormhole.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function createsavage(inst) for k = 1,math.random(10,15) do local pt = inst:GetPosition() local savage = SpawnPrefab("hammer") savage.Transform:SetPosition(pt.x+(math.random(30)-math.random(30)), 0, pt.z+(math.random(30)-math.random(30))) savage.AnimState:SetBank("wilson") savage.AnimState:SetBuild("wolfgang") savage.AnimState:OverrideSymbol("swap_hat", "hat_wathgrithr", "swap_hat") savage.AnimState:OverrideSymbol("swap_body", "torso_rain", "swap_body") savage.AnimState:OverrideSymbol("swap_object", "swap_spear_wathgrithr", "swap_spear_wathgrithr") savage.AnimState:Show("HAT") savage.AnimState:Show("HAT_HAIR") savage.AnimState:Hide("HAIR_NOHAT") savage.AnimState:Hide("HAIR") savage.AnimState:Hide("ARM_normal") savage.AnimState:Show("ARM_carry") savage.AnimState:PlayAnimation("idle") savage.Transform:SetScale(1.2, 1.2, 1.2) local sound = savage.entity:AddSoundEmitter() local shadow = savage.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) savage.Transform:SetFourFaced() MakeCharacterPhysics(savage, 100, .5) local minimap = savage.entity:AddMiniMapEntity() minimap:SetIcon( "wolfgang.png" ) savage:AddComponent("locomotor") savage.components.locomotor.walkspeed = 4 savage.components.locomotor.runspeed = 8 savage:SetStateGraph("SGshadowwaxwell") local brain = require "brains/leifbrain" savage:SetBrain(brain) savage:RemoveComponent("weapon") savage:RemoveComponent("tool") savage:RemoveComponent("finiteuses") savage:RemoveComponent("inventoryitem") savage:RemoveComponent("equippable") savage:RemoveTag("hammer") savage:AddComponent("inventory") savage:AddComponent("health") savage.components.health:SetMaxHealth(2000) savage:ListenForEvent("death", function() local pt1 = savage:GetPosition() for k = 1,math.random(5,10) do local meatnames = {"meat","smallmeat","drumstick"} local meatname = meatnames[math.random(#meatnames)] local meat = SpawnPrefab(meatname) meat.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) end if math.random() < 0.01 then local lootnames = {"spear_wathgrithr","wathgrithrhat"} local lootname = lootnames[math.random(#lootnames)] local loot = SpawnPrefab(lootname) loot.Transform:SetPosition(pt1.x, 0, pt1.z) end end ) savage:AddComponent("combat") savage.components.combat:SetDefaultDamage(30) savage.components.combat:SetAttackPeriod(1.5) savage.components.combat:SetRetargetFunction(3, function(savage) if not savage.components.health:IsDead() then return FindEntity(savage, 20, function(guy) return savage.components.combat:CanTarget(guy) and not guy:HasTag("savages") and not guy:HasTag("goodsavages") end ) end end ) savage.components.combat:SetKeepTargetFunction(function(savage, target) return target and target:IsValid() end ) savage:ListenForEvent("attacked", function(savage, data) savage.components.combat:SetTarget(data.attacker) 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) end ) savage.Physics:SetCollisionCallback(function(savage, other) if other and other.components.workable and other.components.workable.workleft > 0 then other.components.workable:Destroy(savage) end end) savage:ListenForEvent( "nighttime", function() savage:Remove() end , GetWorld()) savage:AddComponent("trader") savage.components.trader:SetAcceptTest(function(savage, item) if GetPlayer():HasTag("goodsavages") then if GetPlayer().components.inventory:Has("meat", 10) then if item.prefab == "meat" then return true end end end return false end ) savage.components.trader.onaccept = function(savage, giver, item) GetPlayer().components.inventory:ConsumeByName("meat", 9) savage:AddTag("mysavage") savage.AnimState:SetBloomEffectHandle("shaders/anim.ksh") savage:AddComponent("follower") savage.components.follower:SetLeader(GetPlayer()) local brain = require "brains/abigailbrain" savage:SetBrain(brain) savage:RestartBrain() savage.components.combat:SetAttackPeriod(1) savage.components.combat:SetRetargetFunction(1, function(savage) if not savage.components.health:IsDead() then return FindEntity(GetPlayer(), 20, function(guy) if guy.components.combat and guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") end end ) end end ) savage:RemoveAllEventCallbacks() savage:RemoveComponent("trader") savage:ListenForEvent( "daytime", function() savage.components.health:DoDelta(2000) end , GetWorld()) savage:ListenForEvent("attacked", function(savage, data) savage.components.combat:SetTarget(data.attacker) end ) savage.Physics:SetCollisionCallback( nil ) savage.components.inspectable.getstatus = function(savage) if not savage:HasTag("stophere") then savage:AddTag("stophere") savage.components.locomotor:Stop() savage:SetBrain(nil) savage.components.follower:SetLeader(nil) savage.AnimState:SetBloomEffectHandle("") else savage:RemoveTag("stophere") local brain = require "brains/abigailbrain" savage:SetBrain(brain) savage:RestartBrain() savage.components.follower:SetLeader(GetPlayer()) savage.AnimState:SetBloomEffectHandle("shaders/anim.ksh") end end end savage:AddTag("savages") end end inst:ListenForEvent( "daytime", function() createsavage(inst) end , GetWorld()) 2.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/hammer.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local items = { SWORD = "swap_spear_wathgrithr" } local function EquipItem(inst, item) if item then inst.AnimState:OverrideSymbol("swap_object", item, item) inst.AnimState:Show("ARM_carry") inst.AnimState:Hide("ARM_normal") end end inst.items = items inst.equipfn = EquipItem EquipItem(inst) local function onsave(inst, data) if inst:HasTag("savages") then data.savages = true end if inst:HasTag("mysavage") then data.mysavage = true end if inst:HasTag("stophere") then data.stophere = true end end local function onload(inst, data) if data and data.savages then inst.AnimState:SetBank("wilson") inst.AnimState:SetBuild("wolfgang") inst.AnimState:OverrideSymbol("swap_hat", "hat_wathgrithr", "swap_hat") inst.AnimState:OverrideSymbol("swap_body", "torso_rain", "swap_body") inst.AnimState:OverrideSymbol("swap_object", "swap_spear_wathgrithr", "swap_spear_wathgrithr") inst.AnimState:Show("HAT") inst.AnimState:Show("HAT_HAIR") inst.AnimState:Hide("HAIR_NOHAT") inst.AnimState:Hide("HAIR") inst.AnimState:Hide("ARM_normal") inst.AnimState:Show("ARM_carry") inst.AnimState:PlayAnimation("idle") inst.Transform:SetScale(1.2, 1.2, 1.2) local sound = inst.entity:AddSoundEmitter() local shadow = inst.entity:AddDynamicShadow() shadow:SetSize( 1.3, .6 ) inst.Transform:SetFourFaced() MakeCharacterPhysics(inst, 100, .5) local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon( "wolfgang.png" ) inst:AddComponent("locomotor") inst.components.locomotor.walkspeed = 4 inst.components.locomotor.runspeed = 8 inst:SetStateGraph("SGshadowwaxwell") local brain = require "brains/leifbrain" inst:SetBrain(brain) inst:RemoveComponent("weapon") inst:RemoveComponent("tool") inst:RemoveComponent("finiteuses") inst:RemoveComponent("inventoryitem") inst:RemoveComponent("equippable") inst:RemoveTag("hammer") inst:AddComponent("inventory") inst:AddComponent("health") inst.components.health:SetMaxHealth(2000) inst:ListenForEvent("death", function() local pt1 = inst:GetPosition() for k = 1,math.random(5,10) do local meatnames = {"meat","smallmeat","drumstick"} local meatname = meatnames[math.random(#meatnames)] local meat = SpawnPrefab(meatname) meat.Transform:SetPosition(pt1.x+(math.random(3)-math.random(3)), 0, pt1.z+(math.random(3)-math.random(3))) end if math.random() < 0.01 then local lootnames = {"spear_wathgrithr","wathgrithrhat"} local lootname = lootnames[math.random(#lootnames)] local loot = SpawnPrefab(lootname) loot.Transform:SetPosition(pt1.x, 0, pt1.z) end end ) inst:AddComponent("combat") inst.components.combat:SetDefaultDamage(30) inst.components.combat:SetAttackPeriod(1.5) inst.components.combat:SetRetargetFunction(3, function(inst) if not inst.components.health:IsDead() then return FindEntity(inst, 20, function(guy) return inst.components.combat:CanTarget(guy) and not guy:HasTag("savages") and not guy:HasTag("goodsavages") end ) end end ) inst.components.combat:SetKeepTargetFunction(function(inst, target) return target and target:IsValid() end ) inst:ListenForEvent("attacked", function(inst, data) inst.components.combat:SetTarget(data.attacker) inst.components.combat:ShareTarget(data.attacker, 30, function(dude) return dude:HasTag("savages") and not dude:HasTag("mysavage") and not dude.components.health:IsDead() end, 5) end ) inst.Physics:SetCollisionCallback(function(inst, other) if other and other.components.workable and other.components.workable.workleft > 0 then other.components.workable:Destroy(inst) end end) inst:ListenForEvent( "nighttime", function() inst:Remove() end , GetWorld()) inst:AddComponent("trader") inst.components.trader:SetAcceptTest(function(inst, item) if GetPlayer():HasTag("goodsavages") then if GetPlayer().components.inventory:Has("meat", 10) then if item.prefab == "meat" then return true end end end return false end ) inst.components.trader.onaccept = function(inst, giver, item) GetPlayer().components.inventory:ConsumeByName("meat", 9) inst:AddTag("mysavage") inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") inst:AddComponent("follower") inst.components.follower:SetLeader(GetPlayer()) local brain = require "brains/abigailbrain" inst:SetBrain(brain) inst:RestartBrain() inst.components.combat:SetAttackPeriod(1) inst.components.combat:SetRetargetFunction(1, function(inst) if not inst.components.health:IsDead() then return FindEntity(GetPlayer(), 20, function(guy) if guy.components.combat and guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") end end ) end end ) inst:RemoveAllEventCallbacks() inst:RemoveComponent("trader") inst:ListenForEvent( "daytime", function() inst.components.health:DoDelta(2000) end , GetWorld()) inst:ListenForEvent("attacked", function(inst, data) inst.components.combat:SetTarget(data.attacker) end ) inst.Physics:SetCollisionCallback( nil ) inst.components.inspectable.getstatus = function(inst) if not inst:HasTag("stophere") then inst:AddTag("stophere") inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.follower:SetLeader(nil) inst.AnimState:SetBloomEffectHandle("") else inst:RemoveTag("stophere") local brain = require "brains/abigailbrain" inst:SetBrain(brain) inst:RestartBrain() inst.components.follower:SetLeader(GetPlayer()) inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") end end end inst:AddTag("savages") end if data and data.mysavage then inst:AddTag("mysavage") inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") inst:AddComponent("follower") inst.components.follower:SetLeader(GetPlayer()) local brain = require "brains/abigailbrain" inst:SetBrain(brain) inst:RestartBrain() inst.components.combat:SetAttackPeriod(1) inst.components.combat:SetRetargetFunction(1, function(inst) if not inst.components.health:IsDead() then return FindEntity(GetPlayer(), 20, function(guy) if guy.components.combat and guy.components.health and not guy.components.health:IsDead() then return guy.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == guy or guy:HasTag("monster") end end ) end end ) inst:RemoveAllEventCallbacks() inst:RemoveComponent("trader") inst:ListenForEvent( "daytime", function() inst.components.health:DoDelta(2000) end , GetWorld()) inst:ListenForEvent("attacked", function(inst, data) inst.components.combat:SetTarget(data.attacker) end ) inst.Physics:SetCollisionCallback( nil ) inst.components.inspectable.getstatus = function(inst) if not inst:HasTag("stophere") then inst:AddTag("stophere") inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.follower:SetLeader(nil) inst.AnimState:SetBloomEffectHandle("") else inst:RemoveTag("stophere") local brain = require "brains/abigailbrain" inst:SetBrain(brain) inst:RestartBrain() inst.components.follower:SetLeader(GetPlayer()) inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") end end end if data and data.stophere then inst:AddTag("stophere") inst.components.locomotor:Stop() inst:SetBrain(nil) inst.components.follower:SetLeader(nil) inst.AnimState:SetBloomEffectHandle("") end end inst.OnSave = onsave inst.OnLoad = onload 3.用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/hats.lua文件,在inst.components.armor:InitCondition(TUNING.ARMOR_WATHGRITHRHAT, TUNING.ARMOR_WATHGRITHRHAT_ABSORPTION)的下一行插入以下内容: inst.components.equippable:SetOnEquip(function(inst, owner) onequip(inst, owner) if owner == GetPlayer() then owner:AddTag("goodsavages") end end ) inst.components.equippable:SetOnUnequip(function(inst, owner) onunequip(inst, owner) owner:RemoveTag("goodsavages") end ) 即可有蛮族霸占虫洞附近的区域,白天和傍晚活动,黑夜消失。他们会攻击一切生物,拆毁建筑,通过小地图可查询蛮族所在位置,显示为沃尔夫冈图标。与蛮族对战时,他们会围攻你,打死蛮族可获得他们携带的肉类,还有一定概率获得瓦丝格雷斯帽和瓦丝格雷斯矛。装备瓦丝格雷斯帽,将被蛮族视为同类,从而免受攻击,并可以用10个大肉收买蛮族作手下(拿着大肉对蛮族点鼠标左键)。蛮族手下不会破坏建筑,无论受多重的伤,每天清晨都会恢复健康,鼠标左键点击(不要拿武器)蛮族手下可让其停留在原地,再次点击可继续跟随。从此开启与铁血蛮族共处的时代,作他们望而生畏的敌人,或带领他们征霸天下吧

2025/04/23 · Bny

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

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

2025/04/23 · Bny

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

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

2025/04/23 · Bny