Advertisement
ZoriaRPG

More Sensitive Step Combos

Jul 15th, 2018
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.14 KB | None | 0 0
  1. //import "std.zh"
  2.  
  3. // More Sensitive Step Combos
  4. // v0.6
  5. // 19th July, 2018
  6. // By: ZoriaRPG, requested by DarkMatt
  7.  
  8. const int CT_MISC_STEP_SRC = 250; //This type cannot be assigned in the EDITOR, but can be defined by script.
  9.     //In 2.54+, this type *can be* set in the editor.
  10. const int CT_MISC_STEP_DONE = 251;
  11. const int STEP_SENS_DEFAULT = 8; //pixels
  12.  
  13. global script test
  14. {
  15.     void run()
  16.     {
  17.         while(1)
  18.         {
  19.             steps.checks(STEP_SENS_DEFAULT);
  20.             Waitdraw();
  21.             Waitframe();
  22.         }
  23.     }
  24. }
  25.  
  26. ffc script steps
  27. {
  28.     void run(int sens)
  29.     {
  30.         sens = Cond(sens > 0, sens, STEP_SENS_DEFAULT);
  31.         int pos; int type; int w;
  32.         while(1)
  33.         {
  34.        
  35.             for ( pos = 0; pos < 176; ++pos )
  36.             {
  37.                 type = istype(pos);
  38.                 if ( type ) //assign is intentional
  39.                     // Sadly, i forgot that assign during a statement isn't yet supported.
  40.                 //if ( ( type = istype(pos,type) ) ) //assign is intentional
  41.                 {
  42.                     if ( coll(pos,sens) )
  43.                     {
  44.                         if ( type == CT_STEP )
  45.                         {
  46.                             ++Screen->ComboD[pos];
  47.                             for ( w = 0; w < 176; ++w )
  48.                             {
  49.                                 if ( w == pos ) continue;
  50.                                 if (istype(w) == CT_STEPCOPY )
  51.                                     ++Screen->ComboD[pos];
  52.                             }
  53.                                
  54.                         }
  55.                         if ( type == CT_STEPALL )
  56.                         {
  57.                             //find all identical combos
  58.                             for ( w = 0; w < 176; ++w )
  59.                             {
  60.                                 //if ( w == pos ) continue;
  61.                                 if (istype(w) == type )
  62.                                     ++Screen->ComboD[pos];
  63.                             }
  64.                         }
  65.                         if ( type == CT_STEPALL )
  66.                         {
  67.                             int dat = Screen->ComboD[pos];
  68.                             //find all identical combos
  69.                             for ( w = 0; w < 176; ++w )
  70.                             {
  71.                                 //if ( w == pos ) continue;
  72.                                 if (Screen->ComboD[w] == dat )
  73.                                     ++Screen->ComboD[pos];
  74.                             }
  75.                         }
  76.                         if ( type == CT_STRIGFLAG )
  77.                         {
  78.                             Screen->ComboT[pos] = CT_MISC_STEP_DONE;
  79.                             Screen->TriggerSecrets();
  80.                             Screen->State[ST_SECRET] = true;
  81.                             Game->PlaySound(SFX_SECRET);
  82.                         }
  83.                         if ( type == CT_TRIGFLAG )
  84.                         {
  85.                             Screen->ComboT[pos] = CT_MISC_STEP_DONE;
  86.                             Screen->TriggerSecrets();
  87.                             Screen->State[ST_SECRET] = true;
  88.                             Game->PlaySound(SFX_SECRET);
  89.                         }
  90.                         if ( type == CT_TRIGNOFLAG )
  91.                         {
  92.                             Screen->ComboT[pos] = CT_MISC_STEP_DONE;
  93.                             Screen->TriggerSecrets();
  94.                             Game->PlaySound(SFX_SECRET);
  95.                         }
  96.                         if ( type == CT_STRIGNOFLAG )
  97.                         {
  98.                             Screen->ComboT[pos] = CT_MISC_STEP_DONE;
  99.                             Screen->TriggerSecrets();
  100.                             Game->PlaySound(SFX_SECRET);
  101.                         }
  102.                     }
  103.                    
  104.                 }
  105.            
  106.             }
  107.             Waitframe();
  108.            
  109.         }
  110.        
  111.        
  112.     }
  113.     //Typecheck a combo type given as 'pos' (screen index 0->175) against a
  114.     //series of valid types.
  115.     //Returns the same type on success, otherwise 0.
  116.     int istype(int pos)
  117.     {
  118.         int t = Screen->ComboT[pos];
  119.         if ( t == CT_STEP ) return t;
  120.         if ( t == CT_STEPALL ) return t;
  121.         if ( t == CT_STEPSAME ) return t;
  122.         if ( t == CT_STEPCOPY ) return t;
  123.         if ( t == CT_STRIGFLAG ) return t; //Step (Secrets, Sensitive, Permanent)
  124.         if ( t == CT_STRIGNOFLAG ) return t; //Step (Secrets, Sensitive, Temporary)
  125.         if ( t == CT_TRIGFLAG ) return t; //Step (Secrets, Permanent)
  126.         if ( t == CT_TRIGNOFLAG ) return t; //Step (Secrets, Temporary)
  127.         return 0;
  128.     }
  129.  
  130.     //Marks a given combo position as a step source.
  131.     //Used for base step types that transfer their properties to other combos.
  132.     void mark(int pos)
  133.     {
  134.         Screen->ComboT[pos] = CT_MISC_STEP_SRC;
  135.     }
  136.     //Returns true is Link is stepping on a combo at position 'pos' within
  137.     //the given sensitivty 'sens' in pixels.
  138.     bool coll(int pos, int sens)
  139.     {
  140.  
  141.         if ( Abs(Link->X - ComboX(pos)) <= sens )
  142.         {
  143.             if ( Abs(Link->Y - ComboX(pos)) <= sens )
  144.             {
  145.                 return true;
  146.             }
  147.         }
  148.         return false;
  149.     }
  150.     //Runs the checks for the supported step cmbo types.
  151.     void checks(int sens)
  152.     {
  153.         sens = Cond(sens > 0, sens, STEP_SENS_DEFAULT); //assign the default if no other value is provided.
  154.         int pos; int type; int w;
  155.         //scan the 176 positions of the combo grid
  156.         for ( pos = 0; pos < 176; ++pos )
  157.         {
  158.             type = istype(pos);
  159.             //check if the current iteration position is a matching type
  160.             if ( type ) //assign is intentional
  161.             {
  162.                 //and if there is collision...
  163.                 if ( coll(pos,sens) )
  164.                 {
  165.                     ///based on the type, perform the requisite actions
  166.                     //to replicate engine behaviour
  167.                     if ( type == CT_STEP )
  168.                     {
  169.                         ++Screen->ComboD[pos]; //advance to the next combo
  170.                         //find copy and similar combo types that would be affected
  171.                         //at the same time, and apply the changes to those, too
  172.                         for ( w = 0; w < 176; ++w )
  173.                         {
  174.                             if ( w == pos ) continue; //ignore src combo
  175.                             if (istype(w) == CT_STEPCOPY )
  176.                                 ++Screen->ComboD[pos];
  177.                         }
  178.                            
  179.                     }
  180.                     if ( type == CT_STEPALL )
  181.                     {
  182.                         //find all identical combos and apply to them
  183.                         for ( w = 0; w < 176; ++w )
  184.                         {
  185.                             //if ( w == pos ) continue; //probably not here
  186.                             if (istype(w) == type )
  187.                                 ++Screen->ComboD[pos];
  188.                         }
  189.                     }
  190.                     if ( type == CT_STEPSAME )
  191.                     {
  192.                         int dat = Screen->ComboD[pos];
  193.                         //find all identical combos
  194.                         for ( w = 0; w < 176; ++w )
  195.                         {
  196.                             //if ( w == pos ) continue; probably not here, either
  197.                             if (Screen->ComboD[w] == dat )
  198.                                 ++Screen->ComboD[pos];
  199.                         }
  200.                     }
  201.                     //secret triggrs
  202.                     if ( type == CT_STRIGFLAG )
  203.                     {
  204.                         Screen->ComboT[pos] = CT_MISC_STEP_DONE;
  205.                         Screen->TriggerSecrets(); //triggers ALL secrets
  206.                         Screen->State[ST_SECRET] = true; //make them permanent
  207.                         Game->PlaySound(SFX_SECRET);
  208.                     }
  209.                     if ( type == CT_TRIGFLAG )
  210.                     {
  211.                         Screen->ComboT[pos] = CT_MISC_STEP_DONE;
  212.                         Screen->TriggerSecrets();
  213.                         Screen->State[ST_SECRET] = true;
  214.                         Game->PlaySound(SFX_SECRET);
  215.                     }
  216.                     //these two are temporary, so ST_SECRET is not set
  217.                     if ( type == CT_TRIGNOFLAG )
  218.                     {
  219.                         Screen->ComboT[pos] = CT_MISC_STEP_DONE;
  220.                         Screen->TriggerSecrets();
  221.                         Game->PlaySound(SFX_SECRET);
  222.                     }
  223.                     if ( type == CT_STRIGNOFLAG )
  224.                     {
  225.                         Screen->ComboT[pos] = CT_MISC_STEP_DONE;
  226.                         Screen->TriggerSecrets();
  227.                         Game->PlaySound(SFX_SECRET);
  228.                     }
  229.                 }
  230.                
  231.             }
  232.        
  233.         }
  234.     }
  235. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement