[FIX/WORKAROUND] DockAllDrones

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

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

w.evans
Posts: 2962
Joined: Tue, 18. Nov 14, 17:23
x4

[FIX/WORKAROUND] DockAllDrones

Post by w.evans » Tue, 21. Jul 15, 09:28

Quick and dirty hack that makes all drones in the galaxy dock with their parent ships, and destroys drones whose parent ships are no longer operational.

Works best OOZ, so go to a zone where no other capital ships are present before installing this.
After this script runs, you will receive a notification in your in-game display, and in your logbook.

Please deactivate this script by:
  • deactivating it in your in-game "Extensions" menu, or
  • deleting the directory "w.e_dockalldrones" from your extensions directory.
Since drones aren't normally launched OOZ, it shouldn't cause any problems as long as no other ships are present in the same zone as the Skunk when this script is activated. However, no guarantees on this one. You use this at your own risk.

Note: While this script does appear to dock/destroy all orphaned drones in the galaxy, some of my ships are still showing drones in use. Unless something is found that says otherwise, I'm taking this to mean that in some situations, drones can be marked "in use" without actually being in space somewhere. Should help efforts to narrow down the search for anyone trying to get to the bottom of the drones in use problem. NOTE: This issue was fixed in X:R 3.60 RC1.

_____
Usage:

1. In-game, go to a zone where there are no other capital ships. (This script should not yet be installed at this point.)
2. Save the game, exit,
3. Install this script,
4. Load your save,
5. Wait for the notification (should come in around 10 seconds),
6. Save,
7. Deactivate this mod,
8. Restart the game,
9. Load

_____
Installation:

Extract to your extensions directory.

_____
Uninstallation:

Disable from your in-game extensions directory,

or

Delete the folder "w.e_dockalldrones" from your extensions directory.

_____
Compatibility:

This mod is current as of X:R 4.00
Compatible with X:R 3.61

Should be future-proof since it alters no vanilla files.

Compatible with Windows, Linux, and Mac versions of X Rebirth.

_____
Available for download:

http://www.nexusmods.com/xrebirth/mods/453

_____
Code:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<mdscript name="we_DockAllDrones" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<cues>
		<cue name="we_DockAllDrones">
			<conditions>
				<event_player_created/>
			</conditions>
			<delay min="10s"/>
			<actions>
				<create_list name="$we_FollowerDronesDocked"/>
				<create_list name="$we_LostFollowers"/>
				<create_list name="$we_LeaderDronesDocked"/>
				<create_list name="$we_LostNonFollowers"/>
				<create_list name="$we_LostWelders"/>
				<create_list name="$we_LostCargoLifters"/>
				<create_list name="$we_OtherLostMassTraffic"/>
				<create_list name="$we_WorkingMassTraffic"/>

				<find_ship name="$we_EverySingleVerySmallShip" multiple="true" space="player.galaxy" class="[class.drone, class.ship_xs]" recursive="true"/>

				<write_to_logbook category="tips" text="'Drone reset script active. \n\n Preliminary search. \n %1 ships found.'.[$we_EverySingleVerySmallShip.count]"/>

				<do_all exact="$we_EverySingleVerySmallShip.count" counter="$i">

					<!-- Followers first.  Set drones following other drones to dock with their mother ship if it's still intact.  Otherwise, goodbye. -->
					<do_if value="$we_EverySingleVerySmallShip.{$i}.commander.isclass.drone or $we_EverySingleVerySmallShip.{$i}.commander.isclass.ship_xs">
						<do_if value="$we_EverySingleVerySmallShip.{$i}.commander.commander.isoperational">
							<!--<write_to_logbook category="tips" text="'%1 sent to dock with %2.'.[$we_EverySingleVerySmallShip.{$i}.knownname, $we_EverySingleVerySmallShip.{$i}.commander.commander.knownname]"/>-->
							<append_to_list name="$we_FollowerDronesDocked" exact="$we_EverySingleVerySmallShip.{$i}"/>
							<abort_scripts entity="$we_EverySingleVerySmallShip.{$i}.controlentity"/>
							<set_object_commander object="$we_EverySingleVerySmallShip.{$i}" commander="$we_EverySingleVerySmallShip.{$i}.commander.commander"/>
							<dock_drone homebase="$we_EverySingleVerySmallShip.{$i}.commander" object="$we_EverySingleVerySmallShip.{$i}"/>
						</do_if>
						<do_else>
							<!--<write_to_logbook category="tips" text="'%1 destroyed. LOST FOLLOWERS'.[$we_EverySingleVerySmallShip.{$i}.knownname]"/>-->
							<append_to_list name="$we_LostFollowers" exact="$we_EverySingleVerySmallShip.{$i}"/>
							<destroy_object object="$we_EverySingleVerySmallShip.{$i}"/>
						</do_else>
					</do_if>

					<!-- Leaders last.  Set drones following other drones to dock with their mother ship if it's still intact.  Otherwise, goodbye. -->
					<do_else>
						<do_if value="$we_EverySingleVerySmallShip.{$i}.ismasstraffic" negate="true">
							<do_if value="$we_EverySingleVerySmallShip.{$i}.commander.isoperational or $we_EverySingleVerySmallShip.{$i}.dronecommander.isoperational">
								<!--<do_if value="$we_EverySingleVerySmallShip.{$i}.commander">
									<write_to_logbook category="tips" text="'%1 sent to dock with %2.'.[$we_EverySingleVerySmallShip.{$i}.knownname, $we_EverySingleVerySmallShip.{$i}.commander.knownname]"/>
								</do_if>
								<do_else>
									<write_to_logbook category="tips" text="'%1 sent to dock with %2.'.[$we_EverySingleVerySmallShip.{$i}.knownname, $we_EverySingleVerySmallShip.{$i}.dronecommander.knownname]"/>
								</do_else>-->
								<append_to_list name="$we_LeaderDronesDocked" exact="$we_EverySingleVerySmallShip.{$i}"/>
								<abort_scripts entity="$we_EverySingleVerySmallShip.{$i}.controlentity"/>
								<dock_drone homebase="$we_EverySingleVerySmallShip.{$i}.commander" object="$we_EverySingleVerySmallShip.{$i}"/>
							</do_if>
							<do_else>
								<!--<write_to_logbook category="tips" text="'%1 destroyed. LOST NON-FOLLOWERS'.[$we_EverySingleVerySmallShip.{$i}.knownname]"/>-->
								<append_to_list name="$we_LostNonFollowers" exact="$we_EverySingleVerySmallShip.{$i}"/>
								<destroy_object object="$we_EverySingleVerySmallShip.{$i}"/>
							</do_else>
						</do_if>
						<!-- can probably remove this. to do: verify that $we_LostMassTraffic is always empty.
							nope. looks like there are mass traffic objects that don't have a commander.
								normal mass traffic does, since they're docked above,
									so these are likely candidates as lost welder drones and cargolifters. -->
						<do_elseif value="$we_EverySingleVerySmallShip.{$i}.commander.isoperational or $we_EverySingleVerySmallShip.{$i}.dronecommander.isoperational" negate="true">
							<do_if value="$we_EverySingleVerySmallShip.{$i}.unitcategory" exact="unitcategory.welder">
								<!--<write_to_logbook category="tips" text="'%1 destroyed. LOST WELDERS'.[$we_EverySingleVerySmallShip.{$i}.knownname]"/>-->
								<append_to_list name="$we_LostWelders" exact="$we_EverySingleVerySmallShip.{$i}"/>
								<destroy_object object="$we_EverySingleVerySmallShip.{$i}"/>
							</do_if>
							<do_elseif value="$we_EverySingleVerySmallShip.{$i}.unitcategory" exact="unitcategory.transport">
								<!--<write_to_logbook category="tips" text="'%1 destroyed. LOST CARGOLIFTERS'.[$we_EverySingleVerySmallShip.{$i}.knownname]"/>-->
								<append_to_list name="$we_LostCargoLifters" exact="$we_EverySingleVerySmallShip.{$i}"/>
								<destroy_object object="$we_EverySingleVerySmallShip.{$i}"/>
							</do_elseif>
							<do_else>
								<!--<write_to_logbook category="tips" text="'%1 destroyed. LOST OTHER MASSTRAFFIC'.[$we_EverySingleVerySmallShip.{$i}.knownname]"/>-->
								<append_to_list name="$we_OtherLostMassTraffic" exact="$we_EverySingleVerySmallShip.{$i}"/>
								<destroy_object object="$we_EverySingleVerySmallShip.{$i}"/>
							</do_else>
						</do_elseif>
						<do_else>
							<append_to_list name="$we_WorkingMassTraffic" exact="$we_EverySingleVerySmallShip.{$i}"/>
						</do_else>
					</do_else>
				</do_all>

				<show_notification caption="'=== DRONE RESET ==='" details="'Drone reset script completed. \n\n %1 leader drones heading home. \n %2 follower drones heading home. \n %3 lost follower drones found and destroyed. \n %4 lost non-follower drones found and destroyed. \n %5 lost Construction URVs found and destroyed. \n %6 lost CargoLifters found and destroyed. \n %7 other lost mass traffic xs ships and drones found and destroyed. \n\n %8 mass traffic drones are working and have been left alone.'.[$we_LeaderDronesDocked.count, $we_FollowerDronesDocked.count, $we_LostFollowers.count, $we_LostNonFollowers.count, $we_LostWelders.count, $we_LostCargoLifters.count, $we_OtherLostMassTraffic.count, $we_WorkingMassTraffic.count]" queued="false" priority="9"/>
				<write_to_logbook category="tips" text="'Drone reset script completed. \n\n %1 leader drones heading home. \n %2 follower drones heading home. \n %3 lost follower drones found and destroyed. \n %4 lost non-follower drones found and destroyed. \n %5 lost Construction URVs found and destroyed. \n %6 lost CargoLifters found and destroyed. \n %7 other lost mass traffic xs ships and drones found and destroyed. \n\n %8 mass traffic drones are working and have been left alone.'.[$we_LeaderDronesDocked.count, $we_FollowerDronesDocked.count, $we_LostFollowers.count, $we_LostNonFollowers.count, $we_LostWelders.count, $we_LostCargoLifters.count, $we_OtherLostMassTraffic.count, $we_WorkingMassTraffic.count]"/>

				<remove_value name="$we_EverySingleVerySmallShip"/>
				<remove_value name="$we_FollowerDronesDocked"/>
				<remove_value name="$we_LostFollowers"/>
				<remove_value name="$we_LeaderDronesDocked"/>
				<remove_value name="$we_LostNonFollowers"/>
				<remove_value name="$we_LostWelders"/>
				<remove_value name="$we_LostCargoLifters"/>
				<remove_value name="$we_OtherLostMassTraffic"/>
				<remove_value name="$we_WorkingMassTraffic"/>

				<reset_cue cue="this" />
			</actions>
		</cue>
	</cues>
</mdscript>
_____
Check out my other mods for X Rebirth:
MarineRebalance,
BetterAutoAim
SmalltalkHack,
Epic Capital Ship Shields,
Station Engineers,
Engineer Drone Fix,
Slightly More Useful Plot Station,
Miscellaneous IZ Combat Tweaks,
Miscellaneous OOZ Combat Tweaks,
DifficultyHack
Last edited by w.evans on Sat, 11. Jun 16, 13:19, edited 9 times in total.

Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 7519
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp » Tue, 21. Jul 15, 09:35

Nice idea. I guess a temp zone away from normal traffic could work well.

w.evans
Posts: 2962
Joined: Tue, 18. Nov 14, 17:23
x4

Post by w.evans » Tue, 21. Jul 15, 16:46

Sparky Sparkycorp wrote:Nice idea. I guess a temp zone away from normal traffic could work well.
Yup, or one of those deserted zones in DeVries.

A couple of updates up, both bugfixes due to sloppy work. For those of you who have already run the script, should be fine. Changes were just to make sure that any scripts running on the orphaned drones are aborted before they're docked, but should be unnecessary because drones cease to be drones anyway when they're docked. (They turn into the drone ware, and the previous drone ship is removed completely.)

Also added this to the OP:

Note: While this script does appear to dock/destroy all orphaned drones in the galaxy, some of my ships are still showing drones in use. Unless something is found that says otherwise, I'm taking this to mean that in some situations, drones can be marked "in use" without actually being in space somewhere. Should help efforts to narrow down the search for anyone trying to get to the bottom of the drones in use problem.

Scoob
Posts: 6685
Joined: Thu, 27. Feb 03, 23:28
x4

Post by Scoob » Tue, 21. Jul 15, 17:43

Hi,

One of my biggest issues, affecting most, but not all of my ships, is drones that are showing as "In Use" but were actually destroyed in combat. The issue with this is I'd have say 20 drones, 10 showing as "In Use" (destroyed), I'd SELL all 20 drones successfully - which is a bug in its self - however, any drones of the same type I loaded on the ship in future - either buying or via transfer - the first 10 would always be "In Use".

This and a number of other bugs basically rendered my long-term game somewhat frustrating, especially as I'd invested in Drone Production for my Fleet, and my ships steadily got clogged up with destroyed drones, listed as "In Use".

No worries if this isn't part of what you're intended to address, just thought I'd put it out there for your consideration :)

Scoob.

w.evans
Posts: 2962
Joined: Tue, 18. Nov 14, 17:23
x4

Post by w.evans » Tue, 21. Jul 15, 18:06

Hi Scoob,

That is very useful, thanks!

This was prompted by frustration over seeing drones in use when no visible drones were present (not addressed yet), but the tipping point was seeing them actually floating in space doing nothing (this is addressed). Positive confirmation that it might have something to do with drones being destroyed, but not being marked as such, should help narrow the search.

w.evans
Posts: 2962
Joined: Tue, 18. Nov 14, 17:23
x4

Post by w.evans » Sat, 25. Jul 15, 01:42

Oh cool! With this fix from 3.60 RC1:
changelog wrote:• RC 1 Fixed drone units being marked as "in use" even if launching them failed.
All of my drones are back! Thanks, Ego!

kelmenwong
Posts: 195
Joined: Sat, 17. Mar 12, 18:40
x3tc

Post by kelmenwong » Sat, 25. Jul 15, 03:43

recently i add in 2 mods, include this one.

my skunk drones keep vanished, even if i restock them

not sure if it is by this mod, or the other (Conquest and War in Rebirth)

now trying to disabled this to see if problem persist.

w.evans
Posts: 2962
Joined: Tue, 18. Nov 14, 17:23
x4

Post by w.evans » Sat, 25. Jul 15, 04:24

crap! Thanks! Didn't even notice until you pointed it out.

Fixed in v0.04

kelmenwong
Posts: 195
Joined: Sat, 17. Mar 12, 18:40
x3tc

Post by kelmenwong » Wed, 29. Jul 15, 15:24

can this fix "waiting for drones"?

i of my construction vessel captain stuck on this, while the other ship already went on doing other stuffs.

there is no drone-in-use in this case though.

w.evans
Posts: 2962
Joined: Tue, 18. Nov 14, 17:23
x4

Post by w.evans » Wed, 29. Jul 15, 17:08

kelmenwong wrote:can this fix "waiting for drones"?

i of my construction vessel captain stuck on this, while the other ship already went on doing other stuffs.

there is no drone-in-use in this case though.
Hey kelmenwong,

Nope, this won't directly affect capital ships. However, please make sure that there are no capital ships in zone when you use this. I haven't actually seen it do anything bad, but some capship scripts might expect drones to be deployed IZ, and this might break that.

swatti
Posts: 1255
Joined: Sun, 7. Dec 03, 13:03
x4

Post by swatti » Thu, 30. Jul 15, 18:52

REQ: Destroy ALL combat-drones or drones currently OUTSIDE their ship, or just ALL combat drones alltogether with a menu-command.

* Evil laughter *

Is that even possible?
I'd exclude constructor and cargo-drones as they rarely cause issues.

w.evans
Posts: 2962
Joined: Tue, 18. Nov 14, 17:23
x4

Post by w.evans » Thu, 30. Jul 15, 19:34

swatti wrote:REQ: Destroy ALL combat-drones or drones currently OUTSIDE their ship, or just ALL combat drones alltogether with a menu-command.

* Evil laughter *

Is that even possible?
I'd exclude constructor and cargo-drones as they rarely cause issues.
Yup.

Code: Select all

<find_ship name="$Drone_Armageddon" multiple="true" space="player.galaxy">
	<match class="class.drone"/>
	<match group="unitcategory.defence"/>
</find_ship>
<do_all exact="$Drone_Armageddon.count" counter="$i">
	<destroy_object object="$Drone_Armageddon.{$i}"/>
</do_all>
will destroy all combat drones everywhere.

An early version of this destroyed every single ship everywhere except for the Skunk.

Code: Select all

<find_ship name="$EverySingleShip" multiple="true" space="player.galaxy"/>
<do_all exact="$EverySingleShip.count" counter="$i">
	<do_if value="$EverySingleShip.{$i} == player.primaryship">
		<continue/>
	</do_if>
	</do_else>
		<destroy_object object="$EverySingleShip.{$i}"/>
	</do_else>
</do_all>
Very first version destroyed everything.

w.evans
Posts: 2962
Joined: Tue, 18. Nov 14, 17:23
x4

Post by w.evans » Mon, 10. Aug 15, 15:26

DockAllDrones updated to v0.05. Bugfix.

A variable that was incorrectly formatted was causing harmless, but irritating debug spew. Fixed.

Rubini
Posts: 452
Joined: Mon, 7. May 07, 05:17
xr

Post by Rubini » Sun, 5. Jun 16, 17:18

Hi w.evans,

Thanks by this mod/fix...i have a question...
Perhaps this could go to MICT thread but it also fits here.
I was messing a bit with welder drones and noticed that they dont have a commander. I mean, for example, $welder_drone.{i}.commander is always null even in zone and seing them there repairing a ship. Seems that they are handler as a masstraffic object by the code and dont really have a commander. Do you have noticed this too? If so, then how we can now if a welder drone is orfan? And also any idea on how we can know who is their home ship (as they dont have a commander) for suppress fire to them (welder drones) if their home ship is being boarded? Any idea?

Cheers!
Rubini.

w.evans
Posts: 2962
Joined: Tue, 18. Nov 14, 17:23
x4

Post by w.evans » Sun, 5. Jun 16, 17:57

Hi Rubini,

yes, you're right. They are deployed as part of a ship's mass traffic network rather than as individual objects flown by entities subordinate to a commander. Come to think of it, I don't know if they even have entities. Found that they are difficult (haven't found a way yet) to find if, say, deployed by one ship onto another. It is, however, possible to find and manipulate (to an extent) a mass traffic network deployed around an object by itself.

As such, this mod won't work in docking them, but would probably ignore them since their commanders would come out null.

That said, they shouldn't orphan unless their commander gets destroyed or a mass traffic network breaks down somehow.

Do they? Think the only ones I've found were orphaned by their home ship being destroyed.

Post Reply

Return to “X Rebirth - Scripts and Modding”