Difference between revisions of "Script: Mongen"

From Ultima Online: The Second Age
Jump to: navigation, search
Line 17: Line 17:
 
   <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"onlyOne"</span>))
 
   <span style="color:#0000FF">if</span> ([[Engine Function:_hasObjVar|<span style="color:#FF0000;font-weight:bold">hasObjVar</span>]](this, <span style="color:#800000">"onlyOne"</span>))
 
   {
 
   {
     de[[activate|<span style="color:#2B91AF">activate</span>]](this);
+
     deactivate(this);
 
   }
 
   }
 
   <span style="color:#0000FF">int</span> radius = 0x03;
 
   <span style="color:#0000FF">int</span> radius = 0x03;
Line 48: Line 48:
 
  <span style="color:#0000FF">trigger</span> message(<span style="color:#800000">"deactivate"</span>)
 
  <span style="color:#0000FF">trigger</span> message(<span style="color:#800000">"deactivate"</span>)
 
  {
 
  {
   de[[activate|<span style="color:#2B91AF">activate</span>]](this);
+
   deactivate(this);
 
   <span style="color:#0000FF">return</span> (0x00);
 
   <span style="color:#0000FF">return</span> (0x00);
 
  }
 
  }

Revision as of 01:06, 21 October 2018

function void deactivate(obj this)
{
  if (hasObjVar(this, "objectId") && hasObjVar(this, "objectType"))
  {
    obj objectId = getobjvar_obj(this, "objectId");
    int objectType = getobjvar_int(this, "objectType");
    deleteIfValid(objectId, objectType);
    removeObjVar(this, "objectId");
    removeObjVar(this, "objectType");
    processTriggerCmds(this, "d");
  }
  return;
}
trigger message("activate")
{
  if (hasObjVar(this, "onlyOne"))
  {
    deactivate(this);
  }
  int radius = 0x03;
  if (hasObjVar(this, "radius"))
  {
    radius = getobjvar_int(this, "radius");
  }
  int Q4F3 = 0x00;
  if (hasObjVar(this, "template"))
  {
    Q4F3 = getobjvar_int(this, "template");
    loc location = getLocation(this);
    obj Q5BQ = requestCreateNPCAt(Q4F3, location, radius);
    int a = objtoint(Q5BQ);
    if (a != 0x00)
    {
      int objectType = getObjType(Q5BQ);
      setObjVar(this, "objectId", Q5BQ);
      setObjVar(this, "objectType", objectType);
      processTriggerCmds(this, "a");
    }
  }
  else
  {
    bark(this, "Missing template objvar!");
  }
  return (0x00);
}
trigger message("deactivate")
{
  deactivate(this);
  return (0x00);
}