Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/base/npc.cc42
1 files changed, 23 insertions, 19 deletions
diff --git a/src/game/base/npc.cc b/src/game/base/npc.cc
index 992ba6c..d09f8a2 100644
--- a/src/game/base/npc.cc
+++ b/src/game/base/npc.cc
@@ -120,7 +120,7 @@ Ship *NPC::target_closest_enemy()
const float r = radius() + ship->radius();
// too far
- if (d > r + core::range::fxdistance * 2.0f) {
+ if (d > r + core::range::fxdistance) {
continue;
}
@@ -143,15 +143,7 @@ Ship *NPC::target_closest_enemy()
if (reputation >= -50.0f) {
continue;
}
-
- // reputation threshold to get hunted
- if (d > core::range::fxdistance + r) {
-
- if ((!ship->owner()) || (reputation > -100.0f)) {
- continue;;
- }
- }
-
+
current_enemy = ship;
current_distance = d;
}
@@ -200,7 +192,6 @@ void NPC::frame(const unsigned long elapsed)
} else if (leader()->zone() == zone()) {
// leader is in this zone
-
if (leader()->state() == Docked) {
if (state() != core::Entity::Docked) {
@@ -210,6 +201,7 @@ void NPC::frame(const unsigned long elapsed)
set_autopilot_flag(Ship::AutoPilotEnabled);
set_autopilot_flag(Ship::AutoPilotDock);
unset_autopilot_flag(Ship::AutoPilotFormation);
+ unset_autopilot_flag(Ship::AutoPilotCombat);
} else {
unset_autopilot_flag(Ship::AutoPilotEnabled);
@@ -218,11 +210,11 @@ void NPC::frame(const unsigned long elapsed)
} else if ((leader()->state() == JumpInitiate) || (leader()->state() == Jump)) {
// goto wherever the leader is jumping
-
set_autopilot_target(leader()->jumpdepart());
set_autopilot_flag(Ship::AutoPilotEnabled);
set_autopilot_flag(Ship::AutoPilotDock);
unset_autopilot_flag(Ship::AutoPilotFormation);
+ unset_autopilot_flag(Ship::AutoPilotCombat);
} else {
@@ -231,14 +223,23 @@ void NPC::frame(const unsigned long elapsed)
launch();
} else {
-
- set_autopilot_target(leader());
-
- set_autopilot_flag(Ship::AutoPilotEnabled);
- unset_autopilot_flag(Ship::AutoPilotDock);
- set_autopilot_flag(Ship::AutoPilotFormation);
+ Ship *enemy = target_closest_enemy();
- target_closest_enemy();
+ if (enemy && leader()->has_autopilot_flag(Ship::AutoPilotCombat)) {
+ set_autopilot_target(enemy);
+
+ set_autopilot_flag(Ship::AutoPilotEnabled);
+ set_autopilot_flag(Ship::AutoPilotCombat);
+ unset_autopilot_flag(Ship::AutoPilotDock);
+ unset_autopilot_flag(Ship::AutoPilotFormation);
+ } else {
+ set_autopilot_target(leader());
+
+ set_autopilot_flag(Ship::AutoPilotEnabled);
+ unset_autopilot_flag(Ship::AutoPilotCombat);
+ unset_autopilot_flag(Ship::AutoPilotDock);
+ set_autopilot_flag(Ship::AutoPilotFormation);
+ }
}
}
@@ -264,6 +265,7 @@ void NPC::frame(const unsigned long elapsed)
set_autopilot_flag(Ship::AutoPilotEnabled);
set_autopilot_flag(Ship::AutoPilotDock);
unset_autopilot_flag(Ship::AutoPilotFormation);
+ unset_autopilot_flag(Ship::AutoPilotCombat);
}
}
@@ -287,6 +289,8 @@ void NPC::frame(const unsigned long elapsed)
}
}
+ } else {
+ die();
}
}