<do_if value="not lib.units.combat?">

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

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

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

Post by w.evans » Mon, 3. Aug 15, 11:42

Update:

Code: Select all

<do_if value="(this.station.trueowner != faction.player) or @this.$config_unitstorage_automatic">
	<do_if value="this.station.units.count lt this.station.units.maxcount">
		<do_if value="this.station.cargo.{ware.drp_interceptor_mk1}.count gt 0">

			<add_units object="this.station" macro="macro.units_size_drone_attackdrone_impulse_mk1_macro" exact="this.station.cargo.{ware.drp_interceptor_mk1}.count"/>
			<remove_cargo object="this.station" ware="ware.drp_interceptor_mk1" exact="this.station.cargo.{ware.drp_interceptor_mk1}.count"/>

			<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n has acquired %2 drones. \n Taking out of storage.'.[this.station.knownname, this.station.cargo.{ware.drp_interceptor_mk1}.count]" queued="false" priority="9"/>
			<write_to_logbook category="tips" text="'%1 \n has acquired %2 drones. \n Taking out of storage.'.[this.station.knownname, this.station.cargo.{ware.drp_interceptor_mk1}.count]"/>
		</do_if>

		<set_value name="$MICT_StDrTradeFreeCapacity" exact="this.station.units.maxcount - this.station.units.count"/>
		<set_value name="$MICT_StDrTradeWare" exact="ware.drp_interceptor_mk1"/>
		<set_value name="$MICT_StDrTradePrice" exact="ware.drp_interceptor_mk1.averageprice"/>

		<find_buy_offer buyer="this.station" wares="$MICT_StDrTradeWare" result="$MICT_StDrTradeOfferMult" excludeempty="false" multiple="true"/>

		<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n Looking for existing trade offers for %2 \n NODE 1'.[this.station.knownname, $MICT_StDrTradeWare, $MICT_StDrTradeFreeCapacity, $MICT_StDrTradePrice / 100]" queued="false" priority="1"/>
		<write_to_logbook category="tips" text="'%1 \n Looking for existing trade offers for %2 \n NODE 1'.[this.station.knownname, $MICT_StDrTradeWare, $MICT_StDrTradeFreeCapacity, $MICT_StDrTradePrice / 100]"/>

		<do_if value="$MICT_StDrTradeOfferMult.count ge 1">
			<do_all exact="$MICT_StDrTradeOfferMult.count" counter="$i">
				<set_value name="$MICT_StDrTradeOffer" exact="$MICT_StDrTradeOfferMult.{$i}"/>

				<update_trade trade="$MICT_StDrTradeOffer" amount="$MICT_StDrTradeFreeCapacity" desiredamount="$MICT_StDrTradeFreeCapacity" unbundle="true"/>

				<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n Updating trade offer for %2 \n Now wants %3 units. \n NODE 2'.[this.station.knownname, $MICT_StDrTradeWare, $MICT_StDrTradeFreeCapacity, $MICT_StDrTradePrice / 100]" queued="false" priority="1"/>
				<write_to_logbook category="tips" text="'%1 \n Updating trade offer for %2 \n Now wants %3 units. \n NODE 2'.[this.station.knownname, $MICT_StDrTradeWare, $MICT_StDrTradeFreeCapacity, $MICT_StDrTradePrice / 100]"/>
			</do_all>
		</do_if>
		<do_elseif value="this.station.trueowner == faction.player">

			<create_trade_offer amount="$MICT_StDrTradeFreeCapacity" buyer="this.station" object="this.station" name="$MICT_StDrTrade" ware="$MICT_StDrTradeWare" price="$MICT_StDrTradePrice" unbundle="true" playeronly="false" />

			<show_notification caption="'=== MICT Drone Project ==='" details="'%1 placed an order for \n %2 units of %3 \n at %4Cr per unit. \n NODE 3'.[this.station.knownname, $MICT_StDrTradeFreeCapacity, $MICT_StDrTradeWare, $MICT_StDrTradePrice / 100]" queued="false" priority="1"/>
			<write_to_logbook category="tips" text="'%1 placed an order for \n %2 units of %3 \n at %4Cr per unit. \n NODE 3'.[this.station.knownname, $MICT_StDrTradeFreeCapacity, $MICT_StDrTradeWare, $MICT_StDrTradePrice / 100]"/>
		</do_elseif>
		<do_else>

			<add_tradeware ware="$MICT_StDrTradeWare" object="this.station" allowbuy="true"/>

			<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n Now trading in %2. \n NODE 4'.[this.station.knownname, $MICT_StDrTradeWare, $MICT_StDrTradeFreeCapacity, $MICT_StDrTradePrice / 100]" queued="false" priority="1"/>
			<write_to_logbook category="tips" text="'%1 \n Now trading in %2. \n NODE 4'.[this.station.knownname, $MICT_StDrTradeWare, $MICT_StDrTradeFreeCapacity, $MICT_StDrTradePrice / 100]"/>
		</do_else>
	</do_if>
</do_if>
And I think that the structure's sound now. Next to add the capability to deal with multiple drone types. Fixed proportion for now.

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

Post by Sparky Sparkycorp » Mon, 3. Aug 15, 11:48

