Advertisement
ZoriaRPG

Boss Spawner v4

Mar 5th, 2018
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.23 KB | None | 0 0
  1. //ZoriaRPG
  2. //Spawn an npc that never returns after death.
  3. //Set 'Run on Screen Init to TRUE.
  4. //v4 -6th March, 2018
  5.  
  6. const int NPC_MISC_BOSS_SPAWN_BIT_INDEX = 15; //The Misc[ index to use for this script.
  7. const int BOSS_SPAWN_SCREEN_D_BIT = 1;
  8. const int BOSS_SPAWN_SCREEN_D_REG = 1;
  9. ffc script spawn_boss {
  10.     void run( int enem_id, int reg, int bit )
  11.     //D0: THe ID of the enemy
  12.     //D1: A Screen->D register. Should be unique for this screen. Valid range is 0 to 7.
  13.     //D2: THe bit of the register. Should be unque per instance of this FFC on the screen.
  14.     //  This is a bit value, in decimal, so use powers of two.
  15.     //  The first instance of the ffc is 1, then 2, then 4, 8, 16.
  16.     {
  17.     if ( reg < 1 || reg > 7 ) reg = BOSS_SPAWN_SCREEN_D_REG;
  18.     if ( bit < 1 || bit > 16 ) bit = BOSS_SPAWN_SCREEN_D_BIT;
  19.         int q; npc n;
  20.         if ( GetScreenDBit(reg,bit) )
  21.         {
  22.             this->Data = 0; Quit();
  23.         }
  24.    
  25.     //close the shutters
  26.     for ( q = 0; q < 4; q++ )
  27.     {
  28.         if ( Screen->Door[q] == D_OPEN )
  29.         {
  30.             //play shutter sound
  31.             Game->PlaySound(9);
  32.             //close shutter
  33.             Screen->Door[q] = D_SHUTTER;
  34.        
  35.            
  36.         }
  37.     }
  38.         //Waitframes(5); //not here!
  39.    
  40.         n = Screen->CreateNPC(enem_id);
  41.         n->X = this->X; n->Y = this->Y; //Spawn the npc at the ffc coordinates.
  42.    
  43.     Waitframes(5); //here!
  44.    
  45.         while(NPCsAlive())
  46.         {
  47.             //While this npc is alive, loop.
  48.             Waitframe();
  49.         }
  50.         //this boss is dead.
  51.         SetScreenDBit(reg,bit,true); //Set the bit so that it never respawns.
  52.     //open the shutters
  53.     //close the shutters
  54.     for ( q = 0; q < 4; q++ )
  55.     {
  56.         if ( Screen->Door[q] == D_SHUTTER )
  57.         {
  58.             //play shutter sound
  59.             Game->PlaySound(9);
  60.             //close shutter
  61.             Screen->Door[q] = D_OPEN;
  62.         }
  63.     }
  64.         this->Data = 0; Quit(); //Clean up the ffc and free it.
  65.     }
  66. }
  67.  
  68. bool NPCsAlive()
  69. {
  70.     bool alive = false;
  71.     for ( int q = Screen->NumNPCs(); q > 0; --q )
  72.     {
  73.         npc n = Screen->LoadNPC(q);
  74.         if ( n->Type != NPCT_PROJECTILE )
  75.         {
  76.             if ( !(n->MiscFlags&NPCMF_NOT_BEATABLE) )
  77.             {
  78.                 if ( n->Type != NPCT_FAIRY )
  79.                 {
  80.                     if ( n->Type != NPCT_GUY )
  81.                     {
  82.                         alive = true;
  83.                     }
  84.                 }
  85.             }
  86.         }
  87.     }
  88.     return alive;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement