Advertisement
ZoriaRPG

Boss Spawner v5

Mar 6th, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.27 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, int no_trap_link )
  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 ( no_trap_link ) break;
  29.         if ( Screen->Door[q] == D_OPEN )
  30.         {
  31.             //play shutter sound
  32.             Game->PlaySound(9);
  33.             //close shutter
  34.             Screen->Door[q] = D_SHUTTER;
  35.        
  36.            
  37.         }
  38.     }
  39.         //Waitframes(5); //not here!
  40.    
  41.         n = Screen->CreateNPC(enem_id);
  42.         n->X = this->X; n->Y = this->Y; //Spawn the npc at the ffc coordinates.
  43.    
  44.     Waitframes(5); //here!
  45.    
  46.         while(NPCsAlive())
  47.         {
  48.             //While this npc is alive, loop.
  49.             Waitframe();
  50.         }
  51.         //this boss is dead.
  52.         SetScreenDBit(reg,bit,true); //Set the bit so that it never respawns.
  53.     //open the shutters
  54.     //close the shutters
  55.     for ( q = 0; q < 4; q++ )
  56.     {
  57.         if ( Screen->Door[q] == D_SHUTTER )
  58.         {
  59.             //play shutter sound
  60.             Game->PlaySound(9);
  61.             //close shutter
  62.             Screen->Door[q] = D_OPEN;
  63.         }
  64.     }
  65.         this->Data = 0; Quit(); //Clean up the ffc and free it.
  66.     }
  67. }
  68.  
  69. bool NPCsAlive()
  70. {
  71.     bool alive = false;
  72.     for ( int q = Screen->NumNPCs(); q > 0; --q )
  73.     {
  74.         npc n = Screen->LoadNPC(q);
  75.         if ( n->Type != NPCT_PROJECTILE )
  76.         {
  77.             if ( !(n->MiscFlags&NPCMF_NOT_BEATABLE) )
  78.             {
  79.                 if ( n->Type != NPCT_FAIRY )
  80.                 {
  81.                     if ( n->Type != NPCT_GUY )
  82.                     {
  83.                         alive = true;
  84.                     }
  85.                 }
  86.             }
  87.         }
  88.     }
  89.     return alive;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement