Last active
August 29, 2015 14:06
-
-
Save dhh1128/ce0cd3fdbd390e6f2417 to your computer and use it in GitHub Desktop.
evasive action snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void spaceship::take_evasive_action(list<threat> threats_by_proximity) { | |
course escape_vector = nullptr; | |
list<threat> weighted_threats = order_by_evasion_priority( | |
threats_by_proximity, multiply_by_threat_severity); | |
if (this->has_warp()) { | |
bool warp_is_practical = true; | |
double max_safe_warp = 1.0; | |
// do a bunch of calculations about whether warp is | |
// practical, based on current fuel, gravitational | |
// fields, battle damage, etc. Also, figure out what | |
// speed we can achieve. | |
// ... 50 lines omitted ... | |
if (warp_is_practical) { | |
escape_vector = select_safest_course(max_safe_warp, | |
weighted_threats, bias::away); | |
} | |
} else { | |
switch (this->conventional_propulsion_type) { | |
case propulsion_type::impulse: | |
// ... 5 lines omitted ... | |
case propulsion_type::thrusters: | |
// ... 4 lines omitted ... | |
case propulsion_type::ion: | |
// ... 12 lines omitted ... | |
default: | |
if (this->has_countermeasures()) | |
deploy_decoys(); | |
break; | |
} | |
} | |
if (escape_vector) { | |
engage(escape_vector); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment