Advertisement
ZoriaRPG

ZScript Gust Jar (Item + FFC)

Nov 20th, 2016
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.98 KB | None | 0 0
  1. /// Gust Jar with FFC
  2. /// Brought to you by ZoriaRPG
  3.  
  4.  
  5. const int Jar_SPR = 101;
  6. const int Gust_SPR = 100;
  7. const int SFX_Gust = 92;
  8. const int WPN_MISC_GUST = 6;
  9. const int WPN_FLAG_GUST = 0100b;
  10. const int slot = 39;
  11. const int CF_FAN = 10000;
  12.  
  13. const int ____FFC_COMBO_INVISIBLE = 1;
  14.  
  15. const int GUSTJAR_DISPLAY_TIME = 120; //120 frames
  16.  
  17. item script GustGust{
  18.     void run(){
  19.         int ff[]="GustFFC"; //Type the name of the ffc script between the quotes.
  20.         int fff = Game->GetFFCScript(ff); //Get the script ID
  21.         if ( FindFFCRunning(fff) ) Quit(); //If the script is already running, halt now.
  22.        
  23.         ffc f; //Declare an ffc to use as a pointer.
  24.  
  25.         for(int q = 0; q <= 32; q++){ //Find an unused ffc...
  26.             f = Screen->LoadFFC(q);
  27.        
  28.             if (f->Script !=0 || (f->Data !=0 && f->Data != 1) || f->Flags[FFCF_CHANGER])
  29.             continue; //Don't use any that are already in use!
  30.        
  31.             f->Data = ____FFC_COMBO_INVISIBLE; //Give it an invisible combo that is not ID 0.
  32.             f->Script = fff; //Assign the ffc script slot to the gust jar ffc.
  33.         }
  34.     }
  35. }
  36.  
  37. ffc script GustFFC{
  38.     void run(){
  39.         int a[10]={GUSTJAR_DISPLAY_TIME}; //Let's hold all our values in one array; yes?
  40.         for ( a[1] = 1; a[1] <= 32; a[1]++ ) {
  41.             f = Screen->LoadFFC(q);
  42.             if ( f->Script == this->Script ) { this->Data = 0; this->Script = 0; Quit(); } //If there is another instance of this script, halt and exit.
  43.         }
  44.        
  45.         Link->Action = LA_ATTACKING;
  46.         Game->PlaySound(SFX_Gust);
  47.        
  48.         //Make the wind.
  49.         lweapon Gust = CreateLWeaponAt(LW_SCRIPT1, Link->X+InFrontX(Link->Dir, 0), Link->Y+InFrontY(Link->Dir, 0));
  50.         Gust->Damage = 0;
  51.         Gust->Misc[WPN_MISC_GUST] = WPN_FLAG_GUST;
  52.         Gust->UseSprite(Gust_SPR);
  53.         Gust->Dir = Link->Dir;
  54.         Gust->Step = 200;
  55.        
  56.         //Make the jar.
  57.         lweapon Jar = CreateLWeaponAt(LW_SCRIPT2, Link->X+InFrontX(Link->Dir, 4), Link->Y+InFrontY(Link->Dir, 4));
  58.         Jar->UseSprite(Jar_SPR);
  59.         Jar->CollDetection = false;
  60.        
  61.         //Orient the jar to match Link
  62.         if ( Link->Dir == DIR_DOWN ){
  63.             Jar->Flip = 2;
  64.         }
  65.         if ( Link->Dir == DIR_LEFT ){
  66.             Jar->Tile++;
  67.             Jar->Flip = 1;
  68.         }
  69.         if ( Link->Dir == DIR_RIGHT ){
  70.             Jar->Tile++;
  71.         }
  72.        
  73.         //FFC Magic Starts...
  74.        
  75.         while ( a[0] > 0 || Gust->isValid() ) { //If the wind is on-screen, or our timer hasn't expired...
  76.             if ( a[0] > 0 ) a[0]--; //Reduce the timer.
  77.            
  78.             //Orient the jar to face where Link faces
  79.             if ( Link->Dir == DIR_DOWN ){
  80.                 Jar->Flip = 2;
  81.             }
  82.             if ( Link->Dir == DIR_LEFT ){
  83.                 Jar->Tile++;
  84.                 Jar->Flip = 1;
  85.             }
  86.             if ( Link->Dir == DIR_RIGHT ){
  87.                 Jar->Tile++;
  88.             }
  89.             Jar->DeadState = -2; //Keep it alive.
  90.             Jar->X = Link->X+InFrontX(Link->Dir, 4); //Keep it at Link's position.
  91.             Jar->Y = Link->Y+InFrontY(Link->Dir, 4);
  92.            
  93.             //If the wind touches a fan, trigger the secrets.
  94.             if (ComboFI(ComboAt(Gust->X+8, Gust->Y+8),CF_FAN) ) {
  95.                 Screen->TriggerSecrets();
  96.             }  
  97.             Waitframe();               
  98.         }
  99.         Remove(Jar); //Eliminate the jar lweapon
  100.         this->Data = 0; this->Script = 0; Quit();
  101.     }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement