Skip to content

Instantly share code, notes, and snippets.

@caasi
Created August 26, 2012 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caasi/3481658 to your computer and use it in GitHub Desktop.
Save caasi/3481658 to your computer and use it in GitHub Desktop.
fo2 pseudo code ez version
int apply_distance_modifier() {
attack_is_ranged = 1;
int mod;
int new_perception = attacker_is_player ? attacker_perception - 2 : attacker_perception;
int dist = target_invalid ? 0 : distance_between_attacker_and _target;
switch(weapon_perk) {
case long_range:
mod = (new_perception * 4 - dist) * 4;
break;
case scope_range:
dist = dist < 8 ? dist + 8 : dist;
mod = (new_perception * 5 - dist) * 4;
break;
default:
mod = (new_perception * 2 - dist) * 4;
break;
};
mod = min(8 * attacker_perception, mod);
if (attacker_is_player) mod += 8 * player_sharpshooter_level;
if (attacker_eye_damage && mod <= 0) mod *= 3;
if (!attack_with_norange_argument || mod > 0) tohit += mod;
if (!target_invalid && !attack_with_norange_argument) tohit -= 10 * objects_between_attacker_and_target;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment