ZoriaRPG

Level Screen Intros (v0.5) for 2.55 for SkyLizardGirl

Mar 9th, 2019
393
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //v0.5 - 9th march, 2019
  2. //Revision History
  3.  
  4. //v0.2
  5. //v0.3
  6. //v0.4 Fix compile
  7. //v0.5 Update DMaps after Levels in Link Active
  8.  
  9.  
  10. script typedef ffc struct;
  11. script typedef ffc class;
  12.  
  13. struct script locations
  14. {
  15.     enum{ curDMAP, curSCREEN, curLEVEL, pvsDMAP, pvsSCREEN, pvsLEVEL, locLAST};
  16.     int data[locLAST];
  17.     void run(){}
  18.     void clear() { for ( int q = 0; q < locLAST; ++q ) data[q] = 0; }
  19.     bool changed() { return ( Game->GetCurDMap() != data[curDMAP] || Game->GetCurScreen() != data[curSCREEN] ); }
  20.     bool dmapchanged() { return ( Game->GetCurDMap() != data[curDMAP] ); }
  21.     bool screenchanged() { return ( Game->GetCurScreen() != data[curSCREEN] ); }
  22.     bool levelchanged() { return ( Game->GetCurLevel() != data[curLEVEL] ); }
  23.     int priorDMap() { return ( data[pvsDMAP] ); }
  24.     void update()
  25.     {
  26.         data[pvsSCREEN] = data[curSCREEN];
  27.         data[pvsDMAP] = data[curDMAP];
  28.         data[curSCREEN] = Game->GetCurScreen();
  29.         data[curDMAP] = Game->GetCurDMap();
  30.     }
  31.     void update_dmap()
  32.     {
  33.         data[pvsDMAP] = data[curDMAP];
  34.         data[curDMAP] = Game->GetCurDMap();
  35.     }
  36.     void update_level()
  37.     {
  38.         data[pvsLEVEL] = data[curLEVEL];
  39.         data[curLEVEL] = Game->GetCurLevel();
  40.     }
  41.     void update_screen()
  42.     {
  43.         data[pvsSCREEN] = data[curSCREEN];
  44.         data[curSCREEN] = Game->GetCurScreen();
  45.     }
  46.    
  47. }
  48.  
  49. class script screenintros
  50. {
  51.     const int REGISTER = 6;
  52.     const int BIT = 2;
  53.     void run(){}
  54.     void clear()
  55.     {
  56.         for ( int q = 0; q < 0x80; ++q )
  57.         {
  58.             SetScreenDBit(locations.data[locations.pvsDMAP], q, REGISTER, BIT, false);
  59.         }
  60.     }
  61.     void update()
  62.     {
  63.    
  64.         if ( locations.levelchanged() )
  65.         {
  66.             locations.update_level();
  67.             locations.update_dmap();
  68.             clear(); //Re-display after changing dmaps, like DMap intros repeat, but for screens.
  69.         }
  70.     }
  71. }
  72.  
  73. link script active
  74. {
  75.     void run()
  76.     {
  77.         while(1)
  78.         {
  79.             screenintros.update();
  80.            
  81.             Waitframe();
  82.         }
  83.     }
  84. }
  85.  
  86. //Does not repeat if you revisit the screen, unless you change dmaps.
  87. ffc script screenmessage
  88. {
  89.  
  90.     const int REGISTER = 6;
  91.     const int BIT = 2;
  92.     const int DELAY_DEFAULT = 1;
  93.     void run(int delay, int reg, int bit )
  94.     {
  95.         reg = ( reg > 0 ) ? reg : REGISTER;
  96.         bit = ( bit > 0 ) ? reg : BIT;
  97.         delay = ( delay > 0 ) ? delay : DELAY_DEFAULT;
  98.        
  99.         while(1)
  100.         {
  101.             if ( !(GetScreenDBit(Game->GetCurDMap(), Game->GetCurScreen(), reg, bit)) )
  102.             {
  103.                 Waitframes(delay);
  104.                 Screen->Message(Screen->String);
  105.                 SetScreenDBit(Game->GetCurDMap(), Game->GetCurScreen(), reg, bit, true);
  106.             }
  107.             Waitframe();
  108.         }
  109.     }
  110. }
  111.  
  112. link script init
  113. {
  114.     void run()
  115.     {
  116.         locations.clear();
  117.         locations.clear(); //Call twice to push the previous screen down.
  118.     }
  119. }
  120.  
  121. ///////////////////////////
  122. /// NPC Script Room Guy ///
  123. /// v0.3                ///
  124. /// 8th March, 2019     ///
  125. /// By: ZoriaRPG        ///
  126. ///////////////////////////
  127.  
  128. //ZQuest Screen Menu Sets Options
  129. //Set Screen->String to the string to display
  130. //Set Screen->Catchall to the delay time, if the roomtype is none.
  131. //Otherwise, you can set a default delay on the enemy using D0.
  132.  
  133. //v0.2 Initial Fixes
  134. //v0.3 Added Once Only Behavioural Flag
  135.  
  136. npc script screenguy
  137. {
  138.     const int DELAY = 20; //Time to spawn.
  139.     const int BFLAG_ONCE = 4;
  140.     const int REGISTER = 6;
  141.     const int BIT = 2;
  142.     void run(int delay, int reg, int bit)
  143.     {
  144.         delay = this->InitD[0] > 0 ? delay : DELAY;
  145.         reg = this->InitD[1] > 0 ? reg : REGISTER;
  146.         bit = this->InitD[2] > 0 ? bit : BIT;
  147.        
  148.         if ( !Screen->RoomType )
  149.         {
  150.             if ( Screen->Catchall )
  151.             {
  152.                 delay = Screen->Catchall;
  153.             }
  154.         }
  155.         this->CollDetection = false;
  156.         //this->DrawYOffset = -32768;
  157.         //Waitframes(Screen->Catchall); //might be in use depending on room type
  158.         Waitframes(delay);
  159.        
  160.         if ( this->BFlags[BFLAG_ONCE] )
  161.         {
  162.             if ( !(GetScreenDBit(Game->GetCurDMap(), Game->GetCurScreen(), reg, bit)) )
  163.             {
  164.                 Screen->Message(Screen->String);
  165.                 SetScreenDBit(Game->GetCurDMap(), Game->GetCurScreen(), reg, bit, true);
  166.             }
  167.         }
  168.         else Screen->Message(Screen->String);
  169.     }
  170. }
RAW Paste Data