XRWS         !  ½_  ?  ³s  ­ext_01.cat ext_01.dat readme.txt libraries/charactergroups.xml 1051 1441759983 38b58c271c9e37e0b83862df0149e8bf
libraries/characters.xml 4406 1441759939 2d4b4c92b2752f50979f087fd7078a3d
libraries/shipgroups.xml 1560 1441445462 10e5027a79179e92785158946d9ac740
md/Baely.xml 32280 1441781429 b18011d710341abb317524982c3299ef
md/NPC_Shiptrader.xml 325 1441775773 9ef20097641038fac05ef1f8f09ba3f1
md/NPC_Shiptrader_Small.xml 352 1441775751 4d97029ec86cbd1fe1bf62307d2d3ef6
ui.xml 339 1441769317 afe8f93b19127bec6f3e03102ffa47f6
ui/bae_mainmenu/mainmenu_baely.lua 5626 1441789818 ba38c8c00991d2b3eeb366efe8d80962
<?xml version="1.0" encoding="utf-8" ?>
<diff>
  <add sel="/characters">
    <!-- Bae Character groups used for for Baely Hire -->
    <character name="Bae.commander">
      <select character="argon.commander" />
      <select character="devries.commander" />
    </character>
    <character name="Bae.defence">
      <select character="argon.defence" />
      <select character="devries.defence" />
    </character>
    <character name="Bae.engineer">
      <select character="argon.engineer" />
      <select character="devries.engineer" />
    </character>
    <character name="Bae.architect">
      <select character="argon.architect" />
      <select character="devries.architect" />
    </character>
    <character name="Bae.pilot">
      <select character="argon.pilot"/>
      <select character="devries.pilot"/>
    </character>
    <character name="Bae.specialengineer">
      <select character="argon.specialengineer" />
      <select character="devries.specialengineer" />
    </character>
  
  </add>
</diff><?xml version="1.0" encoding="utf-8"?>
<diff>
<add sel="/characters">
  <!-- Specialist Engineers for Baely Hire -->
  <!-- Skill importance:
  Engineering: all
  Science: pharma, hydro, chemical, food, geo, agri, metal
  Leadership: pharma, agri
  Navigation: hydro, geo
  Management: chemical, food
  Combat: weapons
  Morale: none
  -->
  
  <character id="Bae_specialman" group="Bae.specialengineer">
    <skills>
      <skill type="engineering" exact="5"/>
      <skill type="science" exact="5"/>
      <skill type="management" exact="5"/>
      <skill type="morale" min="3" max="4"/>
      <skill type="leadership" min="0" max="3"/>
      <skill type="combat" min="0" max="3"/>
      <skill type="navigation" min="0" max="2"/>
    </skills>
  </character>
  <character id="Bae_specialnav" group="Bae.specialengineer">
    <skills>
      <skill type="science" exact="5"/>
      <skill type="engineering" exact="5"/>
      <skill type="navigation" exact="5"/>
      <skill type="morale" min="3" max="4"/>
      <skill type="management" min="0" max="3"/>
      <skill type="leadership" min="0" max="3"/>
      <skill type="combat" min="0" max="2"/>
    </skills>
  </character>
  <character id="Bae_speciallead" group="Bae.specialengineer">
    <skills>
      <skill type="engineering" exact="5"/>
      <skill type="science" exact="5"/>
      <skill type="leadership" exact="5"/>
      <skill type="navigation" min="3" max="4"/>
      <skill type="combat" min="0" max="3"/>
      <skill type="morale" min="0" max="3"/>
      <skill type="management" min="0" max="2"/>
    </skills>
  </character>
  <character id="Bae_specialcombat" group="Bae.specialengineer">
    <skills>
      <skill type="engineering" exact="5"/>
      <skill type="combat" exact="5"/>
      <skill type="morale" min="3" max="4"/>
      <skill type="management" min="0" max="3"/>
      <skill type="leadership" min="0" max="3"/>
      <skill type="navigation" min="0" max="3"/>
      <skill type="science" min="0" max="2"/>
    </skills>
  </character>
  
  <!-- Crew for Baely Hire -->
  <!-- Architects -->
  <character id="Bae_architect" group="Bae.architect">
    <skills>
      <skill type="management" exact="5" />
      <skill type="navigation" exact="5" />
      <skill type="engineering" exact="5" />
      <skill type="morale" min="1" max="4" />
      <skill type="combat" min="0" max="3" />
      <skill type="leadership" min="1" max="4" />
      <skill type="science" min="1" max="4" />
    </skills>
  </character>
  <!-- Commanders -->
  <character id="Bae_commander" group="Bae.commander">
    <skills>
      <skill type="morale" exact="5" />
      <skill type="navigation" exact="5" />
      <skill type="leadership" exact="5" />
      <skill type="management" min="0" max="3" />
      <skill type="combat" min="1" max="4" />
      <skill type="engineering" min="1" max="4" />
      <skill type="science" min="0" max="3" />
    </skills>
  </character>
  <!-- Defence officers -->
  <character id="Bae_defence" group="Bae.defence">
    <skills>
      <skill type="morale" exact="5" />
      <skill type="combat" exact="5" />
      <skill type="leadership" exact="5" />
      <skill type="management" min="0" max="3" />
      <skill type="navigation" min="1" max="4" />
      <skill type="engineering" min="1" max="4" />
      <skill type="science" min="0" max="3" />
    </skills>
  </character>
  <!-- Engineers -->
  <character id="Bae_engineer" group="Bae.engineer">
    <skills>
      <skill type="engineering" exact="5" />
      <skill type="morale" min="1" max="4" />
      <skill type="navigation" min="1" max="4" />
      <skill type="leadership" min="1" max="4" />
      <skill type="management" min="1" max="4" />
      <skill type="combat" min="0" max="3" />
      <skill type="science" min="1" max="4" />
    </skills>
  </character>
  <!-- Pilots -->
  <character id="Bae_fighter" group="Bae.pilot">
    <skills>
      <skill type="morale" exact="5" />
      <skill type="navigation" exact="5" />
      <skill type="combat" exact="5" />
      <skill type="leadership" min="1" max="4" />
      <skill type="management" min="0" max="3" />
      <skill type="engineering" min="1" max="4" />
      <skill type="science" min="0" max="3" />
    </skills>
  </character>
</add>
</diff>
<?xml version="1.0" encoding="utf-8" ?>
<diff>
  <add sel="/groups">
    <group name="Bae_guard_ships">
      <select macro="units_size_s_ship_ar_military_01_macro" />
      <select macro="units_size_s_ship_ar_military_02_macro" />
      <select macro="units_size_s_ship_ar_military_03_macro" />
      <select macro="units_size_s_ship_ar_military_04_macro" />
      <select macro="units_size_s_ship_ar_military_05_macro" />
      <select macro="units_size_s_ship_ar_military_06_macro" />
      <select macro="units_size_s_ship_ar_military_07_macro" />
      <select macro="units_size_s_ship_ar_military_08_macro" />
      <select macro="units_size_s_ship_ar_military_09_macro" />
      <select macro="units_size_s_ship_pirate_01_macro" />
      <select macro="units_size_s_ship_pirate_02_macro" />
      <select macro="units_size_s_ship_pirate_03_macro" />
      <select macro="units_size_m_canteran_01_macro" />
      <select macro="units_size_m_canteran_02_macro" />
      <select macro="units_size_s_ship_pmc_01_macro" />
      <select macro="units_size_s_ship_pmc_02_macro" />
      <select macro="units_size_s_ship_pmc_03_macro" />
      <select macro="units_size_s_ship_01_macro" />
      <select macro="units_size_s_ship_02_macro" />
      <select macro="units_size_s_ship_03_macro" />
      <select macro="units_size_s_ship_04_macro" />
      <select macro="units_size_s_ship_05_macro" />
      <select macro="units_size_s_ship_06_macro" />
      <select macro="units_size_s_ship_07_macro" />
    </group>
  </add>
