local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS
GetPlayer = GLOBAL.GetPlayer
local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS
STRINGS = GLOBAL.STRINGS
RECIPETABS = GLOBAL.RECIPETABS
Recipe = GLOBAL.Recipe
Ingredient = GLOBAL.Ingredient


modimport("scripts/cookpotfix.lua")

PrefabFiles = {
	"wisp",
	"wei",
	"wynter",
	"catrope",
	"collarbell",
	"collarbug",
	"collarrhinestone",
	"collartricky",
	"collarwei",
	"fishyconcoction",
	"flan",
	"freshricotta",
	"hairball",
	"snootysnack",
	"poshsweatervest",
	"pailofmilk",
}


Assets = {

	-- wisp

    Asset( "IMAGE", "images/saveslot_portraits/wisp.tex" ),
    Asset( "ATLAS", "images/saveslot_portraits/wisp.xml" ),

    Asset( "IMAGE", "images/selectscreen_portraits/wisp.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wisp.xml" ),

    Asset( "IMAGE", "images/selectscreen_portraits/wisp_silho.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wisp_silho.xml" ),

    Asset( "IMAGE", "bigportraits/wisp.tex" ),
    Asset( "ATLAS", "bigportraits/wisp.xml" ),
	
	Asset("IMAGE", "minimap/wisp.tex"),
    Asset("ATLAS", "minimap/wisp.xml"),
	
	Asset("SOUNDPACKAGE", "sound/wisp.fev"),
    Asset("SOUND", "sound/wisp.fsb"),
	
	
	-- wei
	
	
	Asset( "IMAGE", "images/saveslot_portraits/wei.tex" ),
    Asset( "ATLAS", "images/saveslot_portraits/wei.xml" ),

    Asset( "IMAGE", "images/selectscreen_portraits/wei.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wei.xml" ),

    Asset( "IMAGE", "images/selectscreen_portraits/wei_silho.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wei_silho.xml" ),

    Asset( "IMAGE", "bigportraits/wei.tex" ),
    Asset( "ATLAS", "bigportraits/wei.xml" ),
	
	Asset("IMAGE", "minimap/wei.tex"),
    Asset("ATLAS", "minimap/wei.xml"),
	
    Asset("SOUND", "sound/wei.fsb"),
	
	
	
	-- wynter
	
	
	Asset( "IMAGE", "images/saveslot_portraits/wynter.tex" ),
    Asset( "ATLAS", "images/saveslot_portraits/wynter.xml" ),

    Asset( "IMAGE", "images/selectscreen_portraits/wynter.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wynter.xml" ),

    Asset( "IMAGE", "images/selectscreen_portraits/wynter_silho.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wynter_silho.xml" ),

    Asset( "IMAGE", "bigportraits/wynter.tex" ),
    Asset( "ATLAS", "bigportraits/wynter.xml" ),
	
	Asset("IMAGE", "minimap/wynter.tex"),
    Asset("ATLAS", "minimap/wynter.xml"),
	
    Asset("SOUND", "sound/winter.fsb"),
	
	

	-- Foods and stuff
	
		
	Asset( "IMAGE", "images/inventoryimages/fishyconcoction.tex" ),
	Asset( "ATLAS", "images/inventoryimages/fishyconcoction.xml" ),
	Asset( "IMAGE", "images/inventoryimages/flan.tex" ),
	Asset( "ATLAS", "images/inventoryimages/flan.xml" ),
	Asset( "IMAGE", "images/inventoryimages/freshricotta.tex" ),
	Asset( "ATLAS", "images/inventoryimages/freshricotta.xml" ),
	Asset( "IMAGE", "images/inventoryimages/snootysnack.tex" ),
	Asset( "ATLAS", "images/inventoryimages/snootysnack.xml" ),
	
	Asset( "IMAGE", "images/tab_cats.tex" ),
	Asset( "ATLAS", "images/tab_cats.xml" ),
	Asset( "IMAGE", "images/inventoryimages/catrope.tex" ),
	Asset( "ATLAS", "images/inventoryimages/catrope.xml" ),
	Asset( "IMAGE", "images/inventoryimages/collarbell.tex" ),
	Asset( "ATLAS", "images/inventoryimages/collarbell.xml" ),
	Asset( "IMAGE", "images/inventoryimages/collarbug.tex" ),
	Asset( "ATLAS", "images/inventoryimages/collarbug.xml" ),
	Asset( "IMAGE", "images/inventoryimages/collarrhinestone.tex" ),
	Asset( "ATLAS", "images/inventoryimages/collarrhinestone.xml" ),
	Asset( "IMAGE", "images/inventoryimages/collartricky.tex" ),
	Asset( "ATLAS", "images/inventoryimages/collartricky.xml" ),
	Asset( "IMAGE", "images/inventoryimages/collarwei.tex" ),
	Asset( "ATLAS", "images/inventoryimages/collarwei.xml" ),
	Asset( "IMAGE", "images/inventoryimages/hairball.tex" ),
	Asset( "ATLAS", "images/inventoryimages/hairball.xml" ),
	Asset( "IMAGE", "images/inventoryimages/poshsweatervest.tex" ),
	Asset( "ATLAS", "images/inventoryimages/poshsweatervest.xml" ),

	
	Asset("SOUNDPACKAGE", "sound/collarbell.fev"),
    Asset("SOUND", "sound/collarbell.fsb"),
	
}

RemapSoundEvent( "dontstarve/characters/wisp/death_voice", "wisp/wisp/death_voice" )
RemapSoundEvent( "dontstarve/characters/wisp/hurt", "wisp/wisp/hurt" )
RemapSoundEvent( "dontstarve/characters/wisp/talk_LP", "wisp/wisp/talk_LP" )

RemapSoundEvent( "dontstarve/characters/wei/death_voice", "wisp/wei/death_voice" )
RemapSoundEvent( "dontstarve/characters/wei/hurt", "wisp/wei/hurt" )
RemapSoundEvent( "dontstarve/characters/wei/talk_LP", "wisp/wei/talk_LP" )

RemapSoundEvent( "dontstarve/characters/winter/death_voice", "wisp/winter/death_voice" )
RemapSoundEvent( "dontstarve/characters/winter/hurt", "wisp/winter/hurt" )
RemapSoundEvent( "dontstarve/characters/winter/talk_LP", "wisp/winter/talk_LP" )

RemapSoundEvent( "dontstarve/collarbell/jinglejingle", "collarbell/collarbell/jinglejingle" )

AddMinimapAtlas("minimap/wisp.xml")
AddMinimapAtlas("minimap/wei.xml")
AddMinimapAtlas("minimap/wynter.xml")








------------------------------------------------
-- New Crafts!
------------------------------------------------

		STRINGS.TABS.CATSSTAB = "Cat Stuff"
			GLOBAL.RECIPETABS['CATSTAB'] = {str = "CATSTAB", sort=15, icon = "tab_cats.tex", icon_atlas = "images/tab_cats.xml"}
			
		local catrope = GLOBAL.Ingredient( "catrope", 1)
			catrope.atlas = "images/inventoryimages/catrope.xml"
			
		local catropetwo = GLOBAL.Ingredient( "catrope", 2)
			catropetwo.atlas = "images/inventoryimages/catrope.xml"
			
		local hairball = GLOBAL.Ingredient( "hairball", 1)
			hairball.atlas = "images/inventoryimages/hairball.xml"
			
		local hairballten = GLOBAL.Ingredient( "hairball", 10)
			hairballten.atlas = "images/inventoryimages/hairball.xml"
			
function CatCraftsPostInit(inst)
    if GLOBAL.GetPlayer().prefab == "wei" then

		local collarweicraft = GLOBAL.Recipe("collarwei", {Ingredient("cutgrass", 8), Ingredient("petals", 5)}, RECIPETABS.CATSTAB, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0})
			collarweicraft.atlas = "images/inventoryimages/collarwei.xml"
			GLOBAL.STRINGS.RECIPE_DESC.COLLARWEI = "Heartwarming; puts a spring in your step."

		local catropecraft = GLOBAL.Recipe("catrope", {hairballten, Ingredient("petals", 10)}, RECIPETABS.CATSTAB, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0})
			catropecraft.atlas = "images/inventoryimages/catrope.xml"	
			GLOBAL.STRINGS.RECIPE_DESC.CATROPE = "Warm and fuzzy festive yarn."
			
		local collarrhinestonecraft = GLOBAL.Recipe("collarrhinestone", {catrope, Ingredient("goldnugget", 1), Ingredient("rocks", 5)}, RECIPETABS.CATSTAB, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0})
			collarrhinestonecraft.atlas = "images/inventoryimages/collarrhinestone.xml"
			GLOBAL.STRINGS.RECIPE_DESC.COLLARRHINESTONE = "Shine almost like diamonds. Kinda."
			
		local poshsweatervestcraft = GLOBAL.Recipe("poshsweatervest", {catropetwo, Ingredient("rope", 2), Ingredient("feather_robin_winter", 1)}, RECIPETABS.CATSTAB, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0})
			poshsweatervestcraft.atlas = "images/inventoryimages/poshsweatervest.xml"
			GLOBAL.STRINGS.RECIPE_DESC.POSHSWEATERVEST = "Cozy, but definitely not your size."
			
		local collarbellcraft = GLOBAL.Recipe("collarbell", {catrope, Ingredient("goldnugget", 1)}, RECIPETABS.CATSTAB, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0})
			collarbellcraft.atlas = "images/inventoryimages/collarbell.xml"
			GLOBAL.STRINGS.RECIPE_DESC.COLLARBELL = "Keeps the ghosts at bay; also, adorable."
			
		local collarbugcraft = GLOBAL.Recipe("collarbug", {catrope, Ingredient("stinger", 1), Ingredient("cutgrass", 10)}, RECIPETABS.CATSTAB, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0})
			collarbugcraft.atlas = "images/inventoryimages/collarbug.xml"
			GLOBAL.STRINGS.RECIPE_DESC.COLLARBUG = "Bugs ain't nothin!."

		local collartrickycraft = GLOBAL.Recipe("collartricky", {catropetwo, Ingredient("purplegem", 1)}, RECIPETABS.CATSTAB, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0})
			collartrickycraft.atlas = "images/inventoryimages/collartricky.xml"
			GLOBAL.STRINGS.RECIPE_DESC.COLLARTRICKY = "Keeps enemies away...in a way."
	end
	
	if GLOBAL.GetPlayer().prefab == "wynter" then
	
		local catropecraft = GLOBAL.Recipe("catrope", {hairballten, Ingredient("petals", 10)}, RECIPETABS.CATSTAB, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0})
			catropecraft.atlas = "images/inventoryimages/catrope.xml"	
			GLOBAL.STRINGS.RECIPE_DESC.CATROPE = "Warm and fuzzy festive yarn."
			
		local poshsweatervestcraft = GLOBAL.Recipe("poshsweatervest", {catropetwo, Ingredient("rope", 2), Ingredient("feather_robin_winter", 1)}, RECIPETABS.CATSTAB, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0})
			poshsweatervestcraft.atlas = "images/inventoryimages/poshsweatervest.xml"
			GLOBAL.STRINGS.RECIPE_DESC.POSHSWEATERVEST = "Cozy, but definitely not your size."
			
		local collarbellcraft = GLOBAL.Recipe("collarbell", {catrope, Ingredient("goldnugget", 1)}, RECIPETABS.CATSTAB, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0})
			collarbellcraft.atlas = "images/inventoryimages/collarbell.xml"
			GLOBAL.STRINGS.RECIPE_DESC.COLLARBELL = "Keeps the ghosts at bay; also, adorable."
			
		local collarbugcraft = GLOBAL.Recipe("collarbug", {catrope, Ingredient("stinger", 1), Ingredient("cutgrass", 10)}, RECIPETABS.CATSTAB, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0})
			collarbugcraft.atlas = "images/inventoryimages/collarbug.xml"
			GLOBAL.STRINGS.RECIPE_DESC.COLLARBUG = "Bugs ain't nothin!."

		local collartrickycraft = GLOBAL.Recipe("collartricky", {catropetwo, Ingredient("purplegem", 1)}, RECIPETABS.CATSTAB, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0})
			collartrickycraft.atlas = "images/inventoryimages/collartricky.xml"
			GLOBAL.STRINGS.RECIPE_DESC.COLLARTRICKY = "Keeps enemies away...in a way."
	end
	
	if GLOBAL.GetPlayer().prefab == "wisp" then
	
		local catropecraft = GLOBAL.Recipe("catrope", {hairballten, Ingredient("petals", 10)}, RECIPETABS.CATSTAB, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0})
			catropecraft.atlas = "images/inventoryimages/catrope.xml"	
			GLOBAL.STRINGS.RECIPE_DESC.CATROPE = "Warm and fuzzy festive yarn."
		
		local poshsweatervestcraft = GLOBAL.Recipe("poshsweatervest", {catropetwo, Ingredient("rope", 2), Ingredient("feather_robin_winter", 1)}, RECIPETABS.CATSTAB, {SCIENCE = 0, MAGIC = 0, ANCIENT = 0})
			poshsweatervestcraft.atlas = "images/inventoryimages/poshsweatervest.xml"
			GLOBAL.STRINGS.RECIPE_DESC.POSHSWEATERVEST = "Cozy, but definitely not your size."
			
		
	end

end	
		
	
AddSimPostInit(function(inst)
    CatCraftsPostInit(inst)
end)


-- Makes petals eatable for Wisp
AddPrefabPostInit("petals", function(inst)	
	if GLOBAL.GetPlayer().prefab == "wisp" then
		inst.components.edible.foodtype = "MEAT" 
	end
end)

local function modsanityarmour(inst)
    if GLOBAL.GetPlayer().prefab == "wisp" then
		inst.components.equippable.walkspeedmult = 1.1
	end
end
local function modlightarmour(inst)
    if GLOBAL.GetPlayer().prefab == "wisp" then
		inst.components.equippable.walkspeedmult = 0.85
	end
end
local function modmediumarmour(inst)
    if GLOBAL.GetPlayer().prefab == "wisp" then
		inst.components.equippable.walkspeedmult = 0.7
	end
end
local function modheavyarmour(inst)
    if GLOBAL.GetPlayer().prefab == "wisp" then
		inst.components.equippable.walkspeedmult = 0.4
	end
end

-- Armours
AddPrefabPostInit('armorgrass', modlightarmour)  
AddPrefabPostInit('armorsnurtleshell', modlightarmour)
AddPrefabPostInit('armordragonfly', modlightarmour)	

AddPrefabPostInit('armorwood', modmediumarmour)

AddPrefabPostInit('armormarble', modheavyarmour)
AddPrefabPostInit('armorruins', modheavyarmour) 

AddPrefabPostInit('armor_sanity', modsanityarmour)			 	

-- Helmets
AddPrefabPostInit('footballhat', modlightarmour)
AddPrefabPostInit('ruinshat', modmediumarmour)
AddPrefabPostInit('slurtlehat', modmediumarmour)




local function ModMaxwellIntro(inst)
    if GLOBAL.GetPlayer().prefab == "wisp" or GLOBAL.GetPlayer().prefab == "wei" or GLOBAL.GetPlayer().prefab == "wynter" then
        inst.components.maxwelltalker.speeches.SANDBOX_1 =
        {
            appearsound = "dontstarve/maxwell/appear_adventure",
	    voice = "dontstarve/maxwell/talk_LP_world1",
		appearanim = "appear2",
		idleanim= "idle2_loop",
		dialogpreanim = "dialog2_pre",
		dialoganim="dialog2_loop",
		dialogpostanim = "dialog2_pst",
		disappearanim = "disappear2",
            disableplayer = true,
            skippable = false,
            {
                string = "Say, pal. You don't look s--",
                wait = 2,
                anim = nil,
                sound = nil,
            },
			{
                string = "Oh.",
                wait = 1,
                anim = nil,
                sound = nil,
            },
            {
                string = "I could have sworn Wilson came in here...",
                wait = 3,
                anim = dialog2_loop,
                sound = nil,
            },
	}
    end
	
	
end

AddPrefabPostInit("maxwellintro", ModMaxwellIntro)

-- You can also add any kind of custom dialogue that you would like. Don't forget to make
-- categores that don't exist yet using = {}
-- note: these are UPPER-CASE charcacter name

GLOBAL.STRINGS.CHARACTERS.wisp = {}
GLOBAL.STRINGS.CHARACTERS.wisp.DESCRIBE = {}

GLOBAL.STRINGS.NAMES.CATROPE = "Colorful Yarn"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.CATROPE = "Yarn. How nice."

GLOBAL.STRINGS.NAMES.COLLARBELL = "Bell Collar"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.COLLARBELL = "So soothing."

GLOBAL.STRINGS.NAMES.COLLARBUG = "Bug Collar"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.COLLARBUG = "It'll take care of all your bug problems!"

GLOBAL.STRINGS.NAMES.COLLARRHINESTONE = "Shiny Rhinestone Collar"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.COLLARRHINESTONE = "With a shine like that, no one will know it's not really diamonds."

GLOBAL.STRINGS.NAMES.COLLARTRICKY = "Scaredycat Collar"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.COLLARTRICKY = "Escape all your enemies in one way or another!"

GLOBAL.STRINGS.NAMES.COLLARWEI = "Wei's Bow"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.COLLARWEI = "An adorable blue ribbon."

GLOBAL.STRINGS.NAMES.FISHYCONCOCTION = "Fishy Concoction"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.FISHYCONCOCTION = "Just a bowl of fish parts."

GLOBAL.STRINGS.NAMES.FLAN = "Flan"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.FLAN = "Delicious caramel pudding!"

GLOBAL.STRINGS.NAMES.FRESHRICOTTA = "Fresh Ricotta"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.FRESHRICOTTA = "A jar of soft, creamy cheese."

GLOBAL.STRINGS.NAMES.HAIRBALL = "Hairball"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.HAIRBALL = "Ew, a hairball!"

GLOBAL.STRINGS.NAMES.SNOOTYSNACK = "Snooty Snack"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.SNOOTYSNACK = "It's still just cat food."

GLOBAL.STRINGS.NAMES.POSHSWEATERVEST = "Posh Sweatervest"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.POSHSWEATERVEST = "Stylish, if a little big."

GLOBAL.STRINGS.NAMES.PAILOFMILK = "Beefy Milk"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.PAILOFMILK = "An entire pail of milk."



-- Let the game know Wod is a male, for proper pronouns during the end-game sequence.
-- Possible genders here are MALE, FEMALE, or ROBOT
table.insert(GLOBAL.CHARACTER_GENDERS.FEMALE, "Wisp")
table.insert(GLOBAL.CHARACTER_GENDERS.MALE, "Wei")
table.insert(GLOBAL.CHARACTER_GENDERS.FEMALE, "Wynter")

AddModCharacter("wisp")
AddModCharacter("wei")
AddModCharacter("wynter")