From eeb9eb02113f2c483cce404460b22f11997a5b0c Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 2 Nov 2013 21:32:11 +0000 Subject: Copy currently mounted weapons onto wingmen. --- src/game/base/npc.cc | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/game/base/npc.cc') 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); + } + */ } } -- cgit v1.2.3