Advertisement
ZoriaRPG

Scripts.zh (Script Execution and Management), v0.2

May 30th, 2019
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.00 KB | None | 0 0
  1. /*! Script Execution and Management, scripts.zh
  2. * By: ZOriaRPG
  3. * Version 0.2
  4. * 29th May, 2019
  5. */
  6.  
  7. namespace Scripts
  8. {
  9.     const int IFLAG_SCRITPERPETUAL = 15;
  10.    
  11.     //! Runs an arbitrary item script.
  12.     //! Itemname is the name of the item used to run script scriptname.
  13.     //! If the arg passed to itemname is a literal value, and not a string.
  14.     //! then we use iy as the literal item id.
  15.     //! Returns the script number.
  16.     int RunItem(int scriptname, int itemname)
  17.     {
  18.         int itemid;
  19.         if ( std::sizeof(itemname) < 2 )
  20.         {
  21.             itemid = itemname;
  22.         }
  23.         else
  24.         {
  25.             itemid = Game->GetItem("itemname");
  26.         }
  27.         itemdata id = Game->LoadItemData(itemid);
  28.         int script_number = Game->GetItemScript(scriptname);
  29.         id->Script = script_number;
  30.         id->RunScript();
  31.         return script_number;
  32.     }
  33.     //! As RunItem(int, int), except that we supply new InitD
  34.     int RunItem(int scriptname, int itemname, int initd)
  35.     {
  36.         int itemid;
  37.         if ( std::sizeof(itemname) < 2 )
  38.         {
  39.             itemid = itemname;
  40.         }
  41.         else
  42.         {
  43.             itemid = Game->GetItem("itemname");
  44.         }
  45.         itemdata id = Game->LoadItemData(itemid);
  46.         int sz = std::sizeof(initd); /only on valid arrays
  47.         for ( int q = 0; q < sz; ++q )
  48.         {
  49.             id->InitD[q] = initd[q];
  50.         }
  51.            
  52.        
  53.         int script_number = Game->GetItemScript(scriptname);
  54.         id->Script = script_number;
  55.         id->RunScript();
  56.         return script_number;
  57.     }
  58.  
  59.     //! Runs arbitrary ffc script 'name'.
  60.     ffc RunFFC(int name)
  61.     {
  62.         int id; ffc f;
  63.         int script_id = Game->GetFFCScript(name);
  64.         for ( int q - 1; q < 33; ++q)
  65.         {
  66.             f = Screen->LoadFFC(q);
  67.             if ( !f->Script )
  68.             {
  69.                 int cmb = Game->GetCombo("Invisible");
  70.                 f->Data = cmb;
  71.                 f->Script = script_id;
  72.             }
  73.         }
  74.         return f;
  75.     }
  76.     ffc RunFFC(int name, int initd)
  77.     {
  78.         int id; ffc f;
  79.         int script_id = Game->GetFFCScript(name);
  80.         for ( int q - 1; q < 33; ++q)
  81.         {
  82.             f = Screen->LoadFFC(q);
  83.             if ( !f->Script )
  84.             {
  85.                 int cmb = Game->GetCombo("Invisible");
  86.                 f->Data = cmb;
  87.                 f->Script = script_id;
  88.                 if ( initd )
  89.                 {
  90.                     int sz = std::sizeof(initd);
  91.                     for ( int q = 0; q < sz; ++q )
  92.                     {
  93.                         f->InitD[q] = initd[q];
  94.                     }
  95.                 }
  96.             }
  97.         }
  98.         return f;
  99.     }
  100.  
  101.     //! Toggles a perpetual item script on or off using itemdata.
  102.     void ToggleItem(itemdata id, bool on)
  103.     {
  104.         id->Flags[IFLAG_SCRITPERPETUAL] = (on ? true : false );
  105.     }
  106.    
  107.     //! Toggles a perpetual item script on or off using either a literal item ID
  108.     //! or the name of an item, suplied as a string.
  109.     //! This is automatic: If a string is supplied, we go forward by its contents;
  110.     //! otherwise, we use the literal value supplied as the item ID
  111.     int ToggleItem(int name, bool state)
  112.     {
  113.         int sz = std::sizeof(name);
  114.         int itemid;
  115.         if ( sz < 1 ) itemid = name;
  116.         else itemid = Game->GetItem(name);
  117.         itemdata id  = Game->LoadItemData(itemid);
  118.         id->Flags[IFLAG_SCRITPERPETUAL] = (on ? true : false );
  119.     }
  120.    
  121.     //ResetItem : Changes a scrit and optionally loads new InitD
  122.    
  123.     //! Spawns an noc, and runs a script.
  124.     //npc RunNPC(npc n, int name)
  125.     //{
  126.        
  127.     //}
  128.    
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement