--[[
    ╔══════════════════════════════════════════════════════════════════════╗
    ║                    AGENCY ZERO  -  CONFIGURATION                     ║
    ║                          (c) Agency Scripts                          ║
    ╚══════════════════════════════════════════════════════════════════════╝

    CONTENTS
     1. Agency Companion   The free app for your players, accent colour
     2. Core               Language, own texts, debug
     3. Integrations       Agency-Notify, Agency-Progressbar, sounds
     4. Vehicle            Model, plate, colour, wheels, doors, sound chip
     5. Autopilot          /zero without the Agency Phone, notices
     6. Remote & Buying    Owner remote, delivery, buying in game
     7. Cockpit            AgencyOS 27 tablet in the car, Angy destinations
     8. Assistance         Angy assistants and parking assist
     9. Tuning & Stats     Chip tuning stages, statistics
    10. Pro                Unlocks with a genuine Agency Phone

    Project 0 is a free Agency Scripts release.
    Discord: https://discord.gg/RTax3aBMUs · Shop: https://shop.agencyg.de

    Texts live in shared/sprachen*.lua (25+ languages). Your own texts go into
    Config.Text below, they win over the shipped translations and survive
    every update.
]]

Config = {}


--==============================================================================
--  1 · AGENCY COMPANION
--==============================================================================
-- Agency-Companion (free): https://shop.agencyg.de/en/product/agency-companion
-- One resource for every Agency script: your players link them with the free
-- Agency Companion app (iPhone, Android, web) and call their Project 0, open
-- the doors, lock it, switch the lights, see battery and range and buy chip
-- tuning from the phone. Your admins pick one accent colour for all Agency
-- scripts in game (/app, admin page). Drop it into your resources, done.
-- The app can never do more than the player could do himself: the car must be
-- his, and everything you have to touch only works near the car.
-- Linked phones are stored in data/agency-zero.json, no database needed.
Config.Companion = {
    Enabled = true,                           -- connect with Agency-Companion (app + accent colour)
    EnableRemote = true,                      -- false = menu stays, but the server does not talk to the relay
    RelayUrl = 'https://api.agencyg.de',
    TokenTTL = 300,                           -- seconds a pairing code stays valid
    MaxDevices = 3,                           -- linked phones per character (the oldest drops out)
}

-- ── Accent colour ────────────────────────────────────────────────────────────
-- false     = the colour from Agency-Companion, gold without it
-- { r,g,b } = a fixed colour for this script only, e.g. { 0, 190, 255 }
Config.AccentColor = false


--==============================================================================
--  2 · CORE
--==============================================================================

-- ── Language ─────────────────────────────────────────────────────────────────
-- en bg cs da de el es fi fr hr hu it ja ko nb nl pl pt ro ru sk sv tr uk zh (also ar, hi)
-- 'auto' = the game language of each player, English when it is not shipped.
Config.Locale = 'en'

-- ── Own texts ────────────────────────────────────────────────────────────────
-- Keys as in shared/sprachen.lua, e.g. Config.Text.called = 'Your car is on its way.'
Config.Text = {}

-- ── Debug ────────────────────────────────────────────────────────────────────
Config.Debug = false


--==============================================================================
--  3 · INTEGRATIONS
--==============================================================================

-- ── Notifications ────────────────────────────────────────────────────────────
-- Agency-Notify (free): https://agency-script.tebex.io/package/6937769
-- 'auto'   = Agency-Notify when it runs, otherwise QBCore, otherwise the GTA feed
-- 'native' = always the GTA feed
Config.Notify = 'auto'

-- ── Progress bar ─────────────────────────────────────────────────────────────
-- Agency-Progressbar (free): https://agency-script.tebex.io/package/7000468
-- Shown while chip tuning is flashed and the sound chip is switched.
-- 'auto' = Agency-Progressbar when it runs (nothing extra otherwise), false = never
Config.Progressbar = 'auto'

-- ── Sounds ───────────────────────────────────────────────────────────────────
-- Doors, controls, remote and warnings (GTA's own sounds, no extra files)
Config.Sounds = { enabled = true }


--==============================================================================
--  4 · VEHICLE
--==============================================================================
Config.Model = 'zero'                         -- spawn name of Project 0 (display name "Project 0", brand "Agency")
Config.Plate = 'AGENCY 0'                     -- plate of a called car (max. 8 characters)
Config.Colour = 111                           -- GTA colour index (111 = white)

-- ── Wheels ───────────────────────────────────────────────────────────────────
-- GTA stock wheels through tuning (type 7 = High End). Try in game: /agwheels <type> <index>
Config.WheelType = 7
Config.WheelIndex = 0

-- ── Doors ────────────────────────────────────────────────────────────────────
-- Open and close by themselves when Project 0 is called (there is no door handle).
Config.Doors = {
    openTime = 950,                           -- ms for one door (soft ease out)
    closeTime = 850,
    stagger = 140,                            -- ms between the doors (front first when opening, rear first when closing)
    flashOnOpen = true,                       -- hazards twice when opening
    flashOnClose = true,                      -- once when closing ("locked")
}

-- ── Sound chip ───────────────────────────────────────────────────────────────
-- The engine sound is selectable in the Vehicle tab. Uses ForceUseAudioGameObject:
-- the car takes the full sound of another vehicle (idle, revs, load, exhaust).
-- No audio files, no licence question, and EVERY player hears the chosen chip
-- (state bag on the vehicle). audio = nil is the stock sound. Names are GTA
-- vehicle ids; own audio packs work with their id.
Config.SoundChip = {
    enabled = true,
    chips = {
        { id = 'stock',   label = 'Stock',    audio = nil },
        { id = 'v16',     label = 'V16',      audio = 'ADDER' },
        { id = 'v8',      label = 'V8',       audio = 'DOMINATOR' },
        { id = 'v12',     label = 'V12',      audio = 'ZENTORNO' },
        { id = 'turbo',   label = 'Turbo',    audio = 'SULTANRS' },
        { id = 'race',    label = 'Race',     audio = 'TYRUS' },
        { id = 'electro', label = 'Electric', audio = 'RAIDEN' },
    },
}


--==============================================================================
--  5 · AUTOPILOT
--==============================================================================
-- Autopilot without the Agency Phone (command /zero and key). With the Agency
-- Phone everything runs through the AutoRide app.
Config.Autopilot = {
    enabled = true,
    command = 'zero',                         -- /zero, /zero cancel, /zero speed <km/h>, /zero traffic
    key = 'F7',                               -- default key to call (players can rebind it), '' = none
    cooldown = 20,                            -- seconds between two calls
    cruiseKmh = 80,                           -- cruise speed to the destination
    pickupKmh = 110,                          -- speed on the way to the player
    minKmh = 20, maxKmh = 255,                -- limits for /zero speed (the car is lifted when needed)
    arrivalRadius = 16.0,                     -- how close the car comes to the player
    dropoffRadius = 20.0,                     -- how close to the destination
    boardingRadius = 10.0,                    -- E/F within this radius counts as getting in
    waitForBoarding = 120,                    -- seconds the car waits for the player, then leaves
    despawnAfterRide = true,                  -- drive away and despawn after the ride (false: stay)
    invisibleDriver = true,                   -- invisible NPC driver (the car has no steering wheel)
    blipSprite = 198, blipColour = 5,         -- map blip sprite and colour (5 = yellow/gold)
}

-- ── Agency Phone notice ──────────────────────────────────────────────────────
-- Notice about the Agency Phone while driving without it. With a genuine Agency
-- Phone calls run through the AutoRide app and the notice is gone.
Config.Ads = {
    enabled = true,
    onCall = true,                            -- when calling
    onArrival = true,                         -- at the destination
    everyNthRide = 1,                         -- 1 = every ride, 3 = every third ride
}


--==============================================================================
--  6 · REMOTE & BUYING
--==============================================================================

-- ── Remote ───────────────────────────────────────────────────────────────────
-- Owners open the remote with the cockpit key outside the car. A car on the map
-- drives to the player (takes time depending on the distance), otherwise it is
-- delivered for a fee.
Config.Remote = {
    enabled = true,
    deliveryFee = 250,                        -- delivery fee (free without a framework)
    directRadius = 300.0,                     -- closer than this: the car leaves visibly at once
    pickupKmh = 110,                          -- speed on the way to the player
    arrivalRadius = 16.0,                     -- how close the car comes
    ignoreTraffic = true,                     -- ignore traffic rules on the way to the caller (red lights, right of way).
                                              -- false = waits at every light, the trip takes much longer.
                                              -- Parking at the end stays careful either way.
    greetRadius = 12.0,                       -- the waiting car recognises its owner and opens the driver door
    ownership = 'auto',                       -- 'auto': QBCore player_vehicles / ESX owned_vehicles (everyone owns one without a framework)
                                              -- 'everyone': every player owns one, 'none': no remote
    giveCommand = 'zerogive',                 -- admin: /zerogive [id] gives a Project 0 (ace command.zerogive, group.admin or QBCore admin)
    garage = 'pillboxgarage',                 -- garage for given cars (QBCore)
    findRadarSeconds = 45,                    -- "Find": how long the radar stays at the bottom centre (0 = none)
}

-- ── Buying ───────────────────────────────────────────────────────────────────
-- Buy a Project 0 in game, no dealer, no admin. The button is in the Zero app of
-- the Agency Phone and in the Companion app; owners do not see it.
Config.Buy = {
    enabled = true,
    price = 45000,                            -- price in $
    account = 'bank',                         -- 'bank' or 'cash'; the other one is tried when it is not enough
}


--==============================================================================
--  7 · COCKPIT
--==============================================================================
-- AgencyOS 27 tablet in the Zero (only in the car). Tap the map = destination,
-- start ride = the Zero drives there on its own. Angy understands destinations
-- (list below), speeds ("100 km/h"), "stop", "door open/close", "status",
-- "lights on/off" and "override on/off".
Config.Cockpit = {
    key = 'Z',                                -- tablet key in the Zero (players can rebind it), '' = none
    autopilotKey = 'U',                       -- toggles the autopilot; without a destination the map waypoint is used. '' = none
    overrideDefault = true,                   -- manual override on by default: drive yourself at once, assistants help.
                                              -- false = the Zero only drives autonomously until the driver allows it.
    cruiseKmh = 80,                           -- cruise speed at the start
    minKmh = 20, maxKmh = 255,                -- slider limits; the slider ends at the real top speed of the car
    arrivalRadius = 14.0,                     -- how close the car drives to the destination
    kmPerPercent = 4.5,                       -- range per percent of battery (GTA fuel tank as battery)
    pois = {                                  -- Angy destinations: name, coordinates, search words (lower case)
        { name = 'Legion Square',            x = 195.0,   y = -933.0,  keywords = { 'legion', 'square', 'zentrum', 'downtown', 'centre', 'centro' } },
        { name = 'Los Santos Airport',       x = -1037.0, y = -2737.0, keywords = { 'airport', 'flughafen', 'aeropuerto', 'aéroport', 'aeroporto', 'lsia', 'flugplatz' } },
        { name = 'Pillbox Hill Hospital',    x = 307.0,   y = -1433.0, keywords = { 'hospital', 'krankenhaus', 'pillbox', 'klinik', 'hôpital', 'ospedale', 'arzt', 'doctor' } },
        { name = 'Mission Row Police',       x = 428.0,   y = -984.0,  keywords = { 'police', 'polizei', 'policía', 'polizia', 'mission row', 'lspd', 'cops', 'wache' } },
        { name = 'Del Perro Pier',           x = -1850.0, y = -1231.0, keywords = { 'pier', 'del perro', 'seebrücke', 'muelle' } },
        { name = 'Vespucci Beach',           x = -1600.0, y = -1015.0, keywords = { 'beach', 'strand', 'vespucci', 'playa', 'plage', 'spiaggia' } },
        { name = 'Diamond Casino',           x = 925.0,   y = 46.0,    keywords = { 'casino', 'diamond', 'kasino' } },
        { name = 'Maze Bank Tower',          x = -70.0,   y = -800.0,  keywords = { 'maze bank', 'bank', 'tower', 'turm' } },
        { name = 'Rockford Plaza',           x = -160.0,  y = -300.0,  keywords = { 'rockford', 'plaza', 'mall', 'einkaufen', 'shopping' } },
        { name = 'Vinewood Boulevard',       x = 250.0,   y = 280.0,   keywords = { 'vinewood', 'boulevard', 'hollywood' } },
        { name = 'Mirror Park',              x = 1097.0,  y = -650.0,  keywords = { 'mirror park', 'mirror' } },
        { name = 'Los Santos Customs',       x = -365.0,  y = -131.0,  keywords = { 'customs', 'tuning', 'werkstatt', 'taller', 'garage', 'mechanic', 'mechaniker' } },
        { name = 'Premium Deluxe Motorsport', x = -56.0,  y = -1096.0, keywords = { 'motorsport', 'autohaus', 'dealer', 'car dealer', 'concesionario' } },
        { name = 'Grove Street',             x = 110.0,   y = -1960.0, keywords = { 'grove', 'grove street' } },
        { name = 'Sandy Shores',             x = 1960.0,  y = 3740.0,  keywords = { 'sandy', 'sandy shores', 'wüste', 'desert' } },
        { name = 'Paleto Bay',               x = -140.0,  y = 6360.0,  keywords = { 'paleto', 'paleto bay', 'norden', 'north' } },
        { name = 'Galileo Observatory',      x = -438.0,  y = 1076.0,  keywords = { 'observatory', 'observatorium', 'sternwarte', 'galileo' } },
    },
}


--==============================================================================
--  8 · ASSISTANCE
--==============================================================================

-- ── Angy assistance ──────────────────────────────────────────────────────────
-- Assistance tab in the tablet, every assistant switches on its own, the
-- choice is kept per player. defaults = state until the player changes it.
Config.Assist = {
    -- On by default: emergency brake, parking assist and hints. Pull over on
    -- menu and warning tone are off, they would step into driving unasked.
    -- brakeall = also brakes for walls, bollards and everything else while
    -- self-driving (off by default, it steps in early and often).
    defaults = { brake = true, brakeall = false, limiter = false, pullover = false, park = true, hints = true, warnsound = false },
    limitKmh = 80,                            -- default of the speed limiter (players set it in the Assistance tab)
    brakeMinKmh = 15,                         -- emergency brake from this speed
    brakeHeadway = 1.4,                       -- seconds of sight: obstacles closer than speed x headway are braked for
    batteryHint = 15,                         -- battery hint below this percentage
}

-- ── Parking assist ───────────────────────────────────────────────────────────
-- Called or delivered, the Zero looks for a free gap at the kerb on the
-- player's side, approaches slowly and parks straight. Also used when pulling over.
Config.Parking = {
    searchRange = 34.0,                       -- search radius around the player (m)
    approachDist = 14.0,                      -- approach point this far before the gap (m)
    laneOffset = 2.6,                         -- approach point this far from the kerb towards the lane centre (m)
    bayWidth = 2.8,                           -- width of a parking bay between the painted lines (m)
    bayDepth = 5.4,                           -- depth of a bay (m); change both for maps with other bays
}


--==============================================================================
--  9 · TUNING & STATS
--==============================================================================

-- ── Chip tuning ──────────────────────────────────────────────────────────────
-- Upgrades tab: engine/brakes/transmission = GTA tuning level 1..4 (0 = stock),
-- speedPct raises the top speed (also for the autopilot), powerPct the power.
-- Prices in $, free without a framework.
Config.Tuning = {
    enabled = true,
    account = 'bank',                         -- 'bank' or 'cash'; the other one is tried when it is not enough
    stages = {
        { name = 'Stage 1', price = 15000, engine = 2, brakes = 1, transmission = 1, turbo = false, powerPct = 10, speedPct = 8 },
        { name = 'Stage 2', price = 35000, engine = 3, brakes = 2, transmission = 2, turbo = true,  powerPct = 20, speedPct = 16 },
        { name = 'Stage 3', price = 70000, engine = 4, brakes = 3, transmission = 3, turbo = true,  powerPct = 35, speedPct = 25 },
    },
}

-- ── Statistics ───────────────────────────────────────────────────────────────
-- Per plate (km, autopilot km, rides, top speed, driving time) in data/agency-zero.json
Config.Stats = { enabled = true }


--==============================================================================
--  10 · PRO
--==============================================================================
-- The Pro version unlocks by itself as soon as a genuine Agency Phone runs on
-- this server, and only then. Checked on the server with a handshake
-- (HMAC-SHA256 on a fresh nonce). An empty folder called agency-phone is not
-- enough, and the start order of both resources does not matter.
Config.Pro = {
    enabled = true,                           -- false = no check, everyone counts as Pro (own tests only)
    phoneResource = 'agency-phone',           -- name of the phone resource if it is called differently
    phoneFallbacks = { 'agency-pad' },        -- without the phone, Pro also comes from these (Agency Pad)
    recheckSeconds = 90,                      -- silent re-check in the background (at least 30)
    skew = 30,                                -- allowed clock difference in seconds
}
