void main()
{
    int nEvent = GetUserDefinedEventNumber();
    if (nEvent == 1003)
        {
        object oCreature = GetNearestObject(OBJECT_TYPE_CREATURE);
        int iNum = 1;

        while (GetIsObjectValid(oCreature) && GetDistanceToObject(oCreature) < 20.0 && iNum<4 && GetIsEnemy(oCreature))
        {
        if(d100(1) > 50)
        {
        ClearAllActions();
        ActionCastSpellAtObject(SPELL_MAGIC_MISSILE, oCreature, METAMAGIC_SILENT, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, FALSE);
        }
        iNum++;
        oCreature = GetNearestObject(OBJECT_TYPE_CREATURE, OBJECT_SELF, iNum);
        }
        }
}

