Skip to content

Commit

Permalink
v7.04
Browse files Browse the repository at this point in the history
Fixed traders failing repeatedly when finding trades that sell to a station with no cargo for drones, ammunition, or black market. Improved ignoreshipbuyers code. Changed clamp_trade debug message from error to script filter due to it being an intended design to prevent faulty trades.
  • Loading branch information
DeadAirRT committed Oct 2, 2024
1 parent cc23187 commit c224d73
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 17 deletions.
71 changes: 55 additions & 16 deletions aiscripts/deadtater.xml
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,15 @@
</do_if>
<do_if value="@$buyers.count">
<do_all exact="$buyers.count" counter="$buy">
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (@$buyers.{$buy}.type != shiptype.resupplier) and (@$buyers.{$buy}.type != shiptype.carrier))">
<append_to_list name="$buyoffers" exact="$buyers.{$buy}"/>
<!-- 20241002 Updating $ignoreshipbuyers code -->
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (not $buyers.{$buy}.buyer.isclass.ship))">
<!-- 20241002 Implementing fix for stations with no storage -->
<do_if value="$buyers.{$buy}.buyer.cargo.{$Cargo.{$ware}}.free">
<append_to_list name="$buyoffers" exact="$buyers.{$buy}"/>
</do_if>
<do_else>
<debug_text text="'MOD: DeadTater -- %s(%s) -- Skipping offer from: %s(%s) in %s -- No cargo capacity for type: %s'.[this.assignedcontrolled.name,this.assignedcontrolled.idcode,$buyers.{$buy}.buyer.knownname,$buyers.{$buy}.buyer.idcode,$buyers.{$buy}.buyer.sector.knownname,$Cargo.{$ware}.transporttag]" context="false" filter="scripts" chance="@$TaterDebugChance * 100"/>
</do_else>
</do_if>
</do_all>
</do_if>
Expand Down Expand Up @@ -777,8 +784,15 @@
</do_if>
<do_if value="@$buyers.count">
<do_all exact="$buyers.count" counter="$buy">
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (@$buyers.{$buy}.type != shiptype.resupplier) and (@$buyers.{$buy}.type != shiptype.carrier))">
<append_to_list name="$buyoffers" exact="$buyers.{$buy}"/>
<!-- 20241002 Updating $ignoreshipbuyers code -->
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (not $buyers.{$buy}.buyer.isclass.ship))">
<!-- 20241002 Implementing fix for stations with no storage -->
<do_if value="$buyers.{$buy}.buyer.cargo.{$usedwarebasket.{$ware}}.free">
<append_to_list name="$buyoffers" exact="$buyers.{$buy}"/>
</do_if>
<do_else>
<debug_text text="'MOD: DeadTater -- %s(%s) -- Skipping offer from: %s(%s) in %s -- No cargo capacity for type: %s'.[this.assignedcontrolled.name,this.assignedcontrolled.idcode,$buyers.{$buy}.buyer.knownname,$buyers.{$buy}.buyer.idcode,$buyers.{$buy}.buyer.sector.knownname,$usedwarebasket.{$ware}.transporttag]" context="false" filter="scripts" chance="@$TaterDebugChance * 100"/>
</do_else>
</do_if>
</do_all>
</do_if>
Expand Down Expand Up @@ -841,7 +855,8 @@
<do_if value="@$sellers.count">
<do_all exact="$sellers.count" counter="$sell">
<!-- 20240317 At the moment, ships cannot sell goods but this should future proof it. -->
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (@$sellers.{$sell}.type != shiptype.resupplier) and (@$sellers.{$sell}.type != shiptype.carrier))">
<!-- 20241002 Updating $ignoreshipbuyers code -->
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (not $sellers.{$sell}.seller.isclass.ship))">
<append_to_list name="$selloffers" exact="$sellers.{$sell}"/>
</do_if>
</do_all>
Expand Down Expand Up @@ -1097,8 +1112,15 @@
<do_if value="@$buyers.count">
<do_all exact="$buyers.count" counter="$buy">
<!-- 20240317 ignoreshipbuyers filtering was missing from freetrade section. FIXED -->
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (@$buyers.{$buy}.type != shiptype.resupplier) and (@$buyers.{$buy}.type != shiptype.carrier))">
<append_to_list name="$buyoffers" exact="$buyers.{$buy}"/>
<!-- 20241002 Updating $ignoreshipbuyers code -->
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (not $buyers.{$buy}.buyer.isclass.ship))">
<!-- 20241002 Implementing fix for stations with no storage -->
<do_if value="$buyers.{$buy}.buyer.cargo.{$usedwarebasket.{$ware}}.free">
<append_to_list name="$buyoffers" exact="$buyers.{$buy}"/>
</do_if>
<do_else>
<debug_text text="'MOD: DeadTater -- %s(%s) -- Skipping offer from: %s(%s) in %s -- No cargo capacity for type: %s'.[this.assignedcontrolled.name,this.assignedcontrolled.idcode,$buyers.{$buy}.buyer.knownname,$buyers.{$buy}.buyer.idcode,$buyers.{$buy}.buyer.sector.knownname,$usedwarebasket.{$ware}.transporttag]" context="false" filter="scripts" chance="@$TaterDebugChance * 100"/>
</do_else>
</do_if>
</do_all>
</do_if>
Expand Down Expand Up @@ -1161,7 +1183,8 @@
<do_if value="@$sellers.count">
<do_all exact="$sellers.count" counter="$sell">
<!-- 20240317 At the moment, ships cannot sell goods but this should future proof it. -->
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (@$sellers.{$sell}.type != shiptype.resupplier) and (@$sellers.{$sell}.type != shiptype.carrier))">
<!-- 20241002 Updating $ignoreshipbuyers code -->
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (not $sellers.{$sell}.seller.isclass.ship))">
<append_to_list name="$selloffers" exact="$sellers.{$sell}"/>
</do_if>
</do_all>
Expand Down Expand Up @@ -1420,8 +1443,15 @@
</do_if>
<do_if value="@$buyers.count">
<do_all exact="$buyers.count" counter="$buy">
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (@$buyers.{$buy}.type != shiptype.resupplier) and (@$buyers.{$buy}.type != shiptype.carrier))">
<append_to_list name="$buyoffers" exact="$buyers.{$buy}"/>
<!-- 20241002 Updating $ignoreshipbuyers code -->
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (not $buyers.{$buy}.buyer.isclass.ship))">
<!-- 20241002 Implementing fix for stations with no storage -->
<do_if value="$buyers.{$buy}.buyer.cargo.{$usedwarebasket.{$ware}}.free">
<append_to_list name="$buyoffers" exact="$buyers.{$buy}"/>
</do_if>
<do_else>
<debug_text text="'MOD: DeadTater -- %s(%s) -- Skipping offer from: %s(%s) in %s -- No cargo capacity for type: %s'.[this.assignedcontrolled.name,this.assignedcontrolled.idcode,$buyers.{$buy}.buyer.knownname,$buyers.{$buy}.buyer.idcode,$buyers.{$buy}.buyer.sector.knownname,$usedwarebasket.{$ware}.transporttag]" context="false" filter="scripts" chance="@$TaterDebugChance * 100"/>
</do_else>
</do_if>
</do_all>
</do_if>
Expand Down Expand Up @@ -1484,7 +1514,8 @@
<do_if value="@$sellers.count">
<do_all exact="$sellers.count" counter="$sell">
<!-- 20240317 At the moment, ships cannot sell goods but this should future proof it. -->
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (@$sellers.{$sell}.type != shiptype.resupplier) and (@$sellers.{$sell}.type != shiptype.carrier))">
<!-- 20241002 Updating $ignoreshipbuyers code -->
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (not $sellers.{$sell}.seller.isclass.ship))">
<append_to_list name="$selloffers" exact="$sellers.{$sell}"/>
</do_if>
</do_all>
Expand Down Expand Up @@ -1740,8 +1771,15 @@
<do_if value="@$buyers.count">
<do_all exact="$buyers.count" counter="$buy">
<!-- 20240317 ignoreshipbuyers filtering was missing from freetrade section. FIXED -->
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (@$buyers.{$buy}.type != shiptype.resupplier) and (@$buyers.{$buy}.type != shiptype.carrier))">
<append_to_list name="$buyoffers" exact="$buyers.{$buy}"/>
<!-- 20241002 Updating $ignoreshipbuyers code -->
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (not $buyers.{$buy}.buyer.isclass.ship))">
<!-- 20241002 Implementing fix for stations with no storage -->
<do_if value="$buyers.{$buy}.buyer.cargo.{$usedwarebasket.{$ware}}.free">
<append_to_list name="$buyoffers" exact="$buyers.{$buy}"/>
</do_if>
<do_else>
<debug_text text="'MOD: DeadTater -- %s(%s) -- Skipping offer from: %s(%s) in %s -- No cargo capacity for type: %s'.[this.assignedcontrolled.name,this.assignedcontrolled.idcode,$buyers.{$buy}.buyer.knownname,$buyers.{$buy}.buyer.idcode,$buyers.{$buy}.buyer.sector.knownname,$usedwarebasket.{$ware}.transporttag]" context="false" filter="scripts" chance="@$TaterDebugChance * 100"/>
</do_else>
</do_if>
</do_all>
</do_if>
Expand Down Expand Up @@ -1804,7 +1842,8 @@
<do_if value="@$sellers.count">
<do_all exact="$sellers.count" counter="$sell">
<!-- 20240317 At the moment, ships cannot sell goods but this should future proof it. -->
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (@$sellers.{$sell}.type != shiptype.resupplier) and (@$sellers.{$sell}.type != shiptype.carrier))">
<!-- 20241002 Updating $ignoreshipbuyers code -->
<do_if value="(not $ignoreshipbuyers) or ($ignoreshipbuyers and (not $sellers.{$sell}.seller.isclass.ship))">
<append_to_list name="$selloffers" exact="$sellers.{$sell}"/>
</do_if>
</do_all>
Expand Down Expand Up @@ -1981,7 +2020,7 @@
<clamp_trade_amount trade="$GrofferBuy" amount="$Gromount" buyer="this.assignedcontrolled" seller="$GrofferSell.seller" result="$ClampedAmount" reason="$ClampedReason"/>
<do_if value="$ClampedAmount != $Gromount">
<debug_to_file name="this.assignedcontrolled.idcode" directory="'DeadTater'" text="'MOD: DeadTater -- %s -- $GrofferBuy -- Ware: %s -- $Gromount: %s -- $ClampedAmount: %s -- Reason: %s.'.[player.age,$GrofferBuy.ware,$Gromount,$ClampedAmount,$ClampedReason]" output="false" append="true" chance="@$TaterDebugChance * 100"/>
<debug_text text="'MOD: DeadTater -- %s -- Ship: %s(%s) -- $GrofferBuy -- Ware: %s -- $Gromount: %s -- $ClampedAmount: %s -- Reason: %s -- Seller: %s(%s) in %s'.[player.age,this.assignedcontrolled.name,this.assignedcontrolled.idcode,$GrofferBuy.ware,$Gromount,$ClampedAmount,$ClampedReason,$GrofferSell.seller.knownname,$GrofferSell.seller.idcode,$GrofferSell.seller.sector.knownname]" context="false" filter="error"/>
<debug_text text="'MOD: DeadTater -- %s -- Ship: %s(%s) -- $GrofferBuy -- Ware: %s -- $Gromount: %s -- $ClampedAmount: %s -- Reason: %s -- Seller: %s(%s) in %s -- Prevented error prone trade'.[player.age,this.assignedcontrolled.name,this.assignedcontrolled.idcode,$GrofferBuy.ware,$Gromount,$ClampedAmount,$ClampedReason,$GrofferSell.seller.knownname,$GrofferSell.seller.idcode,$GrofferSell.seller.sector.knownname]" context="false" filter="scripts"/>
<!-- 20240423 Abandoning trade if reduced, this has been catching errors but not enforcing restart -->
<do_if value="$ClampedAmount lt $Gromount">
<remove_value name="$ClampedAmount"/>
Expand All @@ -2005,7 +2044,7 @@
<clamp_trade_amount trade="$GrofferSell" amount="$Gromount" buyer="$GrofferBuy.buyer" result="$ClampedAmount" reason="$ClampedReason"/>
<do_if value="$ClampedAmount != $Gromount">
<debug_to_file name="this.assignedcontrolled.idcode" directory="'DeadTater'" text="'MOD: DeadTater -- %s -- $GrofferSell -- Ware: %s -- $Gromount: %s -- $ClampedAmount: %s -- Reason: %s.'.[player.age,$GrofferSell.ware,$Gromount,$ClampedAmount,$ClampedReason]" output="false" append="true" chance="@$TaterDebugChance * 100"/>
<debug_text text="'MOD: DeadTater -- %s -- Ship: %s(%s) -- $GrofferSell -- Ware: %s -- $Gromount: %s -- $ClampedAmount: %s -- Reason: %s -- Buyer: %s(%s) in %s'.[player.age,this.assignedcontrolled.name,this.assignedcontrolled.idcode,$GrofferSell.ware,$Gromount,$ClampedAmount,$ClampedReason,$GrofferBuy.buyer.knownname,$GrofferBuy.buyer.idcode,$GrofferBuy.buyer.sector.knownname]" context="false" filter="error"/>
<debug_text text="'MOD: DeadTater -- %s -- Ship: %s(%s) -- $GrofferSell -- Ware: %s -- $Gromount: %s -- $ClampedAmount: %s -- Reason: %s -- Buyer: %s(%s) in %s -- Prevented error prone trade'.[player.age,this.assignedcontrolled.name,this.assignedcontrolled.idcode,$GrofferSell.ware,$Gromount,$ClampedAmount,$ClampedReason,$GrofferBuy.buyer.knownname,$GrofferBuy.buyer.idcode,$GrofferBuy.buyer.sector.knownname]" context="false" filter="scripts"/>
<!-- 20240423 Abandoning trade if reduced, this has been catching errors but not enforcing restart -->
<do_if value="$ClampedAmount lt $Gromount">
<remove_value name="$ClampedAmount"/>
Expand Down
2 changes: 1 addition & 1 deletion content.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<content id="TaterTrade" name="TaterTrade" description="Automated Trader Script" author="Ludsoe and DeadAir" version="703" date="2024-09-02" save="0">
<content id="TaterTrade" name="TaterTrade" description="Automated Trader Script" author="Ludsoe and DeadAir" version="704" date="2024-10-02" save="0">
<text language="7" name="TaterTrade" description="TaterTrade" author="Ludsoe"/>
<text language="33" name="TaterTrade" description="TaterTrade" author="Ludsoe"/>
<text language="34" name="TaterTrade" description="TaterTrade" author="Ludsoe"/>
Expand Down

0 comments on commit c224d73

Please sign in to comment.