Difference between revisions of "Script: Statfix"

From Ultima Online: The Second Age
Jump to: navigation, search
Line 4: Line 4:
 
  {
 
  {
 
   <span style="color:#0000FF">int</span> num = 0x00;
 
   <span style="color:#0000FF">int</span> num = 0x00;
   <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](Q68S, <span style="color:#800000">"[[fixStats|<span style="color:#2B91AF">fixStats</span>]]"</span>))
+
   <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](Q68S, <span style="color:#800000">"fixStats"</span>))
 
   {
 
   {
     num = [[Engine Function:_getObjVar|<span style="color:#FF0000;font-weight:bold">getObjVar</span>]](Q68S, <span style="color:#800000">"[[fixStats|<span style="color:#2B91AF">fixStats</span>]]"</span>);
+
     num = [[Engine Function:_getObjVar|<span style="color:#FF0000;font-weight:bold">getObjVar</span>]](Q68S, <span style="color:#800000">"fixStats"</span>);
 
   }
 
   }
 
   num++;
 
   num++;
   [[Engine Function:_setObjVar|<span style="color:#FF0000;font-weight:bold">setObjVar</span>]](Q68S, <span style="color:#800000">"[[fixStats|<span style="color:#2B91AF">fixStats</span>]]"</span>, num);
+
   [[Engine Function:_setObjVar|<span style="color:#FF0000;font-weight:bold">setObjVar</span>]](Q68S, <span style="color:#800000">"fixStats"</span>, num);
 
   <span style="color:#0000FF">return</span> ();
 
   <span style="color:#0000FF">return</span> ();
 
  }
 
  }

Revision as of 11:14, 15 October 2018

inherits globals;
function void Q5LY(obj Q68S)
{
  int num = 0x00;
  if (hasObjVar(Q68S, "fixStats"))
  {
    num = getObjVar(Q68S, "fixStats");
  }
  num++;
  setObjVar(Q68S, "fixStats", num);
  return ();
}
function int Q5ML(obj Q68S)
{
  int Q5W5;
  int Q5LU;
  int Q5W0;
  int Q5NC;
  int Q5NG = 0x00;
  for(int i = 0x00; i < 0x03; i++)
  {
    Q5W5 = getStatMod(Q68S, i);
    if (Q5W5 != 0x00)
    {
      Q5NC = setStatMod(Q68S, i, 0x00);
      Q5NG = 0x01;
    }
    Q5LU = getRealStat(Q68S, i);
    Q5W0 = getStatAttributeMax(Q68S, i);
    if (Q5LU != Q5W0)
    {
      Q5NC = setStatAttributeMax(Q68S, i, Q5LU);
      Q5NG = 0x01;
    }
  }
  return (Q5NG);
}
function int fixStats(obj Q68S)
{
  list Q4O3;
  loc Q5AH = getLocation(Q68S);
  int Q5TS;
  obj item;
  int Q5NC;
  int Q5NG;
  for(Q5TS = 0x01; Q5TS < 0x1A; Q5TS++)
  {
    item = getItemAtSlot(Q68S, Q5TS);
    append(Q4O3, item);
    if (item != NULL())
    {
      Q5NC = teleport(item, Q5AH);
    }
  }
  Q5NG = Q5ML(Q68S);
  int Q52R = numInList(Q4O3) + 0x01;
  for(Q5TS = 0x01; Q5TS < Q52R; Q5TS++)
  {
    item = Q4O3[Q5TS - 0x01];
    if (item != NULL())
    {
      Q5NC = equipObj(item, Q68S, Q5TS);
    }
  }
  setNaturalAC(Q68S, 0x00);
  return (Q5NG);
}
function void Q4PM(obj it)
{
  if (fixStats(it))
  {
    bark(it, "Stat(s) fixed");
    Q5LY(it);
  }
  detachScript(it, "statfix");
  return ();
}
function int Q5ON(string Q5OQ)
{
  if (Q5OQ == "bounty")
  {
    return (0x01);
  }
  if (Q5OQ == "giftbag")
  {
    return (0x01);
  }
  if (Q5OQ == "statfix")
  {
    return (0x01);
  }
  if (Q5OQ == "amnesty3")
  {
    return (0x01);
  }
  if (Q5OQ == "amnesty4")
  {
    return (0x01);
  }
  if (Q5OQ == "guarded")
  {
    return (0x01);
  }
  if (Q5OQ == "counokay")
  {
    return (0x01);
  }
  if (Q5OQ == "info")
  {
    return (0x01);
  }
  return (0x00);
}
function int Q5OP(obj it)
{
  list Q5OO;
  getScripts(Q5OO, it);
  int num = numInList(Q5OO);
  string Q5OQ;
  for(int i = 0x00; i < num; i++)
  {
    Q5OQ = Q5OO[i];
    if (!Q5ON(Q5OQ))
    {
      return (0x00);
    }
  }
  return (0x01);
}
function void Q4C9(obj it)
{
  if (Q5OP(it))
  {
    Q4PM(it);
  }
  else
  {
    callback(it, random(0x1E, 0x3C), 0x77);
  }
  return ();
}
trigger creation
{
  Q4C9(this);
  return (0x01);
}
trigger callback(0x77)
{
  Q4C9(this);
  return (0x01);
}

ADDED

 function void statfix(obj it)
 {
   for(int i = 0x00; i < 0x03; i++)
   {
     int Q5G7 = getRealStat(it, i);
     int Q5W9 = Q5G7;
     if (Q5G7 < 0x00)
     {
       Q5W9 = 0x00;
     }
     if (Q5G7 >= 0xC8)
     {
       Q5W9 = 0x00;
     }
     if (Q5W9 != Q5G7)
     {
       int Q527 = setRealStat(it, i, Q5W9);
     }
   }
   return ();
 }