local STRINGS = GLOBAL.STRINGS
local require = GLOBAL.require
local Recipe = GLOBAL.Recipe
local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS
local STRINGS = GLOBAL.STRINGS
local TECH = GLOBAL.TECH
local State = GLOBAL.State
local TimeEvent = GLOBAL.TimeEvent
local EventHandler = GLOBAL.EventHandler
local FRAMES = GLOBAL.FRAMES
local Action = GLOBAL.Action
local ActionHandler = GLOBAL.ActionHandler
ACTIONS = GLOBAL.ACTIONS
GetPlayer = GLOBAL.GetPlayer
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
modimport("scripts/cookpotfix.lua")
modimport("scripts/play_wharang.lua")
modimport("scripts/strings_wharang.lua")
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
local Collect_SoulHeart = GetModConfigData("soulheart")
local BurnPartyTime = GetModConfigData("partytime")
local CALLPET = GetModConfigData("callpet")
--[[
function playerpostinit(inst)
    if GLOBAL.GetPlayer().prefab == "wharang" then
        inst.costumeSetting = GetModConfigData("costume")
    end
end
AddSimPostInit(playerpostinit)
]]
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GLOBAL.STRINGS.CHARACTER_TITLES.wharang = "The Millennium Fox"
GLOBAL.STRINGS.CHARACTER_NAMES.wharang = "WhaRang"
GLOBAL.STRINGS.CHARACTER_DESCRIPTIONS.wharang = "*Pet fox Miho follow you.\n*Upgrade to eat meat, Get to the  Soul Heart!\n*Fox tail and full moon gives you the power."
GLOBAL.STRINGS.CHARACTER_QUOTES.wharang = "\"Will you play with me?\""
GLOBAL.STRINGS.CHARACTERS.WHARANG = {}
GLOBAL.STRINGS.CHARACTERS.WHARANG.DESCRIBE = {}
GLOBAL.STRINGS.NAMES.WHARANG = "WhaRang"
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PrefabFiles = {
	"wharang",
	--??
	"foxtail1",
	"foxtail3",
	"foxtail6",
	--??
	"handfan",
	"gumifan",
	"foxbead_red",
	"flute_flame",
	"flute_frost",
	"flute_healing",
	--??
	"sakurahat",
	"foxmask",
	--??
	"campfire_ghost",
	"campfire_chill",
	"firepit_ghost",
	"firepit_chill",
	"gumipot",
	"wall_asia",
	"asiahouse",
	"asiahouse2",
	--??
	"moondumplings",
	"songpyeon",
	"driedcroaker",
	--???
	"mihobell",
	"peppertreeroot",
	"turf_asia",
	"turf_orient",
	"turf_flamerose",
	--?
	"hound_shadow",
	"miho",
	"reddrake",
	"foxfire",
	"shadowbeak",
	"miregg",
	"mir",
	--FX
	"foxlight_red",
	"wharang_fx",
	"campfire_ghost_fire",
	"campfire_chill_fire",
	"firepit_ghost_fire",
	"firepit_chill_fire",
	-------------
	"grainflour",
	"halfmooncake",
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Assets = {
    Asset( "IMAGE", "images/saveslot_portraits/wharang.tex" ),
    Asset( "ATLAS", "images/saveslot_portraits/wharang.xml" ),
    Asset( "IMAGE", "images/selectscreen_portraits/wharang.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wharang.xml" ),
    Asset( "IMAGE", "images/selectscreen_portraits/wharang_silho.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wharang_silho.xml" ),
    Asset( "IMAGE", "bigportraits/wharang.tex" ),
    Asset( "ATLAS", "bigportraits/wharang.xml" ),
	Asset( "IMAGE", "images/minimapicons/wharang.tex" ),
	Asset( "ATLAS", "images/minimapicons/wharang.xml" ),
	Asset( "IMAGE", "images/minimapicons/wharang_gumi.tex" ),
	Asset( "ATLAS", "images/minimapicons/wharang_gumi.xml" ),
	Asset( "IMAGE", "images/minimapicons/wharang_evil.tex" ),
	Asset( "ATLAS", "images/minimapicons/wharang_evil.xml" ),
--
    Asset( "IMAGE", "images/tabs/yinyangtab.tex"),
	Asset( "ATLAS", "images/tabs/yinyangtab.xml"),
--
	Asset( "ANIM", "anim/wharang_spirit_fx.zip" ),
	Asset( "ANIM", "anim/wharang_spirit_evil_fx.zip" ),
	Asset( "ANIM", "anim/wharang_fire_fx.zip" ),
	Asset( "ANIM", "anim/wharang_ground_fire_fx.zip" ),
	Asset( "ANIM", "anim/wharang_ring_fx.zip" ),
--
	Asset( "ANIM", "anim/miregg.zip" ),
	Asset( "IMAGE", "images/minimapicons/miregg.tex" ),
	Asset( "ATLAS", "images/minimapicons/miregg.xml" ),
--
	Asset( "ANIM", "anim/mir.zip" ),
	Asset( "IMAGE", "images/minimapicons/mir.tex" ),
	Asset( "ATLAS", "images/minimapicons/mir.xml" ),
--
	Asset( "ANIM", "anim/miho.zip" ),
	Asset( "IMAGE", "images/minimapicons/miho.tex" ),
	Asset( "ATLAS", "images/minimapicons/miho.xml" ),
--
	Asset( "ANIM", "anim/mihobell.zip" ),
	Asset( "IMAGE", "images/inventoryimages/mihobell.tex" ),
	Asset( "ATLAS", "images/inventoryimages/mihobell.xml" ),
	Asset( "IMAGE", "images/minimapicons/mihobell.tex" ),
	Asset( "ATLAS", "images/minimapicons/mihobell.xml" ),
--
	Asset( "ANIM",  "anim/foxtail1.zip" ),
	Asset( "ANIM",  "anim/swap_foxtail1.zip" ),
	Asset( "IMAGE", "images/inventoryimages/foxtail1.tex" ),
	Asset( "ATLAS", "images/inventoryimages/foxtail1.xml" ),
	Asset( "IMAGE", "images/minimapicons/foxtail1.tex" ),
	Asset( "ATLAS", "images/minimapicons/foxtail1.xml" ),
--
	Asset( "ANIM",  "anim/foxtail3.zip" ),
	Asset( "ANIM",  "anim/swap_foxtail3.zip" ),
	Asset( "IMAGE", "images/inventoryimages/foxtail3.tex" ),
	Asset( "ATLAS", "images/inventoryimages/foxtail3.xml" ),
	Asset( "IMAGE", "images/minimapicons/foxtail3.tex" ),
	Asset( "ATLAS", "images/minimapicons/foxtail3.xml" ),
--
	Asset( "ANIM",  "anim/foxtail6.zip" ),
	Asset( "ANIM",  "anim/swap_foxtail6.zip" ),
	Asset( "IMAGE", "images/inventoryimages/foxtail6.tex" ),
	Asset( "ATLAS", "images/inventoryimages/foxtail6.xml" ),
	Asset( "IMAGE", "images/minimapicons/foxtail6.tex" ),
	Asset( "ATLAS", "images/minimapicons/foxtail6.xml" ),
--
	Asset( "ANIM", "anim/handfan.zip" ),
	Asset( "ANIM", "anim/swap_handfan.zip" ),
	Asset( "IMAGE", "images/inventoryimages/handfan.tex" ),
	Asset( "ATLAS", "images/inventoryimages/handfan.xml" ),
	Asset( "IMAGE", "images/minimapicons/handfan.tex" ),
	Asset( "ATLAS", "images/minimapicons/handfan.xml" ),
--
	Asset( "ANIM", "anim/gumifan.zip" ),
	Asset( "ANIM", "anim/swap_gumifan.zip" ),
	Asset( "IMAGE", "images/inventoryimages/gumifan.tex" ),
	Asset( "ATLAS", "images/inventoryimages/gumifan.xml" ),
	Asset( "IMAGE", "images/minimapicons/gumifan.tex" ),
	Asset( "ATLAS", "images/minimapicons/gumifan.xml" ),
--
	Asset( "ANIM", "anim/gumipot.zip" ),
	Asset( "IMAGE", "images/inventoryimages/gumipot.tex" ),
	Asset( "ATLAS", "images/inventoryimages/gumipot.xml" ),
	Asset( "IMAGE", "images/minimapicons/gumipot.tex" ),
	Asset( "ATLAS", "images/minimapicons/gumipot.xml" ),
--
	Asset( "ANIM", "anim/sakurahat.zip" ),
	Asset( "ANIM", "anim/swap_sakurahat.zip" ),
	Asset( "IMAGE", "images/inventoryimages/sakurahat.tex" ),
	Asset( "ATLAS", "images/inventoryimages/sakurahat.xml" ),
	
    Asset("ANIM", "anim/foxmask.zip"),
	Asset("ANIM", "anim/swap_foxmask.zip"),
	Asset("IMAGE", "images/inventoryimages/foxmask.tex" ),
	Asset("ATLAS", "images/inventoryimages/foxmask.xml"),
	
	Asset("ANIM", "anim/campfire_ghost.zip"),
	Asset("IMAGE", "images/inventoryimages/campfire_ghost.tex" ),
	Asset("ATLAS", "images/inventoryimages/campfire_ghost.xml"),
	Asset("ANIM", "anim/firepit_ghost.zip"),
	Asset("IMAGE", "images/inventoryimages/firepit_ghost.tex" ),
	Asset("ATLAS", "images/inventoryimages/firepit_ghost.xml"),
	
	Asset("ANIM", "anim/campfire_chill.zip"),
	Asset("IMAGE", "images/inventoryimages/campfire_chill.tex" ),
	Asset("ATLAS", "images/inventoryimages/campfire_chill.xml"),
	Asset("ANIM", "anim/firepit_chill.zip"),
	Asset("IMAGE", "images/inventoryimages/firepit_chill.tex" ),
	Asset("ATLAS", "images/inventoryimages/firepit_chill.xml"),
	
	Asset("ANIM", "anim/moondumplings.zip"),
	Asset("IMAGE", "images/inventoryimages/moondumplings.tex" ),
	Asset("ATLAS", "images/inventoryimages/moondumplings.xml"),
	Asset("IMAGE", "images/inventoryimages/moondumplings_evil.tex" ),
	Asset("ATLAS", "images/inventoryimages/moondumplings_evil.xml"),
	
	Asset("ANIM", "anim/driedcroaker.zip"),
	Asset("IMAGE", "images/inventoryimages/driedcroaker.tex" ),
    Asset("ATLAS", "images/inventoryimages/driedcroaker.xml"),
	Asset("ANIM", "anim/songpyeon.zip"),
	Asset("IMAGE", "images/inventoryimages/songpyeon.tex" ),
    Asset("ATLAS", "images/inventoryimages/songpyeon.xml"),
	
	Asset("ANIM", "anim/flute_flame.zip"),
	Asset("IMAGE", "images/inventoryimages/flute_flame.tex" ),
	Asset("ATLAS", "images/inventoryimages/flute_flame.xml"),
	Asset("ANIM", "anim/flute_frost.zip"),
	Asset("IMAGE", "images/inventoryimages/flute_frost.tex" ),
	Asset("ATLAS", "images/inventoryimages/flute_frost.xml"),
	Asset("ANIM", "anim/flute_healing.zip"),
	Asset("IMAGE", "images/inventoryimages/flute_healing.tex" ),
	Asset("ATLAS", "images/inventoryimages/flute_healing.xml"),
	
	Asset("ANIM", "anim/peppertreeroot.zip"),
	Asset("IMAGE", "images/inventoryimages/peppertreeroot.tex" ),
	Asset("ATLAS", "images/inventoryimages/peppertreeroot.xml"),
	
	Asset("ANIM", "anim/wall.zip"),
	Asset("ANIM", "anim/wall_asia.zip"),
	Asset("IMAGE", "images/inventoryimages/wall_asia_item.tex" ),
	Asset("ATLAS", "images/inventoryimages/wall_asia_item.xml"),
--
	Asset( "ANIM", "anim/asiahouse.zip" ),
	Asset( "IMAGE", "images/inventoryimages/asiahouse.tex" ),
	Asset( "ATLAS", "images/inventoryimages/asiahouse.xml" ),
	Asset( "IMAGE", "images/minimapicons/asiahouse.tex" ),
	Asset( "ATLAS", "images/minimapicons/asiahouse.xml" ),
	Asset( "ANIM", "anim/asiahouse2.zip" ),
	Asset( "IMAGE", "images/inventoryimages/asiahouse2.tex" ),
	Asset( "ATLAS", "images/inventoryimages/asiahouse2.xml" ),
	Asset( "IMAGE", "images/minimapicons/asiahouse2.tex" ),
	Asset( "ATLAS", "images/minimapicons/asiahouse2.xml" ),
--
	Asset( "ANIM", "anim/wharang_turf.zip" ),
	Asset( "ATLAS", "images/inventoryimages/turf_asia.xml" ),
	Asset( "ATLAS", "images/inventoryimages/turf_orient.xml" ),
	Asset( "ATLAS", "images/inventoryimages/turf_flamerose.xml" ),
--
	Asset( "SOUND" , "sound/mir.fsb" ),
	Asset( "SOUND" , "sound/miho.fsb" ),
	Asset( "SOUND" , "sound/foxpointup.fsb" ),
	Asset( "SOUND" , "sound/decidous.fsb" ),
	Asset( "SOUND" , "sound/wharang_evilwhite.fsb" ),
	Asset( "SOUND" , "sound/wharangfan.fsb" ),
	
	Asset( "SOUNDPACKAGE" , "sound/mir.fev" ),
	Asset( "SOUNDPACKAGE" , "sound/miho.fev" ),
	Asset( "SOUNDPACKAGE" , "sound/foxpointup.fev" ),
	Asset( "SOUNDPACKAGE" , "sound/dontstarve_DLC001.fev" ),
	Asset( "SOUNDPACKAGE" , "sound/wharang_evilwhite.fev" ),
	Asset( "SOUNDPACKAGE" , "sound/wharangfan.fev" ),
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
RemapSoundEvent( "dontstarve/characters/wharang_evilwhite/death_voice", "wharang_evilwhite/characters/wharang_evilwhite/death_voice" )
RemapSoundEvent( "dontstarve/characters/wharang_evilwhite/hurt", "wharang_evilwhite/characters/wharang_evilwhite/hurt" )
RemapSoundEvent( "dontstarve/characters/wharang_evilwhite/talk_LP", "wharang_evilwhite/characters/wharang_evilwhite/talk_LP" )
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
AddMinimapAtlas("images/minimapicons/wharang.xml")
AddMinimapAtlas("images/minimapicons/wharang_gumi.xml")
AddMinimapAtlas("images/minimapicons/wharang_evil.xml")
AddMinimapAtlas("images/minimapicons/mihobell.xml")
AddMinimapAtlas("images/minimapicons/miho.xml")
AddMinimapAtlas("images/minimapicons/foxtail1.xml")
AddMinimapAtlas("images/minimapicons/foxtail3.xml")
AddMinimapAtlas("images/minimapicons/foxtail6.xml")
AddMinimapAtlas("images/minimapicons/handfan.xml")
AddMinimapAtlas("images/minimapicons/gumifan.xml")
AddMinimapAtlas("images/minimapicons/gumipot.xml")
AddMinimapAtlas("images/minimapicons/asiahouse.xml")
AddMinimapAtlas("images/minimapicons/asiahouse2.xml")
AddMinimapAtlas("images/minimapicons/miregg.xml")
AddMinimapAtlas("images/minimapicons/mir.xml")
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
AddClassPostConstruct("widgets/crafttabs", function(inst)
    if inst.prefab == "wharang" then
    STRINGS.TABS.YINYANG = "YinYang"
    GLOBAL.RECIPETABS['YINYANG'] = {str = "YINYANG", sort= 99998123, icon = "yinyangtab.tex", icon_atlas = "images/tabs/yinyangtab.xml"}
	table.insert(tabnames, GLOBAL.RECIPETABS['YINYANG'])
    end
end)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
local function ingredientatlas(ingred,count,atlas)
	local frecipe = Ingredient(ingred,count)
	frecipe.atlas = atlas
	return frecipe
end
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function GumihoPostInit(wharang)
------[Food]
		local MoonDumplings = GLOBAL.Recipe( "moondumplings", { Ingredient("berries", 4), Ingredient("seeds_cooked", 3) }, RECIPETABS.YINYANG, {SCIENCE = 0} )
        MoonDumplings.atlas = "images/inventoryimages/moondumplings.xml"
------[Light]
		local Campfire_Ghost = GLOBAL.Recipe( "campfire_ghost", { Ingredient("goldnugget", 3), Ingredient("cutgrass", 2) }, RECIPETABS.YINYANG, {SCIENCE = 0}, "campfire_ghost_placer" )
        Campfire_Ghost.atlas = "images/inventoryimages/campfire_ghost.xml"
		local FirePit_Fhost = GLOBAL.Recipe( "firepit_ghost", { Ingredient("goldnugget", 15), Ingredient("cutstone", 6), Ingredient("nitre", 3) }, RECIPETABS.YINYANG, {SCIENCE = 0}, "firepit_ghost_placer", 3 )
        FirePit_Fhost.atlas = "images/inventoryimages/firepit_ghost.xml"

		if GLOBAL.IsDLCEnabled(GLOBAL.REIGN_OF_GIANTS) then
		local Campfire_Chill = GLOBAL.Recipe( "campfire_chill", { Ingredient("goldnugget", 4), Ingredient("cutgrass", 2) }, RECIPETABS.YINYANG, {SCIENCE = 0}, "campfire_chill_placer" )
        Campfire_Chill.atlas = "images/inventoryimages/campfire_chill.xml"
		local FirePit_Chill = GLOBAL.Recipe( "firepit_chill", { Ingredient("goldnugget", 15), Ingredient("cutstone", 6), Ingredient("nitre", 4) }, RECIPETABS.YINYANG, {SCIENCE = 0}, "firepit_chill_placer", 3 )
        FirePit_Chill.atlas = "images/inventoryimages/firepit_chill.xml"
		elseif not GLOBAL.IsDLCEnabled(GLOBAL.REIGN_OF_GIANTS) then
		end
		
------[Weapon]
		local GumiFan = GLOBAL.Recipe( "gumifan", { Ingredient("handfan", 1,"images/inventoryimages/handfan.xml"), Ingredient("rope", 2), Ingredient("goldnugget", 2) }, RECIPETABS.YINYANG, {SCIENCE = 0} )
        GumiFan.atlas = "images/inventoryimages/gumifan.xml"
------[Hat]
		local SakuraHat = GLOBAL.Recipe( "sakurahat", { Ingredient("petals", 10), Ingredient("cutgrass", 3) }, RECIPETABS.YINYANG, {SCIENCE = 0} )
        SakuraHat.atlas = "images/inventoryimages/sakurahat.xml"
		local FoxMask = GLOBAL.Recipe( "foxmask", { Ingredient("goldnugget", 1), Ingredient("manrabbit_tail", 4), Ingredient("nightmarefuel", 2) }, RECIPETABS.YINYANG, {SCIENCE = 0} )
        FoxMask.atlas = "images/inventoryimages/foxmask.xml"
------[Instrument]
		local Flute_Flame = GLOBAL.Recipe( "flute_flame", { Ingredient("cutreeds",5), Ingredient("feather_robin", 10), Ingredient("goldnugget", 4) }, RECIPETABS.YINYANG, TECH.SCIENCE_ONE )
        Flute_Flame.atlas = "images/inventoryimages/flute_flame.xml"
		local Flute_Frost = GLOBAL.Recipe( "flute_frost", { Ingredient("cutreeds",5), Ingredient("feather_robin_winter", 10), Ingredient("goldnugget", 4) }, RECIPETABS.YINYANG, TECH.SCIENCE_ONE )
        Flute_Frost.atlas = "images/inventoryimages/flute_frost.xml"
		local Flute_Healing = GLOBAL.Recipe( "flute_healing", { Ingredient("cutreeds",5), Ingredient("feather_crow", 10), Ingredient("goldnugget", 4) }, RECIPETABS.YINYANG, TECH.SCIENCE_ONE )
        Flute_Healing.atlas = "images/inventoryimages/flute_healing.xml"
------[Structure]
		local OngGi = GLOBAL.Recipe( "gumipot", { Ingredient("boards", 8), Ingredient("cutstone", 12) }, RECIPETABS.YINYANG, {SCIENCE = 0}, "gumipot_placer", .9 )
        OngGi.atlas = "images/inventoryimages/gumipot.xml"
		local AsiaWall = GLOBAL.Recipe( "wall_asia_item", { Ingredient("log", 6), Ingredient("cutstone", 2) }, RECIPETABS.YINYANG, {SCIENCE = 0}, nil, nil, nil, 4 )
        AsiaWall.atlas = "images/inventoryimages/wall_asia_item.xml"
		local AsiaHouse = GLOBAL.Recipe( "asiahouse", { Ingredient("boards", 10), Ingredient("wall_stone_item", 40), Ingredient("redgem", 2) }, RECIPETABS.YINYANG, TECH.ANCIENT_TWO, "asiahouse_placer", 4 )
        AsiaHouse.atlas = "images/inventoryimages/asiahouse.xml"
		local AsiaHouse2 = GLOBAL.Recipe( "asiahouse2", { Ingredient("goldnugget", 4), Ingredient("wall_wood_item", 40), Ingredient("bluegem", 2) }, RECIPETABS.YINYANG, TECH.ANCIENT_TWO, "asiahouse2_placer", 4 )
        AsiaHouse2.atlas = "images/inventoryimages/asiahouse2.xml"
------[Turf]
		local Turf_Asia = GLOBAL.Recipe( "turf_asia", { Ingredient("beefalowool", 2), Ingredient("silk", 1) }, RECIPETABS.YINYANG, {SCIENCE = 0} )
        Turf_Asia.atlas = "images/inventoryimages/turf_asia.xml"
		local Turf_Orient = GLOBAL.Recipe( "turf_orient", { Ingredient("beefalowool", 2), Ingredient("silk", 1) }, RECIPETABS.YINYANG, {SCIENCE = 0} )
        Turf_Orient.atlas = "images/inventoryimages/turf_orient.xml"
		local Turf_Flame_Rose = GLOBAL.Recipe( "turf_flamerose", { Ingredient("beefalowool", 1), Ingredient("petals", 3) }, RECIPETABS.YINYANG, {SCIENCE = 0} )
        Turf_Flame_Rose.atlas = "images/inventoryimages/turf_flamerose.xml"
------[Fox Tail]
		local FoxTail3 = GLOBAL.Recipe( "foxtail3", { ingredientatlas("foxtail1", 1,"images/inventoryimages/foxtail1.xml"), Ingredient("lightbulb", 2), Ingredient("manrabbit_tail", 3) }, RECIPETABS.YINYANG, {SCIENCE = 0} )
        FoxTail3.atlas = "images/inventoryimages/foxtail3.xml"
		
		if GLOBAL.IsDLCEnabled(GLOBAL.REIGN_OF_GIANTS) then
		local FoxTail6 = GLOBAL.Recipe( "foxtail6", { ingredientatlas("foxtail3", 1,"images/inventoryimages/foxtail3.xml"), Ingredient("purplegem", 9), Ingredient("goose_feather", 3) }, RECIPETABS.YINYANG, {SCIENCE = 0} )
        FoxTail6.atlas = "images/inventoryimages/foxtail6.xml"
		elseif not GLOBAL.IsDLCEnabled(GLOBAL.REIGN_OF_GIANTS) then
		local FoxTail6 = GLOBAL.Recipe( "foxtail6", { ingredientatlas("foxtail3", 1,"images/inventoryimages/foxtail3.xml"), Ingredient("purplegem", 9), Ingredient("wormlight", 3) }, RECIPETABS.YINYANG, {SCIENCE = 0} )
        FoxTail6.atlas = "images/inventoryimages/foxtail6.xml"
		end
end

AddGamePostInit(modGamePostInit)
AddSimPostInit(function(inst)
        if inst.prefab == "wharang" then
                GumihoPostInit(inst)
        end
end)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
local function WharangMaxwellIntro(inst)
    if GLOBAL.GetPlayer().prefab == "wharang" then
        inst.components.maxwelltalker.speeches.SANDBOX_1 =
        {
            appearsound = "dontstarve/maxwell/disappear",	
            voice = "dontstarve/maxwell/talk_LP_world3",
            appearanim = "appear3",
            idleanim = "idle3_loop",
            dialogpreanim = "dialog3_pre",
            dialoganim ="dialog3_loop",
            dialogpostanim = "dialog3_pst",
            disappearanim = "disappear3",
            disableplayer = true,
            skippable = true,
            {
                string = "噢, 怎么又是你?!",
                wait = 2.5,
                anim = nil,
                sound = nil,
            },
            {
                string = "这有什么好笑的? 别对我玩恶作剧!",
                wait = 4,
                anim = nil,
                sound = nil,
            },
            {
                string = "你会后悔的, 小狐狸!",
                wait = 3.5,
                anim = nil,
                sound = nil,
            },
        }
    end
end
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

local function WhaRang_Bat(inst)
local function Retarget(inst)
    local ta = inst.components.teamattacker
    local newtarget = GLOBAL.FindEntity(inst, TUNING.BISHOP_TARGET_DIST, function(guy)
            return (guy:HasTag("character") or guy:HasTag("monster") )
                   and not guy:HasTag("bat")
				   and not (inst.prefab ~= "wharang")
                   and inst.components.combat:CanTarget(guy)
    end)
    if newtarget and not ta.inteam and not ta:SearchForTeam() then
        MakeTeam(inst, newtarget)
    end
    if ta.inteam and not ta.teamleader:CanAttack() then
        return newtarget
    end
end
inst:AddComponent("combat")
inst.components.combat:SetRetargetFunction(3, Retarget)
end
AddPrefabPostInit("bat", WhaRang_Bat)

local function WhaRang_PepperTreeLiving(inst)
if GLOBAL.GetPlayer().prefab == "wharang" then
inst:AddComponent("lootdropper")
inst.components.lootdropper:SetLoot({"livinglog", "livinglog", "peppertreeroot"})
end end
AddPrefabPostInit("livingtree", WhaRang_PepperTreeLiving)

local function WhaRang_PepperTreeGuard(inst)
if GLOBAL.GetPlayer().prefab == "wharang" then
inst:AddComponent("lootdropper")
inst.components.lootdropper:SetLoot({"livinglog", "livinglog", "livinglog", "livinglog", "livinglog", "livinglog", "monstermeat", "peppertreeroot"})
end end
AddPrefabPostInit("leif", WhaRang_PepperTreeGuard)
AddPrefabPostInit("leif_sparse", WhaRang_PepperTreeGuard)

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
table.insert(Assets, Asset("ANIM", "anim/foxpower.zip"))
local function FoxPowerBadge(class)
	if GLOBAL.GetPlayer().prefab == "wharang" then
	class.brain.anim:GetAnimState():SetBuild("foxpower")
	class.brain.anim:GetAnimState():SetBank("foxpower")
	end
end
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GLOBAL.STRINGS.REDDRAKE_TALK_FIGHT = { "Kill!", "Wah-wah!", "Kyu Wa!", "Yum-yum!", "Gooooo!", "Wah!", "Yo-Ho!", "Fight!", "Die!" }
GLOBAL.STRINGS.REDDRAKE_TALK_PANICFIRE = { "Noooo!", "Aaaahh!", "Waaak!", "Wah?", "Hing!", "No!", "What?", "Stop!" }
GLOBAL.STRINGS.MIR_TALK_FIGHT = { "kyuuu!", "kyaaa!", "KILL!", "Fight!" }
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
AddPrefabPostInit("maxwellintro", WharangMaxwellIntro)
table.insert(GLOBAL.CHARACTER_GENDERS.FEMALE, "wharang")
AddModCharacter("wharang")
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
AddIngredientValues({"petals", "petals_evil"}, {flower=1})
AddIngredientValues({"moondumplings"}, {moondumplings=1})
AddIngredientValues({"rope"}, {rope=1})
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--Cook Recipe
local SongPyeon = {
	name = "songpyeon",
	test = function(cooker, names, tags) return names.moondumplings and names.berries and names.berries >= 2 end,
	priority = 1,
	weight = 1,
	foodtype="VEGGIE",
	health = 20,
	hunger = 75,
	sanity = 25,
	perishtime = TUNING.PERISH_SUPERSLOW,
	cooktime = 2,
}
local DriedCroaker = {
	name = "driedcroaker",
	test = function(cooker, names, tags) return names.rope and names.rope >= 1 and tags.fish and tags.fish >= 2 end,
	priority = 10,
	weight = 1,
	foodtype="MEAT",
	health = 40,
	hunger = 80,
	sanity = 5,
	perishtime = TUNING.PERISH_MED,
	cooktime = .2,
}
AddCookerRecipe("cookpot", SongPyeon)
AddCookerRecipe("cookpot", DriedCroaker)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
local function IsModEnabled(name)
for _, moddir in ipairs(GLOBAL.KnownModIndex:GetModsToLoad()) do
if GLOBAL.KnownModIndex:GetModInfo(moddir).name == "RPG HUD"  then
return true
end
end
return false
end

if IsModEnabled( "RPG HUD" ) then
else
AddClassPostConstruct("widgets/statusdisplays", FoxPowerBadge)
end
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--[[
AddPrefabPostInit("forest", function(inst)
    inst:AddComponent("mireggspawner")
    end)]]
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- [[ SITFOLLOWERCOMMAND BEGIN ]] -- 

STRINGS.ACTIONS.PETSTAY = "呆着"
STRINGS.ACTIONS.PETSTAY_CANCEL = "跟随"
STRINGS.CHARACTERS.GENERIC.ANNOUNCE_PETSTAY = "请不要走动!"
STRINGS.CHARACTERS.GENERIC.ANNOUNCE_PETSTAY_CANCEL = "跟我来吧!"
STRINGS.CHARACTERS.WX78.ANNOUNCE_PETSTAY = "呆着"
STRINGS.CHARACTERS.WX78.ANNOUNCE_PETSTAY_CANCEL = "跟随"

ACTIONS.PETSTAY = GLOBAL.Action(2, true, true)
ACTIONS.PETSTAY.fn = function(act)
local targ = act.target
	if targ and targ.components.petstay then
		--act.doer.components.locomotor:Stop()
		act.doer.components.talker:Say(GLOBAL.GetString(act.doer.prefab, "ANNOUNCE_PETSTAY"))
		targ.components.combat:GiveUp()
		targ.components.petstay:SetStaying(true)
		targ.components.petstay:RememberStayPos("stayspos", GLOBAL.Point(targ.Transform:GetWorldPosition())) 
	return true
	end
end
ACTIONS.PETSTAY.str = STRINGS.ACTIONS.PETSTAY
ACTIONS.PETSTAY.id = "PETSTAY"
ACTIONS.PETSTAY_CANCEL = GLOBAL.Action(2, true, true)
ACTIONS.PETSTAY_CANCEL.fn = function(act)
	local targ = act.target
	if targ and targ.components.petstay then
	--act.doer.components.locomotor:Stop()
		act.doer.components.talker:Say(GLOBAL.GetString(act.doer.prefab, "ANNOUNCE_PETSTAY_CANCEL"))
		targ.components.petstay:SetStaying(false)

		return true
	end
end
ACTIONS.PETSTAY_CANCEL.str = STRINGS.ACTIONS.PETSTAY_CANCEL
ACTIONS.PETSTAY_CANCEL.id = "PETSTAY_CANCEL"

STRINGS.ACTIONS.OPENWALL = "Return Wall"
STRINGS.ACTIONS.CLOSEWALL = "Activate Door"

local OPENWALL = Action(3)
OPENWALL.str = STRINGS.ACTIONS.OPENWALL
OPENWALL.id = "OPENWALL"
OPENWALL.fn = function(act)
	local tar = act.target
    if tar and tar.components.walldoors and not tar.components.walldoors:IsOpen() then
		tar.components.walldoors:OpenWall(tar)
		return true
    end
end
AddAction(OPENWALL)
AddStategraphActionHandler("wilson", ActionHandler(OPENWALL, "give"))

local CLOSEWALL = Action(3)
CLOSEWALL.str = STRINGS.ACTIONS.CLOSEWALL
CLOSEWALL.id = "CLOSEWALL"
CLOSEWALL.fn = function(act)
	local tar = act.target
    if tar and tar.components.walldoors and tar.components.walldoors:IsOpen() then
        tar.components.walldoors:CloseWall(tar)
        return true
    end
end
AddAction(CLOSEWALL)
AddStategraphActionHandler("wilson", ActionHandler(CLOSEWALL, "give"))


----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pet_call = function() 
local player = GLOBAL.GetPlayer()
	if not player:HasTag("callpet") then
		player:AddTag("callpet")
		player.components.talker:Say("Pet's Priority - Follow Me!")
	elseif player:HasTag("callpet") then
		player:RemoveTag("callpet")
		player.components.talker:Say("Pet's Priority - Free Fight!")
	end
end

Start_BurnPartyTime = function() 
local player = GLOBAL.GetPlayer()
	if player.level > 249 then
		if player.components.sanity.current >= 50 then
				if not player:HasTag("PartyEnd") then
					if not player:HasTag("FireFoxAttack") then
						player:AddTag("FireFoxAttack")
						player.components.talker:Say("I'm ready to start the party!")
					elseif player:HasTag("FireFoxAttack") then
						player:RemoveTag("FireFoxAttack")
						player.components.talker:Say("WhaRang's party is canceled...")
					end
				elseif player:HasTag("PartyEnd") then
					player.components.talker:Say("Until the next party... "..(player.PartyTime).. " Second!")
				end
		elseif player.components.sanity.current < 50 then
		if player:HasTag("PartyEnd") then
			player.components.talker:Say("Until the next party... "..(player.PartyTime).. " Second!")
		elseif not player:HasTag("PartyEnd") then
			player.components.talker:Say("No, We need 50 Sanity...")
		end
		end
	elseif player.level < 250 then
		player.components.talker:Say("也许... 当我收集满250个魂心的时候,\n我就会开始 party!")
	end
end

Player_Collect_SoulHeart = function() 
local player = GLOBAL.GetPlayer()

if player.level < 500 then
player.components.talker:Say("收集魂心\n".. (player.level))
elseif player.level > 499 then
player.components.talker:Say("收集所有魂心")
end
end

if Collect_SoulHeart == "F11" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_F11, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Player_Collect_SoulHeart()
	end
	end
end)

elseif Collect_SoulHeart == "F10" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_F10, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Player_Collect_SoulHeart()
	end
	end
end)

elseif Collect_SoulHeart == "F9" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_F9, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Player_Collect_SoulHeart()
	end
	end
end)

elseif Collect_SoulHeart == "F8" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_F8, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Player_Collect_SoulHeart()
	end
	end
end)

elseif Collect_SoulHeart == "F7" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_F7, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Player_Collect_SoulHeart()
	end
	end
end)

elseif Collect_SoulHeart == "F6" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_F6, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Player_Collect_SoulHeart()
	end
	end
end)

elseif Collect_SoulHeart == "F5" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_F5, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Player_Collect_SoulHeart()
	end
	end
end)

elseif Collect_SoulHeart == "F4" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_F4, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Player_Collect_SoulHeart()
	end
	end
end)

elseif Collect_SoulHeart == "F3" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_F3, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Player_Collect_SoulHeart()
	end
	end
end)

elseif Collect_SoulHeart == "F2" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_F2, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Player_Collect_SoulHeart()
	end
	end
end)

elseif Collect_SoulHeart == "F1" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_F1, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Player_Collect_SoulHeart()
	end
	end
end)
end

if BurnPartyTime == "shiftJ" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_J, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Start_BurnPartyTime()
	end
	end
end)

elseif BurnPartyTime == "shiftK" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_K, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Start_BurnPartyTime()
	end
	end
end)

elseif BurnPartyTime == "shiftL" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_L, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Start_BurnPartyTime()
	end
	end
end)

elseif BurnPartyTime == "shiftB" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_B, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Start_BurnPartyTime()
	end
	end
end)

elseif BurnPartyTime == "shiftN" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_N, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Start_BurnPartyTime()
	end
	end
end)

elseif BurnPartyTime == "shiftM" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_M, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and not TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	Start_BurnPartyTime()
	end
	end
end)
end

if CALLPET == "ctrlG" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_G, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	pet_call()
	end
	end
end)

elseif CALLPET == "ctrlH" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_H, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	pet_call()
	end
	end
end)

elseif CALLPET == "ctrlT" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_T, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	pet_call()
	end
	end
end)

elseif CALLPET == "ctrlR" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_R, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	pet_call()
	end
	end
end)

elseif CALLPET == "ctrlY" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_Y, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	pet_call()
	end
	end
end)

elseif CALLPET == "ctrlC" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_C, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	pet_call()
	end
	end
end)

elseif CALLPET == "ctrlV" then
GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_V, function()
	local player = GLOBAL.GetPlayer()
	if player and player:HasTag("wharang") then
	local TheInput = GLOBAL.TheInput
	if not GLOBAL.IsPaused() and TheInput:IsKeyDown(GLOBAL.KEY_CTRL) and not TheInput:IsKeyDown(GLOBAL.KEY_SHIFT) then
	pet_call()
	end
	end
end)
end