ZoriaRPG

RunScript Functions v2

Mar 18th, 2019
137
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 < 1 || scriptNum > 511)
  5.     {
  6.         LogPrint("Invalid script ID ( %d ) passed to RunNPCScript. \n Valid range is (1 to 511). Aborting. \n", ID);
  7.         return Debug->NULL();
  8.     }
  9.    
  10.     npc n = Screen->CreateNPC(ID);
  11.     n->Script = scriptNum;
  12.     int sz = SizeOfArray(args);
  13.     if(sz)
  14.     {
  15.         sz = ( sz > 7 ) ? 7 : sz-1;
  16.         for (; sz >= 0; --sz)
  17.             n->InitD[sz] = args[sz];
  18.     }
  19.     return n;
  20. }
  21.  
  22. lweapon RunLWeaponScript(int ID, int scriptNum, untyped args)
  23. {
  24.     // Invalid script
  25.     if(scriptNum < 1 || scriptNum > 511)
  26.     {
  27.         LogPrint("Invalid script ID ( %d ) passed to RunLWeaponScript. \n Valid range is (1 to 511). Aborting. \n", ID);
  28.         return Debug->NULL();
  29.     }
  30.    
  31.     lweapon n = Screen->CreateLWeapon(ID);
  32.     n->Script = scriptNum;
  33.     int sz = SizeOfArray(args);
  34.     if(sz)
  35.     {
  36.         sz = ( sz > 7 ) ? 7 : sz-1;
  37.         for (; sz >= 0; --sz)
  38.             n->InitD[sz] = args[sz];
  39.     }
  40.     return n;
  41. }
  42.  
  43. lweapon RunEWeaponScript(int ID, int scriptNum, untyped args)
  44. {
  45.     // Invalid script
  46.     if(scriptNum < 1 || scriptNum > 511)
  47.     {
  48.         LogPrint("Invalid script ID ( %d ) passed to RunEWeaponScript. \n Valid range is (1 to 511). Aborting. \n", ID);
  49.         return Debug->NULL();
  50.     }
  51.    
  52.     eweapon n = Screen->CreateEWeapon(ID);
  53.     n->Script = scriptNum;
  54.     int sz = SizeOfArray(args);
  55.     if(sz)
  56.     {
  57.         sz = ( sz > 7 ) ? 7 : sz-1;
  58.         for (; sz >= 0; --sz)
  59.             n->InitD[sz] = args[sz];
  60.     }
  61.     return n;
  62. }
RAW Paste Data