//SplitOnDeath ffc a[] //Loops const int SPLTR_Q = 0; const int SPLTR_W = 1; const int SPLTR_E = 2; const int SPLTR_R = 3; const int SPLTR_T = 4; const int SPLTR_Y = 5; const int SPLTR_U = 6; //X/Y Positions const int SPLTR_X = 7; const int SPLTR_Y = 8; //SplitOnHit fff n[] const int SPLTR_ENEM_BASE = 0; const int SPLTR_ENEM_REPL = 1; ffc script SplitOnHit { void run(int enem_id, int splits_into, int number_of_splits, int dist_flux ){ npc n[2]; int a[10]; Waitframes(5); //Enemies require five frames, to spawn. // If a 'No Return' flag is set, and there are no enemies on the screen, // cleanly exit the script and make the ffc slot available. if ( ( Screen->State[ST_ENEMYNORETURN] || Screen->State[ST_TEMPNORETURN] ) && !Screen->NumNPCs() ){ this->Data = 0; this->Script = 0; Quit(); } while(true){ for ( a[SPLTR_Q] = 1; a[SPLTR_Q] <= Screen->NumNPCs(); a[SPLTR_Q]++ ) { n[SPLTR_ENEM_BASE] = Screen->LoadNPC(a[SPLTR_Q]); if ( n[SPLTR_ENEM_BASE]->isValid() ) { // If it's dying, not removed, and the correct enemy ID... if ( n[SPLTR_ENEM_BASE]->ID == enem_id ) { //Read lweapons, check collision, and see if the weapon is blocked for ( a[6] = 1; a[6] <= Screen->NumLWeapons(); a[6]++ ) { //Read the lweapons on the screen, loadfing them lweapon l = Screen->LoadLWeapon(a[7]); if ( l->isValid() ) { //If it's valid if ( Collision(l,n[0]) { //Check for collision with that weapon and the enemy //Check if any of the defs block this weapon. if ( n[0]->Defense[ LWeaponToNPCD(l->ID) ] < 3 ) { //Can be damaged by the weapon for ( a[2] = 0; a[2] < list[a[0]+2]; a[2]++ ) { //Read how many enemies to make, and make one per iteration. a[3] = n->X; //Store its position, so that we know where to spawn its splits. a[4] = n->Y; n[0]->HitXOffset = -200; //Hide the source enemy. n[0]->HitYOffset = -200; n[0]->DrawXOffset = -200; n[0]->DrawYOffset = -200; n[1] = Screen->CreateNPC(list[a[0]+1]); //Reuse our pointer, instead of wasting one. n[1]->X = a[3]+Rand( (dist_flux * -1), dist_flux); n[1]->Y = a[4]+Rand( (dist_flux * -1), dist_flux); n[0]->HP = -9999; //Kill the original enemy. } } } } } } } } if ( ( Screen->State[ST_ENEMYNORETURN] || Screen->State[ST_TEMPNORETURN] ) && !Screen->NumNPCs() ) { this->Data = 0; this->Script = 0; Quit(); // Free up the slot if we're done. } Waitframe(); } } }