Script Function: Q5J8

From Ultima Online: The Second Age
Jump to: navigation, search
 function void Q5J8(int north, int east, int south, int west)
 {
   loc Q5C0 = getLocation(this);
   loc Q5FZ;
   if (hasObjVar(this, "LOCATION"))
   {
     Q5FZ = getObjVar(this, "LOCATION");
   }
   else
   {
     Q5FZ = Q5C0;
   }
   int Q5G3 = getX(Q5FZ);
   int Q5G4 = getY(Q5FZ);
   int Q5CE = getX(Q5C0);
   int Q5CF = getY(Q5C0);
   int Q4HC = Q5G3 - Q5CE;
   int Q4HD = Q5G4 - Q5CF;
   int Q44V;
   int Q44W;
   int Q5BG = 0x00 - 0x01;
   if (Q4HC < 0x00)
   {
     Q44V = Q4HC * Q5BG;
   }
   else
   {
     Q44V = Q4HC;
   }
   if (Q4HD < 0x00)
   {
     Q44W = Q4HD * Q5BG;
   }
   else
   {
     Q44W = Q4HD;
   }
   if (Q44V == Q44W)
   {
     if ((Q44V == 0x00) && (Q44W == 0x00))
     {
       return ();
     }
     int Q5L6 = random(0x00, 0x01);
     if (Q5L6)
     {
       if (Q4HC > 0x00)
       {
         Q5XR(this, west);
       }
       else
       {
         Q5XR(this, east);
       }
     }
     else
     {
       if (Q4HD > 0x00)
       {
         Q5XR(this, north);
       }
       else
       {
         Q5XR(this, south);
       }
     }
   }
   else
   {
     if (Q44V > Q44W)
     {
       if (Q4HC > 0x00)
       {
         Q5XR(this, west);
       }
       else
       {
         Q5XR(this, east);
       }
     }
     else
     {
       if (Q4HD > 0x00)
       {
         Q5XR(this, north);
       }
       else
       {
         Q5XR(this, south);
       }
     }
   }
   loc location = getLocation(this);
   setObjVar(this, "LOCATION", location);
   return ();
 }