[Request/Suggestion] Capital Mining Drone Fix

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

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

Post Reply
skunkmonkey
Posts: 6
Joined: Wed, 17. Apr 19, 15:19
x4

[Request/Suggestion] Capital Mining Drone Fix

Post by skunkmonkey » Sun, 28. Apr 19, 18:52

I'm willing to learn and make the mod myself, but i don't seem to be able to download the catalog tool to let me know what fields I need to modify. The site tells me I need to log in even though I already am obviously since you can read this post.

Currently mining drones on Capital Ships don't launch if the player is in control. They only launch if the AI is auto-mining. I believe this is caused by the fact that the drones are auto-launched whenever an ore on the auto-mine list is floating around in space, and since when the player in control the game ignores the auto-mine settings the drones never launch.

It seems like an easy hack would be to make it so that when the player is in control the drones will automatically activate if ores of ANY type are floating around in space.

skunkmonkey
Posts: 6
Joined: Wed, 17. Apr 19, 15:19
x4

Re: [Request/Suggestion] Capital Mining Drone Fix

Post by skunkmonkey » Sun, 28. Apr 19, 23:52

Well I found out how to get the catalog tool. Apparently you have to link your Steam account to your profile. The website doesn't mention that though. It just tells you that you need to be signed in to download. I only discovered this by accident from a totally different website.

I'll give it a go, and see if I can figure out how to mod this.

Moderator,
Please update the following Mod guide link to let people know that they need to register their X-series game or link their Steam profile to these boards in order to download files.
viewtopic.php?f=181&t=402452

Thanks

skunkmonkey
Posts: 6
Joined: Wed, 17. Apr 19, 15:19
x4

Re: [Request/Suggestion] Capital Mining Drone Fix

Post by skunkmonkey » Mon, 29. Apr 19, 03:36

I've got a bit of a start on the problem. My original hypothesis appears to be wrong. They just haven't implemented automated drones for player controlled ships at all. My approach now is to try to run a script every second that checks to see if the player is operating a capital ship, and if so, check if there are any ore targets floating around nearby, and if so, launch mining drones to pick them up.

Well I think I've taken this about as far as I can... which isn't very far apparently lol. I tried to take pieces of the code from the AI capital ship mining script (mining.collect.ship.capital.xml) and modify them slightly. I don't have enough information to figure out where to go from here, so I'll just leave this here in case someone more capable wants to pick up the torch.

Problems that I ran into with this script:
1. [=ERROR=] 312066.40 extensions\CapitalShipMiningDroneFix\md\PlayerOperatedCapitalMiningDrones.xml(54): Script node 'set_command_action' is not allowed in this context.
2. [=ERROR=] 312067.40 Error in MD cue md.PlayerOperatedCapitalMiningDrones.DroneCheck: Property lookup failed: this.ship
3. I was guessing at what {$ware} and {$checkware} should be. They were parameters into the AI script, but no references to that script set any parameters that I could find for reference.

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<mdscript name="PlayerOperatedCapitalMiningDrones" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="aiscripts.xsd">
	<cues>
		<cue name="DroneCheck">
            <actions>
				<!-- only launch drones if player is in a capital ship. TODO Find out how to also determine if the player is the one operating the ship, and only go into this do_if block if that's true as well -->
				<do_if value="this.ship.iscapitalship">
					<!-- TODO: set these to all ores, and create a loop through all of them once we figure out if this even works -->
					<set_value name="$ware" exact="Ore"/>
					<set_value name="$checkware" exact="Ore"/>
					
					<!-- don't launch mining drones if the cargo is full -->
					<do_if value="this.ship.cargo.{$ware}.free">
						<!-- Command action -->
						<!-- NOT ALLOWED IN THIS CONTEXT <set_command_action commandaction="commandaction.searchingresources" /> -->
						
						<!-- drones are available -->
						<do_if value="this.ship.availableunits.{unitcategory.orecollector}.count">					
							<!-- find pickup (filtered by ownership) and target -->
							<set_value name="$pickuptarget" exact="false"/>
							<find_asteroid_in_cluster name="$pickup" cluster="this.cluster" refobject="this.ship" canpickup="true" multiple="true" maxdistance="4km" viewangle="360deg" ware="$checkware" />
							<do_all exact="$pickup.count" counter="$i" reverse="true">
								<do_if value="$pickup.{$i}.owner">
									<remove_value name="$pickup.{$i}" />
								</do_if>
								<do_elseif value="not $pickup.{$i}.canbepickedup">
									<debug_text text="'%1 in %2 cannot be picked up!'.[$pickup.{$i}, $pickup.{$i}.sector.knownname]" chance="$debugchance"/>
									<remove_value name="$pickup.{$i}" />
								</do_elseif>
								<do_else>
									<remove_value name="$pickup.{$i}" />
								</do_else>
							</do_all>

							<!-- launch drone to pick up the target -->
							<do_if value="$pickup.count and this.ship.availableunits.{unitcategory.orecollector}.count">
								<set_value name="$pickuptarget" exact="$pickup.random"/>
								<set_region_object_persistence object="$pickuptarget" persistent="true" />
								<launch_drone name="$drone" object="this.ship" category="unitcategory.orecollector" exact="1"/>
								<do_if value="$drone.isoperational">
									<debug_text text="'%1 drone launched [pickup count: %2, asteroid count: %3 (%4)]'.[player.age, $pickup.count, $asteroids.count, ($asteroidhull)L]" chance="$debugchance"/>
									<start_script name="'mining.collect.drone'" object="$drone.pilot">
									<param name="homebase" value="this.ship" />
									<param name="target" value="$pickuptarget"/>
									</start_script>
									<set_owner object="$pickuptarget" faction="this.ship.owner"/>
									<!-- command action waiting drone -->
									<set_command_action commandaction="commandaction.waitingdrones" />
								</do_if>
								<do_else>
									<debug_text text="'%1 no drone available [pickup count: %2, asteroid count: %3 (%4)]'.[player.age, $pickup.count, $asteroids.count, ($asteroidhull)L]" chance="$debugchance"/>
								</do_else>
							</do_if>					
						</do_if>
					</do_if>
				</do_if>
            </actions>
           <cues>
                <cue name="DroneCheck_Reset">
                    <delay exact="1s" />
                    <actions>
                        <reset_cue cue="DroneCheck" />
                    </actions>
                </cue>
            </cues>
        </cue>
	</cues>
</mdscript>

Lazerath
Posts: 860
Joined: Tue, 22. Mar 05, 06:31
x4

Re: [Request/Suggestion] Capital Mining Drone Fix

Post by Lazerath » Thu, 30. May 19, 03:49

skunkmonkey wrote:
Mon, 29. Apr 19, 03:36
I've got a bit of a start on the problem. My original hypothesis appears to be wrong. They just haven't implemented automated drones for player controlled ships at all.
This is something that has bothered me for a long time (6 months).

This should NOT have to be fixed my a MOD. Its shameful how much stuff in the base game is still missing yet they are working on a DLC. This should be fixed by the Devs as its a broken/missing/incomplete part of the base game that is supposed to be there.

We should not have to play Modified to fix issues like this. Kudos to you though if you're able to pull it off!

Its definitely a mod I would download when I play modded!

Cheers
COMPUTER SPECS
[Mobo] SABERTOOTH 990FX R2.0
[CPU] AMD FX-9370 8 Cores 4.4 - 4.7GHZ 16MB DDR3-1866
[Cooling] Corsair Hydro Series H80I CPU Cooler System
[Video] Evga 970 GTX SC 3.5Gb Ram ==> [Ram] G-Skills Ripjaws X 16GB
[Harddrive] (2) x Samsung 850 Evo 250GB SSD
[Harddrive] Samsung 840 Series 120GB SSD ==> [Harddrive] WD BLACK 1TB 64MB 7200RPM
[Disc Player] LG 14X BLU-RAY BURNER ==> [Case] Thermaltake A71 Chaser [Windows 7 Pro]

Post Reply

Return to “X4: Foundations - Scripts and Modding”