ZoriaRPG

RunScript Functions

Mar 18th, 2019
127
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. npc RunNPCScript(int ID, int scriptNum, untyped args)
  2. {
  3.     // Invalid script
  4.     if(scriptNum < 0 || scriptNum > 511) // Why allow script 0 here?
  5.         return Debug->NULL();
  6.    
  7.     npc n = Screen->CreateNPC(ID);
  8.     n->Script = scriptNum;
  9.     int sz = SizeOfArray(args);
  10.     if(sz)
  11.     {
  12.         sz = ( sz > 7 ) ? 7 : sz-1;
  13.         for (; sz >= 0; --sz)
  14.             n->InitD[sz] = args[sz];
  15.     }
  16.     return n;
  17. }
  18.  
  19. lweapon RunLWeaponScript(int ID, int scriptNum, untyped args)
  20. {
  21.     // Invalid script
  22.     if(scriptNum < 0 || scriptNum > 511) // Why allow script 0 here?
  23.         return Debug->NULL();
  24.    
  25.     lweapon n = Screen->CreateLWeapon(ID);
  26.     n->Script = scriptNum;
  27.     int sz = SizeOfArray(args);
  28.     if(sz)
  29.     {
  30.         sz = ( sz > 7 ) ? 7 : sz-1;
  31.         for (; sz >= 0; --sz)
  32.             n->InitD[sz] = args[sz];
  33.     }
  34.     return n;
  35. }
  36.  
  37. lweapon RunEWeaponScript(int ID, int scriptNum, untyped args)
  38. {
  39.     // Invalid script
  40.     if(scriptNum < 0 || scriptNum > 511) // Why allow script 0 here?
  41.         return Debug->NULL();
  42.    
  43.     eweapon n = Screen->CreateEWeapon(ID);
  44.     n->Script = scriptNum;
  45.     int sz = SizeOfArray(args);
  46.     if(sz)
  47.     {
  48.         sz = ( sz > 7 ) ? 7 : sz-1;
  49.         for (; sz >= 0; --sz)
  50.             n->InitD[sz] = args[sz];
  51.     }
  52.     return n;
  53. }
RAW Paste Data