XRWS         !  ó  â  æ+  ext_01.cat ext_01.dat readme.txt aiscripts/EuclidsStationengineer.ai.xml 25561 1450219954 6cd119907a065c631dab019dddfd967c
aiscripts/trade.station.player.xml 4466 1418246731 cf29365e8252739fb6b8f4fe94bb7a5f
md/EuclidsTempZoneStationBuilder.xml 21739 1437715003 0e59219b7e2e36bfad867f81af519f17
md/EuclidsTempZoneStationBuilder_shipdiler.xml 2984 1516402289 29eb29c0822e55f345fcb0c4e6c243e9
t/0001-L007.xml 2340 1516402129 b5a51158a470aa7325451b083dfa3252
t/0001.xml 1833 1528401147 8571b71fa586fb0effc7a92f62ccb8e4
<?xml version="1.0" encoding="utf-8" ?>
<aiscript name="EuclidsStationengineer.ai" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="aiscripts.xsd" version="5">
  <init>
    <set_command command="command.repair" />
    <set_command_action commandaction="commandaction.repairchecking" />
    <set_value name="$networkcreated" exact="false" />
  </init>
  <patch sinceversion="3">
    <set_value name="$baserepairrate" exact="250" />
  </patch>
  <patch sinceversion="5">
    <set_value name="$networkcreated" exact="$networkid?" />
    <remove_value name="$networkid" />
  </patch>
  <attention min="unknown">
    <actions>
     
      <do_if value="$operationalelements?">
        <remove_value name="$operationalelements"/>
      </do_if>

      <!-- init -->
      <set_value name="$repairfrequency" exact="20s" />
      <set_value name="$nextelementcheck" exact="0" />
      <set_value name="$baserepairrate" exact="250" />
      <set_value name="$CurrentElement" exact="null"/>

      <label name="checkforrepair" />
			
	
      <set_value name="$hulldamagelimit" exact="100" comment="below what percentage hull is a component considered damaged"/>
      <do_if value="not $CurrentElement.exists">
		    <wait min="10s" max="25s" sinceversion="3" />
      </do_if>
      <wait min="$repairfrequency" max="$repairfrequency + 1s" sinceversion="2"/>
      <set_value name="$Defensible" exact="this.defensible"/>
			
	<!-- Start: restore ammo and drones (only mk1 are filled up) every hour if required -->
		  <do_if value="$Defensible.isclass.station and ((player.age - this.$ammocheck)/1h gt 1)">
				  <set_value name="this.$ammocheck" exact="player.age"/>
					<wait min="3s" max="5s"/>
				
		<!-- welder check -->		
					<set_value name="$Drones" exact="0.5*$Defensible.units.maxcount - $Defensible.units.{unitcategory.welder}.count" />
					<do_if value="($Drones gt 0) and ($Defensible.units.count lt $Defensible.units.maxcount)">
						<set_value name="$Cost" exact="50000000"/>
						<find_sell_offer tradepartner="this.station" wares="ware.drp_construction" space="player.galaxy" result="$selloffers" multiple="true"/>
						<do_if value="$selloffers.count"  min="1">
							<do_all exact="$selloffers.count" counter="$i">
								<do_if value="($selloffers.{$i}.amount ge $Drones) and ($selloffers.{$i}.unitprice lt $Cost)">
									<set_value name="$Cost" exact="$selloffers.{$i}.unitprice"/>
									<set_value name="$selloffer" exact="$selloffers.{$i}"/>
								</do_if>
              </do_all>
						</do_if>
						<do_else>
							 <write_to_logbook category="upkeep" text="{360010,30}.[this.name,$Defensible.knownname,$Drones]" comment="This is %1 from the %2\n I need %3 Construction drones but cannot find a seller. I will try again in 1 hour." />
						</do_else>
						<remove_value name="$selloffers" />
						<do_if value="$selloffer?">
						  <add_ware_reservation type="buy" object="$selloffer.seller" ware="ware.drp_construction" entity="this" amount="$Drones" duration="1h"/>	
							<do_if value="$selloffer.seller.owner == faction.player">
				        <do_if value="@$selloffer.sellerentity and not @$selloffer.seller.commander">
					        <set_value name="$STradenpc" exact="$selloffer.sellerentity" />
				        </do_if>
				        <do_elseif value="@$selloffer.seller.commanderentity">
					        <set_value name="$STradenpc" exact="$selloffer.seller.commanderentity" />
				        </do_elseif>
			        </do_if>	 
							<remove_cargo object="$selloffer.seller" ware="ware.drp_construction" exact="$Drones"/>
							<add_units object="$Defensible" category="unitcategory.welder" mk="1" exact="$Drones" />
							<do_if value="$STradenpc?">
								<transfer_money from="player.entity" to="$STradenpc" amount="$Cost*$Drones" />
								<remove_value name="$STradenpc" />
							</do_if>
							<do_else>
								<reward_player money="-$Cost*$Drones" />
							</do_else>
							<remove_ware_reservation object="$selloffer.seller" entity="this" ware="ware.drp_construction" amount="$Drones"/> 
							<write_to_logbook category="upkeep" text="{360010,33}.[this.name,$Defensible.knownname,$Drones,$selloffer.seller.knownname,($Cost*$Drones)/1Cr]" comment="This is %1 from the %2\n I bought %3 Construction drones from %4 for %5 Credits." />
              <!-- cleanup -->
							<remove_value name="$selloffer" />
							<remove_value name="$Cost" />
						</do_if>
						<do_else>
							 <write_to_logbook category="upkeep" text="{360010,30}.[this.name,$Defensible.knownname,$Drones]" comment="This is %1 from the %2\n I need %3 Construction drones but cannot find a seller. I will try again in 1 hour." />
						</do_else>
          </do_if>
				
				  <wait min="1s" max="2s"/>
				
			<!-- transport  check -->			
					<set_value name="$Drones" exact="0.25*$Defensible.units.maxcount - $Defensible.units.{unitcategory.transport}.count" />
					<do_if value="($Drones gt 0) and ($Defensible.units.count lt $Defensible.units.maxcount)">
						<set_value name="$Cost" exact="50000000"/>
						<find_sell_offer tradepartner="this.station" wares="ware.drp_cargolifter" space="player.galaxy" result="$selloffers" multiple="true"/>
						<do_if value="$selloffers.count"  min="1">
							<do_all exact="$selloffers.count" counter="$i">
								<do_if value="($selloffers.{$i}.amount ge $Drones) and ($selloffers.{$i}.unitprice lt $Cost)">
									<set_value name="$Cost" exact="$selloffers.{$i}.unitprice"/>
									<set_value name="$selloffer" exact="$selloffers.{$i}"/>
								</do_if>
              </do_all>
						</do_if>
						<do_else>
							 <write_to_logbook category="upkeep" text="{360010,36}.[this.name,$Defensible.knownname,$Drones]" comment="This is %1 from the %2\n I need %3 Transport drones but cannot find a seller. I will try again in 1 hour." />
						</do_else>
						<remove_value name="$selloffers" />
						<do_if value="$selloffer?">
						  <add_ware_reservation type="buy" object="$selloffer.seller" ware="ware.drp_cargolifter" entity="this" amount="$Drones" duration="1h"/>	
							<do_if value="$selloffer.seller.owner == faction.player">
				        <do_if value="@$selloffer.sellerentity and not @$selloffer.seller.commander">
					        <set_value name="$STradenpc" exact="$selloffer.sellerentity" />
				        </do_if>
				        <do_elseif value="@$selloffer.seller.commanderentity">
					        <set_value name="$STradenpc" exact="$selloffer.seller.commanderentity" />
				        </do_elseif>
			        </do_if>	 
							<remove_cargo object="$selloffer.seller" ware="ware.drp_cargolifter" exact="$Drones"/>
							<add_units object="$Defensible" category="unitcategory.transport" mk="1" exact="$Drones" />
							<do_if value="$STradenpc?">
								<transfer_money from="player.entity" to="$STradenpc" amount="$Cost*$Drones" />
								<remove_value name="$STradenpc" />
							</do_if>
							<do_else>
								<reward_player money="-$Cost*$Drones" />
							</do_else>
							<remove_ware_reservation object="$selloffer.seller" entity="this" ware="ware.drp_cargolifter" amount="$Drones"/> 
							<write_to_logbook category="upkeep" text="{360010,39}.[this.name,$Defensible.knownname,$Drones,$selloffer.seller.knownname,($Cost*$Drones)/1Cr]" comment="This is %1 from the %2\n I bought %3 Transport drones from %4 for %5 Credits." />
	            <!-- cleanup -->
							<remove_value name="$selloffer" />
							<remove_value name="$Cost" />
						</do_if>
						<do_else>
							 <write_to_logbook category="upkeep" text="{360010,36}.[this.name,$Defensible.knownname,$Drones]" comment="This is %1 from the %2\n I need %3 Transport drones but cannot find a seller. I will try again in 1 hour." />
						</do_else>
					</do_if>
				
				  <wait min="1s" max="2s"/>
				
		<!-- defence check -->		
					<set_value name="$Drones" exact="0.25*$Defensible.units.maxcount - $Defensible.units.{unitcategory.defence}.count" />
					    <do_if value="($Drones gt 0) and ($Defensible.units.count lt $Defensible.units.maxcount)">
						<set_value name="$Cost" exact="50000000"/>
						<find_sell_offer tradepartner="this.station" wares="ware.drp_interceptor_mk1" space="player.galaxy" result="$selloffers" multiple="true"/>
						<do_if value="$selloffers.count"  min="1">
							<do_all exact="$selloffers.count" counter="$i">
								<do_if value="($selloffers.{$i}.amount ge $Drones) and ($selloffers.{$i}.unitprice lt $Cost)">
									<set_value name="$Cost" exact="$selloffers.{$i}.unitprice"/>
									<set_value name="$selloffer" exact="$selloffers.{$i}"/>
								</do_if>
              </do_all>
						</do_if>
						<do_else>
							 <write_to_logbook category="upkeep" text="{360010,42}.[this.name,$Defensible.knownname,$Drones]" comment="This is %1 from the %2\n I need %3 Defence drones but cannot find a seller. I will try again in 1 hour." />
						</do_else>
						<remove_value name="$selloffers" />
						<do_if value="$selloffer?">
						  <add_ware_reservation type="buy" object="$selloffer.seller" ware="ware.drp_interceptor_mk1" entity="this" amount="$Drones" duration="1h"/>	
							<do_if value="$selloffer.seller.owner == faction.player">
				        <do_if value="@$selloffer.sellerentity and not @$selloffer.seller.commander">
					        <set_value name="$STradenpc" exact="$selloffer.sellerentity" />
				        </do_if>
				        <do_elseif value="@$selloffer.seller.commanderentity">
					        <set_value name="$STradenpc" exact="$selloffer.seller.commanderentity" />
				        </do_elseif>
			        </do_if>	 
							<remove_cargo object="$selloffer.seller" ware="ware.drp_interceptor_mk1" exact="$Drones"/>
							<add_units object="$Defensible" category="unitcategory.defence" mk="1" exact="$Drones" />
							<do_if value="$STradenpc?">
								<transfer_money from="player.entity" to="$STradenpc" amount="$Cost*$Drones" />
								<remove_value name="$STradenpc" />
							</do_if>
							<do_else>
								<reward_player money="-$Cost*$Drones" />
							</do_else>
							<remove_ware_reservation object="$selloffer.seller" entity="this" ware="ware.drp_interceptor_mk1" amount="$Drones"/> 
							<write_to_logbook category="upkeep" text="{360010,45}.[this.name,$Defensible.knownname,$Drones,$selloffer.seller.knownname,($Cost*$Drones)/1Cr]" comment="This is %1 from the %2\n I bought %3 Defence drones from %4 for %5 Credits." />
	            <!-- cleanup -->
							<remove_value name="$selloffer" />
							<remove_value name="$Cost" />
						</do_if>
						<do_else>
							 <write_to_logbook category="upkeep" text="{360010,42}.[this.name,$Defensible.knownname,$Drones]" comment="This is %1 from the %2\n I need %3 Defence drones but cannot find a seller. I will try again in 1 hour." />
						</do_else>
					</do_if>
				
				  <wait min="1s" max="2s"/>
				
				<!-- ammo check -->			
			    <evaluate_ammo_storage object="$Defensible" type="missile" amounts="$amountlist" macros="$macrolist" wares="$wares"/>
				  <do_all exact="$macrolist.count" counter="$j">
					 <set_value name="$Drones" exact="$amountlist.{$j}-$Defensible.ammostorage.{$macrolist.{$j}}.count" />
						
					 <wait min="1s" max="2s"/>
						
					 <do_if value="$Drones gt 0">
						<set_value name="$Cost" exact="50000000"/>
						<find_sell_offer tradepartner="this.station" wares="$wares.{$j}" space="player.galaxy" result="$selloffers" multiple="true"/>
						<do_if value="$selloffers.count"  min="1">
							<do_all exact="$selloffers.count" counter="$i">
								<do_if value="($selloffers.{$i}.amount ge $Drones) and ($selloffers.{$i}.unitprice lt $Cost)">
									<set_value name="$Cost" exact="$selloffers.{$i}.unitprice"/>
									<set_value name="$selloffer" exact="$selloffers.{$i}"/>
								</do_if>
              </do_all>
						</do_if>
						<do_else>
							 <write_to_logbook category="upkeep" text="{360010,48}.[this.name,$Defensible.knownname,$Drones,$wares.{$j}.name]" comment="This is %1 from the %2\n I need %3  %4 but cannot find a seller. I will try again in 1 hour." />
						</do_else>
						<remove_value name="$selloffers" />
						<do_if value="$selloffer?">
						  <add_ware_reservation type="buy" object="$selloffer.seller" ware="$wares.{$j}" entity="this" amount="$Drones" duration="1h"/>	
							<do_if value="$selloffer.seller.owner == faction.player">
				        <do_if value="@$selloffer.sellerentity and not @$selloffer.seller.commander">
					        <set_value name="$STradenpc" exact="$selloffer.sellerentity" />
				        </do_if>
				        <do_elseif value="@$selloffer.seller.commanderentity">
					        <set_value name="$STradenpc" exact="$selloffer.seller.commanderentity" />
				        </do_elseif>
			        </do_if>	 
							<remove_cargo object="$selloffer.seller" ware="$wares.{$j}" exact="$Drones"/>
							<add_ammo object="$Defensible" macro="$macrolist.{$j}" amount="$Drones" />
							<do_if value="$STradenpc?">
								<transfer_money from="player.entity" to="$STradenpc" amount="$Cost*$Drones" />
								<remove_value name="$STradenpc" />
							</do_if>
							<do_else>
								<reward_player money="-$Cost*$Drones" />
							</do_else>
							<remove_ware_reservation object="$selloffer.seller" entity="this" ware="$wares.{$j}" amount="$Drones"/> 
							<write_to_logbook category="upkeep" text="{360010,51}.[this.name,$Defensible.knownname,$Drones,$wares.{$j}.name,$selloffer.seller.knownname,($Cost*$Drones)/1Cr]" comment="This is %1 from the %2\n I bought %3  %4 from %5 for %6 Credits." />
	            <!-- cleanup -->
							<remove_value name="$selloffer" />
							<remove_value name="$Cost" />
						</do_if>
						<do_else>
							 <write_to_logbook category="upkeep" text="{360010,48}.[this.name,$Defensible.knownname,$Drones,$wares.{$j}.name]" comment="This is %1 from the %2\n I need %3  %4 but cannot find a seller. I will try again in 1 hour." />
						</do_else>
					</do_if>
				</do_all>
			<!-- ammo end  -->				
				<remove_value name="$wares"/>
				<remove_value name="$Drones"/>
		    <remove_value name="$amountlist"/>
				<remove_value name="$macrolist"/>
			</do_if>
 <!-- End: restore ammo and drones -->	 
			
			<do_if value="$CurrentElement.exists">
        <do_if value="$CurrentElement.iswreck">
          <!--Do not fix wrecked components where the parent is also a wreck-->
          <do_if value="not $CurrentElement.parent.iswreck">
            <resume label="startrepair"/>
          </do_if>
        </do_if>

        <do_if value="$CurrentElement.hullpercentage lt $hulldamagelimit">
          <!--Have a chance to break out if the component is already functional again-->
          <do_if value="$CurrentElement.isfunctional">
            <resume label="startrepair" chance="70"/>
          </do_if>
          <do_else>
            <resume label="startrepair"/>
          </do_else>
        </do_if>
      </do_if>
      <set_value name="$CurrentElement" exact="null"/>

      <!--Find surface elements and put them in the correct lists/groups-->
      <!--This can be quite expensive so only do it once finished with the $CurrentElement-->
      <do_if value="player.age" min="$nextelementcheck">
        <set_value name="$nextelementcheck" min="player.age + 1min" max="player.age + 2min"/>
        <create_group groupname="$PossibleElements"/>
        <set_value name="$FindChance" exact="100"/>

        
        <!--find large, non surface element destructibles-->
        <find_object_component chance="$FindChance" groupname="$PossibleElements" object="$Defensible" class="class.destructible" surfaceelement="false" checkoperational="false" multiple="true">
          <match class="[class.adsign, class.ship]" checkoperational="false" negate="true"/>
          <match_macro_children min="1" comment="Does this component have children, use macro so collapsed surface elements also count"/>
          <match_any>
            <match restorable="true" comment="wrecked"/>
            <match repairable="true" invulnerable="false">
              <match_hull max="$hulldamagelimit - 1"/>
            </match>
          </match_any>
        </find_object_component>
        
        <do_if value="$PossibleElements.count" min="1">
          <!--If something important was found there is only a small chance of finding something small to fix instead-->
          <set_value name="$FindChance" exact="50"/>
        </do_if>
        <!--A chance to find something small to fix. (100% if nothing important was found)-->
        <find_object_component chance="$FindChance" groupname="$PossibleElements" object="$Defensible" class="class.destructible" checkoperational="false" multiple="true">
          <match class="class.ship" checkoperational="false" negate="true"/>
          <match_any>
            <match restorable="true" comment="wrecked"/>
            <match repairable="true" invulnerable="false">
              <match_hull max="$hulldamagelimit - 1"/>
            </match>
          </match_any>
        </find_object_component>
       
        <do_if value="$PossibleElements.count" min="1">
          <set_value name="$MassTrafficTargets" exact="$PossibleElements.list"/>
          <set_value name="$CurrentElement" exact="$PossibleElements.random"/>
          <set_value name="$nextelementcheck" exact="0"/>
          <do_if value="$CurrentElement.iswreck">
            <set_value name="$BaseRestoreTime" exact="($CurrentElement.size)s"/>
            <do_if value="$BaseRestoreTime" max="1min">
              <set_value name="$BaseRestoreTime" exact="20s" comment="время для больших компонентов"/>
            </do_if>
            <do_elseif value="$BaseRestoreTime" min="1min">
              <set_value name="$BaseRestoreTime" exact="10s" comment="время для малых компонентов"/>
            </do_elseif>
            <set_value name="$RestoreTime" min="player.age + $BaseRestoreTime" max="player.age + $BaseRestoreTime + 1s"/>
          </do_if>
         </do_if>
        <clear_group group="$PossibleElements"/>
      </do_if>

      <!--Check if there is nothing to fix-->
      <do_if value="not $CurrentElement.exists">
        <do_if value="$Defensible.hullpercentage" min="$hulldamagelimit">
          <!--Remove mass traffic. Don't care about damaged summaries-->
          <do_if value="$networkcreated">
            <end_repair_mass_traffic object="$Defensible" />
            <set_value name="$networkcreated" exact="false" />
          </do_if>

          <do_if value="$Defensible.summary.numadsigns.wreck
          + $Defensible.summary.numefficiencyupgrades.wreck
          + $Defensible.summary.numshields.wreck
          + $Defensible.summary.numsurfacedestructible.wreck
          + $Defensible.summary.numturrets.wreck" exact="0">

            <!-- set command action to repair checking -->
            <set_command_action commandaction="commandaction.repairchecking" />

            <resume label="checkforrepair"/>
          </do_if>
        </do_if>
      </do_if>

      <label name="startrepair" />
			
      <!-- send out the repair drones -->
      <do_if value="not $networkcreated">
        <do_if value="not $MassTrafficTargets?">
          <set_value name="$MassTrafficTargets" exact="[$Defensible]" />
        </do_if>
        <launch_repair_drones object="$Defensible" target="$Defensible" components="$MassTrafficTargets" result="$networkid" />
       
        <remove_value name="$networkid" />
        <set_value name="$MassTrafficTargets" exact="[]"/>
        <set_value name="$networkcreated" exact="true" />
      </do_if>

      <!-- calculate repair speed -->
      <set_value name="$repairratefactor" exact="0" />
      <do_if value="$networkcreated">
        <find_active_repair_mass_traffic object="$Defensible" result="$networkid" />
        <get_units_in_mass_traffic masstraffic="$networkid" category="unitcategory.welder" amounts="$unitamounts" />
        <remove_value name="$networkid" />
        <do_if value="$unitamounts">
          <do_all exact="unitcategory.welder.maxmk" counter="$i">
            <set_value name="$repairratefactor" operation="add" exact="$unitamounts.{$i} * $i" />
          </do_all>
          <remove_value name="$unitamounts" />
        </do_if>
      </do_if>
      <do_if value="$repairratefactor == 0">
        <do_if value="$networkcreated">
          <end_repair_mass_traffic object="$Defensible" />
          <set_value name="$networkcreated" exact="false" />
        </do_if>
        <!-- if no welders are underway, repair 10 times more slowly than with just one mk1 drone -->
        <set_value name="$repairratefactor" exact="1.5" />
      </do_if>
      <set_value name="$repairratefactor" operation="add" exact="$repairratefactor * this.combinedskill / 10" comment="engineer speeds up repair by up to 400% (meaning a fifth of the normal repair time)" />
      <set_value name="$repairrate" exact="$baserepairrate * $repairratefactor" />
			
      <!--Fix summary components first-->
      <!--Currently only attempt to fix one. Only fix those which have an operational parent-->
      <do_if value="$Defensible.summary.numadsigns.wreck" min="1">
        <set_summarised_adsign_state object="$Defensible" state="operational" parentstate="operational" previous="wreck" exact="1"/>
      </do_if>
      <do_if value="$Defensible.summary.numefficiencyupgrades.wreck" min="1">
        <set_summarised_efficiencyupgrade_state object="$Defensible" state="operational" parentstate="operational" previous="wreck" exact="1"/>
      </do_if>
      <do_if value="$Defensible.summary.numshields.wreck" min="1">
        <set_summarised_shield_state object="$Defensible" state="operational" parentstate="operational" previous="wreck" exact="1"/>
      </do_if>
      <do_if value="$Defensible.summary.numsurfacedestructible.wreck" min="1">
        <set_summarised_surfacedestructible_state object="$Defensible" state="operational" parentstate="operational" previous="wreck" exact="1"/>
      </do_if>
      <do_if value="$Defensible.summary.numturrets.wreck" min="1">
        <set_summarised_turret_state object="$Defensible" state="operational" parentstate="operational" previous="wreck" exact="1"/>
      </do_if>

      <!--Repair Defensible Hull-->
      <do_if value="$Defensible.maxhull" min="1">
        <do_if value="$Defensible.hullpercentage" max="$hulldamagelimit - 1">
          <set_value name="$addedhullpercentage" exact="100f * $repairrate / $Defensible.maxhull" />
          <!-- handle the case of the percentage being < 0 -->
          <do_if value="$addedhullpercentage lt 1">
            <set_value name="$addedhullpercentage" exact="1"/>
          </do_if>
          <do_if value="$addedhullpercentage" min="1">
            <!-- set the repair command action -->
            <set_command_action commandaction="commandaction.repairingto" param="$Defensible" />
            <!-- repair the hull -->
            <set_object_hull object="$Defensible" exact="$Defensible.hullpercentage + $addedhullpercentage" />
           </do_if>
        </do_if>
      </do_if>

      <do_if value="$CurrentElement">
        <do_if value="$CurrentElement.iswreck">
          <do_if value="@$RestoreTime" min="1">
            <do_if value="player.age" min="$RestoreTime">
              <restore_object object="$CurrentElement" hull="1" />
              <set_value name="$RestoreTime" exact="0"/>
            </do_if>
          </do_if>
          <do_else>
            <!--Component is wrecked but no restore time is defined. It may have been recently wrecked.-->
            <set_value name="$CurrentElement" exact="null"/>
          </do_else>
        </do_if>
        <do_else>
          <do_if value="$CurrentElement.maxhull" min="1">
            <do_if value="$CurrentElement.hullpercentage" min="$hulldamagelimit">
              <!--Component is as repaired as possible-->
              <set_value name="$CurrentElement" exact="null"/>
            </do_if>
            <do_else>
              <!--Repair Damaged Component-->
              <set_value name="$addedhullpercentage" exact="500f * $repairrate / $CurrentElement.maxhull" />
              <!-- handle the case of the percentage being < 0 -->
              <do_if value="$addedhullpercentage lt 1">
                <set_value name="$addedhullpercentage" exact="1"/>
              </do_if>
              <do_if value="$addedhullpercentage" min="1">
                <!-- set the repair command action -->
                <set_command_action commandaction="commandaction.repairingto" param="$CurrentElement" />
                <!-- repair the hull -->
                <set_object_hull object="$CurrentElement" exact="$CurrentElement.hullpercentage + $addedhullpercentage" />
                <do_if value="$CurrentElement.hullpercentage" min="$hulldamagelimit">
                 <set_value name="$CurrentElement" exact="null"/>
                </do_if>
              </do_if>
            </do_else>
          </do_if>
        </do_else>
      </do_if>

      <resume label="checkforrepair" />
    </actions>
  </attention>
</aiscript>
<?xml version="1.0" encoding="iso-8859-1" ?>
<diff>
  <add sel="/aiscript/attention[@min='unknown']/actions/label[@name='init']" pos="after">
    <do_if value="this.station.canbuildships">
<!-- Add drones to tradeware -->
      <add_tradeware ware="ware.drp_assault" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_cargolifter" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_construction" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_interceptor_mk1" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_interceptor_mk2" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_intrepid_mk1" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_intrepid_mk2" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_overrun_mk1" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_overrun_mk2" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_scoopcollector_mk1" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_scoopcollector_mk2" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_surfaceminer_mk1" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_surfaceminer_mk2" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.dumbfiremissile" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.swarmmissile" object="this.station" allowbuy="true" />	  
    </do_if>
	<do_if value="this.station.canproduceships">
	  <add_tradeware ware="ware.drp_scoopcollector_mk1" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_scoopcollector_mk2" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_surfaceminer_mk1" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_surfaceminer_mk2" object="this.station" allowbuy="true" />
	  <!-- CHEAT FOR GIVING WARES AUTOMATICALLY -->
      <!--<add_default_production_wares object="this.station" lowerlimit="20" upperlimit="80" /> -->
	</do_if>
	</add>
	
	<add sel="/aiscript/attention[@min='unknown']/actions/label[@name='init']" pos="after">
    <do_if value="this.station.canbuildships">
<!-- Add drones to tradeware -->
      <set_value name="$tradewares" exact="[
                  ware.drp_assault,
                  ware.drp_cargolifter,
                  ware.drp_construction,
                  ware.drp_interceptor_mk1,
                  ware.drp_interceptor_mk2,
                  ware.drp_intrepid_mk1,
                  ware.drp_intrepid_mk2,
                  ware.drp_overrun_mk1,
                  ware.drp_overrun_mk2,
                  ware.drp_scoopcollector_mk1,
                  ware.drp_scoopcollector_mk2,
                  ware.drp_surfaceminer_mk1,
                  ware.drp_surfaceminer_mk2,
                  ware.dumbfiremissile,
                  ware.swarmmissile
      ]" />

      <set_value name="$resources" exact="this.station.resources.list" />
      <set_value name="$products" exact="this.station.products.list" />
      <do_all exact="$tradewares.count" counter="$i">
        <set_value name="$tradeware" exact="$tradewares.{$i}" />
        <do_if value="$resources.indexof.{$tradeware} + $products.indexof.{$tradeware}" exact="0">
          <add_tradeware ware="$tradeware" object="this.station" allowbuy="true" />
        </do_if>
      </do_all>
      <remove_value name="$resources" />
      <remove_value name="$products" />
      <remove_value name="$tradeware" />
      <remove_value name="$tradewares" />	  
	  
	  <wait min="5s" max="10min" />
    </do_if>
	
	
	<!--<do_if value="this.station.canproduceships">
	  <add_tradeware ware="ware.drp_scoopcollector_mk1" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_scoopcollector_mk2" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_surfaceminer_mk1" object="this.station" allowbuy="true" />
      <add_tradeware ware="ware.drp_surfaceminer_mk2" object="this.station" allowbuy="true" />-->
	  <!-- CHEAT FOR GIVING WARES AUTOMATICALLY -->
      <!--<add_default_production_wares object="this.station" lowerlimit="20" upperlimit="80" /> -->
	<!--</do_if>-->
	
	</add>
