Multiple engine size/types on one ship

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

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

Post Reply
YellowBelllyBlackSnake
Posts: 15
Joined: Sun, 12. Jan 14, 23:05
x4

Multiple engine size/types on one ship

Post by YellowBelllyBlackSnake » Sun, 26. Mar 23, 09:37

I've been curious for a while if it is possible to have different size engines on a ship. Technically the engine can do it, and the loadout screen can kinda recognise different engine hardpoint sizes. The problem is that when adding engines it will only apply the last selected engine to all engine hardpoints, no matter their size, making it impossible to have different sized engines.

I ended up thinking up two possible ways to get around this problem.

The first one was to add smaller engines as sub-components of an engine. This would get around the problem of only being able to have one engine type on a ship, but has the downside that each ship would need to have a custom engine component made for them.
This kinda worked, the extra engines were targetable and could be destroyed, but there was a major problem. The extra engines did not contribute any thrust to the ship, making them basically only destructible props. This could be solved if their was a way to have sub-components stats apply to the ship, but currently I don't know of a way to do it.

There were some other issues as well. These were:
  • The extra engines weren't shielded - Can be solved by giving them the same group as the shields on the ship.
  • if the parent engine is destroyed all the child engines die as well.
  • The child engines could cause positioning issues if pointed to the wrong connection point.
This wasn't a complete failure as it made me realise you could have engines (or other component types) which could come with predefined loadouts of turrets, shields, or possibly any other type of component (I did find that weapons don't like having another weapon added to them, but you can have a turret on their barrel ;)).


The second method is pretty simple and works! Just add predefined engines to the ship directly. The hardest part was finding the correct tag and connection point so that the loadout screen wouldn't consider them as swappable engines.

Here's a picture of an Asgard with an extra 4 L and 6 M engines.
https://i.imgur.com/rDG0gpj.jpg

and here's the code for the Asgard.

Component file "ship_atf_xl_battleship_01.xml".

Code: Select all

<?xml version="1.0"?>
<diff>
	<add sel="//components/component/connections">
		<connection name="con_engine_02" group="group_back_mid_down" tags="part ">
			<offset>
				<position x="-301.1" y="0" z="-1004.8"/>
				<quaternion qx="-0" qy="-0" qz="-0.7071068" qw="-0.7071067"/>
			</offset>
		</connection>
		<connection name="con_engine_03" group="group_back_mid_down" tags="part ">
			<offset>
				<position x="301.1" y="0" z="-1004.8"/>
				<quaternion qx="-0" qy="-0" qz="-0.7071068" qw="-0.7071067"/>
			</offset>
		</connection>
		<connection name="con_engine_04" group="group_back_mid_down" tags="part ">
			<offset>
				<position x="360.7" y="0" z="-914.853"/>
				<quaternion qx="-0" qy="-0" qz="-0.7071068" qw="-0.7071067"/>
			</offset>
		</connection>
		<connection name="con_engine_05" group="group_back_mid_down" tags="part ">
			<offset>
				<position x="-360.7" y="0" z="-914.853"/>
				<quaternion qx="-0" qy="-0" qz="-0.7071068" qw="-0.7071067"/>
			</offset>
		</connection>
		<connection name="con_engine_s_01" group="large_engine" tags="part ">
			<offset>
				<position x="165" y="-33" z="-1222"/>
				<quaternion qx="-0" qy="-0" qz="-0.7071068" qw="-0.7071067"/>
			</offset>
		</connection>
		<connection name="con_engine_s_02" group="large_engine" tags="part ">
			<offset>
				<position x="165" y="33" z="-1222"/>
				<quaternion qx="-0" qy="-0" qz="-0.7071068" qw="-0.7071067"/>
			</offset>
		</connection>
		<connection name="con_engine_s_03" group="large_engine" tags="part ">
			<offset>
				<position x="-165" y="33" z="-1222"/>
				<quaternion qx="-0" qy="-0" qz="-0.7071068" qw="-0.7071067"/>
			</offset>
		</connection>
		<connection name="con_engine_s_04" group="large_engine" tags="part ">
			<offset>
				<position x="-165" y="-33" z="-1222"/>
				<quaternion qx="-0" qy="-0" qz="-0.7071068" qw="-0.7071067"/>
			</offset>
		</connection>
		<connection name="con_engine_s_05" group="large_engine" tags="part ">
			<offset>
				<position x="19.3" y="96.2" z="-1388"/>
				<quaternion qx="-0" qy="-0" qz="-0.7071068" qw="-0.7071067"/>
			</offset>
		</connection>
		<connection name="con_engine_s_06" group="large_engine" tags="part ">
			<offset>
				<position x="-19.3" y="96.2" z="-1388"/>
				<quaternion qx="-0" qy="-0" qz="-0.7071068" qw="-0.7071067"/>
			</offset>
		</connection>
	</add>
</diff>
Important part is to set the tags something like "part" so that the loadout screen doesn't think they are swappable.

Macro file "ship_atf_xl_battleship_01_a_macro.xml".

Code: Select all

<diff>
<add sel="//macros/macro/connections">
      <connection ref="con_engine_02">
        <macro ref="engine_ter_l_allround_01_mk1_macro" connection="EngineConnection01" />
      </connection>
      <connection ref="con_engine_03">
        <macro ref="engine_ter_l_allround_01_mk1_macro" connection="EngineConnection01" />
      </connection>
      <connection ref="con_engine_04">
        <macro ref="engine_ter_l_allround_01_mk1_macro" connection="EngineConnection01" />
      </connection>
      <connection ref="con_engine_05">
        <macro ref="engine_ter_l_allround_01_mk1_macro" connection="EngineConnection01" />
      </connection>
      <connection ref="con_engine_s_01">
        <macro ref="engine_ter_m_allround_01_mk3_macro" connection="EngineConnection01" />
      </connection>
      <connection ref="con_engine_s_02">
        <macro ref="engine_ter_m_allround_01_mk3_macro" connection="EngineConnection01" />
      </connection>
      <connection ref="con_engine_s_03">
        <macro ref="engine_ter_m_allround_01_mk3_macro" connection="EngineConnection01" />
      </connection>
      <connection ref="con_engine_s_04">
        <macro ref="engine_ter_m_allround_01_mk3_macro" connection="EngineConnection01" />
      </connection>
      <connection ref="con_engine_s_05">
        <macro ref="engine_ter_m_allround_01_mk3_macro" connection="EngineConnection01" />
      </connection>
      <connection ref="con_engine_s_06">
        <macro ref="engine_ter_m_allround_01_mk3_macro" connection="EngineConnection01" />
      </connection>
</add>
</diff>
It took me a while to figure out the macro file as the connection point has some influence on whether the engines will show up or not. Eventually after looking at a previous attempt I figured out that setting it to "EngineConnection01" works (don't ask me why, because I have no clue).

The upside of this method are:
  • each engine adds to the ships speed.
  • each engine is destroyable and will impact the ships performance
  • Multiple sizes and types of engines can be added to one ship
  • The ship can still have a main engine that can be swapped out
The downsides I've found so far are:
  • The engines are predefined in the macro file and cannot be swapped out with another engine type in game
  • They aren't counted in the calculation for the ships listed speed in the loadout screen. The only way to view it is by either looking in the information panel or flying the ship at full speed
  • They don't appear in the ship modification screen, so likely can't be modified
  • They don't appear to be added to the required constructions wares of a ship

Post Reply

Return to “X4: Foundations - Scripts and Modding”