46 support(0), rumor(0), threat(0), threat_missile(0), drop_time(0),
47 too_close(0), navpt(0), patrol(0), engaged_ship_id(0),
48 bracket(false), identify(false), hold(false), takeoff(false),
49 throttle(0), old_throttle(0), element_index(1), splash_count(0),
50 tactical(0), farcaster(0), ai_level(2), last_avoid_time(0),
60 player_team = pship->
GetIFF();
67 else if (player->
AILevel() == 0) {
113 if (fabs(form.
x) < 0.5) {
146 if (!s ||
rumor == s)
206 static char name[64];
207 sprintf_s(name,
"ShipAI(%s)",
self->
Name());
401 bool directed =
false;
406 if (
threat && !directed) {
412 if (d_support > 35e3) {
448 else if (
navpt && form) {
515 Point self_dest =
self->Location() + cv * time;
574 bool use_farcaster = self_rgn != nav_rgn &&
628 if (!self_rgn || !nav_rgn)
631 bool use_farcaster = self_rgn != nav_rgn &&
679 else if (self_rgn == nav_rgn) {
693 if (dest && dest->
GetRegion() == dst_rgn) {
712 double r3 = (npt - apt).length();
714 if (r1+r2 < 1.2*r3) {
739 const double prediction = 5;
746 if (!lead || lead ==
ship) {
750 if (distance < 30e3 && lead->Velocity().length() < 50) {
769 Point dst_w =
self->Location() +
self->Velocity() * prediction;
794 if (self_rgn && !nav_rgn) {
799 bool use_farcaster = self_rgn != nav_rgn &&
811 if (dest && dest->
GetRegion() == nav_rgn) {
991 if (dv > 0) dt = dv * 1e-2 *
seconds;
992 else if (dv < 0) dt = dv * 1e-2 *
seconds;
1009 if (leader && leader !=
ship) {
1010 bool navlight_enabled =
false;
1016 if (navlight_enabled)
1054 double avoid_dist = 5 *
self->Radius();
1056 if (avoid_dist < 1e3) avoid_dist = 1e3;
1057 else if (avoid_dist > 12e3) avoid_dist = 12e3;
1061 double avoid_time = 15;
1068 Point bearing =
self->Velocity();
1082 while (++contact && !found) {
1093 while (++iter && !found) {
1107 while (++iter && !found) {
1131 const Point& bearing,
1140 if (closure > 1 && dist < avoid_dist) {
1164 if (current_distance > 25e3) {
1178 double angle_off = fabs(acos(dir * obj->
Cam().
vpn()));
1181 angle_off = 180*
DEGREES - angle_off;
1188 if (err < 0.667 * obj->Radius()) {
1199 if (current_distance < (avoid_dist * 0.35)) {
1200 if (closing_velocity > 1 || current_distance < ship->Radius()) {
1207 double separation = (avoid_dist + obj->
Radius());
1208 if ((current_distance-separation) / closing_velocity > avoid_time) {
1218 double dist = (selfpt - testpt).length()
1223 if (dist < avoid_dist) {
1224 if (dist < avoid_dist * 0.25 && time < avoid_time * 0.5) {
1241 else if (
other == obj && dist > avoid_dist * 1.25) {