require "DAMN_Parts";
require "DAMN_Spawns";

--***********************************************************
--**                   KI5 / bikinihorst                   **
--***********************************************************

DAMN.Parts:processConfigV2("SUB93", {
	["BumperFront"] = {
		partId = "DAMNBumperFront",
		itemToModel = {
			["Base.93chevySuburbanBumperFront0"] = "FrontBumper0",
			["Base.93chevySuburbanBumperFront1"] = "FrontBumper1",
			["Base.93chevySuburbanBullbarFrontA"] = "FrontBullbarA",
			["Base.93chevySuburbanBullbarFrontB"] = "FrontBullbarB",
            ["Base.93chevySuburbanBullbarFrontB2"] = "FrontBullbarB2",
			["Base.93chevySuburbanBullbarFrontC"] = "FrontBullbarC",
		},
		allowedForRandom = {
            "Base.93chevySuburbanBumperFront0", "Base.93chevySuburbanBumperFront1"
        },
		default = "trve_random",
		noPartChance = 5,
	},
    ["BumperFrontP"] = {
		partId = "DAMNBumperFront",
		itemToModel = {
			["Base.93chevySuburbanBumperFront0"] = "FrontBumper0",
			["Base.93chevySuburbanBumperFront1"] = "FrontBumper1",
			["Base.93chevySuburbanBullbarFrontA"] = "FrontBullbarA",
			["Base.93chevySuburbanBullbarFrontB"] = "FrontBullbarB",
            ["Base.93chevySuburbanBullbarFrontB2"] = "FrontBullbarB2",
			["Base.93chevySuburbanBullbarFrontC"] = "FrontBullbarC",
            ["Base.93chevySilveradoPlowFrame"] = "FrontBullbarP",
		},
		allowedForRandom = {
            "Base.93chevySuburbanBumperFront0", "Base.93chevySuburbanBumperFront1"
        },
		default = "trve_random",
		noPartChance = 5,
	},
	["BumperFrontPD"] = {
		partId = "DAMNBumperFront",
		itemToModel = {
			["Base.93chevySuburbanBumperFront0"] = "FrontBumper0",
			["Base.93chevySuburbanBumperFront1"] = "FrontBumper1",
			["Base.93chevySuburbanBullbarFrontA"] = "FrontBullbarA",
			["Base.93chevySuburbanBullbarFrontB"] = "FrontBullbarB",
            ["Base.93chevySuburbanBullbarFrontB2"] = "FrontBullbarB2",
			["Base.93chevySuburbanBullbarFrontC"] = "FrontBullbarC",
		},
		default = "93chevySuburbanBullbarFrontA",
	},
	["BumperFrontFD"] = {
		partId = "DAMNBumperFront",
		itemToModel = {
			["Base.93chevySuburbanBumperFront0"] = "FrontBumper0",
			["Base.93chevySuburbanBumperFront1"] = "FrontBumper1",
			["Base.93chevySuburbanBullbarFrontA"] = "FrontBullbarA",
			["Base.93chevySuburbanBullbarFrontB"] = "FrontBullbarB",
            ["Base.93chevySuburbanBullbarFrontB2"] = "FrontBullbarB2",
			["Base.93chevySuburbanBullbarFrontC"] = "FrontBullbarC",
		},
		default = "93chevySuburbanBullbarFrontC",
	},
    ["BumperFrontW"] = {
		partId = "DAMNBumperFront",
		itemToModel = {
			["Base.93chevySuburbanBumperFront0"] = "FrontBumper0",
			["Base.93chevySuburbanBumperFront1"] = "FrontBumper1",
			["Base.93chevySuburbanBullbarFrontA"] = "FrontBullbarA",
			["Base.93chevySuburbanBullbarFrontB"] = "FrontBullbarB",
            ["Base.93chevySuburbanBullbarFrontB2"] = "FrontBullbarB2",
			["Base.93chevySuburbanBullbarFrontC"] = "FrontBullbarC",
            ["Base.93chevySuburbanBullbarFrontD"] = "FrontBullbarD",
		},
		default = "93chevySuburbanBullbarFrontD",
	},
	["BumperRear"] = {
		partId = "DAMNBumperRear",
		itemToModel = {
			["Base.93chevySuburbanBumperRear0"] = "RearBumper0",
		},
		default = "trve_random",
		noPartChance = 5,
	},
	["WindshieldArmor"] = {
		partId = "DAMNWindshieldArmor",
		itemToModel = {
			["Base.93chevySuburbanWindshieldArmor"] = "SUB93winda",
		},
	},
	["WindshieldRearArmor"] = {
		partId = "DAMNWindshieldRearArmor",
		itemToModel = {
			["Base.93chevySuburbanWindshieldRearArmor"] = "SUB93windrb",
		},
	},
	["WindowFrontLeftArmor"] = {
		partId = "DAMNFrontLeftArmor",
		itemToModel = {
			["Base.93chevySuburbanFrontWindowArmor"] = "SUB93leftWindowa",
		},
	},
	["WindowFrontRightArmor"] = {
		partId = "DAMNFrontRightArmor",
		itemToModel = {
			["Base.93chevySuburbanFrontWindowArmor"] = "SUB93rightWindowa",
		},
	},
	["WindowRearLeftArmor"] = {
		partId = "DAMNRearLeftArmor",
		itemToModel = {
			["Base.93chevySuburbanRearWindowArmor"] = "SUB93leftWindowra",
		},
	},
	["WindowRearRightArmor"] = {
		partId = "DAMNRearRightArmor",
		itemToModel = {
			["Base.93chevySuburbanRearWindowArmor"] = "SUB93rightWindowra",
		},
	},
	["WindowBackLeftArmor"] = {
		partId = "DAMNRearLeftArmor",
		itemToModel = {
			["Base.93chevySuburbanBackWindowArmor"] = "SUB93leftWindowba",
		},
	},
	["WindowBackRightArmor"] = {
		partId = "DAMNBackRightArmor",
		itemToModel = {
			["Base.93chevySuburbanBackWindowArmor"] = "SUB93rightWindowba",
		},
	},
	["Roofrack"] = {
		partId = "SUB93Roofrack",
		itemToModel = {
			["Base.93chevySuburbanRoofrack2"] = "SUB93Roofrack0",
		},
		default = "trve_random",
		noPartChance = 85,
	},
	["SideSteps"] = {
		partId = "DAMNSideSteps",
		itemToModel = {
			["Base.93chevySuburbanSideSteps2"] = "SUB93SideSteps0",
            ["Base.93chevySuburbanSideStepsMetal2"] = "SUB93SideSteps1",
            ["Base.93chevySuburbanSideStepsPipes2"] = "SUB93SideSteps2",
		},
		default = "trve_random",
		noPartChance = 25,
	},
    ["SideStepsS"] = {
		partId = "DAMNSideSteps",
		itemToModel = {
            ["Base.93chevySuburbanSideStepsMetal2"] = "SUB93SideSteps1",
            ["Base.93chevySuburbanSideStepsPipes2"] = "SUB93SideSteps2",
		},
		default = "trve_random",
		noPartChance = 33,
	},
    ["SideStepsNA"] = {
		partId = "DAMNSideSteps",
		itemToModel = {
			["Base.93chevySuburbanSideSteps2"] = "SUB93SideSteps0",
            ["Base.93chevySuburbanSideStepsMetal2"] = "SUB93SideSteps1",
            ["Base.93chevySuburbanSideStepsPipes2"] = "SUB93SideSteps2",
		},
	},
	["BugGuard"] = {
		partId = "SUB93BugGuard",
		itemToModel = {
			["Base.93chevySuburbanBugGuard2"] = "SUB93BugGuard0",
		},
		default = "trve_random",
		noPartChance = 85,
	},
	["TireFrontLeft"] = {
		partId = "TireFrontLeft",
		itemToModel = {
			["Base.93chevySuburbanTire1"] = "SUB93Tire0",
			["Base.93chevySuburbanTire2"] = "SUB93Tire1",
            ["Base.76chevyKseriesTire2"] = "SUB93Tire2",
            ["Base.80chevyCKseriesTire2"] = "SUB93Tire3",
            ["Base.80chevyCKseriesTire1"] = "SUB93Tire4",
            ["Base.90chevyCKseriesTire2"] = "SUB93Tire5",
            ["Base.90chevyCKseriesTire1"] = "SUB93Tire6",
		},
	},
	["TireFrontRight"] = {
		partId = "TireFrontRight",
		itemToModel = {
			["Base.93chevySuburbanTire1"] = "SUB93Tire0",
			["Base.93chevySuburbanTire2"] = "SUB93Tire1",
            ["Base.76chevyKseriesTire2"] = "SUB93Tire2",
            ["Base.80chevyCKseriesTire2"] = "SUB93Tire3",
            ["Base.80chevyCKseriesTire1"] = "SUB93Tire4",
            ["Base.90chevyCKseriesTire2"] = "SUB93Tire5",
            ["Base.90chevyCKseriesTire1"] = "SUB93Tire6",
		},
	},
	["TireRearLeft"] = {
		partId = "TireRearLeft",
		itemToModel = {
			["Base.93chevySuburbanTire1"] = "SUB93Tire0",
			["Base.93chevySuburbanTire2"] = "SUB93Tire1",
            ["Base.76chevyKseriesTire2"] = "SUB93Tire2",
            ["Base.80chevyCKseriesTire2"] = "SUB93Tire3",
            ["Base.80chevyCKseriesTire1"] = "SUB93Tire4",
            ["Base.90chevyCKseriesTire2"] = "SUB93Tire5",
            ["Base.90chevyCKseriesTire1"] = "SUB93Tire6",
		},
	},
	["TireRearRight"] = {
		partId = "TireRearRight",
		itemToModel = {
			["Base.93chevySuburbanTire1"] = "SUB93Tire0",
			["Base.93chevySuburbanTire2"] = "SUB93Tire1",
            ["Base.76chevyKseriesTire2"] = "SUB93Tire2",
            ["Base.80chevyCKseriesTire2"] = "SUB93Tire3",
            ["Base.80chevyCKseriesTire1"] = "SUB93Tire4",
            ["Base.90chevyCKseriesTire2"] = "SUB93Tire5",
            ["Base.90chevyCKseriesTire1"] = "SUB93Tire6",
		},
	},
    ["GasCanOne"] = {
		partId = "DAMNGasCanOne",
		itemToModel = {
			["USMIL.GasCan0"] = "GasCanOne",
			["USMIL.WaterCan0"] = "WaterCanOne",
		},
	},
	["GasCanTwo"] = {
		partId = "DAMNGasCanTwo",
		itemToModel = {
			["USMIL.GasCan0"] = "GasCanTwo",
			["USMIL.WaterCan0"] = "WaterCanTwo",
		},
	},
	["GasCanThree"] = {
		partId = "DAMNGasCanThree",
		itemToModel = {
			["USMIL.GasCan0"] = "GasCanThree",
			["USMIL.WaterCan0"] = "WaterCanThree",
		},
	},
    ["Mudflaps"] = {
		partId = "DAMNMudflaps",
		itemToModel = {
			["Base.93chevyK3500mudflaps2"] = "Mudflaps0",
		},
		default = "trve_random",
		noPartChance = 25,
	},
    ["BedTarp"] = {
		partId = "SIL93Tarp",
		itemToModel = {
			["Base.93chevySilveradoBedTarp2"] = "bedTarp0",
		},
	},
    ["BedStakes"] = {
		partId = "SIL93BedStakes",
		itemToModel = {
			["Base.93chevySilveradoStakes2"] = "bedStakes0",
		},
	},
    ["BedStakesR"] = {
		partId = "SIL93BedStakes",
		itemToModel = {
			["Base.93chevySilveradoStakes2"] = "bedStakes0",
		},
		default = "trve_random",
		noPartChance = 5,
	},
    ["RollbarToolbox"] = {
		partId = "SUB93RollbarToolbox",
		itemToModel = {
			["Base.93chevySilverdoRollbar2"] = {"93chevySilveradoLight", "93chevySilveradoRoll"},
            ["Base.93chevyK3500toolbox2"] = "93chevySilveradoToolbox",
		},
	},
    ["RollbarToolboxR"] = {
		partId = "SUB93RollbarToolbox",
		itemToModel = {
			["Base.93chevySilverdoRollbar2"] = {"93chevySilveradoLight", "93chevySilveradoRoll"},
            ["Base.93chevyK3500toolbox2"] = "93chevySilveradoToolbox",
		},
		default = "trve_random",
		noPartChance = 33,
	},
    ["RollbarToolbox2"] = {
		partId = "SUB93RollbarToolbox",
		itemToModel = {
			["Base.93chevySilverdoRollbar2"] = {"93chevySilveradoLight", "93chevySilveradoRoll"},
            ["Base.93chevyK3500toolbox2"] = "93chevySilveradoToolbox",
		},
		default = "Base.93chevyK3500toolbox2",
	},
});


function SUB93.ContainerAccess.Trunk(vehicle, part, chr)
	if chr:getVehicle() == vehicle then
		local seat = vehicle:getSeat(chr)
		return seat == 5 or seat == 4 or seat == 3 or seat == 2;
	elseif chr:getVehicle() then
		return false
	else
		if not vehicle:isInArea(part:getArea(), chr) then return false end
		local doorPart = vehicle:getPartById("TrunkDoor")
		if doorPart and doorPart:getDoor() and not doorPart:getDoor():isOpen() then
			return false
		end
		return true
	end
end

function SUB93.ContainerAccess.TrunkPD(vehicle, part, chr)
	if chr:getVehicle() then return false end
	if not vehicle:isInArea(part:getArea(), chr) then return false end
	local doorPart = vehicle:getPartById("TrunkDoor")
	if doorPart and doorPart:getDoor() then
		if not doorPart:getInventoryItem() then return true end
		if not doorPart:getDoor():isOpen() then return false end
	end
	return true
end