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

local prefabs =
{
	--"collapse_small",
	--"collapse_big",
}
---------------------------
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 Hammer]-\n[Grow Points]".. (inst.level))
inst:RemoveTag("levelup")
end
if inst.level >=0 and inst.level <10 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[10]\n[Grow Points]".. (inst.level))
inst:AddTag("level1")
elseif inst.level >=10 and inst.level <30 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[30]\n[Grow Points]".. (inst.level))
inst:AddTag("level2")
inst:RemoveTag("level1")
elseif inst.level >=30 and inst.level <60 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[60]\n[Grow Points]".. (inst.level))
inst:AddTag("level3")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
elseif inst.level >=60 and inst.level <100 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[100]\n[Grow Points]".. (inst.level))
inst:AddTag("level4")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
elseif inst.level >=100 and inst.level <150 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[150]\n[Grow Points]".. (inst.level))
inst:AddTag("level5")
inst:RemoveTag("level1")
inst:RemoveTag("level2")
inst:RemoveTag("level3")
inst:RemoveTag("level4")
elseif inst.level >=150 and inst.level <200 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[200]\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 >=200 and inst.level <250 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[250]\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 >=250 and inst.level <300 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[300]\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 >=300 and inst.level <350 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[350]\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 >=350 and inst.level <450 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[450]\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 >=450 and inst.level <600 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[600]\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 >=600 and inst.level <700 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[700]\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 >=700 and inst.level <800 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[800]\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 >=800 and inst.level <900 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[900]\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 >=900 and inst.level <1000 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[1000]\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 >=1000 and inst.level <1100 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[1100]\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 >=1100 and inst.level <1200 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[1200]\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 >=1200 and inst.level <1300 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[1300]\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 >=1300 and inst.level <1400 then
inst.components.talker:Say("-[Frost Hammer] \nNext:[1400]\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 >=1400 and inst.level <1500 then
inst.components.talker:Say("-[Frost Hammer] \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 >=1500 and inst.level <1600 then
inst.components.talker:Say("-[Frost Hammer] \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 Hammer] \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 Hammer] \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 Hammer] \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 Hammer] \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 Hammer] \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 Hammer] \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 Hammer] \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 Hammer] \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 Hammer] \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 Frost Hammer \nDamage (1)")
end

local function Upgradedamage(inst)
if inst.components.fueled:IsEmpty() then
inst:AddTag("broken") 
   inst.components.weapon:SetDamage(1)
	inst.components.talker:Say("-Broken  Frost Hammer\nDamage (1)")
end

if inst:HasTag("broken") then
    inst.components.weapon:SetDamage(1)
	inst.components.talker:Say("-Broken Frost Hammer\nDamage (1)")
   end
if not inst:HasTag("broken") then
        if inst:HasTag("level1") then
    inst.components.weapon:SetDamage(40)
	inst.components.talker:Say("-[Frost Hammer (LV1)]\nDamage (40)\nCritical(1per)")
        elseif inst:HasTag("level2") then
    inst.components.weapon:SetDamage(41)
	inst.components.talker:Say("-[Frost Hammer (LV2)]\nDamage (41)\nCritical(2per)")
        elseif inst:HasTag("level3") then
    inst.components.weapon:SetDamage(42)
	inst.components.talker:Say("-[Frost Hammer (LV3)]\nDamage (42)\nCritical(3per)")
        elseif inst:HasTag("level4") then
    inst.components.weapon:SetDamage(43)
	inst.components.talker:Say("-[Frost Hammer (LV4)]\nDamage (43)\nCritical(4per)")
        elseif inst:HasTag("level5") then
    inst.components.weapon:SetDamage(44)
	inst.components.talker:Say("-[Frost Hammer (LV5)]\nDamage (44)\nCritical(5per)")
        elseif inst:HasTag("level6") then
    inst.components.weapon:SetDamage(45)
	inst.components.talker:Say("-[Frost Hammer (LV6)]\nDamage (45)\nCritical(6per)")
        elseif inst:HasTag("level7") then
    inst.components.weapon:SetDamage(46)
	inst.components.talker:Say("-[Frost Hammer (LV7)]\nDamage (46)\nCritical(7per)")
        elseif inst:HasTag("level8") then
    inst.components.weapon:SetDamage(47)
	inst.components.talker:Say("-[Frost Hammer (LV8)]\nDamage (47)\nCritical(8per)")
        elseif inst:HasTag("level9") then
    inst.components.weapon:SetDamage(48)
	inst.components.talker:Say("-[Frost Hammer (LV9)]\nDamage (48)\nCritical(9per)")
        elseif inst:HasTag("level10") then
    inst.components.weapon:SetDamage(49)
	inst.components.talker:Say("-[Frost Hammer (LV10)]\nDamage (49)\nCritical(10per)")
        elseif inst:HasTag("level11") then
    inst.components.weapon:SetDamage(50)
	inst.components.talker:Say("-[Frost Hammer (LV11)]\nDamage (50)\nCritical(11per)")
        elseif inst:HasTag("level12") then
    inst.components.weapon:SetDamage(51)
	inst.components.talker:Say("-[Frost Hammer (LV12)]\nDamage (51)\nCritical(12per)")
        elseif inst:HasTag("level13") then
    inst.components.weapon:SetDamage(52)
	inst.components.talker:Say("-[Frost Hammer (LV13)]\nDamage (52)\nCritical(13per)")
        elseif inst:HasTag("level14") then
    inst.components.weapon:SetDamage(53)
	inst.components.talker:Say("-[Frost Hammer (LV14)]\nDamage (53)\nCritical(14per)")
        elseif inst:HasTag("level15") then
    inst.components.weapon:SetDamage(54)
	inst.components.talker:Say("-[Frost Hammer (LV15)]\nDamage (54)\nCritical(15per)")
        elseif inst:HasTag("level16") then
    inst.components.weapon:SetDamage(55)
	inst.components.talker:Say("-[Frost Hammer (LV16)]\nDamage (55)\nCritical(16per)")
        elseif inst:HasTag("level17") then
    inst.components.weapon:SetDamage(56)
	inst.components.talker:Say("-[Frost Hammer (LV17)]\nDamage (56)\nCritical(17per)")
        elseif inst:HasTag("level18") then
    inst.components.weapon:SetDamage(57)
	inst.components.talker:Say("-[Frost Hammer (LV18)]\nDamage (57)\nCritical(18per)")
        elseif inst:HasTag("level19") then
    inst.components.weapon:SetDamage(58)
	inst.components.talker:Say("-[Frost Hammer (LV19)]\nDamage (58)\nCritical(19per)")
        elseif inst:HasTag("level20") then
    inst.components.weapon:SetDamage(59)
	inst.components.talker:Say("-[Frost Hammer (LV20)]\nDamage (59)\nCritical(20per)")
        elseif inst:HasTag("level21") then
    inst.components.weapon:SetDamage(60)
	inst.components.talker:Say("-[Frost Hammer (LV21)]\nDamage (60)\nCritical(21per)")
        elseif inst:HasTag("level22") then
    inst.components.weapon:SetDamage(61)
	inst.components.talker:Say("-[Frost Hammer (LV22)]\nDamage (61)\nCritical(22per)")
        elseif inst:HasTag("level23") then
    inst.components.weapon:SetDamage(62)
	inst.components.talker:Say("-[Frost Hammer (LV23)]\nDamage (62)\nCritical(23per)")
        elseif inst:HasTag("level24") then
    inst.components.weapon:SetDamage(63)
	inst.components.talker:Say("-[Frost Hammer (LV24)]\nDamage (63)\nCritical(24per)")
        elseif inst:HasTag("level25") then
    inst.components.weapon:SetDamage(64)
	inst.components.talker:Say("-[Frost Hammer (LV25)]\nDamage (64)\nCritical(25per)")
        elseif inst:HasTag("level26") then
    inst.components.weapon:SetDamage(65)
	inst.components.talker:Say("-[Frost Hammer (LV26)]\nDamage (65)\nCritical(26per)")
        elseif inst:HasTag("level27") then
    inst.components.weapon:SetDamage(66)
	inst.components.talker:Say("-[Frost Hammer (LV27)]\nDamage (66)\nCritical(27per)")
        elseif inst:HasTag("level28") then
    inst.components.weapon:SetDamage(67)
	inst.components.talker:Say("-[Frost Hammer (LV28)]\nDamage (67)\nCritical(28per)")
        elseif inst:HasTag("level29") then
    inst.components.weapon:SetDamage(68)
	inst.components.talker:Say("-[Frost Hammer (LV29)]\nDamage (68)\nCritical(29per)")
        elseif inst:HasTag("level30") then
    inst.components.weapon:SetDamage(70)
	inst.components.talker:Say("-[Frost Hammer (Max30)]\nDamage (70)\nCritical(30per)")
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 cansummon(staff, caster, target, pos)
    local ground = GetWorld()
    if ground and pos then
        local tile = ground.Map:GetTileAtPoint(pos.x, pos.y, pos.z)
        return tile ~= GROUND.IMPASSIBLE and tile < GROUND.UNDERGROUND
    end
    return false
end

local function summoning(staff, target, pos)
local player = GetPlayer()
    local caster = staff.components.inventoryitem.owner
if caster.components.sanity.current >= 40 then
    local light = SpawnPrefab("splash")
    local light2 = SpawnPrefab("tentacle_frost")

    light.Transform:SetPosition(pos.x, pos.y, pos.z)
    light2.Transform:SetPosition(pos.x, pos.y, pos.z)
        light2.components.follower:SetLeader(player)
caster.components.sanity:DoDelta(-30)

    elseif caster.components.sanity.current < 40 then
	player.components.talker:Say("not enough [Sanity]..")
        
    end

end


local function onattack_FROST(inst, attacker, target)
local freezechance1 = 0.01
local freezechance2 = 0.02
local freezechance3 = 0.03
local freezechance4 = 0.04
local freezechance5 = 0.05
local freezechance6 = 0.06
local freezechance7 = 0.07
local freezechance8 = 0.08
local freezechance9 = 0.09
local freezechance10 = 0.1
local freezechance11 = 0.11
local freezechance12 = 0.12
local freezechance13 = 0.13
local freezechance14 = 0.14
local freezechance15 = 0.15
local freezechance16 = 0.16
local freezechance17 = 0.17
local freezechance18 = 0.18
local freezechance19 = 0.19
local freezechance20 = 0.2
local freezechance21 = 0.21
local freezechance22 = 0.22
local freezechance23 = 0.23
local freezechance24 = 0.24
local freezechance28 = 0.25
local freezechance26 = 0.26
local freezechance27 = 0.27
local freezechance28 = 0.28
local freezechance29 = 0.29
local freezechance30 = 0.3

local player = GetPlayer()

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 not player:HasTag("frosta") then
        target.components.freezable:AddColdness(0.15)
        target.components.freezable:SpawnShatterFX()
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance1 and inst:HasTag("level1") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
        target.components.health:DoDelta(-20)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance2 and inst:HasTag("level2") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
        target.components.health:DoDelta(-21)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance3 and inst:HasTag("level3") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
        target.components.health:DoDelta(-22)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance4 and inst:HasTag("level4") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-23)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance5 and inst:HasTag("level5") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-24)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance6 and inst:HasTag("level6") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-25)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance7 and inst:HasTag("level7") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-26)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance8 and inst:HasTag("level8") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-27)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance9 and inst:HasTag("level9") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-28)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance10 and inst:HasTag("level10") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-29)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance11 and inst:HasTag("level11") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-30)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance12 and inst:HasTag("level12") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-31)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance13 and inst:HasTag("level13") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-32)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance14 and inst:HasTag("level14") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-33)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance15 and inst:HasTag("level15") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-34)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance16 and inst:HasTag("level16") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-35)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance17 and inst:HasTag("level17") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-36)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance18 and inst:HasTag("level18") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-37)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance19 and inst:HasTag("level19") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-38)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance20 and inst:HasTag("level20") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-39)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance21 and inst:HasTag("level21") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-40)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance22 and inst:HasTag("level22") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-41)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance23 and inst:HasTag("level23") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-42)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance24 and inst:HasTag("level24") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-43)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance25 and inst:HasTag("level25") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-44)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance26 and inst:HasTag("level26") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-45)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance27 and inst:HasTag("level27") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-46)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance28 and inst:HasTag("level28") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-47)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance29 and inst:HasTag("level29") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-48)
     elseif target.components.freezable and not player:HasTag("frosta") and math.random() < freezechance30 and inst:HasTag("level30") and target.components.health then
        target.components.freezable:AddColdness(1)
        target.components.freezable:SpawnShatterFX()
      target.components.health:DoDelta(-50)

elseif target.components.freezable and player:HasTag("frosta") and not player:HasTag("DLC") then
        target.components.freezable:AddColdness(10)
        target.components.freezable:SpawnShatterFX()
local fx = SpawnPrefab("statue_transition_2")
local pos = Vector3(target.Transform:GetWorldPosition())
	fx.Transform:SetPosition(pos:Get())
		target.components.health:DoDelta(-90)
	player:RemoveTag("frosta") 
elseif target.components.freezable and player:HasTag("frosta") and player:HasTag("DLC") then
        target.components.freezable:AddColdness(10)
        target.components.freezable:SpawnShatterFX()
        attacker.components.sanity:DoDelta(-20)
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.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) 
local player = GetPlayer()
   inst:AddTag("talkf")
    Upgradedamage(inst)

    owner.AnimState:OverrideSymbol("swap_object", "swap_frosthammer", "swap_umbrella")
    owner.AnimState:Show("ARM_carry") 
    owner.AnimState:Hide("ARM_normal") 
	player:AddTag("frosthammer") 

 --   owner.components.inventory:SetOverflow(inst)
-- inst.components.container:Open(owner)

end

local function onunequip(inst, owner) 
   inst:RemoveTag("talkf")
local player = GetPlayer()
    owner.AnimState:Hide("ARM_carry") 
    owner.AnimState:Show("ARM_normal") 
--    owner.components.inventory:SetOverflow(nil)
    inst.components.container:Close(owner)
	player:RemoveTag("frosthammer") 
	player:RemoveTag("frosta") 
       inst:RemoveComponent("spellcaster")
      inst:RemoveComponent("heater")

 end
 
local function OnOpen(inst)
  inst.SoundEmitter:PlaySound("dontstarve/common/gem_shatter")
	inst.components.talker:Say("-[Frost Hammer]\nSpeed Down\nSummon monster\nCooling Body heat\n(No ice box)")
    inst.components.equippable.walkspeedmult = 0.6
      inst:AddComponent("heater")
     inst.components.heater.iscooler = true
     inst.components.heater.equippedheat = -1
       inst:AddComponent("spellcaster")
    inst.components.spellcaster:SetSpellFn(summoning)
    inst.components.spellcaster:SetSpellTestFn(cansummon)
    inst.components.spellcaster.canuseonpoint = true
    inst.components.spellcaster.canusefrominventory = false
	inst:AddTag("nocool")

end 

local function OnClose(inst) 
  inst.SoundEmitter:PlaySound("dontstarve/common/fireOut")
	inst.components.talker:Say("-[Frost Hammer]\nSpeed up\nCooling ice box\n\n")
    inst.components.equippable.walkspeedmult = 0.8
       inst:RemoveComponent("spellcaster")
      inst:RemoveComponent("heater")
	inst:RemoveTag("nocool")

end 

local slotpos_2 = {}

for y = 0, 1 do
table.insert(slotpos_2, Vector3(-126, -y*75 + 114 ,-126 +75, -y*75 + 114 ))

	--table.insert(slotpos_2, Vector3(-162, -y*75 + 114 ,0))
	--table.insert(slotpos_2, Vector3( -162 +75, -y*75 + 114 ,0))

end



local function itemtest(inst, item, slot)
	if not item:HasTag("tstonehammer") then
			return true
end
end

local function fn(Sim)

	local inst = CreateEntity()
	local trans = inst.entity:AddTransform()
	local anim = inst.entity:AddAnimState()
	inst.entity:AddSoundEmitter()

    MakeInventoryPhysics(inst)

 --   anim:SetBank("hammer")
    anim:SetBank("umbrella")

    anim:SetBuild("frosthammer")
    anim:PlayAnimation("idle")
     
    inst:AddComponent("weapon")
    inst.components.weapon:SetOnAttack(Upgradedamage)

    inst.components.weapon:SetRange(1.65)
	
  inst.components.weapon:SetOnAttack(onattack_FROST)
  

    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("tool")
    inst.components.tool:SetAction(ACTIONS.HAMMER)
    -------
    -------
    
    inst:AddComponent("inspectable")
    
    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem:SetOnDroppedFn(OnDropped)
    inst.components.inventoryitem:SetOnPutInInventoryFn(OnPutInInventory)
    	inst.components.inventoryitem.atlasname = "images/inventoryimages/frosthammer.xml"
     inst.entity:AddMiniMapEntity()
	inst.MiniMapEntity:SetIcon( "frosthammer.tex" )
   ---------------------  
	inst:AddTag("fridge")
         inst:AddTag("metal")
     ----------------------
    inst:AddComponent("container")
    inst.components.container.itemtestfn = itemtest
    inst.components.container:SetNumSlots(#slotpos_2)
    inst.components.container.onopenfn = OnOpen
    inst.components.container.onclosefn = OnClose
    
    inst.components.container.widgetslotpos = slotpos_2
    inst.components.container.widgetanimbank = "ui_backpack_2x4"
    inst.components.container.widgetanimbuild = "ui_frostsmall"

   -- inst.components.container.widgetpos = Vector3(120,-180,0)
   -- inst.components.container.widgetpos = Vector3(-5,-50,0)
   -- inst.components.container.widgetpos = Vector3(-9,75,0)
inst.components.container.widgetpos = Vector3(-5,-50,0)
    inst.components.container.side_widget = true

    --inst.components.container.side_align_tip = 160
   -- inst.components.container.acceptsstacks = false
    inst.components.container.type = "pack"

------------------------
        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:AddComponent("equippable")

    inst.components.equippable:SetOnEquip( onequip )
    inst.components.equippable:SetOnUnequip( onunequip )

    inst.components.equippable.walkspeedmult = 0.7
    inst.components.equippable.runspeedmult = 0.7

    inst:AddComponent("reticule")
    inst.components.reticule.targetfn = function() 
        return Vector3(GetPlayer().entity:LocalToWorldSpace(5,0,0))
    end
    inst.components.reticule.ease = true

    inst:AddTag("nopunch")
inst:AddTag("level1")
	inst.level = 0
inst:ListenForEvent("levelup", levelexp)
	inst.OnSave = onsave
	inst.OnPreLoad = onpreload

    return inst
end


return Prefab( "common/inventory/frosthammer", fn, assets, prefabs) 
