const int ringTimePerMP = 15; //How many frames 1 unit of MP lasts with the One Ring
const int ringShadowTile = 0; //Shadow tile for invisble Link
const int ringShadowCSet = 7; //CSet of this tile

global script active{
    void run(){
        bool ringOn;
        int ringTimer;
        
        while(true){
            if ( ringOn && Link->MP ){                
                //Decrement magic
                ringTimer = (ringTimer+1) % ringTimePerMP;
                if ( !ringTimer ) Link->MP--;
                
                //Draw shadow under Link
                Screen->FastTile( 2, Link->X, Link->Y, ringShadowTile, ringShadowCset, OP_TRANS );
                
                if ( Link->MP <= 0 //If magic ran out
                || Link->Action == LA_SCROLLING //Or left screen
                ){ //Take off ring
                    ringOn = false;
                    Link->CollDetection = true;
                    Link->Invisible = false;
                }

            }
            else if ( !ringOn ){ //Disable ring
                Link->CollDetection = true;
                Link->Invisible = false;
            }
        }
    }
}

item script theOneRing{
    void run(int onSFX, int offSFX){
        if ( !ringOn && Link->MP > 0 ){
            ringOn = true
            Game->PlaySound(onSFX);
            
            Link->CollDetection = false;
            Link->Invisible = true;
        }
        else if ( ringOn ){
            ringOn = false;
            Game->PlaySound(offSFX);
        }
    }
}