// Slash flags.
//const int SF_CAN = 1;
//const int SF_ITEM = 2;
//const int SF_NEXT = 4;
//const int SF_CONTINUOUS = 8;
//const int SF_BUSH = 16;
//const int SF_FLOWER = 32;
//const int SF_GRASS = 64;

// Id of the bush animation to use.
//const int SLASH_BUSH_ANIM_ID = -1;

// Id of the grass animation to use.
//const int SLASH_GRASS_ANIM_ID = 88;

// Id of the flower animation to use.
//const int SLASH_FLOWER_ANIM_ID = -1;

// How many frames the animation will last.
//const int SLASH_ANIM_DURATION = 14;

// How many animations to create.
//const int SLASH_ANIM_COUNT = 6;

// Maximum amount the animation will be randomly offset.
//const int SLASH_ANIM_MAX_OFFSET = 8;

// Grass Drop Enemy
//const int DROP_GRASS = 177;

// Drop an item from a dropset.
// int dropset: One of the DROP_* constants.
//   Is actually the enemy id of an enemy to kill instantly.
// int x, int y or int loc: location of the drop.
//void DropItem(int dropset, int x, int y) {
//  npc n = CreateNPCAt(dropset, x, y);
//  n->HP = HP_SILENT;}

//void DropItem(int dropset, int loc) {
//  DropItem(dropset, ComboX(loc), ComboY(loc));}

int GetComboSlashType(int combo) {
  if (combo == CT_BUSH) {
    return SF_CAN | SF_BUSH;}
  else if (combo == CT_BUSHC) {
    return SF_CAN | SF_ITEM | SF_CONTINUOUS | SF_BUSH;}
  else if (combo == CT_BUSHNEXT) {
    return SF_CAN | SF_ITEM | SF_NEXT | SF_BUSH;}
  else if (combo == CT_BUSHNEXTC) {
    return SF_CAN | SF_ITEM | SF_NEXT | SF_CONTINUOUS | SF_BUSH;}
  else if (combo == CT_FLOWERS) {
    return SF_CAN | SF_ITEM | SF_FLOWER;}
  else if (combo == CT_FLOWERSC) {
    return SF_CAN | SF_ITEM | SF_CONTINUOUS | SF_FLOWER;}
  else if (combo == CT_SLASH) {
    return SF_CAN;}
  else if (combo == CT_SLASHC) {
    return SF_CAN | SF_CONTINUOUS;}
  else if (combo == CT_SLASHITEM) {
    return SF_CAN | SF_ITEM;}
  else if (combo == CT_SLASHITEMC) {
    return SF_CAN | SF_ITEM | SF_CONTINUOUS;}
  else if (combo == CT_SLASHNEXT) {
    return SF_CAN | SF_NEXT;}
  else if (combo == CT_SLASHNEXTC) {
    return SF_CAN | SF_NEXT | SF_CONTINUOUS;}
  else if (combo == CT_SLASHNEXTITEM) {
    return SF_CAN | SF_ITEM | SF_NEXT;}
  else if (combo == CT_SLASHNEXTITEMC) {
    return SF_CAN | SF_ITEM | SF_NEXT | SF_CONTINUOUS;}
  else if (combo == CT_TALLGRASS) {
    return SF_CAN | SF_ITEM | SF_GRASS;}
  else if (combo == CT_TALLGRASSC) {
    return SF_CAN | SF_ITEM | SF_CONTINUOUS | SF_GRASS;}
  else if (combo == CT_TALLGRASSNEXT) {
    return SF_CAN | SF_ITEM | SF_NEXT | SF_GRASS;}
  else {
    return 0;}}

// Slash a slashable combo.
// Dosen't support continuous.
void SlashComboII(int loc) {
  int combo = Screen->ComboT[loc];
  int info = GetComboSlashInfo(combo);
  if (info & SF_CAN) {
    // Change combo.
    if (info & SF_NEXT) {
      Screen->ComboD[loc]++;}
    else {
      Screen->ComboD[loc] = Screen->UnderCombo;}
    // Drop item.
    if (info & SF_ITEM) {
      DropItem(DROP_GRASS, loc);}
    // Animation
    if ((info & SF_BUSH) && SLASH_BUSH_ANIM_ID != -1) {
      RunSlashAnimations(loc, SLASH_BUSH_ANIM_ID);}
    if ((info & SF_GRASS) && SLASH_GRASS_ANIM_ID != -1) {
      RunSlashAnimations(loc, SLASH_GRASS_ANIM_ID);}
    if ((info & SF_FLOWER) && SLASH_FLOWER_ANIM_ID != -1) {
      RunSlashAnimations(loc, SLASH_FLOWER_ANIM_ID);}
    // Play sound.
    if (info & (SF_BUSH | SF_GRASS | SF_FLOWER)) {
      Game->PlaySound(SFX_GRASSCUT);}}}

void SlashComboII(int x, int y) {
  SlashComboII(ComboAt(x, y));}

// This slashes every slashable combo that
// weapon touches.
void SlashComboII(lweapon weapon) {
  int x = weapon->X;
  int y = weapon->Y;
  SlashComboII(x + 00, y + 00);
  SlashComboII(x + 15, y + 00);
  SlashComboII(x + 00, y + 15);
  SlashComboII(x + 15, y + 15);}

void RunSlashAnimationsII(int loc, int animId) {
  int x = ComboX(loc);
  int y = ComboY(loc);
  for (int i = 0; i < SLASH_ANIM_COUNT; i++) {
    eweapon anim = Screen->CreateEWeapon(EW_SCRIPT1);
    anim->UseSprite(animId);
    anim->Behind = false;
    anim->X = x + Rand(2 * SLASH_ANIM_MAX_OFFSET + 1) - SLASH_ANIM_MAX_OFFSET;
    anim->Y = y + Rand(2 * SLASH_ANIM_MAX_OFFSET + 1) - SLASH_ANIM_MAX_OFFSET;
    anim->CollDetection = false;
    anim->DeadState = SLASH_ANIM_DURATION;
    anim->Flip = Rand(4);}}