Nice one 8)

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

Post by w.evans » Mon, 3. Aug 15, 11:55

Hey Sparks!

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

Post by Sparky Sparkycorp » Mon, 3. Aug 15, 12:11

Hi! Don't mind me, just lurking around :)

I just completed the vanilla 3.60 RC2 plot attack on the Beryl station. It's pretty intense and like before, I expect adding a few additional drones to the mix (many already fly around from hostile capitals) shouldn't change the dynamics substantially. A potentially harder rather than different challenge.

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

Post by w.evans » Mon, 3. Aug 15, 12:23

Sparky Sparkycorp wrote:Hi! Don't mind me, just lurking around :)

I just completed the vanilla 3.60 RC2 plot attack on the Beryl station. It's pretty intense and like before, I expect adding a few additional drones to the mix (many already fly around from hostile capitals) shouldn't change the dynamics substantially. A potentially harder rather than different challenge.
Cool! Yeah, was fun with lots of drones flying, although my poor laptop's fps was brought down to single digits. Was worth the spectacle, I thought, especially if you strategically planned it to happen that way.

You could help with this, too. Questions, suggestions, and clarifications welcome. Code's a foreign language, but logic's logic.

Right now, trying to get stations to only fill up to a certain proportion of max capacity.

Want to fill stations with combat drones up to maximum drone capacity - 100 (100 should be a generous reserve space for cargolifters, construction URVs and anything else that the player wants the station to equip).
And want 40% of that space to be filled with Interceptor URVs Mk1.

So:

Code: Select all

<set_value name="$MICT_StDrTradeFillAmount" exact="this.station.units.maxcount - 100"/>
<set_value name="$MICT_StDrTradeProp" exact="0.4f"/>
And the station should then trade up to "$MICT_StDrTradeFillAmount * $MICT_StDrTradeProp"

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

Post by Sparky Sparkycorp » Mon, 3. Aug 15, 12:37

w.evans wrote: You could help with this, too. Questions, suggestions, and clarifications welcome. Code's a foreign language, but logic's logic.
Thanks :)
w.evans wrote: (100 should be a generous reserve space for cargolifters, construction URVs and anything else that the player wants the station to equip).
Oooh, this gives me two thoughts.

1. Are we talking only about a space allocation for drones used by the station, or also drones it might be selling? Probably the former but just checking.

2. IIRC, there is a Dev-acknowledged issue/bug with mining ships assigned to stations (they cannot be restricted to a single sector*). How does the idea of having stations harvest material from their zone's using their own mining drones? Might that be possible? Hopefully it would be less efficient (more time travelling) as a balance vs ships. Maybe OOZ would need tweaking if travelling to ore isn't needed. Probably an entire pallet of cans of worms if there are issues getting the to mine different materials without filling a station :)


*Particularly annoying in the plot since instead of using Glaring Truth ore to fuel the plot station's Steel Forge, I've had two M miners decide it would be a good idea to go off to get killed by Reivers in Heartache Mist (Barren Heart). I wouldn't mind using the manual "Mine here" order but the plot regularly takes you away from Glaring Truth by the time the Steel Refinery is built.

User avatar
Marvin Martian
Posts: 3053
Joined: Sun, 8. Apr 12, 09:40
x4

Post by Marvin Martian » Mon, 3. Aug 15, 12:44

w.evans wrote:Want to fill stations with combat drones up to maximum drone capacity - 100 (100 should be a generous reserve space for cargolifters, construction URVs and anything else that the player wants the station to equip).
some stations can only have 80 drones over all

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

Post by w.evans » Mon, 3. Aug 15, 12:56

Sparky Sparkycorp wrote:1. Are we talking only about a space allocation for drones used by the station, or also drones it might be selling? Probably the former but just checking.
Just equipped drone capacity for now. Drone horse-trading's a whole other can of worms! (Have to deal with things like price and supply and demand, unless <add_tradeware/> handles that adequately.)
Sparky Sparkycorp wrote:2. IIRC, there is a Dev-acknowledged issue/bug with mining ships assigned to stations (they cannot be restricted to a single sector*). How does the idea of having stations harvest material from their zone's using their own mining drones? Might that be possible? Hopefully it would be less efficient (more time travelling) as a balance vs ships. Maybe OOZ would need tweaking if travelling to ore isn't needed. Probably an entire pallet of cans of worms if there are issues getting the to mine different materials without filling a station :)
I remember reading somewhere that it used to be possible to just equip mining drones on to stations and, if the station is in a zone where the resource is present, the station will mine for itself. Never tried it, though, so don't know if it was ever true, nor if it still is.
Sparky Sparkycorp wrote:*Particularly annoying in the plot since instead of using Glaring Truth ore to fuel the plot station's Steel Forge, I've had two M miners decide it would be a good idea to go off to get killed by Reivers in Heartache Mist (Barren Heart). I wouldn't mind using the manual "Mine here" order but the plot regularly takes you away from Glaring Truth by the time the Steel Refinery is built.
That's funny. My plot station's in Forty-Two, and my station-based miner happily stays put unless it needs to go to Crimson Rocks for Crystal. Never does, though, since I have a YAT miner there.
Der König von Mars wrote:some stations can only have 80 drones over all
Yup, presently working with my increased-station-drone-capacity tweak, so they could have a minimum of 160. Should work with non-tweaked station drone capacities, though. Just added in the <remove_trade_offer/> and <remove_tradeware/> stuff that should just remove the order if they don't need any drones, IF I got the math and the logic right.

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

Post by w.evans » Mon, 3. Aug 15, 13:54

Update:

Code: Select all

<do_if value="(this.station.trueowner != faction.player) or @this.$config_unitstorage_automatic">
	<do_if value="this.station.units.count lt this.station.units.maxcount">
		<set_value name="$MICT_StDrTradeFillAmount" exact="this.station.units.maxcount - 100"/>
		<set_value name="$MICT_StDrTradeWareTypeMult" exact="[ware.drp_interceptor_mk1, ware.drp_intrepid_mk1, ware.drp_overrun_mk1, ware.drp_interceptor_mk2, ware.drp_intrepid_mk2, ware.drp_overrun_mk2]"/>
		<set_value name="$MICT_StDrTradeMacroMult" exact="[macro.units_size_drone_attackdrone_impulse_mk1_macro, macro.units_size_drone_attackdrone_plasma_mk1_macro, macro.units_size_drone_missiledrone_dumbfire_mk1_macro, macro.units_size_drone_attackdrone_impulse_mk2_macro, macro.units_size_drone_attackdrone_plasma_mk2_macro, macro.units_size_drone_missiledrone_dumbfire_mk2_macro]"/>
		<set_value name="$MICT_StDrTradePropMult" exact="[0.4f, 0.2f, 0.1f, 0.1f, 0.1f, 0.1f]"/>

		<do_all exact="$MICT_StDrTradeWareTypeMult.count" counter="$MICT_StDrTrCounter">
			<set_value name="$MICT_StDrTradeWare" exact="$MICT_StDrTradeWareTypeMult.{$MICT_StDrTrCounter}"/>
			<set_value name="$MICT_StDrTradeMacro" exact="$MICT_StDrTradeMacroMult.{$MICT_StDrTrCounter}"/>
			<set_value name="$MICT_StDrTradeProp" exact="$MICT_StDrTradePropMult.{$MICT_StDrTrCounter}"/>
			<set_value name="$MICT_StDrTradeCurrent" exact="this.station.units.{$MICT_StDrTradeMacro}.count"/>
			<set_value name="$MICT_StDrTradeAmount" exact="($MICT_StDrTradeFillAmount * $MICT_StDrTradeProp) - $MICT_StDrTradeCurrent"/>
			<set_value name="$MICT_StDrTradePrice" exact="$MICT_StDrTradeWare.averageprice"/>

			<do_if value="this.station.cargo.{$MICT_StDrTradeWare}.count gt 0">
				<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %3 \n has acquired %2 drones. \n Taking out of storage.'.[this.station.knownname, this.station.cargo.{$MICT_StDrTradeWare}.count, this.zone.knownname]" queued="false" priority="9"/>
				<write_to_logbook category="tips" text="'%1 \n in %3 \n has acquired %2 drones. \n Taking out of storage.'.[this.station.knownname, this.station.cargo.{$MICT_StDrTradeWare}.count, this.zone.knownname]"/>

				<add_units object="this.station" macro="$MICT_StDrTradeMacro" exact="this.station.cargo.{$MICT_StDrTradeWare}.count"/>
				<remove_cargo object="this.station" ware="$MICT_StDrTradeWare" exact="this.station.cargo.{$MICT_StDrTradeWare}.count"/>
			</do_if>

			<find_buy_offer buyer="this.station" wares="$MICT_StDrTradeWare" result="$MICT_StDrTradeOfferMult" excludeempty="false" multiple="true"/>

			<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %3 \n Looking for existing trade offers for %2 \n NODE 1'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]" queued="false" priority="1"/>
			<write_to_logbook category="tips" text="'%1 \n in %3 \n Looking for existing trade offers for %2 \n NODE 1'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]"/>

			<do_if value="$MICT_StDrTradeOfferMult.count ge 1">
				<do_all exact="$MICT_StDrTradeOfferMult.count" counter="$i">
					<do_if value="$MICT_StDrTradeAmount le 0 and $MICT_StDrTradeOffer?">
						<remove_trade_offer object="this.station" tradeoffer="$MICT_StDrTradeOffer"/>

						<do_if value="this.station.trueowner != faction.player">
							<remove_tradeware object="this.station" ware="$MICT_StDrTradeWare"/>
						</do_if>

						<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %3 \n Has enough %2.\n Removing trade offer. \n NODE 2.1'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]" queued="false" priority="1"/>
						<write_to_logbook category="tips" text="'%1 \n in %3 in %3\n Updating trade offer.\n Has enough %2. \n Removing trade offer. \n NODE 2.1'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]"/>
					</do_if>
					<do_else>
						<set_value name="$MICT_StDrTradeOffer" exact="$MICT_StDrTradeOfferMult.{$i}"/>

						<update_trade trade="$MICT_StDrTradeOffer" amount="$MICT_StDrTradeAmount" desiredamount="$MICT_StDrTradeAmount" price="$MICT_StDrTradePrice"/>

						<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %5 \n Updating trade offer.\n Now wants %2 units of %3 \n at %4Cr per unit. \n NODE 2.2'.[this.station.knownname, $MICT_StDrTradeAmount, $MICT_StDrTradeWare, $MICT_StDrTradePrice / 100, this.zone.knownname]" queued="false" priority="1"/>
						<write_to_logbook category="tips" text="'%1 \n in %5 \n Updating trade offer.\n Now wants %2 units of %3 \n at %4Cr per unit. \n NODE 2.2'.[this.station.knownname, $MICT_StDrTradeAmount, $MICT_StDrTradeWare, $MICT_StDrTradePrice / 100, this.zone.knownname]"/>
					</do_else>
				</do_all>
			</do_if>
			<do_elseif value="this.station.trueowner == faction.player">
				<create_trade_offer amount="$MICT_StDrTradeAmount" buyer="this.station" object="this.station" name="$MICT_StDrTrade" ware="$MICT_StDrTradeWare" price="$MICT_StDrTradePrice" unbundle="true" playeronly="false" />

				<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %5 \n placed an order for %2 units of %3 \n at %4Cr per unit. \n NODE 3'.[this.station.knownname, $MICT_StDrTradeAmount, $MICT_StDrTradeWare, $MICT_StDrTradePrice / 100, this.zone.knownname]" queued="false" priority="1"/>
				<write_to_logbook category="tips" text="'%1 \n in %5 \n placed an order for %2 units of %3 \n at %4Cr per unit. \n NODE 3'.[this.station.knownname, $MICT_StDrTradeAmount, $MICT_StDrTradeWare, $MICT_StDrTradePrice / 100, this.zone.knownname]"/>
			</do_elseif>
			<do_else>
				<add_tradeware ware="$MICT_StDrTradeWare" object="this.station" allowbuy="true"/>

				<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %3 \n Now trading in %2. \n NODE 4'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]" queued="false" priority="1"/>
				<write_to_logbook category="tips" text="'%1 \n in %3 \n Now trading in %2. \n NODE 4'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]"/>
			</do_else>
		</do_all>
	</do_if>
	<!--<do_if value="this.station.units.maxcount">
		<do_if value="((this.station.units.count)f / (this.station.units.maxcount - 100)) lt 0.8f">
			<run_script name="'MICT.lib.units.station'" sinceversion="4"/>
		</do_if>
	</do_if>-->
</do_if>
Working. Proportions are currently fixed at:

40%, 20%, 10%, 10%, 10%, and 10%
for interceptor mk1, intrepid mk1, overrun mk1, interceptor mk2, intrepid mk2, and overrun mk2

respectively, with prices fixed at average.

Long-term testing now.

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

Post by w.evans » Mon, 3. Aug 15, 14:30

Heh.

this.station.units.{$macro}.count

resolves null.

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

Post by w.evans » Mon, 3. Aug 15, 15:13

And this:

Code: Select all

<create_list name="$MICT_StDrTradeCurrentList"/>
<do_all exact="this.station.units.{unitcategory.defence}.count" counter="$i">
	<do_if value="this.station.units.{unitcategory.defence}.{$i}.ismacro.{$MICT_StDrTradeMacro}">
		<append_to_list name="$MICT_StDrTradeCurrentList" exact="this.station.units.{unitcategory.defence}.{$i}"/>
	</do_if>
</do_all>
<set_value name="$MICT_StDrTradeCurrent" exact="$MICT_StDrTradeCurrentList.count"/>
<remove_value name="$MICT_StDrTradeCurrentList"/>
doesn't work.

Need a break. :headbang:

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

Post by w.evans » Mon, 3. Aug 15, 15:46

Woohoo! This works:

Code: Select all

<create_list name="$MICT_StDrTradeCurrentList"/>
<do_all exact="this.station.units.{unitcategory.defence}.list.count" counter="$i">
	<do_if value="this.station.units.{unitcategory.defence}.list.{$i}.ismacro.{$MICT_StDrTradeMacro}">
		<append_to_list name="$MICT_StDrTradeCurrentList" exact="this.station.units.list.{$i}"/>
	</do_if>
</do_all>
<set_value name="$MICT_StDrTradeCurrent" exact="$MICT_StDrTradeCurrentList.count"/>
<remove_value name="$MICT_StDrTradeCurrentList"/>
Back in business! Except I need a smoke. Back in business in 5 minutes.

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

Post by w.evans » Mon, 3. Aug 15, 16:18

And, that's it. Added a short, slightly randomized, wait to descynchronize the scripts since the engine kind of hiccups when it runs, because it seems like every station in the galaxy runs it almost simultaneously. Also cleaned up all of the used variables.

Code: Select all

<do_if value="(this.station.trueowner != faction.player) or @this.$config_unitstorage_automatic">
	<do_if value="this.station.units.count lt (this.station.units.maxcount - 100)">
		<set_value name="$MICT_StDrTradeFillAmount" exact="this.station.units.maxcount - 100"/>
		<set_value name="$MICT_StDrTradeWareTypeMult" exact="[ware.drp_interceptor_mk1, ware.drp_intrepid_mk1, ware.drp_overrun_mk1, ware.drp_interceptor_mk2, ware.drp_intrepid_mk2, ware.drp_overrun_mk2]"/>
		<set_value name="$MICT_StDrTradeMacroMult" exact="[macro.units_size_drone_attackdrone_impulse_mk1_macro, macro.units_size_drone_attackdrone_plasma_mk1_macro, macro.units_size_drone_missiledrone_dumbfire_mk1_macro, macro.units_size_drone_attackdrone_impulse_mk2_macro, macro.units_size_drone_attackdrone_plasma_mk2_macro, macro.units_size_drone_missiledrone_dumbfire_mk2_macro]"/>
		<set_value name="$MICT_StDrTradePropMult" exact="[0.4f, 0.2f, 0.1f, 0.1f, 0.1f, 0.1f]"/>

		<do_all exact="$MICT_StDrTradeWareTypeMult.count" counter="$MICT_StDrTrCounter">
			<wait min="250ms" sinceversion="4"/>
			<set_value name="$MICT_StDrTradeWare" exact="$MICT_StDrTradeWareTypeMult.{$MICT_StDrTrCounter}"/>
			<set_value name="$MICT_StDrTradeMacro" exact="$MICT_StDrTradeMacroMult.{$MICT_StDrTrCounter}"/>
			<set_value name="$MICT_StDrTradeProp" exact="$MICT_StDrTradePropMult.{$MICT_StDrTrCounter}"/>

			<create_list name="$MICT_StDrTradeCurrentList"/>
			<do_all exact="this.station.units.{unitcategory.defence}.list.count" counter="$i">
				<do_if value="this.station.units.{unitcategory.defence}.list.{$i}.ismacro.{$MICT_StDrTradeMacro}">
					<append_to_list name="$MICT_StDrTradeCurrentList" exact="this.station.units.{unitcategory.defence}.list.{$i}"/>
				</do_if>
			</do_all>
			<set_value name="$MICT_StDrTradeCurrent" exact="$MICT_StDrTradeCurrentList.count + this.station.cargo.{$MICT_StDrTradeWare}.count"/>
			<remove_value name="$MICT_StDrTradeCurrentList"/>

			<set_value name="$MICT_StDrTradeAmount" exact="(($MICT_StDrTradeFillAmount * $MICT_StDrTradeProp) - $MICT_StDrTradeCurrent)i"/>
			<set_value name="$MICT_StDrTradePrice" exact="$MICT_StDrTradeWare.averageprice"/>

			<do_if value="this.station.cargo.{$MICT_StDrTradeWare}.count gt 0">
				<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %3 \n has acquired %2 drones. \n Taking out of storage.'.[this.station.knownname, this.station.cargo.{$MICT_StDrTradeWare}.count, this.zone.knownname]" queued="false" priority="9"/>
				<write_to_logbook category="tips" text="'%1 \n in %3 \n has acquired %2 drones. \n Taking out of storage.'.[this.station.knownname, this.station.cargo.{$MICT_StDrTradeWare}.count, this.zone.knownname]"/>

				<add_units object="this.station" macro="$MICT_StDrTradeMacro" exact="this.station.cargo.{$MICT_StDrTradeWare}.count"/>
				<remove_cargo object="this.station" ware="$MICT_StDrTradeWare" exact="this.station.cargo.{$MICT_StDrTradeWare}.count"/>
			</do_if>

			<find_buy_offer buyer="this.station" wares="$MICT_StDrTradeWare" result="$MICT_StDrTradeOfferMult" excludeempty="false" multiple="true"/>

			<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %3 \n Looking for existing trade offers for %2 \n NODE 1'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]" queued="false" priority="1"/>
			<write_to_logbook category="tips" text="'%1 \n in %3 \n Looking for existing trade offers for %2 \n NODE 1'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]"/>

			<do_if value="$MICT_StDrTradeOfferMult.count ge 1">
				<do_all exact="$MICT_StDrTradeOfferMult.count" counter="$i">
					<do_if value="$MICT_StDrTradeAmount le 0 and $MICT_StDrTradeOffer?">
						<remove_trade_offer object="this.station" tradeoffer="$MICT_StDrTradeOffer"/>

						<do_if value="this.station.trueowner != faction.player">
							<remove_tradeware object="this.station" ware="$MICT_StDrTradeWare"/>
						</do_if>

						<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %3 \n Has enough %2.\n Removing trade offer. \n NODE 2.1'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]" queued="false" priority="1"/>
						<write_to_logbook category="tips" text="'%1 \n in %3 in %3\n Updating trade offer.\n Has enough %2. \n Removing trade offer. \n NODE 2.1'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]"/>
					</do_if>
					<do_else>
						<set_value name="$MICT_StDrTradeOffer" exact="$MICT_StDrTradeOfferMult.{$i}"/>

						<update_trade trade="$MICT_StDrTradeOffer" amount="$MICT_StDrTradeAmount" desiredamount="$MICT_StDrTradeAmount" price="$MICT_StDrTradePrice"/>

						<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %5 \n Updating trade offer.\n Now wants %2 units of %3 \n at %4Cr per unit. \n NODE 2.2'.[this.station.knownname, $MICT_StDrTradeAmount, $MICT_StDrTradeWare, $MICT_StDrTradePrice / 100, this.zone.knownname]" queued="false" priority="1"/>
						<write_to_logbook category="tips" text="'%1 \n in %5 \n Updating trade offer.\n Now wants %2 units of %3 \n at %4Cr per unit. \n NODE 2.2'.[this.station.knownname, $MICT_StDrTradeAmount, $MICT_StDrTradeWare, $MICT_StDrTradePrice / 100, this.zone.knownname]"/>
					</do_else>
				</do_all>
			</do_if>
			<do_elseif value="this.station.trueowner == faction.player">
				<create_trade_offer amount="$MICT_StDrTradeAmount" buyer="this.station" object="this.station" name="$MICT_StDrTrade" ware="$MICT_StDrTradeWare" price="$MICT_StDrTradePrice" unbundle="true" playeronly="false" />

				<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %5 \n placed an order for %2 units of %3 \n at %4Cr per unit. \n NODE 3'.[this.station.knownname, $MICT_StDrTradeAmount, $MICT_StDrTradeWare, $MICT_StDrTradePrice / 100, this.zone.knownname]" queued="false" priority="1"/>
				<write_to_logbook category="tips" text="'%1 \n in %5 \n placed an order for %2 units of %3 \n at %4Cr per unit. \n NODE 3'.[this.station.knownname, $MICT_StDrTradeAmount, $MICT_StDrTradeWare, $MICT_StDrTradePrice / 100, this.zone.knownname]"/>
			</do_elseif>
			<do_else>
				<add_tradeware ware="$MICT_StDrTradeWare" object="this.station" allowbuy="true"/>

				<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %3 \n Now trading in %2. \n NODE 4'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]" queued="false" priority="1"/>
				<write_to_logbook category="tips" text="'%1 \n in %3 \n Now trading in %2. \n NODE 4'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]"/>
			</do_else>
		</do_all>
		<remove_value name="$MICT_StDrTradeWare"/>
		<remove_value name="$MICT_StDrTradeMacro"/>
		<remove_value name="$MICT_StDrTradeProp"/>
		<remove_value name="$MICT_StDrTradeCurrent"/>
		<remove_value name="$MICT_StDrTradeAmount"/>
		<remove_value name="$MICT_StDrTradePrice"/>
		<remove_value name="$MICT_StDrTradeOffer"/>
		<remove_value name="$MICT_StDrTradeOfferMult"/>
	</do_if>
	<remove_value name="$MICT_StDrTradeFillAmount"/>
	<remove_value name="$MICT_StDrTradeWareTypeMult"/>
	<remove_value name="$MICT_StDrTradeMacroMult"/>
	<remove_value name="$MICT_StDrTradePropMult"/>
