[HELP] Adding MD event condition for all player-owned ships

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

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

Post Reply
bitvoid
Posts: 69
Joined: Wed, 6. Nov 02, 21:31
x4

[HELP] Adding MD event condition for all player-owned ships

Post by bitvoid » Tue, 30. Oct 18, 21:25

I'm trying to get my feet wet with writing some MD and at the same time automating some of the more mundane tasks of managing my ever growing empire.

For one of these I wanted to run some actions whenever one of my ships is assigned to one of my stations.

The MD I initially came up with looks like this (though it doesn't check for owner yet):

Code: Select all

<cue name="CommanderAssignedHandler" instantiate="true" namespace="this">
	<conditions>
		<event_object_commander_set />
		<check_value value="event.param.type" exact="entitytype.manager" />
		<check_value value="event.param.controlled.isclass.[class.ship_xl, class.ship_l, class.ship_m]" />
	</conditions>
	<actions>
		<set_value name="$commander" exact="event.param" />
		<set_value name="$ship" exact="$commander.controlled" />
		<debug_text text="'Ship reassigned: %s Macroname: %s Commander: %s'.[$ship.name, $ship.macro.name, $commander.name]" />
	</actions>
</cue>
The problem is that it doesn't work ... :)

Code: Select all

[=ERROR=] 457942.89 Error in MD cue md.BV_CustomStuff.CommanderAssignedHandler: Error evaluating <event_object_commander_set> event object: Value 'null' is not of type component
Looking at some usages of other "event_object_" conditions, I suppose I need to add either the "object" or "group" attribute. While I could probably build a group containing all player-owned ships in some kind of init cue, I'd still need to maintain that group which seems not that straight forward leading me to believe I'm missing something obvious.

Does anyone know of a good approach for just running some actions whenever a player-owned ship is assigned to a station?

Thank you

User avatar
eliseeff
Posts: 255
Joined: Wed, 26. Jan 05, 18:17
x4

Re: [HELP] Adding MD event condition for all player-owned ships

Post by eliseeff » Wed, 31. Oct 18, 08:35

You had better go the opposite.

<event_object_subordinate_added group="$your_stations_group"/>

event.param will be a new assigned ship

Do not forget to add new stations to the group, if they are built.

bitvoid
Posts: 69
Joined: Wed, 6. Nov 02, 21:31
x4

Re: [HELP] Adding MD event condition for all player-owned ships

Post by bitvoid » Wed, 31. Oct 18, 08:50

Hi eliseeff, thank you for the suggestion. It does raise a question though:

As I understand it I'd have to generate the "$your_stations_group" by myself so I'm asking myself how to best do that.

I know that initially I can rather easily build the group using "<find_station/>". But how do I keep it updated when building (or boarding, since I play with the New Frontiers mod) additional stations. Do I need to hook into the respective architect/boarding md cues adding signals to my own cue or is there another way, maybe another condition that I'm currently not seeing?

User avatar
eliseeff
Posts: 255
Joined: Wed, 26. Jan 05, 18:17
x4

Re: [HELP] Adding MD event condition for all player-owned ships

Post by eliseeff » Wed, 31. Oct 18, 09:27

Well... You can build a station, you can capture a station. But before you can assign a ship to it, you still have to first assign a manager.

View file NPC_Staff.xml and catch the manager's assignment. Then at each appointment of the manager, check whether there is a station in your group. And if not - add.

bitvoid
Posts: 69
Joined: Wed, 6. Nov 02, 21:31
x4

Re: [HELP] Adding MD event condition for all player-owned ships

Post by bitvoid » Wed, 31. Oct 18, 09:43

Thanks, that definitely helps.

I'll still need to see how it interacts with the station surrender behavior in New Frontiers since it transfers ownership of a complete station including manager/crew to the player but it should definitely get me started.

User avatar
eliseeff
Posts: 255
Joined: Wed, 26. Jan 05, 18:17
x4

Re: [HELP] Adding MD event condition for all player-owned ships

Post by eliseeff » Wed, 31. Oct 18, 10:26

Glad to help. :)

Post Reply

Return to “X Rebirth - Scripts and Modding”