Reason and Fix for disappearing drones on player ships

The place to discuss scripting and game modifications for X4: Foundations.

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

Post Reply
oxylos
Posts: 32
Joined: Sat, 2. Aug 08, 19:45

Reason and Fix for disappearing drones on player ships

Post by oxylos » Fri, 17. Sep 21, 15:59

Hi,

like in this example: https://www.reddit.com/r/X4Foundations/ ... ng_in_410/
drones are removed from the ship (and game) sometimes. What I could observe was that it happens when the drones try to dock simultaneously on all pads.

I have checked the scripts and found that at the moment the drones disappear, they are destroyed by line 1208 in order.dock.xml by

Code: Select all

<destroy_object object="$thisship" explosion="false"/>
Obove that there is a check section "<!-- Handle invalid or destroyed destination -->"
In that section this do_if checks (line 1180):

Code: Select all

<do_if value="$callerid and $callerid.$cannotdock?">
When the drone disappear the do_else block is executed giving this debug info (line 1187):

Code: Select all

      <!-- NB: in most cases, this order in the order queue is followed by either an order that does not require docking or the default order, in which cases, it is fine. possible infinite loop if an order calls DockAndWait immediately, in which case, add handling as described below. -->
        <debug_text text="'should we cancel the order that created DockAndWait? we cannot do so. pass in $callerid to DockaAndWait, add $cannotdock parameter to the order and handling in the order script.\n callerid: %s %s\n isparameditable: %s\n  critical? %s\n  default? %s\n  finish? %s\n  state: %s'.[@$callerid.id, $callerid, @$callerid.isparameditable.cannotdock, @$callerid.state == orderstate.critical, $callerid == $thisship.defaultorder, @$callerid.state == orderstate.finish, @$callerid.state]" chance="$debugchance"/>
After this, few lines later the destroy_object command (line 1208) is executed and the drone is gone forever.


Im not sure about the $callerid so i just made a small workaround in that do_else block (line 1187):

Code: Select all

<cancel_all_orders object="this.ship"/>
<collect_unit object="$destination" unit="this.ship"/>
Now the drone gets collected by the ship and then disappear only visual.

I made changes to the whole xml file because im not good at finding the correct xpath to that do_else block. I would be glad about help how to make this as a mod. But only of course if this workaround is valid.

linolafett
EGOSOFT
EGOSOFT
Posts: 3319
Joined: Mon, 26. Mar 12, 14:57
x4

Re: Reason and Fix for disappearing drones on player ships

Post by linolafett » Fri, 17. Sep 21, 16:45

Forwarded to the responsible dev, thanks for poking around!
01001100 01101001 01101110 01100101 01110011 00100000 01101111 01100110 00100000 01110100 01101001 01101101 01100101 01110011 00101110 00101110 00101110

My art stuff

Good Wizard
Posts: 450
Joined: Wed, 9. Jun 21, 16:51
x4

Re: Reason and Fix for disappearing drones on player ships

Post by Good Wizard » Sat, 18. Sep 21, 11:27

At the moment in a new game I have only one L miner, a Magnetar. I always buy 3 mining drones for L miners. Yesterday I moved it from The Reach to Pius Mists IV, and was present (IS). The miner was quite efficient in The Reach (average skill 2 stars), but in Pious Mist I saw often the state 'Waiting for mining drones'. So I checked - there ware only 2 mining drones on the ship.

I remembered the post on Reddit, and continued to watch, and in less than an hour it now has only one mining drone, and no combat at all. There are (yet) very few Khaak in Pious Mists IV and no Khaak at all in The Reach.

I suspect, this does not only happen if you are present on the ship or even mining yourself, it seems to happen if you are IS. The miner worked for hours in The Reach, and did not loose drones.

If you need it: I have two saves, one autosave and around 9 minutes later one quicksave (both unmodified), in the earlier autosave the miner has 2 mining drones, and 9 minutes later it has only one. I can post both, if it helps.

But this is a very bad bug, since miners will 'degrade' fast and stop mining without drones, and it takes a lot of time to send them to buy new drones. Please look into this!

EDIT: I made a bug report with two saves (one before and one after a mining drone was lost). This happened while I was IS in less than 10 minutes, drone count went down from 2 to one (and the ship started with 3, as I always give them 3 mining drones). There was no command aborted, the ship just did automine undisturbed, the drone disappeared. The report is here.

j.harshaw
EGOSOFT
EGOSOFT
Posts: 1847
Joined: Mon, 23. Nov 15, 18:02

Re: Reason and Fix for disappearing drones on player ships

Post by j.harshaw » Sat, 18. Sep 21, 17:13

I've found and fixed a bug that could result in this behavior. Cause was delay between drone docking and being collected with the script assuming that collection is immediate which led to fallback behavior (either undocking again immediately after to try again or self-destructing).

The code you cited is handling in case docking fails.

Anyway, fix should be in a future update.

oxylos
Posts: 32
Joined: Sat, 2. Aug 08, 19:45

Re: Reason and Fix for disappearing drones on player ships

Post by oxylos » Sat, 18. Sep 21, 19:25

Thank you! That sounds like what i could observe visual but couldn't figure it in code. Thats why i was happy with the workaround.

The workaround doesn't collect solid in that case, just makes sure, that the drone goes back to the ship.

I'm not sure when the future update happens so would it be possible to get your fix here as a patch? :)

j.harshaw
EGOSOFT
EGOSOFT
Posts: 1847
Joined: Mon, 23. Nov 15, 18:02

Re: Reason and Fix for disappearing drones on player ships

Post by j.harshaw » Sat, 18. Sep 21, 19:44

in move.collect.drone, add waits after both calls to order.dock, but only if docking was successful. can verify success by either adding a 'result' attribute to the call and checking that, or checking to see if this.assignedcontrolled.dock returns anything other than null.

Code: Select all

          <run_script name="'order.dock'" result="$docked">
            <param name="destination" value="$homebase"/>
            <param name="abouttofinish" value="true"/>
            <param name="debugchance" value="$debugchance"/>
          </run_script>
          <do_if value="$docked">
            <debug_text text="'successfully docked. waiting to be collected.'" chance="$debugchance"/>
            <wait sinceversion="3"/>
          </do_if>

Killin_Kilo
Posts: 2
Joined: Mon, 10. Dec 18, 21:54
x4

Re: Reason and Fix for disappearing drones on player ships

Post by Killin_Kilo » Sun, 26. Dec 21, 19:19

j.harshaw wrote:
Sat, 18. Sep 21, 19:44
in move.collect.drone, add waits after both calls to order.dock, but only if docking was successful. can verify success by either adding a 'result' attribute to the call and checking that, or checking to see if this.assignedcontrolled.dock returns anything other than null.

Code: Select all

          <run_script name="'order.dock'" result="$docked">
            <param name="destination" value="$homebase"/>
            <param name="abouttofinish" value="true"/>
            <param name="debugchance" value="$debugchance"/>
          </run_script>
          <do_if value="$docked">
            <debug_text text="'successfully docked. waiting to be collected.'" chance="$debugchance"/>
            <wait sinceversion="3"/>
          </do_if>
Sounds like you found a good workaround to the issue that's been driving me crazy. I like mining and this bug is really game breaking for me. It sucks when randomly a drone will undock and vanish right before my eyes. I've never poked at X4 files before so I'm not even sure where to apply your fix. I assume "move.collect.drone" is a game file but I cant seem to find it to edit it. Could I trouble you for some steps to apply the workaround?

Post Reply

Return to “X4: Foundations - Scripts and Modding”