Advertisement
ZoriaRPG

ZScript: Z3 Style Lift and Throw Bombs (v0.3.1)

Nov 19th, 2016
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.78 KB | None | 0 0
  1. /////////////////////////////////////
  2. /// Z3 Style Lift and Throw Bombs ///
  3. /// v0.3.1 - 20-Nov-2016          ///
  4. /// By: ZoriaRPG                  ///
  5. /////////////////////////////////////
  6.  
  7.  
  8. int _____GRAM[21747];
  9. const int LINK_HOLDING_OBJ = 23012;
  10.  
  11. int LinkLiftingObject(){ return _____GRAM[LINK_HOLDING_OBJ]; }
  12. void LinkLiftingObject( bool set ) { if ( set ) _____GRAM[LINK_HOLDING_OBJ] = 1; else _____GRAM[LINK_HOLDING_OBJ] = 0; }
  13.  
  14. const int I_LINKLIFTING_TILEMOD = 200; //Ring that gives Link an LTM with lifting item tiles.
  15.  
  16. void LinkLifting(){
  17.     if ( LinkLiftingObject() && !Link->Item[I_LINKLIFTING_TILEMOD] ) Link->Item[I_LINKLIFTING_TILEMOD] = true;
  18.     if ( !LinkLiftingObject() && Link->Item[I_LINKLIFTING_TILEMOD] ) Link->Item[I_LINKLIFTING_TILEMOD] = false;
  19. }
  20.  
  21. global script lift{
  22.     void run(){
  23.         while(true){
  24.             BombLift();
  25.             LinkLifting();
  26.             Waitdraw();
  27.             Waitframe();
  28.         }
  29.     }
  30. }
  31.  
  32. const int FFC_BOMBLIFT_THROWDUR = 90; //Number of frames in the throw anim.
  33. const int DIST_BOMB_LIFT = 8;
  34. const int FFC_MISC_BOMBTIMER = 5;
  35. const int FFC_BOMBLIFT_TIME = 200;
  36. const int CMB_LITBOMB = 1000;
  37. const int CMB_LITBOMB_FLASHING = 1000;
  38. const int FFC_BOMBLIFT_Y_OFS = 16;
  39. const int FFC_BOMBLIFT_X_OFS = 4;
  40. const int FFC_BOMBLIFT_TIME_BEFORE_FLASH = 50;
  41. const int FFC_BOMBLIFT_EXPLODESPRITE_TIME = 30; //Frames of the LW_SPARKLE sprite animation.
  42. const int SPRITE_THROWNBOMB_BOOM = 50; //Sprite of the LW_SPARKLE weapon
  43. const int FFC_BOMBLIFT_TIME_EXPLODE_AT = 2;
  44.  
  45.  
  46. void BombLift(){
  47.     for ( int q = Screen->NumLWeapons(); q > 0; q--) {
  48.         lweapon l = Screen->LoadLWeapon(q);
  49.         if ( l->ID == LW_BOMB && LinkFacing(l) && DistXY(l,DIST_BOMB_LIFT) && Link->PressA && !LinkLiftingObject() ) {
  50.             LinkLiftingObject(true);
  51.             int f[]="BombLiftFFC";
  52.             int ff = Game->GetFFCScript(f);
  53.             RunFFCScript(ff,NULL);
  54.             Remove(l);
  55.         }
  56.     }
  57. }
  58.  
  59. ffc script BombLiftFFC{
  60.     void run(){
  61.         //ffc->Misc holds the timer
  62.         this->Misc[FFC_MISC_BOMBTIMER] = FFC_BOMBLIFT_TIME;
  63.         this->Data = CMB_LITBOMB;
  64.         int throwdir = -100; int q[4]; //q[1] = throwdir
  65.         while(this->Misc[FFC_MISC_BOMBTIMER]--){
  66.             if ( this->Misc[FFC_MISC_BOMBTIMER] <= FFC_BOMBLIFT_TIME_BEFORE_FLASH && this->Misc[FFC_MISC_BOMBTIMER] < 1 ) this->Data = CMB_LITBOMB_FLASHING;
  67.             if ( throwdir < 0 && throwdir > -200 ) {
  68.                 this->X = Link->X + FFC_BOMBLIFT_X_OFS;
  69.                 this->Y = Link->Y - FFC_BOMBLIFT_Y_OFS;
  70.             }
  71.             //Link->Action = LA_CASTING;
  72.             //Change Link's TIile somehow.
  73.             //I usually make him invisible, and draw tiles.
  74.             //but you can also do CopyTile here.
  75.             //LA_CASTING may work.
  76.             if ( Link->PressA || Link->PressB ) thorowdir = Link->Dir;
  77.             if ( throwdir > -1 ) {
  78.                 LinkLiftingObj(false); //Mark that Link is no longer lifting an object.
  79.                 ////Throw the bomb in an arc based on the value of throwdir.
  80.                 q[0] = FFC_BOMBLIFT_THROWDUR;
  81.                 while ( q[0]-- ) { //throw it and time thre throw
  82.                     if ( throwdir == DIR_UP ) this->Y--;
  83.                     if ( throwdir == DIR_DOWN ) this->Y++;
  84.                     if ( throwdir == DIR_LEFT ) this->X--;
  85.                     if ( throwdir == DIR_RIGHT) this->X++;
  86.                     Waitframe();
  87.                 }  
  88.  
  89.                 //if we reach the end of the arc, mark throwdir as stopped
  90.                 //End of arc
  91.                 throwdir = -200;
  92.             }
  93.            
  94.            
  95.             if ( this->Misc[FFC_MISC_BOMBTIMER] <= FFC_BOMBLIFT_TIME_EXPLODE_AT ) {
  96.                
  97.                 this->Data = FFC_INVISIBLE_COMBO;
  98.                 lweapon boomsprite = Screen->CreateLWeapon(LW_SPARKLE);
  99.                 boomsprite->>UseSprite(SPRITE_THROWNBOMB_BOOM);
  100.                
  101.                 Waitframes(FFC_BOMBLIFT_EXPLODESPRITE_TIME); //Wait for the explosion anim to end.
  102.                
  103.                 if ( !throwdir ) LinkLiftingObject(false);
  104.                 lweapon boom = Screen->CreateLWeapon(LW_BOMBBLAST);
  105.                 l->X = this->X;
  106.                 l->Y = this->Y;
  107.                 Waitframe();
  108.                 this->Data = 0; this->Script = 0; Quit();
  109.                
  110.             Waitframe();
  111.         }
  112.        
  113.     }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement