Advertisement
ZoriaRPG

[2.54] Scripted Subscreen Example

Dec 23rd, 2016
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.02 KB | None | 0 0
  1. //Sprite
  2. const int SUBSC_CURSOR_SPR = 66;
  3. //Sounds
  4. const int SUBSC_CURSOR_SFX = 63;
  5. const int SUBSC_CLOSE_SFX = 65;
  6. const int SUBSC_SELECTED_SFX = 66;
  7. const int SUBSC_OPEN_SFX = 67;
  8.  
  9. ffc script SubscreenScript{
  10.     void run(){
  11.         bool active = true;
  12.         int x = 30; int y = 20;
  13.         int q[265]; itemdata id[24]; item i[25]; lweapon cursor;
  14.         int selected = -1; int lastselected = -1;
  15.         int sfxtimer; int cursortimer;
  16.         int cursorinitpos[2];
  17.         int subscreenitems[240]={I_SWORD, I_SWORD2, I_SWORD3, I_SWORD4, I_BRANG1, I_BRANG2
  18.                     I_CANDLE1, I_CANDLE2, I_BOMB, I_SBOMB, I_HAMMER, I_CBYRNA,
  19.                     I_BOOTS, I_BOW2, I_FLIPPERS, I_LADDER, I_HOOKSHOT, I_POTION1,
  20.                     I_POTION2, I_SHIELD, I_WAND, I_WHISTLE, I_MAP, I_BAIT};
  21.             //put the items on the screen.
  22.         for ( q[0] = 0; q[0] < 24; q[0]++ ) {
  23.             i[ q[0] ] = Screen->CreateItem( subscreenitems[ q[0] ]);
  24.             i[ q[0] ]->X = x;
  25.             i[ q[0] ]->Y = y;
  26.             i[ q[0] ]->Pickup = IP_DUMMY;
  27.            
  28.             if ( x < ( 30 + (18*6) )  x += 18;
  29.             else x = 30;
  30.             if ( y < ( 30 + (18*4) ) y += 18;
  31.             else y = 30;
  32.         }
  33.        
  34.         cursor = Screen->CreateLWeapon(LW_SCRIPT1);
  35.         cursor->UseSprite(SUBSC_CURSOR_SPR);
  36.        
  37.         //Find out what is in Link's B slot.
  38.         for ( q[3] = 0; q[3] < 24; q[3]++ ) {
  39.             if ( subscreenitems[q] == Link->ItemB ) { lastselected = subscreenitems[q]; selected =  subscreenitems[q]; }
  40.         }
  41.         //if nothing matches, check the A slot
  42.         for ( q[3] = 0; q[3] < 24; q[3]++ ) {
  43.             if ( subscreenitems[q] == Link->ItemA )  { lastselected = subscreenitems[q]; selected =  subscreenitems[q]; }
  44.         }
  45.         if ( selected == -1 || lastselected == -1 ) selected = 0; //Otherwise, start with item 0
  46.        
  47.         cursor->X = i[lastselected]->X;
  48.         cursor->Y = i[lastselected]->Y;
  49.        
  50.         Game->PlaySound(SUBSC_OPEN_SFX);
  51.         while(active){
  52.             if ( Link->PressRight ) {
  53.                 if ( selected < 24 ) {
  54.                     lastselected = selected;
  55.                     selected++;
  56.                     cursor->X = i[selected]->X;
  57.                     cursor->Y = i[selected]->Y;
  58.                     Game->PlaySound(SUBSC_CURSOR_SFX);
  59.                 }
  60.                 else {
  61.                     lastselected = selected;
  62.                     selected = 0;
  63.                     cursor->X = i[selected]->X;
  64.                     cursor->Y = i[selected]->Y;
  65.                     Game->PlaySound(SUBSC_CURSOR_SFX);
  66.                 }
  67.             }
  68.             if ( Link->PressLeft ) {
  69.                 if ( selected > 0 ) {
  70.                     lastselected = selected;
  71.                     selected--;
  72.                     cursor->X = i[selected]->X;
  73.                     cursor->Y = i[selected]->Y;
  74.                     Game->PlaySound(SUBSC_CURSOR_SFX);
  75.                 }
  76.                 else {
  77.                     lastselected = selected;
  78.                     selected = 23;
  79.                     cursor->X = i[selected]->X;
  80.                     cursor->Y = i[selected]->Y;
  81.                     Game->PlaySound(SUBSC_CURSOR_SFX);
  82.                 }
  83.             }
  84.             if ( Link->PressDown ) {
  85.                 if ( selected < 18 ) {
  86.                     lastselected = selected;
  87.                     selected += 6;
  88.                     cursor->X = i[selected]->X;
  89.                     cursor->Y = i[selected]->Y;
  90.                     Game->PlaySound(SUBSC_CURSOR_SFX);
  91.                 }
  92.                 else {
  93.                     lastselected = selected;
  94.                     selected = (24-selected);
  95.                     cursor->X = i[selected]->X;
  96.                     cursor->Y = i[selected]->Y;
  97.                     Game->PlaySound(SUBSC_CURSOR_SFX);
  98.                 }
  99.             }
  100.             if ( Link->PressUp ) {
  101.                 if ( selected > 5 ) {
  102.                     lastselected = selected;
  103.                     selected -= 6;
  104.                     cursor->X = i[selected]->X;
  105.                     cursor->Y = i[selected]->Y;
  106.                     Game->PlaySound(SUBSC_CURSOR_SFX);
  107.                 }
  108.                 else {
  109.                     lastselected = selected;
  110.                     selected = (Abs(selected-24));
  111.                     cursor->X = i[selected]->X;
  112.                     cursor->Y = i[selected]->Y;
  113.                     Game->PlaySound(SUBSC_CURSOR_SFX);
  114.                 }
  115.             }
  116.             if ( Link->PressA ) {
  117.                 Link->ItemA = i[selected]->ID;
  118.                 Game->PlaySound(SUBSC_SELECTED_SFX);
  119.             }
  120.             if ( Link->PressB ) {
  121.                 Link->ItemB = i[selected]->ID;
  122.                 Game->PlaySound(SUBSC_SELECTED_SFX);
  123.             }
  124.            
  125.             if ( Link->PressR ) {}  //pan to right page
  126.             if ( Link->PressL ) {} //pan to left page
  127.             if ( Link->PressStart || Link->InputStart ) {
  128.                 Link->InputStart = false;
  129.                 Link->PressStart = false;
  130.                 Game->PlaySound(SUBSC_CLOSE_SFX);
  131.                 for ( q[5] = 0; q[5] < 25; q[5]++ ) Remove(i[ q[5] ]);
  132.                 active = false;
  133.             }
  134.             Waitframe();
  135.         }
  136.         this->Data = 0; this->Script = 0; Quit();
  137.     }
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement