Advertisement
ZoriaRPG

NES Zelda Drops v0.1 for 2.55

Feb 17th, 2019
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.18 KB | None | 0 0
  1. //Zelda 1 Style Random drops
  2. //v0.1
  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;
  13.     const int DROPSET_A = 0;
  14.     const int DROPSET_B = 1;
  15.     const int DROPSET_C = 2;
  16.     const int DROPSET_D = 3;
  17.     const int DROPSET_X = 4;
  18.     const int DROPSET_M = 5; MAGIC, 100%
  19.     const int DROP_X_OFS = 0;
  20.     const int DROP_Y_OFS = 0;
  21.    
  22.     int chances[] = {31,41,59,41, 0, 100};
  23.     int lists[4*10]=
  24.     {
  25.         I_RUPEE, I_HEART, I_RUPEE, I_FAIRY, I_RUPEE, I_HEART, I_HEART, I_RUPEE, I_HEART, I_HEART,
  26.         I_BOMB, I_RUPEE, I_CLOCK, I_RUPEE, I_HEART, I_BOMB, I_RUPEE, I_BOMB, I_HEART, I_HEART,
  27.         I_RUPEE, I_HEART, I_RUPEE, I_RUPEE5, I_HEART, I_CLOCK, I_RUPEE, I_RUPEE, I_RUPEE, I_RUPEE5,
  28.         I_HEART, I_FAIRY. I_RUPEE, I_HEART, I_FAIRY, I_HEART, I_HEART, I_HEART, I_RUPEE, I_HEART
  29.     };
  30.     //The dropset that a given enemy uses; SPLITTERS NEED SPECIAL HANDLING?
  31.     int enemydropsets[]=
  32.     {
  33.         //guys
  34.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  35.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  36.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  37.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  38.        
  39.         //enemies start here
  40.         DROPSET_A, DROPSET_B, DROPSET_A, DROPSET_B, DROPSET_A,
  41.         DROPSET_C, DROPSET_C, DROPSET_A, DROPSET_A, DROPSET_B,
  42.         DROPSET_D, DROPSET_C, DROPSET_D, DROPSET_D, DROPSET_X,
  43.                //GHINI2 ?PHANTOM
  44.         DROPSET_C, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  45.         DROPSET_X, DROPSET_C, DROPSET_X, DROPSET_C, DROPSET_C,
  46.         DROPSET_B, DROPSET_D, DROPSET_X, DROPSET_C, DROPSET_B,
  47.         DROPSET_D, DROPSET_X, DROPSET_B, DROPSET_X, DROPSET_B,
  48.         DROPSET_C, DROPSET_B, DROPSET_A, DROPSET_D, DROPSET_D,MOLDORM
  49.         DROPSET_D, DROPSET_D, DROPSET_D, DROPSET_D, DROPSET_D,
  50.         DROPSET_D, DROPSET_X, DROPSET_X, DROPSET_D, DROPSET_D,
  51.         DROPSET_D, DROPSET_D, DROPSET_D, DROPSET_D, DROPSET_D, //LANMOLA
  52.         DROPSET_C, DROPSET_D, DROPSET_D, DROPSET_X, DROPSET_C,
  53.         DROPSET_C, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  54.         DROPSET_X, DROPSET_B, DROPSET_D, DROPSET_X, DROPSET_X,
  55.         DROPSET_X, DROPSET_B, DROPSET_D, DROPSET_D, DROPSET_D,
  56.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_B,
  57.         DROPSET_A, DROPSET_C, DROPSET_C, DROPSET_D, DROPSET_D,
  58.         DROPSET_D, DROPSET_M, DROPSET_A, DROPSET_A, DROPSET_D,
  59.         DROPSET_D, DROPSET_D, DROPSET_D, DROPSET_A, DROPSET_D,
  60.         DROPSET_D, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  61.         DROPSET_C, DROPSET_D, DROPSET_D, DROPSET_X, DROPSET_X,
  62.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  63.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  64.         DROPSET_X, DROPSET_D, DROPSET_A, DROPSET_B, DROPSET_B,
  65.         DROPSET_B, DROPSET_B, DROPSET_X, DROPSET_X, DROPSET_X,
  66.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  67.         DROPSET_X, DROPSET_X, DROPSET_B, DROPSET_A, DROPSET_X,
  68.         DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
  69.         DROPSET_X, DROPSET_X, DROPSET_C, DROPSET_X, DROPSET_C,
  70.         DROPSET_A, DROPSET_X, DROPSET_X, DROPSET_D, DROPSET_D,
  71.         DROPSET_M, DROPSET_C, DROPSET_D, DROPSET_D, DROPSET_M,
  72.         DROPSET_X, DROPSET_X, DROPSET_X
  73.    
  74.     };
  75.     int getChance(int enemyid)
  76.     {
  77.         return chances[enemydropsets[enemyid]];
  78.     }
  79.     bool canDrop(int enemy_id)
  80.     {
  81.         return ( Rand(1,100) <= getChance(enemy_id) );
  82.     }
  83.     void doDrop(npc n)
  84.     {
  85.         if ( n->HP > 0 ) return; //wait until dead
  86.         bool ignore = false;
  87.         switch(n->Family)
  88.         {
  89.             case NPCT_MOLDORM:
  90.             case NPCT_MANHANDLA:
  91.             case NPCT_GLEEOK:
  92.             case NPCT_LANMOLA:
  93.             case NPCT_PATRA:
  94.             {
  95.                 if ( !n->isCore ) ignore = true; break;
  96.             }
  97.             case NPCT_DODONGO: ignore = true; break; //These never drop items, AFAIK.
  98.             default: break;
  99.        
  100.         }
  101.         if ( !ignore )
  102.         {
  103.             if ( canDrop(n->ID) )
  104.             {
  105.                
  106.                 item drp = Screen->CreateItem(lists[enemydropsets[n->ID]+killcount]);
  107.                 drp->X = n->X + DROP_X_OFS; drp->Y = n->Y + DROP_Y_OFS;
  108.                 drp->Pickup = IP_TIMEOUT;
  109.                 ( killcount < 9 ) ? ++killcount : killcount = 0;
  110.             }
  111.         }
  112.     }
  113.     void resetKillcount()
  114.     {  
  115.         if ( Link->InvFrames ) killcount = 0;
  116.     }
  117.    
  118. }
  119.  
  120. link script LinkZ1
  121. {
  122.     void run()
  123.     {
  124.         while(1)
  125.         {
  126.             Z1enemydrop.resetKillcount();
  127.             for ( int q = Screen->NumNPCs(); q > 0; --q )
  128.             {
  129.                 npc n = Screen->LoadNPC(q);
  130.                 Z1enemydrop.doDrop(n);
  131.             }
  132.    
  133.    
  134.     }
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement