SHARE
TWEET

Combo Script Engine

ZoriaRPG Aug 20th, 2019 (edited) 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Combo Scripts v0.3
  2. //26th August, 2019
  3. refInfo comboScriptData[176*7];
  4. word combo_doscript[176] = {0}; //one bit per layer
  5. byte combo_waitdraw[176] = {0}; //one bit per layer
  6. byte combo_initialised[176] = {0}; //one bit per layer
  7. int comboscript_combo_ids[176*7] = {0};
  8. long combo_stack[176*7][MAX_SCRIPT_REGISTERS];
  9.  
  10. //Add to refInfo class: comboposref, used for layer and positional data for special combo script functions
  11.  
  12. void init_combo_doscript()
  13. {
  14.     for ( int q = 0; q < 1232; q++ ) combo_doscript[q] = 1;
  15. }
  16. void clear_combo_refinfo()
  17. {
  18.     for ( int q = 0; q < 1232; q++ )
  19.         comboScriptData[q].Clear();
  20. }
  21.  
  22. void clear_combo_refinfo(int pos)
  23. {
  24.     comboScriptData[pos].Clear();
  25. }
  26.  
  27. void clear_combo_stacks()
  28. {
  29.     for ( int q = 0; q < 1232; q++ )
  30.         memset(combo_stack[q], 0, sizeof(combo_stack[q]));
  31. }
  32. void clear_combo_stack(int q)
  33. {
  34.     memset(combo_stack[q], 0, sizeof(combo_stack[q]));
  35. }
  36.  
  37. void clear_combo_initialised()
  38. {
  39.     memset(combo_initialised, 0, sizeof(combo_initialised));
  40. }
  41.  
  42. //c+176*q : This tells the interpreter which combo pos and which layer it is running.
  43. //used for X(), Y(), Layer() and Pos()
  44.  
  45. //RunScript
  46. case SCRIPT_COMBO:
  47. {
  48.     ri = &(comboScriptData[i]);
  49.  
  50.     curscript = comboscripts[script];
  51.     stack = &(combo_stack[i]);
  52.     int pos = ((i%176));
  53.     int id = comboscript_combo_ids[i];
  54.  
  55.     if(!(combo_initialised[pos]&l))
  56.     {
  57.         memset(ri->d, 0, 8 * sizeof(long));
  58.         for ( int q = 0; q < COMBOINITDMAX; q++ )
  59.             ri->d[q] = combosbuf[m->data[id]].initD[q];
  60.     }
  61.  
  62.     ri->combosref = id; //'this' pointer
  63.     ri->comboposref = i; //used for X(), Y(), Layer(), and so forth.
  64. }
  65.  
  66. //Quit
  67. case SCRIPT_COMBO:
  68. {
  69.     int l = 0; //get the layer
  70.     for int q = 176; q < 1232; q+= 176 )
  71.     {
  72.         if ( i < q )
  73.         {
  74.             break;
  75.         }
  76.         ++l;
  77.     }
  78.     int pos = ((i%176));
  79.     combo_doscript[pos] &=  ~(1<<l);
  80.     combo_initialised[pos] &=  ~(1<<l);
  81.    
  82.     FFScript::deallocateAllArrays(type, i); //need to add combo arrays
  83.  
  84.     break;
  85. }
  86.  
  87. void ComboScriptEngine()
  88. {
  89.    
  90.     for ( int q = 0; q < ; q++ )
  91.     {
  92.         if (!get_bit(quest_rules, qrCOMBO_SCRIPTS_RUN_ON_LAYER_0+q)) continue;
  93.         for ( int c = 0; c < 176; c++ )
  94.         {
  95.             if ( !q )
  96.             {
  97.                 //layer 0
  98.                 if ( combosbuf[tmpscr->data[c]].script )
  99.                 {
  100.                     if ( combo_doscript[c] & 1 )
  101.                     {
  102.                         combo_doscript[c] |= 1;
  103.                         comboscript_combo_ids[c+(176*q)] = tmpscr->data[c];
  104.                         ZScriptVersion::RunScript(SCRIPT_COMBO, combosbuf[tmpscr->data[c].script, c+(176*q));
  105.                     }
  106.                 }
  107.             }
  108.             else //higher layers
  109.             {
  110.                 int ls = tmpscr->layerscreen[q];
  111.                 int lm = tmpscr->layermap[q];
  112.                 mapscr *m = &TheMaps[(zc_max((lm)-1,0) * MAPSCRS + ls)];
  113.                 if ( combosbuf[m->data[c]].script )
  114.                 {
  115.                     if ( combo_doscript[c] & (1<<q) )
  116.                     {
  117.                         combo_doscript[c] |= (1<<q);
  118.                         comboscript_combo_ids[c+(176*q)] = m->data[c];
  119.                         ZScriptVersion::RunScript(SCRIPT_COMBO, combosbuf[m->data[c]].script, c=176*q);
  120.                     }
  121.                 }
  122.             }
  123.         }
  124.     }
  125. }
  126.                
  127.  
  128. //tba
  129. void deallocateComboArrays();
  130.  
  131. int getComboDataLayer(int c, int scripttype)
  132. {
  133.     if ( scripttype != SCRIPT_COMBO )
  134.     {
  135.         Z_scripterrorlog("combodata->Layer() only runs from combo scripts, not from script type &s\n", scripttypenames[scripttype]);
  136.         return -1;
  137.     }
  138.     else
  139.     {
  140.         int l = 0;
  141.         for int q = 176; q < 1232; q+= 176 )
  142.         {
  143.             if ( c < q )
  144.             {
  145.                 return l;
  146.             }
  147.             ++l;
  148.         }
  149.     }
  150. }
  151.  
  152. int getCombodataPos(int c, int scripttype)
  153. {
  154.     if ( scripttype != SCRIPT_COMBO )
  155.     {
  156.         Z_scripterrorlog("combodata->YPos() only runs from combo scripts, not from script type &s\n", scripttypenames[scripttype]);
  157.         return -1;
  158.     }
  159.     else return ((c%176));
  160. }
  161.  
  162. int getCombodataX(int c, int scripttype)
  163. {
  164.     if ( scripttype != SCRIPT_COMBO )
  165.     {
  166.         Z_scripterrorlog("combodata->X() only runs from combo scripts, not from script type &s\n", scripttypenames[scripttype]);
  167.         return -1;
  168.     }
  169.     else
  170.     {
  171.         int pos = getCombodataPos(c);
  172.         return COMBOX(pos);
  173.     }
  174. }
  175.  
  176. int getCombodataY(int c, int scripttype)
  177. {
  178.     if ( scripttype != SCRIPT_COMBO )
  179.     {
  180.         Z_scripterrorlog("combodata->Y() only runs from combo scripts, not from script type &s\n", scripttypenames[scripttype]);
  181.         return -1;
  182.     }
  183.     else
  184.     {
  185.         int pos = getCombodataPos(c);
  186.         return COMBOY(pos);
  187.     }
  188. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top