ZoriaRPG

Autofire (Cheap Method) for 2.54

Apr 25th, 2018
150
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. item script Bullet
  2. {
  3.      void run()
  4.      {
  5.           lweapon l = Screen->CreateLWeapon(Cond((this->Attributes[1] > 0), this->Attributes[1], LW_ARROW));
  6.           //Attributes[1] is the weapon type. Defaults to arrow.
  7.           int canrunffc =  0;
  8.           switch(Link->Dir)
  9.           {
  10.                case DIR_UP:
  11.                { l->X = Link->X -1; l->Y = Link->Y+8; break; }
  12.                case DIR_DOWN:
  13.                { l->X = Link->X +16; l->Y = Link->Y+8; break; }
  14.                case DIR_LEFT:
  15.                { l->X = Link->X +8; l->Y = Link->Y-1; break; }
  16.                case DIR_RIGHT:
  17.                { l->X = Link->X +8; l->Y = Link->Y+16; break; }
  18.                default:            
  19.                {
  20.                  l->X = Link->X; l->Y = Link->Y; TraceNL();
  21.                  TraceS("Invalid Link->Dir for item script Bullet");
  22.                  TraceNL(); break;
  23.                }
  24.           }
  25.           l->Dir = Link->Dir;
  26.           l->UseSprite(this->Sprites[0]);
  27.           Game->PlaySound(this->UseSound);
  28.           l->Step = this->Attributes[0];
  29.           l->Damage = this->Level; //Upgrade canon by level.
  30.           ffc f;
  31.           for ( int q = 1; q < 33; ++q )
  32.           {
  33.                f = Screen->LoadFFC(q);
  34.                if ( f->Flags&FFCF_ETHEREAL ) continue; //ethereal cannot run scripts.
  35.                if ( f->Data == 0 ) break; //find one with no running script.
  36.           }
  37.           if ( f->ID > 31 )
  38.           {
  39.                if ( f->Data > 0 ) { f->InitD[1]  = f->Data; }
  40.                if ( f->Script > 0 )
  41.                {
  42.                     TraceNL(); TraceS("Item script Bullet could not grab a free ffc.."); TraceNL();
  43.                }
  44.                else canrunffc = 1;
  45.           }
  46.           else canrunffc = 1;
  47.           if ( canrunffc )
  48.           {
  49.                if ( f->Data <= 0 ) { f->Data = CMB_INVIS; }
  50.                f->Script = Game->GetFFCScript("Autofire_Bullets");
  51.           }
  52.           if ( GetEquipmentA() == this->ID ) { f->InitD[0] = CB_A; }
  53.           else if ( GetEquipmentB() == this->ID ) { f->InitD[0] = CB_B; }
  54.           else { f->InitD[0] =-1; } //error finding button match ?!
  55.      } //end run()
  56. } // end item script
  57.  
  58. ffc script Autofire_Bullets
  59. {
  60.      void run(int controller_button, int olddata)
  61.      //olddata  is used if this ffc already had a combo set, but no script.
  62.      {
  63.           Input->Held[controller_button] = false;
  64.           if ( olddata <= 0 ) { this->Data = 0; }
  65.           Quit();
  66.                /*     We run out of scope here anyway,
  67.                         but it's safer, and clearer, to call Quit().
  68.                */
  69.      } //end run()
  70. } //end script
RAW Paste Data