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("-[Frost Blade]-\n[Grow Points]".. (inst.level))
inst:RemoveTag("levelup")
end
if inst.level >=0 and inst.level <10 then
inst.components.talker:Say("-[Frost Blade] \nNext:[10]\n[Grow Points]".. (inst.level))
inst:AddTag("level1")
elseif inst.level >=10 and inst.level <30 then
inst.components.talker:Say("-[Frost Blade] \nNext:[30]\n[Grow Points]".. (inst.level))
inst:AddTag("level2")
inst:RemoveTag("level1")
elseif inst.level >=30 and inst.level <50 then
inst.components.talker:Say("-[Frost Blade] \nNext:[50]\n[Grow Points]".. (inst.level))
inst:AddTag("level3")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
elseif inst.level >=50 and inst.level <70 then
inst.components.talker:Say("-[Frost Blade] \nNext:[70]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[90]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[120]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[150]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[180]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[210]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[250]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[350]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[450]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[550]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[650]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[750]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[850]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[950]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[1050]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[1200]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[1500]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[1600]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[1800]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[2000]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[2200]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[2400]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[2600]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[2800]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[3000]\n[Grow Points]".. (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("-[Frost Blade] \nNext:[4000]\n[Grow Points]".. (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("-[Frost Blade] \n[MAX]")
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("-Broken FrostBlade \nDamage (1)")
	   if inst.task then inst.task:Cancel() inst.task = nil end
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("-Broken FrostBlade \nDamage (1)")
end
if inst:HasTag("broken") then
   inst.components.weapon:SetDamage(1)
	inst.components.talker:Say("-Broken FrostBlade \nDamage (1)")
   end
if not inst:HasTag("broken") then
        if inst:HasTag("level1") then
    inst.components.weapon:SetDamage(30)
	inst.components.talker:Say("-Frost Blade (LV1)\nDamage (30)\nFreeze(10)")
        elseif inst:HasTag("level2") then
    inst.components.weapon:SetDamage(31)
	inst.components.talker:Say("-Frost Blade (LV2)\nDamage (31)\nFreeze(11)")
        elseif inst:HasTag("level3") then
    inst.components.weapon:SetDamage(32)
	inst.components.talker:Say("-Frost Blade (LV3)\nDamage (32)\nFreeze(12)")
        elseif inst:HasTag("level4") then
    inst.components.weapon:SetDamage(33)
	inst.components.talker:Say("-Frost Blade (LV4)]\nDamage (33)\nFreeze(13)")
        elseif inst:HasTag("level5") then
    inst.components.weapon:SetDamage(34)
	inst.components.talker:Say("-Frost Blade (LV5)\nDamage (34)\nFreeze(14)")
        elseif inst:HasTag("level6") then
    inst.components.weapon:SetDamage(35)
	inst.components.talker:Say("-Frost Blade (LV6)\nDamage (35)\nFreeze(15)")
        elseif inst:HasTag("level7") then
    inst.components.weapon:SetDamage(36)
	inst.components.talker:Say("-Frost Blade (LV7)\nDamage (36)\nFreeze(16)")
        elseif inst:HasTag("level8") then
    inst.components.weapon:SetDamage(37)
	inst.components.talker:Say("-Frost Blade (LV8)\nDamage (37)\nFreeze(17)")
        elseif inst:HasTag("level9") then
    inst.components.weapon:SetDamage(38)
	inst.components.talker:Say("-Frost Blade (LV9)\nDamage (38)\nFreeze(18)")
        elseif inst:HasTag("level10") then
    inst.components.weapon:SetDamage(42)
	inst.components.talker:Say("-Frost Blade (LV10)\nDamage (42)\nFreeze(19)")
        elseif inst:HasTag("level11") then
    inst.components.weapon:SetDamage(43)
	inst.components.talker:Say("-Frost Blade (LV11)\nDamage (43)\nFreeze(20)")
        elseif inst:HasTag("level12") then
    inst.components.weapon:SetDamage(44)
	inst.components.talker:Say("-Frost Blade (LV12)\nDamage (44)\nFreeze(21)")
        elseif inst:HasTag("level13") then
    inst.components.weapon:SetDamage(45)
	inst.components.talker:Say("-Frost Blade (LV13)\nDamage (46)\nFreeze(22)")
        elseif inst:HasTag("level14") then
    inst.components.weapon:SetDamage(47)
	inst.components.talker:Say("-Frost Blade (LV14)\nDamage (47)\nFreeze(23)")
        elseif inst:HasTag("level15") then
    inst.components.weapon:SetDamage(48)
	inst.components.talker:Say("-Frost Blade (LV15)\nDamage (48)\nFreeze(24)")
        elseif inst:HasTag("level16") then
    inst.components.weapon:SetDamage(49)
	inst.components.talker:Say("-Frost Blade (LV16)\nDamage (49)\nFreeze(25)")
        elseif inst:HasTag("level17") then
    inst.components.weapon:SetDamage(50)
	inst.components.talker:Say("-Frost Blade (LV17)\nDamage (50)\nFreeze(26)")
        elseif inst:HasTag("level18") then
    inst.components.weapon:SetDamage(51)
	inst.components.talker:Say("-Frost Blade (LV18)\nDamage (51)\nFreeze(27)")
        elseif inst:HasTag("level19") then
    inst.components.weapon:SetDamage(54)
	inst.components.talker:Say("-Frost Blade (LV19)\nDamage (54)\nFreeze(28)")
        elseif inst:HasTag("level20") then
    inst.components.weapon:SetDamage(55)
	inst.components.talker:Say("-Frost Blade (LV20)\nDamage (55)\nFreeze(29)")
        elseif inst:HasTag("level21") then
    inst.components.weapon:SetDamage(56)
	inst.components.talker:Say("-Frost Blade (LV21)\nDamage (56)\nFreeze(30)")
        elseif inst:HasTag("level22") then
    inst.components.weapon:SetDamage(57)
	inst.components.talker:Say("-Frost Blade (LV22)\nDamage (57)\nFreeze(31)")
        elseif inst:HasTag("level23") then
    inst.components.weapon:SetDamage(58)
	inst.components.talker:Say("-Frost Blade (LV23)\nDamage (58)\nFreeze(32)")
        elseif inst:HasTag("level24") then
    inst.components.weapon:SetDamage(59)
	inst.components.talker:Say("-Frost Blade (LV24)\nDamage (59)\nFreeze(33)")
        elseif inst:HasTag("level25") then
    inst.components.weapon:SetDamage(60)
	inst.components.talker:Say("-Frost Blade (LV25)\nDamage (60)\nFreeze(34)")
        elseif inst:HasTag("level26") then
    inst.components.weapon:SetDamage(61)
	inst.components.talker:Say("-Frost Blade (LV26)\nDamage (61)\nFreeze(35)")
        elseif inst:HasTag("level27") then
    inst.components.weapon:SetDamage(62)
	inst.components.talker:Say("-Frost Blade (LV27)\nDamage (62)\nFreeze(36)")
        elseif inst:HasTag("level28") then
    inst.components.weapon:SetDamage(63)
	inst.components.talker:Say("-Frost Blade (LV28)\nDamage (63)\nFreeze(37)")
        elseif inst:HasTag("level29") then
    inst.components.weapon:SetDamage(64)
	inst.components.talker:Say("-Frost Blade (LV29)\nDamage (64)\nFreeze(38)")
        elseif inst:HasTag("level30") then
    inst.components.weapon:SetDamage(68)
	inst.components.talker:Say("-Frost Blade (Max30)\nDamage (68)\nFreeze(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("Lucky Points ! +(2)\n[Grow Points]".. (inst.level))
    elseif  math.random() < expchance2 and inst.level <= 4005 then
	inst.level = inst.level + 5
	levelexp(inst)
	inst.components.talker:Say("Lucky Points ! +(5)\n[Grow Points]".. (inst.level))
	elseif  math.random() < expchance3 and inst.level <= 4005 then
	inst.level = inst.level + 8
	levelexp(inst)
	inst.components.talker:Say("Lucky Points ! +(8)\n[Grow Points]".. (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("-Broken Weapon \nDamage (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("Frost Blade is Broken !")
	inst.components.talker:Say("-[Frost Blade]\nDurability (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("Power Blade !")
    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("-[Power Blade I]\nSpeed up(10)\nLight(Small)\nPower attack up")
    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("-[Power Blade II]\nSpeed up(20)\nLight(Med)\nPower attack up\nBlink")
    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("-[Power Blade III]\nSpeed up(30)\nLight(Large)\nPower attack up\nBlink\nDouble Freeze")
    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("Power off !")
	inst.components.talker:Say("-[Frost Blade]\nPower Off")
    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:AddTag("metal")
	 
    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) 
