Auto station and scouting script (need help)

The place to discuss scripting and game modifications for X Rebirth.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

WesternGunman
Posts: 27
Joined: Mon, 13. Feb 06, 02:00
x4

Auto station and scouting script (need help)

Post by WesternGunman »

Hey all,
I've been trying to figure out how to write a script that I can assign to small ships that I own. Their sole purpose would be to fly through all known sectors and scan/refresh the stations. I envision it to be similar to the explorer command software from TC/AP.

I'm hoping to pull the ears of some of the experienced modders in our great community. This will be the first attempt I will be making for an X mod. Any and all help is appreciated.

So how do I get started? Meaning is a mod like this even possible in X-R?
Thanks
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

working on this too with another approach. here is what i have and which works so far:

Code: Select all

      <do_all exact="this.station.usedbuildslots.count" counter="$i">
        <show_notification caption="this.station.usedbuildslots.{$i}.group" details="[ this.station.usedbuildslots.{$i}.sequence , this.station.usedbuildslots.{$i}.stage , this.station.usedbuildslots.{$i}.tags , this.station.usedbuildslots.{$i}.primary , this.station.usedbuildslots.{$i}.name , this.station.usedbuildslots.{$i}.child ]" timeout="3s"/>
        <set_object_scanned object="this.station" sequence="this.station.usedbuildslots.{$i}.sequence" stage="this.station.usedbuildslots.{$i}.stage" scanner="player.primaryship.scanner"/>
        <wait exact="4s"/>
      </do_all>
      
it scans a building stage of a station completely, although the first part (the initial sation without upgrades) is missing. and it doesnt reveal Trade Offers/Ports or Platforms, but this should be solveable, too ^^
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
WesternGunman
Posts: 27
Joined: Mon, 13. Feb 06, 02:00
x4

Post by WesternGunman »

That seems to be limited to player.

I think I have a couple things to work with.

Several items to solve:
How to write a script that will work for any ship.
Determines which stations need scanned
Set course for said station and sector.
Scan the station, whether in parts or as a whole. Including trade offers.
How to assign script to a ship. (will this need to be tied to the UFO project?)

Am I forgetting anything?
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

dont judge a code by its looks :roll: this is in fact executed on a seperate NPC which is on the Station to be scanned :roll: he just uses the Scanners of the Playership because i didnt get to the part where i install Scanners on the NPC yet (and it works even if the Player is somewhere diffrent so until the scanning part works completely its low prio)


and besides: i am not writhing this Code for your project, i am giving you what i currently have on this from my project.
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
WesternGunman
Posts: 27
Joined: Mon, 13. Feb 06, 02:00
x4

Post by WesternGunman »

lol indeed, indeed.

I'm less than a novice at X modding, so reading into how a piece of code can be used is beyond my grasp currently. As i'm a programmer by trade, I just need to get a grasp on how things work in the big picture. ( I think i need to re-read the how to mod pages a couple more times) Reading XML is easy enough, but knowing how it will work when combined with the whole, is a whole other animal.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

ok, just a small update on this: made code cleaner and now scans the Base Station, too ^^ (as it seems the base Station is stage 0 and does not need a sequence attribute, so scanning it seperately)

Code: Select all

  <show_notification caption="this.station.name" details="[ 'Sequence X' , 'X / X' ]" timeout="3s"/>
  <wait exact="4s"/>
  <do_all exact="this.station.currentbuildplan.sequences.count" counter="$sequence">
    <show_notification caption="this.station.name" details="[ 'Sequence '+ this.station.currentbuildplan.sequences.{$sequence} , 'X / ' + this.station.currentbuildplan.{this.station.currentbuildplan.sequences.{$sequence}}.stage ]" timeout="3s"/>
    <wait exact="4s"/>
    <do_all exact="this.station.currentbuildplan.{this.station.currentbuildplan.sequences.{$sequence}}.stage" counter="$stage">
      <show_notification caption="this.station.name" details="[ 'Sequence '+ this.station.currentbuildplan.sequences.{$sequence} , $stage + ' / ' + this.station.currentbuildplan.{this.station.currentbuildplan.sequences.{$sequence}}.stage ]" timeout="3s"/>
      <set_object_scanned object="this.station" sequence="this.station.currentbuildplan.sequences.{$sequence}" stage="$stage" scanner="player.primaryship.scanner"/>
      <wait exact="4s"/>
    </do_all>
  </do_all>
  <show_notification caption="this.station.name" details="[ 'Base Station' , 'N/A' ]" timeout="3s"/>
  <set_object_scanned object="this.station" stage="0" scanner="player.primaryship.scanner"/>
  <wait exact="4s"/>
the "show_notification"s are just Info for developing purposes.

currently still does not yet reveal Docking Platforms or Trading Ports/offers, but will work on this, too ^^
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
WesternGunman
Posts: 27
Joined: Mon, 13. Feb 06, 02:00
x4

Post by WesternGunman »

you have
scanner="player.primaryship.scanner"
in mastraffic.watchdog.xml it has
scanner="$target"
and in Drone_Scan_Hack.xml it has
scanner="player.controlled.scanner"
and several other references to
scanner="player.primaryship"
I wonder what the difference is.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

it determines which scanner to use when revealing something - some scanners are better than others ;) but seems only to work with existent objects & their scanners (additionally in case of player.primaryship.scanner (not sure about the variant without scanner) it makes a short scanning animation on the HUD Haircross and highligts the scanned parts for a moment)

hint: there is a tutorial how to set up eclipse for Scripting/modding ;) it displays the documentation delivered with the .xsd files while writing scripts ;) (although i dont use it currently, i prefer lighter programs)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
User avatar
darthmoll
Posts: 196
Joined: Fri, 11. Sep 09, 16:24
x4

Post by darthmoll »

UniTrader wrote:it determines which scanner to use when revealing something - some scanners are better than others ;) but seems only to work with existent objects & their scanners (additionally in case of player.primaryship.scanner (not sure about the variant without scanner) it makes a short scanning animation on the HUD Haircross and highligts the scanned parts for a moment)

hint: there is a tutorial how to set up eclipse for Scripting/modding ;) it displays the documentation delivered with the .xsd files while writing scripts ;) (although i dont use it currently, i prefer lighter programs)

please. point the way to that tutorial. i did see it somewhere. but now i dont know where.
mrowka
Posts: 128
Joined: Tue, 30. Jun 09, 19:50
x4

Post by mrowka »

MK3 Optimization "If you get stinky rich its his fault"
IEX - Sector Visual Enhancement "Dont enjoy the view navigating thrugh asteroid field, Seriously!"
Marine Repair 2 "Tip 19: Modern coffie cup`s are made of hull plating, beware"
User avatar
darthmoll
Posts: 196
Joined: Fri, 11. Sep 09, 16:24
x4

Post by darthmoll »

thank you. that is the one i was looking for. :)
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

If the player has trade software installed, wouldn't scanning the base structure of the station in that way automatically update the trade info? I'm barely understanding how mods are made atm, so can't test this for myself.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

thats worth lookin into, but its not a must work.. especially because we are revealing the Station per script (and with that there seems to be no range limit of the PS Scanner which indicates this works diffrent)

and i am currently btw a bit stuck with this, my current approach would be that the NPC deals out special offers exclusively for the Player (price depends on Relation, Storage and NPC XP) because it seems i cannt set the knowntoplayer value - either its exclusive for the player or he has to discover it (just by judging the command syntax, didnt try it yet)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

Making a little progress into modding tonight. I borrowed some code from NESA to add a menu item and used this code :

Code: Select all

<cue name="GTN_FindValidTrades" instantiate="true" namespace="this">
      <conditions>
        <event_cue_signalled />
      </conditions>
      <actions>
        <!-- Current state - Finds the buy + sell orders and can scan the station remotely. Does not update trade window with trade software from remote scan of station -->
        
        <!-- Read the list of stations made by a renamed copy of NESA_FindValidStations and scan the base element -->
        <do_all exact="event.param.{2}.count" counter="$i">
          <show_notification caption="event.param.{2}.{$i}.name" details="[ 'Base Station' , 'N/A' ]" timeout="3s"/>
          <set_object_scanned object="event.param.{2}.{$i}" stage="0" scanner="player.primaryship.scanner"/>
        </do_all>

        <find_buy_offer result="$lBuys" tradepartner="player.ship" multiple="true" />
        <show_help custom="'Found %1 buy offers.'.[$lBuys.count]" />

        <find_sell_offer result="$lSells" tradepartner="player.ship" multiple="true" />
        <show_help custom="'Found %1 sell offers.'.[$lSells.count]" />

        <reset_cue cue="this" />
      </actions>
    </cue>
the number of sells and buys for the players zone seems correct, but scanning the station base with your code doesn't update the trade window with trade software installed.

EDIT :

Adding these lines as test case

Code: Select all

        <do_all exact="$lBuys.count" counter="$i">
          <show_help custom="'%1 (Buy) @ %2'.[$lBuys.{$i}.ware.name, $lBuys.{$i}.owner.name]" />
          <set_object_scanned object="$lBuys.{$i}.owner" stage="0" scanner="player.primaryship.scanner"/>
        </do_all>
        
        <do_all exact="$lSells.count" counter="$i">
          <show_help custom="'%1 (Sell) @ %2'.[$lSells.{$i}.ware.name, $lSells.{$i}.owner.name]" />
          <set_object_scanned object="$lSells.{$i}.owner" stage="0" scanner="player.primaryship.scanner"/>
        </do_all>
confirms the validity of gathered orders, although the trade owner points us back to station not a trade node and the order to scan does nothing :s
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

@ WesternGunman

Sorry fella hijacking your thread a bit here :D To go with the scan zone loop in the code above this is the modified FindValidStations cue I used to check all stations whether previously discovered or not

Code: Select all

<cue name="GTN_FindValidStations" instantiate="true" namespace="this">
      <conditions>
        <event_cue_signalled />
      </conditions>
      <actions>
        <!-- Then we can start looking for stations -->
        <set_value name="$oSpace" exact="player.zone" />
        
        <find_station name="$lStations" space="$oSpace" multiple="true" >
          <match_distance object="player.primaryship" max="9999km" />
        </find_station>
        <show_help force="true" custom="'Found %1 stations within %2m of the player.'.[$lStations.count,9999km]" chance="0" />

        <!-- here we are doing an insertion sort -->
        <create_list name="$lStationsSorted" />
        <do_all exact="$lStations.count" counter="$i">
          <set_value name="$iIdx" exact="1" />
          <do_all exact="$lStationsSorted.count">
            <do_if value="player.primaryship.distanceto.{$lStations.{$i}} > player.primaryship.distanceto.{$lStationsSorted.{$iIdx}}">
              <set_value name="$iIdx" operation="add" />
            </do_if>
            <do_else>
              <break />
            </do_else>
          </do_all>
          <show_help force="true" custom="'Inserting station %1 (%2m) at index %3.'.[$lStations.{$i}.name,player.primaryship.distanceto.{$lStations.{$i}},$iIdx]" chance="0" />
          <set_value operation="insert" name="$lStationsSorted.{$iIdx}" exact="$lStations.{$i}" />
        </do_all>

        <!-- Set the return value and reset cue -->
        <set_value name="event.param.{1}.$aReturn" exact="[$lStationsSorted]" />
        <reset_cue cue="this" />
      </actions>
    </cue>
Hope that helps with your mod. Code of course is Mad_Joker's not mine. I just meddled with it.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

ok, i have a way to unlock Trade Offers for the Player. it is a temporary solution and probably needs some modification because it may cause errors:

Code: Select all

      <find_sell_offer seller="this.station" multiple="true" result="$SellOffers" />
      <do_all exact="$SellOffers.count" counter="$i" >
        <add_trade_offer object="player.primaryship" tradeoffer="$SellOffers.{$i}"/>
        <show_notification caption="this.station.name" details="[ $SellOffers.{$i}.owner , $SellOffers.{$i}.ware , $SellOffers.{$i}.amount , $SellOffers.{$i}.unitprice , $SellOffers.{$i}.knowntoplayer ]" timeout="3s"/>
       <wait exact="2s"/>
      </do_all>
      
      <find_buy_offer buyer="this.station" multiple="true" result="$SellOffers" />
      <do_all exact="$SellOffers.count" counter="$i" >
        <add_trade_offer object="player.primaryship" tradeoffer="$SellOffers.{$i}"/>
        <show_notification caption="this.station.name" details="[ $SellOffers.{$i}.owner , $SellOffers.{$i}.ware , $SellOffers.{$i}.amount , $SellOffers.{$i}.unitprice , $SellOffers.{$i}.knowntoplayer ]" timeout="3s"/>
       <wait exact="2s"/>
     </do_all>

with this Code all Trades of the Station are also available on the Playership and therefore known to the Player. it may cause trouble if someone wants to sell to the Playership, so i would suggest to create a new Player Object (Ship) inside the respective Station and add Trade Offers to this Ship - to be in the Tradelist it just has to be available on some player Object, so if you want to remove this offer from the Trading Menu remove it from the Ship ;)

Credits: eMYNOCK the Guy who said "yes"to the question if the Player knows all offers from Stations he owns
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

adding info how to get Zone Position of an Infopoint: (not sure if it will be useful, but maybe someone needs it)

Code: Select all

<transform_position refposition="$Scan.component.station.position" refrotation="$Scan.component.station.rotation" name="$pos">
 <position value="$Scan.component.position"/>
</transform_position>
<transform_position refposition="$pos" refrotation="$Scan.component.rotation" name="$pos">
 <position value="$Scan.offset" />
</transform_position>
$Scan is the Infopoint and $pos is the Position of it in the Zone (to which Positions are relative in many cases)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

Ran a test of your code on all stations in universe, just 1 log entry -

[=ERROR=] c:\dev\x4\X4\ui\xanark\anarkviewbridge.cpp(129): Too many UIObject updates in the current frame. We already scheduled 120 updates. The update calls will be skipped in order to prevent potential crashes. Either locate the underlying issue causing so many updates, or increase the limit to be able to schedule more updates per frame. [ Stefan ]
(version: 1.22 - Code revision: 179703M)

56 too many! doh. will have to seperate the checks to accommodate large numbers of info brokers building up over time if they all update simultaneously.

Excellent job on this, looking forward to seeing the final result :) Reducing the range to cluster left no .log error at all.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
WesternGunman
Posts: 27
Joined: Mon, 13. Feb 06, 02:00
x4

Post by WesternGunman »

I've been AWOL for a few. Life got busy... you know how it is.

Yorr, I don't mind the hijack since it along the same lines, possibly even a better approach then mine ...considering mine also involves fleet management which is sadly lacking in game.

My questions, is it scanning all stations or just known stations?
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

It scans all :) Bit of a cheat doing it this way but it's crucial functionality for my approach to doing fast snapshots of the economy to the onboard trade comp
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

Return to “X Rebirth - Scripts and Modding”