ZoriaRPG

[2.50.x] KnockbackSolidity()

Feb 15th, 2018
107
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // A function to prevent Link from phasing through solid
  2. // combos, 'solid' ffc, and through water, if knocked back.
  3. // Prevention of hookshot and ladder spots is here, but
  4. // disabled, as this *should* be handled by the ZC engine
  5. // internally.
  6.  
  7. //2.50.x Version
  8.  
  9. const int CF_NO_KNOCKBACK = 101; //Generic flag to prevent knockback on a square.
  10.  
  11. void KnockbackSolidity
  12. {
  13.      int x, int y;
  14.      if ( Link->HitDir > -1 )
  15.      {
  16.           if (Link->HitDir == DIR_LEFT )
  17.           {
  18.                x = Link->X-1; y = Link->Y+8;
  19.           }
  20.           else if (Link->HitDir == DIR_RIGHT )
  21.           {
  22.                x = Link->X+17; y = Link->Y+8;
  23.           }
  24.           else if (Link->HitDir == DIR_UP )
  25.           {
  26.                x = Link->X+8; y = Link->Y+7; break;
  27.           }
  28.           else if (Link->HitDir == DIR_DOWN )
  29.           {
  30.                     x = Link->X-1; y = Link->Y+8;
  31.           }
  32.           else
  33.           {
  34.                return; //invalid direction.
  35.           }
  36.           if ( Screen->isSolid(x,y) )
  37.           {
  38.                Link->HitDir = -1;
  39.           }
  40.           if ( IsSolidFFC(x,y) )
  41.           {
  42.                Link->HitDir = -1;
  43.           }
  44.           if ( Screen->ComboF[ComboAt(x,y)] == CF_NO_KNOCKBACK )
  45.           {
  46.                Link->HitDir = -1;
  47.           }
  48.           if ( Screen->ComboI[ComboAt(x,y)] == CF_NO_KNOCKBACK )
  49.           {
  50.                Link->HitDir = -1;
  51.           }
  52.           if ( Link->Action == LA_GOTHURTLAND )
  53.           {
  54.                if ( Screen->ComboT[ComboAt(x,y)] == CT_WATER )
  55.                {
  56.                     Link->HitDir = -1;
  57.                }    
  58.                /*
  59.                if ( Screen->ComboT[ComboAt(x,y)] == CT_LADDER  )
  60.                {
  61.                     Link->HitDir = -1;
  62.                }      
  63.                if ( Screen->ComboT[ComboAt(x,y)] == CT_LADDER_HOOKSHOT  )
  64.                {
  65.                     Link->HitDir = -1;
  66.                }    
  67.                if ( Screen->ComboF[ComboAt(x,y)] == CF_LADDER  )
  68.                {
  69.                     Link->HitDir = -1;
  70.                }    
  71.                if ( Screen->ComboF[ComboAt(x,y)] == CF_LADDER_HOOKSHOT  )
  72.                {
  73.                     Link->HitDir = -1;
  74.                }    
  75.           */
  76.           }
  77.           else //Link is swimming
  78.           {
  79.           if ( Screen->ComboT[ComboAt(x,y)] != CT_WATER )
  80.                {
  81.                     Link->HitDir = -1;
  82.                }
  83.           }
  84.      }
  85. }
  86.  
  87. // Utility function to check for ffc solidity at an arbitrary pixel.
  88. // There *must* be a faster way to do this...
  89. bool IsSolidFFC(int x, int y)
  90. {
  91.      ffc f; int q = 1;
  92.      for ( ; q < 33; ++q )
  93.      {
  94.           f = Screen->LoadFFC(q);
  95.           if ( f->Flags&FFCF_SOLID )
  96.           {
  97.                if ( RectCollision(f->X, f->Y, f->X+f->EffectWidth, f->Y+f->EffectHeight, x, y, x, y) )
  98.                {
  99.                     return true;
  100.                }
  101.           }
  102.           return false;
  103.      }
  104. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×