Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ZoriaRPG
- //Spawn an npc that never returns after death.
- //Set 'Run on Screen Init to TRUE.
- //v4 -6th March, 2018
- const int NPC_MISC_BOSS_SPAWN_BIT_INDEX = 15; //The Misc[ index to use for this script.
- const int BOSS_SPAWN_SCREEN_D_BIT = 1;
- const int BOSS_SPAWN_SCREEN_D_REG = 1;
- ffc script spawn_boss {
- void run( int enem_id, int reg, int bit )
- //D0: THe ID of the enemy
- //D1: A Screen->D register. Should be unique for this screen. Valid range is 0 to 7.
- //D2: THe bit of the register. Should be unque per instance of this FFC on the screen.
- // This is a bit value, in decimal, so use powers of two.
- // The first instance of the ffc is 1, then 2, then 4, 8, 16.
- {
- if ( reg < 1 || reg > 7 ) reg = BOSS_SPAWN_SCREEN_D_REG;
- if ( bit < 1 || bit > 16 ) bit = BOSS_SPAWN_SCREEN_D_BIT;
- int q; npc n;
- if ( GetScreenDBit(reg,bit) )
- {
- this->Data = 0; Quit();
- }
- //close the shutters
- for ( q = 0; q < 4; q++ )
- {
- if ( Screen->Door[q] == D_OPEN )
- {
- //play shutter sound
- Game->PlaySound(9);
- //close shutter
- Screen->Door[q] = D_SHUTTER;
- }
- }
- //Waitframes(5); //not here!
- n = Screen->CreateNPC(enem_id);
- n->X = this->X; n->Y = this->Y; //Spawn the npc at the ffc coordinates.
- Waitframes(5); //here!
- while(NPCsAlive())
- {
- //While this npc is alive, loop.
- Waitframe();
- }
- //this boss is dead.
- SetScreenDBit(reg,bit,true); //Set the bit so that it never respawns.
- //open the shutters
- //close the shutters
- for ( q = 0; q < 4; q++ )
- {
- if ( Screen->Door[q] == D_SHUTTER )
- {
- //play shutter sound
- Game->PlaySound(9);
- //close shutter
- Screen->Door[q] = D_OPEN;
- }
- }
- this->Data = 0; Quit(); //Clean up the ffc and free it.
- }
- }
- bool NPCsAlive()
- {
- bool alive = false;
- for ( int q = Screen->NumNPCs(); q > 0; --q )
- {
- npc n = Screen->LoadNPC(q);
- if ( n->Type != NPCT_PROJECTILE )
- {
- if ( !(n->MiscFlags&NPCMF_NOT_BEATABLE) )
- {
- if ( n->Type != NPCT_FAIRY )
- {
- if ( n->Type != NPCT_GUY )
- {
- alive = true;
- }
- }
- }
- }
- }
- return alive;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement