local STRINGS = GLOBAL.STRINGS
local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS

PrefabFiles = {
	"kyle",
	"wormspider",
	"worm_spiderling",
	"worm_fighter",
	"worm_rocky",
	"worm_flying",
	"worm_warrior",
	"worm_assassin",
}

Assets = {
    Asset( "IMAGE", "images/saveslot_portraits/kyle.tex" ),
    Asset( "ATLAS", "images/saveslot_portraits/kyle.xml" ),

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

    Asset( "IMAGE", "bigportraits/kyle.tex" ),
    Asset( "ATLAS", "bigportraits/kyle.xml" ),
	
	Asset( "IMAGE", "images/map_icons/kyle.tex" ),
	Asset( "ATLAS", "images/map_icons/kyle.xml" ),
	
	Asset( "IMAGE", "images/inventoryimages/wormspider_recipe.tex" ),
	Asset( "ATLAS", "images/inventoryimages/wormspider_recipe.xml" ),

}

local require = GLOBAL.require

local function ModMaxwellIntro(inst)
    if GLOBAL.GetPlayer().prefab == "kyle" then
        inst.components.maxwelltalker.speeches.SANDBOX_1 =
	{
		appearsound = "dontstarve/maxwell/disappear",
	    voice = "dontstarve/maxwell/talk_LP",
		appearanim = "appear",
		idleanim= "idle",
		dialogpreanim = "dialog_pre",
		dialoganim="dial_loop",
		dialogpostanim = "dialog_pst",
		disappearanim = "disappear",
		disableplayer = true,
		skippable = true,
		{
			string = "啊啊啊.......噢噢噢...",
			wait = 3,
			anim = nil,
			sound = nil,
		},
		{
			string = "噢噢噢......啊啊啊...", 
			wait = 3, 
			anim = nil, 
			sound = nil,
		},
	}
	end
end
	
	AddPrefabPostInit("maxwellintro", ModMaxwellIntro)
	
-- The character select screen lines
GLOBAL.STRINGS.CHARACTER_TITLES.kyle = "共生体"
GLOBAL.STRINGS.CHARACTER_NAMES.kyle = "虫师凯尔"
GLOBAL.STRINGS.CHARACTER_DESCRIPTIONS.kyle = "*可怕的外貌.\n*可怕的战斗.\n*可以指挥昆虫部队."
GLOBAL.STRINGS.CHARACTER_QUOTES.kyle = "\"现在可以直接控制.\""

-- Custom speech strings
GLOBAL.STRINGS.CHARACTERS.KYLE = require "speech_x"

-- Let the game know character is male, female, or robot
table.insert(GLOBAL.CHARACTER_GENDERS.MALE, "kyle")

AddMinimapAtlas("images/map_icons/kyle.xml")
AddModCharacter("kyle")

---------------------------------------------------------------------------------------------------------------------------------
--- [Worm Spiders]
STRINGS.NAMES.WORMSPIDER = "蠕虫"
STRINGS.CHARACTERS.KYLE.DESCRIBE.WORMSPIDER = "一 个 老 朋 友"
GLOBAL.STRINGS.RECIPE_DESC.WORMSPIDER = "蠕 虫 在 你 身 边"

STRINGS.NAMES.WORM_SPIDERLING = "蠕虫幼虫"
STRINGS.CHARACTERS.KYLE.DESCRIBE.WORM_SPIDERLING = " 小 家 伙 "
GLOBAL.STRINGS.RECIPE_DESC.WORM_SPIDERLING = "小 战 士"

STRINGS.NAMES.WORM_FIGHTER = "蠕虫斗士"
STRINGS.CHARACTERS.KYLE.DESCRIBE.WORM_FIGHTER = "顽 强 斗 士"
GLOBAL.STRINGS.RECIPE_DESC.WORM_FIGHTER = "聪 明 的 斗 士"

STRINGS.NAMES.WORM_ROCKY = "石虫"
STRINGS.CHARACTERS.KYLE.DESCRIBE.WORM_ROCKY = "肉 盾 战 士"
GLOBAL.STRINGS.RECIPE_DESC.WORM_ROCKY = "真 正 的 石 墙"

STRINGS.NAMES.WORM_FLYING = "飞虫"
STRINGS.CHARACTERS.KYLE.DESCRIBE.WORM_FLYING = "可 惜 太 小 不 能 骑."
GLOBAL.STRINGS.RECIPE_DESC.WORM_FLYING = "空中战士."

STRINGS.NAMES.WORM_WARRIOR = "蠕虫战士"
STRINGS.CHARACTERS.KYLE.DESCRIBE.WORM_WARRIOR = "暴徒一样的生活"
GLOBAL.STRINGS.RECIPE_DESC.WORM_WARRIOR = "无与伦比."

STRINGS.NAMES.WORM_ASSASSIN = "蠕虫刺客"
STRINGS.CHARACTERS.KYLE.DESCRIBE.WORM_ASSASSIN = "无情的刺客."
GLOBAL.STRINGS.RECIPE_DESC.WORM_ASSASSIN = "玻璃炮."

------------------------------------------------------------------------------------------------------------------------------------
---[Worm Spider Names]

GLOBAL.STRINGS.WORMNAMES =
{

--Famous People
	"Annie",
	"Armstrong",
	"Arya",
	"Augustus",
	"Balboa",
	"Caesar",
	"Calhoun",
	"Carnegie",
	"Cecil",
	"Charlotte",
	"Chet Awesomelaser",
	"Clementine",
	"Clippy",
	"Cthulhu",
	"Dahmer",
	"DeGrasse Tyson",
	"Dr. McNinja",
	"Ellie",
	"Eve",
	"Faust",
	"Ford",
	"Gerald",
	"Gertrud",
	"Gretchen",
	"Ikari",
	"Issac Newton",
	"Hitchcock",
	"Homulilly",
	"Jackson",
	"Jack the Ripper",
	"Judas",
	"Jumbo",
	"Kennedy",
	"Kenny",
	"King Radical",
	"Koba",
	"Kriemhild",
	"Kyubey",
	"Lecter",
	"Lee",
	"Leonardo",
	"Lincoln",
	"Lovecraft",
	"Lyndon",
	"Magdalene",
	"Morgan",
	"Nietzsche",
	"Noah",
	"Notch",
	"Oktavia von Seckendorff",
	"Pandora",
	"Patriarachnid",
	"Pegg",
	"Polk",
	"Pollock",
	"Powers Booth",
	"Prometheus",
	"Reagan",
	"Robocop",
	"Rockefeller",
	"Roosevelt",
	"Samson",
	"Santa",
	"Scooby",
	"Seanbaby",
	"Sean Connery",
	"Seuss",
	"Shakespeare",
	"Shaun",
	"Staff Sgt. Max Fightmaster",
	"Steve?",
	"Swaim",
	"Tarantino",
	"Theodore",
	"Truman",
	"Tyrion",
	"Tywin",
	"Vladimir",
	"Washington",
	"Wong",
	"Wonka",
	"Xanatos",
	"Yahtzee",
	
--Misc Names
	"100101010010101011101101",
	"404 ERROR NAME NOT FOUND",
	"Abigail",
	"Alkaline",
	"Alone",
	"Anonymous",
	"Awesome McCoolname",
	"Bobba Feet",
	"Bolschit",
	"Bonesteel",
	"Caitlin",
	"Cassentra",
	"Chad",
	"Charlie",
	"Colonel Rad Pony",
	"Colorless",
	"David",
	"Daniel",
	"Darkness",
	"Deoxyribose",
	"Dianthiflora",
	"Doug",
	"Dr. Lucky",
	"Dr. Mr. Waffles",
	"Dr. Mr. Prof. Waffles",
	"Dr. Mr. Prof. Waffles MD",
	"Dr. Waffles",
	"East",
	"Emily",
	"Fail O'Suckyname",
	"Frontier",
	"Heather",
	"Illuminati",
	"Illuminaughty",
	"Insomniac",
	"Jaeger",
	"Jason",
	"Jim",
	"Joel",
	"John",
	"John J. C. Shephard-Christ",
	"Kit",
	"Kyle II",
	"Kyle MKII",
	"Kyle v2.0",
	"Laser Dolphin",
	"Luthor",
	"Maxwell",
	"McHatesdogs",
	"Michael",
	"Mr. President",
	"Neurax",
	"Ninja McDoctor",
	"North",
	"Ophelia",
	"Panzerfaust",
	"Portia",
	"Punchfacenstein",
	"Punchfist",
	"Punchlaser",
	"Randy",
	"[Redacted]",
	"Rick",
	"Ross",
	"Sean",
	"Shangrilas",
	"South",
	"Tank Fist",
	"Teaspoon",
	"Thelonius",
	"The Goddamn President",
	"The Puppetmaster",
	"The One Without A Name",
	"The One With A Name",
	"The Magnificent Bastard",
	"Tiergan",
	"Ubermensche",
	"[Undisclosed]",
	"Vicki",
	"Waffles",
	"Walter",
	"Webster",
	"Wendy",
	"Wes",
	"West",
	"William",
	"Willow",
	"Wilson",
	"Winnifrid",
	"Wolfgang",
	"Woodie",
	"Wormageddon",
	"Wormy",
	"Worm Spider",
	
}

function lootdropperpostinit(inst)

	inst.GenerateLoot = function(self)
    local loots = {}
    if self.numrandomloot and math.random() <= (self.chancerandomloot or 1) then
		for k = 1, self.numrandomloot do
		    local loot = self:PickRandomLoot()
		    if loot then
			    table.insert(loots, loot)
			end
		end
	end
    if self.chanceloot then
		for k,v in pairs(self.chanceloot) do
			if math.random() < v.chance then
				table.insert(loots, v.prefab)
				self.droppingchanceloot = true
			end
		end
	end
    if self.chanceloottable then
    	local loot_table = GLOBAL.LootTables[self.chanceloottable]
    	if loot_table then
    		for i, entry in ipairs(loot_table) do
    			local prefab = entry[1]
    			local chance = entry[2]    			
				if math.random() <= chance then
					table.insert(loots, prefab)
					self.droppingchanceloot = true
				end
			end
		end
	end
	if not self.droppingchanceloot and self.ifnotchanceloot then
		self.inst:PushEvent("ifnotchanceloot")
		for k,v in pairs(self.ifnotchanceloot) do
			table.insert(loots, v.prefab)
		end
	end
    if self.loot then
		for k,v in ipairs(self.loot) do
			table.insert(loots, v)
		end
	end
	local recipe = GLOBAL.GetRecipe(self.inst.prefab)
	if recipe and not self.inst.components.norecipelootdrop then
		local percent = 1
		if self.inst.components.finiteuses then
			percent = self.inst.components.finiteuses:GetPercent()
		end
		for k,v in ipairs(recipe.ingredients) do
			local amt = math.ceil( (v.amount * TUNING.HAMMER_LOOT_PERCENT) * percent)
			for n = 1, amt do
				table.insert(loots, v.type)
			end
		end
	end
    return loots
    end
end	      
AddComponentPostInit("lootdropper", lootdropperpostinit)