ZoriaRPG

Level Screen Intros (v0.3) for 2.55 for SkyLizardGirl, v0.2

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