local assets=
{
	Asset("ANIM", "anim/mushasword_frost.zip"),
    	Asset("ATLAS", "images/inventoryimages/mushasword_frost.xml"),
	Asset("IMAGE", "images/inventoryimages/mushasword_frost.tex"),

	Asset("ANIM", "anim/swap_mushasword_base.zip"),
	Asset("ANIM", "anim/swap_mushasword_frost1.zip"),
	Asset("ANIM", "anim/swap_mushasword_frost2.zip"),
	Asset("ANIM", "anim/swap_mushasword_frost3.zip"),

}
---------------------------
local function levelexp(inst,data)

	local max_exp = 4100
	local exp = math.min(inst.level, max_exp)

if inst.level <= 4000 then
inst.components.talker:Say("-[冰霜剑]-\n[成长点数]".. (inst.level))
inst:RemoveTag("levelup")
end
if inst.level >=0 and inst.level <10 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[10]\n[成长点数]".. (inst.level))
inst:AddTag("level1")
elseif inst.level >=10 and inst.level <30 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[30]\n[成长点数]".. (inst.level))
inst:AddTag("level2")
inst:RemoveTag("level1")
elseif inst.level >=30 and inst.level <50 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[50]\n[成长点数]".. (inst.level))
inst:AddTag("level3")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
elseif inst.level >=50 and inst.level <70 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[70]\n[成长点数]".. (inst.level))
inst:AddTag("level4")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
elseif inst.level >=70 and inst.level <90 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[90]\n[成长点数]".. (inst.level))
inst:AddTag("level5")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
elseif inst.level >=90 and inst.level <120 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[120]\n[成长点数]".. (inst.level))
inst:AddTag("level6")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
elseif inst.level >=120 and inst.level <150 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[150]\n[成长点数]".. (inst.level))
inst:AddTag("level7")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
elseif inst.level >=150 and inst.level <180 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[180]\n[成长点数]".. (inst.level))
inst:AddTag("level8")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
elseif inst.level >=180 and inst.level <210 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[210]\n[成长点数]".. (inst.level))
inst:AddTag("level9")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
elseif inst.level >=210 and inst.level <250 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[250]\n[成长点数]".. (inst.level))
inst:AddTag("level10")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
elseif inst.level >=250 and inst.level <350 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[350]\n[成长点数]".. (inst.level))
inst:AddTag("level11")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
elseif inst.level >=350 and inst.level <450 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[450]\n[成长点数]".. (inst.level))
inst:AddTag("level12")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
elseif inst.level >=450 and inst.level <550 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[550]\n[成长点数]".. (inst.level))
inst:AddTag("level13")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
elseif inst.level >=550 and inst.level <650 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[650]\n[成长点数]".. (inst.level))
inst:AddTag("level14")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
elseif inst.level >=650 and inst.level <750 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[750]\n[成长点数]".. (inst.level))
inst:AddTag("level15")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
elseif inst.level >=750 and inst.level <850 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[850]\n[成长点数]".. (inst.level))
inst:AddTag("level16")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
elseif inst.level >=850 and inst.level <950 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[950]\n[成长点数]".. (inst.level))
inst:AddTag("level17")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
elseif inst.level >=950 and inst.level <1050 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[1050]\n[成长点数]".. (inst.level))
inst:AddTag("level18")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
elseif inst.level >=1050 and inst.level <1200 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[1200]\n[成长点数]".. (inst.level))
inst:AddTag("level19")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
elseif inst.level >=1200 and inst.level <1400 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[1500]\n[成长点数]".. (inst.level))
inst:AddTag("level20")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
elseif inst.level >=1400 and inst.level <1600 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[1600]\n[成长点数]".. (inst.level))
inst:AddTag("level21")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
elseif inst.level >=1600 and inst.level <1800 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[1800]\n[成长点数]".. (inst.level))
inst:AddTag("level22")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
elseif inst.level >=1800 and inst.level <2000 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[2000]\n[成长点数]".. (inst.level))
inst:AddTag("level23")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
elseif inst.level >=2000 and inst.level <2200 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[2200]\n[成长点数]".. (inst.level))
inst:AddTag("level24")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
inst:RemoveTag("level23")
elseif inst.level >=2200 and inst.level <2400 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[2400]\n[成长点数]".. (inst.level))
inst:AddTag("level25")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
inst:RemoveTag("level23")
inst:RemoveTag("level24")
elseif inst.level >=2400 and inst.level <2600 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[2600]\n[成长点数]".. (inst.level))
inst:AddTag("level26")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
inst:RemoveTag("level23")
inst:RemoveTag("level24")
inst:RemoveTag("level25")
elseif inst.level >=2600 and inst.level <2800 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[2800]\n[成长点数]".. (inst.level))
inst:AddTag("level27")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
inst:RemoveTag("level23")
inst:RemoveTag("level24")
inst:RemoveTag("level25")
inst:RemoveTag("level26")
elseif inst.level >=2800 and inst.level <3000 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[3000]\n[成长点数]".. (inst.level))
inst:AddTag("level28")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
inst:RemoveTag("level23")
inst:RemoveTag("level24")
inst:RemoveTag("level25")
inst:RemoveTag("level26")
inst:RemoveTag("level27")
elseif inst.level >=3000 and inst.level <4000 then
inst.components.talker:Say("-[冰霜剑] \n下一级:[4000]\n[成长点数]".. (inst.level))
inst:AddTag("level29")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
inst:RemoveTag("level23")
inst:RemoveTag("level24")
inst:RemoveTag("level25")
inst:RemoveTag("level26")
inst:RemoveTag("level27")
inst:RemoveTag("level28")
elseif inst.level >=4000 then
inst.components.talker:Say("-[冰霜剑] \n[满级]")
inst:AddTag("level30")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
inst:RemoveTag("level5")
inst:RemoveTag("level6")
inst:RemoveTag("level7")
inst:RemoveTag("level8")
inst:RemoveTag("level9")
inst:RemoveTag("level10")
inst:RemoveTag("level11")
inst:RemoveTag("level12")
inst:RemoveTag("level13")
inst:RemoveTag("level14")
inst:RemoveTag("level15")
inst:RemoveTag("level16")
inst:RemoveTag("level17")
inst:RemoveTag("level18")
inst:RemoveTag("level19")
inst:RemoveTag("level20")
inst:RemoveTag("level21")
inst:RemoveTag("level22")
inst:RemoveTag("level23")
inst:RemoveTag("level24")
inst:RemoveTag("level25")
inst:RemoveTag("level26")
inst:RemoveTag("level27")
inst:RemoveTag("level28")
inst:RemoveTag("level29")
end
end

local function onpreload(inst, data)
	if data then
		if data.level then
		inst.level = data.level
			levelexp(inst)
end
	end
		end
local function onsave(inst, data)
	data.level = inst.level
	data.charge_time = inst.charge_time
end

local function OnDurability(inst, data)
inst:AddTag("broken")
    inst.components.weapon:SetDamage(1)
	inst.components.talker:Say("-残破的 冰霜剑 \n伤害 (1)")
end


local function onblink(staff, pos, caster)

    if caster.components.sanity then
        caster.components.sanity:DoDelta(-10)
    end
end

local function Upgradedamage(inst)
if inst.components.fueled:IsEmpty() then
inst:AddTag("broken") 
   inst.components.weapon:SetDamage(1)
	inst.components.talker:Say("-残破的 冰霜剑 \n伤害 (1)")
end
if inst:HasTag("broken") then
   inst.components.weapon:SetDamage(1)
	inst.components.talker:Say("-残破的 冰霜剑 \n伤害 (1)")
   end
if not inst:HasTag("broken") then
        if inst:HasTag("level1") then
    inst.components.weapon:SetDamage(30)
	inst.components.talker:Say("-冰霜剑 (1级)\n伤害 (30)\n冻结(10)")
        elseif inst:HasTag("level2") then
    inst.components.weapon:SetDamage(31)
	inst.components.talker:Say("-冰霜剑 (2级)\n伤害 (31)\n冻结(11)")
        elseif inst:HasTag("level3") then
    inst.components.weapon:SetDamage(32)
	inst.components.talker:Say("-冰霜剑 (3级)\n伤害 (32)\n冻结(12)")
        elseif inst:HasTag("level4") then
    inst.components.weapon:SetDamage(33)
	inst.components.talker:Say("-冰霜剑 (4)]\n伤害 (33)\n冻结(13)")
        elseif inst:HasTag("level5") then
    inst.components.weapon:SetDamage(34)
	inst.components.talker:Say("-冰霜剑 (5级)\n伤害 (34)\n冻结(14)")
        elseif inst:HasTag("level6") then
    inst.components.weapon:SetDamage(35)
	inst.components.talker:Say("-冰霜剑 (6级)\n伤害 (35)\n冻结(15)")
        elseif inst:HasTag("level7") then
    inst.components.weapon:SetDamage(36)
	inst.components.talker:Say("-冰霜剑 (7级)\n伤害 (36)\n冻结(16)")
        elseif inst:HasTag("level8") then
    inst.components.weapon:SetDamage(37)
	inst.components.talker:Say("-冰霜剑 (8级)\n伤害 (37)\n冻结(17)")
        elseif inst:HasTag("level9") then
    inst.components.weapon:SetDamage(38)
	inst.components.talker:Say("-冰霜剑 (9级)\n伤害 (38)\n冻结(18)")
        elseif inst:HasTag("level10") then
    inst.components.weapon:SetDamage(42)
	inst.components.talker:Say("-冰霜剑 (10级)\n伤害 (42)\n冻结(19)")
        elseif inst:HasTag("level11") then
    inst.components.weapon:SetDamage(43)
	inst.components.talker:Say("-冰霜剑 (11级)\n伤害 (43)\n冻结(20)")
        elseif inst:HasTag("level12") then
    inst.components.weapon:SetDamage(44)
	inst.components.talker:Say("-冰霜剑 (12级)\n伤害 (44)\n冻结(21)")
        elseif inst:HasTag("level13") then
    inst.components.weapon:SetDamage(45)
	inst.components.talker:Say("-冰霜剑 (13级)\n伤害 (46)\n冻结(22)")
        elseif inst:HasTag("level14") then
    inst.components.weapon:SetDamage(47)
	inst.components.talker:Say("-冰霜剑 (14级)\n伤害 (47)\n冻结(23)")
        elseif inst:HasTag("level15") then
    inst.components.weapon:SetDamage(48)
	inst.components.talker:Say("-冰霜剑 (15级)\n伤害 (48)\n冻结(24)")
        elseif inst:HasTag("level16") then
    inst.components.weapon:SetDamage(49)
	inst.components.talker:Say("-冰霜剑 (16级)\n伤害 (49)\n冻结(25)")
        elseif inst:HasTag("level17") then
    inst.components.weapon:SetDamage(50)
	inst.components.talker:Say("-冰霜剑 (17级)\n伤害 (50)\n冻结(26)")
        elseif inst:HasTag("level18") then
    inst.components.weapon:SetDamage(51)
	inst.components.talker:Say("-冰霜剑 (18级)\n伤害 (51)\n冻结(27)")
        elseif inst:HasTag("level19") then
    inst.components.weapon:SetDamage(54)
	inst.components.talker:Say("-冰霜剑 (19级)\n伤害 (54)\n冻结(28)")
        elseif inst:HasTag("level20") then
    inst.components.weapon:SetDamage(55)
	inst.components.talker:Say("-冰霜剑 (20级)\n伤害 (55)\n冻结(29)")
        elseif inst:HasTag("level21") then
    inst.components.weapon:SetDamage(56)
	inst.components.talker:Say("-冰霜剑 (21级)\n伤害 (56)\n冻结(30)")
        elseif inst:HasTag("level22") then
    inst.components.weapon:SetDamage(57)
	inst.components.talker:Say("-冰霜剑 (22级)\n伤害 (57)\n冻结(31)")
        elseif inst:HasTag("level23") then
    inst.components.weapon:SetDamage(58)
	inst.components.talker:Say("-冰霜剑 (23级)\n伤害 (58)\n冻结(32)")
        elseif inst:HasTag("level24") then
    inst.components.weapon:SetDamage(59)
	inst.components.talker:Say("-冰霜剑 (24级)\n伤害 (59)\n冻结(33)")
        elseif inst:HasTag("level25") then
    inst.components.weapon:SetDamage(60)
	inst.components.talker:Say("-冰霜剑 (25级)\n伤害 (60)\n冻结(34)")
        elseif inst:HasTag("level26") then
    inst.components.weapon:SetDamage(61)
	inst.components.talker:Say("-冰霜剑 (26级)\n伤害 (61)\n冻结(35)")
        elseif inst:HasTag("level27") then
    inst.components.weapon:SetDamage(62)
	inst.components.talker:Say("-冰霜剑 (27级)\n伤害 (62)\n冻结(36)")
        elseif inst:HasTag("level28") then
    inst.components.weapon:SetDamage(63)
	inst.components.talker:Say("-冰霜剑 (28级)\n伤害 (63)\n冻结(37)")
        elseif inst:HasTag("level29") then
    inst.components.weapon:SetDamage(64)
	inst.components.talker:Say("-冰霜剑 (29级)\n伤害 (64)\n冻结(38)")
        elseif inst:HasTag("level30") then
    inst.components.weapon:SetDamage(68)
	inst.components.talker:Say("-冰霜剑 (满级30级)\n伤害 (68)\n冻结(40)")
end
end
end

-------- --------
local function TakeItem(inst, item, data)
local expchance0 = 1
local expchance1 = 0.3
local expchance2 = 0.2
local expchance3 = 0.12
	inst.components.fueled:DoDelta(5000000)
	SpawnPrefab("splash").Transform:SetPosition(inst:GetPosition():Get())
inst:RemoveTag ("broken")     
Upgradedamage(inst)
   if math.random() < expchance1 and inst.level <= 4005 then
	inst.level = inst.level + 2
	levelexp(inst)
	inst.components.talker:Say("幸运点数 ! +(2)\n[成长点数]".. (inst.level))
    elseif  math.random() < expchance2 and inst.level <= 4005 then
	inst.level = inst.level + 5
	levelexp(inst)
	inst.components.talker:Say("幸运点数 ! +(5)\n[成长点数]".. (inst.level))
	elseif  math.random() < expchance3 and inst.level <= 4005 then
	inst.level = inst.level + 8
	levelexp(inst)
	inst.components.talker:Say("幸运点数 ! +(8)\n[成长点数]".. (inst.level))
	elseif  math.random() < expchance0 and inst.level <= 4005 then
	inst.level = inst.level + 1
	levelexp(inst)
    end
end

local function OnLoad(inst, data)
    Upgradedamage(inst)
end


local function onattack_Frost(inst, attacker, target)
local player = GetPlayer()
local freezechance1 = 0.45
local freezechance2 = 0.45
local expchance = 0.05
local damagedur1 = 0.2
local damagedur2 = 0.5
local damagedur3 = 0.7
local damagedur4 = 1


if math.random() < expchance and not inst:HasTag("broken") and inst.level < 4010 then
	inst.level = inst.level + 1
	levelexp(inst)
end
    if target and not inst:HasTag("broken") and math.random() < damagedur1 then
inst.components.fueled:DoDelta(-150000)
    elseif target and not inst:HasTag("broken") and math.random() < damagedur2 then
inst.components.fueled:DoDelta(-75000)
    elseif target and not inst:HasTag("broken") and math.random() < damagedur3 then
inst.components.fueled:DoDelta(-35000)
    elseif target and not inst:HasTag("broken") and math.random() < damagedur4 then
inst.components.fueled:DoDelta(-20000)
    elseif target and inst:HasTag("broken") then
		local fx = SpawnPrefab("splash")
	local pos = Vector3(target.Transform:GetWorldPosition())
fx.Transform:SetPosition(pos:Get())
	inst.components.talker:Say("-残破的 武器 \n伤害 (1)")
    end

if target.components.freezable and player:HasTag("frosta") and not inst:HasTag("boost") then
        target.components.freezable:AddColdness(10)
        target.components.freezable:SpawnShatterFX()
        attacker.components.sanity:DoDelta(-4)
