Difference between revisions of "Script Function: Q4M7"

From Ultima Online: The Second Age
Jump to: navigation, search
(Created page with " <span style="color:#0000FF">function</span> <span style="color:#0000FF">int</span> Q4M7(<span style="color:#0000FF">obj</span> this, <span style="color:#0000FF">obj</span> s...")
 
 
Line 104: Line 104:
 
     [[Script_Function:_Q4J9|<span style="color:#2B91AF">Q4J9</span>]](this);
 
     [[Script_Function:_Q4J9|<span style="color:#2B91AF">Q4J9</span>]](this);
 
     <span style="color:#0000FF">return</span> (0x01);
 
     <span style="color:#0000FF">return</span> (0x01);
 +
  }
 +
 +
  <span style="color:#0000FF">function</span> <span style="color:#0000FF">int</span> Q4M7(<span style="color:#0000FF">obj</span> this, <span style="color:#0000FF">obj</span> speaker, <span style="color:#0000FF">string</span> arg)
 +
  {
 +
    <span style="color:#0000FF">if</span> (![[Engine Function:_isShopkeeper|<span style="color:#FF0000;font-weight:bold">isShopkeeper</span>]](this))
 +
    {
 +
      <span style="color:#0000FF">return</span> (0x01);
 +
    }
 +
    <span style="color:#0000FF">loc</span> Q4VS = [[Engine Function:_getLocation|<span style="color:#FF0000;font-weight:bold">getLocation</span>]](this);
 +
    <span style="color:#0000FF">loc</span> there = [[Engine Function:_getLocation|<span style="color:#FF0000;font-weight:bold">getLocation</span>]](speaker);
 +
    <span style="color:#0000FF">if</span> ([[Engine Function:_getDistanceInTiles|<span style="color:#FF0000;font-weight:bold">getDistanceInTiles</span>]](Q4VS, there) > 0x03)
 +
    {
 +
      <span style="color:#0000FF">return</span> (0x01);
 +
    }
 +
    <span style="color:#0000FF">list</span> Q619;
 +
    <span style="color:#0000FF">string</span> Q618;
 +
    <span style="color:#0000FF">string</span> Q51Y;
 +
    <span style="color:#0000FF">string</span> Q60W;
 +
    <span style="color:#0000FF">int</span> Q4LG;
 +
    <span style="color:#0000FF">int</span> i;
 +
    <span style="color:#0000FF">int</span> Q518;
 +
    <span style="color:#0000FF">int</span> Q4QI;
 +
    <span style="color:#0000FF">int</span> Q4QP;
 +
    Q4QI = 0x00;
 +
    Q4QP = 0x00;
 +
    [[Engine Function:_split|<span style="color:#FF0000;font-weight:bold">split</span>]](Q619, arg);
 +
    <span style="color:#0000FF">if</span> ([[Engine Function:_hasShopKeyword|<span style="color:#FF0000;font-weight:bold">hasShopKeyword</span>]](Q619))
 +
    {
 +
      Q4QI = 0x01;
 +
    }
 +
    <span style="color:#0000FF">if</span> ([[Engine Function:_isInList|<span style="color:#FF0000;font-weight:bold">isInList</span>]](Q619, <span style="color:#800000">"sell"</span>))
 +
    {
 +
      <span style="color:#0000FF">if</span> (0x01)
 +
      {
 +
        Q4QP = 0x01;
 +
      }
 +
    }
 +
    <span style="color:#0000FF">if</span> ((!Q4QI) && (!Q4QP))
 +
    {
 +
      <span style="color:#0000FF">return</span> (0x01);
 +
    }
 +
    <span style="color:#0000FF">if</span> (![[Engine Function:_getCompileFlag|<span style="color:#FF0000;font-weight:bold">getCompileFlag</span>]](0x01))
 +
    {
 +
      <span style="color:#0000FF">if</span> ([[Engine Function:_getNotoriety|<span style="color:#FF0000;font-weight:bold">getNotoriety</span>]](speaker) < (0x00 - 0x5A))
 +
      {
 +
        [[Engine Function:_bark|<span style="color:#FF0000;font-weight:bold">bark</span>]](this, <span style="color:#800000">"I shall not treat with scum like thee!"</span>);
 +
        <span style="color:#0000FF">return</span> (0x00);
 +
      }
 +
    }
 +
    <span style="color:#0000FF">else</span>
 +
    {
 +
      <span style="color:#0000FF">if</span> ([[Engine Function:_isMurderer|<span style="color:#FF0000;font-weight:bold">isMurderer</span>]](speaker))
 +
      {
 +
        [[Engine Function:_bark|<span style="color:#FF0000;font-weight:bold">bark</span>]](this, <span style="color:#800000">"I shall not treat with scum like thee!"</span>);
 +
        <span style="color:#0000FF">return</span> (0x00);
 +
      }
 +
      <span style="color:#0000FF">if</span> ([[Engine Function:_getKarmaLevel|<span style="color:#FF0000;font-weight:bold">getKarmaLevel</span>]](speaker) < (0x00 - 0x04))
 +
      {
 +
        [[Engine Function:_bark|<span style="color:#FF0000;font-weight:bold">bark</span>]](this, <span style="color:#800000">"I shall not treat with scum like thee!"</span>);
 +
        <span style="color:#0000FF">return</span> (0x00);
 +
      }
 +
    }
 +
    Q4QI = 0x00;
 +
    <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"myJobLocation"</span>))
 +
    {
 +
      <span style="color:#0000FF">loc</span> myJobLocation = [[Engine Function:_getObjVar|<span style="color:#FF0000;font-weight:bold">getObjVar</span>]](this, <span style="color:#800000">"myJobLocation"</span>);
 +
      <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"myHomeShop"</span>))
 +
      {
 +
        <span style="color:#0000FF">string</span> myHomeShop = [[Engine Function:_getObjVar|<span style="color:#FF0000;font-weight:bold">getObjVar</span>]](this, <span style="color:#800000">"myHomeShop"</span>);
 +
        [[Engine Function:_scoreToSpace|<span style="color:#FF0000;font-weight:bold">scoreToSpace</span>]](myHomeShop);
 +
        <span style="color:#0000FF">list</span> Q5GR;
 +
        [[Engine Function:_split|<span style="color:#FF0000;font-weight:bold">split</span>]](Q5GR, myHomeShop);
 +
        myHomeShop = Q5GR[0x00];
 +
        <span style="color:#0000FF">if</span> (0x00)
 +
        {
 +
          [[Engine Function:_bark|<span style="color:#FF0000;font-weight:bold">bark</span>]](this, myHomeShop);
 +
        }
 +
        <span style="color:#0000FF">string</span> Q4GC = <span style="color:#800000">""</span>;
 +
        <span style="color:#0000FF">list</span> Q4FM;
 +
        <span style="color:#0000FF">if</span> ([[Engine Function:_getSmallestArea|<span style="color:#FF0000;font-weight:bold">getSmallestArea</span>]](Q4GC, [[Engine Function:_getLocation|<span style="color:#FF0000;font-weight:bold">getLocation</span>]](this)))
 +
        {
 +
          [[Engine Function:_scoreToSpace|<span style="color:#FF0000;font-weight:bold">scoreToSpace</span>]](Q4GC);
 +
          [[Engine Function:_split|<span style="color:#FF0000;font-weight:bold">split</span>]](Q4FM, Q4GC);
 +
          Q4GC = Q4FM[0x00];
 +
          <span style="color:#0000FF">if</span> (0x00)
 +
          {
 +
            [[Engine Function:_bark|<span style="color:#FF0000;font-weight:bold">bark</span>]](this, Q4GC);
 +
          }
 +
        }
 +
        <span style="color:#0000FF">if</span> (Q4GC == myHomeShop)
 +
        {
 +
          Q4QI = 0x01;
 +
        }
 +
      }
 +
      <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"NoRegion"</span>))
 +
      {
 +
        Q4QI = 0x01;
 +
      }
 +
      <span style="color:#0000FF">if</span> (!Q4QI)
 +
      {
 +
        [[Engine Function:_bark|<span style="color:#FF0000;font-weight:bold">bark</span>]](this, <span style="color:#800000">"I am sorry, I do not have my wares here with me. Let us go back to my shop."</span>);
 +
        <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"myJobLocation"</span>))
 +
        {
 +
          <span style="color:#0000FF">loc</span> Q5SY = [[Engine Function:_getObjVar|<span style="color:#FF0000;font-weight:bold">getObjVar</span>]](this, <span style="color:#800000">"myJobLocation"</span>);
 +
          [[Engine Function:_walkTo|<span style="color:#FF0000;font-weight:bold">walkTo</span>]](this, Q5SY, 0x06);
 +
        }
 +
        <span style="color:#0000FF">return</span> (0x00);
 +
      }
 +
    }
 +
    <span style="color:#0000FF">else</span>
 +
    {
 +
      [[Engine Function:_bark|<span style="color:#FF0000;font-weight:bold">bark</span>]](this, <span style="color:#800000">"Alas, I have no shop! I cannot do business with thee."</span>);
 +
      [[Script_Function:_Q4J9|<span style="color:#2B91AF">Q4J9</span>]](this);
 +
      <span style="color:#0000FF">return</span> (0x00);
 +
    }
 +
    <span style="color:#0000FF">int</span> guildMember = 0xFF;
 +
    <span style="color:#0000FF">int</span> Q5SW = 0xFE;
 +
    <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"guildMember"</span>))
 +
    {
 +
      Q5SW = [[Engine Function:_getObjVar|<span style="color:#FF0000;font-weight:bold">getObjVar</span>]](this, <span style="color:#800000">"guildMember"</span>);
 +
    }
 +
    <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](speaker, <span style="color:#800000">"guildMember"</span>))
 +
    {
 +
      guildMember = [[Engine Function:_getObjVar|<span style="color:#FF0000;font-weight:bold">getObjVar</span>]](speaker, <span style="color:#800000">"guildMember"</span>);
 +
    }
 +
    <span style="color:#0000FF">if</span> (Q5SW == guildMember)
 +
    {
 +
      [[Engine Function:_bark|<span style="color:#FF0000;font-weight:bold">bark</span>]](this, <span style="color:#800000">"As thou'rt of my same guild, I shall discount my wares to thee."</span>);
 +
      [[Script_Function:_Q4J9|<span style="color:#2B91AF">Q4J9</span>]](this);
 +
    }
 +
    <span style="color:#0000FF">if</span> (Q4QP)
 +
    {
 +
      [[Engine Function:_shopKeeperOpenBuying|<span style="color:#FF0000;font-weight:bold">shopKeeperOpenBuying</span>]](this, speaker);
 +
    }
 +
    <span style="color:#0000FF">else</span>
 +
    {
 +
      [[Engine Function:_shopKeeperOpenBusiness|<span style="color:#FF0000;font-weight:bold">shopKeeperOpenBusiness</span>]](this, speaker);
 +
    }
 +
    [[Engine Function:_setObjVar|<span style="color:#FF0000;font-weight:bold">setObjVar</span>]](this, <span style="color:#800000">"wasAskedBuy"</span>, 0x01);
 +
    [[Script_Function:_Q4J9|<span style="color:#2B91AF">Q4J9</span>]](this);
 +
    <span style="color:#0000FF">return</span> (0x00);
 
   }
 
   }

Latest revision as of 15:39, 12 October 2018

 function int Q4M7(obj this, obj speaker, string arg)
 {
   if (!isShopkeeper(this))
   {
     return (0x01);
   }
   loc Q4VS = getLocation(this);
   loc there = getLocation(speaker);
   if (getDistanceInTiles(Q4VS, there) > 0x03)
   {
     return (0x01);
   }
   list Q51Z;
   list Q5N8;
   list Q619;
   string Q618;
   string Q51Y;
   string Q60W;
   int Q4LG;
   int i;
   int Q518;
   int Q4QI;
   Q4QI = 0x00;
   Q51Z = "buy", "trade", "commerce", "merchant", "shop", "purchase", "business", "open", "shopkeeper", "trader", "tradesman", "shopkeep";
   split(Q619, arg);
   for(i = 0x00; i < numInList(Q619); i++)
   {
     for(Q518 = 0x00; Q518 < numInList(Q51Z); Q518++)
     {
       Q51Y = Q51Z[Q518];
       Q618 = Q619[i];
       if (Q618 == Q51Y)
       {
         Q4QI == 0x01;
       }
     }
   }
   if (!Q4QI)
   {
     return (0x01);
   }
   Q4QI = 0x00;
   if (hasObjVar(this, "myJobLocation"))
   {
     loc myJobLocation = getObjVar(this, "myJobLocation");
     if (hasObjVar(this, "myHomeShop"))
     {
       string myHomeShop = getObjVar(this, "myHomeShop");
       scoreToSpace(myHomeShop);
       list Q5GR;
       split(Q5GR, myHomeShop);
       myHomeShop = Q5GR[0x00];
       if (0x00)
       {
         bark(this, myHomeShop);
       }
       string Q4GC = "";
       list Q4FM;
       if (getSmallestArea(Q4GC, getLocation(this)))
       {
         scoreToSpace(Q4GC);
         split(Q4FM, Q4GC);
         Q4GC = Q4FM[0x00];
         if (0x00)
         {
           bark(this, Q4GC);
         }
       }
       if (Q4GC == myHomeShop)
       {
         Q4QI = 0x01;
       }
     }
     if (!Q4QI)
     {
       bark(this, "I am sorry, I do not have my wares here with me. Mayhap if thou didst catch me in my shop.");
       Q4J9(this);
       return (0x00);
     }
   }
   else
   {
     bark(this, "Alas, I have no shop! I cannot do business with thee.");
     Q4J9(this);
     return (0x00);
   }
   int guildMember = 0xFF;
   int Q5SW = 0xFE;
   if (hasObjVar(this, "guildMember"))
   {
     Q5SW = getObjVar(this, "guildMember");
   }
   if (hasObjVar(speaker, "guildMember"))
   {
     guildMember = getObjVar(speaker, "guildMember");
   }
   if (Q5SW == guildMember)
   {
     bark(this, "As thou'rt of my same guild, I shall discount my wares to thee.");
     Q4J9(this);
   }
   shopKeeperOpenBusiness(this, speaker);
   setObjVar(this, "wasAskedBuy", 0x01);
   Q4J9(this);
   return (0x01);
 }
 function int Q4M7(obj this, obj speaker, string arg)
 {
   if (!isShopkeeper(this))
   {
     return (0x01);
   }
   loc Q4VS = getLocation(this);
   loc there = getLocation(speaker);
   if (getDistanceInTiles(Q4VS, there) > 0x03)
   {
     return (0x01);
   }
   list Q619;
   string Q618;
   string Q51Y;
   string Q60W;
   int Q4LG;
   int i;
   int Q518;
   int Q4QI;
   int Q4QP;
   Q4QI = 0x00;
   Q4QP = 0x00;
   split(Q619, arg);
   if (hasShopKeyword(Q619))
   {
     Q4QI = 0x01;
   }
   if (isInList(Q619, "sell"))
   {
     if (0x01)
     {
       Q4QP = 0x01;
     }
   }
   if ((!Q4QI) && (!Q4QP))
   {
     return (0x01);
   }
   if (!getCompileFlag(0x01))
   {
     if (getNotoriety(speaker) < (0x00 - 0x5A))
     {
       bark(this, "I shall not treat with scum like thee!");
       return (0x00);
     }
   }
   else
   {
     if (isMurderer(speaker))
     {
       bark(this, "I shall not treat with scum like thee!");
       return (0x00);
     }
     if (getKarmaLevel(speaker) < (0x00 - 0x04))
     {
       bark(this, "I shall not treat with scum like thee!");
       return (0x00);
     }
   }
   Q4QI = 0x00;
   if (hasObjVar(this, "myJobLocation"))
   {
     loc myJobLocation = getObjVar(this, "myJobLocation");
     if (hasObjVar(this, "myHomeShop"))
     {
       string myHomeShop = getObjVar(this, "myHomeShop");
       scoreToSpace(myHomeShop);
       list Q5GR;
       split(Q5GR, myHomeShop);
       myHomeShop = Q5GR[0x00];
       if (0x00)
       {
         bark(this, myHomeShop);
       }
       string Q4GC = "";
       list Q4FM;
       if (getSmallestArea(Q4GC, getLocation(this)))
       {
         scoreToSpace(Q4GC);
         split(Q4FM, Q4GC);
         Q4GC = Q4FM[0x00];
         if (0x00)
         {
           bark(this, Q4GC);
         }
       }
       if (Q4GC == myHomeShop)
       {
         Q4QI = 0x01;
       }
     }
     if (hasObjVar(this, "NoRegion"))
     {
       Q4QI = 0x01;
     }
     if (!Q4QI)
     {
       bark(this, "I am sorry, I do not have my wares here with me. Let us go back to my shop.");
       if (hasObjVar(this, "myJobLocation"))
       {
         loc Q5SY = getObjVar(this, "myJobLocation");
         walkTo(this, Q5SY, 0x06);
       }
       return (0x00);
     }
   }
   else
   {
     bark(this, "Alas, I have no shop! I cannot do business with thee.");
     Q4J9(this);
     return (0x00);
   }
   int guildMember = 0xFF;
   int Q5SW = 0xFE;
   if (hasObjVar(this, "guildMember"))
   {
     Q5SW = getObjVar(this, "guildMember");
   }
   if (hasObjVar(speaker, "guildMember"))
   {
     guildMember = getObjVar(speaker, "guildMember");
   }
   if (Q5SW == guildMember)
   {
     bark(this, "As thou'rt of my same guild, I shall discount my wares to thee.");
     Q4J9(this);
   }
   if (Q4QP)
   {
     shopKeeperOpenBuying(this, speaker);
   }
   else
   {
     shopKeeperOpenBusiness(this, speaker);
   }
   setObjVar(this, "wasAskedBuy", 0x01);
   Q4J9(this);
   return (0x00);
 }