With a ranged weapon, you can shoot or throw at any target that is within the weapon’s maximum range and in line of sight. The maximum range for a thrown weapon is five range increments.
For projectile weapons, it is ten range increments. Some ranged weapons have shorter maximum ranges, as specified in their descriptions.
Attack Rolls: An attack roll represents your attempts to strike your opponent.
Your attack roll is 1d20 + your attack bonus with the weapon you’re using. If the result is at least as high as the target’s AC, you hit and deal damage.
Automatic Misses and Hits: A natural 1 (the d20 comes up 1) on the attack roll is always a miss.
A natural 20 (the d20 comes up 20) is always a hit. A natural 20 is also a threat - a possible critical hit.
Damage Rolls: If the attack roll result equals or exceeds the target’s AC, the attack hits and you deal damage.
Roll the appropriate damage for your weapon. Damage is deducted from the target’s current hit points.
Multiple Attacks: A character who can make more than one attack per round must use the full attack action (see section Full-Round Actions) in order to get more than one attack.
Shooting or Throwing into a Melee: If you shoot or throw a ranged weapon at a target engaged in melee with a friendly character, you take a -4 penalty on your attack roll.
Two characters are engaged in melee if they are enemies of each other and either threatens the other. (An unconscious or otherwise immobilized character is not considered engaged unless he is actually being attacked.)
If your target (or the part of your target you’re aiming at, if it’s a big target) is at least 10 feet away from the nearest friendly character, you can avoid the -4 penalty, even if the creature you’re aiming at is engaged in melee with a friendly character.
Precise Shot: If you have the Precise Shot feat you don’t take this penalty.
Fighting Defensively as a Standard Action: You can choose to fight defensively when attacking.
If you do so, you take a -4 penalty on all attacks in a round to gain a +2 dodge bonus to AC for the same round.