</diff><?xml version="1.0" encoding="utf-8" ?>
<mdscript name="Baely" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
  <cues>
      <!-- 
          create cue actor vs create platform actor:
          Platform actor creates npc's identical to the ones on npc stations.
          There is internal logic for when a platform actor is created, mainly the
          handlers for default conversations.
      -->
      
      <cue name="SectionHandler_Baely_GetCrew" instantiate="false" namespace="this">
      <conditions>
        <check_any>
          <event_conversation_next_section sectionprefix="Baely_GetCrew" />
          <event_conversation_returned_to_section sectionprefix="Baely_GetCrew" />
        </check_any>
      </conditions>
      <actions>
        <!-- Get Captain, Engineer, Defence Officer and/or Architect for any empty capital ships in zone -->
        <find_ship groupname="$PlayerShips" multiple="true" class="[class.ship_xl, class.ship_l]" space="player.zone" owner="faction.player" />
        
        <set_value name="$special" exact="false" />
        <set_value name="$NoShips" exact="true" />
        
        <do_all exact="$PlayerShips.count" counter="$i" >
          <set_value name="$IsPoor" exact="false" />
          <set_value name="$NoShips" exact="false" />
          <set_value name="$Details" exact="[]" />
          <set_value name="$TotalFee" exact="0" />
          <set_value name="$CrewAdded" exact="false" />
          
          <find_dock_location name="$CurrentShipDock" container="$PlayerShips.{$i}" required="true" />
          
          <do_if value="not $PlayerShips.{$i}.pilot">
            <!-- create actor and check if player has enough money to hire -->
            <create_cue_actor cue="this" name="$Commander" tags="tag.commander" ref="Bae_commander" />
            <set_entity_type entity="$Commander" type="entitytype.commander" />
            
            <set_value name="$actor" exact="$Commander" />
            <include_actions ref="Baely_FeeCalculation" />
            
            <!-- If he does, hire actor and add him to ship -->
            <do_if value="$CanAfford">
              <set_owner object="$Commander" faction="faction.player" />
              <add_actor_to_platform actor="$Commander" dockingbay="$CurrentShipDock.component" />
              <assign_pilot actor="$Commander" object="$PlayerShips.{$i}" />
              <start_script object="$Commander" name="'player.default'" />
              <set_skills_visible entity="$Commander" />
              <set_value name="$CrewAdded" exact="true" />
              <signal_cue_instantly cue="md.NPC_Staff.LogHired" param="$actor" />
              <signal_cue_instantly cue="md.NPC_Staff.CustomStaff" param="[$actor, $fee]"/>
              <append_to_list name="$Details" exact="'Captain %1'.[ $Commander.name ]" />
            </do_if>
            <do_else>
              <!-- Otherwise, skip hiring actor and declare the player a homeless beggar -->
              <set_value name="$IsPoor" exact="true" />
            </do_else>
          </do_if>
          
          <do_if value="not $PlayerShips.{$i}.engineer and not $IsPoor">
            <!-- For some reason, Engineers don't have dialogue handlers that can be manually signalled
                 Currently, create_platform_actor is the only way to initialize them completely
            -->
            <create_platform_actor name="$Engineer" dockingbay="$CurrentShipDock.component" type="entitytype.engineer" tags="tag.engineer" ref="Bae_engineer" />
            
            <set_value name="$actor" exact="$Engineer" />
            <include_actions ref="Baely_FeeCalculation" />
            
            <do_if value="$CanAfford">
              <set_owner object="$Engineer" faction="faction.player" />
              <assign_engineer actor="$Engineer" object="$PlayerShips.{$i}" />
              <start_script object="$Engineer" name="'engineer.ai'" />
              <set_skills_visible entity="$Engineer" />
              <set_value name="$CrewAdded" exact="true" />
              <signal_cue_instantly cue="md.NPC_Staff.LogHired" param="$actor" />
              <append_to_list name="$Details" exact="'Engineer %1'.[ $Engineer.name ]" />
            </do_if>
            <do_else>
              <set_value name="$IsPoor" exact="true" />
              <remove_actor_from_room actor="$Engineer" />
              <destroy_object object="$Engineer" explosion="false" />
            </do_else>
          </do_if>
          
          <do_if value="not $PlayerShips.{$i}.defencenpc and not $IsPoor">
            <create_cue_actor cue="this" name="$Defence" tags="tag.defencecontrol" ref="Bae_defence" />
            <set_entity_type entity="$Defence" type="entitytype.defencecontrol" />
            
            <set_value name="$actor" exact="$Defence" />
            <include_actions ref="Baely_FeeCalculation" />
            
            <do_if value="$CanAfford">
              <set_owner object="$Defence" faction="faction.player" />
              <add_actor_to_platform actor="$Defence" dockingbay="$CurrentShipDock.component" />
              <assign_defence_manager actor="$Defence" object="$PlayerShips.{$i}" />
              <start_script object="$Defence" name="'fight.defend.capital'" />
              <set_skills_visible entity="$Defence" />
              <set_value name="$CrewAdded" exact="true" />
              <signal_cue_instantly cue="md.NPC_Staff.LogHired" param="$actor" />
              <signal_cue_instantly cue="md.NPC_Staff.CustomStaff" param="[$actor, $fee]"/>
              <append_to_list name="$Details" exact="'Defence Officer %1'.[ $Defence.name ]" />
            </do_if>
            <do_else>
              <set_value name="$IsPoor" exact="true" />
            </do_else>
          </do_if>
          
          <find_object_component name="$BuildModule" object="$PlayerShips.{$i}" class="class.buildmodule" />
          <do_if value="$BuildModule and not $PlayerShips.{$i}.architect and not $IsPoor" >
            <create_cue_actor cue="this" name="$Architect" tags="tag.architect" ref="Bae_architect"  />
            <set_entity_type entity="$Architect" type="entitytype.architect" />
            
            <set_value name="$actor" exact="$Architect" />
            <include_actions ref="Baely_FeeCalculation" />
            
            <do_if value="$CanAfford">
              <set_owner object="$Architect" faction="faction.player" />
              <add_actor_to_platform actor="$Architect" dockingbay="$CurrentShipDock.component" />
              <assign_architect actor="$Architect" object="$PlayerShips.{$i}" />
              <set_skills_visible entity="$Architect" visible="true" />
              <set_actor_account actor="$Architect" />
              <set_value name="$CrewAdded" exact="true" />
              <signal_cue_instantly cue="md.NPC_Staff.LogHired" param="$actor" />
              <signal_cue_instantly cue="md.NPC_Architect.Base" param="[$actor, false, true]"/>
              <append_to_list name="$Details" exact="'Architect %1'.[ $Architect.name ]" />
            </do_if>
            <do_else>
              <set_value name="$IsPoor" exact="true" />
            </do_else>
          </do_if>
          <do_if value="$actor?"><remove_cue_actor cue="this" actor="$actor" /></do_if>
          <do_if value="$Commander?"><remove_cue_actor cue="this" actor="$Commander" /></do_if>
          <do_if value="$Defence?"><remove_cue_actor cue="this" actor="$Defence" /></do_if>
          <do_if value="$Architect?"><remove_cue_actor cue="this" actor="$Architect" /></do_if>

          <do_if value="$CrewAdded">
            <append_to_list name="$Details" exact="'Hired for %1'.[ $PlayerShips.{$i}.name ]" />
            <append_to_list name="$Details" exact="'Spent %1k on hiring fees'.[ ($TotalFee / 1000) ]" />
            <do_if value="$IsPoor" >
              <append_to_list name="$Details" exact="'\nNot enough funds to hire the rest of the crew'" />
            </do_if>
            <show_notification caption="'Hired Crew'" details="$Details" timeout="5s" queued="true" priority="7" sound="notification_generic" />
            <reward_player money="(0 - $TotalFee)Cr" />
            
            <!-- Clean up for this iteration -->
            <remove_value name="$CrewAdded" />
            <remove_value name="$Details" />
            <remove_value name="$TotalFee" />
            <remove_value name="$CanAfford" />
            <remove_value name="$IsPoor" />
          </do_if>
          <do_elseif value="$IsPoor">
            <show_notification caption="'No Crew Hired'" details="'\nNot enough funds to hire.'" timeout="5s" queued="true" priority="7" sound="notification_warning" />
            <remove_value name="$CrewAdded" />
            <remove_value name="$Details" />
            <remove_value name="$TotalFee" />
            <remove_value name="$CanAfford" />
            <remove_value name="$IsPoor" />
            <break />
          </do_elseif>
          
        </do_all>
        
        <do_if value="$NoShips">
          <show_notification caption="'No Crew Hired'" details="'\nDidn\'t find any ships that needed crew.'" timeout="5s" queued="true" priority="7" sound="notification_warning" />
        </do_if>
        
        <remove_value name="$special" />
        <remove_value name="$NoShips" />
        
        <reset_cue cue="this" />
      </actions>
    </cue>
    
    <cue name="SectionHandler_Baely_ClaimShips" instantiate="false" namespace="this">
      <conditions>
        <check_any>
          <event_conversation_next_section sectionprefix="Baely_ClaimShips" />
          <event_conversation_returned_to_section sectionprefix="Baely_ClaimShips" />
        </check_any>
      </conditions>
      <actions>
        <!-- Claim ships in zone -->
        <set_value name="$IsPoor" exact="false" />
        <set_value name="$PilotAdded" exact="false" />
        <set_value name="$special" exact="false" />
        
        <find_ship groupname="$EmptyShips" multiple="true" class="[ class.ship_m, class.ship_s ]" space="player.zone" owner="faction.ownerless" />
        <do_if value="$EmptyShips.count">
          <set_value name="$Details" exact="[ 'Found %1 empty ship(s).'.[ $EmptyShips.count ] ]" />
          <set_value name="$TotalFee" exact="0" />
          
          <do_all exact="$EmptyShips.count" counter="$i">
            <create_cue_actor cue="this" name="$actor" tags="tag.pilot" ref="Bae_fighter" />
            <set_entity_type entity="$actor" type="entitytype.pilot" />
            
            <include_actions ref="Baely_FeeCalculation" />
            
            <do_if value="$CanAfford">
              <set_owner object="$actor" faction="faction.player" />
              
              <create_ship name="$boardingpod" group="boardingpods" zone="player.primaryship.zone">
                <pilot actor="$actor" />
                <position object="player.primaryship" x="40m" y="20m" z="-50m" max="10m" />
              </create_ship>
              <claim_ship target="$EmptyShips.{$i}" pilot="$actor" />
              <do_if value="$actor.ship == $EmptyShips.{$i}">
                <destroy_object object="$boardingpod" explosion="false" />
                <do_if value="$EmptyShips.{$i}.isplayerowned">
                  <set_value name="stat.ships_claimed" operation="add" />
                </do_if>
                <start_script object="$actor" name="'player.default'" />
                <set_value name="$PilotAdded" exact="true" />
                <signal_cue_instantly cue="md.NPC_Staff.LogHired" param="$actor" />
                <append_to_list name="$Details" exact="'Pilot %1 hired for %2'.[ $actor.name, $EmptyShips.{$i}.name ]" />
              </do_if>
            </do_if>
            <do_else>
              <set_value name="$IsPoor" exact="true" />
              <break />
            </do_else>
          </do_all>

          <do_if value="$PilotAdded">
            <append_to_list name="$Details" exact="'Spent %1k on hiring fees'.[ $TotalFee / 1000 ]" />
            <do_if value="$IsPoor">
              <append_to_list name="$Details" exact="'Not enough funds to hire pilots for the rest.'" />
            </do_if>
            <show_notification caption="'Hired Crew'" details="$Details" timeout="5s" queued="true" priority="7" sound="notification_generic" />
            <reward_player money="(0 - $TotalFee)Cr" />
          </do_if>
          <do_elseif value="$IsPoor">
            <show_notification caption="'No Crew Hired'" details="'Not enough funds to hire.\nDo you even lift, bro?'" timeout="5s" queued="true" priority="7" sound="notification_warning" />
          </do_elseif>
          
          <remove_value name="$Details" />
          <remove_value name="$TotalFee" />
          <remove_value name="$CanAfford" />
          <remove_cue_actor cue="this" actor="$actor" />
        </do_if>
        
        <do_else>
          <show_notification caption="'No Crew Hired'" details="'Didn\'t find any empty ships to claim.'" timeout="5s" queued="true" priority="7" sound="notification_warning" />
        </do_else>
        
        <remove_value name="$IsPoor" />
        <remove_value name="$PilotAdded" />
        <remove_value name="$special" />
        <reset_cue cue="this" />
      </actions>
    </cue>
    <!-- Library function to calculate fees for hired crew, about the same as vanilla + "convinience" charge.
        needs an actor entity and its entitytype to be in $actor variable
        needs $special flag for whether or not its for specialist. Leaves behind $fee 
        sets the variables $CanAfford (whether or not player can afford hiring of the actor)
        and $TotalFee (the running Total of fees so far in the qeue of hirings)
    -->
    <library name="Baely_FeeCalculation">
      <actions>
        <do_if value="$actor.type != null">
          <do_all exact="md.$HireFees.count" counter="$c">
            <do_if value="md.$HireFees.{$c}.{1} == $actor.type">
              <set_value name="$HireFeeParams" exact="md.$HireFees.{$c}" />
              <break />
            </do_if>
          </do_all>
        </do_if>
        <do_if value="$HireFeeParams?">
          <set_value name="$fee" exact="$HireFeeParams.{2}" />
          <set_value name="$HireFeeRange" exact="$HireFeeParams.{3} - $fee" />
          <do_if value="$HireFeeRange gt 0">
            <!-- 1/4 = skill based, 3/4 = random -->
            <set_value name="$fee" operation="add" exact="$actor.combinedskill * $HireFeeRange / (4 * 100)" />
            <set_value name="$fee" operation="add" min="0" max="$HireFeeRange * 3 / 4" />
            <!-- Convinience fee: Between 50% and 100% of normal fee (intends to represent how much time it saved you)-->
            <!-- Convinience fee: Between 100% and 200% of normal fee for specialists-->
            <do_if value="$special">
              <set_value name="$fee" operation="add" min="$fee" max="$fee * 2" />
            </do_if>
            <do_else>
              <set_value name="$fee" operation="add" min="$fee / 2" max="$fee" />
            </do_else>

          </do_if>
          <remove_value name="$HireFeeRange" />
          <remove_value name="$HireFeeParams" />
        </do_if>
        <do_else>
          <debug_text text="'No hiring fee for entitytype ' + $actor.type + ' defined. Defaulting to 10000 Cr.'" />
          <set_value name="$fee" exact="100000" />
        </do_else>

        <do_if value="( player.money - ($TotalFee)Cr ) ge ($fee)Cr">
          <set_value name="$TotalFee" operation="add" exact="$fee" />
          <set_value name="$CanAfford" exact="true" />
        </do_if>
        <do_else>
          <set_value name="$CanAfford" exact="false" />
        </do_else>
      </actions>
    </library>
      
    <cue name="SectionHandler_Baely_Get_" instantiate="true" namespace="this">
      <conditions>
        <check_any>
          <event_conversation_next_section sectionprefix="Baely_Get_" />
          <event_conversation_returned_to_section sectionprefix="Baely_Get_" />
        </check_any>
      </conditions>
      <actions>
        <do_if value="event.param == 'Baely_Get_Repairman'">
          <!-- Find closest ship -->
          <find_ship groupname="$CapShips" multiple="true" class="[class.ship_xl, class.ship_l]" space="player.zone" owner="faction.player" />
          <!-- If atleast one player owned capship is in zone -->
          <do_if value="$CapShips.count">
            <find_dock_location name="$ClosestDock" container="$CapShips.{1}" required="true" />
            <set_value name="$ClosestShip" exact="$CapShips.{1}" />

            <!-- If more than one ship available -->
            <do_if value="$CapShips.count gt 1">
              <do_all exact="$CapShips.count" counter="$i">
                <find_dock_location name="$CurrentShipDock" container="$CapShips.{$i}" required="true" />
                <do_if value="player.primaryship.distanceto.{$CurrentShipDock} lt player.primaryship.distanceto.{$ClosestDock}">
                  <debug_text text="'%1\'s dock is closer than %2\'s'.[ $ClosestDock.parent.name, $CurrentShipDock.parent.name]"/>
                  <set_value name="$ClosestDock" exact="$CurrentShipDock" />
                  <set_value name="$ClosestShip" exact="$CapShips.{$i}" />
                </do_if>
              </do_all>
            </do_if>

            <create_platform_actor name="$NewActor" dockingbay="$ClosestDock.component" type="entitytype.engineer" tags="tag.engineer" ref="Bae_argon_engineer">
              <owner exact="faction.friend" />
            </create_platform_actor>
            <show_notification caption="'Engineer Found'" details="'\n Please dock at %1 for repairs.'.[$ClosestShip.name]" timeout="5s" queued="false" priority="7" sound="notification_generic" />
          </do_if>
          <do_else>
            <show_notification caption="'No suitable Engineer Found'" details="'\n You ain\'t got no pancake mix!\n(nor capital ships in zone)'" timeout="5s" queued="false" priority="7" sound="notification_warning" />
          </do_else>
        </do_if>
        <!-- Called in mainmenu_baely.lua, event.param = "Baely_Get_Specialist",
         event.param2.{1} = "(entitytype)", event.param2.{2} = "(character reference ID)" -->
        <do_elseif value="event.param == 'Baely_Get_Specialist'">
          <set_value name="$special" exact="true" />
          <set_value name="$TotalFee" exact="0" />
          <do_if value="player.primaryship.numfreeactorslots" >
            <create_cue_actor cue="this" name="$actor" tags="tag.{event.param2.{1}}" ref="event.param2.{2}" />
            <set_entity_type entity="$actor" type="entitytype.{event.param2.{1}}" />

            <include_actions ref="Baely_FeeCalculation" />

            <do_if value="$CanAfford">
              <set_owner object="$actor" faction="faction.player" />
              <set_skills_visible entity="$actor" />

              <add_actor_to_playership actor="$actor" />
              <signal_cue_instantly cue="md.NPC_Specialist.OnPlatformPopulation_Specialist" param="$actor" />
              <show_notification caption="'Specialist Hired'" details="'\n%1 added to the back room.\nSpent %2k on hiring fees'.[ $actor.typename, $fee / 1000 ]" timeout="5s" queued="true" priority="8" sound="notification_generic" />
              <reward_player money="(0 - $TotalFee)Cr" />
            </do_if>
            <do_else>
              <show_notification caption="'Specialist not Hired'" details="'\n You don\'t have enough money to hire... \n You would need around %1k \nto hire a %2.'.[ $fee / 1000 , $actor.typename ]" timeout="8s" queued="true" priority="8" sound="notification_warning" />
            </do_else>
            <remove_value name="$TotalFee" />
            <remove_value name="$fee" />
            <remove_value name="$CanAfford" />
            <remove_cue_actor cue="this" actor="$actor" />
          </do_if>
          <do_else>
            <show_notification caption="'Specialist not Hired'" details="'\nShip has no more room for passengers'" timeout="5s" queued="false" priority="8" sound="notification_warning" />
          </do_else>
          <remove_value name="$special" />
        </do_elseif>
        
        <reset_cue cue="this" />
      </actions>
    </cue>
    
    <cue name="SectionHandler_Baely_GetBackup" instantiate="false" namespace="this">
      <conditions>
        <check_any>
          <event_conversation_next_section sectionprefix="Baely_GetBackup" />
          <event_conversation_returned_to_section sectionprefix="Baely_GetBackup" />
        </check_any>
      </conditions>
      <actions>
        <set_value name="$isCapShip" exact="false" />
        <do_if value="event.param == 'Baely_GetBackup_Capital'">
          <set_value name="$isCapShip" exact="true" />
          <create_ship name="$Arawn" groupname="$CapShips" zone="player.zone" macro="units_size_xl_capital_destroyer_1_macro">
            <owner exact="faction.player" />
            <pilot actor="null"/>
            <defence actor="null"/>
            <engineer actor="null"/>
            <ammo>
              <macro ref="macro.missile_turret_dumbfire_macro">
                <fillpercent min="80" max="95" />
              </macro>
              <macro ref="macro.missile_turret_swarm_macro">
                <fillpercent min="80" max="95" />
              </macro>
            </ammo>
            <units>
              <unit category="unitcategory.attack" mk="1" min="100" max="140" />
              <unit category="unitcategory.defence" mk="6" min="100" max="130" />
              <unit category="unitcategory.welder" mk="1" min="20" max="30" />
            </units>
            <cargo>
              <wares list="[ware.fuelcells]">
                <fillpercent min="80" max="100" />
              </wares>
            </cargo>
            <!--<drop ref="ship_large_military" /> what's this? -->
            <safepos object="player.primaryship" x="5km" y="1km" z="6km" />
          </create_ship>
        </do_if>
        
        <do_elseif value="event.param == 'Baely_GetBackup_Trader'">
          <set_value name="$isCapShip" exact="true" />
          <do_all exact="3" counter="$s">
            <create_ship name="$Tits" groupname="$CapShips" macro="units_size_xl_cargo_hauler_2_macro" zone="player.zone">
              <owner exact="faction.player" overridenpc="true"/>
              <pilot actor="null"/>
              <defence actor="null"/>
              <engineer actor="null"/>
              <cargo>
                <wares list="[ware.fuelcells]">
                  <fillpercent exact="100"/>
                </wares>
                <wares list="[ware.reinforcedmetalplating, ware.fusionreactor]">
                  <fillpercent min="50" max="75"/>
                </wares>
              </cargo>
              <units>
                <unit category="unitcategory.transport" mk="1" min="50" max="75"/>
                <unit category="unitcategory.welder" mk="1" min="50" max="75"/>
              </units>
              <!--<drop ref="ship_large_civilian"/> what's this? -->
              <safepos object="player.primaryship" allowyaxis="true" radius="4km" max="8km" />
            </create_ship>
            <!-- Add Crew -->
          </do_all>
        </do_elseif>
        
        <do_elseif value="event.param == 'Baely_GetBackup_Swarm'">
          <do_all min="5" max="15">
            <create_ship name="$smallShip" zone="player.zone" group="Bae_guard_ships">
              <owner exact="faction.player" overridenpc="true" />
              <pilot ref="Bae_fighter" />
              <safepos object="player.primaryship" allowyaxis="true" radius="player.primaryship.size * 3" max="player.primaryship.size * 8" />
            </create_ship>
            <set_object_commander object="$smallShip" commander="player.primaryship" />
            <start_script object="$smallShip.pilot" name="'player.default'" />
          </do_all>
        </do_elseif>
        
        <do_if value="$isCapShip">
          <do_all exact="$CapShips.count" counter="$i">
            <set_value name="$CapShip" exact="$CapShips.{$i}" />
            <find_dock_location name="$Dock" container="$CapShip" required="true" />
            <create_platform_actor name="$Commander" dockingbay="$Dock.component" type="entitytype.commander" tags="tag.commander" ref="Bae_commander">
              <owner exact="faction.player" />
            </create_platform_actor>
            <assign_pilot actor="$Commander" object="$CapShip" />
            <start_script object="$Commander" name="'player.default'" />

            <create_platform_actor name="$Engineer" dockingbay="$Dock.component" type="entitytype.engineer" tags="tag.engineer" ref="Bae_engineer">
              <owner exact="faction.player" />
            </create_platform_actor>
            <assign_engineer actor="$Engineer" object="$CapShip" />
            <start_script object="$Engineer" name="'engineer.ai'" />

            <create_platform_actor name="$Defence" dockingbay="$Dock.component" type="entitytype.defencecontrol" tags="tag.defencecontrol" ref="Bae_defence">
              <owner exact="faction.player" />
            </create_platform_actor>
            <assign_defence_manager actor="$Defence" object="$CapShip" />
            <start_script object="$Defence" name="'fight.defend.capital'" />
            <remove_value name="$ship" />
          </do_all>
        </do_if>
        <remove_value name="$isCapShip" />
        <show_notification caption="'Backup is here'" details="[ 'So these niggas can know:', 'I do what they cayn\'t', 'I\'m stuntin for all the people who ain\'t', 'You still hatin?', 'You should be fuckin ashamed.']" timeout="5s" queued="true" priority="5" sound="notification_generic" />
        <reset_cue cue="this" />
      </actions>
    </cue>

    <cue name="SectionHandler_Baely_DoThis" instantiate="false" namespace="this">
      <conditions>
        <check_any>
          <event_conversation_next_section sectionprefix="Baely_DoThis" />
          <event_conversation_returned_to_section sectionprefix="Baely_DoThis" />
        </check_any>
      </conditions>
      <actions>
        
        <!-- Remove foreign actors from player's ship
        <set_value name="$Actors" exact="player.ship.actors" />
        <set_value name="$Details" exact="[]" />
        <do_all exact="$Actors.count" counter="$i">
          <do_if value="$Actors.{$i}.isplayerowned" negate="true">
            <remove_actor_from_room actor="$Actors.{$i}" />
            <append_to_list name="$Details" exact="'Removed %1'.[ $Actors.{$i}.name ]" />
          </do_if>
          <do_else>
            <append_to_list name="$Details" exact="'Kept %1'.[ $Actors.{$i}.name ]" />
          </do_else>
        </do_all>
        <append_to_list name="$Details" exact="'Started with %1'.[ $Actors.count ]" />
        <append_to_list name="$Details" exact="'Ended up with %1'.[ player.ship.actors.count ]" />
        <show_notification caption="'Remove Script Completed'" details="$Details" timeout="10s" queued="false" priority="7" sound="notification_warning" />
        <remove_value name="$Details" />
        <remove_value name="$Actors" />-->
        
        <!-- <find_station name="$PlayerStations" owner="faction.player" space="player.zone" multiple="true" />
        <do_all exact="$PlayerStations.count" counter="$i" >
        <find_dock_location name="$DockingBay" container="$PlayerStations.{$i}" multiple="true" />
        <do_all exact="$DockingBay.count" counter="$j" >
          Remove all NPC-owned actors from player owned stations (Temporary fix to remove specialists in my savegame) 
          <do_all exact="$DockingBay.{$j}.actors.count" counter="$c" >
            <do_if value="not $DockingBay.{$j}.actors.{$c}.isplayerowned">
              <remove_actor_from_room actor="$DockingBay.{$j}.actors.{$c}" />
              <destroy_object object="$DockingBay.{$j}.actors.{$c}" explosion="false" />
            </do_if>
          </do_all>
        </do_all>
        </do_all>-->
        
        <!-- Find Empty ships in the system and galaxy -->
        <find_ship groupname="$AllEmptyShips" multiple="true" owner="faction.ownerless" space="player.galaxy" />
        <find_ship groupname="$SystemEmptyShips" multiple="true" owner="faction.ownerless" space="player.cluster" />
        <do_if value="$AllEmptyShips.count">
          <show_notification caption="'Search Completed'" details="'Found %1 ships total, found %2 ships in this system, check logbook for details'.[ $AllEmptyShips.count, $SystemEmptyShips.count ]" timeout="10s" queued="false" priority="7" sound="notification_generic" />
          <do_if value="$SystemEmptyShips.count">
            <set_value name="$text" exact="'Baely\'s results for ship search in %1:\n'.[ player.cluster.name ]" />
            <set_value name="$c" exact="0" />
            <set_value name="$entries" exact="[]" />
            <do_all exact="$SystemEmptyShips.count" counter="$i">
              <do_if value="$c == 5" >
                <append_to_list name="$entries" exact="$text" />
                <set_value name="$text" exact="'Found %1 in %2.\n'.[ $SystemEmptyShips.{$i}.name, $SystemEmptyShips.{$i}.zone.name ]" />
                <set_value name="$c" exact="0" />
              </do_if>
              <do_else>
                <set_value name="$text" exact="'%1Found %2 in %3.\n'.[ $text, $SystemEmptyShips.{$i}.name, $SystemEmptyShips.{$i}.zone.name ]" />
              </do_else>
              <set_value name="$c" operation="add" />
            </do_all>
            
            <do_if value="$entries.count">
              <do_all exact="$entries.count" counter="$h">
                <write_to_logbook category="tips" text="$entries.{$h}" />
              </do_all>
            </do_if>
            <do_if value="$c != 0">
              <write_to_logbook category="tips" text="$text" />
            </do_if>

            <remove_value name="$c" />
            <remove_value name="$text" />
            <remove_value name="$entries" />
          </do_if>
        </do_if>
        <do_else>
          <show_notification caption="'Search Completed'" details="'Didn\'t find any empty ships'" timeout="5s" queued="false" priority="7" sound="notification_warning" />
        </do_else>
        
        <!-- for development purposes 
        <set_value name="$jobWeight" value="[[[dockpopulationtype.bar, dockpopulationtype.ships], 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 40, 0, 40, 60, 50], [dockpopulationtype.repair, 80, 80, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0], [dockpopulationtype.trade, 0, 0, 0, 0, 40, 40, 40, 40, 30, 40, 40, 0, 0, 0, 0, 0, 0, 0], [[dockpopulationtype.administrative, dockpopulationtype.ammo, dockpopulationtype.drones, dockpopulationtype.build], 80, 80, 50, 60, 40, 40, 40, 40, 30, 40, 40, 50, 50, 40, 60, 40, 60, 50]]" />
        <find_station name="$PlayerStations" space="player.zone" multiple="true" />
        <do_all exact="$PlayerStations.count" counter="$i" >
          <find_dock_location name="$DockingBay" container="$PlayerStations.{$i}" freemissionactorslot="true" multiple="true" dockpopulationtype="$jobWeight.{1}.{1}" />
          <do_all exact="$DockingBay.count" counter="$d">
            <show_notification caption="'Debug info'" details="'bar and ships'" timeout="5s" queued="true" priority="7" sound="notification_warning" />
          </do_all>
          
        </do_all>-->
        <reset_cue cue="this" />
      </actions>
    </cue>
     
    
    
    
    
  </cues>
</mdscript><?xml version="1.0" encoding="utf-8" ?>
<diff>
  <!-- Make it a Bae pilot -->
  <replace sel="/mdscript[@name='NPC_Shiptrader']/cues/cue[@name='Base']/cues/cue[@name='BuildFinished']/actions/do_if/do_if/create_cue_actor">
    <create_cue_actor cue="this" tags="tag.commander" ref="Bae_commander" />
  </replace>
</diff><?xml version="1.0" encoding="utf-8" ?>
<diff>
  <!--  Make it a Bae pilot -->
  <replace sel="/mdscript[@name='NPC_Shiptrader_Small']/cues/cue[@name='Base']/cues/cue[@name='SectionHandler']/actions/do_elseif/do_if/do_all/create_ship/pilot">
    <pilot ref="Bae_fighter">
      <owner exact="faction.player" />
    </pilot>
  </replace>
</diff><?xml version="1.0" encoding="utf-8"?>
<addon name="Baely" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Temp\Rebirth\ui\core\addon.xsd">
  <environment type="fullscreen">
    <file name="ui/bae_mainmenu/mainmenu_Baely.lua" />
    <dependency name="ego_mainmenu" />
  </environment>
</addon>local entitytypesetup = {
-- Specialist for station
    { type = "specialistagriculture", skills = "Bae_speciallead", info = ReadText(1002, 21501) }, { type = "specialistpowerstorage", skills = "Bae_specialman", info = ReadText(1002, 21502) }, { type = "specialistfood", skills = "Bae_specialman", info = ReadText(1002, 21503) }, { type = "specialistchemical", skills = "Bae_specialman", info = ReadText(1002, 21504) }, { type = "specialistprecision", skills = "Bae_specialman", info = ReadText(1002, 21505) }, { type = "specialistweapons", skills = "Bae_specialcombat", info = ReadText(1002, 21506) }, { type = "specialistpharmaceuticals", skills = "Bae_speciallead", info = ReadText(1002, 21507) }, {type = "specialistmetals", skills = "Bae_specialman", info = ReadText(1002, 21508) }, {type = "specialistgeophysics", skills = "Bae_specialnav", info=ReadText(1002, 21509) }, { type = "specialistsurfacesystems", skills = "Bae_specialman", info = ReadText(1002, 21510) }, { type = "specialistpowersupply", skills = "Bae_specialman", info = ReadText(1002, 21511) }, { type = "specialistaquatics", skills = "Bae_specialnav", info = ReadText(1002, 21512) }
}
local menuAddon = {
    entry1 = {
        icon = "mm_ic_comm_crewforplayer",
	name = "Hire crew for me",
        info = "Skip employee hunting - for a fee",
        list = {
            [1] = {
                icon = "mm_ic_comm_crewforcapship",
                section = "Baely_GetCrew",
		name = "Man them capital ships!",
		info = "Hire crew for your empty capital ships in zone"
            },
            [2] = {
                icon = "mm_ic_comm_crewforplayer",
                section = "Baely_ClaimShips",
		name = "Claim them ships",
		info = "Hire crew for all the ownerless ships in zone"
            }
        }
    },
    entry2 = {
        icon = "mm_ic_comm_services",
        name = "I need some repairs",
        section = "Baely_Get_Repairman",
        info = "Place an engineer on the closest owned capital ship"
    },

    entry3 = {
        icon = "mm_ic_ability_smartdefense",
        name = "I need backup!",
        info = "Summon friendlies to defend you",
        list = {
            [1] = {
                icon = "mm_ic_comm_crewforcapship",
                name = "Sledgehammer",
		section = "Baely_GetBackup_Capital",
		info = "Summon Arawn to defend you."
            },
            [2] = {
                icon = "mm_ic_ability_smartdefense",
                name = "Swarm",
		section = "Baely_GetBackup_Swarm",
		info = "Summon a swarm to defend you."
            },
            [3] = {
                icon = "mm_ic_comm_trader",
                name = "Traders",
		section = "Baely_GetBackup_Trader",
		info = "Summon Traders to defend you."
            }
        }
    },
    entry4 = {
        icon = "mm_ic_info_logbook",
	name = "Run Script...",
        section = "Baely_DoThis",
	info = "Search for ownerless ships"
    }
}

local function createSetupBaely(menu)
    local playership = GetPlayerPrimaryShipID()
    local player = GetComponentData(playership, "controlentity")
    local playerroom = GetPlayerRoom()
    local incockpit = IsComponentClass(playerroom, "cockpit")
    local playersector = GetComponentData(playership, "sectorid")
    local crew = GetNPCs(playership)
    local hascrew = false

    -- Skunk has crew in back room check for Intercom function
    if 0 < #crew then
        for _, npc in ipairs(crew) do
            local owner = GetComponentData(npc, "owner")
            if owner == "player" then
                hascrew = true
                break
            end
        end
    end
    
    -- Create specialists section
    local speclist = {}
    for _, type in ipairs(entitytypesetup) do
            local icon, name = GetEntityTypeData(type.type, "icon", "name")
            table.insert(speclist, { icon = icon, name = name, section = "Baely_Get_Specialist", sectionparam = { type.type, type.skills }, info = type.info })
    end
    local specsection = {
        icon = "mm_ic_comm_specialistforstation",
	name = "Hire me a Specialist",
	info = "Skip Specialist hunting - for a fee",
        list = speclist
    }

    -- Create intercom section
    local intercomsection = {
        icon = "mm_ic_crew_callremotely",
        name = ReadText(1002, 1076),
        section = "gMain_crewList",
        sectionparam = {0, 0, playership},
        condition = hascrew,
        info = ReadText(1002, 21048),
    }

    -- Insert new section entries into actual menu
    for _, subMenu in ipairs(menu.setup.top) do
        if subMenu.icon == "mm_ic_crew" then
            if (incockpit) then
                table.insert(subMenu.list, intercomsection)
                table.insert(subMenu.list, menuAddon.entry1)
                table.insert(subMenu.list, menuAddon.entry2)
                --table.insert(subMenu.list, menuAddon.entry3)
                table.insert(subMenu.list, specsection)
                --table.insert(subMenu.list, menuAddon.entry4)
            end
        end
    end
end

local function createSetupWrapper()
    menuAddon.origCreateSetup()
    createSetupBaely(menuAddon.menu)
end

local function init()
    if Menus then
        for _, menu in ipairs(Menus) do
            if menu.name == "MainMenu" then
                menuAddon.menu = menu
                menuAddon.origCreateSetup = menu.createSetup
                menu.createSetup = createSetupWrapper
                break
            end
        end
    end
end

init()
Baely v1.0
==================
You'd think there be more X-Rebirth mods to choose from after 2 years since its release.
Anyways,
Somewhere along midgame, X-Rebirth starts having so many repetitive micromanagement tasks that it becomes difficult to stay interested.
So I made this mod to "SETA" my way forward, if you will, and skip employee hunting and get back to boarding and station building and all that other good stuff sooner. 

What is it?
-----------
This mod adds a few sub-menus under Main > Crew (ENTER-7)
2."Call Remotely" - Intercom function identical to the vanilla version that you normally see only while inside a station.

3."Hire crew for me" 
 ->1."Man them capital ships!"- Generates and hires crew for all the player owned capital ships in sector. Each new employee cost 150% to 200% of normal hiring fees.
 ->2."Claim them ships" - Automatically claims all ownerless ships in zone, hiring fees apply.

4."I need repairs" - Places a friendly engineer on the closest owned capital ship to allow for repairs

5."Hire me a Specialist"
 ->[List of all specialists] - Choose a specialist, any specialist. Costs 200% to 300% of normal hiring fees. Bypasses incarnation system problem and places it, player-owned, in skunk backroom.

These functions use custom characters/charactergroups to ensure each NPC has vanilla star levels with only primary skills at 5 stars.

While I was at it, I modified the ship trader scripts to hire Baely commander and pilots instead of the bland, mediocre pilots they normally hire.

Feedback is welcomed.

Developed while using X Rebirth v3.60

Changes
-------
v1.0 -
    -Skipped 0.01-1.0 alphas and Published at 1.0

Uninstall
---------

Unsuscribe in Steam WS to deactivate/remove. Should not have any effect on save games.

Credits
-------
BlackRain whose NPCSpawn Mod inspired me to start my own modding. (thanks)
J3ANP3T3R, Yorrick Vander, UniTrader, euclid + Mad_Joker.<?xml version="1.0" encoding="utf-8"?>
<content id="" name="" description="" author="Apostilite" version="102" date="2015-09-09" save="false" lastupdate="">
  <dependency version="360"/>
  <text language="44" name="Baely" description="Baely does 5 things on command:&#10;1. Instantly hire crew and put them to work on inzone capitalships. Useful for post-boarding ops.&#10;2. Instantly hire pilots and use them to claim all ships in current zone&#10;3. Call Remotely intercom function while in cockpit&#10;4. Place a friendly Engineer on an inzone playerowned capital ship to get repairs&#10;5. Instantly hire any specialist and place it in the Skunk's backroom" author="Apostilite" version="102" date="2015-09-8" save="false"/>
</content>
