#include "libforest/gbi_extensions.h"
#include "PR/gbi.h"
#include "evw_anime.h"
#include "c_keyframe.h"
#include "ac_npc.h"
#include "ef_effect_control.h"

u8 cKF_ckcb_r_npc_1_sitdown_d1_tbl[] = {
    63, 7, 0, 7, 7, 7, 0, 7, 7, 7, 0, 7, 7, 7, 0, 7, 7, 0, 7, 7, 7, 7, 0, 7, 0, 0
};

s16 cKF_kn_npc_1_sitdown_d1_tbl[] = { 6,  15, 7,  5,  2,  2, 8, 8, 6,  9,  11, 12, 2,  11, 2,  2,  2, 2, 13,
                                      12, 13, 2,  15, 2,  2, 2, 2, 2,  13, 9,  3,  13, 9,  12, 14, 6, 6, 9,
                                      8,  2,  13, 2,  10, 8, 9, 2, 16, 2,  2,  2,  2,  7,  12, 5,  3, 3, 3 };

s16 cKF_c_npc_1_sitdown_d1_tbl[] = { 0, 0, 1800, 0, 0,    1800, 0, 900, 0, 0, 0, -900,
                                     0, 0, 900,  0, -900, 0,    0, 0,   0, 0, 0, -900 };

