-- ============================================================================
-- Vamoose's Companion - Animation Database
-- Per-archetype behavior profiles mapping intents to animation fallback chains.
-- The resolver tries each name in order; first found in companion.animations wins.
-- ============================================================================

VC_AnimDB = {}

-- ============================================================================
-- COMPANION BEHAVIOR PROFILES
-- ============================================================================

VC_AnimDB.behaviors = {
    -- HUMANOID archetype (Vamoose, Gazlowe, Dash, Torque, Grimble)
    humanoid = {
        IDLE           = { "Stand" },
        IDLE_SEATED    = { "SitGround", "Stand" },
        FIDGET         = { "Talk", "Eat", "Question", "Point", "Shy", "Laugh", "Dance", "Wave", "Exclamation", "Bow", "Chicken", "Flex", "Kiss", "Rude", "Applaud", "Work", "Stand" },
        SLEEP          = { "Sleep", "SitGround", "Stand" },
        DYING          = { "Death", "Knockdown", "Stand" },
        MOURNING       = { "Cry", "Kneel", "Beg", "Cower", "Stand" },
        DISTRESSED     = { "Cower", "Stun", "StandWound", "CombatCritical", "CombatWound", "Stand" },
        EXCITED        = { "Exclamation", "Cheer", "Stand" },
        TRIUMPHANT     = { "BattleRoar", "Whirlwind", "Flex", "Cheer", "Stand" },
        CELEBRATING    = { "Cheer", "Dance", "Applaud", "Stand" },
        TALKING        = { "Talk", "Stand" },
        TALKING_URGENT = { "Exclamation", "Shout", "Talk", "Stand" },
        POINTING       = { "Point", "Exclamation", "Stand" },
        WORKING        = { "Work", "Loot", "Stand" },
        APPROVING      = { "Applaud", "Bow", "Stand" },
        MONEY          = { "Exclamation", "Flex", "Cheer", "Stand" },
        COMBAT_READY   = { "ReadyUnarmed", "Ready1H", "AttackUnarmed", "Attack1H", "CombatWound", "Stand" },
        SPELLCASTING   = { "SpellCastOmni", "ReadySpellOmni", "Stand" },
        SWIMMING       = { "SwimIdle", "Swim", "Stand" },
        SWIMMING_MOVE  = { "Swim", "SwimIdle", "Run", "Stand" },
        FLYING         = { "Hover", "Fly", "Stand" },
        FALLING        = { "Fall", "Stand" },
        MOUNTED        = { "Run", "Walk", "Stand" },
        LOOTING        = { "Loot", "Work", "Stand" },
        CRAFTING       = { "Work", "Loot", "Stand" },
        FISHING        = { "SitGround", "Stand" },
        INTERACTING    = { "Work", "Talk", "Stand" },
        HEARTHING      = { "Wave", "Cheer", "Stand" },
        GREETING       = { "Wave", "Bow", "Stand" },
        LAUGHING       = { "Laugh", "Stand" },
        EATING         = { "Eat", "SitGround", "Stand" },
        BORED          = { "Sleep", "SitGround", "Stand" },
        RELAXED        = { "SitGround", "Stand" },
        RUNNING        = { "Run", "Stand" },
        WALKING        = { "Walk", "Stand" },
    },

    -- BIRD archetype (Patches)
    -- Note: Fly animation sends parrot off-viewport. Use MountSpecial (wing flap in place) instead.
    bird = {
        IDLE           = { "SitGround", "Stand" },           -- perch
        IDLE_SEATED    = { "SitGround", "Stand" },
        FIDGET         = { "ReadyUnarmed", "MountSpecial", "Stand" },
        SLEEP          = { "SitGround", "Stand" },
        DYING          = { "Death", "Cower", "Stand" },
        MOURNING       = { "Cower", "SitGround", "Stand" },
        DISTRESSED     = { "Cower", "Stun", "CombatCritical", "CombatWound", "StandWound", "Stand" },
        EXCITED        = { "MountSpecial", "Stand" },
        TRIUMPHANT     = { "MountSpecial", "Stand" },
        CELEBRATING    = { "MountSpecial", "Stand" },
        TALKING        = { "Bow", "Stand" },
        TALKING_URGENT = { "ReadyCrossbow", "Bow", "Stand" },
        COMBAT_READY   = { "ReadyUnarmed", "AttackUnarmed", "Stand" },
        SPELLCASTING   = { "ReadyCrossbow", "Stand" },
        SWIMMING       = { "SwimIdle", "Swim", "Stand" },
        SWIMMING_MOVE  = { "Swim", "SwimIdle", "Run", "Stand" },
        FLYING         = { "Hover", "Run", "Walk", "Stand" },
        FALLING        = { "MountSpecial", "Stand" },
        MOUNTED        = { "Run", "Walk", "Stand" },
        LOOTING        = { "Loot", "LootHold", "Stand" },
        CRAFTING       = { "Work", "Loot", "Stand" },
        FISHING        = { "SitGround", "Stand" },
        INTERACTING    = { "Bow", "Work", "Stand" },
        HEARTHING      = { "MountSpecial", "Stand" },
        GREETING       = { "Bow", "Stand" },
        LAUGHING       = { "MountSpecial", "Bow", "Stand" },
        EATING         = { "SitGround", "Stand" },
        BORED          = { "SitGround", "Stand" },
        RELAXED        = { "SitGround", "Stand" },
        RUNNING        = { "Run", "Stand" },
        WALKING        = { "Walk", "Stand" },
        POINTING       = { "Bow", "Stand" },
        WORKING        = { "Work", "Loot", "Stand" },
        APPROVING      = { "Bow", "Stand" },
        MONEY          = { "MountSpecial", "Bow", "Stand" },
    },

    -- CRITTER archetype (Scurry)
    critter = {
        IDLE           = { "Stand" },
        IDLE_SEATED    = { "Stand" },
        FIDGET         = { "AttackUnarmed", "Run", "Stand" },
        SLEEP          = { "Death", "Stand" },  -- Death = curled up on side (no Sleep anim)
        DYING          = { "Death", "CombatWound", "Stand" },
        MOURNING       = { "CombatWound", "Stand" },
        DISTRESSED     = { "CombatWound", "Stand" },
        EXCITED        = { "Run", "AttackUnarmed", "Stand" },
        TRIUMPHANT     = { "Run", "AttackUnarmed", "Stand" },
        CELEBRATING    = { "Run", "AttackUnarmed", "Stand" },
        TALKING        = { "Stand" },
        TALKING_URGENT = { "AttackUnarmed", "Stand" },
        COMBAT_READY   = { "AttackUnarmed", "CombatWound", "Stand" },
        SPELLCASTING   = { "Stand" },
        SWIMMING       = { "SwimIdle", "Swim", "Stand" },
        SWIMMING_MOVE  = { "Swim", "SwimIdle", "Run", "Stand" },
        FLYING         = { "Run", "Walk", "Stand" },
        FALLING        = { "Run", "Stand" },
        MOUNTED        = { "Run", "Walk", "Stand" },
        LOOTING        = { "Stand" },
        CRAFTING       = { "Stand" },
        FISHING        = { "Stand" },
        INTERACTING    = { "Stand" },
        HEARTHING      = { "Run", "Stand" },
        GREETING       = { "Stand" },
        LAUGHING       = { "AttackUnarmed", "Stand" },
        EATING         = { "Stand" },
        BORED          = { "Death", "Stand" },  -- Death = curled on side (no Sleep/Sit)
        RELAXED        = { "Stand" },
        RUNNING        = { "Run", "Stand" },
        WALKING        = { "Walk", "Stand" },
        POINTING       = { "Run", "Stand" },
        WORKING        = { "Stand" },
        APPROVING      = { "Stand" },
        MONEY          = { "Run", "AttackUnarmed", "Stand" },
    },

    -- SERPENT archetype (Breezy)
    serpent = {
        IDLE           = { "Hover", "SwimIdle", "Stand" },
        IDLE_SEATED    = { "SwimIdle", "Stand" },
        FIDGET         = { "ShuffleLeft", "ShuffleRight", "Stand" },
        SLEEP          = { "SwimIdle", "Stand" },
        DYING          = { "Death", "Stun", "Stand" },
        MOURNING       = { "Stun", "SwimIdle", "Stand" },
        DISTRESSED     = { "Stun", "CombatWound", "Stand" },
        EXCITED        = { "Fly", "SpellCast", "Stand" },
        TRIUMPHANT     = { "Fly", "SpellCast", "Stand" },
        CELEBRATING    = { "Fly", "SpellCast", "Stand" },
        TALKING        = { "Stand" },
        TALKING_URGENT = { "SpellCast", "Stand" },
        COMBAT_READY   = { "ReadyUnarmed", "CombatWound", "Stand" },
        SPELLCASTING   = { "SpellCast", "Stand" },
        SWIMMING       = { "SwimIdle", "Swim", "Stand" },
        SWIMMING_MOVE  = { "Swim", "SwimIdle", "Run", "Stand" },
        FLYING         = { "Fly", "Hover", "Stand" },
        FALLING        = { "Fly", "Stand" },
        MOUNTED        = { "Run", "Walk", "Stand" },
        LOOTING        = { "Stand" },
        CRAFTING       = { "Stand" },
        FISHING        = { "SwimIdle", "Stand" },
        INTERACTING    = { "Stand" },
        HEARTHING      = { "Fly", "Stand" },
        GREETING       = { "ShuffleLeft", "Stand" },
        LAUGHING       = { "ShuffleRight", "Stand" },
        EATING         = { "SwimIdle", "Stand" },
        BORED          = { "SwimIdle", "Stand" },
        RELAXED        = { "Hover", "SwimIdle", "Stand" },
        RUNNING        = { "Run", "Stand" },
        WALKING        = { "Walk", "Stand" },
        POINTING       = { "ShuffleLeft", "Stand" },
        WORKING        = { "Stand" },
        APPROVING      = { "Stand" },
        MONEY          = { "Fly", "SpellCast", "Stand" },
    },

    -- DEMON archetype (Vexia)
    demon = {
        IDLE           = { "Stand" },
        IDLE_SEATED    = { "Stand" },
        FIDGET         = { "ReadyUnarmed", "Flourish", "Lean", "Preen", "Stand" },
        SLEEP          = { "Stand" },
        DYING          = { "Death", "CombatCritical", "Stand" },
        MOURNING       = { "CombatWound", "Stand" },
        DISTRESSED     = { "CombatWound", "CombatCritical", "Stand" },
        EXCITED        = { "BattleRoar", "Flourish", "Stand" },
        TRIUMPHANT     = { "BattleRoar", "Preen", "Stand" },
        CELEBRATING    = { "BattleRoar", "Flourish", "Stand" },
        TALKING        = { "Stand" },
        TALKING_URGENT = { "Flourish", "Stand" },
        COMBAT_READY   = { "ReadyUnarmed", "CombatCritical", "Stand" },
        SPELLCASTING   = { "Flourish", "Stand" },
        SWIMMING       = { "SwimIdle", "Swim", "Stand" },
        SWIMMING_MOVE  = { "Swim", "SwimIdle", "Run", "Stand" },
        FLYING         = { "SwimIdle", "Stand" }, -- owner call: the float pose reads as hovering
        FALLING        = { "Stand" },
        MOUNTED        = { "Run", "Walk", "Stand" },
        LOOTING        = { "Stand" },
        CRAFTING       = { "Lean", "Stand" },
        FISHING        = { "Stand" },
        INTERACTING    = { "Stand" },
        HEARTHING      = { "Preen", "Stand" },
        GREETING       = { "Flourish", "Stand" },
        LAUGHING       = { "Lean", "Stand" },
        EATING         = { "Stand" },
        BORED          = { "Stand" },
        RELAXED        = { "Stand" },
        RUNNING        = { "Run", "Stand" },
        WALKING        = { "Walk", "Stand" },
        POINTING       = { "Flourish", "Stand" },
        WORKING        = { "Lean", "Stand" },
        APPROVING      = { "Stand" },
        MONEY          = { "Preen", "Stand" },
    },

    -- PHOENIX archetype (Ember)
    phoenix = {
        IDLE           = { "Hover", "Stand" },
        IDLE_SEATED    = { "SitGround", "Stand" },
        FIDGET         = { "MountSpecial", "RunRight", "RunLeft", "Stand" },
        SLEEP          = { "SitGround", "Stand" },
        DYING          = { "Death", "Stun", "Stand" },
        MOURNING       = { "Stun", "SitGround", "Stand" },
        DISTRESSED     = { "Stun", "CombatWound", "Stand" },
        EXCITED        = { "MountSpecial", "Fly", "Stand" },
        TRIUMPHANT     = { "Fly", "MountSpecial", "Stand" },
        CELEBRATING    = { "MountSpecial", "Fly", "Stand" },
        TALKING        = { "Bow", "Stand" },
        TALKING_URGENT = { "Work", "Bow", "Stand" },
        COMBAT_READY   = { "ReadyUnarmed", "CombatWound", "Stand" },
        SPELLCASTING   = { "Work", "Stand" },
        SWIMMING       = { "SwimIdle", "Swim", "Stand" },
        SWIMMING_MOVE  = { "Swim", "SwimIdle", "Run", "Stand" },
        FLYING         = { "Fly", "FlyRun", "Hover", "Stand" },
        FALLING        = { "Fly", "Stand" },
        MOUNTED        = { "Run", "Walk", "Stand" },
        LOOTING        = { "Loot", "LootHold", "Stand" },
        CRAFTING       = { "Work", "Loot", "Stand" },
        FISHING        = { "SitGround", "Stand" },
        INTERACTING    = { "Bow", "Work", "Stand" },
        HEARTHING      = { "MountSpecial", "Fly", "Stand" },
        GREETING       = { "Bow", "Stand" },
        LAUGHING       = { "MountSpecial", "Stand" },
        EATING         = { "SitGround", "Stand" },
        BORED          = { "SitGround", "Stand" },
        RELAXED        = { "Hover", "SitGround", "Stand" },
        RUNNING        = { "Run", "Stand" },
        WALKING        = { "Walk", "Stand" },
        POINTING       = { "Bow", "Stand" },
        WORKING        = { "Work", "Loot", "Stand" },
        APPROVING      = { "Bow", "Stand" },
        MONEY          = { "MountSpecial", "Fly", "Stand" },
    },

    -- AQUATIC archetype (Murgle)
    aquatic = {
        IDLE           = { "Stand" },
        IDLE_SEATED    = { "Stand" },
        FIDGET         = { "Dance", "SpellCast", "Cower", "Stand" },
        SLEEP          = { "Sleep", "SitGround", "Stand" },
        DYING          = { "Death", "CombatWound", "Stand" },
        MOURNING       = { "Cower", "Cry", "CombatWound", "Stand" },
        DISTRESSED     = { "CombatWound", "Stun", "CombatCritical", "Cower", "Stand" },
        EXCITED        = { "Dance", "SpellCast", "Stand" },
        TRIUMPHANT     = { "BattleRoar", "Dance", "SpellCast", "Stand" },
        CELEBRATING    = { "Dance", "Cheer", "SpellCast", "Stand" },
        TALKING        = { "Talk", "Stand" },
        TALKING_URGENT = { "SpellCast", "AttackUnarmed", "Stand" },
        COMBAT_READY   = { "AttackUnarmed", "Attack1H", "CombatWound", "Stand" },
        SPELLCASTING   = { "SpellCast", "Stand" },
        SWIMMING       = { "SwimIdle", "Swim", "Stand" },
        SWIMMING_MOVE  = { "Swim", "SwimIdle", "Run", "Stand" },
        FLYING         = { "SwimIdle", "Swim", "Stand" },
        FALLING        = { "SwimIdle", "Stand" },
        MOUNTED        = { "Mount", "Run", "Walk", "Stand" },
        LOOTING        = { "SpellCast", "Work", "Stand" },
        CRAFTING       = { "Work", "SpellCast", "Stand" },
        FISHING        = { "SwimIdle", "Stand" },
        INTERACTING    = { "Talk", "Work", "SpellCast", "Stand" },
        HEARTHING      = { "SpellCast", "Dance", "Stand" },
        GREETING       = { "Wave", "Dance", "Stand" },
        LAUGHING       = { "Laugh", "Dance", "Stand" },
        EATING         = { "Eat", "Stand" },
        BORED          = { "Sleep", "SitGround", "Stand" },
        RELAXED        = { "SwimIdle", "Stand" },
        RUNNING        = { "Run", "Stand" },
        WALKING        = { "Walk", "Stand" },
        POINTING       = { "Point", "SpellCast", "Stand" },
        WORKING        = { "Work", "SpellCast", "Stand" },
        APPROVING      = { "Applaud", "Bow", "Dance", "Stand" },
        MONEY          = { "Flex", "Dance", "SpellCast", "Stand" },
    },
}

