adding a new class

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

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

h2o.Ava
Posts: 349
Joined: Sun, 12. Oct 08, 04:04
x4

adding a new class

Post by h2o.Ava »

hmm testing stuff about using tags to create custom station classes
Last edited by h2o.Ava on Fri, 22. Nov 24, 19:59, edited 3 times in total.
Rothank
XWiki Moderator
XWiki Moderator
Posts: 85
Joined: Mon, 11. Aug 14, 22:48
x4

Re: adding a new class

Post by Rothank »

You can create any new size class you want, but you'd need to also create custom docks for them to dock/land at. SWI does this with their XXLs.
What you cannot do are custom ship types (fighter, destroyer etc). You can, however, reuse types across sizes (nothing prevents you from making an M fighter, for example).
Image Image
Image
h2o.Ava
Posts: 349
Joined: Sun, 12. Oct 08, 04:04
x4

Re: adding a new class

Post by h2o.Ava »

hmm, they do it by changing the docksize tag.

we could use custom connection tags to create new classes of ships via

Code: Select all

<find_ship_by_true_owner name="$ships" faction="faction.factionname" space="player.galaxy" tag="tag.newtag" />

however, for stations, what about:

Code: Select all

<find_station_by_true_owner faction="faction.factionname" space="player.galaxy" multiple="true" functional="true" name="$stations" tag="tag.newtag" />
where would I set that tag (there isn't a components.xsd or macros.xsd)?

would it be in extensions\modname\assets\structures\station_name.xml:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<components>
  <component tag="newtag" name="station_name" class="station">  			<!--here?-->
    <connections>
      <connection name="docked" tags="ship" value="0" />
      <connection name="controlroom" tags="room" />
      <connection name="modules" tags="module" />
      <connection name="space" tags="station" />
      <connection name="newtag_name" tags="newtag" \>  					<!--here?-->
    </connections>
  </component>
</components>
would it be in extensions\modname\assets\structures\macros\station_name_macro.xml:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<macros>
  <macro name="station_name_macro" class="station" tag="newtag">  			<!--here?-->
    <component ref="station_name" />
    <properties>
      <identification name="'station name'" icon="mapob_station_icon"
      factionhqicon="mapob_station_icon" hudicon="si_station_icon"
      makerace="race" type="tradestation" tag="newtag"/>				<!--here?-->
      <build>
        <sets>
          <set ref="factory" />
        </sets>
      </build>
    </properties>
    <connections>
      <connection ref="controlroom">
        <macro ref="control_room_macro" connection="Connection01" />
      </connection>
    </connections>
  </macro>
</macros>

for checking an individual station/ship for its newtag, we could use:

Code: Select all

<find_object_component object="$station" name="$component" tag="tag.newtag" />
Placing the newtag within the ship is easy. But where would the newtag be placed in the station's xml files? would it be on a module? if so, then the station would need a custom module like this?

extensions\modname\assets\structures\connectionmodules\custom_module_name.xml:

Code: Select all

<?xml version="1.0"?>
<components>
	<component name="custom_module_name" class="pier">
		<source geometry="assets\structures\dock\\custom_module_name_data"/>
		<layers>
			...
		</layers>
		<connections>
			...
			<connection name="newtag_name" tags="newtag" />			<!--here?-->
h2o.Ava
Posts: 349
Joined: Sun, 12. Oct 08, 04:04
x4

Re: adding a new class

Post by h2o.Ava »

testing...
h2o.Ava
Posts: 349
Joined: Sun, 12. Oct 08, 04:04
x4

Re: adding a new class

Post by h2o.Ava »

ok so creating new classes of ships is likely easy, via tags.

This works:

Code: Select all

<find_ship name="$miners" space="player.galaxy" multiple="true" tag="tag.miner"/>

however, the same for stations does nothing:

Code: Select all

<find_station name="$stations" space="player.galaxy" multiple="true" tag="tag.newtag"/>

i've tried placing tag="newtag" and tags="newtag" everywhere, and it never finds any stations.

so it seems like what we need is for stations to have custom tags
h2o.Ava
Posts: 349
Joined: Sun, 12. Oct 08, 04:04
x4

Re: adding a new class

Post by h2o.Ava »

Ok, so the way to do this is to create a custom component with the custom tag (tags="customtag"). add it to the station's construction plan. then when you want to find stations of the new class you must find all stations (find_station multiple="true"), then loop check each station for the tagged component (find object component tag="customtag"), when found then append that station to a list.

you how have a list consisting of all the stations of the new class.
Realspace
Posts: 1637
Joined: Wed, 15. Nov 06, 10:21
x4

Re: adding a new class

Post by Realspace »

Hi h2o.Ava
I am having the same issue, I created some jump portals around the anomalies. To be sure the scripts find the right thing, I also made a custom anomaly macro.
Problem is when looking for that macro, it sometimes works sometimes not, depending the situation. If it is close to player, the engine finds it, otherwise not.
Then also tried the find_station method instead, following the tag way, or just a station very close to an anomaly (no success).

So what do you suggest to do is to create a module macro right? I made a module macro with an empty component, both indexed. Then added the macro to the plan (it is invisible).
How do I recall that presence in the station, with match_content?

Also you talk about adding the tags anyway (but before, you told they do not work ever), do you mean making a new class for the object?
For instance I used the radar macro and made empty:

Code: Select all

<macros>
  <macro name="portal_invisible_01_macro" class="radar" tag="portal">
    <component ref="portal_invisible_01" />
    <properties>
      <identification unique="1" />
	  <hull invulnerable="1" />
    </properties>
  </macro>
</macros>
Should I rename the class to "portal" ?
Thank you!

Return to “X4: Foundations - Scripts and Modding”