</do_if>
Thanks to UniTrader, Euclid, Sparky Sparkycorp, and Marvin von Mars for your help and contributions.

@MICT/MCT users, start building drone production facilities! A lot of demand for your product, as well as a much more dangerous galaxy, awaits if you so choose.

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

Post by UniTrader » Mon, 3. Aug 15, 17:20

Sparky Sparkycorp wrote:
2. IIRC, there is a Dev-acknowledged issue/bug with mining ships assigned to stations (they cannot be restricted to a single sector*). How does the idea of having stations harvest material from their zone's using their own mining drones? Might that be possible? Hopefully it would be less efficient (more time travelling) as a balance vs ships. Maybe OOZ would need tweaking if travelling to ore isn't needed. Probably an entire pallet of cans of worms if there are issues getting the to mine different materials without filling a station :)
Already thought about trying this -> I already added the script for this to the default order list of my Manager but it has no functionality yet (it just waits a bit and returns then iirc)
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: 2962
Joined: Tue, 18. Nov 14, 17:23
x4

Post by w.evans » Mon, 3. Aug 15, 23:05

Last update:

Code: Select all

<do_if value="(this.station.trueowner != faction.player) or @this.$config_ammostorage_automatic">
<!--<do_if value="(this.station.trueowner != faction.player) or @this.$config_unitstorage_automatic">-->
	<do_if value="this.station.units.count lt (this.station.units.maxcount - 100)">
		<set_value name="$MICT_StDrTradeFillAmount" exact="this.station.units.maxcount - 100"/>
		<set_value name="$MICT_StDrTradeWareTypeMult" exact="[ware.drp_interceptor_mk1, ware.drp_intrepid_mk1, ware.drp_overrun_mk1, ware.drp_interceptor_mk2, ware.drp_intrepid_mk2, ware.drp_overrun_mk2]"/>
		<set_value name="$MICT_StDrTradeMacroMult" exact="[macro.units_size_drone_attackdrone_impulse_mk1_macro, macro.units_size_drone_attackdrone_plasma_mk1_macro, macro.units_size_drone_missiledrone_dumbfire_mk1_macro, macro.units_size_drone_attackdrone_impulse_mk2_macro, macro.units_size_drone_attackdrone_plasma_mk2_macro, macro.units_size_drone_missiledrone_dumbfire_mk2_macro]"/>
		<set_value name="$MICT_StDrTradePropMult" exact="[0.4f, 0.2f, 0.1f, 0.1f, 0.1f, 0.1f]"/>

		<do_all exact="$MICT_StDrTradeWareTypeMult.count" counter="$MICT_StDrTrCounter">
			<wait min="250ms" sinceversion="4"/>
			<set_value name="$MICT_StDrTradeWare" exact="$MICT_StDrTradeWareTypeMult.{$MICT_StDrTrCounter}"/>
			<set_value name="$MICT_StDrTradeMacro" exact="$MICT_StDrTradeMacroMult.{$MICT_StDrTrCounter}"/>
			<set_value name="$MICT_StDrTradeProp" exact="$MICT_StDrTradePropMult.{$MICT_StDrTrCounter}"/>

			<create_list name="$MICT_StDrTradeCurrentList"/>
			<do_all exact="this.station.units.{unitcategory.defence}.list.count" counter="$i">
				<do_if value="this.station.units.{unitcategory.defence}.list.{$i}.ismacro.{$MICT_StDrTradeMacro}">
					<append_to_list name="$MICT_StDrTradeCurrentList" exact="this.station.units.list.{$i}"/>
				</do_if>
			</do_all>
			<set_value name="$MICT_StDrTradeCurrent" exact="$MICT_StDrTradeCurrentList.count + this.station.cargo.{$MICT_StDrTradeWare}.count"/>
			<remove_value name="$MICT_StDrTradeCurrentList"/>
			<!--<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %2 \n has %3 units of %4.'.[this.station.knownname, this.zone.knownname, $MICT_StDrTradeCurrent, $MICT_StDrTradeWare]" queued="false" priority="1"/>
			<write_to_logbook category="tips" text="'%1 \n in %2 \n has %3 units of %4.'.[this.station.knownname, this.zone.knownname, $MICT_StDrTradeCurrent, $MICT_StDrTradeWare]"/>-->

			<set_value name="$MICT_StDrTradeAmount" exact="(($MICT_StDrTradeFillAmount * $MICT_StDrTradeProp) - $MICT_StDrTradeCurrent)i"/>
			<set_value name="$MICT_StDrTradePrice" exact="$MICT_StDrTradeWare.averageprice"/>

			<do_if value="this.station.cargo.{$MICT_StDrTradeWare}.count gt 0">
				<!--<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %3 \n has acquired %2 drones. \n Taking out of storage.'.[this.station.knownname, this.station.cargo.{$MICT_StDrTradeWare}.count, this.zone.knownname]" queued="false" priority="9"/>
				<write_to_logbook category="tips" text="'%1 \n in %3 \n has acquired %2 drones. \n Taking out of storage.'.[this.station.knownname, this.station.cargo.{$MICT_StDrTradeWare}.count, this.zone.knownname]"/>-->

				<add_units object="this.station" macro="$MICT_StDrTradeMacro" exact="this.station.cargo.{$MICT_StDrTradeWare}.count"/>
				<remove_cargo object="this.station" ware="$MICT_StDrTradeWare" exact="this.station.cargo.{$MICT_StDrTradeWare}.count"/>
			</do_if>

			<find_buy_offer buyer="this.station" wares="$MICT_StDrTradeWare" result="$MICT_StDrTradeOfferMult" excludeempty="false" multiple="true"/>

			<!--<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %3 \n Looking for existing trade offers for %2 \n NODE 1'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]" queued="false" priority="1"/>
			<write_to_logbook category="tips" text="'%1 \n in %3 \n Looking for existing trade offers for %2 \n NODE 1'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]"/>-->

			<do_if value="$MICT_StDrTradeOfferMult.count ge 1">
				<do_all exact="$MICT_StDrTradeOfferMult.count" counter="$i">
					<do_if value="$MICT_StDrTradeAmount le 0 and $MICT_StDrTradeOffer?">
						<remove_trade_offer object="this.station" tradeoffer="$MICT_StDrTradeOffer"/>

						<do_if value="this.station.trueowner != faction.player">
							<remove_tradeware object="this.station" ware="$MICT_StDrTradeWare"/>
						</do_if>

						<!--<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %3 \n Has enough %2.\n Removing trade offer. \n NODE 2.1'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]" queued="false" priority="1"/>
						<write_to_logbook category="tips" text="'%1 \n in %3 \n Updating trade offer.\n Has enough %2. \n Removing trade offer. \n NODE 2.1'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]"/>-->
					</do_if>
					<do_else>
						<set_value name="$MICT_StDrTradeOffer" exact="$MICT_StDrTradeOfferMult.{$i}"/>

						<update_trade trade="$MICT_StDrTradeOffer" amount="$MICT_StDrTradeAmount" desiredamount="$MICT_StDrTradeAmount" price="$MICT_StDrTradePrice"/>

						<!--<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %5 \n Updating trade offer.\n Now wants %2 units of %3 \n at %4Cr per unit. \n NODE 2.2'.[this.station.knownname, $MICT_StDrTradeAmount, $MICT_StDrTradeWare, $MICT_StDrTradePrice / 100, this.zone.knownname]" queued="false" priority="1"/>
						<write_to_logbook category="tips" text="'%1 \n in %5 \n Updating trade offer.\n Now wants %2 units of %3 \n at %4Cr per unit. \n NODE 2.2'.[this.station.knownname, $MICT_StDrTradeAmount, $MICT_StDrTradeWare, $MICT_StDrTradePrice / 100, this.zone.knownname]"/>-->
					</do_else>
				</do_all>
			</do_if>
			<do_elseif value="this.station.trueowner == faction.player">
				<create_trade_offer amount="$MICT_StDrTradeAmount" buyer="this.station" object="this.station" name="$MICT_StDrTradeOffer" ware="$MICT_StDrTradeWare" price="$MICT_StDrTradePrice" unbundle="true" playeronly="false" />

				<!--<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %5 \n placed an order for %2 units of %3 \n at %4Cr per unit. \n NODE 3'.[this.station.knownname, $MICT_StDrTradeAmount, $MICT_StDrTradeWare, $MICT_StDrTradePrice / 100, this.zone.knownname]" queued="false" priority="1"/>
				<write_to_logbook category="tips" text="'%1 \n in %5 \n placed an order for %2 units of %3 \n at %4Cr per unit. \n NODE 3'.[this.station.knownname, $MICT_StDrTradeAmount, $MICT_StDrTradeWare, $MICT_StDrTradePrice / 100, this.zone.knownname]"/>-->
			</do_elseif>
			<do_else>
				<add_tradeware ware="$MICT_StDrTradeWare" object="this.station" allowbuy="true"/>

				<!--<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %3 \n Now trading in %2. \n NODE 4'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]" queued="false" priority="1"/>
				<write_to_logbook category="tips" text="'%1 \n in %3 \n Now trading in %2. \n NODE 4'.[this.station.knownname, $MICT_StDrTradeWare, this.zone.knownname]"/>-->
			</do_else>
		</do_all>
		<remove_value name="$MICT_StDrTradeWare"/>
		<remove_value name="$MICT_StDrTradeMacro"/>
		<remove_value name="$MICT_StDrTradeProp"/>
		<remove_value name="$MICT_StDrTradeCurrent"/>
		<remove_value name="$MICT_StDrTradeAmount"/>
		<remove_value name="$MICT_StDrTradePrice"/>
		<remove_value name="$MICT_StDrTradeOffer"/>
		<remove_value name="$MICT_StDrTradeOfferMult"/>
		<remove_value name="$MICT_StDrTrCounter"/>
	</do_if>
	<remove_value name="$MICT_StDrTradeFillAmount"/>
	<remove_value name="$MICT_StDrTradeWareTypeMult"/>
	<remove_value name="$MICT_StDrTradeMacroMult"/>
	<remove_value name="$MICT_StDrTradePropMult"/>
