代码来源于“易宁”大佬的分享,仅供学习,不要直接复制粘贴。
原帖链接:http://bbs.3dmgame.com/thread-3859071-1-1.html
一七五.霸王斧(用蜻蜓鳞片种霸王斧,攻击敌人时震开并伤害周围敌人,可吸敌人的血) 用MT管理器打开游戏目录/assets/DLC0002/scripts/prefabs/dragon_scales.lua文件,在inst:AddComponent("inspectable")的下一行插入以下内容: local function OnDeploy (inst, pt) local bigaxe = SpawnPrefab("dragon_scales") bigaxe.Transform:SetPosition(pt.x, pt.y, pt.z) bigaxe.AnimState:SetBank("Lucy_axe") bigaxe.AnimState:SetBuild("Lucy_axe") bigaxe.AnimState:PlayAnimation("idle") bigaxe.components.inventoryitem:ChangeImageName("lucy") bigaxe:AddComponent("named") bigaxe.components.named:SetName("Poleaxe") bigaxe:RemoveComponent("stackable") bigaxe:RemoveComponent("deployable") bigaxe:AddComponent("equippable") bigaxe.components.equippable.equipslot = EQUIPSLOTS.HANDS bigaxe.components.equippable:SetOnEquip(function(bigaxe, owner) owner.AnimState:OverrideSymbol("swap_object", "swap_lucy_axe", "swap_lucy_axe") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") bigaxe.fire = SpawnPrefab( "campfirefire" ) local follower = bigaxe.fire.entity:AddFollower() follower:FollowSymbol( owner.GUID, "swap_object", -2, -135, 1 ) bigaxe.fire.AnimState:SetMultColour(255/255,0/255,0/255,1) bigaxe.fire:RemoveComponent("heater") bigaxe.fire.persists = false end ) bigaxe.components.equippable:SetOnUnequip(function(bigaxe, owner) owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") bigaxe.fire:Remove() bigaxe.fire = nil end ) bigaxe:AddComponent("weapon") bigaxe.components.weapon:SetDamage(500) bigaxe.components.weapon:SetOnAttack(function(bigaxe, attacker, target) GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") SpawnPrefab("groundpoundring_fx").Transform:SetPosition(attacker.Transform:GetWorldPosition()) GetPlayer().components.playercontroller:ShakeCamera(attacker, "FULL", 0.5, 0.05, 2, 40) if target.components.locomotor then target.components.locomotor:Stop() end if target.components.health:GetPercent() < 0.3 then target.AnimState:SetMultColour(255/255,0/255,0/255,1) end attacker.components.health:DoDelta(150) attacker:StartThread(function() for k = 1, 3 do local blood = SpawnPrefab("splash") blood.Transform:SetPosition(target.Transform:GetWorldPosition()) blood.AnimState:SetMultColour(255/255,0/255,0/255,1) blood.Transform:SetScale(2, 2, 2) Sleep(.1) end end ) target:AddTag("nomove") target:DoTaskInTime(0.4, function() target:RemoveTag("nomove") end ) local pos = Vector3(attacker.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 8) for k,v in pairs(ents) do if v.components.health and v.components.combat and not v.components.health:IsDead() and not v:HasTag("nomove") then if v.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == v or v:HasTag("monster") then SpawnPrefab("explode_small").Transform:SetPosition(v.Transform:GetWorldPosition()) v.components.health:DoDelta(-300) local pt01 = attacker:GetPosition() local pt02 = v:GetPosition() v.Transform:SetPosition((pt02.x-pt01.x)*1.5+pt02.x, 0, (pt02.z-pt01.z)*1.5+pt02.z) if v.components.locomotor then v.components.locomotor:Stop() end if v.components.health:GetPercent() < 0.3 then v.AnimState:SetMultColour(255/255,0/255,0/255,1) end end end end end ) bigaxe:AddComponent("tool") bigaxe.components.tool:SetAction(ACTIONS.CHOP, 15) bigaxe:AddTag("bigaxes") inst.components.stackable:Get():Remove() end inst:AddComponent("deployable") inst.components.deployable.ondeploy = OnDeploy local function onsave(inst, data) if inst:HasTag("bigaxes") then data.bigaxes = true end end local function onload(inst, data) if data and data.bigaxes then inst.AnimState:SetBank("Lucy_axe") inst.AnimState:SetBuild("Lucy_axe") inst.AnimState:PlayAnimation("idle") inst.components.inventoryitem:ChangeImageName("lucy") inst:AddComponent("named") inst.components.named:SetName("Poleaxe") inst:RemoveComponent("stackable") inst:RemoveComponent("deployable") inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.HANDS inst.components.equippable:SetOnEquip(function(inst, owner) owner.AnimState:OverrideSymbol("swap_object", "swap_lucy_axe", "swap_lucy_axe") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") inst.fire = SpawnPrefab( "campfirefire" ) local follower = inst.fire.entity:AddFollower() follower:FollowSymbol( owner.GUID, "swap_object", -2, -135, 1 ) inst.fire.AnimState:SetMultColour(255/255,0/255,0/255,1) inst.fire:RemoveComponent("heater") inst.fire.persists = false end ) inst.components.equippable:SetOnUnequip(function(inst, owner) owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") inst.fire:Remove() inst.fire = nil end ) inst:AddComponent("weapon") inst.components.weapon:SetDamage(500) inst.components.weapon:SetOnAttack(function(inst, attacker, target) GetPlayer().SoundEmitter:PlaySound("dontstarve_DLC001/creatures/glommer/foot_ground") SpawnPrefab("groundpoundring_fx").Transform:SetPosition(attacker.Transform:GetWorldPosition()) GetPlayer().components.playercontroller:ShakeCamera(attacker, "FULL", 0.5, 0.05, 2, 40) if target.components.locomotor then target.components.locomotor:Stop() end if target.components.health:GetPercent() < 0.3 then target.AnimState:SetMultColour(255/255,0/255,0/255,1) end attacker.components.health:DoDelta(150) attacker:StartThread(function() for k = 1, 3 do local blood = SpawnPrefab("splash") blood.Transform:SetPosition(target.Transform:GetWorldPosition()) blood.AnimState:SetMultColour(255/255,0/255,0/255,1) blood.Transform:SetScale(2, 2, 2) Sleep(.1) end end ) target:AddTag("nomove") target:DoTaskInTime(0.4, function() target:RemoveTag("nomove") end ) local pos = Vector3(attacker.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 8) for k,v in pairs(ents) do if v.components.health and v.components.combat and not v.components.health:IsDead() and not v:HasTag("nomove") then if v.components.combat.target == GetPlayer() or GetPlayer().components.combat.target == v or v:HasTag("monster") then SpawnPrefab("explode_small").Transform:SetPosition(v.Transform:GetWorldPosition()) v.components.health:DoDelta(-300) local pt01 = attacker:GetPosition() local pt02 = v:GetPosition() v.Transform:SetPosition((pt02.x-pt01.x)*1.5+pt02.x, 0, (pt02.z-pt01.z)*1.5+pt02.z) if v.components.locomotor then v.components.locomotor:Stop() end if v.components.health:GetPercent() < 0.3 then v.AnimState:SetMultColour(255/255,0/255,0/255,1) end end end end end ) inst:AddComponent("tool") inst.components.tool:SetAction(ACTIONS.CHOP, 15) inst:AddTag("bigaxes") end end inst.OnSave = onsave inst.OnLoad = onload 即可用蜻蜓鳞片种霸王斧,装备霸王斧攻击时,自动会吸取敌人的血,补充主角生命值,同时震开并伤害周围的敌人(区域攻击),减少你被围殴的机会。霸王斧用来砍树也极其锋利,一斧便可砍倒一棵。蜻蜓鳞片靠打蜻蜓获得,也可在“巨型超市”花9-11个黄金购得