Advertisement
ZoriaRPG

ZC Swim Code To Take to the Pub

Sep 22nd, 2017
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.27 KB | None | 0 0
  1.  //All problems related to exiting water are probably here. -Z
  2.     if(action==swimming)
  3.     {
  4.         if(!wf)
  5.         {
  6.             if(landswim>= (get_bit(quest_rules,qr_DROWN) && isSwimming() ? 1
  7.                            : (!diagonalMovement) ? 1 : 22))
  8.             {
  9.                 //Check for out of bounds for swimming
  10.                 bool changehop = true;
  11.                
  12.                 if(diagonalMovement)
  13.                 {
  14.                     if(wx<0||wy<0)
  15.                         changehop = false;
  16.                     else if(wx>248)
  17.                         changehop = false;
  18.                     else if(wx>240&&cnt==2)
  19.                         changehop = false;
  20.                     else if(wy>168)
  21.                         changehop = false;
  22.                 }
  23.                 //This may be where the hang-up for exiting water exists. -Z
  24.                 // hop out of the water
  25.                 if(changehop)
  26.                     ret.setHopClk(1);
  27.             }
  28.             else
  29.             {
  30.                 if(dir==d2 || shiftdir==d2)
  31.                 {
  32.                     //int vx=((int)x+4)&0xFFF8;
  33.                     //int vy=((int)y+4)&0xFFF8;
  34.                     if(d2==left)
  35.                     {
  36.                         if(!iswater(MAPCOMBO(x-1,y+(bigHitbox?6:11))) &&
  37.                            !iswater(MAPCOMBO(x-1,y+(bigHitbox?9:12))) &&
  38.                            !_walkflag(x-1,y+(bigHitbox?6:11),1) &&
  39.                            !_walkflag(x-1,y+(bigHitbox?9:12),1))
  40.                         {
  41.                             ret.setHopDir(d2);
  42.                             ret.setIlswim(true);
  43.                         }
  44.                         else ret.setIlswim(false);
  45.                     }
  46.                     else if(d2==right)
  47.                     {
  48.                         if(!iswater(MAPCOMBO(x+16,y+(bigHitbox?6:11))) &&
  49.                            !iswater(MAPCOMBO(x+16,y+(bigHitbox?9:12))) &&
  50.                            !_walkflag(x+16,y+(bigHitbox?6:11),1) &&
  51.                            !_walkflag(x+16,y+(bigHitbox?9:12),1))
  52.                         {
  53.                             ret.setHopDir(d2);
  54.                             ret.setIlswim(true);
  55.                         }
  56.                         else ret.setIlswim(false);
  57.                     }
  58.                     else if(d2==up)
  59.                     {
  60.                         if(!iswater(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1)) &&
  61.                            !iswater(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1)) &&
  62.                            !_walkflag(x+7,y+(bigHitbox?0:8)-1,1) &&
  63.                            !_walkflag(x+8,y+(bigHitbox?0:8)-1,1))
  64.                         {
  65.                             ret.setHopDir(d2);
  66.                             ret.setIlswim(true);
  67.                         }
  68.                         else ret.setIlswim(false);
  69.                     }
  70.                     else if(d2==down)
  71.                     {
  72.                         if(!iswater(MAPCOMBO(x+7,y+16)) &&
  73.                            !iswater(MAPCOMBO(x+8,y+16)) &&
  74.                            !_walkflag(x+7,y+16,1) &&
  75.                            !_walkflag(x+8,y+16,1))
  76.                         {
  77.                             ret.setHopDir(d2);
  78.                             ret.setIlswim(true);
  79.                         }
  80.                         else ret.setIlswim(false);
  81.                     }
  82.                 }
  83.                
  84.                 if(wx<0||wy<0);
  85.                 else if(wx>248);
  86.                 else if(wx>240&&cnt==2);
  87.                 else if(wy>168);
  88.                 else if(get_bit(quest_rules, qr_DROWN) && !ilswim);
  89.                 else if(iswater(MAPCOMBO(wx,wy)) && iswater(MAPCOMBO(wx,wy)))
  90.                 {
  91.                     ret.setUnwalkable(false);
  92.                     return ret;
  93.                 }
  94.                 else
  95.                 {
  96.                     ret.setUnwalkable(true);
  97.                     return ret;
  98.                 }
  99.             }
  100.         }
  101.         else
  102.         {
  103.             bool wtrx  = iswater(MAPCOMBO(wx,wy));
  104.             bool wtrx8 = iswater(MAPCOMBO(x+8,wy));
  105.            
  106.             if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
  107.             {
  108.                 ret.setUnwalkable(false);
  109.                 return ret;
  110.             }
  111.         }
  112.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement