local MakePlayerCharacter = require "prefabs/player_common"

local assets = {
        Asset( "ANIM", "anim/player_basic.zip" ),
        Asset( "ANIM", "anim/player_idles_shiver.zip" ),
        Asset( "ANIM", "anim/player_actions.zip" ),
        Asset( "ANIM", "anim/player_actions_axe.zip" ),
        Asset( "ANIM", "anim/player_actions_pickaxe.zip" ),
        Asset( "ANIM", "anim/player_actions_shovel.zip" ),
        Asset( "ANIM", "anim/player_actions_blowdart.zip" ),
        Asset( "ANIM", "anim/player_actions_eat.zip" ),
        Asset( "ANIM", "anim/player_actions_item.zip" ),
        Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ),
        Asset( "ANIM", "anim/player_actions_bugnet.zip" ),
        Asset( "ANIM", "anim/player_actions_fishing.zip" ),
        Asset( "ANIM", "anim/player_actions_boomerang.zip" ),
        Asset( "ANIM", "anim/player_bush_hat.zip" ),
        Asset( "ANIM", "anim/player_attacks.zip" ),
        Asset( "ANIM", "anim/player_idles.zip" ),
        Asset( "ANIM", "anim/player_rebirth.zip" ),
        Asset( "ANIM", "anim/player_jump.zip" ),
        Asset( "ANIM", "anim/player_amulet_resurrect.zip" ),
        Asset( "ANIM", "anim/player_teleport.zip" ),
        Asset( "ANIM", "anim/wilson_fx.zip" ),
        Asset( "ANIM", "anim/player_one_man_band.zip" ),
        Asset( "ANIM", "anim/shadow_hands.zip" ),
        Asset( "SOUND", "sound/sfx.fsb" ),
        Asset( "SOUND", "sound/maxwell.fsb" ),
	Asset("SOUND", "sound/willow.fsb"),    
        Asset( "ANIM", "anim/beard.zip" ),

        Asset( "ANIM", "anim/musha_battle.zip" ),
        Asset( "ANIM", "anim/musha.zip" ),
        Asset( "ANIM", "anim/musha_normal.zip" ),
Asset( "ANIM", "anim/musha_hunger.zip" ),
}
local prefabs = {
	"shadowmusha",
        "book_birds",
        "book_tentacles",
        "book_gardening",
        "book_sleep",
        "book_brimstone",
}

local start_inv = 
{
      "musha_small",
 --     "musha_egg",
      "broken_frosthammer",
   --   "frosthammer",
   --   "hat_mbunny",
   --   "hat_mcrown",
     "hat_mprincess",
   --   "armor_mushaa",
   --   "armor_mushab",
--	"mushasword_base",
--	"mushasword",
--	"mushasword2",
--	"mushasword3",
--	"mushasword4",
--	"musha_flute",
	"glowdust",
	"glowdust",
	"glowdust",
		"glowdust",
			"glowdust",
--	"cristal",
}
			
local function stamina_sleep(inst,data)
local max_stamina = 100
local stamina = math.min(inst.stamina, max_stamina)
 end
local function fatigue_sleep(inst,data)
local max_fatigue = 100
local fatigue = math.min(inst.fatigue, max_fatigue)
 end
local function fullcharged_music(inst)
local max_music = 100
local music = math.min(inst.music, max_music)
 end
 
local function check_music(inst)
local chrged_time = 2
local chrging_timer = 0
	inst.time_perfomance = inst:DoPeriodicTask(0.1,function(inst)
		chrging_timer = chrging_timer + 1
		if chrging_timer > chrged_time then
		if inst:HasTag("dsleep_veasy") then
	inst.music = inst.music + 2.5
	elseif inst:HasTag("dsleep_easy") then
	inst.music = inst.music + 1.5
	elseif inst:HasTag("dsleep_normal") then
	inst.music = inst.music + 1
	elseif inst:HasTag("dsleep_hard") then
	inst.music = inst.music + 0.5
	elseif inst:HasTag("dsleep_hardcore") then
	inst.music = inst.music + 0.25
		end
			fullcharged_music(inst)
		end
		if inst.time_perfomance and (chrging_timer > chrged_time)  then
			inst.time_perfomance:Cancel()
			inst.time_perfomance = nil
		end	end)
	end
	
local function levelexp(inst,data)

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

	--local hunger_percent = inst.components.hunger:GetPercent()
	local health_percent = inst.components.health:GetPercent()
	local sanity_percent = inst.components.sanity:GetPercent()

	--inst.components.hunger.max = math.ceil (200 + exp* 0.02)
	--inst.components.health.maxhealth = math.ceil (50 + exp* 0.05)
	--inst.components.sanity.max = math.ceil (100 + exp* 0.05)
	
	inst.components.talker:Say("[EXP] \n".. (inst.level))
 --inst.components.talker:Say("[Next : Level Up] \n EXP ".. (inst.level))

--[test]
--[[
if inst.level >0 then
inst:AddTag("level1")
	inst:AddTag("healshield1")
	inst:AddTag("hitcritical1")
	inst:AddTag("Valkyrie")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("fshield1")
	inst:AddTag("hpregen1")
	inst:AddTag("hitfreeze1")
	inst:AddTag("lessercure1")
	inst:AddTag("cure0")
 	inst:AddTag("berserkarmor")
 	inst:AddTag("shadowimage")
 	inst:AddTag("backstab")

]]--
			if inst.level >0 and inst.level <= 4 then
--inst.components.talker:Say("Next :EXP[5]\n[EXP] ".. (inst.level))
inst:AddTag("level1")

			elseif inst.level >4 and inst.level <= 5 then
	inst.components.talker:Say("Level 2\n Unlock: [Ligntnig Shield]\n Unlock: [Shield]")
	inst:AddTag("healshield1")
	inst:AddTag("cure0")
	inst:AddTag("level2")
	inst:RemoveTag("level1")

inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")


			elseif inst.level >5 and inst.level <= 9 then
--inst.components.talker:Say("Next :EXP[10]\n[EXP] + ".. (inst.level))
	inst:AddTag("healshield1")
	inst:AddTag("cure0")
	inst:AddTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >9 and inst.level <= 10 then
	inst.components.talker:Say("Level 3\n Unlock:[Valkyrie Phase]\n1/1")
	inst:AddTag("Valkyrie")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("healshield1")
	inst:AddTag("cure0")
	inst:AddTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >10 and inst.level <= 29 then
--inst.components.talker:Say("Next :EXP[30]\n[EXP] + ".. (inst.level))
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("cure0")
	inst:AddTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >29 and inst.level <= 30 then
	inst.components.talker:Say("Level 4\n Unlock: [Critical Hit]\n1/4")
	inst:AddTag("hitcritical1")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("cure0")
	inst:AddTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level > 30 and inst.level <= 49  then
--inst.components.talker:Say("Next :EXP[50]\n[EXP] + ".. (inst.level))
	inst:AddTag("hitcritical1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("cure0")
	inst:AddTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >49 and inst.level <= 50 then
	inst.components.talker:Say("Level 5\n Unlock: [Lightning Strike]\n1/2")
	inst:AddTag("hitlightning1")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("hitcritical1")
	inst:AddTag("cure0")
	inst:AddTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")


			elseif inst.level >50 and inst.level <=79  then
--inst.components.talker:Say("Next :EXP[80]\n[EXP] + ".. (inst.level))
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("hitcritical1")
	inst:AddTag("cure0")
	inst:AddTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >79 and inst.level <= 80 then
	inst.components.talker:Say("Level 6\n Unlock : [Lesser Cure]\n1/2")
	inst:AddTag("lessercure1")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("hitcritical1")
	inst:AddTag("cure0")
	inst:AddTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >80 and inst.level <=124  then
--inst.components.talker:Say("Next :EXP[125]\n[EXP] + ".. (inst.level))
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("hitcritical1")
	inst:AddTag("cure0")
	inst:AddTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >124 and inst.level <= 125 then
	inst.components.talker:Say("Level 7\n Unlock: [Berserk Phase]\n1/1")
	inst:AddTag("Berserk")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("hitcritical1")
	inst:AddTag("cure0")
	inst:AddTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >125 and inst.level <=199  then
--inst.components.talker:Say("Next :EXP[200]\n[EXP] + ".. (inst.level))
inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("hitcritical1")
	inst:AddTag("cure0")
	inst:AddTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >199 and inst.level <= 200 then
	inst.components.talker:Say("Level 8\n Unlock : [Frame shield]\n1/4")
	inst:AddTag("fshield1")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("hitcritical1")
	inst:AddTag("cure0")
	inst:AddTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >200 and inst.level <=339  then
--inst.components.talker:Say("Next :EXP[340]\n[EXP] + ".. (inst.level))
	inst:AddTag("fshield1")
inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("hitcritical1")
	inst:AddTag("cure0")
	inst:AddTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
		elseif inst.level >339 and inst.level <= 340 then
	inst.components.talker:Say("Level 9\n Unlock : [HP Regenerate]\n1/4")
	inst:AddTag("hpregen1")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("hitcritical1")
	inst:AddTag("cure0")
	inst:AddTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >340 and inst.level <=429  then
--inst.components.talker:Say("Next :EXP[430]\n[EXP] + ".. (inst.level))
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("hitcritical1")
	inst:AddTag("cure0")
	inst:AddTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >429 and inst.level <= 430 then
	inst.components.talker:Say("Level 10\n Unlock :[Backstab] 1/3\n Unlock :[Freeze Hit] 1/4")
	inst:AddTag("hitfreeze1")
 	inst:AddTag("backstab1") 
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("hitcritical1")
	inst:AddTag("cure0")
	inst:AddTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >430 and inst.level <=529  then
--inst.components.talker:Say("Next :EXP[530]\n[EXP] + ".. (inst.level))
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("hitcritical1")
	inst:AddTag("cure0")
	inst:AddTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

		elseif inst.level >529 and inst.level <= 530 then
	inst.components.talker:Say("Level 11\n Unlock: [Critical Hit]\n2/4")
	inst:RemoveTag("hitcritical1")
	inst:AddTag("hitcritical2")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:AddTag("cure0")
	inst:AddTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

			elseif inst.level >530 and inst.level <=639  then
--inst.components.talker:Say("Next :EXP[640]\n[EXP] + ".. (inst.level))
	inst:AddTag("hitcritical2")
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:AddTag("cure0")
	inst:AddTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

		elseif inst.level >639 and inst.level <= 640 then
	inst.components.talker:Say("Level 12\n Unlock: [Critical Hit]\n3/4")
	inst:RemoveTag("hitcritical2")
	inst:AddTag("hitcritical3")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:AddTag("cure0")
	inst:AddTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

			elseif inst.level >640 and inst.level <=759  then
--inst.components.talker:Say("Next :EXP[760]\n[EXP] + ".. (inst.level))
	inst:AddTag("hitcritical3")
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:AddTag("cure0")
	inst:AddTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

		elseif inst.level >759 and inst.level <= 760 then
inst.components.talker:Say("Level 13\n Unlock: [Critical Hit Master]\n4/4")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("hitcritical4")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:AddTag("cure0")
	inst:AddTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

			elseif inst.level >760 and inst.level <=889  then
--inst.components.talker:Say("Next :EXP[890]\n[EXP] + ".. (inst.level))
	inst:AddTag("hitcritical4")
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:AddTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

		elseif inst.level >889 and inst.level <= 890 then
	inst.components.talker:Say("Level 14\n Unlock: [Ligntnig Shield]\n2/4")
	inst:RemoveTag("healshield1")
	inst:AddTag("healshield2")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("hitcritical4")
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

			elseif inst.level >890 and inst.level <=1029  then
--inst.components.talker:Say("Next :EXP[1030]\n[EXP] + ".. (inst.level))
	inst:AddTag("healshield2")
	inst:AddTag("hitcritical4")
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

		elseif inst.level >1029 and inst.level <= 1030 then
	inst.components.talker:Say("Level 15\n Unlock: [Ligntnig Shield]\n3/4")
	inst:RemoveTag("healshield2")
	inst:AddTag("healshield3")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("hitcritical4")
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

			elseif inst.level >1030 and inst.level <=1179  then
--inst.components.talker:Say("Next :EXP[1180]\n[EXP] + ".. (inst.level))
	inst:AddTag("healshield3")
	inst:AddTag("hitcritical4")
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

		elseif inst.level >1179 and inst.level <= 1180 then
inst.components.talker:Say("Level 16\n Unlock: [Ligntnig Shield Master]\n4/4")
	inst:RemoveTag("healshield3")
	inst:AddTag("healshield4")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("hitcritical4")
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

			elseif inst.level >1180 and inst.level <=1339  then
--inst.components.talker:Say("Next :EXP[1340]\n[EXP] + ".. (inst.level))
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("lessercure1")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

		elseif inst.level >1339 and inst.level <= 1340 then
inst.components.talker:Say("Level 17\n Unlock : [Lesser Cure Master]\n2/2")
	inst:RemoveTag("lessercure1")
	inst:AddTag("lessercure2")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

			elseif inst.level >1340 and inst.level <=1509  then
--inst.components.talker:Say("Next :EXP[1510]\n[EXP] + ".. (inst.level))
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

		elseif inst.level >1509 and inst.level <= 1510 then
	inst.components.talker:Say("Level 18\n Unlock : [Freeze Hit]\n2/4")
	inst:RemoveTag("hitfreeze1")
	inst:AddTag("hitfreeze2")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("hitfreeze1")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

			elseif inst.level >1510 and inst.level <=1689  then
--inst.components.talker:Say("Next :EXP[1690]\n[EXP] + ".. (inst.level))
	inst:AddTag("hitfreeze2")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

		elseif inst.level >1689 and inst.level <= 1690 then
inst.components.talker:Say("Level 19\n Unlock : [Freeze Hit]\n3/4")
	inst:RemoveTag("hitfreeze2")
	inst:AddTag("hitfreeze3")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

			elseif inst.level >1690 and inst.level <=1879  then
--inst.components.talker:Say("Next :EXP[1880]\n[EXP] + ".. (inst.level))
	inst:AddTag("hitfreeze3")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
 	inst:AddTag("backstab1") 

		elseif inst.level >1879 and inst.level <= 1880 then
inst.components.talker:Say("Level 20\n Unlock : Unlock : [Backstab] 2/3\n[Freeze Hit Master] 4/4")
	inst:RemoveTag("hitfreeze3")
	inst:AddTag("hitfreeze4")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level20")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >1880 and inst.level <=2079  then
--inst.components.talker:Say("Next :EXP[2080]\n[EXP] + ".. (inst.level))
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level20")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >2079 and inst.level <= 2080 then
	inst.components.talker:Say("Level 21\n Unlock : [HP Regenerate]\n2/4")
	inst:RemoveTag("hpregen1")
	inst:AddTag("hpregen2")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level21")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >2080 and inst.level <=2289  then
--inst.components.talker:Say("Next :EXP[2289]\n[EXP] + ".. (inst.level))
	inst:AddTag("hpregen2")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level21")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >2189 and inst.level <= 2290 then
	inst.components.talker:Say("Level 22\n Unlock : [HP Regenerate]\n3/4")
	inst:RemoveTag("hpregen2")
	inst:AddTag("hpregen3")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level22")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >2290 and inst.level <=2499  then
--inst.components.talker:Say("Next :EXP[2500]\n[EXP] + ".. (inst.level))
	inst:AddTag("hpregen3")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("hpregen1")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level22")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >2499 and inst.level <= 2500 then
	inst.components.talker:Say("Level 23\n Unlock : [Frame shield]\n2/4")
	inst:RemoveTag("fshield1")
	inst:AddTag("fshield2")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("hpregen3")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("hpregen1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level23")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >2500 and inst.level <=2849  then
--inst.components.talker:Say("Next :EXP[2850]\n[EXP] + ".. (inst.level))
	inst:AddTag("fshield2")
	inst:AddTag("hpregen3")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("fshield1")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level23")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >2849 and inst.level <= 2850 then
	inst.components.talker:Say("Level 24\n Unlock : [Frame shield]\n3/4")
	inst:RemoveTag("fshield2")
	inst:AddTag("fshield3")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("hpregen3")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("fshield1")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level24")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level23")
	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >2850 and inst.level <=3199  then
--inst.components.talker:Say("Next :EXP[3200]\n[EXP] + ".. (inst.level))
	inst:AddTag("fshield3")
	inst:AddTag("hpregen3")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("fshield2")
	inst:RemoveTag("fshield1")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level24")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level23")
	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >3199 and inst.level <= 3200 then
inst.components.talker:Say("Level 25\n Unlock : [Frame shield Master]\n4/4")
	inst:RemoveTag("fshield3")
	inst:AddTag("fshield4")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("hpregen3")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("fshield2")
	inst:RemoveTag("fshield1")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level25")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level24")
	inst:RemoveTag("level23")
	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >3200 and inst.level <=3699  then
--inst.components.talker:Say("Next :EXP[3700]\n[EXP] + ".. (inst.level))
	inst:AddTag("fshield4")
	inst:AddTag("hpregen3")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("fshield3")
	inst:RemoveTag("fshield2")
	inst:RemoveTag("fshield1")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:AddTag("cure0")
	inst:AddTag("level25")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level24")
	inst:RemoveTag("level23")
	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >3699 and inst.level <= 3700 then
inst.components.talker:Say("Level 26\n Unlock : [Shield]\n2/3")
	inst:AddTag("cure1")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("fshield4")
	inst:AddTag("hpregen3")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("fshield3")
	inst:RemoveTag("fshield2")
	inst:RemoveTag("fshield1")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:RemoveTag("cure0")
	inst:AddTag("level26")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level25")
	inst:RemoveTag("level24")
	inst:RemoveTag("level23")
	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >3700 and inst.level <=4199  then
--inst.components.talker:Say("Next :EXP[4200]\n[EXP] + ".. (inst.level))
	inst:AddTag("cure1")
	inst:AddTag("fshield4")
	inst:AddTag("hpregen3")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("fshield3")
	inst:RemoveTag("fshield2")
	inst:RemoveTag("fshield1")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:RemoveTag("cure0")
	inst:AddTag("level26")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level25")
	inst:RemoveTag("level24")
	inst:RemoveTag("level23")
	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >4199 and inst.level <= 4200 then
inst.components.talker:Say("Level 27\n Unlock : [Shield Master]\n3/3")
	inst:RemoveTag("cure1")
	inst:AddTag("cure2")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("fshield4")
	inst:AddTag("hpregen3")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("fshield3")
	inst:RemoveTag("fshield2")
	inst:RemoveTag("fshield1")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:RemoveTag("cure0")
	inst:AddTag("level27")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level26")
	inst:RemoveTag("level25")
	inst:RemoveTag("level24")
	inst:RemoveTag("level23")
	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >4200 and inst.level <=4699  then
--inst.components.talker:Say("Next :EXP[4700]\n[EXP] + ".. (inst.level))
	inst:AddTag("cure2")
	inst:AddTag("fshield4")
	inst:AddTag("hpregen3")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("fshield3")
	inst:RemoveTag("fshield2")
	inst:RemoveTag("fshield1")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:RemoveTag("cure1")
	inst:RemoveTag("cure0")
	inst:AddTag("level27")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level26")
	inst:RemoveTag("level25")
	inst:RemoveTag("level24")
	inst:RemoveTag("level23")
	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >4699 and inst.level <= 4700 then
inst.components.talker:Say("Level 28\n Unlock : [Double Damage]\n1/1")
	inst:AddTag("berserkarmor")

inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("cure2")
	inst:AddTag("fshield4")
	inst:AddTag("hpregen3")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("fshield3")
	inst:RemoveTag("fshield2")
	inst:RemoveTag("fshield1")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:RemoveTag("cure1")
	inst:RemoveTag("cure0")
	inst:AddTag("level28")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level27")
	inst:RemoveTag("level26")
	inst:RemoveTag("level25")
	inst:RemoveTag("level24")
	inst:RemoveTag("level23")
	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >4700 and inst.level <=5499  then
--inst.components.talker:Say("Next :EXP[5500]\n[EXP] + ".. (inst.level))
	inst:AddTag("cure2")
	inst:AddTag("fshield4")
	inst:AddTag("hpregen3")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("fshield3")
	inst:RemoveTag("fshield2")
	inst:RemoveTag("fshield1")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:RemoveTag("cure1")
 	inst:AddTag("berserkarmor")
	inst:RemoveTag("cure0")
	inst:AddTag("level28")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level27")
	inst:RemoveTag("level26")
	inst:RemoveTag("level25")
	inst:RemoveTag("level24")
	inst:RemoveTag("level23")
	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >5499 and inst.level <= 5500 then
	inst.components.talker:Say("Level 29\n Unlock : [HP Regenerate Master]\n4/4")
	inst:RemoveTag("hpregen3")
	inst:AddTag("hpregen4")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("cure2")
	inst:AddTag("fshield4")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("fshield3")
	inst:RemoveTag("fshield2")
	inst:RemoveTag("fshield1")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:RemoveTag("cure1")
 	inst:AddTag("berserkarmor")
	inst:RemoveTag("cure0")
	inst:AddTag("level29")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level28")
	inst:RemoveTag("level27")
	inst:RemoveTag("level26")
	inst:RemoveTag("level25")
	inst:RemoveTag("level24")
	inst:RemoveTag("level23")
	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

			elseif inst.level >5500 and inst.level <=6999  then
--inst.components.talker:Say("Next :EXP[7000]\n[EXP] + ".. (inst.level))
	inst:AddTag("hpregen4")
	inst:AddTag("cure2")
	inst:AddTag("fshield4")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("hitlightning1")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("fshield3")
	inst:RemoveTag("fshield2")
	inst:RemoveTag("fshield1")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:RemoveTag("cure1")
	inst:RemoveTag("hpregen3")
 	inst:AddTag("berserkarmor")
	inst:RemoveTag("cure0")
	inst:AddTag("level29")
 	inst:AddTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level28")
	inst:RemoveTag("level27")
	inst:RemoveTag("level26")
	inst:RemoveTag("level25")
	inst:RemoveTag("level24")
	inst:RemoveTag("level23")
	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

		elseif inst.level >6999 and inst.level <= 7000 then
inst.components.talker:Say("Level 30\n Unlock : [Lightning Strike Master] 2/2\n Unlock : [Backstab Master]3/3\n Unlock : [Shadow image]1/1")
	inst:RemoveTag("hitlightning1")
	inst:AddTag("hitlightning2")
inst.SoundEmitter:PlaySound("dontstarve/common/cookingpot_finish", "snd")
inst.SoundEmitter:PlaySound("dontstarve/wilson/equip_item_gold")
	inst:AddTag("hpregen4")
	inst:AddTag("cure2")
	inst:AddTag("fshield4")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("fshield3")
	inst:RemoveTag("fshield2")
	inst:RemoveTag("fshield1")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:RemoveTag("cure1")
	inst:RemoveTag("hpregen3")
 	inst:AddTag("berserkarmor")
	inst:RemoveTag("cure0")
 	inst:AddTag("shadowb")
	inst:AddTag("level30")
 	inst:AddTag("backstab3") 
 	inst:RemoveTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level29")
	inst:RemoveTag("level28")
	inst:RemoveTag("level27")
	inst:RemoveTag("level26")
	inst:RemoveTag("level25")
	inst:RemoveTag("level24")
	inst:RemoveTag("level23")
	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")

---
		elseif inst.level > 7000 then
	inst:AddTag("hitlightning2")
	inst:AddTag("hpregen4")
	inst:AddTag("cure2")
	inst:AddTag("fshield4")
	inst:AddTag("hitfreeze4")
	inst:AddTag("lessercure2")
	inst:AddTag("healshield4")
	inst:AddTag("hitcritical4")
	inst:AddTag("fshield1")
	inst:AddTag("Berserk")
	inst:AddTag("Valkyrie")
	inst:RemoveTag("hitlightning1")
	inst:RemoveTag("fshield3")
	inst:RemoveTag("fshield2")
	inst:RemoveTag("fshield1")
	inst:RemoveTag("hpregen2")
	inst:RemoveTag("hpregen1")
	inst:RemoveTag("hitfreeze3")
	inst:RemoveTag("hitfreeze2")
	inst:RemoveTag("hitfreeze1")
	inst:RemoveTag("lessercure1")
	inst:RemoveTag("healshield3")
	inst:RemoveTag("healshield2")
	inst:RemoveTag("healshield1")
	inst:RemoveTag("hitcritical1")
	inst:RemoveTag("hitcritical2")
	inst:RemoveTag("hitcritical3")
	inst:RemoveTag("cure1")
	inst:RemoveTag("hpregen3")
 	inst:AddTag("berserkarmor")
	inst:RemoveTag("cure0")
	inst:AddTag("level30")
 	inst:AddTag("shadowb")
 	inst:AddTag("backstab3") 
 	inst:RemoveTag("backstab2") 
 	inst:RemoveTag("backstab1") 

	inst:RemoveTag("level29")
	inst:RemoveTag("level28")
	inst:RemoveTag("level27")
	inst:RemoveTag("level26")
	inst:RemoveTag("level25")
	inst:RemoveTag("level24")
	inst:RemoveTag("level23")
	inst:RemoveTag("level22")
	inst:RemoveTag("level21")
	inst:RemoveTag("level20")
	inst:RemoveTag("level19")
	inst:RemoveTag("level18")
	inst:RemoveTag("level17")
	inst:RemoveTag("level16")
	inst:RemoveTag("level15")
	inst:RemoveTag("level14")
	inst:RemoveTag("level13")
	inst:RemoveTag("level12")
	inst:RemoveTag("level11")
	inst:RemoveTag("level10")
	inst:RemoveTag("level9")
	inst:RemoveTag("level8")
	inst:RemoveTag("level7")
	inst:RemoveTag("level6")
	inst:RemoveTag("level5")
	inst:RemoveTag("level4")
	inst:RemoveTag("level3")
	inst:RemoveTag("level2")
	inst:RemoveTag("level1")
	end

		if inst:HasTag("normalh") then
--level1~5
		if inst.level < 51 then
	inst.components.health.maxhealth = math.ceil (60 + exp* 0.5)
	inst.components.sanity.max = math.ceil (100 + exp* 0.3)
--level5~10(380)
		elseif inst.level >= 51 and inst.level <431 then
	inst.components.health.maxhealth = math.ceil (85 + exp* 0.2)
	inst.components.sanity.max = math.ceil (115 + exp* 0.2)
--level10~15(500)
		elseif inst.level >= 431 and inst.level <1031 then
	inst.components.health.maxhealth = math.ceil (161 + exp* 0.1)
	inst.components.sanity.max = math.ceil (191 + exp* 0.1)
--level15~20(850)
		elseif inst.level >= 1031 and inst.level <1881 then
	inst.components.health.maxhealth = math.ceil (211 + exp* 0.05)
	inst.components.sanity.max = math.ceil (241 + exp* 0.05)
--level20~25(2320)
		elseif inst.level >= 1881 and inst.level <4201 then
	inst.components.health.maxhealth = math.ceil (254 + exp* 0.01)
	inst.components.sanity.max = math.ceil (284 + exp* 0.02)
--level25~30(2800)
		elseif inst.level >= 4201 and inst.level <7001 then
	inst.components.health.maxhealth = math.ceil (277+ exp* 0.01)
	inst.components.sanity.max = math.ceil (340 + exp* 0.02)
--level30~
		elseif inst.level >= 7001 then
	inst.components.health.maxhealth = math.ceil (305 + exp* 0.005)
	inst.components.sanity.max = math.ceil (396 + exp* 0.01)
	end

		elseif inst:HasTag("hardh") then
--level1~5
		if inst.level < 51 then
	inst.components.health.maxhealth = math.ceil (50 + exp* 0.25)
	inst.components.sanity.max = math.ceil (100 + exp* 0.3)
--level5~10(380)
		elseif inst.level >= 51 and inst.level <431 then
	inst.components.health.maxhealth = math.ceil (63 + exp* 0.1)
	inst.components.sanity.max = math.ceil (115 + exp* 0.2)
--level10~15(500)
		elseif inst.level >= 431 and inst.level <1031 then
	inst.components.health.maxhealth = math.ceil (101 + exp* 0.05)
	inst.components.sanity.max = math.ceil (191 + exp* 0.1)
--level15~20(850)
		elseif inst.level >= 1031 and inst.level <1881 then
	inst.components.health.maxhealth = math.ceil (151 + exp* 0.025)
	inst.components.sanity.max = math.ceil (241 + exp* 0.05)
--level20~25(2320)
		elseif inst.level >= 1881 and inst.level <4201 then
	inst.components.health.maxhealth = math.ceil (173 + exp* 0.02)
	inst.components.sanity.max = math.ceil (284 + exp* 0.02)
--level25~30(2800)
		elseif inst.level >= 4201 then
	inst.components.health.maxhealth = math.ceil (220 + exp* 0.01)
	inst.components.sanity.max = math.ceil (340 + exp* 0.01)
--level30~
		elseif inst.level >= 7001 then
	inst.components.health.maxhealth = math.ceil (248 + exp* 0.005)
	inst.components.sanity.max = math.ceil (368 + exp* 0.01)
	end

		elseif inst:HasTag("hardcoreh") then
--level1~5
		if inst.level < 51 then
	inst.components.health.maxhealth = math.ceil (40 + exp* 0.25)
	inst.components.sanity.max = math.ceil (80 + exp* 0.3)
--level5~10(380)
		elseif inst.level >= 51 and inst.level <431 then
	inst.components.health.maxhealth = math.ceil (53 + exp* 0.1)
	inst.components.sanity.max = math.ceil (95 + exp* 0.2)
--level10~15(500)
		elseif inst.level >= 431 and inst.level <1031 then
	inst.components.health.maxhealth = math.ceil (91 + exp* 0.05)
	inst.components.sanity.max = math.ceil (171 + exp* 0.1)
--level15~20(850)
		elseif inst.level >= 1031 and inst.level <1881 then
	inst.components.health.maxhealth = math.ceil (141 + exp* 0.025)
	inst.components.sanity.max = math.ceil (221 + exp* 0.05)
--level20~25(2320)
		elseif inst.level >= 1881 and inst.level <4201 then
	inst.components.health.maxhealth = math.ceil (163 + exp* 0.02)
	inst.components.sanity.max = math.ceil (264 + exp* 0.02)
--level25~30(2800)
		elseif inst.level >= 4201 then
	inst.components.health.maxhealth = math.ceil (210 + exp* 0.005)
	inst.components.sanity.max = math.ceil (320 + exp* 0.01)
--level30~
		elseif inst.level >= 7001 then
	inst.components.health.maxhealth = math.ceil (224 + exp* 0.005)
	inst.components.sanity.max = math.ceil (348 + exp* 0.005)
	end

		elseif inst:HasTag("hellh") then

--level1~5
		if inst.level < 51 then
	inst.components.health.maxhealth = math.ceil (40 + exp* 0.25)
	inst.components.sanity.max = math.ceil (80 + exp* 0.3)
--level5~10(380)
		elseif inst.level >= 51 and inst.level <431 then
	inst.components.health.maxhealth = math.ceil (53 + exp* 0.1)
	inst.components.sanity.max = math.ceil (95 + exp* 0.2)
--level10~15(500)
		elseif inst.level >= 431 and inst.level <1031 then
	inst.components.health.maxhealth = math.ceil (91 + exp* 0.05)
	inst.components.sanity.max = math.ceil (171 + exp* 0.1)
--level15~20(850)
		elseif inst.level >= 1031 and inst.level <1881 then
	inst.components.health.maxhealth = math.ceil (141 + exp* 0.025)
	inst.components.sanity.max = math.ceil (221 + exp* 0.05)
--level20~25(2320)
		elseif inst.level >= 1881 and inst.level then
	inst.components.health.maxhealth = math.ceil (163 + exp* 0.005)
	inst.components.sanity.max = math.ceil (264 + exp* 0.005)
--level25~30(2800)
--level30~
	end

		elseif inst:HasTag("easyh") then
--level1~5
		if inst.level < 51 then
	inst.components.health.maxhealth = math.ceil (75 + exp* 0.5)
	inst.components.sanity.max = math.ceil (120 + exp* 0.3)
--level5~10(380)
		elseif inst.level >= 51 and inst.level <431 then
	inst.components.health.maxhealth = math.ceil (100 + exp* 0.2)
	inst.components.sanity.max = math.ceil (135 + exp* 0.2)
--level10~15(500)
		elseif inst.level >= 431 and inst.level <1031 then
	inst.components.health.maxhealth = math.ceil (176 + exp* 0.1)
	inst.components.sanity.max = math.ceil (211 + exp* 0.1)
--level15~20(850)
		elseif inst.level >= 1031 and inst.level <1881 then
	inst.components.health.maxhealth = math.ceil (226 + exp* 0.05)
	inst.components.sanity.max = math.ceil (261 + exp* 0.05)
--level20~25(2320)
		elseif inst.level >= 1881 and inst.level <4201 then
	inst.components.health.maxhealth = math.ceil (269 + exp* 0.02)
	inst.components.sanity.max = math.ceil (304 + exp* 0.02)
--level25~30(2800)
		elseif inst.level >= 4201 and inst.level <7001 then
	inst.components.health.maxhealth = math.ceil (315 + exp* 0.01)
	inst.components.sanity.max = math.ceil (360 + exp* 0.02)
--level30~
		elseif inst.level >= 7001 then
	inst.components.health.maxhealth = math.ceil (343 + exp* 0.005)
	inst.components.sanity.max = math.ceil (416 + exp* 0.01)
	end

		elseif inst:HasTag("veasyh") then
--level1~5
		if inst.level < 51 then
	inst.components.health.maxhealth = math.ceil (100 + exp* 0.5)
	inst.components.sanity.max = math.ceil (150 + exp* 0.3)
--level5~10(380)
		elseif inst.level >= 51 and inst.level <431 then
	inst.components.health.maxhealth = math.ceil (175 + exp* 0.2)
	inst.components.sanity.max = math.ceil (165 + exp* 0.2)
--level10~15(500)
		elseif inst.level >= 431 and inst.level <1031 then
	inst.components.health.maxhealth = math.ceil (251 + exp* 0.1)
	inst.components.sanity.max = math.ceil (241 + exp* 0.1)
--level15~20(850)
		elseif inst.level >= 1031 and inst.level <1881 then
	inst.components.health.maxhealth = math.ceil (301 + exp* 0.05)
	inst.components.sanity.max = math.ceil (291 + exp* 0.05)
--level20~25(2320)
		elseif inst.level >= 1881 and inst.level <4201 then
	inst.components.health.maxhealth = math.ceil (344 + exp* 0.02)
	inst.components.sanity.max = math.ceil (334 + exp* 0.02)
--level25~30(2800)
		elseif inst.level >= 4201 and inst.level <7001 then
	inst.components.health.maxhealth = math.ceil (390 + exp* 0.01)
	inst.components.sanity.max = math.ceil (390 + exp* 0.02)
--level30~
		elseif inst.level >= 7001 then
	inst.components.health.maxhealth = math.ceil (418 + exp* 0.01)
	inst.components.sanity.max = math.ceil (446 + exp* 0.01)
	end

	--inst.components.hunger:SetPercent(hunger_percent)
	inst.components.health:SetPercent(health_percent)
	inst.components.sanity:SetPercent(sanity_percent)
end
end
---
local exp1x = 0.1
local exp2x = 0.4
local exp3x = 0.6
local exp4x = 0.7
local tynychance = 0.05
local smallllchance = 0.1
local smallchance = 0.2
local normalchance = 0.3
local largechance = 0.7
local berserkchance = 0.25
local foodnormalchance = 0.4
local foodgoodchance = 0.6
local foodlargechance = 0.8

local function onkilll(inst, data)
	if data.cause == inst.prefab and not data.inst:HasTag("companion") then
                if math.random() < normalchance and data.inst:HasTag("prey") then
        			inst.level = inst.level + 1
	levelexp(inst)	

	elseif math.random() < largechance and not data.inst:HasTag("prey") and not data.inst:HasTag("eyeplant") and not data.inst:HasTag("insect") and not data.inst:HasTag("arm") and not data.inst:HasTag("giant1x") and not data.inst:HasTag("giant2x") and not data.inst:HasTag("giant3x") and not data.inst:HasTag("giant4x") and not data.inst:HasTag("small_giant2x") and not data.inst:HasTag("small_giant3x") and not data.inst:HasTag("small_giant4x") and not data.inst:HasTag("wall") then
    				inst.level = inst.level + 1
	levelexp(inst)

	elseif math.random() < tynychance and data.inst:HasTag("insect") then
    				inst.level = inst.level + 1
	levelexp(inst)

	elseif math.random() < smallllchance and data.inst:HasTag("eyeplant") then
    				inst.level = inst.level + 1
	levelexp(inst)

	elseif math.random() < smallllchance and data.inst:HasTag("arm") then
    				inst.level = inst.level + 1
	levelexp(inst)

------extra
	elseif math.random() < exp1x and data.inst:HasTag("spider1x") then
	local fx = SpawnPrefab("statue_transition")
	local fx2 = SpawnPrefab("exp")
        		fx.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx2.Transform:SetPosition(data.inst:GetPosition():Get())
	elseif math.random() < exp1x and data.inst:HasTag("hound1x") then
	local fx = SpawnPrefab("statue_transition")
	local fx2 = SpawnPrefab("exp")
        		fx.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx2.Transform:SetPosition(data.inst:GetPosition():Get())

	elseif math.random() < exp2x and data.inst:HasTag("spider2x") then
	local fx = SpawnPrefab("statue_transition")
	local fx2 = SpawnPrefab("exp")
        		fx.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx2.Transform:SetPosition(data.inst:GetPosition():Get())
	elseif math.random() < exp3x and data.inst:HasTag("spider3x") then
	local fx = SpawnPrefab("statue_transition")
	local fx2 = SpawnPrefab("exp")
        		fx.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx2.Transform:SetPosition(data.inst:GetPosition():Get())
	elseif math.random() < exp4x and data.inst:HasTag("spider4x") then
	local fx = SpawnPrefab("statue_transition")
	local fx2 = SpawnPrefab("exp")
        		fx.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx2.Transform:SetPosition(data.inst:GetPosition():Get())
	elseif math.random() < exp2x and data.inst:HasTag("hound2x") then
	local fx = SpawnPrefab("statue_transition")
	local fx2 = SpawnPrefab("exp")
        		fx.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx2.Transform:SetPosition(data.inst:GetPosition():Get())
	elseif math.random() < exp3x and data.inst:HasTag("hound3x") then
	local fx = SpawnPrefab("statue_transition")
	local fx2 = SpawnPrefab("exp")
        		fx.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx2.Transform:SetPosition(data.inst:GetPosition():Get())
	elseif math.random() < exp4x and data.inst:HasTag("hound4x") then
	local fx = SpawnPrefab("statue_transition")
	local fx2 = SpawnPrefab("exp")
        		fx.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx2.Transform:SetPosition(data.inst:GetPosition():Get())

	elseif data.inst:HasTag("giant1x") then
	local fx = SpawnPrefab("statue_transition")
	local fx2 = SpawnPrefab("redgem")
	local fx3 = SpawnPrefab("bluegem")
	local fx4 = SpawnPrefab("glowdust")
        		fx.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx2.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx3.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx4.Transform:SetPosition(data.inst:GetPosition():Get())
    				inst.level = inst.level + 10
	levelexp(inst)
	inst.components.talker:Say("extra [EXP](+10) \n".. (inst.level))

	elseif data.inst:HasTag("giant2x") then
	local fx = SpawnPrefab("statue_transition")
	local fx2 = SpawnPrefab("redgem")
	local fx3 = SpawnPrefab("bluegem")
	local fx4 = SpawnPrefab("hat_mprincess")
        		fx.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx2.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx3.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx4.Transform:SetPosition(data.inst:GetPosition():Get())
    				inst.level = inst.level + 20
	levelexp(inst)
	inst.components.talker:Say("extra [EXP](+20) \n".. (inst.level))

	elseif data.inst:HasTag("giant3x") then
	local fx = SpawnPrefab("statue_transition")
	local fx2 = SpawnPrefab("redgem")
	local fx3 = SpawnPrefab("bluegem")
	local fx4 = SpawnPrefab("hat_mcrown")
        		fx.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx2.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx3.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx4.Transform:SetPosition(data.inst:GetPosition():Get())
    				inst.level = inst.level + 30
	levelexp(inst)
	inst.components.talker:Say("extra [EXP](+30) \n".. (inst.level))

	elseif data.inst:HasTag("giant4x") then
	local fx = SpawnPrefab("statue_transition")
	local fx2 = SpawnPrefab("redgem")
	local fx3 = SpawnPrefab("bluegem")
	local fx4 = SpawnPrefab("hat_mcrown")
	local fx5 = SpawnPrefab("armor_mushaa")
        		fx.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx2.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx3.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx4.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx5.Transform:SetPosition(data.inst:GetPosition():Get())
    				inst.level = inst.level + 40
	levelexp(inst)
	inst.components.talker:Say("extra [EXP](+40) \n".. (inst.level))

	elseif data.inst:HasTag("small_giant2x") then
	local fx = SpawnPrefab("statue_transition")
	local fx2 = SpawnPrefab("exp")
        		fx.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx2.Transform:SetPosition(data.inst:GetPosition():Get())
	local fx3 = SpawnPrefab("glowdust")
        		fx3.Transform:SetPosition(data.inst:GetPosition():Get())
    				inst.level = inst.level + 5
	levelexp(inst)
	inst.components.talker:Say("extra [EXP](+4) \n".. (inst.level))

	elseif data.inst:HasTag("small_giant3x") then
	local fx = SpawnPrefab("statue_transition")
	local fx2 = SpawnPrefab("exp")
        		fx.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx2.Transform:SetPosition(data.inst:GetPosition():Get())
	local fx3 = SpawnPrefab("glowdust")
        		fx3.Transform:SetPosition(data.inst:GetPosition():Get())
    				inst.level = inst.level + 8
	levelexp(inst)
	inst.components.talker:Say("extra [EXP](+8) \n".. (inst.level))
	elseif data.inst:HasTag("small_giant4x") then
	local fx = SpawnPrefab("statue_transition")
	local fx2 = SpawnPrefab("exp")
        		fx.Transform:SetPosition(data.inst:GetPosition():Get())
        		fx2.Transform:SetPosition(data.inst:GetPosition():Get())
	local fx3 = SpawnPrefab("glowdust")
        		fx3.Transform:SetPosition(data.inst:GetPosition():Get())
    				inst.level = inst.level + 12
	levelexp(inst)
	inst.components.talker:Say("extra [EXP](+12) \n".. (inst.level))

    			 end
		          end
			end

local function expeat(inst, food)

if food.components.edible.hungervalue >= 150 and food.components.edible.healthvalue >= 100 then 
if food.components.edible then
	inst.level = inst.level + 50
	levelexp(inst)
inst.components.talker:Say(" I Love Soup !! \nEXP + 50 ")
end
elseif food.components.edible.hungervalue > 100 or food.components.edible.healthvalue > 35 then 
if food.components.edible and math.random() < foodlargechance then
	inst.level = inst.level + 1
	levelexp(inst)
end
elseif food.components.edible.hungervalue > 55 or food.components.edible.healthvalue > 29 or food.components.edible.sanityvalue > 19 then 
if food.components.edible and math.random() < foodgoodchance then
	inst.level = inst.level + 1
	levelexp(inst)
end
elseif food.components.edible.hungervalue > 24 or food.components.edible.healthvalue > 19 or food.components.edible.sanityvalue > 14 then 
if food.components.edible and math.random() < foodnormalchance then
	inst.level = inst.level + 1
	levelexp(inst)
end
elseif food.components.edible.hungervalue > 9 or food.components.edible.healthvalue > 9 or food.components.edible.sanityvalue > 9 then 
if food.components.edible and math.random() < tynychance then
	inst.level = inst.level + 1
	levelexp(inst)
end
end
--force bersek
if inst:HasTag("berserk") then
	if string.find(tostring(food),"monsterm") then
 if math.random() < berserkchance then 
		 	inst:AddTag("fberserk") 

	end
	end
end
end


local function flower_shield(inst, attacked, data) 
if not inst.components.health:IsDead() and inst:HasTag("DLC") then
    if inst.strength == "Valkyrie" then
	SpawnPrefab("purple_leaves_chop").Transform:SetPosition(inst:GetPosition():Get())	
    elseif inst.strength == "normal" then
	SpawnPrefab("yellow_leaves_chop").Transform:SetPosition(inst:GetPosition():Get())
    elseif inst.strength == "full" then
	SpawnPrefab("orange_leaves_chop").Transform:SetPosition(inst:GetPosition():Get())
   -- elseif inst.strength == "berserk" then
	--SpawnPrefab("red_leaves_chop").Transform:SetPosition(inst:GetPosition():Get())
	end	end
end

local function on_music_act2(inst)
if inst.components.playercontroller then
inst:RemoveTag("Light_on")
inst.components.playercontroller:Enable(false)
inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" )
local flute = inst.sg:GoToState("play_flute")
inst.AnimState:PlayAnimation("flute")
inst.SoundEmitter:PlaySound("dontstarve/wilson/onemanband")

inst.entity:AddLight()
inst.Light:SetRadius(4)
inst.Light:SetFalloff(.7)
inst.Light:SetIntensity(.7)
inst.Light:SetColour(150/255,150/255,150/255)
--inst.components.health:SetAbsorptionAmount(1)
inst.music_armor = true inst:RemoveTag("switlight")  inst.nsleep = true
scheduler:ExecuteInTime(3, function() inst.SoundEmitter:PlaySound("dontstarve/wilson/onemanband") inst.sg:GoToState("play_flute")
scheduler:ExecuteInTime(3, function() inst.sg:GoToState("enter_onemanband")scheduler:ExecuteInTime(3, function() inst.SoundEmitter:PlaySound("dontstarve/wilson/onemanband") inst.sg:GoToState("play_flute")
scheduler:ExecuteInTime(3, function() inst.components.playercontroller:Enable(true) inst.AnimState:SetBloomEffectHandle("") inst.Light:Enable(true) inst.components.sanity:DoDelta(25) inst.music = inst.music * 0 inst.components.talker:Say("[Light Aura] -on !") SpawnPrefab("statue_transition_2").Transform:SetPosition(inst:GetPosition():Get()) SpawnPrefab("ghosthound").Transform:SetPosition(inst:GetPosition():Get()) SpawnPrefab("statue_transition_2").Transform:SetPosition(inst:GetPosition():Get()) SpawnPrefab("ghosthound").Transform:SetPosition(inst:GetPosition():Get()) inst.music_armor = false scheduler:ExecuteInTime(180, function() inst.components.talker:Say("[Light Aura] -off ") inst.SoundEmitter:PlaySound("dontstarve/common/fireOut") SpawnPrefab("statue_transition_2").Transform:SetPosition(inst:GetPosition():Get()) inst.Light:SetRadius(0.5) scheduler:ExecuteInTime(5, function()  if inst.nsleep then inst.Light:Enable(false) end inst.SoundEmitter:PlaySound("dontstarve/common/fireOut") inst.nsleep = false end) end)end)end)end)end)
end end

local function on_music_act1(inst)
if inst.components.playercontroller then
inst:RemoveTag("Light_on")
inst.components.playercontroller:Enable(false)
inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" )
local flute = inst.sg:GoToState("play_flute")
inst.AnimState:PlayAnimation("flute")
inst.SoundEmitter:PlaySound("dontstarve/wilson/onemanband")

inst.entity:AddLight()
inst.Light:SetRadius(5)
inst.Light:SetFalloff(.7)
inst.Light:SetIntensity(.7)
inst.Light:SetColour(150/255,150/255,150/255)
--inst.components.health:SetAbsorptionAmount(1)
inst.music_armor = true inst:RemoveTag("switlight")  inst.nsleep = true
scheduler:ExecuteInTime(3, function() inst.SoundEmitter:PlaySound("dontstarve/wilson/onemanband") inst.sg:GoToState("play_flute")
scheduler:ExecuteInTime(3, function() inst.sg:GoToState("enter_onemanband")scheduler:ExecuteInTime(3, function() inst.SoundEmitter:PlaySound("dontstarve/wilson/onemanband") inst.sg:GoToState("play_flute")
scheduler:ExecuteInTime(3, function() inst.components.playercontroller:Enable(true) inst.AnimState:SetBloomEffectHandle("") inst.Light:Enable(true) inst.components.sanity:DoDelta(25) inst.music = inst.music * 0 inst.components.talker:Say("[Light Aura] -on !") SpawnPrefab("statue_transition_2").Transform:SetPosition(inst:GetPosition():Get()) SpawnPrefab("ghosthound").Transform:SetPosition(inst:GetPosition():Get()) inst.stamina = inst.stamina + 10 inst.fatigue = inst.fatigue - 10  inst.components.sanity:DoDelta(15) inst.music_armor = false scheduler:ExecuteInTime(180, function() inst.components.talker:Say("[Light Aura] -off ") inst.SoundEmitter:PlaySound("dontstarve/common/fireOut") SpawnPrefab("statue_transition_2").Transform:SetPosition(inst:GetPosition():Get()) inst.Light:SetRadius(0.5) scheduler:ExecuteInTime(5, function()  if inst.nsleep then inst.Light:Enable(false) end inst.SoundEmitter:PlaySound("dontstarve/common/fireOut") inst.nsleep = false end) end)end)end)end)end)
end end

local function on_music_act0(inst)
if inst.components.playercontroller then
inst:RemoveTag("Light_on")
inst.components.playercontroller:Enable(false)
inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" )
local flute = inst.sg:GoToState("play_flute")
inst.AnimState:PlayAnimation("flute")
inst.SoundEmitter:PlaySound("dontstarve/wilson/onemanband")

inst.entity:AddLight()
inst.Light:SetRadius(8)
inst.Light:SetFalloff(.7)
inst.Light:SetIntensity(.7)
inst.Light:SetColour(150/255,150/255,150/255)
--inst.components.health:SetAbsorptionAmount(1)
inst.music_armor = true inst:RemoveTag("switlight")  inst.nsleep = true
scheduler:ExecuteInTime(3, function() inst.SoundEmitter:PlaySound("dontstarve/wilson/onemanband") inst.sg:GoToState("play_flute")
scheduler:ExecuteInTime(3, function() inst.sg:GoToState("enter_onemanband")
scheduler:ExecuteInTime(3, function() inst.components.playercontroller:Enable(true) inst.AnimState:SetBloomEffectHandle("") inst.Light:Enable(true) inst.components.sanity:DoDelta(25) inst.music = inst.music * 0 inst.components.talker:Say("[Light Aura] -on !") inst.stamina = inst.stamina + 25 inst.fatigue = inst.fatigue - 25  inst.components.sanity:DoDelta(40) inst.music_armor = false scheduler:ExecuteInTime(180, function() inst.components.talker:Say("[Light Aura] -off ") inst.SoundEmitter:PlaySound("dontstarve/common/fireOut") SpawnPrefab("statue_transition_2").Transform:SetPosition(inst:GetPosition():Get()) inst.Light:SetRadius(0.5) scheduler:ExecuteInTime(5, function()  if inst.nsleep then inst.Light:Enable(false) end inst.SoundEmitter:PlaySound("dontstarve/common/fireOut") inst.nsleep = false end) end)end)end)end)
end end

local function on_buff_act(inst)
local performance0 = 1
local performance1 = 0.3
local performance2 = 0.15

if math.random() < performance1 and not inst.components.health:IsDead() then
inst.components.talker:Say("Now, look at me!\nPerformance[type1]")
on_music_act1(inst)
elseif math.random() < performance2 and not inst.components.health:IsDead() then
inst.components.talker:Say("Now, look at me!\nPerformance[type2]")
on_music_act2(inst)
elseif math.random() < performance1 and not inst.components.health:IsDead() then
inst.components.talker:Say("Now, look at me!\nPerformance[type1]")
on_music_act1(inst)
elseif math.random() < performance2 and not inst.components.health:IsDead() then
inst.components.talker:Say("Now, look at me!\nPerformance[type2]")
on_music_act2(inst)
elseif math.random() < performance0 and not inst.components.health:IsDead() then
inst.components.talker:Say("Now, look at me!\nPerformance[type0]")
on_music_act0(inst)
end 
inst.components.talker.colour = Vector3(1, 0.85, 0.75, 1)
 end

--------sleep_test

 local function onsleepheal(inst)
 if inst.sleep_no then
 inst.sleep_no = false 
end
if inst.music_armor and inst:HasTag("DLC") then
inst.components.health:SetAbsorptionAmount(1)
elseif inst.music_armor and not inst:HasTag("DLC") then
inst.components.health:SetAbsorbAmount(1)
elseif not inst.music_armor and inst:HasTag("DLC") and not inst:HasTag("cureo0") and not inst:HasTag("cureo1") and not inst:HasTag("cureo2") and not inst.components.health:IsDead() and not inst:HasTag("valkyrieh") then
inst.components.health:SetAbsorptionAmount(0)
elseif not inst.music_armor and not inst:HasTag("DLC") and not inst:HasTag("cureo0") and not inst:HasTag("cureo1") and not inst:HasTag("cureo2") and not inst.components.health:IsDead() and not inst:HasTag("valkyrieh") then
inst.components.health:SetAbsorbAmount(0)
end
if GetClock():IsNight() and inst:HasTag("sleep_in") and not inst.warm_on and not inst.warm_tent then
local random1 = 0.2
 inst:RemoveTag("sleep_on")
  inst:RemoveTag("sleep_in")
  inst:RemoveTag("bedrolll")
   inst.sg:GoToState("wakeup")
if math.random() < random1 then
inst.components.talker:Say("Too dark..")
elseif math.random() < random1 then
inst.components.talker:Say("More light !")
elseif math.random() < random1 then
inst.components.talker:Say("Darkness too danger..")
elseif math.random() < random1 then
inst.components.talker:Say("Musha must find fire !")
elseif math.random() < random1 then
inst.components.talker:Say("Musha need fire !")
end end

if inst:HasTag("sleep_on") then

 if not inst.warm_on then
		--inst.components.sanity:DoDelta(0.5)
 elseif inst.warm_on then
        inst.components.health:DoDelta(0.5)
		  inst.components.sanity:DoDelta(0.5)
			--inst.components.hunger:DoDelta(0.5)
			end end
end

local function sleep_test(inst, data)
    local x, y, z = inst.Transform:GetWorldPosition() 
    local ents = TheSim:FindEntities(x, y, z, 6, { "monster" or "gruef" })
    for i, v in ipairs(ents) do
	if not (v:AddTag("tree") or v:AddTag("birchnut") or v:AddTag("deciduoustree")) then
    if v.components.health and not v.components.health:IsDead() then
		inst.sleep_no = true
    elseif v.components.health and v.components.health:IsDead() then
		inst.sleep_no = false
		end
	        end end

    local x, y, z = inst.Transform:GetWorldPosition() 
    local ents = TheSim:FindEntities(x, y, z, 4, { "fire" })
    for i, v in ipairs(ents) do
        if v.components.burnable:IsBurning() then
		inst.warm_on = true
    elseif v.components.burnable:Extinguish() then
		inst.warm_on = false
        end
     end

if inst:HasTag("bedrolll") then
inst.sg:AddStateTag("busy")
end	 
if inst:HasTag("sleep_in") then 
inst.charging_music = true
local sleep = inst.sg:GoToState("sleep")
inst.sg:AddStateTag("busy")
inst.AnimState:PlayAnimation("sleep")
inst:AddTag("sleep_on")
--inst.components.health:IsHurt()
if inst.sleep_no then
inst.charging_music = false
  inst:RemoveTag("sleep_on")
  inst:RemoveTag("sleep_in")
  inst:RemoveTag("bedrolll")
  inst.sg:GoToState("wakeup")
  inst:DoTaskInTime(3, function() inst.components.playercontroller:Enable(true) end)
end 
end
if not ( inst:HasTag("sleep_in") or  inst:HasTag("sleep_on")) then
inst.charging_music = false
  inst:RemoveTag("sleep_on")
  inst:RemoveTag("sleep_in")
  inst:RemoveTag("bedrolll")
end
if inst.sg:HasStateTag("moving") then
inst:RemoveTag("sleep_on")
inst:RemoveTag("sleep_in")
inst.charging_music = false
end
if not inst.warm_on and (inst:HasTag("sleep_on") or inst:HasTag("sleep_in")) and inst.stamina < 100 then
inst.stamina = inst.stamina + 0.02
 	if inst:HasTag("dsleep_veasy") then
	inst.stamina = inst.stamina + 0.1
	elseif inst:HasTag("dsleep_easy") then
	inst.stamina = inst.stamina + 0.05
	elseif inst:HasTag("dsleep_normal") then
	inst.stamina = inst.stamina + 0.02
	elseif inst:HasTag("dsleep_hard") then
	inst.stamina = inst.stamina + 0.01
	elseif inst:HasTag("dsleep_hardcore") then
	inst.stamina = inst.stamina + 0.005
end
elseif inst.warm_on and (inst:HasTag("sleep_on") or inst:HasTag("sleep_in")) and inst.stamina < 100 then
 	if inst:HasTag("dsleep_veasy") then
	inst.stamina = inst.stamina + 0.3
	elseif inst:HasTag("dsleep_easy") then
	inst.stamina = inst.stamina + 0.15
	elseif inst:HasTag("dsleep_normal") then
	inst.stamina = inst.stamina + 0.1
	elseif inst:HasTag("dsleep_hard") then
	inst.stamina = inst.stamina + 0.05
	elseif inst:HasTag("dsleep_hardcore") then
	inst.stamina = inst.stamina + 0.025
end
end
if not inst.warm_on and (inst:HasTag("sleep_on") or inst:HasTag("sleep_in")) and inst.fatigue > 0 then
	if inst:HasTag("dsleep_veasy") then
	inst.fatigue = inst.fatigue - 0.3
	elseif inst:HasTag("dsleep_easy") then
	inst.fatigue = inst.fatigue - 0.1
	elseif inst:HasTag("dsleep_normal") then
	inst.fatigue = inst.fatigue - 0.05
	elseif inst:HasTag("dsleep_hard") then
	inst.fatigue = inst.fatigue - 0.025
	elseif inst:HasTag("dsleep_hardcore") then
	inst.fatigue = inst.fatigue - 0.01
end
elseif inst.warm_on and (inst:HasTag("sleep_on") or inst:HasTag("sleep_in")) and inst.fatigue > 0 then
	if inst:HasTag("dsleep_veasy") then
	inst.fatigue = inst.fatigue - 0.5
	elseif inst:HasTag("dsleep_easy") then
	inst.fatigue = inst.fatigue - 0.2
	elseif inst:HasTag("dsleep_normal") then
	inst.fatigue = inst.fatigue - 0.1
	elseif inst:HasTag("dsleep_hard") then
	inst.fatigue = inst.fatigue - 0.05
	elseif inst:HasTag("dsleep_hardcore") then
	inst.fatigue = inst.fatigue - 0.025
	end
end
--dlc2
if inst.sg:HasStateTag("rowing") or inst.sg:HasStateTag("sailing") or inst.sg:HasStateTag("sail") or inst.sg:HasStateTag("row") or inst.sg:HasStateTag("boating") then
inst:AddTag("sailing") 
inst:AddTag("on_water")
elseif inst:HasTag("on_water") and not (inst.sg:HasStateTag("rowing") and not inst.sg:HasStateTag("sailing") and not inst.sg:HasStateTag("sail") and not inst.sg:HasStateTag("row")) and not inst.sg:HasStateTag("boating")then
scheduler:ExecuteInTime(4, function() inst:RemoveTag("on_water") inst:RemoveTag("sailing") end)
end
  --sleepy

 if inst:HasTag("ready_music") then 
 inst:AddTag("switlight")
 
 end
 if inst:HasTag("Light_on") and not inst.nsleep then
-- on_music_act1(inst)
 on_buff_act(inst)
end
if inst.music < 100 then
--inst:RemoveTag("Light_on")
inst:RemoveTag("switlight")
end
if inst.stamina <=0 then
		inst:AddTag("Valkyriech2")
		inst:RemoveTag("Valkyrieh")
		inst:RemoveTag("sneaka")
        inst:RemoveTag("notarget")
end

   if inst.valkyrie and not inst.berserk then
   	if inst:HasTag("dsleep_veasy") then
	inst.fatigue = inst.fatigue + 0	
	elseif inst:HasTag("dsleep_easy") then
	inst.fatigue = inst.fatigue + 0
	elseif inst:HasTag("dsleep_normal") then
	inst.fatigue = inst.fatigue + 0.01
	elseif inst:HasTag("dsleep_hard") then
	inst.fatigue = inst.fatigue + 0.02
	elseif inst:HasTag("dsleep_hardcore") then
	inst.fatigue = inst.fatigue + 0.03
	end
  inst.components.combat:SetAttackPeriod(0.1)
  inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.35)
  inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.35)	
  elseif not inst.valkyrie and inst.berserk then
   	if inst:HasTag("dsleep_veasy") then
	inst.fatigue = inst.fatigue + 0	
	elseif inst:HasTag("dsleep_easy") then
	inst.fatigue = inst.fatigue + 0
	elseif inst:HasTag("dsleep_normal") then
	inst.fatigue = inst.fatigue + 0.01
	elseif inst:HasTag("dsleep_hard") then
	inst.fatigue = inst.fatigue + 0.02
	elseif inst:HasTag("dsleep_hardcore") then
	inst.fatigue = inst.fatigue + 0.03
	end
   inst.components.combat:SetAttackPeriod(0.1)
  inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.45) 
  inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.45)
  end
  
if not inst.valkyrie and not inst.berserk and not inst:HasTag("sleep_on") then
if inst.stamina >= 95 then
inst.components.combat:SetAttackPeriod(0.2)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.12 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.12 )	
	inst.components.health:StartRegen(1, 20)
elseif inst.stamina < 95 and inst.stamina >= 90 then
inst.components.combat:SetAttackPeriod(0.3)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.08 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.08 )	
	inst.components.health:StartRegen(1, 25)
elseif inst.stamina < 90 and inst.stamina >= 85 then
inst.components.combat:SetAttackPeriod(0.4)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.04 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.04 )	
	inst.components.health:StartRegen(1, 30)
elseif inst.stamina < 85 and inst.stamina >= 80 then
inst.components.combat:SetAttackPeriod(0.5)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.0 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.0 )	
inst.components.health:StartRegen(1, 40)
elseif inst.stamina < 80 and inst.stamina >= 75 then
inst.components.combat:SetAttackPeriod(0.5)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.0 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.0 )	
inst.components.health:StartRegen(1, 50)
elseif inst.stamina < 75 and inst.stamina >= 70 then
inst.components.combat:SetAttackPeriod(0.5)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.0 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.0 )	
inst.components.health:StartRegen(1, 60)
elseif inst.stamina < 70 and inst.stamina >= 65 then
inst.components.combat:SetAttackPeriod(0.55)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.98 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.98 )	
inst.components.health:StartRegen(0, 0)
elseif inst.stamina < 60 and inst.stamina >= 55 then
inst.components.combat:SetAttackPeriod(0.6)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.96 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.96 )	
inst.components.health:StartRegen(0, 0)
elseif inst.stamina < 55 and inst.stamina >= 50 then
inst.components.combat:SetAttackPeriod(0.65)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.94 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.94 )	
inst.components.health:StartRegen(0, 0)
elseif inst.stamina < 50 and inst.stamina >= 45 then
inst.components.combat:SetAttackPeriod(0.7)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.92 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.92 )	
inst.components.health:StartRegen(0, 0)
elseif inst.stamina < 40 and inst.stamina >= 35 then
inst.components.combat:SetAttackPeriod(0.75)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.9 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.9)	
 inst.components.health:StartRegen(0, 0)
elseif inst.stamina < 35 and inst.stamina >= 30 then
inst.components.combat:SetAttackPeriod(0.8)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.85 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.85 )	
 inst.components.health:StartRegen(0, 0)
elseif inst.stamina < 30 and inst.stamina >= 25 then
inst.components.combat:SetAttackPeriod(0.85)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.8 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.8 )	
 inst.components.health:StartRegen(-1, 60)
elseif inst.stamina < 25 and inst.stamina >= 20 then
inst.components.combat:SetAttackPeriod(0.9)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.75 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.75 )	
 inst.components.health:StartRegen(-1, 55)
elseif inst.stamina < 20 and inst.stamina >= 15 then
inst.components.combat:SetAttackPeriod(0.95)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.7 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.7 )	
 inst.components.health:StartRegen(-1, 50)
elseif inst.stamina < 15 and inst.stamina >= 10 then
inst.components.combat:SetAttackPeriod(1.0)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.65 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.65 )	
 inst.components.health:StartRegen(-1, 45)
elseif inst.stamina < 10 and inst.stamina >= 5 then
inst.components.combat:SetAttackPeriod(1.05)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.6 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.6 )	
 inst.components.health:StartRegen(-1, 40)
elseif inst.stamina < 5 and inst.stamina > 0 then
inst.components.combat:SetAttackPeriod(1.1)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.55 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.55 )	
 inst.components.health:StartRegen(-1, 35)
elseif inst.stamina <= 0 then
inst.components.combat:SetAttackPeriod(1.2)
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED *0.5 )
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.5 )	
 inst.components.health:StartRegen(-1, 30)	 
------
end end
end
 
local function consume_stamina(inst, data)

if inst.charging_music and inst.music < 100 then
check_music(inst)
end
if inst.charging_music and inst.music >= 100 then	
inst:AddTag("music_check")
inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" ) 
elseif inst.music < 100 then
inst:RemoveTag("music_check") 
end

if not inst:HasTag("sleep_on") then
    if GetClock():IsDay() and inst.stamina >0 then
	if inst:HasTag("dsleep_veasy") then
	inst.stamina = inst.stamina - 0	
	elseif inst:HasTag("dsleep_easy") then
	inst.stamina = inst.stamina - 0.005
	elseif inst:HasTag("dsleep_normal") then
	inst.stamina = inst.stamina - 0.01
	elseif inst:HasTag("dsleep_hard") then
	inst.stamina = inst.stamina - 0.015
	elseif inst:HasTag("dsleep_hardcore") then
	inst.stamina = inst.stamina - 0.02
	end
elseif GetClock():IsDusk() and inst.stamina >0 then
	if inst:HasTag("dsleep_veasy") then
	inst.stamina = inst.stamina - 0	
	elseif inst:HasTag("dsleep_easy") then
	inst.stamina = inst.stamina - 0.005
	elseif inst:HasTag("dsleep_normal") then
	inst.stamina = inst.stamina - 0.015
	elseif inst:HasTag("dsleep_hard") then
	inst.stamina = inst.stamina - 0.02
	elseif inst:HasTag("dsleep_hardcore") then
	inst.stamina = inst.stamina - 0.025
	end
elseif GetClock():IsNight() and inst.stamina >0 then
 	if inst:HasTag("dsleep_veasy") then
	inst.stamina = inst.stamina - 0	
	elseif inst:HasTag("dsleep_easy") then
	inst.stamina = inst.stamina - 0.005
	elseif inst:HasTag("dsleep_normal") then
	inst.stamina = inst.stamina - 0.02
	elseif inst:HasTag("dsleep_hard") then
	inst.stamina = inst.stamina - 0.025
	elseif inst:HasTag("dsleep_hardcore") then
	inst.stamina = inst.stamina - 0.03
	end
end end
if not (inst.tiny_sleep or inst.sleep_on) and inst.fatigue <100 and (inst.sg:HasStateTag("attack") or inst.sg:HasStateTag("moving")) then
	if inst:HasTag("dsleep_veasy") then
	inst.fatigue = inst.fatigue + 0.05	
	elseif inst:HasTag("dsleep_easy") then
	inst.fatigue = inst.fatigue + 0.1
	elseif inst:HasTag("dsleep_normal") then
	inst.fatigue = inst.fatigue + 0.15
	elseif inst:HasTag("dsleep_hard") then
	inst.fatigue = inst.fatigue + 0.2
	elseif inst:HasTag("dsleep_hardcore") then
	inst.fatigue = inst.fatigue + 0.25
	end
end
if not (inst.tiny_sleep or inst.sleep_on) and inst.fatigue <100 and (inst.sg:HasStateTag("chopping") or inst.sg:HasStateTag("mining") or  inst.sg:HasStateTag("hammering") or inst.sg:HasStateTag("digging") or inst.sg:HasStateTag("netting") or inst.sg:HasStateTag("fishing") or inst.sg:HasStateTag("reading")) then
	if inst:HasTag("dsleep_veasy") then
	inst.fatigue = inst.fatigue + 0.05	
	elseif inst:HasTag("dsleep_easy") then
	inst.fatigue = inst.fatigue + 0.1
	elseif inst:HasTag("dsleep_normal") then
	inst.fatigue = inst.fatigue + 0.15
	elseif inst:HasTag("dsleep_hard") then
	inst.fatigue = inst.fatigue + 0.2
	elseif inst:HasTag("dsleep_hardcore") then
	inst.fatigue = inst.fatigue + 0.25
	end
	
if inst:HasTag("backstab1") and inst:HasTag("sneaka") then
		inst:RemoveTag("sneaka")
  inst:RemoveTag("hide")
        inst:RemoveTag("notarget")
	inst.components.talker:Say("Unhide !")
	inst.components.colourtweener:StartTween({1,1,1,1}, 0)
	local fx = SpawnPrefab("statue_transition_2")
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(1.2, 1.2, 1.2)
        fx.Transform:SetPosition(0, 0, 0)
         inst.components.sanity:DoDelta(80)

elseif inst:HasTag("backstab2") and inst:HasTag("sneaka") then
		inst:RemoveTag("sneaka")
        inst:RemoveTag("notarget")
	inst.components.talker:Say("Unhide !")
	inst.components.colourtweener:StartTween({1,1,1,1}, 0)
	local fx = SpawnPrefab("statue_transition_2")
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(1.2, 1.2, 1.2)
        fx.Transform:SetPosition(0, 0, 0)
         inst.components.sanity:DoDelta(160)

elseif inst:HasTag("backstab3")  and inst:HasTag("sneaka") then
		inst:RemoveTag("sneaka")
        inst:RemoveTag("notarget")
	inst.components.talker:Say("Unhide !")
	inst.components.colourtweener:StartTween({1,1,1,1}, 0)
	local fx = SpawnPrefab("statue_transition_2")
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(1.2, 1.2, 1.2)
        fx.Transform:SetPosition(0, 0, 0)
         inst.components.sanity:DoDelta(240)
end
end 
if not inst:HasTag("sleep_on") and inst.fatigue >0 and not (inst.sg:HasStateTag("moving") or inst.sg:HasStateTag("attack") or inst.sg:HasStateTag("chopping") or inst.sg:HasStateTag("mining") or  inst.sg:HasStateTag("hammering") or inst.sg:HasStateTag("digging") or inst.sg:HasStateTag("netting") or inst.sg:HasStateTag("fishing")) then
	if inst:HasTag("dsleep_veasy") then
	inst.fatigue = inst.fatigue - 0.5	
	elseif inst:HasTag("dsleep_easy") then
	inst.fatigue = inst.fatigue - 0.25
	elseif inst:HasTag("dsleep_normal") then
	inst.fatigue = inst.fatigue - 0.15
	elseif inst:HasTag("dsleep_hard") then
	inst.fatigue = inst.fatigue - 0.1
	elseif inst:HasTag("dsleep_hardcore") then
	inst.fatigue = inst.fatigue - 0.05
	end
end
if inst.stamina > 0 then
if inst.fatigue >=10 and inst.fatigue <20 and not inst.sleep_on and not inst.tiny_sleep then
inst.stamina = inst.stamina - 0.04
elseif inst.fatigue >=20 and inst.fatigue <30 and not inst.sleep_on and not inst.tiny_sleep then
inst.stamina = inst.stamina - 0.08
elseif inst.fatigue >=30 and inst.fatigue <40 and not inst.sleep_on and not inst.tiny_sleep then
inst.stamina = inst.stamina - 0.12
elseif inst.fatigue >=40 and inst.fatigue <50 and not inst.sleep_on and not inst.tiny_sleep then
inst.stamina = inst.stamina - 0.16
elseif inst.fatigue >=50 and inst.fatigue <60 and not inst.sleep_on and not inst.tiny_sleep then
inst.stamina = inst.stamina - 0.2
elseif inst.fatigue >=60 and inst.fatigue <70 and not inst.sleep_on and not inst.tiny_sleep then
inst.stamina = inst.stamina - 0.24
elseif inst.fatigue >=70 and inst.fatigue <80 and not inst.sleep_on and not inst.tiny_sleep then
inst.stamina = inst.stamina - 0.28
elseif inst.fatigue >=80 and inst.fatigue <90 and not inst.sleep_on and not inst.tiny_sleep then
inst.stamina = inst.stamina - 0.32
elseif inst.fatigue >=90 and not inst.sleep_on and not inst.tiny_sleep then
inst.stamina = inst.stamina - 0.4
end  
end
inst.components.talker.colour = Vector3(1, 1, 1, 1)
inst.components.talker.fontsize = 30
if inst.warm_on then
scheduler:ExecuteInTime(8, function() inst.warm_on = false end) 
end

if inst.strength == "Valkyrie" and not inst:HasTag("sleep_on") and inst.fatigue < 100 then
	if inst:HasTag("dsleep_veasy") then
	inst.fatigue = inst.fatigue + 0.05	
	elseif inst:HasTag("dsleep_easy") then
	inst.fatigue = inst.fatigue + 0.1
	elseif inst:HasTag("dsleep_normal") then
	inst.fatigue = inst.fatigue + 0.2
	elseif inst:HasTag("dsleep_hard") then
	inst.fatigue = inst.fatigue + 0.3
	elseif inst:HasTag("dsleep_hardcore") then
	inst.fatigue = inst.fatigue + 0.4
	end
elseif inst.strength == "berserk" and not inst:HasTag("sleep_on") and inst.fatigue < 100 then
	if inst:HasTag("dsleep_veasy") then
	inst.fatigue = inst.fatigue + 0	
	elseif inst:HasTag("dsleep_easy") then
	inst.fatigue = inst.fatigue + 0.01
	elseif inst:HasTag("dsleep_normal") then
	inst.fatigue = inst.fatigue + 0.05
	elseif inst:HasTag("dsleep_hard") then
	inst.fatigue = inst.fatigue + 0.1
	elseif inst:HasTag("dsleep_hardcore") then
	inst.fatigue = inst.fatigue + 0.15
	end
end

if inst:HasTag("sneaka") and inst.fatigue < 100 then 
	if inst:HasTag("dsleep_veasy") then
	inst.fatigue = inst.fatigue + 0.05	
	elseif inst:HasTag("dsleep_easy") then
	inst.fatigue = inst.fatigue + 0.1
	elseif inst:HasTag("dsleep_normal") then
	inst.fatigue = inst.fatigue + 0.2
	elseif inst:HasTag("dsleep_hard") then
	inst.fatigue = inst.fatigue + 0.3
	elseif inst:HasTag("dsleep_hardcore") then
	inst.fatigue = inst.fatigue + 0.4
	end
end

if inst:HasTag("cureo0") or inst:HasTag("cureo1") or inst:HasTag("cureo2") and inst.stamina < 100 then
	if inst:HasTag("dsleep_veasy") then
	inst.fatigue = inst.fatigue + 0.05	
	elseif inst:HasTag("dsleep_easy") then
	inst.fatigue = inst.fatigue + 0.5
	elseif inst:HasTag("dsleep_normal") then
	inst.fatigue = inst.fatigue + 1
	elseif inst:HasTag("dsleep_hard") then
	inst.fatigue = inst.fatigue + 2
	elseif inst:HasTag("dsleep_hardcore") then
	inst.fatigue = inst.fatigue + 3
	end
end	
if not inst:HasTag("sleep_on") then

--inst.components.sleeper:WakeUp()
end

--dizzy
local dizzy = 0.1
if inst.stamina > 20 then
inst.dizzy = false
elseif inst.stamina <= 20 and not inst.dizzy and math.random() < dizzy and not inst.sg:HasStateTag("attack") and not inst.sg:HasStateTag("moving") then
if math.random() < dizzy then
inst.components.talker:Say("feel so dizzy..")
inst.dizzy = true
elseif math.random() < dizzy then
inst.components.talker:Say("Musha so tired..")
inst.dizzy = true
elseif math.random() < dizzy then
inst.components.talker:Say("Musha fell asleep forever..")
inst.dizzy = true
elseif math.random() < dizzy then
inst.components.talker:Say("Musha, almost died..")
inst.dizzy = true
end
--[[
	inst:DoTaskInTime( 0, function() 
scheduler:ExecuteInTime(1, function() inst.sg:GoToState("knockout") inst.tiny_sleep = true end)
inst.sg:AddStateTag("busy")
	inst:DoTaskInTime( 150, function() inst.dizzy = false end) end)]]
 end end

 

-------------
--normal bersek
local function berserkchanger(inst, data)

if inst:HasTag("berserk") and inst.components.hunger.current < 40  then
	inst:AddTag("berserks") 
	inst:RemoveTag("Valkyrieh") 
elseif inst:HasTag("berserk") and inst.components.hunger.current > 40  then
	inst:RemoveTag("berserks") 
	end
	if not inst:HasTag("Valkyrieh") and inst.components.hunger.current >= 160  and not inst:HasTag("berserks") and not inst:HasTag("fberserk") then
if not inst.visual_hold then
			inst.AnimState:SetBuild("musha")
			end 
elseif not inst:HasTag("Valkyrieh") and inst.components.hunger.current < 160 and not inst:HasTag("berserks") and not inst:HasTag("fberserk") then
if not inst.visual_hold then
			inst.AnimState:SetBuild("musha_normal")
			end 			
			end
	end


local function onpreload(inst, data)
	if data then
			if data.music then
			inst.music = data.music
			fullcharged_music(inst)
			end
				if data.stamina then
			inst.stamina = data.stamina
			stamina_sleep(inst)
			end
				if data.fatigue then
			inst.fatigue = data.fatigue
			fatigue_sleep(inst)
			end
			if data.level then
			inst.level = data.level
			levelexp(inst)
--
			if data.health and data.health.health then inst.components.health.currenthealth = data.health.health end
			--if data.hunger and data.hunger.hunger then inst.components.hunger.current = data.hunger.hunger end
--
			if data.sanity and data.sanity.current then inst.components.sanity.current = data.sanity.current end
			inst.components.health:DoDelta(0)
			--inst.components.hunger:DoDelta(0)
			inst.components.sanity:DoDelta(0)
end
	end
		end

local function onsave(inst, data)
	data.stamina = inst.stamina
	data.fatigue = inst.fatigue
	data.level = inst.level
	data.music = inst.music
	end
	
    local function lessercure_proc(inst, data)
	if inst.components.sanity:GetPercent() > 0.5 and inst.components.health:GetPercent() < .3 and not inst.components.health:IsDead() then
        inst.components.health:DoDelta(75)
        inst.components.sanity:DoDelta(-20)
inst.components.talker:Say("Lesser Cure !!")
        local fx = SpawnPrefab("sparklefx")
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/raise")
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/pop")
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(1.3, 1.3, 1.3)
        fx.Transform:SetPosition(0, -0.2, 0)
        local fx_hitanim = function()
            fx.AnimState:PlayAnimation("hit")
            fx.AnimState:PushAnimation("idle_loop")
        end
        fx:ListenForEvent("blocked", fx_hitanim, inst)
        inst.activelc = true
        inst:DoTaskInTime(--[[Duration]] 5, function()
            fx:RemoveEventCallback("blocked", fx_hitanim, inst)
            if inst:IsValid() then
                inst:DoTaskInTime(--[[Cooldown]] 1800, function() inst.activelc = false 			end)
            end
        end)
    end
end
    local function lessercure2_proc(inst, data)
	if inst.components.sanity:GetPercent() > 0.5 and inst.components.health:GetPercent() < .3 and not inst.components.health:IsDead() then
        inst.components.health:DoDelta(150)
        inst.components.sanity:DoDelta(-20)
inst.components.talker:Say("Lesser Cure !!")
        local fx = SpawnPrefab("sparklefx")
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/raise")
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/pop")
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(1.3, 1.3, 1.3)
        fx.Transform:SetPosition(0, -0.2, 0)
        local fx_hitanim = function()
            fx.AnimState:PlayAnimation("hit")
            fx.AnimState:PushAnimation("idle_loop")
        end
        fx:ListenForEvent("blocked", fx_hitanim, inst)
        inst.activelc2 = true
        inst:DoTaskInTime(--[[Duration]] 5, function()
            fx:RemoveEventCallback("blocked", fx_hitanim, inst)
            if inst:IsValid() then
                inst:DoTaskInTime(--[[Cooldown]] 900, function() inst.activelc2 = false 			end)
            end
        end)
    end
end

    local function cure0_proc(inst, attacked, data)
if inst:HasTag("cure0") and inst:HasTag("cureo0") and inst:HasTag("DLC") and not inst.components.health:IsDead() then

inst.components.talker:Say("Shield on!!")
inst:RemoveTag("shieldon2") 

      --  local fx = SpawnPrefab("sparklefx")
        local fx = SpawnPrefab("forcefieldfxx")

        --inst.components.health:DoDelta(2)
      --  inst.components.sanity:DoDelta(-1)
	inst.components.health:SetAbsorptionAmount(1)

            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/raise")
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/pop")
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(0.8, 0.8, 0.8)
        fx.Transform:SetPosition(0, 0.2, 0)
        local fx_hitanim = function()
            fx.AnimState:PlayAnimation("hit")
            fx.AnimState:PushAnimation("idle_loop")
        end
        fx:ListenForEvent("blocked", fx_hitanim, inst)
        inst.activec0 = true
   inst:DoTaskInTime(--[[Duration]] 5, function()
            fx:RemoveEventCallback("blocked", fx_hitanim, inst)
            if inst:IsValid() then
            fx.kill_fx(fx)
	inst.components.health:SetAbsorptionAmount(0)
inst:RemoveTag("Cureo0") 
inst:RemoveTag("Cureoo0") 
inst:RemoveTag("shieldon") 
inst:AddTag("effectsheild2") 
inst:RemoveTag("frameon1")
inst:RemoveTag("frameon2")
inst:RemoveTag("frameon3")
inst:RemoveTag("frameon4")
inst.components.talker:Say("[Shield] cooldown -[200sec]")
                inst:DoTaskInTime(--[[Cooldown]] 200, function() inst.activec0 = false 			end)

            end
        end)
    end

if inst:HasTag("cure0") and inst:HasTag("cureo0") and not inst:HasTag("DLC") and not inst.components.health:IsDead() then

inst.components.talker:Say("Shield on!!")
inst:RemoveTag("shieldon2") 

      --  local fx = SpawnPrefab("sparklefx")
        local fx = SpawnPrefab("forcefieldfxx")

      --  inst.components.health:DoDelta(20)
      --  inst.components.sanity:DoDelta(-1)
	inst.components.health:SetAbsorbAmount(1)

            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/raise")
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/pop")
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(0.8, 0.8, 0.8)
        fx.Transform:SetPosition(0, 0.2, 0)
        local fx_hitanim = function()
            fx.AnimState:PlayAnimation("hit")
            fx.AnimState:PushAnimation("idle_loop")
        end
        fx:ListenForEvent("blocked", fx_hitanim, inst)
        inst.activec0 = true
   inst:DoTaskInTime(--[[Duration]] 5, function()
            fx:RemoveEventCallback("blocked", fx_hitanim, inst)
            if inst:IsValid() then
            fx.kill_fx(fx)
	inst.components.health:SetAbsorbAmount(0)
inst:RemoveTag("Cureo0") 
inst:RemoveTag("Cureoo0") 
inst:RemoveTag("shieldon") 
inst:AddTag("effectsheild2") 
inst:RemoveTag("frameon1")
inst:RemoveTag("frameon2")
inst:RemoveTag("frameon3")
inst:RemoveTag("frameon4")
inst.components.talker:Say("[Shield] cooldown -[200sec]")
                inst:DoTaskInTime(--[[Cooldown]] 200, function() inst.activec0 = false 			end)

            end
        end)
    end

end

    local function cure1_proc(inst, data)
	if inst:HasTag("cure1") and inst:HasTag("cureo1") and inst:HasTag("DLC") and not inst.components.health:IsDead() then

inst.components.talker:Say("Shield on!!")
inst:RemoveTag("shieldon2") 
	inst.components.health:SetAbsorptionAmount(1)

      --  local fx = SpawnPrefab("sparklefx")
        local fx = SpawnPrefab("forcefieldfxx")

            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/raise")
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/pop")
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(0.8, 0.8, 0.8)
        fx.Transform:SetPosition(0, 0.2, 0)
        local fx_hitanim = function()
            fx.AnimState:PlayAnimation("hit")
            fx.AnimState:PushAnimation("idle_loop")
        end
        fx:ListenForEvent("blocked", fx_hitanim, inst)
        inst.activec1 = true
   inst:DoTaskInTime(--[[Duration]] 7, function()
            fx:RemoveEventCallback("blocked", fx_hitanim, inst)
            if inst:IsValid() then
            fx.kill_fx(fx)
	inst.components.health:SetAbsorptionAmount(0)
inst:RemoveTag("Cureo1") 
inst:RemoveTag("Cureoo1") 
inst:RemoveTag("shieldon") 
inst:AddTag("effectsheild2") 
inst:RemoveTag("frameon1")
inst:RemoveTag("frameon2")
inst:RemoveTag("frameon3")
inst:RemoveTag("frameon4")
inst.components.talker:Say("[Shield] cooldown -[150sec]")
                inst:DoTaskInTime(--[[Cooldown]] 150, function() inst.activec1 = false 			end)

            end
        end)
    end
if inst:HasTag("cure1") and inst:HasTag("cureo1") and not inst:HasTag("DLC") and not inst.components.health:IsDead() then

inst.components.talker:Say("Shield on!!")
inst:RemoveTag("shieldon2") 
	inst.components.health:SetAbsorbAmount(1)

      --  local fx = SpawnPrefab("sparklefx")
        local fx = SpawnPrefab("forcefieldfxx")

            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/raise")
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/pop")
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(0.8, 0.8, 0.8)
        fx.Transform:SetPosition(0, 0.2, 0)
        local fx_hitanim = function()
            fx.AnimState:PlayAnimation("hit")
            fx.AnimState:PushAnimation("idle_loop")
        end
        fx:ListenForEvent("blocked", fx_hitanim, inst)
        inst.activec1 = true
   inst:DoTaskInTime(--[[Duration]] 7, function()
            fx:RemoveEventCallback("blocked", fx_hitanim, inst)
            if inst:IsValid() then
            fx.kill_fx(fx)
	inst.components.health:SetAbsorbAmount(0)
inst:RemoveTag("Cureo1") 
inst:RemoveTag("Cureoo1") 
inst:RemoveTag("shieldon") 
inst:AddTag("effectsheild2") 
inst:RemoveTag("frameon1")
inst:RemoveTag("frameon2")
inst:RemoveTag("frameon3")
inst:RemoveTag("frameon4")
inst.components.talker:Say("[Shield] cooldown -[150sec]")
                inst:DoTaskInTime(--[[Cooldown]] 150, function() inst.activec1 = false 			end)

            end
        end)
    end

end

    local function cure2_proc(inst, data)
	if inst:HasTag("cure2") and inst:HasTag("cureo2") and inst:HasTag("DLC") and not inst.components.health:IsDead() then

inst.components.talker:Say("Shield On!!")
inst:RemoveTag("shieldon2") 
	inst.components.health:SetAbsorptionAmount(1)

      --  local fx = SpawnPrefab("sparklefx")
        local fx = SpawnPrefab("forcefieldfxx")

            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/raise")
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/pop")
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(0.8, 0.8, 0.8)
        fx.Transform:SetPosition(0, 0.2, 0)
        local fx_hitanim = function()
            fx.AnimState:PlayAnimation("hit")
            fx.AnimState:PushAnimation("idle_loop")
        end
        fx:ListenForEvent("blocked", fx_hitanim, inst)
        inst.activec2 = true
   inst:DoTaskInTime(--[[Duration]] 9, function()
            fx:RemoveEventCallback("blocked", fx_hitanim, inst)
            if inst:IsValid() then
            fx.kill_fx(fx)
	inst.components.health:SetAbsorptionAmount(0)
inst:RemoveTag("Cureo2") 
inst:RemoveTag("Cureoo2") 
inst:RemoveTag("shieldon") 
inst:AddTag("effectsheild2") 
inst:RemoveTag("frameon1")
inst:RemoveTag("frameon2")
inst:RemoveTag("frameon3")
inst:RemoveTag("frameon4")
inst.components.talker:Say("[Shield] cooldown -[100sec]")
                inst:DoTaskInTime(--[[Cooldown]] 100, function() inst.activec2 = false 			end)

            end
        end)
    end
	if inst:HasTag("cure2") and inst:HasTag("cureo2") and not inst:HasTag("DLC") and not inst.components.health:IsDead() then

inst.components.talker:Say("Shield On!!")
inst:RemoveTag("shieldon2") 
	inst.components.health:SetAbsorbAmount(1)

      --  local fx = SpawnPrefab("sparklefx")
        local fx = SpawnPrefab("forcefieldfxx")

            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/raise")
            inst.SoundEmitter:PlaySound("dontstarve/creatures/chester/pop")
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(0.8, 0.8, 0.8)
        fx.Transform:SetPosition(0, 0.2, 0)
        local fx_hitanim = function()
            fx.AnimState:PlayAnimation("hit")
            fx.AnimState:PushAnimation("idle_loop")
        end
        fx:ListenForEvent("blocked", fx_hitanim, inst)
        inst.activec2 = true
   inst:DoTaskInTime(--[[Duration]] 9, function()
            fx:RemoveEventCallback("blocked", fx_hitanim, inst)
            if inst:IsValid() then
            fx.kill_fx(fx)
	inst.components.health:SetAbsorbAmount(0)
inst:RemoveTag("Cureo2") 
inst:RemoveTag("Cureoo2") 
inst:RemoveTag("shieldon") 
inst:AddTag("effectsheild2") 
inst:RemoveTag("frameon1")
inst:RemoveTag("frameon2")
inst:RemoveTag("frameon3")
inst:RemoveTag("frameon4")
inst.components.talker:Say("[Shield] cooldown -[100sec]")
                inst:DoTaskInTime(--[[Cooldown]] 100, function() inst.activec2 = false 			end)

            end
        end)
    end

end

    local function healshield1_proc(inst, data)
	if inst.components.sanity.current > 3 and inst.components.health:GetPercent() < .9 and not inst.components.health:IsDead() then
        inst.components.health:DoDelta(5)
        inst.components.sanity:DoDelta(-1)
        local sfx = SpawnPrefab("shock_fx2")
        local fx = SpawnPrefab("sparklefx")
    inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod")
        sfx.entity:SetParent(inst.entity)
	sfx.Transform:SetScale(1.3, 1.3, 1.3)
        sfx.Transform:SetPosition(0, -0.2, 0)
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(1.3, 1.3, 1.3)
        fx.Transform:SetPosition(0, -0.2, 0)
        local fx_hitanim = function()
            fx.AnimState:PlayAnimation("hit")
            fx.AnimState:PushAnimation("idle_loop")
        end
        fx:ListenForEvent("blocked", fx_hitanim, inst)
        inst.activeh1 = true
        inst:DoTaskInTime(--[[Duration]] 1, function()
            fx:RemoveEventCallback("blocked", fx_hitanim, inst)
            if inst:IsValid() then
                inst:DoTaskInTime(--[[Cooldown]] 2, function() inst.activeh1 = false 			end)
            end
        end)
    end
end
    local function healshield2_proc(inst, data)
	if inst.components.sanity.current > 3 and inst.components.health:GetPercent() < .9 and not inst.components.health:IsDead() then
        inst.components.health:DoDelta(6)
        inst.components.sanity:DoDelta(-1)
        local sfx = SpawnPrefab("shock_fx2")
        local fx = SpawnPrefab("sparklefx")
    inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod")
        sfx.entity:SetParent(inst.entity)
	sfx.Transform:SetScale(1.3, 1.3, 1.3)
        sfx.Transform:SetPosition(0, -0.2, 0)
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(1.3, 1.3, 1.3)
        fx.Transform:SetPosition(0, -0.2, 0)
        local fx_hitanim = function()
            fx.AnimState:PlayAnimation("hit")
            fx.AnimState:PushAnimation("idle_loop")
        end
        fx:ListenForEvent("blocked", fx_hitanim, inst)
        inst.activeh1 = true
        inst:DoTaskInTime(--[[Duration]] 1, function()
            fx:RemoveEventCallback("blocked", fx_hitanim, inst)
            if inst:IsValid() then
                inst:DoTaskInTime(--[[Cooldown]] 2, function() inst.activeh1 = false 			end)
            end
        end)
    end
end
    local function healshield3_proc(inst, data)
	if inst.components.sanity.current > 3 and inst.components.health:GetPercent() < .9 and not inst.components.health:IsDead() then
        inst.components.health:DoDelta(7)
        inst.components.sanity:DoDelta(-1)
        local sfx = SpawnPrefab("shock_fx2")
        local fx = SpawnPrefab("sparklefx")
    inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod")
        sfx.entity:SetParent(inst.entity)
	sfx.Transform:SetScale(1.3, 1.3, 1.3)
        sfx.Transform:SetPosition(0, -0.2, 0)
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(1.3, 1.3, 1.3)
        fx.Transform:SetPosition(0, -0.2, 0)
        local fx_hitanim = function()
            fx.AnimState:PlayAnimation("hit")
            fx.AnimState:PushAnimation("idle_loop")
        end
        fx:ListenForEvent("blocked", fx_hitanim, inst)
        inst.activeh3 = true
        inst:DoTaskInTime(--[[Duration]] 1, function()
            fx:RemoveEventCallback("blocked", fx_hitanim, inst)
            if inst:IsValid() then
                inst:DoTaskInTime(--[[Cooldown]] 2, function() inst.activeh3 = false 			end)
              end
        end)
    end
end
    local function healshield4_proc(inst, data)
	if inst.components.sanity.current > 3 and inst.components.health:GetPercent() < .9 and not inst.components.health:IsDead() then
        inst.components.health:DoDelta(8)
        inst.components.sanity:DoDelta(-1)
        local sfx = SpawnPrefab("shock_fx2")
        local fx = SpawnPrefab("sparklefx")
    inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod")
        sfx.entity:SetParent(inst.entity)
	sfx.Transform:SetScale(1.3, 1.3, 1.3)
        sfx.Transform:SetPosition(0, -0.2, 0)
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(1.3, 1.3, 1.3)
        fx.Transform:SetPosition(0, -0.2, 0)
        local fx_hitanim = function()
            fx.AnimState:PlayAnimation("hit")
            fx.AnimState:PushAnimation("idle_loop")
        end
        fx:ListenForEvent("blocked", fx_hitanim, inst)
        inst.activeh4 = true
        inst:DoTaskInTime(--[[Duration]] 1, function()
            fx:RemoveEventCallback("blocked", fx_hitanim, inst)
            if inst:IsValid() then
                inst:DoTaskInTime(--[[Cooldown]] 2, function() inst.activeh4 = false 			end)
              end
        end)
    end
end

------------------    
--test
local function berserkattack(inst, data)
local other = data.target
   local pos = other:GetPosition()
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
end

local function OnHitfreeze(inst, data)
    local other = data.target
     if other and other.components.freezable and inst:HasTag("Hitfreeze1") then
        other.components.freezable:AddColdness(0.15)
        other.components.freezable:SpawnShatterFX()
     elseif other and other.components.freezable and inst:HasTag("Hitfreeze2") then
        other.components.freezable:AddColdness(0.2)
        other.components.freezable:SpawnShatterFX()
     elseif other and other.components.freezable and inst:HasTag("Hitfreeze3") then
        other.components.freezable:AddColdness(0.25)
        other.components.freezable:SpawnShatterFX()
     elseif other and other.components.freezable and inst:HasTag("Hitfreeze4") then
        other.components.freezable:AddColdness(0.3)
        other.components.freezable:SpawnShatterFX()
    end
    if other.components.burnable and other.components.burnable:IsBurning() then
        other.components.burnable:Extinguish()
end
end

local function Onframeshield1(attacked, data)
        if data and data.attacker and data.attacker.components.health and data.attacker.components.burnable and not data.attacker:HasTag("thorny") and not data.attacker:HasTag("gruef") then
            data.attacker.components.health:DoDelta(-5)
            data.attacker.components.burnable:Ignite()
		end
    if data.attacker.components.burnable and data.attacker.components.burnable:IsBurning() then
        data.attacker.components.burnable:Extinguish()
        end 
    end
local function Onframeshield2(attacked, data)
        if data and data.attacker and data.attacker.components.health and data.attacker.components.burnable and not data.attacker:HasTag("thorny") and not data.attacker:HasTag("gruef") then
            data.attacker.components.health:DoDelta(-8)
            data.attacker.components.burnable:Ignite()
		end
    if data.attacker.components.burnable and data.attacker.components.burnable:IsBurning() then
        data.attacker.components.burnable:Extinguish()
        end 
    end
local function Onframeshield3(attacked, data)
        if data and data.attacker and data.attacker.components.health and data.attacker.components.burnable and not data.attacker:HasTag("thorny") and not data.attacker:HasTag("gruef") then
            data.attacker.components.health:DoDelta(-11)
            data.attacker.components.burnable:Ignite()
		end
    if data.attacker.components.burnable and data.attacker.components.burnable:IsBurning() then
        data.attacker.components.burnable:Extinguish()
        end 
    end
local function Onframeshield4(attacked, data)
        if data and data.attacker and data.attacker.components.health and data.attacker.components.burnable and not data.attacker:HasTag("thorny") and not data.attacker:HasTag("gruef") then
            data.attacker.components.health:DoDelta(-15)
            data.attacker.components.burnable:Ignite()
		end
    if data.attacker.components.burnable and data.attacker.components.burnable:IsBurning() then
        data.attacker.components.burnable:Extinguish()
        end 
    end
---berserk shield
local function Onfreeze(attacked, data)
        if data and data.attacker and data.attacker.components.freezable then
            data.attacker.components.freezable:AddColdness(0.4)
            data.attacker.components.freezable:SpawnShatterFX()
        end 
    end

--simple

local function OnHitlightning1(inst, data)
local other = data.target
   local pos = other:GetPosition()
if inst:HasTag("lightningblue1") and inst:HasTag("DLC")  then
if other and other.components.burnable and other.components.health and not other:HasTag("wall") and not other:HasTag("structure")  then
        other.components.burnable:Ignite()
            SpawnPrefab("lightning").Transform:SetPosition(other:GetPosition():Get())
        other.components.health:DoDelta(-110)
SpawnPrefab("shock_fx2").Transform:SetPosition(other:GetPosition():Get())
            SpawnPrefab("groundpoundring_fx").Transform:SetPosition(other:GetPosition():Get())
    inst.components.sanity:DoDelta(-20)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue1")
inst:RemoveTag("lightningo1") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning1)

	elseif other and not other.components.burnable and other.components.health and not other:HasTag("wall") and not other:HasTag("structure") and inst:HasTag("DLC") then
            SpawnPrefab("lightning").Transform:SetPosition(other:GetPosition():Get())
        other.components.health:DoDelta(-110)
SpawnPrefab("shock_fx2").Transform:SetPosition(other:GetPosition():Get())
            SpawnPrefab("groundpoundring_fx").Transform:SetPosition(other:GetPosition():Get())
    inst.components.sanity:DoDelta(-20)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue1")
inst:RemoveTag("lightningo1") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning1)

	elseif other:HasTag("wall") or other:HasTag("structure") and inst:HasTag("DLC") then
            SpawnPrefab("lightning").Transform:SetPosition(other:GetPosition():Get())
SpawnPrefab("shock_fx2").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
		other.components.health:DoDelta(-110)
    inst.components.sanity:DoDelta(-20)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue1")
inst:RemoveTag("lightningo1") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning1)
end
    if other.components.burnable and other.components.burnable:IsBurning() and inst:HasTag("DLC") then
        other.components.burnable:Extinguish()
   		 end
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue1")
inst:RemoveTag("lightningo1") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning1)
		
inst.components.combat:SetRange(2)

end

if inst:HasTag("lightningblue1") and not inst:HasTag("DLC") then
if other and other.components.burnable and other.components.health and not other:HasTag("wall") and not other:HasTag("structure")  then
        other.components.burnable:Ignite()
            SpawnPrefab("lightning").Transform:SetPosition(other:GetPosition():Get())
        other.components.health:DoDelta(-110)
            SpawnPrefab("shock_fx2").Transform:SetPosition(other:GetPosition():Get())
    inst.components.sanity:DoDelta(-20)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue1")
inst:RemoveTag("lightningo1") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning1)

elseif other and not other.components.burnable and other.components.health and not other:HasTag("wall") and not other:HasTag("structure") and not inst:HasTag("DLC")  then
            SpawnPrefab("lightning").Transform:SetPosition(other:GetPosition():Get())
        other.components.health:DoDelta(-110)
            SpawnPrefab("shock_fx2").Transform:SetPosition(other:GetPosition():Get())
    inst.components.sanity:DoDelta(-20)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue1")
inst:RemoveTag("lightningo1") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning1)

	elseif other:HasTag("wall") or other:HasTag("structure") and not inst:HasTag("DLC") then
            SpawnPrefab("lightning").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
		other.components.health:DoDelta(-110)
    inst.components.sanity:DoDelta(-20)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue1")
inst:RemoveTag("lightningo1") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning1)
end

    if other.components.burnable and other.components.burnable:IsBurning() and not inst:HasTag("DLC") then
        other.components.burnable:Extinguish()
   		 end
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue1")
inst:RemoveTag("lightningo1") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning1)
		end
inst.components.combat:SetRange(2)

end
----


local function OnHitlightning2(inst, data)
local other = data.target
   local pos = other:GetPosition()
if inst:HasTag("lightningblue2") and inst:HasTag("DLC")  then
if other and other.components.burnable and other.components.health and not other:HasTag("wall") and not other:HasTag("structure")  then
        other.components.burnable:Ignite()
            SpawnPrefab("lightning").Transform:SetPosition(other:GetPosition():Get())
        other.components.health:DoDelta(-220)
SpawnPrefab("shock_fx2").Transform:SetPosition(other:GetPosition():Get())
            SpawnPrefab("groundpoundring_fx").Transform:SetPosition(other:GetPosition():Get())
    inst.components.sanity:DoDelta(-20)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue2")
inst:RemoveTag("lightningo2") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning2)

	elseif other and not other.components.burnable and other.components.health and not other:HasTag("wall") and not other:HasTag("structure") and inst:HasTag("DLC") then
            SpawnPrefab("lightning").Transform:SetPosition(other:GetPosition():Get())
        other.components.health:DoDelta(-220)
SpawnPrefab("shock_fx2").Transform:SetPosition(other:GetPosition():Get())
            SpawnPrefab("groundpoundring_fx").Transform:SetPosition(other:GetPosition():Get())
    inst.components.sanity:DoDelta(-20)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue2")
inst:RemoveTag("lightningo2") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning2)

	elseif other:HasTag("wall") or other:HasTag("structure") and inst:HasTag("DLC") then
            SpawnPrefab("lightning").Transform:SetPosition(other:GetPosition():Get())
SpawnPrefab("shock_fx2").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
		other.components.health:DoDelta(-220)
    inst.components.sanity:DoDelta(-20)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue2")
inst:RemoveTag("lightningo2") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning2)
end
    if other.components.burnable and other.components.burnable:IsBurning() and inst:HasTag("DLC") then
        other.components.burnable:Extinguish()
   		 end
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue2")
inst:RemoveTag("lightningo2") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning2)
		
inst.components.combat:SetRange(2)

end

if inst:HasTag("lightningblue2") and not inst:HasTag("DLC") then
if other and other.components.burnable and other.components.health and not other:HasTag("wall") and not other:HasTag("structure")  then
        other.components.burnable:Ignite()
            SpawnPrefab("lightning").Transform:SetPosition(other:GetPosition():Get())
        other.components.health:DoDelta(-220)
            SpawnPrefab("shock_fx2").Transform:SetPosition(other:GetPosition():Get())
    inst.components.sanity:DoDelta(-20)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue2")
inst:RemoveTag("lightningo2") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning2)

elseif other and not other.components.burnable and other.components.health and not other:HasTag("wall") and not other:HasTag("structure") and not inst:HasTag("DLC")  then
            SpawnPrefab("lightning").Transform:SetPosition(other:GetPosition():Get())
        other.components.health:DoDelta(-220)
            SpawnPrefab("shock_fx2").Transform:SetPosition(other:GetPosition():Get())
    inst.components.sanity:DoDelta(-20)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue2")
inst:RemoveTag("lightningo2") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning2)

	elseif other:HasTag("wall") or other:HasTag("structure") and not inst:HasTag("DLC") then
            SpawnPrefab("lightning").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
		other.components.health:DoDelta(-220)
    inst.components.sanity:DoDelta(-20)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue2")
inst:RemoveTag("lightningo2") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning2)
end

    if other.components.burnable and other.components.burnable:IsBurning() and not inst:HasTag("DLC") then
        other.components.burnable:Extinguish()
   		 end
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue2")
inst:RemoveTag("lightningo2") 
inst.AnimState:SetBloomEffectHandle( "" )
inst.lightning_activate = false
inst:RemoveEventCallback("onhitother", OnHitlightning2)
		end
inst.components.combat:SetRange(2)

end


--[[
local function OnHitlightning1(inst, data)
local other = data.target
   local pos = other:GetPosition()
	if inst:HasTag("lightningblue1") and inst:HasTag("DLC") then
	if not other.components.burnable then
            SpawnPrefab("groundpoundring_fx").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
		other.components.health:DoDelta(-100)
    inst.components.sanity:DoDelta(-10)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue1")
inst:RemoveTag("lightningo1") 
inst.AnimState:SetBloomEffectHandle( "" )
inst:RemoveEventCallback("onhitother", OnHitlightning1)

	elseif other:HasTag("wall") or other:HasTag("structure") then
            SpawnPrefab("groundpoundring_fx").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
		other.components.health:DoDelta(-100)
    inst.components.sanity:DoDelta(-10)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue1")
inst:RemoveTag("lightningo1") 
inst.AnimState:SetBloomEffectHandle( "" )
inst:RemoveEventCallback("onhitother", OnHitlightning1)

	elseif other.components.burnable and not other:HasTag("wall") and not other:HasTag("structure") then
	do
	GetSeasonManager():DoLightningStrike(pos)
	inst.components.health:SetAbsorptionAmount(1)

            SpawnPrefab("groundpoundring_fx").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
	other.components.burnable:Ignite()
		other.components.health:DoDelta(-100)
    inst.components.sanity:DoDelta(-10)
    if other.components.burnable and other.components.burnable:IsBurning() then
        other.components.burnable:Extinguish()
   		 end
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue1")
inst:RemoveTag("lightningo1") 
inst.AnimState:SetBloomEffectHandle( "" )
inst:RemoveEventCallback("onhitother", OnHitlightning1)
		end
	--inst.components.health:SetAbsorptionAmount(0.5)
inst.components.combat:SetRange(2)

	end
end
	if inst:HasTag("lightningblue1") and not inst:HasTag("DLC") then
	if not other.components.burnable then
            SpawnPrefab("statue_transition").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
		other.components.health:DoDelta(-100)
    inst.components.sanity:DoDelta(-10)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue1")
inst:RemoveTag("lightningo1") 
inst.AnimState:SetBloomEffectHandle( "" )
inst:RemoveEventCallback("onhitother", OnHitlightning1)

	elseif other:HasTag("wall") or other:HasTag("structure") then
            SpawnPrefab("statue_transition").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
		other.components.health:DoDelta(-100)
    inst.components.sanity:DoDelta(-10)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue1")
inst:RemoveTag("lightningo1") 
inst.AnimState:SetBloomEffectHandle( "" )
inst:RemoveEventCallback("onhitother", OnHitlightning1)

	elseif other.components.burnable and not other:HasTag("wall") and not other:HasTag("structure") then
	do
	GetSeasonManager():DoLightningStrike(pos)
	inst.components.health:SetAbsorbAmount(1)

            SpawnPrefab("statue_transition").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
	other.components.burnable:Ignite()
		other.components.health:DoDelta(-100)
    inst.components.sanity:DoDelta(-10)
    if other.components.burnable and other.components.burnable:IsBurning() then
        other.components.burnable:Extinguish()
   		 end
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue1")
inst:RemoveTag("lightningo1") 
inst.AnimState:SetBloomEffectHandle( "" )
inst:RemoveEventCallback("onhitother", OnHitlightning1)
		end
	--inst.components.health:SetAbsorbAmount(0.5)
inst.components.combat:SetRange(2)

	end
end
end

local function OnHitlightning2(inst, data)
local other = data.target
   local pos = other:GetPosition()
	if inst:HasTag("lightningblue2") and inst:HasTag("DLC") then
	if not other.components.burnable then
            SpawnPrefab("groundpoundring_fx").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
		other.components.health:DoDelta(-200)
    inst.components.sanity:DoDelta(-15)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue2")
inst:RemoveTag("lightningo2") 
inst.AnimState:SetBloomEffectHandle( "" )
inst:RemoveEventCallback("onhitother", OnHitlightning2)

	elseif other:HasTag("wall") or other:HasTag("structure") then
            SpawnPrefab("groundpoundring_fx").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
		other.components.health:DoDelta(-200)
    inst.components.sanity:DoDelta(-15)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue2")
inst:RemoveTag("lightningo2") 
inst.AnimState:SetBloomEffectHandle( "" )
inst:RemoveEventCallback("onhitother", OnHitlightning2)

	elseif other.components.burnable and not other:HasTag("wall") and not other:HasTag("structure") then
	do
	GetSeasonManager():DoLightningStrike(pos)
	inst.components.health:SetAbsorptionAmount(1)

            SpawnPrefab("groundpoundring_fx").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
	other.components.burnable:Ignite()
		other.components.health:DoDelta(-200)
    inst.components.sanity:DoDelta(-15)
    if other.components.burnable and other.components.burnable:IsBurning() then
        other.components.burnable:Extinguish()
   		 end
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue2")
inst:RemoveTag("lightningo2") 
inst.AnimState:SetBloomEffectHandle( "" )
inst:RemoveEventCallback("onhitother", OnHitlightning2)
		end
	--inst.components.health:SetAbsorptionAmount(0.5)
inst.components.combat:SetRange(2)
	end
end
	if inst:HasTag("lightningblue2") and not inst:HasTag("DLC") then
	if not other.components.burnable then
            SpawnPrefab("statue_transition").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
		other.components.health:DoDelta(-200)
    inst.components.sanity:DoDelta(-15)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue2")
inst:RemoveTag("lightningo2") 
inst.AnimState:SetBloomEffectHandle( "" )
inst:RemoveEventCallback("onhitother", OnHitlightning2)

	elseif other:HasTag("wall") or other:HasTag("structure") then
            SpawnPrefab("statue_transition").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
		other.components.health:DoDelta(-200)
    inst.components.sanity:DoDelta(-15)
inst.components.combat:SetRange(2)
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue2")
inst:RemoveTag("lightningo2") 
inst.AnimState:SetBloomEffectHandle( "" )
inst:RemoveEventCallback("onhitother", OnHitlightning2)

	elseif other.components.burnable and not other:HasTag("wall") and not other:HasTag("structure") then
	do
	GetSeasonManager():DoLightningStrike(pos)
	inst.components.health:SetAbsorbAmount(1)

            SpawnPrefab("statue_transition").Transform:SetPosition(other:GetPosition():Get())
	            SpawnPrefab("collapse_small").Transform:SetPosition(other:GetPosition():Get())
	other.components.burnable:Ignite()
		other.components.health:DoDelta(-200)
    inst.components.sanity:DoDelta(-15)
    if other.components.burnable and other.components.burnable:IsBurning() then
        other.components.burnable:Extinguish()
   		 end
	 if not inst.nsleep then inst.Light:Enable(false) end
inst:RemoveTag("lightningblue2")
inst:RemoveTag("lightningo2") 
inst.AnimState:SetBloomEffectHandle( "" )
inst:RemoveEventCallback("onhitother", OnHitlightning2)
		end
	--inst.components.health:SetAbsorbAmount(0.5)
inst.components.combat:SetRange(2)
	end
end
end
]]--


local function fshieldupgrade(inst, data)

	if inst:HasTag("Fshield1") and inst:HasTag("frameon1") then
    inst:ListenForEvent("attacked", Onframeshield1)
	elseif inst:HasTag("Fshield2") and inst:HasTag("frameon2") then
    inst:ListenForEvent("attacked", Onframeshield2)
	elseif inst:HasTag("Fshield3") and inst:HasTag("frameon3") then
    inst:ListenForEvent("attacked", Onframeshield3)
	elseif inst:HasTag("Fshield4") and inst:HasTag("frameon4") then
    inst:ListenForEvent("attacked", Onframeshield4)
end
	if not inst:HasTag("frameon1") and not inst:HasTag("frameon2") and not inst:HasTag("frameon3") and not inst:HasTag("frameon4") then
	     inst:RemoveEventCallback("attacked", Onframeshield1)
	     inst:RemoveEventCallback("attacked", Onframeshield2)
	     inst:RemoveEventCallback("attacked", Onframeshield3)
	     inst:RemoveEventCallback("attacked", Onframeshield4)
end
end

local function OnHitcritical(inst, data)
local hitcriticalchance1 = 0.07
local hitcriticalchance2 = 0.1
local hitcriticalchance3 = 0.13
local hitcriticalchance4 = 0.15

    local other = data.target
    if math.random() < hitcriticalchance1 and inst:HasTag("Hitcritical1") then
    SpawnPrefab("explode_small").Transform:SetPosition(other:GetPosition():Get())
	 inst.SoundEmitter:PlaySound("dontstarve/tentacle/tentacle_emerge")
	    other.components.health:DoDelta(-30)

     elseif math.random() < hitcriticalchance2 and inst:HasTag("Hitcritical2") then
      SpawnPrefab("explode_small").Transform:SetPosition(other:GetPosition():Get())
	 inst.SoundEmitter:PlaySound("dontstarve/tentacle/tentacle_emerge")
	    other.components.health:DoDelta(-40)

    elseif math.random() < hitcriticalchance3 and inst:HasTag("Hitcritical3") then
     SpawnPrefab("explode_small").Transform:SetPosition(other:GetPosition():Get())
	 inst.SoundEmitter:PlaySound("dontstarve/tentacle/tentacle_emerge")
	    other.components.health:DoDelta(-50)

    elseif math.random() < hitcriticalchance4 and inst:HasTag("Hitcritical4") then
       SpawnPrefab("explode_small").Transform:SetPosition(other:GetPosition():Get())
	 inst.SoundEmitter:PlaySound("dontstarve/tentacle/tentacle_emerge")
	    other.components.health:DoDelta(-60)

    end
	 		inst:RemoveEventCallback("onhitother", OnHitcritical) 
end

local function removeskill(inst, data)
	if not inst:HasTag("frameon1") and not inst:HasTag("frameon2") and not inst:HasTag("frameon3") and not inst:HasTag("frameon4") then
	     inst:RemoveEventCallback("attacked", Onframeshield1)
	     inst:RemoveEventCallback("attacked", Onframeshield2)
	     inst:RemoveEventCallback("attacked", Onframeshield3)
	     inst:RemoveEventCallback("attacked", Onframeshield4)
end
--if not inst:HasTag("Valkyrieh") then
--    inst:RemoveEventCallback("onhitother", OnHitcritical)
--end
end
----------
local function fullmoon_buff(inst)
inst:DoPeriodicTask(10, function() if inst.fullmoon then inst.components.sanity:DoDelta(1) end end)
end 

----------

    local function tryproc(inst)

 if not inst.activeh1 and math.random() < .2 and inst:HasTag("healshield1") and not inst:HasTag("healshield2") and not inst:HasTag("healshield3") and not inst:HasTag("healshield4") and not inst.components.health:IsDead() then
           healshield1_proc(inst)
 elseif not inst.activeh2 and math.random() < .25 and inst:HasTag("healshield2") and not inst:HasTag("healshield1") and not inst:HasTag("healshield3") and not inst:HasTag("healshield4")   and not inst.components.health:IsDead() then
           healshield2_proc(inst)
 elseif not inst.activeh3 and math.random() < .3 and inst:HasTag("healshield3") and not inst:HasTag("healshield1") and not inst:HasTag("healshield2") and not inst:HasTag("healshield4")  and not inst.components.health:IsDead() then
           healshield3_proc(inst)
 elseif not inst.activeh4 and math.random() < .35 and inst:HasTag("healshield4") and not inst:HasTag("healshield1") and not inst:HasTag("healshield2") and not inst:HasTag("healshield3")  and not inst.components.health:IsDead() then
           healshield4_proc(inst)
 	elseif not inst.activelc1 and math.random() < .1 and inst:HasTag("lessercure1") and not inst:HasTag("lessercure2") and not inst.components.health:IsDead() then
           lessercure_proc(inst)
 	elseif not inst.activelc2 and math.random() < .1 and inst:HasTag("lessercure2") and not inst:HasTag("lessercure1") and not inst.components.health:IsDead() then
           lessercure2_proc(inst)
end
end

    local function shieldproc(inst)

---shield cooltime
	if not inst.activec0 and inst:HasTag("cure0") and not inst:HasTag("cure1") and not inst:HasTag("cure2") and not inst:HasTag("shieldon") and not inst.components.health:IsDead() then
           cure0_proc(inst)
	inst:AddTag("cureoo0") 
	inst:AddTag("shieldon2") 
	inst:AddTag("effectsheild") 

	--inst.components.talker:Say("Charged [Shield]\n((T))")

    elseif not inst.activec1 and inst:HasTag("cure1") and not inst:HasTag("cure0") and not inst:HasTag("cure2") and not inst:HasTag("shieldon") and not inst.components.health:IsDead() then
           cure1_proc(inst)
	inst:AddTag("cureoo1") 
	inst:AddTag("shieldon2") 
	inst:AddTag("effectsheild") 

	---inst.components.talker:Say("Charged [Shield]\n((T))")

    elseif not inst.activec2 and inst:HasTag("cure2") and not inst:HasTag("cure0") and not inst:HasTag("cure1") and not inst:HasTag("shieldon") and not inst.components.health:IsDead() then
           cure2_proc(inst)
	inst:AddTag("cureoo2") 
	inst:AddTag("shieldon2") 
	inst:AddTag("effectsheild") 

	---inst.components.talker:Say("Charged [Shield]\n((T))")


end
if inst:HasTag("cureo0") and inst:HasTag("shieldon2") 
then
           cure0_proc(inst)
	inst:AddTag("shieldon") 
inst:RemoveTag("effectsheild") 


elseif inst:HasTag("cureo1") and inst:HasTag("shieldon2") 
then

           cure1_proc(inst)
	inst:AddTag("shieldon") 
inst:RemoveTag("effectsheild") 

elseif inst:HasTag("cureo2") and inst:HasTag("shieldon2") 
then

           cure2_proc(inst)
	inst:AddTag("shieldon") 
inst:RemoveTag("effectsheild") 

elseif inst:HasTag("effectsheild") and inst:HasTag("effectsheild2") 
then
	local sparks = SpawnPrefab("sparks")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	sparks.Transform:SetPosition(pos:Get())
	inst.components.talker:Say("Full charged [Shield]")
inst:RemoveTag("effectsheild2") 
        end
    end

local shieldchance = .25
--local lightningchance = 0.2

local function powerattack(inst, data)
if inst:HasTag("Valkyrieh") and inst:HasTag("Hitlightning1") and not inst:HasTag("lightningo1") and not inst:HasTag("lightningblue1") then
	inst:AddTag("lightningo1") 
	local sparks = SpawnPrefab("sparks")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	sparks.Transform:SetPosition(pos:Get())
   inst:ListenForEvent("onhitother", OnHitlightning1)

elseif inst:HasTag("Valkyrieh") and inst:HasTag("Hitlightning2") and not inst:HasTag("lightningo2") and not inst:HasTag("lightningblue2") then
	inst:AddTag("lightningo2") 
	local sparks = SpawnPrefab("sparks")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	sparks.Transform:SetPosition(pos:Get())
    inst:ListenForEvent("onhitother", OnHitlightning2)

	end

				if not inst:HasTag("Valkyrieh") then
	inst:RemoveTag("lightningo1") 
	inst:RemoveTag("lightningblue1") 
	inst:RemoveTag("lightningo2") 
	inst:RemoveTag("lightningblue2") 
	 if not inst.nsleep then inst.Light:Enable(false) end
inst.AnimState:SetBloomEffectHandle( "" )
inst.components.combat:SetRange(2)
    inst:RemoveEventCallback("onhitother", OnHitlightning1)
    inst:RemoveEventCallback("onhitother", OnHitlightning2)

end
end

local function sneakattack(inst, data)
    local other = data.target
  
if inst:HasTag("backstab1") and inst:HasTag("sneaka") and not other:HasTag("wall") and not other:HasTag("structure") and not other:HasTag("pillarretracting") and not other:HasTag("tentacle_pillar") then

if not other.sg:HasStateTag("attack") and not other.sg:HasStateTag("shield") and not other.sg:HasStateTag("moving") and not other:HasTag("wall") and not other:HasTag("structure") and not other.sg:HasStateTag("frozen") then
	inst.components.colourtweener:StartTween({1,1,1,1}, 0)
inst:RemoveTag("sneaka") 
	inst.components.talker:Say("Successful Backstab !!")
        other.components.health:DoDelta(-400)
	local dark1 = SpawnPrefab("statue_transition")
	local pos = Vector3(other.Transform:GetWorldPosition())
	dark1.Transform:SetPosition(pos:Get())
	dark1.Transform:SetScale(0.5,4,0.5)
	local fx = SpawnPrefab("explode_small")
	local pos = Vector3(other.Transform:GetWorldPosition())
	fx.Transform:SetPosition(pos:Get())
inst:RemoveTag("notarget") 
        other.SoundEmitter:PlaySound("dontstarve/wilson/blowdart_impact_sleep")
	--inst.components.sanityaura.penalty = 0
	--inst.components.sanity:RecalculatePenalty()
	inst.components.sanity:DoDelta(80)

elseif other.sg:HasStateTag("frozen") then
	inst.components.colourtweener:StartTween({1,1,1,1}, 0)
inst:RemoveTag("sneaka") 
	inst.components.talker:Say("Successful Backstab !!\nFrozen target-half damage")
        other.components.health:DoDelta(-200)
	local dark1 = SpawnPrefab("statue_transition")
	local pos = Vector3(other.Transform:GetWorldPosition())
	dark1.Transform:SetPosition(pos:Get())
	dark1.Transform:SetScale(0.5,4,0.5)
	local fx = SpawnPrefab("explode_small")
	local pos = Vector3(other.Transform:GetWorldPosition())
	fx.Transform:SetPosition(pos:Get())
inst:RemoveTag("notarget") 
        other.SoundEmitter:PlaySound("dontstarve/wilson/blowdart_impact_sleep")
	--inst.components.sanityaura.penalty = 0
	--inst.components.sanity:RecalculatePenalty()
	inst.components.sanity:DoDelta(80)

    elseif other.sg:HasStateTag("attack") or other.sg:HasStateTag("shield") or other.sg:HasStateTag("moving") then
	inst.components.colourtweener:StartTween({1,1,1,1}, 0)
inst:RemoveTag("sneaka") 
	inst.components.talker:Say("Failed Backstab..")
	local fx = SpawnPrefab("splash")
	local pos = Vector3(other.Transform:GetWorldPosition())
	fx.Transform:SetPosition(pos:Get())
	inst:RemoveTag("notarget") 

end
elseif inst:HasTag("backstab2") and inst:HasTag("sneaka") and not other:HasTag("wall") and not other:HasTag("structure") then
	    if not other.sg:HasStateTag("attack") and not other.sg:HasStateTag("shield") and not other.sg:HasStateTag("moving") and not other:HasTag("wall") and not other:HasTag("structure") and not other.sg:HasStateTag("frozen") then
	inst.components.colourtweener:StartTween({1,1,1,1}, 0)
inst:RemoveTag("sneaka") 
	inst.components.talker:Say("Successful Backstab !!")
        other.components.health:DoDelta(-700)
	local dark1 = SpawnPrefab("statue_transition")
	local pos = Vector3(other.Transform:GetWorldPosition())
	dark1.Transform:SetPosition(pos:Get())
	dark1.Transform:SetScale(0.5,4,0.5)
	local fx = SpawnPrefab("explode_small")
	local pos = Vector3(other.Transform:GetWorldPosition())
	fx.Transform:SetPosition(pos:Get())
inst:RemoveTag("notarget") 
        other.SoundEmitter:PlaySound("dontstarve/wilson/blowdart_impact_sleep")
	inst.components.sanity:DoDelta(160)

elseif other.sg:HasStateTag("frozen") then
	inst.components.colourtweener:StartTween({1,1,1,1}, 0)
inst:RemoveTag("sneaka") 
	inst.components.talker:Say("Successful Backstab !!\nFrozen target-half damage")
        other.components.health:DoDelta(-350)
	local dark1 = SpawnPrefab("statue_transition")
	local pos = Vector3(other.Transform:GetWorldPosition())
	dark1.Transform:SetPosition(pos:Get())
	dark1.Transform:SetScale(0.5,4,0.5)
	local fx = SpawnPrefab("explode_small")
	local pos = Vector3(other.Transform:GetWorldPosition())
	fx.Transform:SetPosition(pos:Get())
inst:RemoveTag("notarget") 
        other.SoundEmitter:PlaySound("dontstarve/wilson/blowdart_impact_sleep")
	inst.components.sanity:DoDelta(160)

    elseif other.sg:HasStateTag("attack") or other.sg:HasStateTag("shield") or other.sg:HasStateTag("moving") then
	inst.components.colourtweener:StartTween({1,1,1,1}, 0)
inst:RemoveTag("sneaka") 
	inst.components.talker:Say("Failed Backstab..")
	local fx = SpawnPrefab("splash")
	local pos = Vector3(other.Transform:GetWorldPosition())
	fx.Transform:SetPosition(pos:Get())
	inst:RemoveTag("notarget") 


end
elseif inst:HasTag("backstab3") and inst:HasTag("sneaka") and not other:HasTag("wall") and not other:HasTag("structure") then
	    if not other.sg:HasStateTag("attack") and not other.sg:HasStateTag("shield") and not other.sg:HasStateTag("moving") and not other:HasTag("wall") and not other:HasTag("structure") and not other.sg:HasStateTag("frozen") then
	inst.components.colourtweener:StartTween({1,1,1,1}, 0)
inst:RemoveTag("sneaka") 
	inst.components.talker:Say("Successful Backstab !!")
        other.components.health:DoDelta(-1000)
	local dark1 = SpawnPrefab("statue_transition")
	local pos = Vector3(other.Transform:GetWorldPosition())
	dark1.Transform:SetPosition(pos:Get())
	dark1.Transform:SetScale(0.5,4,0.5)
	local fx = SpawnPrefab("explode_small")
	local pos = Vector3(other.Transform:GetWorldPosition())
	fx.Transform:SetPosition(pos:Get())
inst:RemoveTag("notarget") 
        other.SoundEmitter:PlaySound("dontstarve/wilson/blowdart_impact_sleep")
	inst.components.sanity:DoDelta(240)

elseif other.sg:HasStateTag("frozen") then
	inst.components.colourtweener:StartTween({1,1,1,1}, 0)
inst:RemoveTag("sneaka") 
	inst.components.talker:Say("Successful Backstab !!\nFrozen target-half damage")
        other.components.health:DoDelta(-500)
	local dark1 = SpawnPrefab("statue_transition")
	local pos = Vector3(other.Transform:GetWorldPosition())
	dark1.Transform:SetPosition(pos:Get())
	dark1.Transform:SetScale(0.5,4,0.5)
	local fx = SpawnPrefab("explode_small")
	local pos = Vector3(other.Transform:GetWorldPosition())
	fx.Transform:SetPosition(pos:Get())
inst:RemoveTag("notarget") 
        other.SoundEmitter:PlaySound("dontstarve/wilson/blowdart_impact_sleep")
	inst.components.sanity:DoDelta(240)

    elseif other.sg:HasStateTag("attack") or other.sg:HasStateTag("shield") or other.sg:HasStateTag("moving") then
	inst.components.colourtweener:StartTween({1,1,1,1}, 0)
inst:RemoveTag("sneaka") 
	inst.components.talker:Say("Failed Backstab..")
	local fx = SpawnPrefab("splash")
	local pos = Vector3(other.Transform:GetWorldPosition())
	fx.Transform:SetPosition(pos:Get())
	inst:RemoveTag("notarget") 

end
    end
end

local function fsneakattack(inst, data)
    if inst:HasTag("sneaka") then
	inst.components.colourtweener:StartTween({1,1,1,1}, 0)
inst:RemoveTag("sneaka") 
	local fx = SpawnPrefab("statue_transition_2")
        fx.entity:SetParent(inst.entity)
	fx.Transform:SetScale(1.2, 1.2, 1.2)
        fx.Transform:SetPosition(0, 0, 0)
	inst.components.talker:Say("Musha discovered by enemy !")
inst:RemoveTag("notarget") 
    end
end

local function shadows(inst, data)
--if inst.level >7002 and 
--and not inst:HasTag("shadowmusha") 
	local player = GetPlayer()
if inst.level >7003 and inst:HasTag("shadowb") and inst:HasTag("shadows") and inst.components.sanity:GetMaxSanity() >= 50 and inst.components.health.currenthealth >= 40 then

        			inst.level = inst.level - 2

        local bunsin = SpawnPrefab("shadowmusha")
	local dark2 = SpawnPrefab("statue_transition_2")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	dark2.Transform:SetPosition(pos:Get())
	bunsin.Transform:SetPosition(pos:Get())
        bunsin.components.follower:SetLeader(player)
        inst.components.health:DoDelta(-30)
        inst.SoundEmitter:PlaySound("dontstarve/maxwell/shadowmax_appear")

	levelexp(inst)	

end
inst:RemoveTag("shadows") 
end

local function gdogs(inst, data)
--and not inst:HasTag("shadowmusha") 
local dogchance = 0.3
local dogchance2 = 0.2
	local player = GetPlayer()
if math.random() < dogchance and inst:HasTag("ghoundb") and inst:HasTag("ghound") and inst.components.health.currenthealth >= 40 and not inst:HasTag("ghounds") then
inst:AddTag("ghounds") 
if inst.components.playercontroller then
  inst.components.playercontroller:Enable(false)
  inst.music_armor = true
inst.sg:GoToState("play_flute")
--inst.sg:GoToState("enter_onemanband")
scheduler:ExecuteInTime(3, function()
inst.components.playercontroller:Enable(true) 
        local dog = SpawnPrefab("ghosthound")
	local dark2 = SpawnPrefab("statue_transition_2")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	dark2.Transform:SetPosition(pos:Get())
	dog.Transform:SetPosition(pos:Get())
        dog.components.follower:SetLeader(player)
        inst.components.health:DoDelta(-15)
       -- inst.components.sanity:DoDelta(-20)
inst.SoundEmitter:PlaySound("dontstarve/maxwell/shadowmax_appear")
inst:RemoveTag("ghound")
inst.music_armor = false
 end) end 
elseif math.random() < dogchance2 and inst:HasTag("ghoundb") and inst:HasTag("ghound") and inst.components.health.currenthealth >= 40 and not inst:HasTag("ghounds") then
inst:AddTag("ghounds") 
if inst.components.playercontroller then
  inst.components.playercontroller:Enable(false)
  inst.music_armor = true
--inst.sg:GoToState("play_flute")
inst.sg:GoToState("enter_onemanband")
scheduler:ExecuteInTime(2, function() inst.SoundEmitter:PlaySound("dontstarve/wilson/onemanband") inst.sg:GoToState("play_flute") scheduler:ExecuteInTime(4, function() inst.components.playercontroller:Enable(true) 
        local dog = SpawnPrefab("ghosthound")
	local dog2 = SpawnPrefab("ghosthound")
	local dark2 = SpawnPrefab("statue_transition_2")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	dark2.Transform:SetPosition(pos:Get())
	dog.Transform:SetPosition(pos:Get())
        dog.components.follower:SetLeader(player)
	dog2.Transform:SetPosition(pos:Get())
        dog2.components.follower:SetLeader(player)
        inst.components.health:DoDelta(-15)
        inst.components.sanity:DoDelta(20)
		inst.SoundEmitter:PlaySound("dontstarve/wilson/onemanband") inst.sg:GoToState("play_flute")
inst.SoundEmitter:PlaySound("dontstarve/maxwell/shadowmax_appear")
inst:RemoveTag("ghound")
inst.music_armor = false
 end) end) end 
elseif inst:HasTag("ghoundb") and inst:HasTag("ghound") and inst.components.health.currenthealth >= 40 and not inst:HasTag("ghounds") then
inst:AddTag("ghounds") 
if inst.components.playercontroller then
inst.music_armor = true
  inst.components.playercontroller:Enable(false)
inst.sg:GoToState("play_flute")
--inst.sg:GoToState("enter_onemanband")
scheduler:ExecuteInTime(3, function()
inst.components.playercontroller:Enable(true) 
        local dog = SpawnPrefab("ghosthound")
	local dark2 = SpawnPrefab("statue_transition_2")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	dark2.Transform:SetPosition(pos:Get())
	dog.Transform:SetPosition(pos:Get())
        dog.components.follower:SetLeader(player)
        inst.components.health:DoDelta(-15)
       -- inst.components.sanity:DoDelta(-20)
inst.SoundEmitter:PlaySound("dontstarve/maxwell/shadowmax_appear")
inst:RemoveTag("ghound")
inst.music_armor = false
 end) end 

 end end

local function valkyriehp(inst, data)

--[[valkyrie status and DLC]]
--[[if inst:HasTag("valkyrieh") then
   inst:ListenForEvent("onhitother", OnHitcritical)
elseif not inst:HasTag("valkyrieh") then
	inst:RemoveEventCallback("onhitother", OnHitcritical) 
end]]

if inst:HasTag("DLC") and not inst:HasTag("cureo0") and not inst:HasTag("cureo1") and not inst:HasTag("cureo2") and not inst.components.health:IsDead() and not inst.music_armor then
if inst:HasTag("valkyrieh") then
inst.components.health:StartRegen(1, 4)
end
if inst:HasTag("valkyrieh") and inst.components.health:GetPercent() < .3 then
	--inst.components.health:StartRegen(1, 4)
	inst.components.health:SetAbsorptionAmount(0.5)
elseif inst:HasTag("valkyrieh") and inst.components.health:GetPercent() >= .3 and inst.components.health:GetPercent() < .4 then
	--inst.components.health:StartRegen(1, 6)
	inst.components.health:SetAbsorptionAmount(0.45)
elseif inst:HasTag("valkyrieh") and inst.components.health:GetPercent() >= .4 and inst.components.health:GetPercent() < .5 then
	--inst.components.health:StartRegen(1, 8)
	inst.components.health:SetAbsorptionAmount(0.4)
elseif inst:HasTag("valkyrieh") and inst.components.health:GetPercent() >= .5 and inst.components.health:GetPercent() < .6 then
	--inst.components.health:StartRegen(1, 10)
	inst.components.health:SetAbsorptionAmount(0.35)
elseif inst:HasTag("valkyrieh") and inst.components.health:GetPercent() >= .6 and inst.components.health:GetPercent() < .7 then
	--inst.components.health:StartRegen(1, 12)
	inst.components.health:SetAbsorptionAmount(0.3)
elseif inst:HasTag("valkyrieh") and inst.components.health:GetPercent() >= .7 and inst.components.health:GetPercent() < .8 then
	--inst.components.health:StartRegen(1, 14)
	inst.components.health:SetAbsorptionAmount(0.25)
elseif inst:HasTag("valkyrieh") and inst.components.health:GetPercent() >= .8 and inst.components.health:GetPercent() <= 1 then
	--inst.components.health:StartRegen(1, 16)
	inst.components.health:SetAbsorptionAmount(0.2)

	elseif inst:HasTag("berserkarmor") and inst:HasTag("crazy") and not inst:HasTag("valkyrieh") then
	inst.components.health:StartRegen(1, 1)
	inst.components.health:SetAbsorptionAmount(0.2)

	elseif not inst:HasTag("berserkarmor") and inst:HasTag("crazy")  then
	inst.components.health:StartRegen(0, 0)
	inst.components.health:SetAbsorptionAmount(0)

	elseif not inst:HasTag("valkyrieh") and not inst:HasTag("crazy")  then
	inst.components.health:StartRegen(0, 0)
	inst.components.health:SetAbsorptionAmount(0)

	end


--[[valkyrie status and Orizinal]]


if not inst:HasTag("DLC") and not inst:HasTag("cureo0") and not inst:HasTag("cureo1") and not inst:HasTag("cureo2") and not inst.components.health:IsDead() and not inst.music_armor then
if inst:HasTag("valkyrieh") then
inst.components.health:StartRegen(1, 3)
end
if inst:HasTag("valkyrieh") and inst.components.health:GetPercent() < .3 then
	--inst.components.health:StartRegen(1, 4)
	inst.components.health:SetAbsorbAmount(0.5)
elseif inst:HasTag("valkyrieh") and inst.components.health:GetPercent() >= .3 and inst.components.health:GetPercent() < .4 then
	--inst.components.health:StartRegen(1, 6)
	inst.components.health:SetAbsorbAmount(0.45)
elseif inst:HasTag("valkyrieh") and inst.components.health:GetPercent() >= .4 and inst.components.health:GetPercent() < .5 then
	--inst.components.health:StartRegen(1, 8)
	inst.components.health:SetAbsorbAmount(0.4)
elseif inst:HasTag("valkyrieh") and inst.components.health:GetPercent() >= .5 and inst.components.health:GetPercent() < .6 then
	--inst.components.health:StartRegen(1, 10)
	inst.components.health:SetAbsorbAmount(0.35)
elseif inst:HasTag("valkyrieh") and inst.components.health:GetPercent() >= .6 and inst.components.health:GetPercent() < .7 then
	--inst.components.health:StartRegen(1, 12)
	inst.components.health:SetAbsorbAmount(0.3)
elseif inst:HasTag("valkyrieh") and inst.components.health:GetPercent() >= .7 and inst.components.health:GetPercent() < .8 then
	--inst.components.health:StartRegen(1, 14)
	inst.components.health:SetAbsorbAmount(0.25)
elseif inst:HasTag("valkyrieh") and inst.components.health:GetPercent() >= .8 and inst.components.health:GetPercent() <= 1 then
	--inst.components.health:StartRegen(1, 16)
	inst.components.health:SetAbsorbAmount(0.2)

	elseif inst:HasTag("berserkarmor") and inst:HasTag("crazy") and not inst:HasTag("valkyrieh") then
	inst.components.health:StartRegen(1, 1)
	inst.components.health:SetAbsorbAmount(0.2)

	elseif not inst:HasTag("valkyrieh") and not  inst:HasTag("berserkarmor") and not inst:HasTag("crazy") then
	inst.components.health:StartRegen(0, 0)
	inst.components.health:SetAbsorbAmount(0)

	end

end
end

end


local function applystats(inst)

    if GetClock():IsDay() then
		if inst.strength == "full" then
			
			inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1.3)
			TUNING.SANITY_DAY_GAIN = 10/60

		elseif inst.strength == "normal" then	
			inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1.0)
			TUNING.SANITY_DAY_GAIN = 0/60
	
		elseif inst.strength == "Valkyrie" then
			inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 5)
			TUNING.SANITY_DAY_GAIN = 0/60

		elseif inst.strength == "berserk" then
	
			inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 0.6)
			TUNING.SANITY_DAY_GAIN = -25/60
			--inst.components.temperature.hurtrate = 0

		end

 	elseif GetClock():IsDusk() then
		if inst.strength == "full" then	

			inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1.2)
			TUNING.SANITY_NIGHT_LIGHT = 5/60
			TUNING.SANITY_NIGHT_MID = 2/60

		elseif inst.strength == "normal" then	

			inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 0.9)
			TUNING.SANITY_NIGHT_LIGHT = 0/60
			TUNING.SANITY_NIGHT_MID = -8/60

		elseif inst.strength == "Valkyrie" then
			inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 5)
			TUNING.SANITY_NIGHT_LIGHT = 0/60
			TUNING.SANITY_NIGHT_MID = -10/60

		elseif inst.strength == "berserk" then

			inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 0.5)
			TUNING.SANITY_NIGHT_LIGHT = -25/60
			TUNING.SANITY_NIGHT_MID = -25/60
			--inst.components.temperature.hurtrate = 0

		end

    elseif GetClock():IsNight() then
		if inst.strength == "full" then	

			inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1.0)
			TUNING.SANITY_NIGHT_LIGHT = 2/60
			TUNING.SANITY_NIGHT_DARK = 0/60

		elseif inst.strength == "normal" then	
	
			inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 0.8)
			TUNING.SANITY_NIGHT_LIGHT = -8/60
			TUNING.SANITY_NIGHT_DARK = -15/60

		elseif inst.strength == "Valkyrie" then
			inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 5)
			TUNING.SANITY_NIGHT_LIGHT = -10/60
			TUNING.SANITY_NIGHT_DARK = -17/60

		elseif inst.strength == "berserk" then

			inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 0.4 )
			TUNING.SANITY_NIGHT_LIGHT = -25/60
			TUNING.SANITY_NIGHT_DARK = -25/60
			--inst.components.temperature.hurtrate = 0

		end	
	end
end


local function phasechange(inst, data)
			
if inst.strength == "full" then
inst.valkyrie = false
inst.berserk = false
			if not inst.visual_hold then
			inst.AnimState:SetBuild("musha")
			end
	if inst:HasTag("Valkyrie") and inst:HasTag("Valkyrieh") and not inst:HasTag("berserks") and not inst:HasTag("fberserk") then

			inst.strength = "Valkyrie"
inst.valkyrie = true
inst.berserk = false
	inst.soundsname = "willow"
inst:RemoveTag("crazy")
    --inst.components.combat:SetAttackPeriod(.15)
inst.components.combat:SetAreaDamage(0, 0)
    inst:RemoveEventCallback("attacked", Onfreeze)
    inst:RemoveEventCallback("onhitother", berserkattack)
    inst:RemoveEventCallback("onhitother", OnHitfreeze)
    inst:ListenForEvent("onhitother", OnHitcritical)

inst.components.health.fire_damage_scale = 0
--inst.components.temperature.hurtrate = 1
	local sparks = SpawnPrefab("sparks")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	sparks.Transform:SetPosition(pos:Get())

		--inst.components.talker:Say("I am Valkyrie !")
			if not inst.visual_hold then
			inst.AnimState:SetBuild("musha_battle")
			end
		elseif inst.components.hunger.current < 160 and inst.components.hunger.current > 40 and not inst:HasTag("Valkyrieh") and not inst:HasTag("berserks") and not inst:HasTag("fberserk") then

			inst.strength = "normal"
inst.valkyrie = false
inst.berserk = false	
	inst.soundsname = "willow"
inst:RemoveTag("crazy")
    --inst.components.combat:SetAttackPeriod(.5)
inst.components.combat:SetAreaDamage(0, 0)
    inst:RemoveEventCallback("attacked", Onfreeze)
    inst:RemoveEventCallback("onhitother", berserkattack)
    inst:RemoveEventCallback("onhitother", OnHitfreeze)

inst.components.health.fire_damage_scale = 1
--inst.components.temperature.hurtrate = 1
	
		---inst.components.talker:Say("A little bit hungry.")
		if not inst.visual_hold then
			inst.AnimState:SetBuild("musha_normal")
			end
		elseif inst:HasTag("berserks") or inst:HasTag("fberserk") then
 
			inst.strength = "berserk"
inst.valkyrie = false
inst.berserk = true
	inst.soundsname = "wendy"
inst:AddTag("crazy")
    --inst.components.combat:SetAttackPeriod(.05)
inst.components.combat:SetAreaDamage(2.5, .5)
    inst:ListenForEvent("attacked", Onfreeze)
    inst:ListenForEvent("onhitother", berserkattack)
    inst:ListenForEvent("onhitother", OnHitfreeze)

inst.components.health.fire_damage_scale = 1
--inst.components.temperature.hurtrate = 0
	inst:RemoveTag("Valkyrieh") 
	inst:AddTag("Valkyriech2") 
	local dark1 = SpawnPrefab("statue_transition")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	dark1.Transform:SetPosition(pos:Get())

			inst.components.talker:Say("Krrrrrr...")
		if not inst.visual_hold then
			inst.AnimState:SetBuild("musha_hunger")
			end
		end

else
if inst.strength == "Valkyrie" then
inst.valkyrie = true
inst.berserk = false
		if not inst.visual_hold then
			inst.AnimState:SetBuild("musha_battle")
			end
		if inst.components.hunger.current < 160 and inst:HasTag("Valkyriech2") and not inst:HasTag("berserks") and not inst:HasTag("fberserk") then

			inst.strength = "normal"
inst.valkyrie = false
inst.berserk = false
	inst.soundsname = "willow"
inst:RemoveTag("crazy")
    --inst.components.combat:SetAttackPeriod(.5)
inst.components.combat:SetAreaDamage(0, 0)
inst.components.combat:SetRange(2)
    inst:RemoveEventCallback("attacked", Onfreeze)
    inst:RemoveEventCallback("onhitother", berserkattack)
    inst:RemoveEventCallback("onhitother", OnHitfreeze)
inst.components.health.fire_damage_scale = 1
--inst.components.temperature.hurtrate = 1
		inst:RemoveTag("Valkyrieh")
	local sparks = SpawnPrefab("sparks")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	sparks.Transform:SetPosition(pos:Get())
		 if not inst.nsleep then inst.Light:Enable(false) end
inst.AnimState:SetBloomEffectHandle( "" )
			--inst.components.talker:Say("Musha, feels elsweyr")
		if not inst.visual_hold then
			inst.AnimState:SetBuild("musha_normal")
			end
		elseif inst.components.hunger.current > 160 and inst:HasTag("Valkyriech2") and not inst:HasTag("fberserk") and not inst:HasTag("berserks") then

			inst.strength = "full"
inst.valkyrie = false
inst.berserk = false
	inst.soundsname = "willow"
inst:RemoveTag("crazy")
    --inst.components.combat:SetAttackPeriod(.6)
inst.components.combat:SetAreaDamage(0, 0)
inst.components.combat:SetRange(2)
    inst:RemoveEventCallback("attacked", Onfreeze)
    inst:RemoveEventCallback("onhitother", berserkattack)
    inst:RemoveEventCallback("onhitother", OnHitfreeze)
inst.components.health.fire_damage_scale = 1
--inst.components.temperature.hurtrate = 1
		inst:RemoveTag("Valkyrieh")
	local sparks = SpawnPrefab("sparks")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	sparks.Transform:SetPosition(pos:Get())
		 if not inst.nsleep then inst.Light:Enable(false) end
inst.AnimState:SetBloomEffectHandle( "" )
		if not inst.visual_hold then
			inst.AnimState:SetBuild("musha")
			end
	--	inst.components.talker:Say("Easy")

		elseif inst:HasTag("berserks") or inst:HasTag("fberserk") then
 
			inst.strength = "berserk"
inst.valkyrie = false
inst.berserk = true
	inst.soundsname = "wendy"
inst:AddTag("crazy")
    --inst.components.combat:SetAttackPeriod(.05)
inst.components.combat:SetAreaDamage(2.5, .5)
inst.components.combat:SetRange(2)
    inst:ListenForEvent("attacked", Onfreeze)
    inst:ListenForEvent("onhitother", berserkattack)
    inst:ListenForEvent("onhitother", OnHitfreeze)
inst.components.health.fire_damage_scale = 1
--inst.components.temperature.hurtrate = 0
	inst:RemoveTag("Valkyrieh") 
	inst:AddTag("Valkyriech2") 
	local dark1 = SpawnPrefab("statue_transition")
	local pos = Vector3(inst.Transform:GetWorldPosition())
		dark1.Transform:SetPosition(pos:Get())
inst.AnimState:SetBloomEffectHandle( "" )
			inst.components.talker:Say("Grrrrrr...")
		if not inst.visual_hold then
			inst.AnimState:SetBuild("musha_hunger")
			end
		end

else
if inst.strength == "normal" then
inst.valkyrie = false
inst.berserk = false
		if not inst.visual_hold then
			inst.AnimState:SetBuild("musha_normal")
			end
	if inst:HasTag("Valkyrieh") and not inst:HasTag("berserks") and not inst:HasTag("fberserk") then

			inst.strength = "Valkyrie"
inst.valkyrie = true
inst.berserk = false
	inst.soundsname = "willow"
inst:RemoveTag("crazy")
    --inst.components.combat:SetAttackPeriod(.15)
inst.components.combat:SetAreaDamage(0, 0)
    inst:RemoveEventCallback("attacked", Onfreeze)
    inst:RemoveEventCallback("onhitother", berserkattack)
    inst:RemoveEventCallback("onhitother", OnHitfreeze)
    inst:ListenForEvent("onhitother", OnHitcritical)

inst.components.health.fire_damage_scale = 0
--inst.components.temperature.hurtrate = 1
	local sparks = SpawnPrefab("sparks")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	sparks.Transform:SetPosition(pos:Get())

		--inst.components.talker:Say("For battle !!")
		if not inst.visual_hold then
			inst.AnimState:SetBuild("musha_battle")
			end
		elseif inst.components.hunger.current > 160 and not inst:HasTag("Valkyrieh") and not inst:HasTag("berserks") and not inst:HasTag("fberserk") then

			inst.strength = "full"
inst.valkyrie = false
inst.berserk = false	
	inst.soundsname = "willow"
inst:RemoveTag("crazy")
    --inst.components.combat:SetAttackPeriod(.6)
inst.components.combat:SetAreaDamage(0, 0)
    inst:RemoveEventCallback("attacked", Onfreeze)
    inst:RemoveEventCallback("onhitother", berserkattack)
    inst:RemoveEventCallback("onhitother", OnHitfreeze)

inst.components.health.fire_damage_scale = 1
	
		--inst.components.talker:Say("Happy mind !")
		if not inst.visual_hold then
			inst.AnimState:SetBuild("musha")
			end
		elseif inst:HasTag("berserks") or inst:HasTag("fberserk") then
 
			inst.strength = "berserk"
inst.valkyrie = false
inst.berserk = true
	inst.soundsname = "wendy"
inst:AddTag("crazy")
    --inst.components.combat:SetAttackPeriod(.05)
inst.components.combat:SetAreaDamage(2.5, .5)
    inst:ListenForEvent("attacked", Onfreeze)
    inst:ListenForEvent("onhitother", berserkattack)
    inst:ListenForEvent("onhitother", OnHitfreeze)
	local dark1 = SpawnPrefab("statue_transition")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	dark1.Transform:SetPosition(pos:Get())

inst.components.health.fire_damage_scale = 1
--inst.components.temperature.hurtrate = 0
	inst:RemoveTag("Valkyrieh") 
	inst:AddTag("Valkyriech2") 
	
			inst.components.talker:Say("Krrrrrr...")
		if not inst.visual_hold then
			inst.AnimState:SetBuild("musha_hunger")
			end
		end
else
if inst.strength == "berserk" then
inst.valkyrie = false
inst.berserk = true
		if not inst.visual_hold then
			inst.AnimState:SetBuild("musha_hunger")
			end
	if inst.components.hunger.current > 160 and not inst:HasTag("berserks") and not inst:HasTag("fberserk") then
			inst.strength = "full"
inst.valkyrie = false
inst.berserk = false
	inst.soundsname = "willow"
		inst:RemoveTag("berserks") 
		inst:RemoveTag("fberserk") 
inst:RemoveTag("crazy")
    --inst.components.combat:SetAttackPeriod(.6)
inst.components.combat:SetAreaDamage(0, 0)
    inst:RemoveEventCallback("attacked", Onfreeze)
    inst:RemoveEventCallback("onhitother", berserkattack)
    inst:RemoveEventCallback("onhitother", OnHitfreeze)
	local dark2 = SpawnPrefab("statue_transition_2")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	dark2.Transform:SetPosition(pos:Get())
inst.components.health.fire_damage_scale = 1
--inst.components.temperature.hurtrate = 1
	
	inst.components.talker:Say("... I can not remember.. ")
		if not inst.visual_hold then
			inst.AnimState:SetBuild("musha")
			end
	elseif inst.components.hunger.current < 160 and not inst:HasTag("berserks") and not inst:HasTag("fberserk") then

			inst.strength = "normal"
inst.valkyrie = false
inst.berserk = false
	inst.soundsname = "willow"
		inst:RemoveTag("berserks") 
		inst:RemoveTag("fberserk") 
inst:RemoveTag("crazy")
    --inst.components.combat:SetAttackPeriod(.5)
inst.components.combat:SetAreaDamage(0, 0)
    inst:RemoveEventCallback("attacked", Onfreeze)
    inst:RemoveEventCallback("onhitother", berserkattack)
    inst:RemoveEventCallback("onhitother", OnHitfreeze)
	local dark2 = SpawnPrefab("statue_transition_2")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	dark2.Transform:SetPosition(pos:Get())
inst.components.health.fire_damage_scale = 1
--inst.components.temperature.hurtrate = 1
	
	inst.components.talker:Say("... I can not remember.. ")
		if not inst.visual_hold then
			inst.AnimState:SetBuild("musha_normal")
			end
------force berserk

		elseif inst:HasTag("fberserk") and inst.components.sanity:GetPercent() < 0.3 and inst.components.hunger.current > 160  then
			inst.strength = "full"
inst.valkyrie = false
inst.berserk = false
	inst.soundsname = "willow"
		inst:RemoveTag("berserks") 
		inst:RemoveTag("fberserk") 
inst:RemoveTag("crazy")
    --inst.components.combat:SetAttackPeriod(.5)
inst.components.combat:SetAreaDamage(0, 0)
    inst:RemoveEventCallback("attacked", Onfreeze)
    inst:RemoveEventCallback("onhitother", berserkattack)
    inst:RemoveEventCallback("onhitother", OnHitfreeze)
	local dark2 = SpawnPrefab("statue_transition_2")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	dark2.Transform:SetPosition(pos:Get())
inst.components.health.fire_damage_scale = 1
--inst.components.temperature.hurtrate = 1
		inst:RemoveTag("berserks") 
		inst:RemoveTag("fberserk") 
inst:RemoveTag("crazy")
		inst.components.talker:Say("... I can not remember what I ate?")
		if not inst.visual_hold then
			inst.AnimState:SetBuild("musha")
			end
		elseif not inst:HasTag("berserks") and inst:HasTag("fberserk") and inst.components.sanity:GetPercent() < 0.3 and inst.components.hunger.current < 160 then
			inst.strength = "normal"
inst.valkyrie = false
inst.berserk = false	
	inst.soundsname = "willow"
		inst:RemoveTag("berserks") 
		inst:RemoveTag("fberserk") 
inst:RemoveTag("crazy")
    --inst.components.combat:SetAttackPeriod(.5)
inst.components.combat:SetAreaDamage(0, 0)
    inst:RemoveEventCallback("attacked", Onfreeze)
    inst:RemoveEventCallback("onhitother", berserkattack)
    inst:RemoveEventCallback("onhitother", OnHitfreeze)
	local dark2 = SpawnPrefab("statue_transition_2")
	local pos = Vector3(inst.Transform:GetWorldPosition())
	dark2.Transform:SetPosition(pos:Get())
inst.components.health.fire_damage_scale = 1
--inst.components.temperature.hurtrate = 1
	
		inst.components.talker:Say("... I can not remember what I ate?")
		if not inst.visual_hold then
			inst.AnimState:SetBuild("musha_normal")
			end
		end

	end
	end
	end
end
	
	applystats(inst)
end

local fn = function(inst)

	inst.soundsname = "willow"
    inst.entity:AddMiniMapEntity()
	inst.MiniMapEntity:SetIcon( "mushas.tex" )
	inst.level = 0
			inst.stamina = 100 
			inst.fatigue = 0
			inst.music = 0
	inst.components.eater:SetOnEatFn(expeat)
inst:ListenForEvent("levelup", levelexp)
	inst:ListenForEvent("sleep", stamina_sleep)
	inst:ListenForEvent("sleepy", fatigue_sleep)
	
	inst.strength = "normal"
	--inst.components.health:SetMaxHealth(50)
	inst.components.hunger:SetMax(200)
    	inst.components.sanity:SetMax(100)
 --inst.components.combat.damagemultiplier = TUNING.WENDY_DAMAGE_MULT
inst:AddTag("musha")
--inst:AddTag("yamcheb")
inst:AddTag("effectsheild2") 
inst:AddTag("level1") 
--inst:AddTag("shadowb") 
inst:AddTag("ghoundb") 

    inst:AddComponent("talker")
    --inst.components.talker.ontalk = ontalk
--inst:AddComponent("sleeper")
  --  inst.components.talker.fontsize = 30
   -- inst.components.talker.font = TALKINGFONT
    --inst.components.talker.colour = Vector3(1, 0.75, 1, 1)

--   inst:AddComponent("sanityaura")
	inst:AddComponent("colourtweener")
   inst:ListenForEvent("onhitother", sneakattack)
   inst:ListenForEvent("attacked", fsneakattack)

-----------light on
    inst.entity:AddLight()
	inst.Light:SetRadius(.6)
    inst.Light:SetFalloff(.8)
    inst.Light:SetIntensity(.5)
    inst.Light:SetColour(255/255,255/255,255/255)
	 if not inst.nsleep then inst.Light:Enable(false) end

        inst.procfn = function() tryproc(inst) end
        inst:ListenForEvent("attacked", inst.procfn)

        inst.shieldfn = function() shieldproc(inst) end
inst:ListenForEvent( "healthdelta", inst.shieldfn )
inst:ListenForEvent("hungerdelta", inst.shieldfn )

	inst:AddComponent("playerlightningtarget")
--------------------------------------------------------------
--test bird
--[[
    inst:AddComponent("childspawner")
    inst.components.childspawner.childname = "musha_tall2"
    inst.components.childspawner:StartSpawning()
    inst.components.childspawner.maxchildren = 1
]]--

    ----------------------------------------------------------
   -- inst.userfunctions =    {updatestats = updatestats}
	-- eater
    inst.components.eater:SetOmnivore()

	--inst.components.eater.strongstomach = true

inst:ListenForEvent( "attacked", fshieldupgrade)
inst:ListenForEvent("hungerdelta", removeskill)
--inst:ListenForEvent("healthdelta", removeskill)
inst:ListenForEvent("hungerdelta", shadows)
--inst:ListenForEvent("hungerdelta", gdogs)
inst:ListenForEvent("hungerdelta", berserkchanger)
--inst:ListenForEvent( "onhitother", powerattack)
inst:ListenForEvent( "hungerdelta", powerattack)
inst:ListenForEvent( "attacked", powerattack)
inst:ListenForEvent( "healthdelta", valkyriehp)
inst:ListenForEvent("hungerdelta", phasechange)
--inst.valkyriehp = inst:DoPeriodicTask(0, valkyriehp)
inst.sleep_test = inst:DoPeriodicTask(0, sleep_test)
inst.consume_sleep1 = inst:DoPeriodicTask(1, consume_stamina)
inst.sleepheal = inst:DoPeriodicTask(6,onsleepheal)
    inst:ListenForEvent("attacked", flower_shield)
 		inst:ListenForEvent( "dusktime", function() applystats(inst) end , GetWorld())
        inst:ListenForEvent( "daytime", function() applystats(inst) end , GetWorld())
        inst:ListenForEvent( "nighttime", function() applystats(inst) end , GetWorld())
         applystats(inst)
		 
 inst:ListenForEvent("nighttime", function(global, data)
	    if GetClock():GetMoonPhase() == "full" then
		fullmoon_buff(inst)
		if not GetWorld().prefab == "cave" then
		inst.fullmoon = true
		elseif GetWorld().prefab == "cave" then
		inst.fullmoon = false
		end
				end end, GetWorld())
inst:ListenForEvent("daytime", function() inst.fullmoon = false end, GetWorld())
inst:ListenForEvent("dusktime", function() inst.fullmoon = false end, GetWorld())
			
	inst:AddComponent("reader")
    inst.components.eater.stale_hunger = .5
--TUNING.WICKERBOTTOM_STALE_FOOD_HUNGER
    inst.components.eater.stale_health =  TUNING.WICKERBOTTOM_STALE_FOOD_HEALTH
    inst.components.eater.spoiled_hunger = TUNING.WICKERBOTTOM_SPOILED_FOOD_HUNGER
    inst.components.eater.spoiled_health = TUNING.WICKERBOTTOM_SPOILED_FOOD_HEALTH

	--inst.components.builder.science_bonus = 1
	local booktab = {str = STRINGS.TABS.BOOKS, sort=999, icon = "tab_book.tex"}
	inst.components.builder:AddRecipeTab(booktab)

	Recipe("book_birds", {Ingredient("papyrus", 2), Ingredient("bird_egg", 2)}, booktab, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0})
	Recipe("book_gardening", {Ingredient("papyrus", 2), Ingredient("seeds", 1), Ingredient("poop", 1)}, booktab, {SCIENCE = 1})
	Recipe("book_sleep", {Ingredient("papyrus", 2), Ingredient("nightmarefuel", 2)}, booktab, {MAGIC = 2})
	Recipe("book_brimstone", {Ingredient("papyrus", 2), Ingredient("redgem", 1)}, booktab, {MAGIC = 3})
	Recipe("book_tentacles", {Ingredient("papyrus", 2), Ingredient("tentaclespots", 1)}, booktab, {SCIENCE = 3})

	inst.OnSave = onsave
	inst.OnPreLoad = onpreload

    inst:ListenForEvent("entity_death", function(wrld, data) onkilll(inst, data) end, GetWorld())

		return inst

	end


--------------------------------------------------------------

STRINGS.CHARACTER_TITLES.musha = "Puppy Princess Musha"
STRINGS.CHARACTER_NAMES.musha = "musha"
STRINGS.CHARACTER_DESCRIPTIONS.musha = "[Level up and unlock to Skills] Level(L) Skill(K)\n[Companion Yamche] Battle(Z)\nShield(C)Valkyrie(V)Lightning(R)Dog(X)Shadow(G)Sleep(T)"
STRINGS.CHARACTER_QUOTES.musha = "\" I am True Princess ! \""
STRINGS.CHARACTERS.musha = {}
STRINGS.CHARACTERS.musha.DESCRIBE = {}


return MakePlayerCharacter("musha", prefabs, assets, fn) --start_inv)