local fx = SpawnPrefab("statue_transition_2")
local pos = Vector3(target.Transform:GetWorldPosition())
	fx.Transform:SetPosition(pos:Get())
		--target.components.health:DoDelta(-80)
	player:RemoveTag("frosta") 

elseif target.components.freezable and player:HasTag("frosta") and not player:HasTag("DLC") and inst:HasTag("boost") then
        target.components.freezable:AddColdness(10)
        target.components.freezable:SpawnShatterFX()
        attacker.components.sanity:DoDelta(-12)
local fx = SpawnPrefab("statue_transition_2")
local pos = Vector3(target.Transform:GetWorldPosition())
	fx.Transform:SetPosition(pos:Get())
		target.components.health:DoDelta(-100)
	player:RemoveTag("frosta") 

elseif target.components.freezable and player:HasTag("frosta") and player:HasTag("DLC") and inst:HasTag("boost") then
        target.components.freezable:AddColdness(10)
        target.components.freezable:SpawnShatterFX()
        attacker.components.sanity:DoDelta(-12)
local fx = SpawnPrefab("groundpoundring_fx")
local pos = Vector3(target.Transform:GetWorldPosition())
	fx.Transform:SetPosition(pos:Get())
		target.components.health:DoDelta(-100)
	player:RemoveTag("frosta") 
    end

     if target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level1") and math.random() < freezechance1 then
        target.components.freezable:AddColdness(0.1)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level2") and math.random() < freezechance1 then
        target.components.freezable:AddColdness(0.11)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level3") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.12)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level4") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.13)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level5") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.14)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level6") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.15)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level7") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.16)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level8") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.17)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level9") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.18)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level10") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.19)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level11") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.2)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level12") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.21)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level13") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.22)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level14") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.23)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level15") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.24)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level16") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.25)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level17") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.26)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level18") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.27)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level19") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.28)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level20") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.29)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level21") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.3)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level22") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.31)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level23") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.32)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level24") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.33)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level25") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.34)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level26") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.35)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level27") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.36)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level28") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.37)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level29") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.38)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level30") and math.random() < freezechance1 then
       target.components.freezable:AddColdness(0.4)
        target.components.freezable:SpawnShatterFX()
-----boost
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level1") and math.random() < freezechance2 and inst:HasTag("boost2") then
        target.components.freezable:AddColdness(0.1)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level2") and math.random() < freezechance2 and inst:HasTag("boost2") then
        target.components.freezable:AddColdness(0.11)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level3") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.12)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level4") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.13)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level5") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.14)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level6") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.15)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level7") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.16)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level8") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.17)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level9") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.18)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level10") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.19)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level11") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.2)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level12") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.21)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level13") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.22)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level14") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.23)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level15") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.24)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level16") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.25)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level17") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.26)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level18") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.27)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level19") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.28)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level20") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.29)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level21") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.3)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level22") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.31)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level23") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.32)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level24") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.33)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level25") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.34)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level26") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.35)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level27") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.36)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level28") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.37)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level29") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.38)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and inst:HasTag("level30") and math.random() < freezechance2 and inst:HasTag("boost2") then
       target.components.freezable:AddColdness(0.4)
        target.components.freezable:SpawnShatterFX()

    end

    if target.components.sleeper and target.components.sleeper:IsAsleep() then
        target.components.sleeper:WakeUp()
    end
    if target.components.burnable and target.components.burnable:IsBurning() then
        target.components.burnable:Extinguish()
    end

    if target.components.combat then
        target.components.combat:SuggestTarget(attacker)


    end
	player:RemoveTag("frosta") 
end

local function OnDropped(inst,data)
   inst:AddTag("talkf")
    end
local function OnPutInInventory(inst)
   inst:RemoveTag("talkf")
    end

local function onequip(inst, owner)
   inst:AddTag("talkf")
    Upgradedamage(inst)
--inst.components.fueled:StartConsuming()        

local player = GetPlayer()
	player:AddTag("frosthammer") 
    owner.AnimState:OverrideSymbol("swap_object", "swap_mushasword_frost1", "swap_nightmaresword")
    owner.AnimState:Show("ARM_carry") 
    owner.AnimState:Hide("ARM_normal") 
if inst.level >=0 and inst.level <250 then
    owner.AnimState:OverrideSymbol("swap_object", "swap_mushasword_base", "swap_nightmaresword")
    owner.AnimState:Show("ARM_carry") 
    owner.AnimState:Hide("ARM_normal") 
elseif inst.level >=250 and inst.level <1400 then
    owner.AnimState:OverrideSymbol("swap_object", "swap_mushasword_frost1", "swap_nightmaresword")
    owner.AnimState:Show("ARM_carry") 
    owner.AnimState:Hide("ARM_normal") 
elseif inst.level >=1400 then
    owner.AnimState:OverrideSymbol("swap_object", "swap_mushasword_frost2", "swap_nightmaresword")
    owner.AnimState:Show("ARM_carry") 
    owner.AnimState:Hide("ARM_normal") 
        inst.entity:AddLight()
	inst.Light:SetRadius(.8)
    inst.Light:SetFalloff(.5)
    inst.Light:SetIntensity(.5)
    inst.Light:SetColour(80/255,120/255,250/255)
end
end

local function onunequip(inst, owner) 
   inst:RemoveTag("talkf")
    inst:RemoveComponent("blinkstaff")
    Upgradedamage(inst)
inst:RemoveTag("boost") 
	inst:RemoveTag("boost2") 
    if inst.task then inst.task:Cancel() inst.task = nil end
local player = GetPlayer()
    owner.AnimState:Hide("ARM_carry") 
    owner.AnimState:Show("ARM_normal") 
		player:RemoveTag("frosthammer") 
		player:RemoveTag("frosta") 

end

local function consume(inst, owner)
if not inst:HasTag("broken") then
inst.components.fueled:DoDelta(-50000)
end
end

  local function boost(inst, data, owner, fname_override)
local player = GetPlayer()
        local owner = inst.components.inventoryitem.owner
if owner and inst:HasTag("broken") then
	inst:RemoveTag("boost") 
	inst:RemoveTag("boost2") 
	player.components.talker:Say("冰霜剑破了!")
	inst.components.talker:Say("-[冰霜剑]\n耐久度 (0)")
    inst.components.equippable.walkspeedmult = 1
	inst.Light:Enable(false)
    owner.AnimState:OverrideSymbol("swap_object", "swap_mushasword_base", "swap_nightmaresword")
    owner.AnimState:Show("ARM_carry") 
    owner.AnimState:Hide("ARM_normal") 
        inst.components.useableitem:StopUsingItem()
end
if owner and not inst:HasTag("boost") and not inst:HasTag("broken") then
	inst:AddTag("boost")
	player.components.talker:Say("能量剑刃!")
    inst.task = inst:DoPeriodicTask(1, function() consume(inst, owner) end)
  inst.SoundEmitter:PlaySound("dontstarve/common/gem_shatter")
        inst.entity:AddLight()
		local fx = SpawnPrefab("splash")
	local pos = Vector3(inst.Transform:GetWorldPosition())
fx.Transform:SetPosition(pos:Get())

        inst.components.useableitem:StopUsingItem()

if inst.level >=0 and inst.level <250 then
	inst.components.talker:Say("-[能量剑刃 I]\n速度上升(10)\n发光(小)\n能量攻击上升")
    inst.components.equippable.walkspeedmult = 1.1
	inst.Light:SetRadius(.4)
    inst.Light:SetFalloff(.5)
    inst.Light:SetIntensity(.5)
    inst.Light:SetColour(80/255,120/255,250/255)
	inst.Light:Enable(true)
    owner.AnimState:OverrideSymbol("swap_object", "swap_mushasword_frost1", "swap_nightmaresword")
    owner.AnimState:Show("ARM_carry") 
    owner.AnimState:Hide("ARM_normal") 
elseif inst.level >=250 and inst.level <1400 then
	inst.components.talker:Say("-[能量剑刃 II]\n速度上升(20)\n发光(中)\n能量攻击上升\n传送")
    inst:AddComponent("blinkstaff")
    inst.components.blinkstaff.onblinkfn = onblink
        inst:AddComponent("reticule")
    inst.components.reticule.targetfn = function() 
        return inst.components.blinkstaff:GetBlinkPoint()
    end
    inst.components.reticule.ease = true
    inst:AddTag("nopunch")
    inst.components.equippable.walkspeedmult = 1.2
	inst.Light:SetRadius(.6)
    inst.Light:SetFalloff(.5)
    inst.Light:SetIntensity(.5)
    inst.Light:SetColour(80/255,120/255,250/255)
	inst.Light:Enable(true)
    owner.AnimState:OverrideSymbol("swap_object", "swap_mushasword_frost2", "swap_nightmaresword")
    owner.AnimState:Show("ARM_carry") 
    owner.AnimState:Hide("ARM_normal") 
elseif inst.level >=1400 then
	inst.components.talker:Say("-[能量剑刃 III]\n速度上升(30)\n发光(大)\n能量攻击上升\n传送\n双倍冻结")
    inst:AddComponent("blinkstaff")
    inst.components.blinkstaff.onblinkfn = onblink
        inst:AddComponent("reticule")
    inst.components.reticule.targetfn = function() 
        return inst.components.blinkstaff:GetBlinkPoint()
    end
    inst.components.reticule.ease = true
    inst:AddTag("nopunch")
    inst:AddTag("boost2")
    inst.components.equippable.walkspeedmult = 1.3
	inst.Light:SetRadius(.8)
    inst.Light:SetFalloff(.5)
    inst.Light:SetIntensity(.5)
    inst.Light:SetColour(80/255,120/255,250/255)
	inst.Light:Enable(true)
    owner.AnimState:OverrideSymbol("swap_object", "swap_mushasword_frost3", "swap_nightmaresword")
    owner.AnimState:Show("ARM_carry") 
    owner.AnimState:Hide("ARM_normal") 
end
-----------
elseif owner and inst:HasTag("boost") and not inst:HasTag("broken") then
	inst:RemoveTag("boost") 
	inst:RemoveTag("boost2") 
	player.components.talker:Say("能量关闭 !")
	inst.components.talker:Say("-[冰霜剑]\n能量关闭")
    inst:RemoveComponent("blinkstaff")
    if inst.task then inst.task:Cancel() inst.task = nil end
    inst.components.equippable.walkspeedmult = 1
    inst.components.equippable.runspeedmult = 1
	inst.Light:Enable(false)
		local fx = SpawnPrefab("splash")
	local pos = Vector3(inst.Transform:GetWorldPosition())
fx.Transform:SetPosition(pos:Get())
  inst.SoundEmitter:PlaySound("dontstarve/common/fireOut")

