Advertisement
ZoriaRPG

More Sensitive Step Combos v0.5

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