local hungerbonus = GetModConfigData("hunger")
local speedbonus = GetModConfigData("speed")
local levelbonus = GetModConfigData("level")
local mytype = GetModConfigData("type")
local myitem = GetModConfigData("item")
local obediencebonus = GetModConfigData("obedience")

---Obedience Level---
if obediencebonus == 0 then
TUNING.BEEFALO_DOMESTICATION_STARVE_OBEDIENCE = TUNING.BEEFALO_DOMESTICATION_STARVE_OBEDIENCE/levelbonus
TUNING.BEEFALO_DOMESTICATION_FEED_OBEDIENCE = TUNING.BEEFALO_DOMESTICATION_FEED_OBEDIENCE*levelbonus
TUNING.BEEFALO_DOMESTICATION_OVERFEED_OBEDIENCE = TUNING.BEEFALO_DOMESTICATION_OVERFEED_OBEDIENCE/levelbonus
TUNING.BEEFALO_DOMESTICATION_ATTACKED_BY_PLAYER_OBEDIENCE = TUNING.BEEFALO_DOMESTICATION_STARVE_OBEDIENCE/levelbonus
TUNING.BEEFALO_DOMESTICATION_BRUSHED_OBEDIENCE = TUNING.BEEFALO_DOMESTICATION_BRUSHED_OBEDIENCE*levelbonus
TUNING.BEEFALO_DOMESTICATION_SHAVED_OBEDIENCE = TUNING.BEEFALO_DOMESTICATION_SHAVED_OBEDIENCE/levelbonus
end
if obediencebonus == 1 then
TUNING.BEEFALO_DOMESTICATION_STARVE_OBEDIENCE = 0
TUNING.BEEFALO_DOMESTICATION_FEED_OBEDIENCE = TUNING.BEEFALO_DOMESTICATION_FEED_OBEDIENCE*levelbonus
TUNING.BEEFALO_DOMESTICATION_OVERFEED_OBEDIENCE = 0
TUNING.BEEFALO_DOMESTICATION_ATTACKED_BY_PLAYER_OBEDIENCE = 0
TUNING.BEEFALO_DOMESTICATION_BRUSHED_OBEDIENCE = TUNING.BEEFALO_DOMESTICATION_BRUSHED_OBEDIENCE*levelbonus
TUNING.BEEFALO_DOMESTICATION_SHAVED_OBEDIENCE = 0
end

---Domestication Level---
TUNING.BEEFALO_DOMESTICATION_LOSE_DOMESTICATION = 0
TUNING.BEEFALO_DOMESTICATION_GAIN_DOMESTICATION = TUNING.BEEFALO_DOMESTICATION_GAIN_DOMESTICATION*levelbonus
TUNING.BEEFALO_DOMESTICATION_MAX_LOSS_DAYS = 0
TUNING.BEEFALO_DOMESTICATION_OVERFEED_DOMESTICATION = 0
TUNING.BEEFALO_DOMESTICATION_ATTACKED_DOMESTICATION = 0
TUNING.BEEFALO_DOMESTICATION_ATTACKED_OBEDIENCE = 0
TUNING.BEEFALO_DOMESTICATION_ATTACKED_BY_PLAYER_DOMESTICATION = 0
TUNING.BEEFALO_DOMESTICATION_BRUSHED_DOMESTICATION = TUNING.BEEFALO_DOMESTICATION_BRUSHED_DOMESTICATION*levelbonus

---Hunger Modifier---
TUNING.BEEFALO_HUNGER_RATE = TUNING.BEEFALO_HUNGER_RATE*hungerbonus;

---Movement Speed Modifier---
TUNING.BEEFALO_WALK_SPEED = 1.0
TUNING.BEEFALO_RUN_SPEED = {
            DEFAULT = 7,
            RIDER = 8.0*speedbonus,
            ORNERY = 7.0*speedbonus,
            PUDGY = 6.5*speedbonus,
        }

---Type Preference---
if mytype == 2 then--Rider
	TUNING.BEEFALO_RIDER_RIDDEN = TUNING.BEEFALO_RIDER_RIDDEN*levelbonus
end
if mytype == 3 then--Ornery
	TUNING.BEEFALO_ORNERY_DOATTACK = TUNING.BEEFALO_ORNERY_DOATTACK*levelbonus
	TUNING.BEEFALO_ORNERY_ATTACKED = TUNING.BEEFALO_ORNERY_ATTACKED*levelbonus
end
if mytype == 4 then--Pudgy
	TUNING.BEEFALO_PUDGY_WELLFED = TUNING.BEEFALO_PUDGY_WELLFED*levelbonus
	TUNING.BEEFALO_PUDGY_OVERFEED = TUNING.BEEFALO_PUDGY_OVERFEED*levelbonus
end

------------------------------------------Current Beefalo Status-------------------------------------
	local Hunger = "Hunger "
	local Obey = "Obedience "
	local Process = "Tamed "

	local round2=function(num, idp)
		return GLOBAL.tonumber(string.format("%." .. (idp or 0) .. "f", num))
	end

	AddComponentPostInit("inspectable", function(inst)
		local oldGetDesc = inst.GetDescription
		function inst:GetDescription(viewer)
			local desc = oldGetDesc(self,viewer)
			if self.inst and self.inst.components then
				is_admin = nil
				local item = self.inst
				local prefab = item.prefab
				if type(desc)~="string" then
					desc=""
				end
				local c=item.components
				if c.domesticatable then 
					local myhunger = c.hunger.current
					local myobey = c.domesticatable:GetObedience()*100
					local mydomesticate = c.domesticatable:GetDomestication()*100
					desc = (desc.."\n")..Hunger..tostring(round2(myhunger,1))
					desc = (desc.."\n")..Obey..tostring(round2(myobey,2)).."%"
					desc = (desc.."\n")..Process..tostring(round2(mydomesticate,2)).."%"
				end
			end
		return desc
		end
	end)
--------------------------------------------Items-------------------------------------------------

modimport("scripts/patches/beefalodomestication.lua")

if myitem == 1 then

	TUNING.SADDLE_MOON_BONUS_DAMAGE = 30
	TUNING.SADDLE_MOON_USES = 10
	TUNING.SADDLE_MOON_SPEEDMULT = 1.25

	PrefabFiles = {
		"fodder",
		"saddle_moon",
		"dragonbulb",
		"beefalocollar",
		"permission",
	}

	Assets = {
		Asset("IMAGE", "images/inventoryimages/saddle_moon.tex"),
		Asset("ATLAS", "images/inventoryimages/saddle_moon.xml"),
		Asset( "IMAGE", "images/inventoryimages/fodder.tex" ),
		Asset( "ATLAS", "images/inventoryimages/fodder.xml" ),
		Asset( "IMAGE", "images/inventoryimages/dragonbulb.tex" ),
		Asset( "ATLAS", "images/inventoryimages/dragonbulb.xml" ),
		Asset( "IMAGE", "images/inventoryimages/beefalocollar.tex" ),
		Asset( "ATLAS", "images/inventoryimages/beefalocollar.xml" ),
		Asset( "IMAGE", "images/inventoryimages/permission.tex" ),
		Asset( "ATLAS", "images/inventoryimages/permission.xml" ),
	}

	local require = GLOBAL.require

	local Ingredient = GLOBAL.Ingredient
	local RECIPETABS = GLOBAL.RECIPETABS
	local STRINGS = GLOBAL.STRINGS
	local TECH = GLOBAL.TECH
	
	local saddle_moon = GLOBAL.Recipe("saddle_moon", {Ingredient("dragon_scales", 1), Ingredient("moonrocknugget", 4), Ingredient("steelwool", 2)}, RECIPETABS.TOOLS,  TECH.SCIENCE_TWO)
	saddle_moon.atlas = "images/inventoryimages/saddle_moon.xml"
	local fodder = GLOBAL.Recipe("fodder", {Ingredient("cutgrass", 4), Ingredient("twigs", 3)}, RECIPETABS.SURVIVAL,  TECH.SCIENCE_ONE)
	fodder.atlas = "images/inventoryimages/fodder.xml"
	local dragonbulb = GLOBAL.Recipe("dragonbulb", {Ingredient("dragonfruit", 1), Ingredient("lightbulb", 1)}, RECIPETABS.SURVIVAL,  TECH.SCIENCE_ONE)
	dragonbulb.atlas = "images/inventoryimages/dragonbulb.xml"
	local permission = GLOBAL.Recipe("permission", {Ingredient("honey", 1)},RECIPETABS.SURVIVAL,  TECH.SCIENCE_ONE)
	permission.atlas = "images/inventoryimages/permission.xml"
	
	GLOBAL.STRINGS.NAMES.SADDLE_MOON = "Moon Saddle"
	GLOBAL.STRINGS.RECIPE_DESC.SADDLE_MOON = "More damage,easier to make"
	GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.SADDLE_MOON = "It makes my beefalo stronger and faster!"
	GLOBAL.STRINGS.NAMES.FODDER = "Beefer Snack"
	GLOBAL.STRINGS.RECIPE_DESC.FODDER = "A snack for your Beefalo."
	GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.FODDER = "It's for beefalo."
	GLOBAL.STRINGS.NAMES.DRAGONBULB = "Dragonbulb"
	GLOBAL.STRINGS.RECIPE_DESC.DRAGONBULB = "Food to make your Beefalo feel better."
	GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.DRAGONBULB = "My beefalo will like this."
	GLOBAL.STRINGS.NAMES.PERMISSION = "Permission"
	GLOBAL.STRINGS.RECIPE_DESC.PERMISSION = "Allow others to ride your beefalo."
	GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.PERMISSION = "It's for my friend."
	GLOBAL.STRINGS.NAMES.BEEFALOCOLLAR = "Beefalo Collar"
	GLOBAL.STRINGS.RECIPE_DESC.BEEFALOCOLLAR = "If you love it, put a ring on it."
	GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.BEEFALOCOLLAR = "It may be smelly, but it will be mine."
end




