ZoriaRPG

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

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