s16 cKF_ds_npc_1_sitdown_d1_tbl[] = {
    1,  3960, 0,     19, 1980, -4017, 38, 765,  0,     39, 675,  -4357, 55, 0,     0,     60, 0,     0,
    1,  1000, 0,     5,  1050, 0,     9,  1000, 0,     13, 1050, 0,     17, 1000,  0,     21, 1050,  0,
    25, 1000, 0,     29, 1050, 0,     34, 950,  -1157, 38, 800,  0,     40, 1200,  13385, 46, 2500,  1748,
    50, 2500, -1710, 53, 2300, 0,     60, 2400, 0,     1,  900,  0,     19, 1665,  1741,  31, 1890,  0,
    38, 1890, 0,     39, 1755, -7318, 55, 0,    0,     60, 0,    0,     1,  -218,  0,     38, -1618, 0,
    45, -690, 7491,  51, 0,    0,     60, 0,    0,     1,  0,    0,     60, 0,     0,     1,  900,   0,
    60, 900,  0,     1,  0,    0,     9,  0,    888,   13, 80,   0,     21, -80,   0,     25, 0,     733,
    31, 50,   0,     38, 0,    0,     60, 0,    0,     1,  0,    0,     31, 0,     0,     38, -240,  0,
    41, -180, 1442,  45, 200,  2890,  49, 350,  0,     56, 160,  -1347, 60, 80,    0,     1,  0,     0,
    31, 0,    0,     38, 60,   869,   44, 380,  0,     51, 0,    0,     60, 0,     0,     1,  -175,  0,
    13, -50,  0,     21, -150, 0,     25, -103, 618,   31, -175, 0,     36, 0,     1406,  38, 100,   0,
    40, 4,    -3094, 60, -750, 0,     1,  -100, 0,     5,  -300, 0,     12, 150,   0,     20, -300,  0,
    28, 0,    0,     32, -100, -1579, 38, -350, 0,     40, 0,    0,     43, -50,   -772,  49, -300,  -1273,
    60, -500, 0,     1,  25,   0,     9,  50,   -557,  13, 0,    0,     21, 150,   0,     25, 80,    -538,
    36, 25,   0,     38, -30,  0,     40, 0,    986,   45, 450,  0,     49, 275,   -1098, 53, 200,   0,
    60, 300,  0,     1,  0,    0,     60, 0,    0,     1,  200,  0,     9,  0,     0,     16, 500,   0,
    24, 0,    0,     36, 600,  3212,  38, 700,  0,     40, 0,    0,     45, 200,   0,     51, 145,   0,
    57, 400,  0,     60, 350,  0,     1,  0,    0,     60, 0,    0,     1,  0,     0,     60, 0,     0,
    1,  -100, 0,     60, -100, 0,     1,  0,    0,     60, 0,    0,     1,  175,   0,     5,  55,    0,
    13, 150,  0,     20, 5,    0,     25, 5,    0,     31, 175,  0,     34, 138,   0,     37, 441,   6599,
    38, 670,  0,     39, 560,  -3513, 45, 250,  0,     50, 605,  1368,  60, 750,   0,     1,  -100,  0,
    5,  -10,  0,     12, -300, 0,     20, 200,  0,     28, -300, 0,     31, -200,  0,     34, -350,  -3142,
    38, -700, 0,     40, -300, 3644,  44, -150, 0,     49, -300, -1263, 60, -500,  0,     1,  -25,   0,
    5,  0,    0,     13, -100, 0,     19, -200, -1266, 21, -250, 0,     34, -75,   0,     37, -365,  -6735,
    38, -606, 0,     39, -460, 5208,  44, 50,   0,     50, -150, -2196, 55, -300,  0,     60, -300,  0,
    1,  0,    0,     60, 0,    0,     1,  200,  0,     4,  250,  998,   9,  500,   0,     16, 0,     0,
    19, 0,    0,     24, 500,  0,     31, 100,  0,     34, 200,  2008,  38, 850,   0,     39, 705,   -8983,
    40, 100,  0,     45, 250,  0,     51, 190,  0,     57, 400,  0,     60, 350,   0,     1,  0,     0,
    60, 0,    0,     1,  0,    0,     60, 0,    0,     1,  -100, 0,     60, -100,  0,     1,  0,     0,
    60, 0,    0,     1,  0,    0,     60, 0,    0,     1,  60,   0,     5,  -160,  0,     10, 0,     0,
    14, -160, 0,     18, 0,    0,     22, -160, 0,     26, 0,    0,     31, -250,  0,     38, 245,   0,
    43, 75,   -2773, 47, -500, -1505, 54, -450, 963,   60, -250, 0,     1,  0,     0,     11, 25,    246,
    21, 150,  0,     29, -15,  -658,  35, -100, -671,  43, -350, 0,     47, -225,  2281,  51, 100,   1003,
    60, 0,    0,     1,  0,    0,     9,  0,    0,     60, 0,    0,     1,  82,    0,     5,  -50,   -1897,
    7,  -150, 0,     12, 150,  0,     16, -150, 0,     20, 150,  0,     25, -150,  0,     30, 150,   0,
    35, -350, 0,     42, 450,  0,     47, 300,  -2271, 51, -250, -780,  60, -100,  0,     1,  0,     0,
    11, 100,  603,   25, 350,  0,     33, -50,  -736,  39, -180, -761,  46, -500,  0,     50, -345,  3230,
    53, 200,  970,   60, 0,    0,     1,  0,    0,     9,  0,    -994,  13, -80,   0,     21, 80,    0,
    25, 0,    -738,  29, -80,  0,     31, -50,  675,   38, 150,  908,   45, 250,   0,     51, 0,     0,
    57, 0,    0,     60, 0,    0,     1,  2,    0,     5,  20,   0,     9,  6,     0,     12, 30,    0,
    17, 6,    0,     20, 30,   0,     25, 5,    0,     28, 30,   0,     31, 2,     -78,   37, 200,   0,
    44, -80,  -2101, 49, -400, -312,  54, -300, 1641,  60, -100, 0,     1,  0,     0,     31, 0,     0,
    45, -350, 0,     48, -205, 3036,  51, 20,   216,   60, 0,    0,     1,  0,     0,     36, 0,     0,
    41, -100, 0,     46, 300,  1333,  50, 348,  -553,  60, 0,    0,     1,  58,    0,     5,  200,   0,
    12, -115, 0,     20, 230,  0,     28, -120, 0,     36, 200,  2827,  42, 750,   0,     48, 275,   -1789,
    60, 50,   0,     1,  -414, 0,     28, -400, 775,   36, -150, 0,     44, -1005, 0,     46, -800,  5746,
    50, -300, 0,     55, -650, 0,     60, -650, 0,     1,  0,    0,     60, 0,     0,     1,  -57,   0,
    6,  0,    0,     10, 0,    0,     14, -250, 0,     20, 0,    0,     25, 0,     0,     29, -250,  -2908,
    38, -800, 0,     45, 0,    0,     48, -100, -1963, 52, -250, 0,     55, -100,  0,     60, -250,  0,
    1,  0,    0,     60, 0,    0,     1,  0,    0,     31, 0,    0,     35, 100,   3532,  38, 670,   0,
    39, 510,  -7081, 44, -650, -6298, 45, -800, 0,     49, -250, 2888,  55, 0,     0,     60, 0,     0,
    1,  58,   0,     5,  -120, 0,     12, 230,  0,     20, -115, 0,     27, 230,   0,     31, 58,    -2583,
    38, -685, 0,     60, 50,   0,     1,  414,  0,     31, 390,  -770,  35, 180,   -2778, 39, -590,  0,
    40, -200, 7379,  46, 450,  0,     50, 250,  0,     56, 650,  0,     60, 650,   0,     1,  0,     0,
    60, 0,    0,     1,  -57,  0,     6,  -250, 0,     12, 0,    0,     18, 0,     0,     22, -250,  0,
    28, 0,    0,     31, -100, -3111, 35, -650, 0,     38, -300, 0,     39, -300,  0,     41, -680,  0,
    45, -430, 4361,  47, -250, 0,     52, -400, 0,     55, -125, 0,     60, -250,  0,     1,  0,     0,
    60, 0,    0,     1,  0,    0,     60, 0,    0,     1,  0,    0,     60, 0,     0,     1,  0,     0,
    60, 0,    0,     1,  0,    0,     9,  0,    0,     25, -200, 0,     38, 150,   937,   45, 250,   0,
    51, 0,    0,     60, 0,    0,     1,  0,    0,     5,  15,   0,     10, -20,   0,     14, 20,    0,
    18, -20,  0,     22, 20,   0,     26, -20,  0,     35, 45,   0,     40, -30,   -689,  45, -75,   0,
    57, 20,   0,     60, 0,    0,     1,  0,    0,     31, 0,    0,     38, 100,   0,     46, 0,     -296,
    60, 0,    0,     1,  0,    0,     9,  0,    0,     60, 0,    0,     1,  0,     0,     9,  0,     0,
    60, 0,    0,     1,  0,    0,     9,  0,    0,     60, 0,    0
};

