Skip to content

Commit

Permalink
Merge pull request #1 from UniTrader/Development
Browse files Browse the repository at this point in the history
Movement Scripts Update
  • Loading branch information
UniTrader committed Aug 30, 2015
2 parents c374842 + 5c35272 commit 0824396
Show file tree
Hide file tree
Showing 26 changed files with 15,738 additions and 279 deletions.
Binary file not shown.
21 changes: 12 additions & 9 deletions aiscripts/ut.cac.base.captain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</actions>
</handler>
<!-- here are all Signals listed the planned Navigation Script(s) will send with a short description what they do - this is just a declaration of intention, nothing is actually used/implemented so far.-->
<handler>
<!--handler>
<conditions>
<check_any>
<event_object_signalled object="this.ship" param="'travel jump prep'" param2="$destination" param3="$follower_list" comment="
Expand All @@ -32,7 +32,7 @@
<event_object_signalled object="this.ship" param="'emergency boost'" param2="$destination" comment="see above - just for boost"/>
</check_any>
</conditions>
</handler>
</handler-->
<handler>
<!--
add a new Order to the queue - param2 = Order List; param3 = Position in List (0=end; 1=first, interrupt current Order (will be repeated), any other Number: Insert at Position)
Expand Down Expand Up @@ -121,13 +121,16 @@
<debug_text filter="general" chance="this.$debug * 100" text="'%1 %2 %3 Command Queue: \n%4'.[player.age,this.name,this.container.name,this.$orderlist]"/>
<set_value name="$order" exact="this.$orderlist.{1}" />
<do_if value="typeof $order == datatype.table">
<remove_value name="$repeat"/>
<set_value name="$order.$interruptable" exact="false"/>
<run_script name="$order.$script">
<param name="params" value="$order" />
</run_script>
</do_if>
<!-- remove current Order so we can get to the next one - after that wait a split-second to prevent Freezes should something go wrong-->
<remove_value name="this.$orderlist.{1}" />
<!-- If current first Order is still the same as before executing it - remove it from Orderlist so we can continue with the next one - after that wait a split-second to prevent Freezes should something go wrong -->
<!-- (if its a diffrent Order the first Order was moved or replaced, which should cause an abort of it and a the new first Order should be executed immediately) -->
<do_if value="this.$orderlist.{1} == $order">
<remove_value name="this.$orderlist.{1}" />
</do_if>
<wait exact="100ms"/>
</do_while>

Expand All @@ -138,7 +141,7 @@
<!-- if there are outstanding Trade Orders: do trade. -->
<get_trade_from_shoppinglist object="this.ship" result="$trade"/>
<do_if value="$trade.exists">
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.com.captain.performsingletraderun',$repeat=0]"/>
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.com.captain.performsingletraderun',$displayname='Perform Trade (default)',$repeat=0,$interruptable=true]"/>
<resume label="start"/>
</do_if>

Expand All @@ -157,7 +160,7 @@

<!-- Cargobay (more than) half full without any other orders, so its dead weight - empty it. -->
<do_if value="this.ship.cargo.free lt this.ship.cargo.capacity/2">
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.com.captain.emptycargo',$onlysector=true]"/>
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.com.captain.emptycargo',$displayname='Empty Cargobay (default)',$onlysector=true,$interruptable=true]"/>
<resume label="start"/>
</do_if>

Expand All @@ -170,13 +173,13 @@
</do_if>
<do_else comment="this.ship.primarypurpose == objectpurpose.trade">
<!-- wait at current Position until given a new Order, pester again after 1h -->
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.microorder',$order='wait signal',$signalobject=this,$signalparam='new order',$repeat=0]"/>
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.microorder',$displayname='Wait for Orders (default)',$order='wait signal',$signalobject=this,$signalparam='new order',$repeat=0]"/>
<resume label="start"/>
</do_else>
</do_if>
<do_else>
<!-- nothing to do - wait and add to Order request Group of Commander -->
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.microorder',$order='wait order',$time=10min]"/>
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.microorder',$displayname='Wait for Orders (default)',$order='wait order',$time=10min,$interruptable=true]"/>
<signal_objects object="this.ship.commanderentity" param="'request orders'" param2="this"/>
</do_else>

Expand Down
22 changes: 12 additions & 10 deletions aiscripts/ut.cac.base.manager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,16 @@
</do_if>

<!-- Set up mining Command (must re-use the same table since i am also using it to store persistent Values) - only $mininglist is updated with every iteration so the miningscript knows what is needed -->
<set_value name="$miningorder" exact="table[$script='ut.cac.com.manager.gatherressources']"/>
<set_value name="$miningorder" exact="table[$script='ut.cac.com.manager.gatherressources',$displayname='Gather Ressources (default)',$interruptable=false]"/>

<!--immediately allow Zone Trading and Mining -->
<set_value name="$next_zonetrade" exact="player.age"/>
<set_value name="$next_miningstep" exact="player.age"/>

<!-- for debug purposes-->
<set_value name="this.$debug" exact="true"/>
<!--set_value name="this.$debug" exact="true"/-->

<!-- add Fuelcells as Trade Ware if Sctation has Cargo for them so Energy Freighters will buy it and put it into the Station Cargo for Refueling of Station Ships -->
<!-- note: will be unused in first release Version because i remove Energy/Fuel Cargo combination for now -->
<do_if value="this.container.cargo.{ware.fuelcells}.free gt 0">
<add_tradeware object="this.container" ware="ware.fuelcells" allowbuy="true" allowsell="false"/>
</do_if>
Expand All @@ -93,13 +92,16 @@
<debug_text filter="general" chance="this.$debug * 100" text="'%1 %2 %3 Command Queue: \n%4'.[player.age,this.name,this.container.name,this.$orderlist]"/>
<set_value name="$order" exact="this.$orderlist.{1}" />
<do_if value="typeof $order == datatype.table">
<remove_value name="$repeat"/>
<set_value name="$order.$interruptable" exact="false"/>
<run_script name="$order.$script">
<param name="params" value="$order" />
</run_script>
</do_if>
<!-- remove current Order so we can get to the next one - after that wait a split-second to prevent Freezes should something go wrong-->
<remove_value name="this.$orderlist.{1}" />
<!-- If current first Order is still the same as before executing it - remove it from Orderlist so we can continue with the next one - after that wait a split-second to prevent Freezes should something go wrong -->
<!-- (if its a diffrent Order the first Order was moved or replaced, which should cause an abort of it and a the new first Order should be executed immediately) -->
<do_if value="this.$orderlist.{1} == $order">
<remove_value name="this.$orderlist.{1}" />
</do_if>
<wait exact="100ms"/>
</do_while>

Expand All @@ -110,12 +112,12 @@
<!-- check if we have Idle Subordinates and find Jobs for them (priority, immediately start with finding orders fo them) -->
<do_if value="this.$idle_subordinates.count gt 0">
<do_all exact="this.$idle_subordinates.count" counter="$i">
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.com.manager.findjob',$entity=this.$idle_subordinates.{$i}]"/>
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.com.manager.findjob',$displayname='Find Job (Subordinate Request)',$entity=this.$idle_subordinates.{$i},$interruptable=false]"/>
</do_all>
<resume label="start with orderlist"/>
</do_if>

<!-- check if we have gasses as ressource and can mine them directly (!!!Testing needed!!! )-->
<!-- check if we have gasses as ressource and can mine them directly -->
<do_if value="player.age gt $next_miningstep">
<set_value name="$next_miningstep" exact="player.age + 1min"/>
<create_list name="$mineable_ressources"/>
Expand All @@ -142,11 +144,11 @@
<!-- if there is not much else to do - do Zonetrade (POSSIBLY TIME INTENSIVE) -->
<do_if value="this.$orderlist.count lt 1 and player.age gt $next_zonetrade">
<set_value name="$next_zonetrade" exact="player.age + 7min"/>
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.com.manager.zonetrade',$repeat=false]"/>
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.com.manager.zonetrade',$displayname='Perform Zonetrade (default)',$repeat=false,$interruptable=true]"/>
</do_if>

<do_if value="this.$orderlist.count == 0">
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.microorder',$order='wait order',$time=5min]"/>
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.microorder',$displayname='Wait for Orders (default)',$order='wait order',$time=5min,$interruptable=true]"/>
</do_if>

<resume label="start with orderlist"/>
Expand Down
6 changes: 3 additions & 3 deletions aiscripts/ut.cac.com.capain.performsingletraderun.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@
<debug_text filter="general" chance="this.$debug * 100" text="'%1 %2 %3 Move to correct Zone:\n$tradepartner.zone= %4'.[player.age,this.name,this.container.name,$tradepartner.zone.knownname]"/>
<do_if value="this.zone != $tradepartner.zone">
<set_command_action commandaction="commandaction.flyingto" param="$tradepartner.zone"/>
<run_script name="'move.generic'">
<run_script name="'ut.cac.move.generic'">
<param name="destination" value="$tradepartner" />
<param name="endintargetzone" value="true" />
<param name="endintargetspace" value="true" />
</run_script>
</do_if>

Expand Down Expand Up @@ -419,7 +419,7 @@
</do_if>
<!-- remove shoppinglist item, and check list again -->
<remove_trade_order object="this.ship" trade="$trade" />
<debug_text filter="general" chance="this.$debug * 100" text="'%1 %2 %3 Trade failed - aborting'.[player.age,this.name,this.container.name]"/>
<debug_text filter="error" text="'%1 %2 %3 Trade failed - aborting'.[player.age,this.name,this.container.name]"/>
<return/>
</do_if>

Expand Down
4 changes: 2 additions & 2 deletions aiscripts/ut.cac.com.capain.refuel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@

<!-- find nearest Source for Fuel Cells (first check current Station and Home Station (Offers and Cargo), then Sector and as last the Cluster) -->
<set_value name="$selloffer" exact="null"/>
<do_if value="this.ship.parkedat.container.exists">
<do_if value="this.ship.parkedat.exists">
<find_sell_offer result="$selloffer" seller="this.ship.parkedat.container" wares="ware.fuelcells">
<offeramount min="$buyamount"/>
</find_sell_offer>
<do_if value="not $selloffer.available and this.ship.parkedat.container.cargo.{ware.fuelcells}.count ge $buyamount and this.ship.parkedat.container.trueownner == this.ship.trueowner">
<do_if value="not $selloffer.available and this.ship.parkedat.container.cargo.{ware.fuelcells}.count ge $buyamount and this.ship.parkedat.container.trueowner == this.ship.trueowner">
<execute_custom_trade buyer="this.ship" seller="this.ship.parkedat.container" amount="$buyamount" ware="ware.fuelcells" price="0Cr" result="$result" usecommandermoney="true">
<interrupt_after_time time="121min"/>
</execute_custom_trade>
Expand Down
4 changes: 2 additions & 2 deletions aiscripts/ut.cac.com.captain.emptycargo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<!-- Offer is in current Zone - just add it to the Trade Orders -->
<do_if value="$buyoffers.{$i}.owner.zone == $currentzone">
<add_sell_order object="this.ship" trade="$buyoffers.{$i}" amount="this.ship.cargo.{$warelist.{$i}}.count" price="$buyoffers.{$i}.unitprice"/>
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.com.captain.performsingletraderun',$repeat=0]"/>
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.com.captain.performsingletraderun',$displayname='Traderun (Empty cargo)',$repeat=0]"/>
<remove_value name="$buyoffers.{$i}"/>
</do_if>
<!-- Offer is somewhere else - if its closer than the previous Offer save it, if not wait for next iteration -->
Expand All @@ -96,7 +96,7 @@
</do_all>
<debug_text filter="general" chance="this.$debug * 100" text="'%1 %2 %3 Adding Buy Offer to Trade List:\n%4'.[player.age,this.name,this.container.name,$buyoffers.{$mindistindex}]"/>
<add_sell_order object="this.ship" trade="$buyoffers.{$mindistindex}" amount="this.ship.cargo.{$warelist.{$mindistindex}.count}" price="$buyoffers.{$mindistindex}.unitprice"/>
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.com.captain.performsingletraderun',$repeat=0,$command=command.freetrade]"/>
<append_to_list name="this.$orderlist" exact="table[$script='ut.cac.com.captain.performsingletraderun',$displayname='Traderun (Empty cargo)',$repeat=0,$command=command.freetrade]"/>
<set_value name="$currentzone" exact="$buyoffers.{$mindistindex}.zone"/>
<!-- Path Length for small Ships, raw Distance for Big Ships -->
<do_if value="this.ship.isclass.ship_m or this.ship.isclass.ship_s or this.ship.isclass.ship_xs">
Expand Down
4 changes: 2 additions & 2 deletions aiscripts/ut.cac.com.captain.mining.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
<!-- Go to Ordered Zone -->
<do_if value="this.zone != $zone">
<set_command_action commandaction="commandaction.flyingto" param="$zone"/>
<run_script name="'move.generic'">
<run_script name="'ut.cac.move.generic'">
<param name="destination" value="$zone" />
<param name="endintargetzone" value="true" />
<param name="endintargetspace" value="true" />
</run_script>
</do_if>
<debug_text filter="general" chance="this.$debug * 100" text="'%1 %2 %3 Reached Zone where we mine'.[player.age,this.name,this.container.name]"/>
Expand Down
2 changes: 1 addition & 1 deletion aiscripts/ut.cac.com.manager.findjob.mine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $mininglist = ' + $mininglist"/>
<set_value name="$amount" exact="[this.container.cargo.{$mininglist.{1}}.target - this.container.cargo.{$mininglist.{1}}.count - $incomingamount , $entity.ship.cargo.{$mininglist.{1}}.free].min"/>
<!-- $zone is a Return Value!!! -->
<find_closest_resource zone="$zone" ware="$mininglist.{1}" minamount="$amount" refobject="this.container" wares="$secwares" />
<signal_objects object="$entity.ship" param="'new order'" param2="table[$script='ut.cac.com.captain.mining',$zone=$zone,$mininglist=$mininglist]"/>
<signal_objects object="$entity.ship" param="'new order'" param2="table[$script='ut.cac.com.captain.mining',$displayname='Mining in %1 (Manager)'.[$zone.knownname],$zone=$zone,$mininglist=$mininglist,$interruptable=false]"/>

