ZoriaRPG icon

NES Zelda Drops v0.2 for 2.55

ZoriaRPG | PRO | 02/17/19 02:56:45 PM UTC | 0 ⭐ | 621 👁️ | Never ⏰ | []
C++ |

5.51 KB

|

None

|

0 👍

/

0 👎

//Zelda 1 Style Random drops
//v0.2
//For 2.55
//By: ZoriaRPG
//17th February, 2019 
 
script typedef ffc class;
 
class script Z1enemydrop
{
    void run(){}
    int killcount[2];
    const int KILL_NORMAL;
    const int KILL_CONSEC;
    
    const int DROPSET_A = 0;
    const int DROPSET_B = 1;
    const int DROPSET_C = 2;
    const int DROPSET_D = 3;
    const int DROPSET_X = 4;
    const int DROPSET_M = 5; MAGIC, 100%
    const int DROP_X_OFS = 0;
    const int DROP_Y_OFS = 0;
    
    int chances[] = {31,41,59,41, 0, 100};
    int lists[4*10]=
    {
        I_RUPEE, I_HEART, I_RUPEE, I_FAIRY, I_RUPEE, I_HEART, I_HEART, I_RUPEE, I_HEART, I_HEART,
        I_BOMB, I_RUPEE, I_CLOCK, I_RUPEE, I_HEART, I_BOMB, I_RUPEE, I_BOMB, I_HEART, I_HEART,
        I_RUPEE, I_HEART, I_RUPEE, I_RUPEE5, I_HEART, I_CLOCK, I_RUPEE, I_RUPEE, I_RUPEE, I_RUPEE5,
        I_HEART, I_FAIRY. I_RUPEE, I_HEART, I_FAIRY, I_HEART, I_HEART, I_HEART, I_RUPEE, I_HEART
    };
    //The dropset that a given enemy uses; SPLITTERS NEED SPECIAL HANDLING?
    int enemydropsets[]=
    {
        //guys
        DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
        DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
        DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
        DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
        
        //enemies start here
        DROPSET_A, DROPSET_B, DROPSET_A, DROPSET_B, DROPSET_A,
        DROPSET_C, DROPSET_C, DROPSET_A, DROPSET_A, DROPSET_B,
        DROPSET_D, DROPSET_C, DROPSET_D, DROPSET_D, DROPSET_X,
               //GHINI2 ?PHANTOM
        DROPSET_C, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
        DROPSET_X, DROPSET_C, DROPSET_X, DROPSET_C, DROPSET_C,
        DROPSET_B, DROPSET_D, DROPSET_X, DROPSET_C, DROPSET_B,
        DROPSET_D, DROPSET_X, DROPSET_B, DROPSET_X, DROPSET_B,
        DROPSET_C, DROPSET_B, DROPSET_A, DROPSET_D, DROPSET_D,MOLDORM
        DROPSET_D, DROPSET_D, DROPSET_D, DROPSET_D, DROPSET_D,
        DROPSET_D, DROPSET_X, DROPSET_X, DROPSET_D, DROPSET_D,
        DROPSET_D, DROPSET_D, DROPSET_D, DROPSET_D, DROPSET_D, //LANMOLA
        DROPSET_C, DROPSET_D, DROPSET_D, DROPSET_X, DROPSET_C,
        DROPSET_C, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
        DROPSET_X, DROPSET_B, DROPSET_D, DROPSET_X, DROPSET_X,
        DROPSET_X, DROPSET_B, DROPSET_D, DROPSET_D, DROPSET_D,
        DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_B,
        DROPSET_A, DROPSET_C, DROPSET_C, DROPSET_D, DROPSET_D,
        DROPSET_D, DROPSET_M, DROPSET_A, DROPSET_A, DROPSET_D,
        DROPSET_D, DROPSET_D, DROPSET_D, DROPSET_A, DROPSET_D,
        DROPSET_D, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
        DROPSET_C, DROPSET_D, DROPSET_D, DROPSET_X, DROPSET_X,
        DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
        DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
        DROPSET_X, DROPSET_D, DROPSET_A, DROPSET_B, DROPSET_B,
        DROPSET_B, DROPSET_B, DROPSET_X, DROPSET_X, DROPSET_X,
        DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
        DROPSET_X, DROPSET_X, DROPSET_B, DROPSET_A, DROPSET_X,
        DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X, DROPSET_X,
        DROPSET_X, DROPSET_X, DROPSET_C, DROPSET_X, DROPSET_C,
        DROPSET_A, DROPSET_X, DROPSET_X, DROPSET_D, DROPSET_D,
        DROPSET_M, DROPSET_C, DROPSET_D, DROPSET_D, DROPSET_M,
        DROPSET_X, DROPSET_X, DROPSET_X
    
    };
    int getChance(int enemyid)
    {
        return chances[enemydropsets[enemyid]];
    }
    bool canDrop(int enemy_id)
    {
        return ( Rand(1,100) <= getChance(enemy_id) ); 
    }
    void doDrop(npc n)
    {
        if ( n->HP > 0 ) return; //wait until dead
        bool ignore = false;
        switch(n->Family)
        {
            case NPCT_MOLDORM:
            case NPCT_MANHANDLA:
            case NPCT_GLEEOK:
            case NPCT_LANMOLA:
            case NPCT_PATRA:
            {
                if ( !n->isCore ) ignore = true; break;
            }
            case NPCT_DODONGO: ignore = true; break; //These never drop items, AFAIK. 
            default: break;
        
        }
        if ( !ignore )
        {
            if ( canDrop(n->ID) )
            {
                int drp_itm_id = lists[enemydropsets[n->ID]+killcount[KILL_NORMAL]];
                switch(killcount[KILL_CONSEC])
                {
                    begin insane Z1 consecutive drop rules. 
                    case 10: drp_itm_id = I_BOMBAMMO1; break;
                    case 16: drp_itm_id = I_FAIRY; break;
                    default: break;
                    
                    /*
                    TO IMPLEMENT
                    Advanced strategies: If a forced bomb/rupee or forced fairy drops, 
                    the consecutive counter for bombs/rupees is reset, but not the counter 
                    for fairies. So no matter how many hits you get on Manhandla with one 
                    well-placed bomb, the 10 count is reset after defeating him. 
                    The same is true of Dodongo. Likewise with a "Hippo Fairy" 
                    (going into a Patra with 7 on the consecutive counters, so that the 
                    Patra's center will be kill #16 and get a fairy), the bomb/rupee count 
                    resets to 0. Credit to Khananaphone for this discovery. 
                    This means that if you get a forced fairy drop, the next 
                    consecutive bomb/rupee kill will not be at 20. It will be at 26. 
                    So bomb/rupee drops work in one of two methods:
 
                        10, (Fairy at 16), 26, 36, 46...
                        10, (Skip fairy at 16 by killing non-dropping enemy), 20, 30, 40...             
                    */
                }
                item drp = Screen->CreateItem(drp_itm_id);
                drp->X = n->X + DROP_X_OFS; drp->Y = n->Y + DROP_Y_OFS;
                drp->Pickup = IP_TIMEOUT;
                ( killcount[KILL_NORMAL] < 9 ) ? ++killcount[KILL_NORMAL] : killcount[KILL_NORMAL] = 0; 
                ++killcount[KILL_CONSEC]; //when does this roll over on the NES?
            }
        }
    }
    void resetKillcount()
    {   
        if ( Link->InvFrames ) killcount[KILL_CONSEC] = 0;
    }
    
}
 
link script LinkZ1
{
    void run()
    {
        while(1)
        {
            Z1enemydrop.resetKillcount();
            for ( int q = Screen->NumNPCs(); q > 0; --q )
            {
                npc n = Screen->LoadNPC(q);
                Z1enemydrop.doDrop(n);
            }
    
    
    }
}B

Comments