Difference between revisions of "Script: Timer"

From Ultima Online: The Second Age
Jump to: navigation, search
(Created page with " <span style="color:#0000FF">inherits</span> globals; <span style="color:#0000FF">trigger</span> message(<span style="color:#800000">"activate"</span>) { <span style...")
 
 
Line 5: Line 5:
 
   <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"time1"</span>))
 
   <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"time1"</span>))
 
   {
 
   {
     <span style="color:#0000FF">int</span> time1 = [[getobjvar_int|<span style="color:#FF0000;font-weight:bold">getobjvar_int</span>]](this, <span style="color:#800000">"time1"</span>);
+
     <span style="color:#0000FF">int</span> time1 = [[Engine Function: getobjvar_int|<span style="color:#FF0000;font-weight:bold">getobjvar_int</span>]](this, <span style="color:#800000">"time1"</span>);
     <span style="color:#0000FF">if</span> (![[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"running"</span>))
+
     <span style="color:#0000FF">if</span> (![[Engine_Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"running"</span>))
 
     {
 
     {
 
       <span style="color:#0000FF">int</span> Q5I3 = 0x00;
 
       <span style="color:#0000FF">int</span> Q5I3 = 0x00;
Line 12: Line 12:
 
       <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"count"</span>))
 
       <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"count"</span>))
 
       {
 
       {
         <span style="color:#0000FF">int</span> count = [[getobjvar_int|<span style="color:#FF0000;font-weight:bold">getobjvar_int</span>]](this, <span style="color:#800000">"count"</span>);
+
         <span style="color:#0000FF">int</span> count = [[Engine Function:_getobjvar_int|<span style="color:#FF0000;font-weight:bold">getobjvar_int</span>]](this, <span style="color:#800000">"count"</span>);
 
         [[Engine Function:_setObjVar|<span style="color:#FF0000;font-weight:bold">setObjVar</span>]](this, <span style="color:#800000">"tempCount"</span>, count);
 
         [[Engine Function:_setObjVar|<span style="color:#FF0000;font-weight:bold">setObjVar</span>]](this, <span style="color:#800000">"tempCount"</span>, count);
 
       }
 
       }
Line 37: Line 37:
 
   <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"running"</span>))
 
   <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"running"</span>))
 
   {
 
   {
     <span style="color:#0000FF">int</span> Q5I3 = [[getobjvar_int|<span style="color:#FF0000;font-weight:bold">getobjvar_int</span>]](this, <span style="color:#800000">"running"</span>);
+
     <span style="color:#0000FF">int</span> Q5I3 = [[Engine_Function:_getobjvar_int|<span style="color:#FF0000;font-weight:bold">getobjvar_int</span>]](this, <span style="color:#800000">"running"</span>);
 
     <span style="color:#0000FF">if</span> (Q5I3 == 0x00)
 
     <span style="color:#0000FF">if</span> (Q5I3 == 0x00)
 
     {
 
     {
Line 43: Line 43:
 
       <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"time2"</span>))
 
       <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"time2"</span>))
 
       {
 
       {
         <span style="color:#0000FF">int</span> time2 = [[getobjvar_int|<span style="color:#FF0000;font-weight:bold">getobjvar_int</span>]](this, <span style="color:#800000">"time2"</span>);
+
         <span style="color:#0000FF">int</span> time2 = [[Engine_Function:_getobjvar_int|<span style="color:#FF0000;font-weight:bold">getobjvar_int</span>]](this, <span style="color:#800000">"time2"</span>);
 
         Q5I3 = 0x01;
 
         Q5I3 = 0x01;
 
         [[Engine Function:_setObjVar|<span style="color:#FF0000;font-weight:bold">setObjVar</span>]](this, <span style="color:#800000">"running"</span>, Q5I3);
 
         [[Engine Function:_setObjVar|<span style="color:#FF0000;font-weight:bold">setObjVar</span>]](this, <span style="color:#800000">"running"</span>, Q5I3);
Line 50: Line 50:
 
       <span style="color:#0000FF">else</span>
 
       <span style="color:#0000FF">else</span>
 
       {
 
       {
         time1 = [[getobjvar_int|<span style="color:#FF0000;font-weight:bold">getobjvar_int</span>]](this, <span style="color:#800000">"time1"</span>);
+
         time1 = [[Engine_Function:_getobjvar_int|<span style="color:#FF0000;font-weight:bold">getobjvar_int</span>]](this, <span style="color:#800000">"time1"</span>);
 
         [[Engine Function:_callback|<span style="color:#FF0000;font-weight:bold">callback</span>]](this, time1, 0x2F);
 
         [[Engine Function:_callback|<span style="color:#FF0000;font-weight:bold">callback</span>]](this, time1, 0x2F);
 
       }
 
       }
Line 57: Line 57:
 
     {
 
     {
 
       [[Engine Function:_processTriggerCmds|<span style="color:#FF0000;font-weight:bold">processTriggerCmds</span>]](this, <span style="color:#800000">"d"</span>);
 
       [[Engine Function:_processTriggerCmds|<span style="color:#FF0000;font-weight:bold">processTriggerCmds</span>]](this, <span style="color:#800000">"d"</span>);
       time1 = [[getobjvar_int|<span style="color:#FF0000;font-weight:bold">getobjvar_int</span>]](this, <span style="color:#800000">"time1"</span>);
+
       time1 = [[Engine_Function:_getobjvar_int|<span style="color:#FF0000;font-weight:bold">getobjvar_int</span>]](this, <span style="color:#800000">"time1"</span>);
 
       Q5I3 = 0x00;
 
       Q5I3 = 0x00;
 
       [[Engine Function:_setObjVar|<span style="color:#FF0000;font-weight:bold">setObjVar</span>]](this, <span style="color:#800000">"running"</span>, Q5I3);
 
       [[Engine Function:_setObjVar|<span style="color:#FF0000;font-weight:bold">setObjVar</span>]](this, <span style="color:#800000">"running"</span>, Q5I3);
Line 65: Line 65:
 
   <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"tempCount"</span>))
 
   <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"tempCount"</span>))
 
   {
 
   {
     <span style="color:#0000FF">int</span> tempCount = [[getobjvar_int|<span style="color:#FF0000;font-weight:bold">getobjvar_int</span>]](this, <span style="color:#800000">"tempCount"</span>);
+
     <span style="color:#0000FF">int</span> tempCount = [[Engine_Function:_getobjvar_int|<span style="color:#FF0000;font-weight:bold">getobjvar_int</span>]](this, <span style="color:#800000">"tempCount"</span>);
 
     <span style="color:#0000FF">if</span> (tempCount > 0x01)
 
     <span style="color:#0000FF">if</span> (tempCount > 0x01)
 
     {
 
     {

Latest revision as of 03:41, 21 October 2018

inherits globals;
trigger message("activate")
{
  if (hasObjVar(this, "time1"))
  {
    int time1 = getobjvar_int(this, "time1");
    if (!hasObjVar(this, "running"))
    {
      int Q5I3 = 0x00;
      setObjVar(this, "running", Q5I3);
      if (hasObjVar(this, "count"))
      {
        int count = getobjvar_int(this, "count");
        setObjVar(this, "tempCount", count);
      }
      callback(this, time1, 0x2F);
      return (0x00);
    }
  }
  return (0x00);
}
trigger message("deactivate")
{
  if (hasObjVar(this, "running"))
  {
    removeObjVar(this, "running");
  }
  return (0x00);
}
trigger callback(0x2F)
{
  int time1;
  list args;
  if (hasObjVar(this, "running"))
  {
    int Q5I3 = getobjvar_int(this, "running");
    if (Q5I3 == 0x00)
    {
      processTriggerCmds(this, "a");
      if (hasObjVar(this, "time2"))
      {
        int time2 = getobjvar_int(this, "time2");
        Q5I3 = 0x01;
        setObjVar(this, "running", Q5I3);
        callback(this, time2, 0x2F);
      }
      else
      {
        time1 = getobjvar_int(this, "time1");
        callback(this, time1, 0x2F);
      }
    }
    else
    {
      processTriggerCmds(this, "d");
      time1 = getobjvar_int(this, "time1");
      Q5I3 = 0x00;
      setObjVar(this, "running", Q5I3);
      callback(this, time1, 0x2F);
    }
  }
  if (hasObjVar(this, "tempCount"))
  {
    int tempCount = getobjvar_int(this, "tempCount");
    if (tempCount > 0x01)
    {
      tempCount--;
      setObjVar(this, "tempCount", tempCount);
    }
    else
    {
      removeObjVar(this, "tempCount");
      message(this, "deactivate", args);
    }
  }
  return (0x00);
}
trigger enterrange(0x07)
{
  if (isPlayer(target))
  {
    if (!hasObjVar(this, "noAuto") && !hasObjVar(this, "running"))
    {
      list args;
      message(this, "activate", args);
    }
  }
  return (0x01);
}
trigger leaverange(0x07)
{
  if (!hasObjVar(this, "noAuto") && hasObjVar(this, "running"))
  {
    if (isPlayer(target))
    {
      list Q5J1;
      getPlayersInRange(Q5J1, getLocation(this), 0x06);
      if (numInList(Q5J1) == 0x00)
      {
        list args;
        message(this, "deactivate", args);
      }
    }
  }
  return (0x01);
}
trigger creation
{
  if (!hasObjVar(this, "noAuto") && !hasObjVar(this, "running"))
  {
    list Q5J1;
    getPlayersInRange(Q5J1, getLocation(this), 0x06);
    if (numInList(Q5J1) > 0x00)
    {
      list args;
      message(this, "activate", args);
    }
  }
  return (0x00);
}