Script Function: Q4J8

From Ultima Online: The Second Age
Jump to: navigation, search
 function int Q4J8(obj this, obj speaker, string arg)
 {
   loc Q4VS = getLocation(this);
   loc there = getLocation(speaker);
   int Q602 = getDirectionInternal(Q4VS, there);
   member int Q5M8 = Q602;
   list args;
   split(args, arg);
   int Q4QI = 0x00;
   int Q4KB = 0x01;
   if (isDead(speaker))
   {
     return (0x00);
   }
   if (!canSeeObj(this, speaker))
   {
     return (0x00);
   }
   if (getDistanceInTiles(getLocation(this), getLocation(speaker)) > 0x05)
   {
     return (0x00);
   }
   obj lastSpokeTo = NULL();
   if (hasObjVar(this, "lastSpokeTo"))
   {
     lastSpokeTo = getObjVar(this, "lastSpokeTo");
     if (lastSpokeTo == speaker)
     {
       Q4KB = 0x00;
       if (getDistanceInTiles(getLocation(this), getLocation(speaker)) < 0x06)
       {
         faceHere(this, getDirectionInternal(getLocation(this), getLocation(speaker)));
       }
     }
   }
   if (!isFacingPerson(speaker, this))
   {
     if (lastSpokeTo != NULL())
     {
       if (getDistanceInTiles(getLocation(this), getLocation(speaker)) < 0x04)
       {
         if (lastSpokeTo == speaker)
         {
           Q4QI = 0x01;
           Q4KB = 0x00;
         }
       }
     }
     if (getDistanceInTiles(getLocation(speaker), getLocation(this)) < 0x02)
     {
       Q4QI = 0x01;
     }
     if (!Q4CH(this, args))
     {
       Q4QI = 0x00;
     }
     if (Q4QI)
     {
       faceHere(this, getDirectionInternal(getLocation(this), getLocation(speaker)));
       if (Q4KB)
       {
         replyTo(this, speaker, "@InternalConvinit");
       }
       Q4J9(this);
       setObjVar(this, "lastSpokeTo", speaker);
       return (0x01);
     }
     return (0x00);
   }
   if (!isFacingPerson(this, speaker))
   {
     if (0x00)
     {
       bark(this, "We are not facing each other.");
     }
     string Q618;
     int i;
     Q4QI = 0x00;
     if (isInList(args, getName(this)))
     {
       Q4QI = 0x01;
       if (0x00)
       {
         debugMessage("Detected my name in a speech trigger.");
       }
     }
     if (getDistanceInTiles(getLocation(speaker), getLocation(this)) < 0x04)
     {
       if (Q4CH(this, args))
       {
         Q4QI = 0x01;
       }
     }
     if (lastSpokeTo != NULL())
     {
       if (lastSpokeTo == speaker)
       {
         Q4KB = 0x00;
         Q4QI = 0x01;
       }
     }
     if (!Q4QI)
     {
       return (0x00);
     }
     if (lastSpokeTo != NULL())
     {
       if (lastSpokeTo != speaker)
       {
         if (getDistanceInTiles(getLocation(this), getLocation(lastSpokeTo)) < 0x05)
         {
           int Q4ID = getDirectionInternal(getLocation(this), getLocation(lastSpokeTo));
           faceHere(this, Q4ID);
           string Q4OD = "Excuse me, " + getName(lastSpokeTo) + ", but " + getName(speaker) + " is calling me.";
           bark(this, Q4OD);
           Q4KB = 0x01;
         }
       }
     }
     if (0x00)
     {
       debugMessage("Calling the convinit keyword.");
     }
     faceHere(this, Q602);
     if (Q4KB)
     {
       replyTo(this, speaker, "@InternalConvinit");
     }
     int bow = 0x00;
     if (!getCompileFlag(0x01))
     {
       if (getNotoriety(speaker) > 0x5A)
       {
         bow = 0x01;
       }
     }
     else
     {
       if (getFameLevel(speaker) > 0x03)
       {
         bow = 0x01;
       }
     }
     if (bow)
     {
       if (getSex(this) == 0x00)
       {
         Q4M4(this, Q602);
       }
       else
       {
         Q4J3(this, Q602);
       }
     }
     setObjVar(this, "lastSpokeTo", speaker);
     Q4J9(this);
   }
   int Q68W = 0x01;
   if (hasObjVar(this, "myJobLocation"))
   {
     loc myJobLocation = getObjVar(this, "myJobLocation");
     if (getDistanceInTiles(getLocation(this), myJobLocation) > 0x10)
     {
       Q68W = 0x00;
     }
   }
   if (isGuard(this))
   {
     Q68W = 0x00;
   }
   Q68W = 0x00;
   if (isInList(args, "come"))
   {
     if (Q68W)
     {
       walkTo(this, getLocation(speaker), 0x05);
       callback(this, 0x2D, 0x0C);
     }
   }
   else
   {
     if (getDistanceInTiles(Q4VS, there) > 0x03)
     {
       if (Q68W)
       {
         walkTo(this, interpose(Q4VS, there), 0x05);
         if (0x00)
         {
           debugMessage("Walking closer to speaker.");
         }
       }
     }
   }
   return (0x01);
 }