[Help] I have a strange behaviour with a modded ship

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

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

Post Reply
Max Bain
Posts: 1458
Joined: Wed, 27. Jun 18, 19:05
x3ap

[Help] I have a strange behaviour with a modded ship

Post by Max Bain » Wed, 17. Feb 21, 01:18

Hi,

I have a problem with a new ship. I added a lage Khaak destroyer and it works pretty well. Except for one thing: all S ships dont want to attack it. They fly towards the ship, but dont shoot and turn by and repeat. I tested with M ships and L ships and it works well. but S ships dont want to shoot at it. Anyonegot a clue?
The ship has only 4 things that come into my mind that are different to normal L ships. It has a fighter pilot AI, small weapons and it has medium engines. And its a khak ship.

Anyone can help me?

Would be pretty cool to have this ship in game:
Spoiler
Show
Image
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link

User avatar
Axeface
Posts: 2939
Joined: Fri, 18. Nov 05, 00:41
x4

Re: [Help] I have a strange behaviour with a modded ship

Post by Axeface » Wed, 17. Feb 21, 04:00

Did you adjust the <size> attribute? Now I dont actually know what this attribute does, I think it has something to do with a ships 'bounding box'. Whatever it does its something invisible and when messing with it the 3rd person camera distance changes, to get my cyclops working properly I had to fiddle around with this value. My guess would be that its possible the fighters dont think they are in range? Try making the values somewhere near the size of the ship. I may be completely wrong of course.

Code: Select all

		<connections>
			<connection name="container" tags="contents" value="0"/>
			<connection name="position" tags="position" value="1"/>
			<connection name="space" tags="ship ship_l">
				<offset/>
			</connection>
			<connection name="Connection01" tags="part  ">
				<offset>
					<position x="0" y="0" z="0"/>
					<rotation pitch="90" yaw="0" roll="0"/>
				</offset>
				<parts>
					<part name="part_main" wreck="part_main_wreck">
						<lods>
							<lod index="0">
								<materials>
									<material id="1" ref="generic.generic_p1_hulltexture"/>
									<material id="2" ref="generic.generic_p1_fx"/>
									<material id="3" ref="generic.generic_p1_hullpattern"/>
								</materials>
							</lod>
					
											
						<size>       << << << <<              <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<     THIS BIT
							<max x="180" y="180" z="180" />
							<center x="0" y="0" z="0" />
							
							
						</size>
					</part>
				</parts>
			</connection>



PS: - You have new engines there, how hard was it to get animations etc working for them? I would like to make some new engines but its really daunting.

aurumgallente
Posts: 121
Joined: Sun, 14. Jun 20, 14:45
x4

Re: [Help] I have a strange behaviour with a modded ship

Post by aurumgallente » Wed, 17. Feb 21, 08:03

Does it have proper collision model? What ship did you take as a template to make your khaak ship? I would recommend you to take component file and macro file of existing XL ship and put there your node of "part_main" connection. Also check first lines of your component file and macro file and make sure you have proper class of your ship

Code: Select all

<component name="ship_arg_xl_carrier_01" class="ship_xl">

Code: Select all

<macro name="ship_arg_xl_carrier_01_a_macro" class="ship_xl">

Max Bain
Posts: 1458
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: [Help] I have a strange behaviour with a modded ship

Post by Max Bain » Wed, 17. Feb 21, 09:02

Axeface wrote:
Wed, 17. Feb 21, 04:00
Did you adjust the <size> attribute? Now I dont actually know what this attribute does, I think it has something to do with a ships 'bounding box'. Whatever it does its something invisible and when messing with it the 3rd person camera distance changes, to get my cyclops working properly I had to fiddle around with this value. My guess would be that its possible the fighters dont think they are in range? Try making the values somewhere near the size of the ship. I may be completely wrong of course.

PS: - You have new engines there, how hard was it to get animations etc working for them? I would like to make some new engines but its really daunting.
The collision box has perfect siz. The XR converter always gives the right dimensions for the collision model.

To the engines, I just use the khaak medium engine and placed them inside the model so you dont see them. The trail effects are just cosmetic :D.
aurumgallente wrote:
Wed, 17. Feb 21, 08:03
Does it have proper collision model? What ship did you take as a template to make your khaak ship? I would recommend you to take component file and macro file of existing XL ship and put there your node of "part_main" connection. Also check first lines of your component file and macro file and make sure you have proper class of your ship

Code: Select all

<component name="ship_arg_xl_carrier_01" class="ship_xl">

Code: Select all

<macro name="ship_arg_xl_carrier_01_a_macro" class="ship_xl">


As said the collision model is perfect. I sure tested that when I attacked the ship myself in a fighter. Also all other ship classes can attack it properly.

I also gave it the right ship class in macro and component xml.