if inst.level >=0 and inst.level <250 then
    owner.AnimState:OverrideSymbol("swap_object", "swap_mushasword_base", "swap_nightmaresword")
    owner.AnimState:Show("ARM_carry") 
    owner.AnimState:Hide("ARM_normal") 
elseif inst.level >=250 and inst.level <1400 then
    owner.AnimState:OverrideSymbol("swap_object", "swap_mushasword_frost1", "swap_nightmaresword")
    owner.AnimState:Show("ARM_carry") 
    owner.AnimState:Hide("ARM_normal") 
elseif inst.level >=1400 then
    owner.AnimState:OverrideSymbol("swap_object", "swap_mushasword_frost2", "swap_nightmaresword")
    owner.AnimState:Show("ARM_carry") 
    owner.AnimState:Hide("ARM_normal") 
end

        inst.components.useableitem:StopUsingItem()
end
end

local function fn(Sim)
	local inst = CreateEntity()
	local trans = inst.entity:AddTransform()
	local anim = inst.entity:AddAnimState()
    MakeInventoryPhysics(inst)
    	inst.entity:AddSoundEmitter()

    inst.AnimState:SetBank("nightmaresword")
    inst.AnimState:SetBuild("mushasword_frost")
    inst.AnimState:PlayAnimation("idle")
    inst.AnimState:SetMultColour(1, 1, 1, 0.7)

    inst:AddTag("sharp")
    
    inst:AddComponent("weapon")
    inst.components.weapon:SetOnAttack(Upgradedamage)

      inst.components.weapon:SetOnAttack(onattack_Frost)

    -------
    
    inst:AddComponent("inspectable")
        inst:AddComponent("inventoryitem")
    inst.components.inventoryitem:SetOnDroppedFn(OnDropped)
    inst.components.inventoryitem:SetOnPutInInventoryFn(OnPutInInventory)
    	inst.components.inventoryitem.atlasname = "images/inventoryimages/mushasword_frost.xml"
     inst.entity:AddMiniMapEntity()
	inst.MiniMapEntity:SetIcon( "blade_f.tex" )

        inst.entity:AddLight()
	inst.Light:SetRadius(.4)
    inst.Light:SetFalloff(.5)
    inst.Light:SetIntensity(.5)
    inst.Light:SetColour(80/255,120/255,250/255)
	inst.Light:Enable(true)

    inst.OnLoad = OnLoad

    inst:AddComponent("talker")
    inst.components.talker.fontsize = 19
    inst.components.talker.font = TALKINGFONT
    inst.components.talker.colour = Vector3(0.7, 0.85, 1, 1)
    inst.components.talker.offset = Vector3(200,-250,0)

    inst.components.talker.symbol = "swap_object"

            inst:AddComponent("useableitem")
     inst.components.useableitem:SetOnUseFn(boost)
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip( onequip )
    inst.components.equippable:SetOnUnequip( onunequip )

  --[[  inst:AddComponent("blinkstaff")
    inst.components.blinkstaff.onblinkfn = onblink
        inst:AddComponent("reticule")
    inst.components.reticule.targetfn = function() 
        return inst.components.blinkstaff:GetBlinkPoint()
    end
    inst.components.reticule.ease = true
    inst:AddTag("nopunch")]]

        inst:AddComponent("fueled")
       inst.components.fueled.fueltype = "CHEMICAL"
        inst.components.fueled:InitializeFuelLevel(30000000)
       inst.components.fueled:SetDepletedFn(OnDurability)
        inst.components.fueled.ontakefuelfn = TakeItem
        inst.components.fueled.accepting = true
inst.components.fueled:StopConsuming()        
inst:RemoveTag("boost") 
inst:AddTag("level1")
	inst.level = 0
inst:ListenForEvent("levelup", levelexp)
	inst.OnSave = onsave
	inst.OnPreLoad = onpreload

    return inst
end

return Prefab( "common/inventory/mushasword_frost", fn, assets) 