</diff><?xml version="1.0" encoding="utf-8"?>
<mdscript name="EuclidsTempZoneStationBuilder" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
	<cues>
		
	 <cue name="EuclidsTZSBinit" instantiate="true" namespace="this" >
    <conditions>
    <event_object_changed_zone object="player.entity" />
    <check_value value="event.param.name == readtext.{20005}.{200}" />
	<check_value value="event.param.istemporaryzone" />
	<check_value value="player.money gt 50000000Cr" />
    </conditions>
		<actions>
		 <start_conversation actor="player.copilot" conversation="EuclidTZSBMenue"/> 
		</actions>
	 </cue>
		
		<cue name="EuclidsTZSB0" instantiate="true">
     <conditions>
			<event_conversation_started conversation="EuclidTZSBMenue" />
		 </conditions>
      <actions>
       <add_player_choice text="{360010,1}" section="selectstation" comment="Buid Station?"/>
       <add_player_choice_return text="{1001,2670}" section="nothanks"/>
      </actions>
    </cue>
		
		<cue name="EuclidsTZSBEnd" instantiate="true">
		 <conditions>
			<event_conversation_next_section sectionprefix="nothanks"/>
		 </conditions>
		 <actions>
			<reset_cue cue="EuclidsTZSBinit"/>
			<reset_cue cue="EuclidsTZSB0"/>
			<reset_cue cue="EuclidsTZSB1"/> 
			<reset_cue cue="EuclidsTZSB2"/>
			<reset_cue cue="EuclidsTZSB3"/>
			<reset_cue cue="EuclidsTZSB4"/>
			<reset_cue cue="EuclidsTZSBEnd"/>
		 </actions>
	  </cue>	
		
		
		<cue name="EuclidsTZSB1" instantiate="true">
		 <conditions>
			<check_any>
			 <event_conversation_next_section sectionprefix="selectstation"/>
			 <event_conversation_returned_to_section sectionprefix="selectstation" />
			</check_any>
		 </conditions>
		 <actions>
			<add_player_choice_sub text="{360010,3}" section="select_albionstation" comment="Albion Station?" />
			<add_player_choice_sub text="{360010,6}" section="select_devriesstation" comment="DeVries Station?"/>
			<add_player_choice_sub text="{360010,9}" section="select_omicronstation" comment="Omicron Lyrae Station?"/>
		 </actions>
	  </cue>	
	
		<cue name="EuclidsTZSB2A" instantiate="true">
		 <conditions>
			<check_any>
			 <event_conversation_next_section sectionprefix="select_albionstation"/>
			 <event_conversation_returned_to_section sectionprefix="select_albionstation" />
			</check_any>
		 </conditions>
		 <actions>

			 <add_player_choice_sub text="{360010,12}" section="type_eandr" choiceparam="event.param" comment="Energy and Refinery"/>
			 <add_player_choice_sub text="{360010,15}" section="type_aandf" choiceparam="event.param" comment="Agricultural and Food"/>
			 <add_player_choice_sub text="{360010,18}" section="type_wandd" choiceparam="event.param" comment="Weapons, Drones and Ships"/>
			 <add_player_choice_sub text="{360010,21}" section="type_candt" choiceparam="event.param" comment="Construction and Tech"/>
			 <add_player_choice_sub text="{360010,24}" section="type_mandc" choiceparam="event.param" comment="Med and Chem"/> 
		   <add_player_choice_sub text="{1001,2669}" section="selectstation" />
			
		 </actions>
	  </cue>	
		
		<cue name="EuclidsTZSB2D" instantiate="true">
		 <conditions>
			<check_any>
			 <event_conversation_next_section sectionprefix="select_devriesstation"/>
			 <event_conversation_returned_to_section sectionprefix="select_devriesstation" />
			</check_any>
		 </conditions>
		 <actions>
			 
			 <add_player_choice_sub text="macro.struct_bt_dv_wheat_farm_macro.name" section="build_station" choiceparam="macro.struct_bt_dv_wheat_farm_macro"/>
			 <add_player_choice_sub text="macro.struct_bt_dv_water_destillery_macro.name" section="build_station" choiceparam="macro.struct_bt_dv_water_destillery_macro"/>
			 <add_player_choice_sub text="macro.struct_bt_dv_solar_power_plant_macro.name" section="build_station" choiceparam="macro.struct_bt_dv_solar_power_plant_macro"/>
			 <add_player_choice_sub text="{1001,2669}" section="selectstation" />
			
		 </actions>
	  </cue>	
	
		<cue name="EuclidsTZSB2O" instantiate="true">
		 <conditions>
			<check_any>
			 <event_conversation_next_section sectionprefix="select_omicronstation"/>
			 <event_conversation_returned_to_section sectionprefix="select_omicronstation" />
			</check_any>
		 </conditions>
		 <actions>
			 
			 <add_player_choice_sub text="{360010,12}" section="type_eandr" choiceparam="event.param" comment="Energy and Refinery"/>
			 <add_player_choice_sub text="{360010,15}" section="type_aandf" choiceparam="event.param" comment="Agricultural and Food"/>
			 <add_player_choice_sub text="{360010,18}" section="type_wandd" choiceparam="event.param" comment="Weapons, Drones and Ships"/>
			 <add_player_choice_sub text="{360010,21}" section="type_candt" choiceparam="event.param" comment="Construction and Tech"/>
			 <add_player_choice_sub text="{360010,24}" section="type_mandc" choiceparam="event.param" comment="Med and Chem"/> 
		   <add_player_choice_sub text="{1001,2669}" section="selectstation" />
			
		 </actions>
	  </cue>	
		
		<cue name="EuclidsTZSB3" instantiate="true">
		 <conditions>
		  <event_conversation_next_section sectionprefix="type_"/>
	   </conditions>
		 <actions>
			<do_if value="event.param2 == 'select_albionstation'">
			 <do_if value="event.param == 'type_eandr'">
				<add_player_choice_sub text="macro.struct_bt_alb_solar_power_plant_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_solar_power_plant_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_alb_water_destillery_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_water_destillery_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_alb_crystal_refinement_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_crystal_refinement_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_alb_cell_refinery_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_cell_refinery_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_alb_fuelstation_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_fuelstation_macro"/>
				<add_player_choice_sub text="{1001,2669}" section="select_albionstation"/> 
			 </do_if>
			 <do_elseif value="event.param == 'type_aandf'">
				<add_player_choice_sub text="macro.struct_bt_alb_cattle_ranch_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_cattle_ranch_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_alb_farm_complex_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_farm_complex_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_alb_food_production_complex_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_food_production_complex_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_alb_spice_farm_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_spice_farm_macro"/>
				<add_player_choice_sub text="macro.struct_bt_alb_wheat_farm_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_wheat_farm_macro"/>
			  <add_player_choice_sub text="{1001,2669}" section="select_albionstation"/>
			 </do_elseif>	
			 <do_elseif value="event.param == 'type_wandd'">
				<add_player_choice_sub text="macro.struct_bt_alb_weaponry_complex_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_weaponry_complex_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_alb_drone_complex_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_drone_complex_macro"/>
				<add_player_choice_sub text="macro.struct_bt_alb_small_ships_complex_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_small_ships_complex_macro"/>
				<add_player_choice_sub text="macro.struct_bt_alb_drone_factory_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_drone_factory_macro"/>
<!--     Добавочное тестовое Верфи Главная и большая Альбион-->
				<add_player_choice_sub text="macro.struct_bt_alb_small_ships_yard_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_small_ships_yard_macro"/>
				<add_player_choice_sub text="macro.struct_bt_alb_big_ships_yard_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_big_ships_yard_macro"/>
<!-- Конец теста добавления верфи -->				
			  <add_player_choice_sub text="{1001,2669}" section="select_albionstation"/>
			 </do_elseif>	
			 <do_elseif value="event.param == 'type_candt'">
				<add_player_choice_sub text="macro.struct_bt_alb_constructionmaterial_production_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_constructionmaterial_production_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_alb_hightec_construction_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_hightec_construction_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_alb_metal_works_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_metal_works_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_alb_tech_complex_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_tech_complex_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_alb_high_energy_construction_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_high_energy_construction_macro"/>
				<add_player_choice_sub text="{1001,2669}" section="select_albionstation"/> 
			 </do_elseif>	
			 <do_elseif value="event.param == 'type_mandc'">
				<add_player_choice_sub text="macro.struct_bt_alb_laboratory_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_laboratory_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_alb_medical_supplies_macro.name" section="build_station" choiceparam="macro.struct_bt_alb_medical_supplies_macro"/>
				<add_player_choice_sub text="{1001,2669}" section="select_albionstation"/> 
			 </do_elseif>	
			</do_if>
			<do_else>
			 <do_if value="event.param == 'type_eandr'">
				<add_player_choice_sub text="macro.struct_bt_ol_cell_refinery_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_cell_refinery_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_water_destillery_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_water_destillery_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_solar_power_plant_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_solar_power_plant_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_crystal_refinement_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_crystal_refinement_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_fuelstation_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_fuelstation_macro"/>
				<add_player_choice_sub text="{1001,2669}" section="select_omicronstation" /> 
			 </do_if>
			 <do_elseif value="event.param == 'type_aandf'">
				<add_player_choice_sub text="macro.struct_bt_ol_bofu_plant_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_bofu_plant_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_farm_complex_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_farm_complex_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_plankton_tank_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_plankton_tank_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_soy_farm_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_soy_farm_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_spice_farm_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_spice_farm_macro"/>
				<add_player_choice_sub text="{1001,2669}" section="select_omicronstation" /> 
			 </do_elseif>	
			 <do_elseif value="event.param == 'type_wandd'">
				<add_player_choice_sub text="macro.struct_bt_ol_drone_complex_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_drone_complex_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_drone_factory_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_drone_factory_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_weaponrycomplex_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_weaponrycomplex_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_weaponryproduction_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_weaponryproduction_macro"/>
				<add_player_choice_sub text="macro.struct_bt_ol_small_ships_complex_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_small_ships_complex_macro"/>
<!--     Добавочное тестовое Верфи Главная и большая Омикрон Лиры-->
				<add_player_choice_sub text="macro.struct_bt_ol_shipyard_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_shipyard_macro"/>
<!-- Конец теста добавления верфи -->				
		    <add_player_choice_sub text="{1001,2669}" section="select_omicronstation" />
			 </do_elseif>	
			 <do_elseif value="event.param == 'type_candt'">
				<add_player_choice_sub text="macro.struct_bt_ol_high_energy_construction_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_high_energy_construction_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_metalworks_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_metalworks_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_tech_complex_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_tech_complex_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_construction_material_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_construction_material_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_hightec_construction_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_hightec_construction_macro"/>
				<add_player_choice_sub text="{1001,2669}" section="select_omicronstation" />
			 </do_elseif>	
			 <do_elseif value="event.param == 'type_mandc'">
				<add_player_choice_sub text="macro.struct_bt_ol_medical_supplies_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_medical_supplies_macro"/>
			  <add_player_choice_sub text="macro.struct_bt_ol_laboratory_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_laboratory_macro"/>
				<add_player_choice_sub text="macro.struct_bt_ol_spacefuel_production_macro.name" section="build_station" choiceparam="macro.struct_bt_ol_spacefuel_production_macro"/>
				<add_player_choice_sub text="{1001,2669}" section="select_omicronstation" />
			 </do_elseif>	
			</do_else>
		 </actions>
	  </cue>	

		<cue name="EuclidsTZSB4" instantiate="true">
		 <conditions>
			<event_conversation_next_section sectionprefix="build_station"/>
		 </conditions>
		 <actions>
			<create_station name="$Station" macro="event.param2" zone="player.zone" owner="faction.player">
			 <position x="0" y="0" z="0" min="2km" max="5km"/>
		<!-- just use the max possible for any station: -->
			 <buildsequence sequence="'a'" stage="1"/>
			 <buildsequence sequence="'a'" stage="2"/>
			 <buildsequence sequence="'a'" stage="3"/>
			 <buildsequence sequence="'a'" stage="4"/>
			 <buildsequence sequence="'b'" stage="1"/>
			 <buildsequence sequence="'b'" stage="2"/>
			 <buildsequence sequence="'b'" stage="3"/>
			 <buildsequence sequence="'b'" stage="4"/>
			 <buildsequence sequence="'b'" stage="5"/>
			 <buildsequence sequence="'c'" stage="1"/>
			 <buildsequence sequence="'c'" stage="2"/>
			 <buildsequence sequence="'c'" stage="3"/>
			 <buildsequence sequence="'c'" stage="4"/>
			 <buildsequence sequence="'d'" stage="1"/>
			 <buildsequence sequence="'d'" stage="2"/>
			 <buildsequence sequence="'d'" stage="3"/>
			 <buildsequence sequence="'d'" stage="4"/>
			 <buildsequence sequence="'e'" stage="1"/>
			 <buildsequence sequence="'e'" stage="2"/>
			 <buildsequence sequence="'f'" stage="1"/>
			 <buildsequence sequence="'f'" stage="2"/>
			 <buildsequence sequence="'f'" stage="3"/>
			 <buildsequence sequence="'g'" stage="1"/>
			 <buildsequence sequence="'g'" stage="2"/>
			 <buildsequence sequence="'h'" stage="1"/>
			 <buildsequence sequence="'i'" stage="1"/>	
			</create_station>
			 
	<!-- add drones -->
			<set_value name="$Unitcapacity" exact="$Station.units.maxcount" />
			<add_units object="$Station" category="unitcategory.welder" mk="1" exact="0.75*$Unitcapacity" /> 
			<add_units object="$Station" category="unitcategory.transport" mk="1" exact="0.75*$Unitcapacity" />  
			<add_units object="$Station" category="unitcategory.defence" mk="1" exact="0.75*$Unitcapacity" />  
			 
	<!-- add missiles for v launcher -->
			<evaluate_ammo_storage object="$Station" type="missile" macros="$macrolist" amounts="$amountlist" />
      <do_all exact="$macrolist.count" counter="$i">
			 <add_ammo object="$Station" macro="$macrolist.{$i}" amount="$amountlist.{$i}" /> 
			</do_all> 
			 
	<!-- add NPCs -->		 
			<find_dock_location name="$Stationdock" container="$Station" size="tag.dock_p" dockpopulationtype="dockpopulationtype.administrative"/>
			<do_if value="not $Stationdock">
				<find_dock_location name="$Stationdock" container="$Station" size="tag.dock_p"/>
			</do_if>
			 
		<!-- add engineer -->
			<create_cue_actor cue="this" name="$engineer" macro="macro.character_teladi_m_a">
			 <select race="race.teladi" tags="tag.engineer"/>
			 <owner exact="faction.player" />
			 <skills>
				<skill type="boarding" exact="1"/>
				<skill type="combat" exact="3"/>
				<skill type="engineering" exact="5"/>
				<skill type="leadership" exact="2"/>
				<skill type="management" exact="4"/>
				<skill type="morale" exact="4"/>
				<skill type="navigation" exact="3"/>
				<skill type="science" exact="5"/>
			 </skills>
			</create_cue_actor>
			<set_entity_type entity="$engineer" type="entitytype.engineer"/>
			<add_actor_to_platform actor="$engineer" dockingbay="$Stationdock.component"/>
			<assign_engineer actor="$engineer" object="$Station"/>
			<set_value name="$engineer.$ammocheck" exact="player.age"/> 
			<start_script object="$engineer" name="'EuclidsStationengineer.ai'"/>
			 
		<!-- add manager 	-->			
      <create_cue_actor cue="this" name="$manager" macro="macro.character_ar_female_manager_macro">
			 <select race="race.argon" tags="tag.manager"/>
			 <page exact="10109"/>	
       <owner exact="faction.player" />
			 <skills>
				<skill type="boarding" exact="1"/>
				<skill type="combat" exact="2"/>
				<skill type="engineering" exact="1"/>
				<skill type="leadership" exact="5"/>
				<skill type="management" exact="5"/>
				<skill type="morale" exact="5"/>
				<skill type="navigation" exact="5"/>
				<skill type="science" exact="2"/>
			 </skills>
      </create_cue_actor>
      <set_entity_type entity="$manager" type="entitytype.manager"/>
      <add_actor_to_platform actor="$manager" dockingbay="$Stationdock.component"/>
      <assign_trade_manager actor="$manager" object="$Station"/>
			<set_actor_account actor="$manager" />
      <start_script object="$manager" name="'trade.station.player'"/>
			 
    <!-- add defense officer 		-->			
      <create_cue_actor cue="this" name="$defencenpc">
       <select race="race.terran" tags="tag.defencecontrol"/>
       <owner exact="faction.player" />
			 <skills>
				<skill type="boarding" exact="2"/>
				<skill type="combat" exact="5"/>
				<skill type="engineering" exact="2"/>
	      <skill type="leadership" exact="3"/>
			  <skill type="management" exact="2"/>
				<skill type="morale" exact="4"/>
				<skill type="navigation" exact="1"/>
				<skill type="science" exact="3"/>
			 </skills>
      </create_cue_actor>
      <set_entity_type entity="$defencenpc" type="entitytype.defencecontrol"/>
      <add_actor_to_platform actor="$defencenpc" dockingbay="$Stationdock.component"/>
      <assign_defence_manager actor="$defencenpc" object="$Station"/>
      <start_script object="$defencenpc" name="'fight.station.player'" />
			 
	<!-- add some default production wares-->	
			<add_default_production_wares object="$Station" lowerlimit="75" upperlimit="75"/> 
			<reward_player money="-50000000Cr" />
			<write_to_logbook category="general" text="{360010,27}.[$Station.name]" comment="You have built the station %1 for 1M Credits."/>
			<do_if value="player.zone.knownname == readtext.{20005}.{200} ">
			<set_object_name object="$Station.zone" name="{360010,28}" comment="Rename Me." /> 
			</do_if> 
     	    <set_value name="stat.stations_built" operation="add"/>
	
		
			 
	<!-- Cleanup -->		 
			 
			<remove_value name="$Station"/>
			<remove_value name="$defencenpc"/>
			<remove_value name="$Stationdock"/>
	    <remove_value name="$manager"/>
			<remove_value name="$engineer"/>
			<remove_value name="$macrolist"/>
			<remove_value name="$amountlist"/>
      <remove_value name="$Unitcapacity"/>
				
		<!-- avoid copies -->	 
			
			<reset_cue cue="EuclidsTZSBinit"/>
			<reset_cue cue="EuclidsTZSB0"/>
			<reset_cue cue="EuclidsTZSB1"/> 
			<reset_cue cue="EuclidsTZSB2A"/>
			 <reset_cue cue="EuclidsTZSB2D"/>
			 <reset_cue cue="EuclidsTZSB2O"/>
			<reset_cue cue="EuclidsTZSB3"/>
			<reset_cue cue="EuclidsTZSB4"/>
			<reset_cue cue="EuclidsTZSBEnd"/>
		 </actions>
	  </cue>	
	 </cues> 
</mdscript><?xml version="1.0" encoding="utf-8" ?>
<mdscript name="EuclidsTempZoneStationBuilder_shipdiler" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
  <cues>
    <cue name="TempZoneStationBuilder_shipdiler_alexalsp" instantiate="true">
      <conditions>
        <check_any>
          <event_player_created />
          <event_object_docked object="player.primaryship" />
        </check_any>
      </conditions>
      <actions>
	  
        <find_station  name="$stations" owner="faction.player" space="player.galaxy" multiple="true" />
		     <do_all exact="$stations.count" counter="$j">

                  <find_object_component name="$Cradles" object="$stations.{$j}" class="class.buildmodule" multiple="true"/>
                  <do_all exact="$Cradles.count" counter="$Counter">
                    <find_object_component name="$ShipyardDock" object="$stations.{$j}" class="class.dockingbay" dockpopulationtype="dockpopulationtype.ships" multiple="true">
                      <match_buildsource sequence="$Cradles.{$Counter}.sequence" stage="$Cradles.{$Counter}.stage"/>
                    </find_object_component>
                    <do_if value="$ShipyardDock.count gt 0">
                      <create_platform_actor name="$Shipdealer" type="entitytype.shiptrader" dockingbay="$ShipyardDock.random" group="albion.shiptrader">
                        <owner exact="faction.player"/>
                      </create_platform_actor>
                    </do_if>
                  </do_all>
                  <find_object_component name="$ShipyardDock" object="$stations.{$j}" class="class.dockingbay" dockpopulationtype="dockpopulationtype.ships" multiple="true"/>
                  <do_if value="$ShipyardDock.count gt 0">
                    <do_all exact="$ShipyardDock.count" counter="$Counter">
                      <find_object_component name="$Cradles" object="$stations.{$j}" class="class.buildmodule" checkoperational="false">
                        <match_buildsource sequence="$ShipyardDock.{$Counter}.sequence" stage="$ShipyardDock.{$Counter}.stage"/>
                      </find_object_component>
                      <do_if value="not $Cradles">
                        <create_platform_actor name="$Shipdealer" type="entitytype.smallshiptrader" dockingbay="$ShipyardDock.{$Counter}" group="albion.shiptrader">
                          <owner exact="faction.player"/>
                        </create_platform_actor>
                      </do_if>
                    </do_all>
                  </do_if>
				  
 				  
            </do_all>

			<!-- Cleanup -->		 

            <remove_value name="$stations"/>
            <remove_value name="$ShipyardDock"/>
            <remove_value name="$Shipdealer"/>
            <remove_value name="$shiptrader"/>
            <remove_value name="$smallshiptrader"/>

			</actions>
    </cue>	
	
	
  </cues>
</mdscript><?xml version="1.0" encoding="UTF-8" ?>
<!-- 
	Base (English) text file for Temp Zone Station Builder mod.
	
	Author: Euclid
  
	Last Change:
	Version: V0.0.1
	Date: 28-06-2015
  
	X Rebirth version: 4.00+
	
	Перевод alexalsp.  http://apocalypse.moy.su 
    Thanks to alexalsp for this excellent translation!

-->
<language>
      <page id="360010" voice="no">
         <t id="1">Построить станцию?</t>
         <t id="3">Станцию Альбиона?</t>
         <t id="6">Станцию Девриза?</t>
         <t id="9">Станцию Омикрон Лиры?</t>
         <t id="12">Энергия и Переработка</t>
         <t id="15">Сельхоз и Еда</t>
         <t id="18">Оружие, Дроны и Суда</t>
         <t id="21">Технология и Строительство</t>
         <t id="24">Медицина и Химия</t>
         <t id="27">Вы построили станцию %1 за 50 000 000 Кредитов.</t>
         <t id="28">Пустое пространство</t>
         <t id="30">Это %1 с %2\n Мне нужны %3 Строительный Дрон, но не могу найти продавца. Я попробую снова через 1 час.</t>
         <t id="33">Это %1 с %2\n Я купил %3 Строительный Дрон у %4 за %5 Кредитов.</t>
         <t id="36">Это %1 с %2\n Мне нужны %3 Транспортный Дрон, но не могу нати продавца. Я попробую снова через 1 час.</t>
         <t id="39">Это %1 с %2\n Я купил %3 Транспортный дрон у %4 за %5 Кредитов.</t>
         <t id="42">Это %1 с %2\n Мне нужно %3 Дрон Защитник но не могу найти продавца. Я попробую снова через 1 час.</t>
         <t id="45">Это %1 с %2\n Я купил %3 Дрон Зщитник у %4 за %5 Кредитов.</t>
         <t id="48">Это %1 с %2\n Мне нужно %3  %4 но не могу найти продавца. Я попробую снова через 1 час.</t>
         <t id="51">Это %1 с %2\n Я купил %3  %4 у %5 за %6 Кредитов.</t>
       </page>
</language><?xml version="1.0" encoding="UTF-8" ?>
<!-- 
	Base (English) text file for Temp Zone Station Builder mod.
	
	Author: Euclid
  
	Last Change:
	Version: V0.0.1
	Date: 28-06-2015
  
	X Rebirth version: 3.00+
	
	Перевод alexalsp.  http://apocalypse.moy.su 
    Thanks to alexalsp for this excellent translation!

-->
<language>
      <page id="360010" voice="no">
         <t id="1">Buid Station?</t>
         <t id="3">Albion Station?</t>
         <t id="6">DeVries Station?</t>
         <t id="9">Omicron Lyrae Station?</t>
         <t id="12">Energy and Refinery</t>
         <t id="15">Agricultural and Food</t>
         <t id="18">Weapons, Drones and Ships</t>
         <t id="21">Construction and Tech</t>
         <t id="24">Med and Chem</t>
         <t id="28">Rename Me</t>
         <t id="27">You have built the station %1 for 50 000 000 Credits.</t>
         <t id="30">This is %1 from the %2\n I need %3 Construction drones but cannot find a seller. I will try again in 1 hour.</t>
         <t id="33">This is %1 from the %2\n I bought %3 Construction drones from %4 for %5 Credits.</t>
         <t id="36">This is %1 from the %2\n I need %3 Transport drones but cannot find a seller. I will try again in 1 hour.</t>
         <t id="39">This is %1 from the %2\n I bought %3 Transport drones from %4 for %5 Credits.</t>
         <t id="42">This is %1 from the %2\n I need %3 Defence drones but cannot find a seller. I will try again in 1 hour.</t>
         <t id="45">This is %1 from the %2\n I bought %3 Defence drones from %4 for %5 Credits.</t>
         <t id="48">This is %1 from the %2\n I need %3  %4 but cannot find a seller. I will try again in 1 hour.</t>
         <t id="51">This is %1 from the %2\n I bought %3  %4 from %5 for %6 Credits.</t>
       </page>
</language>[color=cyan]Temp Zone Station Builder(V0.5)[/color]

This mod is meant to be for the 'rich' players ;-) When you enter a temporary zone (Empty Space) a custom menu is triggered - if you got the cash !!. It provided the option to select a station which is then built near the centre of the zone.

Each station cost the lump sum of [b]100M credits[/b] and comprised of
[list]
1# all upgrades and extension,
2# a highly skilled manager & DO (feel free to train them further or replace them),
3# a highly skilled engineer who repaires/rebuilds [b]any[/b] damaged/destroyed parts and replenishes drones and ammunition if required (do [b]not[/b] replace him but fee free to train him),
4# a full stock units: welder, transport and defence drones,
5# maximum ammunition (missiles) loaded,
6# some resources and some products (so it produces and sell instantaneously).
[/list]
and hence the price is [b]non-negociable!![/b] Don't push it: If you do not have distinctly more that 100M Cr then think twice because the manager need money, too.




[list]
[b]Installation[/b]
Extract the entire folder to your extensions folder.
 
[b]Deinstallation[/b] 
If you have built already any station with this mod then fire the engineer! Only then save the game, exit and remove the mod folder from your extensions folder. Then load the saved game and deploy a new engineer as usual.

[b]Technical info[/b]
The station do not have and do not need an architect or a CV. This mod uses an modified engineer script. It is a new script based on the vanilla engineer.ai but [b]not[/b] an XML patching of the vanilla script! The engineer will check the stock of drones and ammunition every hour and, if necessary, will replenish them (special delivery) from a factory with the best offer in the galaxy. All replenished drones will be MK 1 but feel free to add higher quality drones manually but please do not add any attack drones or bombs as this might interfere with the engineer's job. The costs for replenished drones and ammunition are taken for the player's account. A correponding note is send to the player's logbook under'Upkeep'.

[b]Warning[/b]
It is highly recommended that you only build one station per temporary zone. As mentioned above the station will be placed near the zone centre to avoid various problems that occur near any zone boundary. If you place a second station they may be too close to eachother! To prevent 'accidents' the temporary zone will be [b]renamed automatically[/b] once the station is placed. Feel free to 
re-rename it.
[/list]

Cheers Euclid

v0.5: Replaced the aiscript missing in v0.3 - thx to John McG
v0.4: Fixed flaw in menu - thx to Mylo-s
V0.3: Removed redundant flak-related checks to avoid debug errors.
v0.2: Added a condition to prevent multiple build in the same zone<?xml version="1.0" encoding="iso-8859-1"?>
<content id="" name="" description="" author="Euclid" version="060" date="2018-06-07" save="0" lastupdate="">
  <text language="7" name="TempZoneStationBuilder" description="&#1055;&#1086;&#1089;&#1090;&#1088;&#1086;&#1081;&#1082;&#1072; &#1087;&#1086;&#1083;&#1085;&#1086;&#1089;&#1090;&#1100;&#1102; &#1092;&#1091;&#1085;&#1082;&#1094;&#1080;&#1086;&#1085;&#1072;&#1083;&#1100;&#1085;&#1099;&#1093; &#1089;&#1090;&#1072;&#1085;&#1094;&#1080;&#1081; &#1074; &#1055;&#1091;&#1089;&#1090;&#1086;&#1084; &#1055;&#1088;&#1086;&#1089;&#1090;&#1088;&#1072;&#1085;&#1089;&#1090;&#1074;&#1077;" author="Euclid"/>
  <text language="44" name="TempZoneStationBuilder" description="Option to build selected station when entering empty space" author="Euclid"/>
  <text language="49" name="TempZoneStationBuilder" description="Option eine ausgewaehlte Station in einer Leerzone zu bauen" author="Euclid"/>
</content>