Nothing helped :(.

Another idea I had was that maybe because I placed the engines inside the model, the fighter want to target them but dont have a direct los to them and therefore cancel their attack. But I now made them unittable without any effect (but maybe that tag does not wort).

Edit:

Ok it seems that the ships wanted to target something that was inside the model. I removed all modules except the weapons and now they attack the ship at the weapons positions. Now I need to find out what module was causing the problem.
Thank you both for your help!
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link

aurumgallente
Posts: 121
Joined: Sun, 14. Jun 20, 14:45
x4

Re: [Help] I have a strange behaviour with a modded ship

Post by aurumgallente » Wed, 17. Feb 21, 10:07

When you will find out what was that, post it here please, I worked on small ships before and now I started to work on capital ships so this information could be very useful.
Also how did you manage to attach that ship to khaak race? I made X2 khaak M0 ship but I can't add it to my mod because I don't know how to add khaak capital ship to npc faction.

Max Bain
Posts: 1458
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: [Help] I have a strange behaviour with a modded ship

Post by Max Bain » Wed, 17. Feb 21, 10:48

aurumgallente wrote:
Wed, 17. Feb 21, 10:07
When you will find out what was that, post it here please, I worked on small ships before and now I started to work on capital ships so this information could be very useful.
Also how did you manage to attach that ship to khaak race? I made X2 khaak M0 ship but I can't add it to my mod because I don't know how to add khaak capital ship to npc faction.
It seems tobe the khaak medium turret that is broken. I had to flip it so that it is visible but still it seems that it is causing the issue. Dont have a fix yet. Will let you know.
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link

aurumgallente
Posts: 121
Joined: Sun, 14. Jun 20, 14:45
x4

Re: [Help] I have a strange behaviour with a modded ship

Post by aurumgallente » Wed, 17. Feb 21, 12:29

macro of khaak turret has this code

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<macros>
  <macro name="turret_kha_m_beam_01_mk1_macro" class="turret">
    <component ref="turret_kha_m_beam_01_mk1" />
    <properties>
      <identification name="{20105,4804}" basename="{20105,4801}" shortname="{20105,4805}" makerrace="khaak" description="{20105,4802}" mk="1" />
      <bullet class="bullet_kha_m_beam_01_macro" />
      <rotationspeed max="210" />
      <reload rate="1" time="4" />
      <hull max="500" integrated="0" />
    </properties>
  </macro>
</macros>
You can try to create custom khaak turret and change one line

Code: Select all

<hull max="500" integrated="1" />
this should prevent any attempts of targeting that turret.

Max Bain
Posts: 1458
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: [Help] I have a strange behaviour with a modded ship

Post by Max Bain » Wed, 17. Feb 21, 13:47

aurumgallente wrote:
Wed, 17. Feb 21, 12:29
macro of khaak turret has this code

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<macros>
  <macro name="turret_kha_m_beam_01_mk1_macro" class="turret">
    <component ref="turret_kha_m_beam_01_mk1" />
    <properties>
      <identification name="{20105,4804}" basename="{20105,4801}" shortname="{20105,4805}" makerrace="khaak" description="{20105,4802}" mk="1" />
      <bullet class="bullet_kha_m_beam_01_macro" />
      <rotationspeed max="210" />
      <reload rate="1" time="4" />
      <hull max="500" integrated="0" />
    </properties>
  </macro>
</macros>
You can try to create custom khaak turret and change one line

Code: Select all

<hull max="500" integrated="1" />
this should prevent any attempts of targeting that turret.
Yeah that would be my workaround, but its a bad solution because
a) turrets would be indestructable
b) less points S ships will target, so if I do it, they all try to shoot the weapons only (I could make these also integrated...)

So far, no luck whatever I try to fix it properly :(
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link

User avatar
Axeface
Posts: 2939
Joined: Fri, 18. Nov 05, 00:41
x4

Re: [Help] I have a strange behaviour with a modded ship

Post by Axeface » Wed, 17. Feb 21, 15:43

Good info that it was a component they couldnt target (might need to move some things on my ship).
Max Bain wrote:
Wed, 17. Feb 21, 09:02
Axeface wrote:
Wed, 17. Feb 21, 04:00
Did you adjust the <size> attribute? Now I dont actually know what this attribute does, I think it has something to do with a ships 'bounding box'. Whatever it does its something invisible and when messing with it the 3rd person camera distance changes, to get my cyclops working properly I had to fiddle around with this value. My guess would be that its possible the fighters dont think they are in range? Try making the values somewhere near the size of the ship. I may be completely wrong of course.

PS: - You have new engines there, how hard was it to get animations etc working for them? I would like to make some new engines but its really daunting.
The collision box has perfect siz. The XR converter always gives the right dimensions for the collision model.
Of topic but when you say 'collision box', is that definitely what it is? Why is there a collision box if we have a collision model? Also when I export my models the converter just returns everything as 0. Meh I dunno.
Eg

Code: Select all

				<size>
							<max x="0" y="0" z="0" />
							<center x="0" y="0" z="0" />
						</size>

aurumgallente
Posts: 121
Joined: Sun, 14. Jun 20, 14:45
x4

Re: [Help] I have a strange behaviour with a modded ship

Post by aurumgallente » Wed, 17. Feb 21, 15:48

It defines how camera renders an element when you are looking at it.

User avatar
Axeface
Posts: 2939
Joined: Fri, 18. Nov 05, 00:41
x4

Re: [Help] I have a strange behaviour with a modded ship

Post by Axeface » Wed, 17. Feb 21, 16:12

aurumgallente wrote:
Wed, 17. Feb 21, 15:48
It defines how camera renders an element when you are looking at it.
Could you elaborate at all? Not sure what this means exactly. I saw no difference in 'render' results when changing this value, only the distance of the camera from the object and size of the targetting box in the ui.

aurumgallente
Posts: 121
Joined: Sun, 14. Jun 20, 14:45
x4

Re: [Help] I have a strange behaviour with a modded ship

Post by aurumgallente » Wed, 17. Feb 21, 18:18

it affects the distance where part is visible. Also if part of the ship has a few nodes with different materials, this part is not rendered by game engine until all nodes of the part on the screen (at least 1 pixel of each node). Large values of "size" and "size_raw" can change this.

User avatar
Shuulo
Posts: 1629
Joined: Mon, 14. Apr 08, 17:03
x4

Re: [Help] I have a strange behaviour with a modded ship

Post by Shuulo » Thu, 18. Feb 21, 17:26

size parameter is also used for large vs large ships collision, view distance of some effects (like bloom on projectile material, though that one is more affected by size_raw) and for turrets targeting, they usually tend to fire in the direction of a bounding box if not targeting specific turrets.

Post Reply

Return to “X4: Foundations - Scripts and Modding”