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-11-02 21:32:11 +0000
committerStijn Buys <ingar@osirion.org>2013-11-02 21:32:11 +0000
commiteeb9eb02113f2c483cce404460b22f11997a5b0c (patch)
treeef22e65c77014885377fc345cbc7be6a61455224 /src/game
parent4eedeb0bc1f40f6a67f609514f9732c8ec5a5c6d (diff)
Copy currently mounted weapons onto wingmen.
Diffstat (limited to 'src/game')
-rw-r--r--src/game/base/npc.cc36
-rw-r--r--src/game/base/ship.cc2
2 files changed, 36 insertions, 2 deletions
diff --git a/src/game/base/npc.cc b/src/game/base/npc.cc
index 8e820a7..8b81f04 100644
--- a/src/game/base/npc.cc
+++ b/src/game/base/npc.cc
@@ -35,6 +35,33 @@ NPC *NPC::add_wingman(Ship *leader)
npc->set_axis(leader->axis());
npc->set_zone(leader->zone());
+ // copy weapon layout
+
+ if (!npc->inventory()) {
+ npc->add_inventory();
+ }
+ // TODO ship models should be identical, otherwise the slot loeading can fail in horrible ways
+ assert (npc->shipmodel() == leader->shipmodel());
+
+ for (size_t i = 0; i < leader->slots()->size(); ++i) {
+ core::Slot *slot = leader->slots()->operator[](i);
+
+ if (!slot->has_flag(core::Slot::Mounted) && slot->item()) {
+ continue;
+ }
+
+ core::Item *npc_item = new core::Item(slot->item()->info());
+ npc_item->set_amount(slot->item()->amount());
+ npc_item->set_flags(slot->item()->flags());
+ npc_item->set_flag(core::Item::Mounted);
+ npc->inventory()->add(npc_item);
+
+ core::Slot *npc_slot = npc->slots()->operator[](i);
+ npc_slot->set_item(npc_item);
+ npc_slot->set_flag(core::Slot::Active);
+ npc_slot->set_flag(core::Slot::Mounted);
+ }
+
npc->reset();
return npc;
@@ -123,6 +150,15 @@ void NPC::frame(const unsigned long elapsed)
set_autopilot_flag(Ship::AutoPilotEnabled);
unset_autopilot_flag(Ship::AutoPilotDock);
set_autopilot_flag(Ship::AutoPilotFormation);
+
+ /*
+ if (leader()->has_target_controlflag(core::EntityControlable::ControlFlagFire)) {
+ set_target_controlflag(core::EntityControlable::ControlFlagFire);
+ target_aim.assign(leader()->aim());
+ } else {
+ unset_target_controlflag(core::EntityControlable::ControlFlagFire);
+ }
+ */
}
}
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 5d8ace2..16c2ea8 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -1206,13 +1206,11 @@ void Ship::frame_autopilot_formation(const unsigned long elapsed, core::Entity *
// target is behind the ship
target_direction = math::sgnf(reference.forward().y());
target_pitch = 0.0f;
- target_roll = 0.0f;
} else if (reference.forward().x() + MIN_DELTA < 1.0f) {
// target is in front of the ship
target_direction = reference.forward().y();
target_pitch = reference.forward().z();
- target_roll = 0.0f;
} else {
target_direction = 0.0f;