Script Function: Q65A

From Ultima Online: The Second Age
Jump to: navigation, search
 function int Q65A(obj user, obj usedon)
 {
   int Q66P = getObjType(usedon);
   if (isAtHome(usedon))
   {
     systemMessage(user, "That book belongs to someone else.");
     if (hasObjVar(usedon, "inUse"))
     {
       removeObjVar(usedon, "inUse");
     }
     return (0x00);
   }
   int Q5KZ = getBookPages(usedon);
   if (Q5U9 == NULL())
   {
     if (Q5KZ == 0x00)
     {
       systemMessage(user, "Can't copy an empty book.");
       if (hasObjVar(usedon, "inUse"))
       {
         removeObjVar(usedon, "inUse");
       }
       return (0x00);
     }
     Q5U9 = usedon;
     systemMessage(user, "Select a book to copy this to.");
     targetObj(user, this);
   }
   else
   {
     if (Q66P == 0x0FEF)
     {
       systemMessage(user, "Cannot write into that book.");
       if (hasObjVar(Q5U9, "inUse"))
       {
         removeObjVar(Q5U9, "inUse");
       }
       if (hasObjVar(usedon, "inUse"))
       {
         removeObjVar(usedon, "inUse");
       }
       return (0x00);
     }
     if (Q66P == 0x0FF0)
     {
       systemMessage(user, "Cannot write into that book.");
       if (hasObjVar(Q5U9, "inUse"))
       {
         removeObjVar(Q5U9, "inUse");
       }
       if (hasObjVar(usedon, "inUse"))
       {
         removeObjVar(usedon, "inUse");
       }
       return (0x00);
     }
     if (usedon == Q5U9)
     {
       systemMessage(user, "Cannot copy a book onto itself.");
       if (hasObjVar(Q5U9, "inUse"))
       {
         removeObjVar(Q5U9, "inUse");
       }
       if (hasObjVar(usedon, "inUse"))
       {
         removeObjVar(usedon, "inUse");
       }
       return (0x00);
     }
     int Q4IA = 0x96;
     int Q4OU = 0x00;
     if (testAndLearnSkill(user, 0x17, Q4IA, 0x32) <= 0x00)
     {
       Q4OU = 0x01;
     }
     else
     {
       int Q5NB;
       Q5NB = copybook(usedon, Q5U9);
       sfx(getLocation(Q62D), 0x0249, 0x00);
       if (Q5NB == 0x00)
       {
         Q4OU = 0x01;
       }
     }
     if (hasObjVar(Q5U9, "inUse"))
     {
       removeObjVar(Q5U9, "inUse");
     }
     if (hasObjVar(usedon, "inUse"))
     {
       removeObjVar(usedon, "inUse");
     }
     Q5U9 = NULL();
     if (Q4OU)
     {
       systemMessage(user, "You fail to make a copy of the book.");
       return (0x00);
     }
     else
     {
       systemMessage(user, "You make a copy of the book.");
     }
   }
   return (0x01);
 }