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

YN172-溜溜球(用陷阱种溜溜球,连续打击多个目标,打完自动回到手中)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一七二.溜溜球(用陷阱种溜溜球,连续打击多个目标,打完自动回到手中) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/trap.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local colours= 7{ 8 {198/255,43/255,43/255}, 9 {79/255,153/255,68/255}, 10 {35/255,105/255,235/255}, 11 {233/255,208/255,69/255}, 12 {109/255,50/255,163/255}, 13 {222/255,126/255,39/255}, 14} 15local function OnDeploy (inst, pt) 16 local ball = SpawnPrefab("trap") 17 ball.Transform:SetPosition(pt.x, pt.y, pt.z) 18 ball.AnimState:SetBank("bulb") 19 ball.AnimState:SetBuild("bulb") 20 ball.AnimState:PlayAnimation("idle") 21 ball.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 22 ball:ClearStateGraph() 23 RemovePhysicsColliders(ball) 24 ball.components.inventoryitem:ChangeImageName("lightbulb") 25 ball.colour_idx = math.random(#colours) 26 ball.AnimState:SetMultColour(colours[ball.colour_idx][1],colours[ball.colour_idx][2],colours[ball.colour_idx][3],1) 27 ball:RemoveComponent("finiteuses") 28 ball:RemoveComponent("trap") 29 ball:RemoveComponent("deployable") 30 ball:RemoveTag("trap") 31 ball:AddComponent("weapon") 32 ball.components.weapon:SetDamage(30) 33 ball.components.weapon:SetRange(20, 25) 34 ball:AddComponent("equippable") 35 ball.components.equippable.equipslot = EQUIPSLOTS.HANDS 36 ball.components.equippable:SetOnEquip(function(ball) 37 ball.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") 38 end ) 39 ball:AddComponent("projectile") 40 ball.components.projectile:SetSpeed(25) 41 ball.components.projectile:SetOnHitFn(function(ball, owner, target) 42 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") 43 local target0 = FindEntity(owner, 25, function(guy) 44 if guy.components.combat and guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("player") then 45 return guy.components.combat.target == owner or owner.components.combat.target == guy or guy:HasTag("monster") 46 end 47 end ) 48 if target0 then 49 ball.components.projectile:Throw(owner, target0) 50 else 51 owner.components.inventory:Equip(ball) 52 end 53 end ) 54 ball.components.projectile:SetOnMissFn(function(ball, owner) 55 owner.components.inventory:Equip(ball) 56 end ) 57 ball:ListenForEvent("onthrown", function(ball) 58 local pt = ball:GetPosition() 59 ball.Transform:SetPosition(pt.x, 2, pt.z) 60 ball.SoundEmitter:PlaySound("dontstarve/wilson/boomerang_throw") 61 end ) 62 ball:AddComponent("workable") 63 ball.components.workable:SetWorkAction(ACTIONS.HAMMER) 64 ball.components.workable:SetWorkLeft(3) 65 ball.components.workable:SetOnFinishCallback(function(ball) 66 SpawnPrefab("ground_chunks_breaking").Transform:SetPosition(ball.Transform:GetWorldPosition()) 67 ball:Remove() 68 end ) 69 ball:AddTag("projectile") 70 ball:AddTag("balls") 71 inst:Remove() 72end 73 inst:AddComponent("deployable") 74 inst.components.deployable.ondeploy = OnDeploy 75local function onsave(inst, data) 76 if inst:HasTag("balls") then 77 data.balls = true 78 end 79 data.colour_idx = inst.colour_idx 80end 81local function onload(inst, data) 82 if data and data.balls then 83 inst.AnimState:SetBank("bulb") 84 inst.AnimState:SetBuild("bulb") 85 inst.AnimState:PlayAnimation("idle") 86 inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 87 inst:ClearStateGraph() 88 RemovePhysicsColliders(inst) 89 inst.components.inventoryitem:ChangeImageName("lightbulb") 90 inst:RemoveComponent("finiteuses") 91 inst:RemoveComponent("trap") 92 inst:RemoveComponent("deployable") 93 inst:RemoveTag("trap") 94 inst:AddComponent("weapon") 95 inst.components.weapon:SetDamage(30) 96 inst.components.weapon:SetRange(20, 25) 97 inst:AddComponent("equippable") 98 inst.components.equippable.equipslot = EQUIPSLOTS.HANDS 99 inst.components.equippable:SetOnEquip(function(inst) 100 inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") 101 end ) 102 inst:AddComponent("projectile") 103 inst.components.projectile:SetSpeed(25) 104 inst.components.projectile:SetOnHitFn(function(inst, owner, target) 105 GetPlayer().SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold") 106 local target0 = FindEntity(owner, 25, function(guy) 107 if guy.components.combat and guy.components.health and not guy.components.health:IsDead() and not guy:HasTag("player") then 108 return guy.components.combat.target == owner or owner.components.combat.target == guy or guy:HasTag("monster") 109 end 110 end ) 111 if target0 then 112 inst.components.projectile:Throw(owner, target0) 113 else 114 owner.components.inventory:Equip(inst) 115 end 116 end ) 117 inst.components.projectile:SetOnMissFn(function(inst, owner) 118 owner.components.inventory:Equip(inst) 119 end ) 120 inst:ListenForEvent("onthrown", function(inst) 121 local pt = inst:GetPosition() 122 inst.Transform:SetPosition(pt.x, 2, pt.z) 123 inst.SoundEmitter:PlaySound("dontstarve/wilson/boomerang_throw") 124 end ) 125 inst:AddComponent("workable") 126 inst.components.workable:SetWorkAction(ACTIONS.HAMMER) 127 inst.components.workable:SetWorkLeft(3) 128 inst.components.workable:SetOnFinishCallback(function(inst) 129 SpawnPrefab("ground_chunks_breaking").Transform:SetPosition(inst.Transform:GetWorldPosition()) 130 inst:Remove() 131 end ) 132 inst:AddTag("projectile") 133 inst:AddTag("balls") 134 end 135 if data and data.colour_idx then 136 inst.colour_idx = math.min(#colours, data.colour_idx) 137 inst.AnimState:SetMultColour(colours[inst.colour_idx][1],colours[inst.colour_idx][2],colours[inst.colour_idx][3],1) 138 end 139end 140 inst.OnSave = onsave 141 inst.OnLoad = onload 142 143 即可用陷阱种溜溜球(颜色随机),装备后对敌人按鼠标左键,可以扔出并连续打击附近所有敌人,消灭敌人后自动回到手中,完美代替回旋镖。不想要溜溜球时,用锤子砸掉即可。陷阱在生存选项(画着绳套)下,用2个树枝、6个草制造

2025/04/23 · Bny

YN173-千斤锤(用火腿短棍攻击时,天降巨石将敌人拍扁)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一七三.千斤锤(用火腿短棍攻击时,天降巨石将敌人拍扁) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/hambat.lua文件,将inst:AddComponent("weapon")替换为以下内容: 5 6local function onattack(inst, owner, target) 7 local pt = target:GetPosition() 8 local boulder = SpawnPrefab("thulecite") 9 RemovePhysicsColliders(boulder) 10 boulder.AnimState:SetBloomEffectHandle("shaders/anim.ksh") 11 boulder.Transform:SetScale(3,3,3) 12 boulder:RemoveComponent("inventoryitem") 13 boulder.Transform:SetPosition(pt.x, 10, pt.z) 14 boulder.falling = boulder:DoPeriodicTask(.01, function() boulder.Physics:SetMotorVelOverride(0,-55,0) end) 15 boulder:DoTaskInTime(0.1, function() 16 if boulder.falling then boulder.falling:Cancel() boulder.falling = nil end 17 GetPlayer().SoundEmitter:PlaySound("dontstarve/creatures/eyeballturret/shotexplo") 18 GetPlayer().components.playercontroller:ShakeCamera(boulder, "FULL", 0.5, 0.05, 2, 40) 19 SpawnPrefab("collapse_big").Transform:SetPosition(boulder.Transform:GetWorldPosition()) 20 target:AddTag("NOCLICK") 21 MakeInventoryPhysics(target) 22 target.AnimState:SetOrientation( ANIM_ORIENTATION.OnGround ) 23 target.AnimState:SetLayer( LAYER_BACKGROUND ) 24 target.AnimState:SetSortOrder( 1 ) 25 target.AnimState:SetPercent("hit", math.random()) 26 if target.brain then target:SetBrain(nil) end 27 if target.components.locomotor then target.components.locomotor:Stop() end 28 if target.components.combat then target.components.combat:SetTarget(nil) end 29 if target.components.health then target.components.health:SetInvincible(false) end 30 target:DoTaskInTime(5, function() target.components.health:Kill() end ) 31 local pos = Vector3(boulder.Transform:GetWorldPosition()) 32 local ents = TheSim:FindEntities(pos.x,0,pos.z, 5) 33 for k,v in pairs(ents) do 34 if v.components.workable and v.components.workable.workleft > 0 and not v.components.inventoryitem then 35 v.components.workable:Destroy(boulder) 36 end 37 end 38 boulder:DoTaskInTime(0.5, function() 39 GetPlayer().SoundEmitter:PlaySound("dontstarve/common/stone_drop") 40 SpawnPrefab("ground_chunks_breaking").Transform:SetPosition(boulder.Transform:GetWorldPosition()) 41 boulder:Remove() 42 end ) 43 end ) 44end 45 inst:AddComponent("weapon") 46 inst.components.weapon:SetRange(20, 25) 47 inst.components.weapon:SetOnAttack(onattack) 48 49 即可在用火腿短棍攻击时,天降巨石将敌人拍扁,并震毁附近的建筑、石头、植物,敌人将在5秒后死亡。火腿短棍在战斗选项(画着两把剑)下,用1个猪皮、2个树枝、2个大肉制造

2025/04/23 · Bny

YN174-霸王枪(瓦丝格雷斯矛升级为霸王枪,鼠标左键远距离突刺并撤回,右键挑飞敌人,敌人会喷血)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一七四.霸王枪(瓦丝格雷斯矛升级为霸王枪,鼠标左键远距离突刺并撤回,右键挑飞敌人,敌人会喷血) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/spear_wathgrithr.lua文件, 5 6 1.在local function onequip(inst, owner)的下一行插入以下内容: 7 8 inst.fire = SpawnPrefab( "campfirefire" ) 9 local follower = inst.fire.entity:AddFollower() 10 follower:FollowSymbol( owner.GUID, "swap_object", 20, -88, 1 ) 11 inst.fire.AnimState:SetMultColour(255/255,0/255,0/255,1) 12 inst.fire.Transform:SetScale(0.8, 0.8, 0.8) 13 inst.fire:RemoveComponent("heater") 14 inst.fire.persists = false 15 16 17 2.在local function onunequip(inst, owner)的下一行插入以下内容: 18 19 inst.fire:Remove() 20 inst.fire = nil 21 22 23 3.将下列内容: 24 25 inst:AddComponent("weapon") 26 inst.components.weapon:SetDamage(TUNING.WATHGRITHR_SPEAR_DAMAGE) 27 28 ------- 29 30 inst:AddComponent("finiteuses") 31 inst.components.finiteuses:SetMaxUses(TUNING.WATHGRITHR_SPEAR_USES) 32 inst.components.finiteuses:SetUses(TUNING.WATHGRITHR_SPEAR_USES) 33 34 inst.components.finiteuses:SetOnFinished( onfinished ) 35 36 替换为: 37 38local function canattack(inst, target) 39 if TheInput:IsMouseDown(MOUSEBUTTON_RIGHT) then 40 GetPlayer().AnimState:PlayAnimation("atk") 41 SpawnPrefab("groundpoundring_fx").Transform:SetPosition(GetPlayer().Transform:GetWorldPosition()) 42 SpawnPrefab("explode_small").Transform:SetPosition(target.Transform:GetWorldPosition()) 43 GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") 44 local pt01 = GetPlayer():GetPosition() 45 local pt02 = target:GetPosition() 46 target.Transform:SetPosition((pt02.x-pt01.x)*0.5+pt02.x, 0, (pt02.z-pt01.z)*0.5+pt02.z) 47 local blood = SpawnPrefab("splash") 48 blood.Transform:SetPosition(target.Transform:GetWorldPosition()) 49 blood.AnimState:SetMultColour(255/255,0/255,0/255,1) 50 blood.Transform:SetScale(2, 2, 2) 51 if target.components.locomotor then target.components.locomotor:Stop() end 52 if target.components.combat then target.components.combat:SetTarget(GetPlayer()) end 53 if target.components.health then 54 target.components.health:DoDelta(-100) 55 if target.components.health:GetPercent() < 0.3 then 56 target.AnimState:SetMultColour(255/255,0/255,0/255,1) 57 end 58 end 59 end 60 return true 61end 62local function onattack(inst, attacker, target) 63 local pt1 = attacker:GetPosition() 64 local pt2 = target:GetPosition() 65 GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") 66 attacker:DoTaskInTime(0.01, function() 67 attacker.Transform:SetPosition(pt2.x, pt2.y, pt2.z) 68 SpawnPrefab("explode_small").Transform:SetPosition(target.Transform:GetWorldPosition()) 69 SpawnPrefab("groundpoundring_fx").Transform:SetPosition(target.Transform:GetWorldPosition()) 70 if target.components.locomotor then target.components.locomotor:Stop() end 71 attacker:StartThread(function() 72 for k = 1, 3 do 73 local blood = SpawnPrefab("splash") 74 blood.Transform:SetPosition(pt2.x, 1.5, pt2.z) 75 blood.AnimState:SetMultColour(255/255,0/255,0/255,1) 76 blood.Transform:SetScale(2, 2, 2) 77 Sleep(.1) 78 end 79 end ) 80 if target.components.health and target.components.health:GetPercent() < 0.3 then 81 target.AnimState:SetMultColour(255/255,0/255,0/255,1) 82 end 83 end ) 84 attacker:DoTaskInTime(0.3, function() 85 attacker.Transform:SetPosition(pt1.x, pt1.y, pt1.z) 86 end ) 87end 88 inst:AddComponent("weapon") 89 inst.components.weapon:SetDamage(300) 90 inst.components.weapon:SetRange(15, 20) 91 inst.components.weapon:SetOnAttack(onattack) 92 inst.components.weapon:SetCanAttack(canattack) 93 94 即可让瓦丝格雷斯矛升级为霸王枪,装备霸王枪,鼠标左键点敌人(按住可连续攻击),会远距离突刺敌人,刺中后迅速撤回原位,不给敌人还击的机会。鼠标右键点敌人,可将敌人挑飞,按住右键扫过一群敌人,可防止被围攻。使用霸王枪时,敌人会喷血,场面极其惨烈,如果你是儿童,请捂住眼睛使用。瓦丝格雷斯矛可修改“全人物可制造瓦丝格雷斯矛、瓦丝格雷斯帽”获得

2025/04/23 · Bny

YN175-霸王斧(用蜻蜓鳞片种霸王斧,攻击敌人时震开并伤害周围敌人,可吸敌人的血)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一七五.霸王斧(用蜻蜓鳞片种霸王斧,攻击敌人时震开并伤害周围敌人,可吸敌人的血) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/dragon_scales.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function OnDeploy (inst, pt) 7 local bigaxe = SpawnPrefab("dragon_scales") 8 bigaxe.Transform:SetPosition(pt.x, pt.y, pt.z) 9 bigaxe.AnimState:SetBank("Lucy_axe") 10 bigaxe.AnimState:SetBuild("Lucy_axe") 11 bigaxe.AnimState:PlayAnimation("idle") 12 bigaxe.components.inventoryitem:ChangeImageName("lucy") 13 bigaxe:AddComponent("named") 14 bigaxe.components.named:SetName("Poleaxe") 15 bigaxe:RemoveComponent("stackable") 16 bigaxe:RemoveComponent("deployable") 17 bigaxe:AddComponent("equippable") 18 bigaxe.components.equippable.equipslot = EQUIPSLOTS.HANDS 19 bigaxe.components.equippable:SetOnEquip(function(bigaxe, owner) 20 owner.AnimState:OverrideSymbol("swap_object", "swap_lucy_axe", "swap_lucy_axe") 21 owner.AnimState:Show("ARM_carry") 22 owner.AnimState:Hide("ARM_normal") 23 bigaxe.fire = SpawnPrefab( "campfirefire" ) 24 local follower = bigaxe.fire.entity:AddFollower() 25 follower:FollowSymbol( owner.GUID, "swap_object", -2, -135, 1 ) 26 bigaxe.fire.AnimState:SetMultColour(255/255,0/255,0/255,1) 27 bigaxe.fire:RemoveComponent("heater") 28 bigaxe.fire.persists = false 29 end ) 30 bigaxe.components.equippable:SetOnUnequip(function(bigaxe, owner) 31 owner.AnimState:Hide("ARM_carry") 32 owner.AnimState:Show("ARM_normal") 33 bigaxe.fire:Remove() 34 bigaxe.fire = nil 35 end ) 36 bigaxe:AddComponent("weapon") 37 bigaxe.components.weapon:SetDamage(500) 38 bigaxe.components.weapon:SetOnAttack(function(bigaxe, attacker, target) 39 GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") 40 SpawnPrefab("groundpoundring_fx").Transform:SetPosition(attacker.Transform:GetWorldPosition()) 41 GetPlayer().components.playercontroller:ShakeCamera(attacker, "FULL", 0.5, 0.05, 2, 40) 42 if target.components.locomotor then target.components.locomotor:Stop() end 43 if target.components.health:GetPercent() < 0.3 then 44 target.AnimState:SetMultColour(255/255,0/255,0/255,1) 45 end 46 attacker.components.health:DoDelta(150) 47 attacker:StartThread(function() 48 for k = 1, 3 do 49 local blood = SpawnPrefab("splash") 50 blood.Transform:SetPosition(target.Transform:GetWorldPosition()) 51 blood.AnimState:SetMultColour(255/255,0/255,0/255,1) 52 blood.Transform:SetScale(2, 2, 2) 53 Sleep(.1) 54 end 55 end ) 56 target:AddTag("nomove") 57 target:DoTaskInTime(0.4, function() target:RemoveTag("nomove") end ) 58 local pos = Vector3(attacker.Transform:GetWorldPosition()) 59 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 8) 60 for k,v in pairs(ents) do 61 if v.components.health and v.components.combat and not v.components.health:IsDead() and not v:HasTag("nomove") then 62 if v.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == v or v:HasTag("monster") then 63 SpawnPrefab("explode_small").Transform:SetPosition(v.Transform:GetWorldPosition()) 64 v.components.health:DoDelta(-300) 65 local pt01 = attacker:GetPosition() 66 local pt02 = v:GetPosition() 67 v.Transform:SetPosition((pt02.x-pt01.x)*1.5+pt02.x, 0, (pt02.z-pt01.z)*1.5+pt02.z) 68 if v.components.locomotor then v.components.locomotor:Stop() end 69 if v.components.health:GetPercent() < 0.3 then 70 v.AnimState:SetMultColour(255/255,0/255,0/255,1) 71 end 72 end 73 end 74 end 75 end ) 76 bigaxe:AddComponent("tool") 77 bigaxe.components.tool:SetAction(ACTIONS.CHOP, 15) 78 bigaxe:AddTag("bigaxes") 79 inst.components.stackable:Get():Remove() 80end 81 inst:AddComponent("deployable") 82 inst.components.deployable.ondeploy = OnDeploy 83local function onsave(inst, data) 84 if inst:HasTag("bigaxes") then 85 data.bigaxes = true 86 end 87end 88local function onload(inst, data) 89 if data and data.bigaxes then 90 inst.AnimState:SetBank("Lucy_axe") 91 inst.AnimState:SetBuild("Lucy_axe") 92 inst.AnimState:PlayAnimation("idle") 93 inst.components.inventoryitem:ChangeImageName("lucy") 94 inst:AddComponent("named") 95 inst.components.named:SetName("Poleaxe") 96 inst:RemoveComponent("stackable") 97 inst:RemoveComponent("deployable") 98 inst:AddComponent("equippable") 99 inst.components.equippable.equipslot = EQUIPSLOTS.HANDS 100 inst.components.equippable:SetOnEquip(function(inst, owner) 101 owner.AnimState:OverrideSymbol("swap_object", "swap_lucy_axe", "swap_lucy_axe") 102 owner.AnimState:Show("ARM_carry") 103 owner.AnimState:Hide("ARM_normal") 104 inst.fire = SpawnPrefab( "campfirefire" ) 105 local follower = inst.fire.entity:AddFollower() 106 follower:FollowSymbol( owner.GUID, "swap_object", -2, -135, 1 ) 107 inst.fire.AnimState:SetMultColour(255/255,0/255,0/255,1) 108 inst.fire:RemoveComponent("heater") 109 inst.fire.persists = false 110 end ) 111 inst.components.equippable:SetOnUnequip(function(inst, owner) 112 owner.AnimState:Hide("ARM_carry") 113 owner.AnimState:Show("ARM_normal") 114 inst.fire:Remove() 115 inst.fire = nil 116 end ) 117 inst:AddComponent("weapon") 118 inst.components.weapon:SetDamage(500) 119 inst.components.weapon:SetOnAttack(function(inst, attacker, target) 120 GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") 121 SpawnPrefab("groundpoundring_fx").Transform:SetPosition(attacker.Transform:GetWorldPosition()) 122 GetPlayer().components.playercontroller:ShakeCamera(attacker, "FULL", 0.5, 0.05, 2, 40) 123 if target.components.locomotor then target.components.locomotor:Stop() end 124 if target.components.health:GetPercent() < 0.3 then 125 target.AnimState:SetMultColour(255/255,0/255,0/255,1) 126 end 127 attacker.components.health:DoDelta(150) 128 attacker:StartThread(function() 129 for k = 1, 3 do 130 local blood = SpawnPrefab("splash") 131 blood.Transform:SetPosition(target.Transform:GetWorldPosition()) 132 blood.AnimState:SetMultColour(255/255,0/255,0/255,1) 133 blood.Transform:SetScale(2, 2, 2) 134 Sleep(.1) 135 end 136 end ) 137 target:AddTag("nomove") 138 target:DoTaskInTime(0.4, function() target:RemoveTag("nomove") end ) 139 local pos = Vector3(attacker.Transform:GetWorldPosition()) 140 local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 8) 141 for k,v in pairs(ents) do 142 if v.components.health and v.components.combat and not v.components.health:IsDead() and not v:HasTag("nomove") then 143 if v.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == v or v:HasTag("monster") then 144 SpawnPrefab("explode_small").Transform:SetPosition(v.Transform:GetWorldPosition()) 145 v.components.health:DoDelta(-300) 146 local pt01 = attacker:GetPosition() 147 local pt02 = v:GetPosition() 148 v.Transform:SetPosition((pt02.x-pt01.x)*1.5+pt02.x, 0, (pt02.z-pt01.z)*1.5+pt02.z) 149 if v.components.locomotor then v.components.locomotor:Stop() end 150 if v.components.health:GetPercent() < 0.3 then 151 v.AnimState:SetMultColour(255/255,0/255,0/255,1) 152 end 153 end 154 end 155 end 156 end ) 157 inst:AddComponent("tool") 158 inst.components.tool:SetAction(ACTIONS.CHOP, 15) 159 inst:AddTag("bigaxes") 160 end 161end 162 inst.OnSave = onsave 163 inst.OnLoad = onload 164 165 即可用蜻蜓鳞片种霸王斧,装备霸王斧攻击时,自动会吸取敌人的血,补充主角生命值,同时震开并伤害周围的敌人(区域攻击),减少你被围殴的机会。霸王斧用来砍树也极其锋利,一斧便可砍倒一棵。蜻蜓鳞片靠打蜻蜓获得,也可在“巨型超市”花9-11个黄金购得

2025/04/23 · Bny

YN176-霸王盔(用猪皮种霸王盔,吸收99%伤害,挨打时弹开并反伤敌人,可照明、防雨、防冻、防暑、补脑、奔跑加速)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一七六.霸王盔(用猪皮种霸王盔,吸收99%伤害,挨打时弹开并反伤敌人,可照明、防雨、防冻、防暑、补脑、奔跑加速) 3 4 用MT管理器打开游戏目录/assets/scripts/prefabs/pigskin.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function OnDeploy (inst, pt) 7 local helmet = SpawnPrefab("pigskin") 8 helmet.Transform:SetPosition(pt.x, pt.y, pt.z) 9 helmet.AnimState:SetBank("wathgrithrhat") 10 helmet.AnimState:SetBuild("hat_wathgrithr") 11 helmet.AnimState:PlayAnimation("anim") 12 helmet.components.inventoryitem:ChangeImageName("wathgrithrhat") 13 helmet:RemoveComponent("stackable") 14 helmet:RemoveComponent("tradable") 15 helmet:RemoveComponent("edible") 16 helmet:RemoveComponent("burnable") 17 helmet:RemoveComponent("propagator") 18 helmet:RemoveComponent("deployable") 19 helmet:AddComponent("equippable") 20 helmet.components.equippable.equipslot = EQUIPSLOTS.HEAD 21 helmet.components.equippable.walkspeedmult = 2.5 22 helmet.components.equippable.dapperness = TUNING.DAPPERNESS_HUGE*32 23 helmet.components.equippable:SetOnEquip(function(helmet, owner) 24 owner.AnimState:OverrideSymbol("swap_hat", "hat_wathgrithr", "swap_hat") 25 owner.AnimState:Show("HAT") 26 owner.AnimState:Show("HAT_HAIR") 27 owner.AnimState:Hide("HAIR_NOHAT") 28 owner.AnimState:Hide("HAIR") 29 if owner == GetPlayer() then 30 owner.AnimState:Hide("HEAD") 31 owner.AnimState:Show("HEAD_HAIR") 32 owner.components.temperature:SetTemp(20) 33 owner:PushEvent("stopfreezing") 34 owner:PushEvent("stopoverheating") 35 owner.components.moisture:SetMoistureLevel(0) 36 helmet.fire = SpawnPrefab( "campfirefire" ) 37 local follower = helmet.fire.entity:AddFollower() 38 follower:FollowSymbol( owner.GUID, "swap_hat", -6, -196, 0 ) 39 helmet.fire.AnimState:SetMultColour(255/255,0/255,0/255,1) 40 helmet.fire.Transform:SetScale(1.3, 1.3, 1.3) 41 helmet.fire:RemoveComponent("heater") 42 helmet.fire.persists = false 43 helmet.helmetfn = function(attacked, data) 44 if data and data.attacker and data.attacker.components.health then 45 SpawnPrefab("groundpoundring_fx").Transform:SetPosition(owner.Transform:GetWorldPosition()) 46 data.attacker.components.health:DoDelta(-300) 47 local pt01 = owner:GetPosition() 48 local pt02 = data.attacker:GetPosition() 49 data.attacker.Transform:SetPosition((pt02.x-pt01.x)*1.5+pt02.x, 0, (pt02.z-pt01.z)*1.5+pt02.z) 50 if data.attacker.components.locomotor then data.attacker.components.locomotor:Stop() end 51 if data.attacker.components.health:GetPercent() < 0.3 then 52 data.attacker.AnimState:SetMultColour(255/255,0/255,0/255,1) 53 end 54 end 55 end 56 helmet:ListenForEvent("attacked", helmet.helmetfn, owner) 57 owner:AddTag("goodsavages") 58 end 59 end ) 60 helmet.components.equippable:SetOnUnequip(function(helmet, owner) 61 owner.AnimState:Hide("HAT") 62 owner.AnimState:Hide("HAT_HAIR") 63 owner.AnimState:Show("HAIR_NOHAT") 64 owner.AnimState:Show("HAIR") 65 if owner == GetPlayer() then 66 owner.AnimState:Show("HEAD") 67 owner.AnimState:Hide("HEAD_HAIR") 68 owner.components.temperature:SetTemp(nil) 69 helmet.fire:Remove() 70 helmet.fire = nil 71 helmet:RemoveEventCallback("attacked", helmet.helmetfn, owner) 72 owner:RemoveTag("goodsavages") 73 end 74 75 end ) 76 helmet:AddComponent("armor") 77 helmet.components.armor:InitCondition(20000, 0.99) 78 helmet:AddComponent("waterproofer") 79 helmet.components.waterproofer:SetEffectiveness(1) 80 helmet:AddTag("helmets") 81 inst.components.stackable:Get():Remove() 82end 83 inst:AddComponent("deployable") 84 inst.components.deployable.ondeploy = OnDeploy 85local function onsave(inst, data) 86 if inst:HasTag("helmets") then 87 data.helmets = true 88 end 89end 90local function onload(inst, data) 91 if data and data.helmets then 92 inst.AnimState:SetBank("wathgrithrhat") 93 inst.AnimState:SetBuild("hat_wathgrithr") 94 inst.AnimState:PlayAnimation("anim") 95 inst.components.inventoryitem:ChangeImageName("wathgrithrhat") 96 inst:RemoveComponent("stackable") 97 inst:RemoveComponent("tradable") 98 inst:RemoveComponent("edible") 99 inst:RemoveComponent("burnable") 100 inst:RemoveComponent("propagator") 101 inst:RemoveComponent("deployable") 102 inst:AddComponent("equippable") 103 inst.components.equippable.equipslot = EQUIPSLOTS.HEAD 104 inst.components.equippable.walkspeedmult = 2.5 105 inst.components.equippable.dapperness = TUNING.DAPPERNESS_HUGE*32 106 inst.components.equippable:SetOnEquip(function(inst, owner) 107 owner.AnimState:OverrideSymbol("swap_hat", "hat_wathgrithr", "swap_hat") 108 owner.AnimState:Show("HAT") 109 owner.AnimState:Show("HAT_HAIR") 110 owner.AnimState:Hide("HAIR_NOHAT") 111 owner.AnimState:Hide("HAIR") 112 if owner == GetPlayer() then 113 owner.AnimState:Hide("HEAD") 114 owner.AnimState:Show("HEAD_HAIR") 115 owner.components.temperature:SetTemp(20) 116 owner:PushEvent("stopfreezing") 117 owner:PushEvent("stopoverheating") 118 owner.components.moisture:SetMoistureLevel(0) 119 inst.fire = SpawnPrefab( "campfirefire" ) 120 local follower = inst.fire.entity:AddFollower() 121 follower:FollowSymbol( owner.GUID, "swap_hat", -6, -196, 0 ) 122 inst.fire.AnimState:SetMultColour(255/255,0/255,0/255,1) 123 inst.fire.Transform:SetScale(1.3, 1.3, 1.3) 124 inst.fire:RemoveComponent("heater") 125 inst.fire.persists = false 126 inst.helmetfn = function(attacked, data) 127 if data and data.attacker and data.attacker.components.health then 128 SpawnPrefab("groundpoundring_fx").Transform:SetPosition(owner.Transform:GetWorldPosition()) 129 data.attacker.components.health:DoDelta(-300) 130 local pt01 = owner:GetPosition() 131 local pt02 = data.attacker:GetPosition() 132 data.attacker.Transform:SetPosition((pt02.x-pt01.x)*1.5+pt02.x, 0, (pt02.z-pt01.z)*1.5+pt02.z) 133 if data.attacker.components.locomotor then data.attacker.components.locomotor:Stop() end 134 if data.attacker.components.health:GetPercent() < 0.3 then 135 data.attacker.AnimState:SetMultColour(255/255,0/255,0/255,1) 136 end 137 end 138 end 139 inst:ListenForEvent("attacked", inst.helmetfn, owner) 140 owner:AddTag("goodsavages") 141 end 142 end ) 143 inst.components.equippable:SetOnUnequip(function(inst, owner) 144 owner.AnimState:Hide("HAT") 145 owner.AnimState:Hide("HAT_HAIR") 146 owner.AnimState:Show("HAIR_NOHAT") 147 owner.AnimState:Show("HAIR") 148 if owner == GetPlayer() then 149 owner.AnimState:Show("HEAD") 150 owner.AnimState:Hide("HEAD_HAIR") 151 owner.components.temperature:SetTemp(nil) 152 inst.fire:Remove() 153 inst.fire = nil 154 inst:RemoveEventCallback("attacked", inst.helmetfn, owner) 155 owner:RemoveTag("goodsavages") 156 end 157 158 end ) 159 inst:AddComponent("armor") 160 inst.components.armor:InitCondition(20000, 0.99) 161 inst:AddComponent("waterproofer") 162 inst.components.waterproofer:SetEffectiveness(1) 163 inst:AddTag("helmets") 164 end 165end 166 inst.OnSave = onsave 167 inst.OnLoad = onload 168 169 即可用猪皮种霸王盔,吸收99%伤害,敌人攻击你时会被弹开,并遭到反伤,让你流的每一滴血,都收到百倍利息。霸王盔可照明、防雨、防冻、防暑、补脑,并使奔跑加速,与“霸王枪”并称饥荒世界两大神器,助你在乱世中百战百胜。佩戴霸王盔时,“铁血蛮族”不敢主动攻击你。不要与“用猪皮种猪火炬”一同修改

2025/04/23 · Bny

YN177-活捉手杖(装备龙卷风魔杖,鼠标左键点鸟、鼹鼠等小动物,可远程活捉)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一七七.活捉手杖(装备龙卷风魔杖,鼠标左键点鸟、鼹鼠等小动物,可远程活捉) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/staff_tornado.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6local function canattack(inst, target) 7 if target.prefab == "bee" or target.prefab == "killerbee" or target.prefab == "crow" or target.prefab == "robin" or target.prefab == "robin_winter" or target.prefab == "butterfly" or target.prefab == "mole" or target.prefab == "mosquito" or target.prefab == "rabbit" then 8 return true 9 end 10 return false 11end 12local function onattack(inst, attacker, target) 13 if target.prefab == "bee" then 14 local prey = SpawnPrefab("bee") 15 GetPlayer().components.inventory:GiveItem(prey) 16 end 17 if target.prefab == "killerbee" then 18 local prey = SpawnPrefab("killerbee") 19 GetPlayer().components.inventory:GiveItem(prey) 20 end 21 if target.prefab == "crow" then 22 local prey = SpawnPrefab("crow") 23 GetPlayer().components.inventory:GiveItem(prey) 24 end 25 if target.prefab == "robin" then 26 local prey = SpawnPrefab("robin") 27 GetPlayer().components.inventory:GiveItem(prey) 28 end 29 if target.prefab == "robin_winter" then 30 local prey = SpawnPrefab("robin_winter") 31 GetPlayer().components.inventory:GiveItem(prey) 32 end 33 if target.prefab == "butterfly" then 34 local prey = SpawnPrefab("butterfly") 35 GetPlayer().components.inventory:GiveItem(prey) 36 end 37 if target.prefab == "mole" then 38 local prey = SpawnPrefab("mole") 39 GetPlayer().components.inventory:GiveItem(prey) 40 end 41 if target.prefab == "mosquito" then 42 local prey = SpawnPrefab("mosquito") 43 GetPlayer().components.inventory:GiveItem(prey) 44 end 45 if target.prefab == "rabbit" then 46 local prey = SpawnPrefab("rabbit") 47 GetPlayer().components.inventory:GiveItem(prey) 48 end 49 target:Remove() 50end 51 inst:AddComponent("weapon") 52 inst.components.weapon:SetDamage(0) 53 inst.components.weapon:SetRange(25, 30) 54 inst.components.weapon:SetOnAttack(onattack) 55 inst.components.weapon:SetCanAttack(canattack) 56 inst.components.weapon:SetProjectile("bishop_charge") 57 58 即可将龙卷风魔杖升级为活捉手杖,装备活捉手杖,鼠标左键点小动物,可远距离活捉它们。可活捉的小动物包括蜜蜂、杀人蜂、鸟、蝴蝶、鼹鼠、蚊子、兔子。龙卷风魔杖右键召唤龙卷风的功能保留。龙卷风魔杖在战斗选项下,用10个鹿鸭羽毛、1个闪电羊角、1个齿轮制造

2025/04/23 · Bny

YN178-巨人帽(带猪皮帽变巨人,攻击、防御上升,可撞毁建筑、树、石头)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一七八.巨人帽(带猪皮帽变巨人,攻击、防御上升,可撞毁建筑、树、石头) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/hats.lua文件,将下列内容: 5 6 local function football() 7 local inst = simple() 8 inst:AddComponent("armor") 9 10 inst:AddComponent("waterproofer") 11 inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_SMALL) 12 13 inst.components.armor:InitCondition(TUNING.ARMOR_FOOTBALLHAT, TUNING.ARMOR_FOOTBALLHAT_ABSORPTION) 14 return inst 15 end 16 17 替换为: 18 19local function football_equip(inst, owner) 20 onequip(inst, owner) 21 if owner == GetPlayer() then 22 owner.Transform:SetScale(3, 3, 3) 23 owner.components.combat:SetDefaultDamage(500) 24 owner.Physics:SetCollisionCallback(function(owner, other) 25 if other and other.components.workable and other.components.workable.workleft > 0 then 26 other.components.workable:Destroy(owner) 27 end 28 end) 29 end 30end 31local function football_unequip(inst, owner) 32 onunequip(inst, owner) 33 if owner == GetPlayer() then 34 owner.Transform:SetScale(1, 1, 1) 35 owner.components.combat:SetDefaultDamage(TUNING.UNARMED_DAMAGE) 36 owner.Physics:SetCollisionCallback( nil ) 37 end 38end 39local function football() 40 local inst = simple() 41 inst:AddComponent("armor") 42 inst.components.armor:InitCondition(TUNING.ARMOR_FOOTBALLHAT, 0.95) 43 inst:AddComponent("waterproofer") 44 inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_SMALL) 45 inst.components.equippable:SetOnEquip( football_equip ) 46 inst.components.equippable:SetOnUnequip( football_unequip ) 47 return inst 48end 49 50 即可戴猪皮帽变巨人,空手攻击力达到500点(空手按Ctrl + 鼠标左键攻击,或按住F反击),防御敌人95%的伤害(只掉5%的血),可撞毁建筑、树、石头。猪皮帽在战斗选项(画着两把剑)下,用1个绳子、1个猪皮制造,制造时须靠近炼金术引擎

2025/04/23 · Bny

YN179-防弹背包(装备背包吸收99%伤害值)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一七九.防弹背包(装备背包吸收99%伤害值) 3 4 1.普通背包作盔甲:用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/backpack.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 5 6 inst:AddComponent("armor") 7 inst.components.armor:InitCondition(TUNING.ARMORMARBLE, 0.99) 8 9 10 2.小猪包作盔甲:用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/piggyback.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 11 12 inst:AddComponent("armor") 13 inst.components.armor:InitCondition(TUNING.ARMORMARBLE, 0.99) 14 15 16 3.坎普斯背包作盔甲:用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/krampus_sack.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 17 18 inst:AddComponent("armor") 19 inst.components.armor:InitCondition(TUNING.ARMORMARBLE, 0.99) 20 21 22 4.冰包作盔甲:用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/icepack.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: 23 24 inst:AddComponent("armor") 25 inst.components.armor:InitCondition(TUNING.ARMORMARBLE, 0.99) 26 27 28 5.盔甲永固:用MT管理器打开游戏目录/assets/scripts/components/armor.lua文件,将下列内容: 29 30function Armor:SetCondition(amount) 31 self.condition = amount 32 33 替换为: 34 35function Armor:SetCondition(amount) 36 self.condition = self.maxcondition 37 38 即可装备背包就拥有盔甲防护作用,且99%吸收伤害值,还无限使用哦

2025/04/23 · Bny

YN180-芦苇吹出催眠曲(在携带的芦苇上按鼠标右键,可催眠怪物)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一八0.芦苇吹出催眠曲(在携带的芦苇上按鼠标右键,可催眠怪物) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/cutreeds.lua文件,在inst:AddComponent("inventoryitem")的下一行插入以下内容: 5 6 inst:AddTag("flute") 7local function HearPanFlute(inst, musician, instrument) 8 if inst.components.sleeper then 9 inst.components.sleeper:AddSleepiness(10, TUNING.PANFLUTE_SLEEPTIME*1) 10 end 11end 12 inst:AddComponent("tool") 13 inst.components.tool:SetAction(ACTIONS.PLAY) 14 inst:AddComponent("instrument") 15 inst.components.instrument.range = TUNING.PANFLUTE_SLEEPRANGE*2 16 inst.components.instrument:SetOnHeardFn(HearPanFlute) 17 18 即可在携带的芦苇上按鼠标右键,可催眠一片怪物。其中*1为催眠时间20秒,想催眠60秒就*3即可。其中*2为催眠范围30格,想扩大至60格就*4即可

2025/04/23 · Bny

YN181-隐身背心(穿小巧背心可隐身)

代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。 原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html 1 2一八一.隐身背心(穿小巧背心可隐身) 3 4 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/sweatervest.lua文件,将下列内容: 5 6local function onequip(inst, owner) 7 owner.AnimState:OverrideSymbol("swap_body", "armor_sweatervest", "swap_body") 8 inst.components.fueled:StartConsuming() 9end 10 11local function onunequip(inst, owner) 12 owner.AnimState:ClearOverrideSymbol("swap_body") 13 inst.components.fueled:StopConsuming() 14end 15 16 替换为: 17 18local function onequip(inst, owner) 19 owner.AnimState:OverrideSymbol("swap_body", "armor_sweatervest", "swap_body") 20 inst.components.equippable.walkspeedmult = TUNING.CANE_SPEED_MULT*2 21 owner:Hide() 22 local shadow = GetPlayer().entity:AddDynamicShadow() 23 shadow:SetSize( 0, 0 ) 24end 25local function onunequip(inst, owner) 26 owner.AnimState:ClearOverrideSymbol("swap_body") 27 owner:Show() 28 local shadow = GetPlayer().entity:AddDynamicShadow() 29 shadow:SetSize( 1.3, .6 ) 30end 31 32 即可穿上小巧背心隐身,你可以攻击敌人,敌人找不到你,连鸟、兔子都可以直接攻击哦。小巧背心在穿戴选项(画着礼帽)下,用8个犬牙、6个蛛丝制造

2025/04/23 · Bny