static int lfoot_se_chk_pat[] = { 9, 25 };

static aNPC_se_data_c lfoot_se_dt[] = { { ARRAY_COUNT(lfoot_se_chk_pat), lfoot_se_chk_pat } };

static int rfoot_se_chk_pat[] = { 17, 34 };

static aNPC_se_data_c rfoot_se_dt[] = { { ARRAY_COUNT(rfoot_se_chk_pat), rfoot_se_chk_pat } };

int jump_se_chk_pat[] = { 39 };

int sit_se_chk_pat[] = { 53 };

static aNPC_other_se_data_c other_se_dt[] = { { { ARRAY_COUNT(jump_se_chk_pat), jump_se_chk_pat }, 1044 },
                                              { { ARRAY_COUNT(sit_se_chk_pat), sit_se_chk_pat }, 1048 } };

static aNPC_se_data_table_c se_dt_tbl[] = { { lfoot_se_dt, rfoot_se_dt, 2, other_se_dt } };

aNPC_Animation_c cKF_ba_r_npc_1_sitdown_d1 = {
    { cKF_ckcb_r_npc_1_sitdown_d1_tbl, cKF_ds_npc_1_sitdown_d1_tbl, cKF_kn_npc_1_sitdown_d1_tbl,
      cKF_c_npc_1_sitdown_d1_tbl, -1, 60 },
    1.0f,
    60.0f,
    cKF_FRAMECONTROL_STOP,
    0.0f,
    NULL,
    aNPC_EYE_TEX0,
    0,
    NULL,
    aNPC_MOUTH_TEX1,
    0,
    -1,
    -1,
    NULL,
    se_dt_tbl,
};