</do_if>
<do_else>
	<set_value name="$MICT_StDrTradeWareTypeMult" exact="[ware.drp_interceptor_mk1, ware.drp_intrepid_mk1, ware.drp_overrun_mk1, ware.drp_interceptor_mk2, ware.drp_intrepid_mk2, ware.drp_overrun_mk2]"/>
	<do_all exact="$MICT_StDrTradeWareTypeMult.count" counter="$i">
		<set_value name="$MICT_StDrTradeWare" exact="$MICT_StDrTradeWareTypeMult.{$i}"/>
		<find_buy_offer buyer="this.station" wares="$MICT_StDrTradeWare" result="$MICT_StDrTradeOfferMult" excludeempty="false" multiple="true"/>
		<do_all exact="$MICT_StDrTradeOfferMult.count" counter="$j">
			<set_value name="$MICT_StDrTradeOffer" exact="$MICT_StDrTradeOfferMult.{$j}"/>
			<remove_trade_offer object="this.station" tradeoffer="$MICT_StDrTradeOffer"/>
			<!--<show_notification caption="'=== MICT Drone Project ==='" details="'%1 \n in %2 \n Was ordered to stop trading drones. \n Removing trade offer for %3 \n NODE X'.[this.station.knownname, this.zone.knownname, $MICT_StDrTradeWare]" queued="false" priority="1"/>
			<write_to_logbook category="tips" text="'%1 \n in %2 \n Was ordered to stop trading drones. \n Removing trade offer for %3 \n NODE X'.[this.station.knownname, this.zone.knownname, $MICT_StDrTradeWare]"/>-->
		</do_all>
	</do_all>
	<remove_value name="$MICT_StDrTradeWareTypeMult"/>
	<remove_value name="$MICT_StDrTradeOfferMult"/>
	<remove_value name="$MICT_StDrTradeWare"/>
	<remove_value name="$MICT_StDrTradeOffer"/>
</do_else>
Added the do_else in the end to clear out orders if the station's defence officer is set to not manage ammunition; and changed $config_unitstorage_automatic to $config_ammostorage_automatic because the DO's "manage drones" tick box acts funny. (It causes it to run the do_else, thereby clearing out the orders, then runs the do_if again, thus renewing orders.

Also, published this as a part of MICT_supp4 because it doesn't make sense unless stations actually use their combat drones.

And before I forget:

</do_if>

Post Reply

Return to “X Rebirth - Scripts and Modding”