Advertisement
ZoriaRPG

FIX std_functions.zh AdjacentCombos() 25-Nov-2016

Nov 24th, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | None | 0 0
  1. //Constants for AdjacentCombo()
  2.  
  3.     //const int CMB_UPLEFT    = 0;
  4.     //const int CMB_UP        = 1;
  5.     //const int CMB_UPRIGHT   = 2;
  6.     //const int CMB_RIGHT     = 3;
  7.     //const int CMB_DOWNRIGHT = 4;
  8.     //const int CMB_DOWN      = 5;
  9.     //const int CMB_DOWNLEFT  = 6;
  10.     //const int CMB_LEFT      = 7;
  11.     //const int CMB_LEFTUP    = 0; //Not 8, as those are dir + shield
  12.  
  13.     //Returns the Nth combo index of a combo based on a central point, and a direction.
  14.     //For example, combo 22 + COMBO_UPRIGHT returns '7',
  15.     //as combo 7 is to the upper-right of combo 22.
  16.     int AdjacentCombo(int cmb, int dir){
  17.         int combooffsets[13]={-0x11,-0x10,-0x0F,1,0x11,0x10,0x0F,-1,-0x10};
  18.         if ( cmb % 16 == 0 ) combooffsets[9] = 1;
  19.         if ( (cmb & 15) == 1 ) combooffsets[10] = 1;
  20.         if ( cmb < 0x10 ) combooffsets[11] = 1; //if it's the top row
  21.         if ( cmb > 0x9F ) combooffsets[12] = 1; //if it's on the bottom row
  22.         if ( combooffsets[9] && ( dir == CMB_LEFT || dir == CMB_UPLEFT || dir == CMB_DOWNLEFT || dir == CMB_LEFTUP ) ) return 0; //if the left columb
  23.         if ( combooffsets[10] && ( dir == CMB_RIGHT || dir == CMB_UPRIGHT || dir == CMB_DOWNRIGHT ) ) return 0; //if the right column
  24.         if ( combooffsets[11] && ( dir == CMB_UP || dir == CMB_UPRIGHT || dir == CMB_UPLEFT || dir == CMB_LEFTUP ) ) return 0; //if the top row
  25.         if ( combooffsets[12] && ( dir == CMB_DOWN || dir == CMB_DOWNRIGHT || dir == CMB_DOWNLEFT ) ) return 0; //if the bottom row
  26.         else if ( cmb >= 0 && cmb <= 176 ) return cmb + combooffsets[dir];
  27.         else return -1;
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement