Auto station and scouting script (need help)
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 27
- Joined: Mon, 13. Feb 06, 02:00
Auto station and scouting script (need help)
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
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
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
working on this too with another approach. here is what i have and which works so far:
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 ^^
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>
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
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

-
- Posts: 27
- Joined: Mon, 13. Feb 06, 02:00
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?
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?
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
dont judge a code by its looks
this is in fact executed on a seperate NPC which is on the Station to be scanned
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.


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
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

-
- Posts: 27
- Joined: Mon, 13. Feb 06, 02:00
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.
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.
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
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)
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 ^^
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"/>
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
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

-
- Posts: 27
- Joined: Mon, 13. Feb 06, 02:00
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
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)

hint: there is a tutorial how to set up eclipse for Scripting/modding


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
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

-
- Posts: 196
- Joined: Fri, 11. Sep 09, 16:24
UniTrader wrote:it determines which scanner to use when revealing something - some scanners are better than othersbut 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/moddingit 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.
-
- Posts: 128
- Joined: Tue, 30. Jun 09, 19:50
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"
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"
-
- Posts: 196
- Joined: Fri, 11. Sep 09, 16:24
-
- Posts: 2774
- Joined: Tue, 29. Oct 13, 21:59
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.
Split irritate visiting pilot with strange vocal patterns.
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
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)
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
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

-
- Posts: 2774
- Joined: Tue, 29. Oct 13, 21:59
Making a little progress into modding tonight. I borrowed some code from NESA to add a menu item and used this code :
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
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 
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>
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>

X Rebirth - A Sirius Cybernetics Corporation Product
Split irritate visiting pilot with strange vocal patterns.
Split irritate visiting pilot with strange vocal patterns.
-
- Posts: 2774
- Joined: Tue, 29. Oct 13, 21:59
@ WesternGunman
Sorry fella hijacking your thread a bit here
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
Hope that helps with your mod. Code of course is Mad_Joker's not mine. I just meddled with it.
Sorry fella hijacking your thread a bit here

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>
X Rebirth - A Sirius Cybernetics Corporation Product
Split irritate visiting pilot with strange vocal patterns.
Split irritate visiting pilot with strange vocal patterns.
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
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:
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
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
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

-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
adding info how to get Zone Position of an Infopoint: (not sure if it will be useful, but maybe someone needs it)
$Scan is the Infopoint and $pos is the Position of it in the Zone (to which Positions are relative in many cases)
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>
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
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

-
- Posts: 2774
- Joined: Tue, 29. Oct 13, 21:59
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.
[=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

X Rebirth - A Sirius Cybernetics Corporation Product
Split irritate visiting pilot with strange vocal patterns.
Split irritate visiting pilot with strange vocal patterns.
-
- Posts: 27
- Joined: Mon, 13. Feb 06, 02:00
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?
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?
-
- Posts: 2774
- Joined: Tue, 29. Oct 13, 21:59