-- ============================================================================
-- COMPANION → ARCHETYPE MAP
-- ============================================================================

VC_AnimDB.companionArchetype = {
    vamoose = "humanoid",
    gazlowe = "humanoid",
    dash    = "humanoid",
    torque  = "humanoid",
    grimble = "humanoid",
    scurry  = "critter",
    patches = "bird",
    breezy  = "serpent",
    vexia   = "demon", -- probe 2026-06-12: sayaad rig is NOT humanoid (15 anims on every candidate model); demon chains are authored for it
    ember   = "phoenix",
    murgle  = "aquatic",
}

-- ============================================================================
-- EVENT TYPE → INTENT MAPPING (shared across all archetypes)
-- ============================================================================

VC_AnimDB.eventIntents = {
    achieve        = "CELEBRATING",
    boss           = "TRIUMPHANT",
    levelup        = "TRIUMPHANT",
    mythicplus     = "CELEBRATING",
    housing        = "CELEBRATING",
    home           = "GREETING",
    death          = "DISTRESSED",
    login          = "GREETING",
    friendonline   = "GREETING",
    group          = "GREETING",
    quest          = "CELEBRATING",
    farming        = "WORKING",
    gold           = "MONEY",
    rep            = "APPROVING",
    reprank        = "CELEBRATING",
    zone           = "POINTING",
    ambient        = "TALKING",
    crafting       = "WORKING",
    craftingorder  = "WORKING",
    combatend      = "CELEBRATING",
    resurrection   = "EXCITED",
    fishing        = "TALKING",
    transmog       = "EXCITED",
    appearance     = "EXCITED",
    petbattle      = "TRIUMPHANT",
    petsummon      = "EXCITED",
    scenario       = "CELEBRATING",
    mission        = "APPROVING",
    eating         = "EATING",
    drinking       = "EATING",      -- reuse eating intent for drinking
    hearthing      = "HEARTHING",
    flightpath     = "RELAXED",
    restzone       = "RELAXED",
    rarespawn      = "EXCITED",
    idle           = "BORED",
    _default       = "TALKING",
}

-- ============================================================================
-- QUALITY UPGRADES — epic/legendary quotes escalate the reaction
-- ============================================================================

VC_AnimDB.qualityUpgrades = {
    epic      = "EXCITED",
    legendary = "TRIUMPHANT",
}

-- ============================================================================
-- PER-ARCHETYPE CAMERA OVERRIDES
-- Applied per-intent in the portrait animation state machine.