</actions>
</attention>
Expand Down
4 changes: 2 additions & 2 deletions aiscripts/ut.cac.com.manager.findjob.trade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ $entity = ' + $entity"/>
<add_sell_order object="$entity.ship" trade="$buyoffer" amount="$amount" price="$selloffer.unitprice"/>
<remove_trade_offer object="this.container" tradeoffer="$buyoffer"/>
<!-- tell the Ship to get the Wares and bring them back ( ^= 2 single trade runs ) -->
<signal_objects object="$entity.ship" param="'new order'" param2="[ table[$script='ut.cac.com.captain.performsingletraderun',$undock=1] , table[$script='ut.cac.com.captain.performsingletraderun',$undock=0] , table[$script='ut.cac.com.captain.refuel',$undock=1] ]"/>
<signal_objects object="$entity.ship" param="'new order'" param2="[ table[$script='ut.cac.com.captain.performsingletraderun',$displayname='Perform Trade (Manager)',$undock=1,$interruptable=false] , table[$script='ut.cac.com.captain.performsingletraderun',$displayname='Perform Trade (Manager)',$undock=0,$interruptable=false] , table[$script='ut.cac.com.captain.refuel',$displayname='Refuel (Manager)',$undock=1,$interruptable=true] ]"/>
<break/>
</do_if>
</do_if>
Expand Down Expand Up @@ -307,7 +307,7 @@ $entity = ' + $entity"/>
<add_sell_order object="$entity.ship" trade="$buyoffer" amount="$amount" price="$buyoffer.unitprice"/>
<remove_trade_offer object="this.container" tradeoffer="$selloffer"/>
<!-- tell the Ship to get the Wares and bring them back ( ^= 2 single trade runs ) -->
<signal_objects object="$entity.ship" param="'new order'" param2="[ table[$script='ut.cac.com.captain.performsingletraderun',$undock=0] , table[$script='ut.cac.com.captain.refuel',$undock=1] , table[$script='ut.cac.com.captain.performsingletraderun',$undock=1] ]"/>
<signal_objects object="$entity.ship" param="'new order'" param2="[ table[$script='ut.cac.com.captain.performsingletraderun',$displayname='Perform Trade (Manager)',$undock=0,$interruptable=false] , table[$script='ut.cac.com.captain.refuel',$displayname='Refuel (Manager)',$undock=1,$interruptable=true] , table[$script='ut.cac.com.captain.performsingletraderun',$displayname='Perform Trade (Manager)',$undock=1,$interruptable=false] ]"/>
<!--do_if value="$entity.$orderlist.{1}.$order == 'wait minmax'">
<signal_objects object="$entity.ship" param="'next order'"/>
</do_if-->
Expand Down

0 comments on commit 0824396

Please sign in to comment.