-- ============================================================================
-- 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", "Rude", "Applaud", "Work", "Stand" },
        SLEEP          = { "Sleep", "SitGround", "Stand" },
        DYING          = { "Death", "Knockdown", "Stand" },
        MOURNING       = { "Cry", "Kneel", "Beg", "Stand" },
        DISTRESSED     = { "Cower", "StandWound", "CombatWound", "Stand" },
        EXCITED        = { "Exclamation", "Cheer", "Stand" },
        TRIUMPHANT     = { "BattleRoar", "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", "CombatWound", "Stand" },
        SPELLCASTING   = { "SpellCastOmni", "ReadySpellOmni", "Stand" },
        SWIMMING       = { "SwimIdle", "Swim", "Stand" },
        FLYING         = { "Hover", "Fly", "Stand" },
        FALLING        = { "JumpStart", "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" },
        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", "CombatWound", "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" },
        FLYING         = { "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" },
        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          = { "Stand" },
        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" },
        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" },
        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" },
        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" },
        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", "SpellCastOmni", "Stand" },
        SLEEP          = { "Stand" },
        DYING          = { "Death", "CombatCritical", "Stand" },
        MOURNING       = { "CombatWound", "Stand" },
        DISTRESSED     = { "CombatWound", "CombatCritical", "Stand" },
        EXCITED        = { "BattleRoar", "SpellCastOmni", "Stand" },
        TRIUMPHANT     = { "BattleRoar", "SpellCastOmni", "Stand" },
        CELEBRATING    = { "BattleRoar", "SpellCastOmni", "Stand" },
        TALKING        = { "Stand" },
        TALKING_URGENT = { "SpellCastOmni", "BattleRoar", "Stand" },
        COMBAT_READY   = { "ReadyUnarmed", "CombatCritical", "Stand" },
        SPELLCASTING   = { "SpellCastOmni", "Stand" },
        SWIMMING       = { "SwimIdle", "Swim", "Stand" },
        FLYING         = { "Stand" },
        FALLING        = { "Stand" },
        MOUNTED        = { "Run", "Walk", "Stand" },
        LOOTING        = { "Stand" },
        CRAFTING       = { "SpellCastOmni", "Stand" },
        FISHING        = { "Stand" },
        INTERACTING    = { "Stand" },
        HEARTHING      = { "SpellCastOmni", "Stand" },
        GREETING       = { "SpellCastOmni", "Stand" },
        LAUGHING       = { "SpellCastOmni", "Stand" },
        EATING         = { "Stand" },
        RUNNING        = { "Run", "Stand" },
        WALKING        = { "Walk", "Stand" },
        POINTING       = { "SpellCastOmni", "Stand" },
        WORKING        = { "SpellCastOmni", "Stand" },
        APPROVING      = { "Stand" },
        MONEY          = { "BattleRoar", "SpellCastOmni", "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" },
        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" },
        RUNNING        = { "Run", "Stand" },
        WALKING        = { "Walk", "Stand" },
        POINTING       = { "Bow", "Stand" },
        WORKING        = { "Work", "Loot", "Stand" },
        APPROVING      = { "Bow", "Stand" },
        MONEY          = { "MountSpecial", "Fly", "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",
    ember   = "phoenix",
}

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

VC_AnimDB.eventIntents = {
    achieve        = "CELEBRATING",
    boss           = "TRIUMPHANT",
    levelup        = "TRIUMPHANT",
    mythicplus     = "CELEBRATING",
    housing        = "CELEBRATING",
    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",
    scenario       = "CELEBRATING",
    mission        = "APPROVING",
    _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.
