Advertisement
ZoriaRPG

RunFFC.zs

Sep 13th, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 24.87 KB | None | 0 0
  1. ////////////////////////////
  2. /// RunFFC.zh            ///
  3. /// By: ZoriaRPG         ///
  4. /// v0.2.2               ///
  5. /// 13th September, 2018 ///
  6. ////////////////////////////
  7.  
  8. script typedef ffc struct;
  9.  
  10. struct script RunFFC //No need to assign this to a slot.
  11. {
  12.     void run(){}
  13.     const int MAX_INDEX = 32;
  14.     const int MIN_INDEX = 1;
  15.     const int CMB_INVIS = 100;
  16. }
  17.  
  18.  
  19. /*
  20.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  21.     [ example--
  22.         RunFFC("scriptname", {1,2,3,4,5,6,7});
  23.     --end example]
  24. */
  25.  
  26. int RunFFC(int scriptname, float init_d_ptr)
  27. {
  28.     int id = Game->GetFFCScript(scriptname);
  29.     if( id <= 0 ) return 0;
  30.     if ( is > 511 ) return 0;
  31.    
  32.     ffc f = Debug->Null();
  33.    
  34.     for ( int q = RunFFC.MIN_INDEX; q <= RunFFC.MAX_INDEX; --q )
  35.     {
  36.         f = Screen->LoadFFC(q);
  37.        
  38.         if ( f->Data !=0 ) continue;
  39.         //Do we really want to latch onto ffcs with an invis combo set?
  40.         //Scripts should clear that with EndFFC!
  41.         if ( f->Script !=0 ) continue;
  42.         if ( f->Flags[FFCF_CHANGER] ) continue;
  43.  
  44.         f->Data = RunFFC.CMB_INVIS;
  45.         f->Script = id;
  46.  
  47.        
  48.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  49.         {
  50.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  51.             {
  52.                 f->InitD[w] = init_d_ptr[w];
  53.             }
  54.         }
  55.        
  56.         return q; //or do we want to return as ffc?
  57.     }
  58.    
  59.  
  60.     return Debug->Null();
  61. }
  62.  
  63. /*
  64.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  65.     Can be set to quit a running script if the script calls it, but
  66.     cannot find a free ffc on the screen.
  67.     [ example--
  68.         RunFFC("scriptname", {1,2,3,4,5,6,7}, true);  
  69.             //Will quit the script on failure.
  70.     --end example]
  71. */
  72.  
  73. int RunFFC(int scriptname, float init_d_ptr, bool quit_on_failure)
  74. {
  75.     int id = Game->GetFFCScript(scriptname);
  76.     if( id <= 0 ) return 0;
  77.     if ( is > 511 ) return 0;
  78.    
  79.     ffc f = Debug->Null();
  80.    
  81.     for ( int q = RunFFC.MIN_INDEX; q <= RunFFC.MAX_INDEX; --q )
  82.     {
  83.         f = Screen->LoadFFC(q);
  84.        
  85.         if ( f->Data !=0 ) continue;
  86.         //Do we really want to latch onto ffcs with an invis combo set?
  87.         //Scripts should clear that with EndFFC!
  88.         if ( f->Script !=0 ) continue;
  89.         if ( f->Flags[FFCF_CHANGER] ) continue;
  90.  
  91.         f->Data = RunFFC.CMB_INVIS;
  92.         f->Script = id;
  93.  
  94.        
  95.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  96.         {
  97.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  98.             {
  99.                 f->InitD[w] = init_d_ptr[w];
  100.             }
  101.         }
  102.        
  103.         return q; //or do we want to return as ffc?
  104.     }
  105.    
  106.     if ( quit_on_failure ) Quit();
  107.     else return Debug->Null();
  108. }
  109.  
  110. /*
  111.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  112.     You may set the invisible combo manually. Will default to the constant in struct RunFFC.
  113.     [ example--
  114.         RunFFC("scriptname", {1,2,3,4,5,6,7}, CMB_CUSTOM_INVISIBLE);  
  115.             //Will use a user-set invisible combo.
  116.     --end example]
  117. */
  118.  
  119. int RunFFC(int scriptname, float init_d_ptr, int cmb)
  120. {
  121.     int id = Game->GetFFCScript(scriptname);
  122.     if( id <= 0 ) return 0;
  123.     if ( is > 511 ) return 0;
  124.    
  125.     ffc f = Debug->Null();
  126.     if ( cmb <= 0 ) cmb = RunFFC.CMB_INVIS;
  127.    
  128.     for ( int q = RunFFC.MIN_INDEX; q <= RunFFC.MAX_INDEX; --q )
  129.     {
  130.         f = Screen->LoadFFC(q);
  131.        
  132.         if ( f->Data !=0 ) continue;
  133.         //Do we really want to latch onto ffcs with an invis combo set?
  134.         //Scripts should clear that with EndFFC!
  135.         if ( f->Script !=0 ) continue;
  136.         if ( f->Flags[FFCF_CHANGER] ) continue;
  137.  
  138.         f->Data = cmb;
  139.         f->Script = id;
  140.  
  141.        
  142.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  143.         {
  144.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  145.             {
  146.                 f->InitD[w] = init_d_ptr[w];
  147.             }
  148.                
  149.         }
  150.        
  151.         return q; //or do we want to return as ffc?
  152.     }
  153.    
  154.  
  155.     return Debug->Null();
  156. }
  157.  
  158.  
  159. /*
  160.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  161.     You may set the invisible combo manually. Will default to the constant in struct RunFFC.
  162.     Can be set to quit a running script if the script calls it, but
  163.     cannot find a free ffc on the screen.
  164.     [ example--
  165.         RunFFC("scriptname", {1,2,3,4,5,6,7}, CMB_CUSTOM_INVISIBLE, true);  
  166.             //Will use a user-set invisible combo.
  167.             //Will quit the script on failure.
  168.     --end example]
  169. */
  170.  
  171. int RunFFC(int scriptname, float init_d_ptr, int cmb, bool quit_on_failure)
  172. {
  173.     int id = Game->GetFFCScript(scriptname);
  174.     if( id <= 0 ) return 0;
  175.     if ( is > 511 ) return 0;
  176.    
  177.     ffc f = Debug->Null();
  178.     if ( cmb <= 0 ) cmb = RunFFC.CMB_INVIS;
  179.    
  180.     for ( int q = RunFFC.MIN_INDEX; q <= RunFFC.MAX_INDEX; ++q )
  181.     {
  182.         f = Screen->LoadFFC(q);
  183.        
  184.         if ( f->Data !=0 ) continue;
  185.         //Do we really want to latch onto ffcs with an invis combo set?
  186.         //Scripts should clear that with EndFFC!
  187.         if ( f->Script !=0 ) continue;
  188.         if ( f->Flags[FFCF_CHANGER] ) continue;
  189.  
  190.         f->Data = cmb;
  191.         f->Script = id;
  192.  
  193.        
  194.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  195.         {
  196.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  197.             {
  198.                 f->InitD[w] = init_d_ptr[w];
  199.             }
  200.         }
  201.        
  202.         return q; //or do we want to return as ffc?
  203.     }
  204.    
  205.     if ( quit_on_failure ) Quit();
  206.     else return Debug->Null();
  207. }
  208.  
  209. /*
  210.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  211.     You may set the minimum, and the maximum screen indices that it tries to use, manually.
  212.     It will default to the constantas in struct RunFFC, if these values are set out of bounds.
  213.     [ example--
  214.         RunFFC("scriptname", {1,2,3,4,5,6,7}, 3, 19);  
  215.             //Will only check FFC Ids 3 to 19.
  216.     --end example]
  217. */
  218.  
  219. int RunFFC(int scriptname, float init_d_ptr, int min_index, int max_index)
  220. {
  221.     int id = Game->GetFFCScript(scriptname);
  222.     if( id <= 0 ) return 0;
  223.     if ( is > 511 ) return 0;
  224.    
  225.     ffc f = Debug->Null();
  226.     if ( min_index > max_index )
  227.     {
  228.         //reversed args sanity check
  229.         int swp = min_index;
  230.         max_index = min_index;
  231.         min_index = swp;
  232.     }
  233.     if ( min_index < 1 ) min_index = RunFFC.MIN_INDEX;
  234.     if ( max_index > 32 ) min_index = RunFFC.MAX_INDEX;
  235.    
  236.     for ( int q = min_index; q <= max_index; ++q )
  237.     {
  238.         f = Screen->LoadFFC(q);
  239.        
  240.         if ( f->Data !=0 ) continue;
  241.         //Do we really want to latch onto ffcs with an invis combo set?
  242.         //Scripts should clear that with EndFFC!
  243.         if ( f->Script !=0 ) continue;
  244.         if ( f->Flags[FFCF_CHANGER] ) continue;
  245.  
  246.         f->Data = RunFFC.CMB_INVIS;
  247.         f->Script = id;
  248.  
  249.        
  250.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  251.         {
  252.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  253.             {
  254.                 f->InitD[w] = init_d_ptr[w];
  255.             }              
  256.         }
  257.        
  258.         return q; //or do we want to return as ffc?
  259.     }
  260.    
  261.  
  262.     return Debug->Null();
  263. }
  264.  
  265. /*
  266.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  267.     You may set the minimum, and the maximum screen indices that it tries to use, manually.
  268.     Will default to the min and max slot constants in struct RunFFC, if the values set aren't
  269.     in bounds; and it will further accept slot args in reverse-order.
  270.     It will default to the constants in struct RunFFC, if these values are set out of bounds.
  271.     Can be set to quit a running script if the script calls it, but
  272.     cannot find a free ffc on the screen.
  273.     [ example--
  274.         RunFFC("scriptname", {1,2,3,4,5,6,7}, 3, 19, true);  
  275.             //Will only check FFC Ids 3 to 19.
  276.             //Will quit the script on failure.
  277.     --end example]
  278. */
  279.  
  280. int RunFFC(int scriptname, float init_d_ptr, int min_index, int max_index, bool quit_on_failure)
  281. {
  282.     int id = Game->GetFFCScript(scriptname);
  283.     if( id <= 0 ) return 0;
  284.     if ( is > 511 ) return 0;
  285.    
  286.     if ( min_index > max_index )
  287.     {
  288.         //reversed args sanity check
  289.         int swp = min_index;
  290.         max_index = min_index;
  291.         min_index = swp;
  292.     }
  293.     ffc f = Debug->Null();
  294.     if ( min_index < 1 ) min_index = RunFFC.MIN_INDEX;
  295.     if ( max_index > 32 ) min_index = RunFFC.MAX_INDEX;
  296.    
  297.     for ( int q = min_index; q <= max_index; ++q )
  298.     {
  299.         f = Screen->LoadFFC(q);
  300.        
  301.         if ( f->Data !=0 ) continue;
  302.         //Do we really want to latch onto ffcs with an invis combo set?
  303.         //Scripts should clear that with EndFFC!
  304.         if ( f->Script !=0 ) continue;
  305.         if ( f->Flags[FFCF_CHANGER] ) continue;
  306.  
  307.         f->Data = RunFFC.CMB_INVIS;
  308.         f->Script = id;
  309.  
  310.        
  311.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  312.         {
  313.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  314.             {
  315.                 f->InitD[w] = init_d_ptr[w];
  316.             }              
  317.         }
  318.        
  319.         return q; //or do we want to return as ffc?
  320.     }
  321.    
  322.     if ( quit_on_failure ) Quit();
  323.     else return Debug->Null();
  324. }
  325.  
  326. /*
  327.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  328.     You may set the invisible combo manually. Will default to the constant in struct RunFFC.
  329.     You may set the minimum, and the maximum screen indices that it tries to use, manually.
  330.     It will default to the constants in struct RunFFC, if these values are set out of bounds.
  331.     Will default to the min and max slot constants in struct RunFFC, if the values set aren't
  332.     in bounds; and it will further accept slot args in reverse-order.
  333.    
  334.         RunFFC("scriptname", {1,2,3,4,5,6,7}, CMB_CUSTOM_INVISIBLE, 3, 19);  
  335.             //Will use a user-set invisible combo.
  336.             //Will only check FFC Ids 3 to 19.
  337.             //Will quit the script on failure.
  338.     [ example--
  339.                                
  340.     --end example]
  341. */
  342.  
  343. int RunFFC(int scriptname, float init_d_ptr, int cmb, int min_index, int max_index)
  344. {
  345.     int id = Game->GetFFCScript(scriptname);
  346.     if( id <= 0 ) return 0;
  347.     if ( is > 511 ) return 0;
  348.    
  349.     if ( min_index > max_index )
  350.     {
  351.         //reversed args sanity check
  352.         int swp = min_index;
  353.         max_index = min_index;
  354.         min_index = swp;
  355.     }
  356.     ffc f = Debug->Null();
  357.     if ( cmb <= 0 ) cmb = RunFFC.CMB_INVIS;
  358.     if ( min_index < 1 ) min_index = RunFFC.MIN_INDEX;
  359.     if ( max_index > 32 ) min_index = RunFFC.MAX_INDEX;
  360.    
  361.     for ( int q = min_index; q <= max_index; ++q )
  362.     {
  363.         f = Screen->LoadFFC(q);
  364.        
  365.         if ( f->Data !=0 ) continue;
  366.         //Do we really want to latch onto ffcs with an invis combo set?
  367.         //Scripts should clear that with EndFFC!
  368.         if ( f->Script !=0 ) continue;
  369.         if ( f->Flags[FFCF_CHANGER] ) continue;
  370.  
  371.         f->Data = cmb;
  372.         f->Script = id;
  373.  
  374.        
  375.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  376.         {
  377.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  378.             {
  379.                 f->InitD[w] = init_d_ptr[w];
  380.             }              
  381.         }
  382.        
  383.         return q; //or do we want to return as ffc?
  384.     }
  385.    
  386.  
  387.     return Debug->Null();
  388. }
  389.  
  390. /*
  391.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  392.     You may set the invisible combo manually. Will default to the constant in struct RunFFC.
  393.     You may set the minimum, and the maximum screen indices that it tries to use, manually.
  394.     It will default to the constants in struct RunFFC, if these values are set out of bounds.
  395.     Will default to the min and max slot constants in struct RunFFC, if the values set aren't
  396.     in bounds; and it will further accept slot args in reverse-order.
  397.     Can be set to quit a running script if the script calls it, but
  398.     cannot find a free ffc on the screen.
  399.     [ example--
  400.         RunFFC("scriptname", {1,2,3,4,5,6,7}, CMB_CUSTOM_INVISIBLE, 3, 19, true);  
  401.             //Will only check FFC Ids 3 to 19.
  402.             //Will quit the script on failure.
  403.     --end example]
  404. */
  405.  
  406. int RunFFC(int scriptname, float init_d_ptr, int cmb, int min_index, int max_index, bool quit_on_failure)
  407. {
  408.     int id = Game->GetFFCScript(scriptname);
  409.     if( id <= 0 ) return 0;
  410.     if ( is > 511 ) return 0;
  411.    
  412.     if ( min_index > max_index )
  413.     {
  414.         //reversed args sanity check
  415.         int swp = min_index;
  416.         max_index = min_index;
  417.         min_index = swp;
  418.     }
  419.     ffc f = Debug->Null();
  420.     if ( cmb <= 0 ) cmb = RunFFC.CMB_INVIS;
  421.     if ( min_index < 1 ) min_index = RunFFC.MIN_INDEX;
  422.     if ( max_index > 32 ) min_index = RunFFC.MAX_INDEX;
  423.    
  424.     for ( int q = min_index; q <= max_index; ++q )
  425.     {
  426.         f = Screen->LoadFFC(q);
  427.        
  428.         if ( f->Data !=0 ) continue;
  429.         //Do we really want to latch onto ffcs with an invis combo set?
  430.         //Scripts should clear that with EndFFC!
  431.         if ( f->Script !=0 ) continue;
  432.         if ( f->Flags[FFCF_CHANGER] ) continue;
  433.  
  434.         f->Data = cmb;
  435.         f->Script = id;
  436.  
  437.        
  438.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  439.         {
  440.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  441.             {
  442.                 f->InitD[w] = init_d_ptr[w];
  443.             }
  444.         }
  445.        
  446.         return q; //or do we want to return as ffc?
  447.     }
  448.    
  449.     if ( quit_on_failure ) Quit();
  450.     else return Debug->Null();
  451. }////////////////////////////
  452. /// RunFFC.zh            ///
  453. /// By: ZoriaRPG         ///
  454. /// v0.2.2               ///
  455. /// 13th September, 2018 ///
  456. ////////////////////////////
  457.  
  458. script typedef ffc struct;
  459.  
  460. struct script RunFFC //No need to assign this to a slot.
  461. {
  462.     void run(){}
  463.     const int MAX_INDEX = 32;
  464.     const int MIN_INDEX = 1;
  465.     const int CMB_INVIS = 100;
  466. }
  467.  
  468.  
  469. /*
  470.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  471.     [ example--
  472.         RunFFC("scriptname", {1,2,3,4,5,6,7});
  473.     --end example]
  474. */
  475.  
  476. int RunFFC(int scriptname, float init_d_ptr)
  477. {
  478.     int id = Game->GetFFCScript(scriptname);
  479.     if( id <= 0 ) return 0;
  480.     if ( is > 511 ) return 0;
  481.    
  482.     ffc f = Debug->Null();
  483.    
  484.     for ( int q = RunFFC.MIN_INDEX; q <= RunFFC.MAX_INDEX; --q )
  485.     {
  486.         f = Screen->LoadFFC(q);
  487.        
  488.         if ( f->Data !=0 ) continue;
  489.         //Do we really want to latch onto ffcs with an invis combo set?
  490.         //Scripts should clear that with EndFFC!
  491.         if ( f->Script !=0 ) continue;
  492.         if ( f->Flags[FFCF_CHANGER] ) continue;
  493.  
  494.         f->Data = RunFFC.CMB_INVIS;
  495.         f->Script = id;
  496.  
  497.        
  498.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  499.         {
  500.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  501.             {
  502.                 f->InitD[w] = init_d_ptr[w];
  503.             }
  504.         }
  505.        
  506.         return q; //or do we want to return as ffc?
  507.     }
  508.    
  509.  
  510.     return Debug->Null();
  511. }
  512.  
  513. /*
  514.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  515.     Can be set to quit a running script if the script calls it, but
  516.     cannot find a free ffc on the screen.
  517.     [ example--
  518.         RunFFC("scriptname", {1,2,3,4,5,6,7}, true);  
  519.             //Will quit the script on failure.
  520.     --end example]
  521. */
  522.  
  523. int RunFFC(int scriptname, float init_d_ptr, bool quit_on_failure)
  524. {
  525.     int id = Game->GetFFCScript(scriptname);
  526.     if( id <= 0 ) return 0;
  527.     if ( is > 511 ) return 0;
  528.    
  529.     ffc f = Debug->Null();
  530.    
  531.     for ( int q = RunFFC.MIN_INDEX; q <= RunFFC.MAX_INDEX; --q )
  532.     {
  533.         f = Screen->LoadFFC(q);
  534.        
  535.         if ( f->Data !=0 ) continue;
  536.         //Do we really want to latch onto ffcs with an invis combo set?
  537.         //Scripts should clear that with EndFFC!
  538.         if ( f->Script !=0 ) continue;
  539.         if ( f->Flags[FFCF_CHANGER] ) continue;
  540.  
  541.         f->Data = RunFFC.CMB_INVIS;
  542.         f->Script = id;
  543.  
  544.        
  545.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  546.         {
  547.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  548.             {
  549.                 f->InitD[w] = init_d_ptr[w];
  550.             }
  551.         }
  552.        
  553.         return q; //or do we want to return as ffc?
  554.     }
  555.    
  556.     if ( quit_on_failure ) Quit();
  557.     else return Debug->Null();
  558. }
  559.  
  560. /*
  561.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  562.     You may set the invisible combo manually. Will default to the constant in struct RunFFC.
  563.     [ example--
  564.         RunFFC("scriptname", {1,2,3,4,5,6,7}, CMB_CUSTOM_INVISIBLE);  
  565.             //Will use a user-set invisible combo.
  566.     --end example]
  567. */
  568.  
  569. int RunFFC(int scriptname, float init_d_ptr, int cmb)
  570. {
  571.     int id = Game->GetFFCScript(scriptname);
  572.     if( id <= 0 ) return 0;
  573.     if ( is > 511 ) return 0;
  574.    
  575.     ffc f = Debug->Null();
  576.     if ( cmb <= 0 ) cmb = RunFFC.CMB_INVIS;
  577.    
  578.     for ( int q = RunFFC.MIN_INDEX; q <= RunFFC.MAX_INDEX; --q )
  579.     {
  580.         f = Screen->LoadFFC(q);
  581.        
  582.         if ( f->Data !=0 ) continue;
  583.         //Do we really want to latch onto ffcs with an invis combo set?
  584.         //Scripts should clear that with EndFFC!
  585.         if ( f->Script !=0 ) continue;
  586.         if ( f->Flags[FFCF_CHANGER] ) continue;
  587.  
  588.         f->Data = cmb;
  589.         f->Script = id;
  590.  
  591.        
  592.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  593.         {
  594.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  595.             {
  596.                 f->InitD[w] = init_d_ptr[w];
  597.             }
  598.                
  599.         }
  600.        
  601.         return q; //or do we want to return as ffc?
  602.     }
  603.    
  604.  
  605.     return Debug->Null();
  606. }
  607.  
  608.  
  609. /*
  610.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  611.     You may set the invisible combo manually. Will default to the constant in struct RunFFC.
  612.     Can be set to quit a running script if the script calls it, but
  613.     cannot find a free ffc on the screen.
  614.     [ example--
  615.         RunFFC("scriptname", {1,2,3,4,5,6,7}, CMB_CUSTOM_INVISIBLE, true);  
  616.             //Will use a user-set invisible combo.
  617.             //Will quit the script on failure.
  618.     --end example]
  619. */
  620.  
  621. int RunFFC(int scriptname, float init_d_ptr, int cmb, bool quit_on_failure)
  622. {
  623.     int id = Game->GetFFCScript(scriptname);
  624.     if( id <= 0 ) return 0;
  625.     if ( is > 511 ) return 0;
  626.    
  627.     ffc f = Debug->Null();
  628.     if ( cmb <= 0 ) cmb = RunFFC.CMB_INVIS;
  629.    
  630.     for ( int q = RunFFC.MIN_INDEX; q <= RunFFC.MAX_INDEX; ++q )
  631.     {
  632.         f = Screen->LoadFFC(q);
  633.        
  634.         if ( f->Data !=0 ) continue;
  635.         //Do we really want to latch onto ffcs with an invis combo set?
  636.         //Scripts should clear that with EndFFC!
  637.         if ( f->Script !=0 ) continue;
  638.         if ( f->Flags[FFCF_CHANGER] ) continue;
  639.  
  640.         f->Data = cmb;
  641.         f->Script = id;
  642.  
  643.        
  644.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  645.         {
  646.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  647.             {
  648.                 f->InitD[w] = init_d_ptr[w];
  649.             }
  650.         }
  651.        
  652.         return q; //or do we want to return as ffc?
  653.     }
  654.    
  655.     if ( quit_on_failure ) Quit();
  656.     else return Debug->Null();
  657. }
  658.  
  659. /*
  660.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  661.     You may set the minimum, and the maximum screen indices that it tries to use, manually.
  662.     It will default to the constantas in struct RunFFC, if these values are set out of bounds.
  663.     [ example--
  664.         RunFFC("scriptname", {1,2,3,4,5,6,7}, 3, 19);  
  665.             //Will only check FFC Ids 3 to 19.
  666.     --end example]
  667. */
  668.  
  669. int RunFFC(int scriptname, float init_d_ptr, int min_index, int max_index)
  670. {
  671.     int id = Game->GetFFCScript(scriptname);
  672.     if( id <= 0 ) return 0;
  673.     if ( is > 511 ) return 0;
  674.    
  675.     ffc f = Debug->Null();
  676.     if ( min_index > max_index )
  677.     {
  678.         //reversed args sanity check
  679.         int swp = min_index;
  680.         max_index = min_index;
  681.         min_index = swp;
  682.     }
  683.     if ( min_index < 1 ) min_index = RunFFC.MIN_INDEX;
  684.     if ( max_index > 32 ) min_index = RunFFC.MAX_INDEX;
  685.    
  686.     for ( int q = min_index; q <= max_index; ++q )
  687.     {
  688.         f = Screen->LoadFFC(q);
  689.        
  690.         if ( f->Data !=0 ) continue;
  691.         //Do we really want to latch onto ffcs with an invis combo set?
  692.         //Scripts should clear that with EndFFC!
  693.         if ( f->Script !=0 ) continue;
  694.         if ( f->Flags[FFCF_CHANGER] ) continue;
  695.  
  696.         f->Data = RunFFC.CMB_INVIS;
  697.         f->Script = id;
  698.  
  699.        
  700.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  701.         {
  702.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  703.             {
  704.                 f->InitD[w] = init_d_ptr[w];
  705.             }              
  706.         }
  707.        
  708.         return q; //or do we want to return as ffc?
  709.     }
  710.    
  711.  
  712.     return Debug->Null();
  713. }
  714.  
  715. /*
  716.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  717.     You may set the minimum, and the maximum screen indices that it tries to use, manually.
  718.     Will default to the min and max slot constants in struct RunFFC, if the values set aren't
  719.     in bounds; and it will further accept slot args in reverse-order.
  720.     It will default to the constants in struct RunFFC, if these values are set out of bounds.
  721.     Can be set to quit a running script if the script calls it, but
  722.     cannot find a free ffc on the screen.
  723.     [ example--
  724.         RunFFC("scriptname", {1,2,3,4,5,6,7}, 3, 19, true);  
  725.             //Will only check FFC Ids 3 to 19.
  726.             //Will quit the script on failure.
  727.     --end example]
  728. */
  729.  
  730. int RunFFC(int scriptname, float init_d_ptr, int min_index, int max_index, bool quit_on_failure)
  731. {
  732.     int id = Game->GetFFCScript(scriptname);
  733.     if( id <= 0 ) return 0;
  734.     if ( is > 511 ) return 0;
  735.    
  736.     if ( min_index > max_index )
  737.     {
  738.         //reversed args sanity check
  739.         int swp = min_index;
  740.         max_index = min_index;
  741.         min_index = swp;
  742.     }
  743.     ffc f = Debug->Null();
  744.     if ( min_index < 1 ) min_index = RunFFC.MIN_INDEX;
  745.     if ( max_index > 32 ) min_index = RunFFC.MAX_INDEX;
  746.    
  747.     for ( int q = min_index; q <= max_index; ++q )
  748.     {
  749.         f = Screen->LoadFFC(q);
  750.        
  751.         if ( f->Data !=0 ) continue;
  752.         //Do we really want to latch onto ffcs with an invis combo set?
  753.         //Scripts should clear that with EndFFC!
  754.         if ( f->Script !=0 ) continue;
  755.         if ( f->Flags[FFCF_CHANGER] ) continue;
  756.  
  757.         f->Data = RunFFC.CMB_INVIS;
  758.         f->Script = id;
  759.  
  760.        
  761.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  762.         {
  763.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  764.             {
  765.                 f->InitD[w] = init_d_ptr[w];
  766.             }              
  767.         }
  768.        
  769.         return q; //or do we want to return as ffc?
  770.     }
  771.    
  772.     if ( quit_on_failure ) Quit();
  773.     else return Debug->Null();
  774. }
  775.  
  776. /*
  777.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  778.     You may set the invisible combo manually. Will default to the constant in struct RunFFC.
  779.     You may set the minimum, and the maximum screen indices that it tries to use, manually.
  780.     It will default to the constants in struct RunFFC, if these values are set out of bounds.
  781.     Will default to the min and max slot constants in struct RunFFC, if the values set aren't
  782.     in bounds; and it will further accept slot args in reverse-order.
  783.    
  784.         RunFFC("scriptname", {1,2,3,4,5,6,7}, CMB_CUSTOM_INVISIBLE, 3, 19);  
  785.             //Will use a user-set invisible combo.
  786.             //Will only check FFC Ids 3 to 19.
  787.             //Will quit the script on failure.
  788.     [ example--
  789.                                
  790.     --end example]
  791. */
  792.  
  793. int RunFFC(int scriptname, float init_d_ptr, int cmb, int min_index, int max_index)
  794. {
  795.     int id = Game->GetFFCScript(scriptname);
  796.     if( id <= 0 ) return 0;
  797.     if ( is > 511 ) return 0;
  798.    
  799.     if ( min_index > max_index )
  800.     {
  801.         //reversed args sanity check
  802.         int swp = min_index;
  803.         max_index = min_index;
  804.         min_index = swp;
  805.     }
  806.     ffc f = Debug->Null();
  807.     if ( cmb <= 0 ) cmb = RunFFC.CMB_INVIS;
  808.     if ( min_index < 1 ) min_index = RunFFC.MIN_INDEX;
  809.     if ( max_index > 32 ) min_index = RunFFC.MAX_INDEX;
  810.    
  811.     for ( int q = min_index; q <= max_index; ++q )
  812.     {
  813.         f = Screen->LoadFFC(q);
  814.        
  815.         if ( f->Data !=0 ) continue;
  816.         //Do we really want to latch onto ffcs with an invis combo set?
  817.         //Scripts should clear that with EndFFC!
  818.         if ( f->Script !=0 ) continue;
  819.         if ( f->Flags[FFCF_CHANGER] ) continue;
  820.  
  821.         f->Data = cmb;
  822.         f->Script = id;
  823.  
  824.        
  825.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  826.         {
  827.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  828.             {
  829.                 f->InitD[w] = init_d_ptr[w];
  830.             }              
  831.         }
  832.        
  833.         return q; //or do we want to return as ffc?
  834.     }
  835.    
  836.  
  837.     return Debug->Null();
  838. }
  839.  
  840. /*
  841.     Runs an ffc script `scriptname` with InitD[] set to `{array}`
  842.     You may set the invisible combo manually. Will default to the constant in struct RunFFC.
  843.     You may set the minimum, and the maximum screen indices that it tries to use, manually.
  844.     It will default to the constants in struct RunFFC, if these values are set out of bounds.
  845.     Will default to the min and max slot constants in struct RunFFC, if the values set aren't
  846.     in bounds; and it will further accept slot args in reverse-order.
  847.     Can be set to quit a running script if the script calls it, but
  848.     cannot find a free ffc on the screen.
  849.     [ example--
  850.         RunFFC("scriptname", {1,2,3,4,5,6,7}, CMB_CUSTOM_INVISIBLE, 3, 19, true);  
  851.             //Will only check FFC Ids 3 to 19.
  852.             //Will quit the script on failure.
  853.     --end example]
  854. */
  855.  
  856. int RunFFC(int scriptname, float init_d_ptr, int cmb, int min_index, int max_index, bool quit_on_failure)
  857. {
  858.     int id = Game->GetFFCScript(scriptname);
  859.     if( id <= 0 ) return 0;
  860.     if ( is > 511 ) return 0;
  861.    
  862.     if ( min_index > max_index )
  863.     {
  864.         //reversed args sanity check
  865.         int swp = min_index;
  866.         max_index = min_index;
  867.         min_index = swp;
  868.     }
  869.     ffc f = Debug->Null();
  870.     if ( cmb <= 0 ) cmb = RunFFC.CMB_INVIS;
  871.     if ( min_index < 1 ) min_index = RunFFC.MIN_INDEX;
  872.     if ( max_index > 32 ) min_index = RunFFC.MAX_INDEX;
  873.    
  874.     for ( int q = min_index; q <= max_index; ++q )
  875.     {
  876.         f = Screen->LoadFFC(q);
  877.        
  878.         if ( f->Data !=0 ) continue;
  879.         //Do we really want to latch onto ffcs with an invis combo set?
  880.         //Scripts should clear that with EndFFC!
  881.         if ( f->Script !=0 ) continue;
  882.         if ( f->Flags[FFCF_CHANGER] ) continue;
  883.  
  884.         f->Data = cmb;
  885.         f->Script = id;
  886.  
  887.        
  888.         if( init_d_ptr > 0 ) //!= NULL would permit assigning negative values here.
  889.         {
  890.             for ( int w = Min(SizeOfArray(init_d_ptr)-1, 7); w >= 0; --w )
  891.             {
  892.                 f->InitD[w] = init_d_ptr[w];
  893.             }
  894.         }
  895.        
  896.         return q; //or do we want to return as ffc?
  897.     }
  898.    
  899.     if ( quit_on_failure ) Quit();
  900.     else return Debug->Null();
  901. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement