Advertisement
ZoriaRPG

NES Zelda Drops v0.2 for 2.55

Feb 17th, 2019
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.51 KB | None | 0 0
  1. //Zelda 1 Style Random drops
  2. //v0.2
  3. //For 2.55
  4. //By: ZoriaRPG
  5. //17th February, 2019
  6.  
  7. script typedef ffc class;
  8.  
  9. class script Z1enemydrop
  10. {
  11.     void run(){}
  12.     int killcount[2];
  13.     const int KILL_NORMAL;
  14.     const int KILL_CONSEC;
  15.    
  16.     const int DROPSET_A = 0;
  17.     const int DROPSET_B = 1;
  18.     const int DROPSET_C = 2;
  19.     const int DROPSET_D = 3;
  20.     const int DROPSET_X = 4;
  21.     const int DROPSET_M = 5; MAGIC, 100%
  22.     const int DROP_X_OFS = 0;
  23.     const int DROP_Y_OFS = 0;
  24.    
  25.     int chances[] = {31,41,59,41, 0, 100};
  26.     int lists[4*10]=
  27.     {
  28.         I_RUPEE, I_HEART, I_RUPEE, I_FAIRY, I_RUPEE, I_HEART, I_HEART, I_RUPEE, I_HEART, I_HEART,
  29.         I_BOMB, I_RUPEE, I_CLOCK, I_RUPEE, I_HEART, I_BOMB, I_RUPEE, I_BOMB, I_HEART, I_HEART,
  30.         I_RUPEE, I_HEART, I_RUPEE, I_RUPEE5, I_HEART, I_CLOCK, I_RUPEE, I_RUPEE, I_RUPEE, I_RUPEE5,
  31.         I_HEART, I_FAIRY. I_RUPEE, I_HEART, I_FAIRY, I_HEART, I_HEART, I_HEART, I_RUPEE, I_HEART
  32.     };
  33.     //The dropset that a given enemy uses; SPLITTERS NEED SPECIAL HANDLING?
  34.     int enemydropsets[]=
  35.     {
  36.         //guys
  37.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  38.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  39.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  40.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  41.        
  42.         //enemies start here
  43.         DROPSET_A, DROPSET_B, DROPSET_A, DROPSET_B, DROPSET_A,
  44.         DROPSET_C, DROPSET_C, DROPSET_A, DROPSET_A, DROPSET_B,
  45.         DROPSET_D, DROPSET_C, DROPSET_D, DROPSET_D, DROPSET_X,
  46.                //GHINI2 ?PHANTOM
  47.         DROPSET_C, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  48.         DROPSET_X, DROPSET_C, DROPSET_X, DROPSET_C, DROPSET_C,
  49.         DROPSET_B, DROPSET_D, DROPSET_X, DROPSET_C, DROPSET_B,
  50.         DROPSET_D, DROPSET_X, DROPSET_B, DROPSET_X, DROPSET_B,
  51.         DROPSET_C, DROPSET_B, DROPSET_A, DROPSET_D, DROPSET_D,MOLDORM
  52.         DROPSET_D, DROPSET_D, DROPSET_D, DROPSET_D, DROPSET_D,
  53.         DROPSET_D, DROPSET_X, DROPSET_X, DROPSET_D, DROPSET_D,
  54.         DROPSET_D, DROPSET_D, DROPSET_D, DROPSET_D, DROPSET_D, //LANMOLA
  55.         DROPSET_C, DROPSET_D, DROPSET_D, DROPSET_X, DROPSET_C,
  56.         DROPSET_C, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  57.         DROPSET_X, DROPSET_B, DROPSET_D, DROPSET_X, DROPSET_X,
  58.         DROPSET_X, DROPSET_B, DROPSET_D, DROPSET_D, DROPSET_D,
  59.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_B,
  60.         DROPSET_A, DROPSET_C, DROPSET_C, DROPSET_D, DROPSET_D,
  61.         DROPSET_D, DROPSET_M, DROPSET_A, DROPSET_A, DROPSET_D,
  62.         DROPSET_D, DROPSET_D, DROPSET_D, DROPSET_A, DROPSET_D,
  63.         DROPSET_D, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  64.         DROPSET_C, DROPSET_D, DROPSET_D, DROPSET_X, DROPSET_X,
  65.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  66.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  67.         DROPSET_X, DROPSET_D, DROPSET_A, DROPSET_B, DROPSET_B,
  68.         DROPSET_B, DROPSET_B, DROPSET_X, DROPSET_X, DROPSET_X,
  69.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  70.         DROPSET_X, DROPSET_X, DROPSET_B, DROPSET_A, DROPSET_X,
  71.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  72.         DROPSET_X, DROPSET_X, DROPSET_C, DROPSET_X, DROPSET_C,
  73.         DROPSET_A, DROPSET_X, DROPSET_X, DROPSET_D, DROPSET_D,
  74.         DROPSET_M, DROPSET_C, DROPSET_D, DROPSET_D, DROPSET_M,
  75.         DROPSET_X, DROPSET_X, DROPSET_X
  76.    
  77.     };
  78.     int getChance(int enemyid)
  79.     {
  80.         return chances[enemydropsets[enemyid]];
  81.     }
  82.     bool canDrop(int enemy_id)
  83.     {
  84.         return ( Rand(1,100) <= getChance(enemy_id) );
  85.     }
  86.     void doDrop(npc n)
  87.     {
  88.         if ( n->HP > 0 ) return; //wait until dead
  89.         bool ignore = false;
  90.         switch(n->Family)
  91.         {
  92.             case NPCT_MOLDORM:
  93.             case NPCT_MANHANDLA:
  94.             case NPCT_GLEEOK:
  95.             case NPCT_LANMOLA:
  96.             case NPCT_PATRA:
  97.             {
  98.                 if ( !n->isCore ) ignore = true; break;
  99.             }
  100.             case NPCT_DODONGO: ignore = true; break; //These never drop items, AFAIK.
  101.             default: break;
  102.        
  103.         }
  104.         if ( !ignore )
  105.         {
  106.             if ( canDrop(n->ID) )
  107.             {
  108.                 int drp_itm_id = lists[enemydropsets[n->ID]+killcount[KILL_NORMAL]];
  109.                 switch(killcount[KILL_CONSEC])
  110.                 {
  111.                     begin insane Z1 consecutive drop rules.
  112.                     case 10: drp_itm_id = I_BOMBAMMO1; break;
  113.                     case 16: drp_itm_id = I_FAIRY; break;
  114.                     default: break;
  115.                    
  116.                     /*
  117.                     TO IMPLEMENT
  118.                     Advanced strategies: If a forced bomb/rupee or forced fairy drops,
  119.                     the consecutive counter for bombs/rupees is reset, but not the counter
  120.                     for fairies. So no matter how many hits you get on Manhandla with one
  121.                     well-placed bomb, the 10 count is reset after defeating him.
  122.                     The same is true of Dodongo. Likewise with a "Hippo Fairy"
  123.                     (going into a Patra with 7 on the consecutive counters, so that the
  124.                     Patra's center will be kill #16 and get a fairy), the bomb/rupee count
  125.                     resets to 0. Credit to Khananaphone for this discovery.
  126.                     This means that if you get a forced fairy drop, the next
  127.                     consecutive bomb/rupee kill will not be at 20. It will be at 26.
  128.                     So bomb/rupee drops work in one of two methods:
  129.  
  130.                         10, (Fairy at 16), 26, 36, 46...
  131.                         10, (Skip fairy at 16 by killing non-dropping enemy), 20, 30, 40...            
  132.                     */
  133.                 }
  134.                 item drp = Screen->CreateItem(drp_itm_id);
  135.                 drp->X = n->X + DROP_X_OFS; drp->Y = n->Y + DROP_Y_OFS;
  136.                 drp->Pickup = IP_TIMEOUT;
  137.                 ( killcount[KILL_NORMAL] < 9 ) ? ++killcount[KILL_NORMAL] : killcount[KILL_NORMAL] = 0;
  138.                 ++killcount[KILL_CONSEC]; //when does this roll over on the NES?
  139.             }
  140.         }
  141.     }
  142.     void resetKillcount()
  143.     {  
  144.         if ( Link->InvFrames ) killcount[KILL_CONSEC] = 0;
  145.     }
  146.    
  147. }
  148.  
  149. link script LinkZ1
  150. {
  151.     void run()
  152.     {
  153.         while(1)
  154.         {
  155.             Z1enemydrop.resetKillcount();
  156.             for ( int q = Screen->NumNPCs(); q > 0; --q )
  157.             {
  158.                 npc n = Screen->LoadNPC(q);
  159.                 Z1enemydrop.doDrop(n);
  160.             }
  161.    
  162.    
  163.     }
  164. }B
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement