WARNING: This script uses a script command that is not present in Build 1296! You must have a newer build than that in order to use this script!

Code:
ffc script AntiFairy {
    void run(int type, int dmg, int sfx) {
        int dir = 4 + Rand(4);
        int hurttimeout = 0;
        
        while(true) {
            dir = MoveBounce(this, dir);
            
            if(hurttimeout == 0) {
                if(LinkCollision(this) && Link->Action != LA_GOTHURTLAND && Link->Action != LA_GOTHURTWATER) {
                    Link->Action = LA_GOTHURTLAND;
                    Link->HitDir = RelativeDir(this);
                    
                    if(sfx != 0) Game->PlaySound(sfx);
                    
                    if(type == 0) {
                        Link->HP -= dmg;
                    } else if(type == 1) {
                        Link->MP -= dmg;
                    }
                    
                    hurttimeout = 10;
                }
            } else {
                hurttimeout -= 1;
            }
            
            for(int i = 1; i <= Screen->NumLWeapons(); i++) {
                lweapon lw = Screen->LoadLWeapon(i);
                
                if(lw->ID == LW_BRANG && Collision(this, lw)) {
                    //buh bye
                    lw->DeadState = WDS_BOUNCE;
                    Game->PlaySound(25);
                    item itm = Screen->CreateItem(I_FAIRY);
                    itm->X = this->X;
                    itm->Y = this->Y;
                    itm->Pickup = IP_TIMEOUT;
                    this->X = -100;
                    this->Y = -100;
                    return;
                }
            }
            
            Waitframe();
        }
    }
    
    int FlipH(int dir) {
        if(dir == DIR_LEFTUP) {
            return DIR_RIGHTUP;
        } else if(dir == DIR_RIGHTUP) {
            return DIR_LEFTUP;
        } else if(dir == DIR_LEFTDOWN) {
            return DIR_RIGHTDOWN;
        } else if(dir == DIR_RIGHTDOWN) {
            return DIR_LEFTDOWN;
        }
    }
    
    int FlipV(int dir) {
        if(dir == DIR_LEFTUP) {
            return DIR_LEFTDOWN;
        } else if(dir == DIR_RIGHTUP) {
            return DIR_RIGHTDOWN;
        } else if(dir == DIR_LEFTDOWN) {
            return DIR_LEFTUP;
        } else if(dir == DIR_RIGHTDOWN) {
            return DIR_RIGHTUP;
        }
    }
    
    int MoveBounce(ffc this, int dir) {
        int newx = this->X;
        int newy = this->Y;
        if(dir == DIR_LEFTUP) {
            newx -= 1;
            newy -= 1;
        } else if(dir == DIR_RIGHTUP) {
            newx += 1;
            newy -= 1;
        } else if(dir == DIR_LEFTDOWN) {
            newx -= 1;
            newy += 1;
        } else if(dir == DIR_RIGHTDOWN) {
            newx += 1;
            newy += 1;
        }
        
        //this doesn't check the extreme top or bottom!
        if(newx <= 0 || newx + 15 >= 255) {
            dir = FlipH(dir);
        } else {
            for(int y = newy+2; y < newy + 14; y++) {
                if(Screen->isSolid(newx+1, y) || Screen->isSolid(newx + 14, y)) {
                    dir = FlipH(dir);
                    break;
                }
            }
        }
        
        //this doesn't check the extreme right or left!
        if(newy <= 0 || newy + 15 >= 175) {
            dir = FlipV(dir);
        } else {
            for(int x = newx+2; x < newx + 14; x++) {
                if(Screen->isSolid(x, newy+1) || Screen->isSolid(x, newy + 14)) {
                    dir = FlipV(dir);
                    break;
                }
            }
        }
        
        newx = this->X;
        newy = this->Y;
        if(dir == DIR_LEFTUP) {
            newx -= 1;
            newy -= 1;
        } else if(dir == DIR_RIGHTUP) {
            newx += 1;
            newy -= 1;
        } else if(dir == DIR_LEFTDOWN) {
            newx -= 1;
            newy += 1;
        } else if(dir == DIR_RIGHTDOWN) {
            newx += 1;
            newy += 1;
        }
        
        this->X = newx;
        this->Y = newy;
        
        return dir;
    }
}
This script creates one of those enemies from the Zelda 3/the gameboy zeldas that bounces diagonally around the screen. In Zelda 3, they take magic instead of health, while on the game boy, they do damage. In addition, they turn into fairies when struck with the boomerang.

Fortunately for you, these ones do all of the above.

Usage:
No special set up is required. Just place the FFC and set the arguments.

Arguments:
D0 - The type of damage to do: 0 = HP, 1 = MP
D1 - The amount of damage.
D2 - The sound effect to play on contact. (0 = none)