diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/entity.h | 7 | ||||
-rw-r--r-- | src/core/slots.h | 2 | ||||
-rw-r--r-- | src/game/base/npc.cc | 36 | ||||
-rw-r--r-- | src/game/base/ship.cc | 2 |
4 files changed, 44 insertions, 3 deletions
diff --git a/src/core/entity.h b/src/core/entity.h index 6878f08..721c329 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -744,11 +744,16 @@ public: /** * @brief returns true if a specified control flag is set * */ - inline bool has_target_controlflag(ControlFlags controlflag) + inline const bool has_target_controlflag(ControlFlags controlflag) const { return ((target_controlflags & controlflag) == controlflag); } + inline const math::Vector3f &aim() const + { + return target_aim; + } + /*----- serializers ----------------------------------------------- */ /// serialize the entity to a stream diff --git a/src/core/slots.h b/src/core/slots.h index 6ac9eb8..2452ccb 100644 --- a/src/core/slots.h +++ b/src/core/slots.h @@ -27,6 +27,8 @@ public: typedef Container::iterator iterator; + typedef Container::const_iterator const_iterator; + /** * @brief initialize slots collection from model properties * */ 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; |