protected void attack()
    {
        if (counter >= attackRate ) //used for the attack cycle of the weapon
        {
            if (targetedMob != null && targetedMob.getHp() > 0 && 
            getDistance (targetedMob) <= range/2){  
                //if the mob its attacking is not dead     
                launch();
            }
            else{
                //get a group of enemies that is within range
                Enemy attack = withinRange(targetPriority);
                if (attack != null){
                    targetedMob = attack;      
                    launch();
                }
            }
        }
        else{
            counter++;
        }
    }