[FIX/WORKAROUND] DockAllDrones

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

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

w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16: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: 8074
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: 2963
Joined: Tue, 18. Nov 14, 16: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: 9920
Joined: Thu, 27. Feb 03, 22: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: 2963
Joined: Tue, 18. Nov 14, 16: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: 2963
Joined: Tue, 18. Nov 14, 16: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: 197
Joined: Sat, 17. Mar 12, 17: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: 2963
Joined: Tue, 18. Nov 14, 16: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: 197
Joined: Sat, 17. Mar 12, 17: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: 2963
Joined: Tue, 18. Nov 14, 16: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: 1278
Joined: Sun, 7. Dec 03, 12: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: 2963
Joined: Tue, 18. Nov 14, 16: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: 2963
Joined: Tue, 18. Nov 14, 16: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: 2963
Joined: Tue, 18. Nov 14, 16: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.

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

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

Thanks by the reply mate!

Well, good to know that i was right then. But not good news to mess with welder drones! :D

Yes, see, the problem is that with mods like Conquer_Mod/CWIR, where we have a lot of ship destruction in the war (and also stations a bit) this is very common issue. We can end with a lot of welder drones floating in space. The second problem is that the ships/station continues to target the welder drones even when the main target is being boarded what can ruin your board strategy, because these hits ends on the main target too and can destroy it before you end the board process (stations are not a problem as they have really a big hull and parts). This is a very frequent issue on big fights.

One possible workaround is just to stop to target welder drones at all (well, this will end in yet more welder drones floating around...), this is easy, but i want a more precise behavior following the same procedure that we do with all board actions: just not target an enemy object (welder drone included) if it is being boarded (or its "commander" in the welder drones case) and is being boarded by your friends and the main target hull is bellow 70. All others situations the main target and also the welder drones must be hit. Any idea?

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

Post by UniTrader » Sun, 5. Jun 16, 18:45

w.evans wrote: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.
for the regular mass trafic they have pilots, which perform "masstraffic.generic" - which is basically an endless wait unless attacked... no idea about repair drones, but i think its similiar there...



@Rubini maybe these two lines are a start - they result in the amount of drones currently repairing an Object:
<find_active_repair_mass_traffic object="$Defensible" result="$networkid" />
<get_units_in_mass_traffic masstraffic="$networkid" category="unitcategory.welder" amounts="$unitamounts" />
still no idea how to link them to a Ship though... i think it requires some changes to the vanilla scripts to make this value accessable... (i think it must be known to the pilot of the drone at least)
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 ;)

w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans » Sun, 5. Jun 16, 18:50

You could make it so that no welder drones are targeted if there's a boarding operation going on in the same zone. Or everything of class drone within a certain distance of a ship that's being boarded, or something like that. Think distance check is just a quick look up, so shouldn't hurt performance much, especially if you avoid any find_ operations by just working with objects that're already on a list.

edit: @Uni, that's what I was looking for. Remember playing around with those a while back.

I remember find_active_repair_mass_traffic does find mass traffic networks launched by an object on itself, but couldn't find mass traffic networks launched by an object onto something else. At least, I couldn't get them to end their mass traffic network via end_repair_mass_traffic. Then again, this was before 4.0, so might have been fixed by now.

But I'm getting distracted. Yes, find_active_repair_mass_traffic does find the mass traffic launched by an object onto itself, which should be the case in CWIR. Don't think that'll help with preventing them from being targeted though, since you would be able to find the mass traffic network rather than the objects in it.

get_units_in_mass_traffic should find the objects within that mass traffic network, but i think it only outputs the amounts per mk in the category you define. In the engineer script that's just used to set the adjustment to the repair rate that each welder drone contributes.

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

Post by Rubini » Sun, 5. Jun 16, 19:02

@UniTrader: the problem is that at that point i just have an list of targets and eventually a welder drone is on it, but i dont know which are its homeship. So i guess that your suggestion is not possible on this scenario. See below.

@w.evans: this is exactly what im trying. But have not tested it yet because, you know, scenarios like that is very time consuming to test. See:

Code: Select all

        <do_all counter="$i" exact="$enemies.count">
					<set_value name="$flagD" exact="100"/>
					<do_if value="$enemies.{$i}.macro.ismacro.units_size_xs_welder_drone_macro">
						<find_gravidar_contact name="$contacts" object="$enemies.{$i}" class="[class.ship_l, class.ship_xl, class.station]" functional="true"  multiple="true" >
								<match_distance object="$enemies.{$i}" max="2000m"/>
								<match_relation object="$enemies.{$i}" relation="self" />
								<match_hull max="75" />
						</find_gravidar_contact>						
						<do_all exact="$contacts.count" counter="$j">
							<do_if value="$contacts.{$j}.isoperational and @$contacts.{$j}.boarder and @this.ship.relationto.{$contacts.{$j}.boarder} ge 0 and $contacts.{$j}.hullpercentage le 70">
								<set_value name="$flagD" exact="0"/>
							</do_if>
						</do_all>
					</do_if>				
					<do_if value="(@$enemies.{$i}.boarder and @this.ship.relationto.{$enemies.{$i}.boarder} ge 0 and $enemies.{$i}.hullpercentage le 70) or not $flagD">
						<remove_value name="$enemies.{$i}" />
					</do_if>
        </do_all>
This is what i do before any futher on any target list to just put the not wanted targets of from the list.

w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans » Sun, 5. Jun 16, 19:28

Oof. Looks like it would work, but doing find_gravidar_contacts for everything in $enemies is probably going to hurt performance. Why not just work within the $enemies list? Something like:

Code: Select all

<do_all exact="$enemies.count" counter="$i" reverse="true">
  <do_if value="$enemies.{$i}.isclass.drone" negate="true">
    <continue/>
  </do_if>
  <do_elseif value="$enemies.{$i}.macro.unitcategory" exact="unitcategory.welder" negate="true">
    <continue/>
  </do_elseif>
  <do_else>
    <!-- everything that gets in here is a welder drone. -->
    <do_all exact="$enemies.count" counter="$j">
      <do_if value="$enemies.{$j}.boarder and $enemies.{$j}.isoperational and (this.ship.relationto.{$enemies.{$j}.boarder} ge 0)">
        <do_if value="$enemies.{$i}.distanceto.{$enemies.{$j}} le 2000">
          <do_if value="$enemies.{$i}.relationto.{$enemies.{$j}}" min="self">
            <do_if value="$enemies.{$j}.hullpercentage" max="75">
              <remove_value name="$enemies.{$i}"/>
              <break/>
            </do_if>
          </do_if>
        </do_if>
      </do_if>
    </do_all>
  </do_else>
</do_all>
Just wrote that into the forum interface, so no idea if it says what i hope it says. Just used the conditions you set, although trimmed out a redundant hullpercentage check since i think you already filtered that in your find_gravidar_contacts(?). Might have missed something.

Longish sequence of do_ifs can, of course, be combined into a single do_if with ands. Thought might be easier to read this way.

Post Reply

Return to “X Rebirth - Scripts and Modding”