Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-10-20 14:36:45 +0000
committerStijn Buys <ingar@osirion.org>2013-10-20 14:36:45 +0000
commitb277c65615482f17c966771341ae6b7a89cc9568 (patch)
treed5138749901e816ac1b197279b51e7ac23e15b82 /src/game
parent6704be2d5550f091c18c4cc50ef6d28bf55a31a4 (diff)
Make wingmen follow you through jumpgates.
Diffstat (limited to 'src/game')
-rw-r--r--src/game/base/npc.cc42
-rw-r--r--src/game/base/ship.cc10
-rw-r--r--src/game/base/ship.h7
3 files changed, 43 insertions, 16 deletions
diff --git a/src/game/base/npc.cc b/src/game/base/npc.cc
index be7a754..8e820a7 100644
--- a/src/game/base/npc.cc
+++ b/src/game/base/npc.cc
@@ -84,6 +84,8 @@ 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) {
@@ -98,6 +100,15 @@ void NPC::frame(const unsigned long elapsed)
unset_autopilot_flag(Ship::AutoPilotEnabled);
}
+ } 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);
+
} else {
if (state() == core::Entity::Docked) {
@@ -116,20 +127,27 @@ void NPC::frame(const unsigned long elapsed)
}
} else {
- unset_autopilot_flag(Ship::AutoPilotEnabled);
-
- target_direction = 0;
- target_pitch = 0;
- target_roll = 0;
- target_strafe = 0.0f;
- target_vstrafe = 0.0f;
-
- target_afterburner = 0.0f;
- target_thrust = 0;
- if (state() == core::Entity::Impulse) {
+ // leader is not in this zone
+ if (!autopilot_target()) {
+
+ target_direction = 0;
+ target_pitch = 0;
+ target_roll = 0;
+ target_strafe = 0.0f;
+ target_vstrafe = 0.0f;
+
+ target_afterburner = 0.0f;
+ target_thrust = 0;
+
+ if (state() == core::Entity::Impulse) {
- func_impulse();
+ func_impulse();
+ }
+ } else {
+ set_autopilot_flag(Ship::AutoPilotEnabled);
+ set_autopilot_flag(Ship::AutoPilotDock);
+ unset_autopilot_flag(Ship::AutoPilotFormation);
}
}
}
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 75656dc..c017ce1 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -693,10 +693,13 @@ void Ship::frame(const unsigned long elapsed)
set_zone(ship_jumpdepart->target()->zone());
- if (owner() && owner()->view() && (owner()->view()->zone() != ship_jumpdepart->target()->zone()))
- owner()->set_view(0);
+ if (owner()) {
+ if (owner()->view() && (owner()->view()->zone() != ship_jumpdepart->target()->zone())) {
+ owner()->set_view(0);
+ }
- owner()->send("^BJumping to the " + ship_jumpdepart->target()->zone()->name());
+ owner()->send("^BJumping to the " + ship_jumpdepart->target()->zone()->name());
+ }
} else {
set_state(core::Entity::Normal);
}
@@ -1155,6 +1158,7 @@ void Ship::frame_autopilot_dock(const unsigned long elapsed, core::Entity *targe
// jumpgates have their own docking function
JumpGate *jumpgate = static_cast<JumpGate *>(target);
jumpgate->func_dock(this);
+
unset_autopilot_flag(AutoPilotDock);
return;
diff --git a/src/game/base/ship.h b/src/game/base/ship.h
index 61ff1c7..fa6e60d 100644
--- a/src/game/base/ship.h
+++ b/src/game/base/ship.h
@@ -83,6 +83,11 @@ public:
return ship_spawn;
}
+ inline JumpPoint *jumpdepart()
+ {
+ return ship_jumpdepart;
+ }
+
/// current autopilot target
inline core::Entity *autopilot_target()
{
@@ -230,7 +235,7 @@ protected:
* @brief autopilot formation flying
* */
void frame_autopilot_formation(const unsigned long elapsed, core::Entity *target);
-
+
private:
JumpPoint *find_closest_jumppoint();