Advertisement
ZoriaRPG

Splitters Do Not Return v2

Nov 19th, 2016
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.28 KB | None | 0 0
  1. //D0: The ID of the enemy to remove.
  2. //D1: The enemi ID that the D0 splits into.
  3. //D2: the starting number of enemies on this screen (the number of times it is in the enemy list)
  4. //D3: The register to use to store enemy counts.
  5. //D4: the register to check for intialisation.
  6. //D5: Total number of lanmola enemies on the screen.
  7. //D6: Lanmola enemy ID.
  8. //D7: Register for tracking lanmolas.
  9.  
  10. ffc script RemoveKilledSpliiters{
  11.     void run(int enemID, int splitsInto, int startNum, int reg, int regInit, int totalLanmolas, int lanmolaID, int lanmolasReg){
  12.         int curNum = NumNPCsOf(enemID);
  13.         int presentMax = Screen->D[reg];
  14.         int children;
  15.         int numLanmolas;
  16.         Waitframes(5);
  17.         bool firstRun = true;
  18.         int segments;
  19.         if ( lanmolaID ) {
  20.             for ( int q = 1; q <= Screen->NumNPCs(); q++ ) {
  21.                 npc a = Screen->LoadNPC(q);
  22.                 if ( a->ID == lanmolaID ) {
  23.                     segments = a->Attributes[0] + 1;
  24.                     break;
  25.                 }
  26.             }
  27.         }
  28.        
  29.         float segs = segments / 10;
  30.         Screen->D[lanmolasReg] += segs;
  31.         int lanmolasValid = Floor(Screen->D[lanmolasReg]);
  32.         float deciSegs = ( Screen->D[lanmolasReg] - Floor(Screen->D[lanmolasReg]) ) * 10 ;
  33.        
  34.         while(true){
  35.             segments = deciSegs;
  36.             lanmolasValid = Floor(Screen->D[lanmolasReg]);
  37.            
  38.             if ( presentMax == 0 && Screen->D[regInit] == 0 ) {
  39.                 Screen->D[regInit] = 1;
  40.                 Screen->D[reg] = startNum;
  41.                 Trace(Screen->D[reg]);
  42.                 TraceNL();
  43.             }
  44.            
  45.             if ( lanmolasValid && NumNPCsOf(lanmolaID) == 0 && firstRun ) {
  46.                 Unsecret = true;
  47.                 for ( int q = ( Floor(Screen->D[lanmolasReg]) / segments ); q > 0; q-- ) {
  48.                     Screen->CreateNPC(lanmolaID);
  49.                 }
  50.                 firstRun = false;
  51.             }
  52.            
  53.            
  54.            
  55.            
  56.             curNum = NumNPCsOf(enemID);
  57.             presentMax = Screen->D[reg];
  58.             if ( presentMax == 0 && Screen->D[regInit] > 0 ) {
  59.                 for ( int q = 1; q <= Screen->NumNPCs(); q++ ) {
  60.                    
  61.                     npc n = Screen->LoadNPC(q);
  62.                     if ( n->ID == enemID ) Remove(n);
  63.                 }
  64.             }
  65.             curNum = NumNPCsOf(enemID);
  66.             children = NumNPCsOf(splitsInto);
  67.             if ( Screen->D[reg] > curNum+children ) Screen->D[reg] = curNum;
  68.            
  69.             if ( curNum > Screen->D[reg] ) {
  70.                 int diff = curNum - Screen->D[reg];
  71.                 int removed;
  72.                 for ( int q = 1; q <= Screen->NumNPCs(); q++ ) {
  73.                     if ( removed == diff ) break;
  74.                     npc n = Screen->LoadNPC(q);
  75.                     if ( enemID != lanmolaID ) {
  76.                         if ( n->ID == enemID ) {
  77.                             Remove(n);
  78.                             removed++;
  79.                         }
  80.                     }
  81.                 }
  82.             }
  83.             int lanmolasOffscreen;
  84.            
  85.             if ( curNum == totalLanmolas ) {
  86.                 for ( int q = 1; q <= Screen->NumNPCs(); q++ ) {
  87.                     npc n = Screen->LoadNPC(q);
  88.                     if ( n->ID == lanmolaID && n->X == -32768 ) lanmolasOffscreen++;
  89.                 }
  90.             }
  91.            
  92.             if ( lanmolasOffscreen == totalLanmolas ) {
  93.                 for ( ; lanmolasOffscreen < 0; lanmolasOffscreen -- ){
  94.                     npc n = Screen->LoadNPC(lanmolasOffscreen);
  95.                     n->HP = -9999;
  96.                 }
  97.             }
  98.            
  99.             lanmolasOffscreen = 0;
  100.            
  101.             Screen->D[lanmolasReg] = NumNPCsOf(lanmolaID) + ( segments / 10 );
  102.            
  103.             if ( !NumNPCsOf(lanmolaID) ) {
  104.                 Screen->D[lanmolasReg] = 0;
  105.                 //! Add secret triggers.
  106.             }
  107.            
  108.             Waitframe();
  109.         }
  110.     }
  111. }
  112.  
  113. bool Unsecret;
  114.  
  115. global script active{
  116.     void run(){
  117.         while(true){
  118.             if ( Unsecret ) {
  119.                 Screen->State[ST_SECRET] = false;
  120.                 Unsecret = false;
  121.                
  122.             }
  123.             Waitdraw();
  124.             Waitframe();
  125.         }
  126.     }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement