[QUESTION] - M turret doesn't work on S size ship, but exactly why? edit: [SOLVED]

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

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

Post Reply
vonclausewitz
Posts: 14
Joined: Sun, 7. Jan 18, 20:15
x3ap

[QUESTION] - M turret doesn't work on S size ship, but exactly why? edit: [SOLVED]

Post by vonclausewitz » Sat, 25. Sep 21, 14:58

In this tutorial - viewtopic.php?f=129&t=424921 - it is mentioned that S-mall sized ship cannot carry M turrets. To be precise, turret mount can be added to small ship, but turret logic will not work.

I have tried to do it anyway, in hope that at some point I will be able to push that subject forward, but I am stuck now.

I have edited file ship_par_s_trans_container_01.xml by adding turret:

Code: Select all

<connection name="con_turret_01" tags="turret standard medium hittable">
				<offset>
					<position x="1.679909E-02" y="2.246185" z="3.0"/>
				</offset>
			</connection>
			
			<connection name="con_turret_02" tags="turret medium standard component hittable">
				<offset>
					<position x="1.679909E-02" y="2.246185" z="-12.0"/>
				</offset>
			</connection>
I have experimented with various tags - no result. Turrets can be mounted, but they do not react to enemy activity. I have experimented with unhittable tag as well, no result too.

Then, I thought, that maybe it depends on ship size or type so I have edited ship_par_s_trans_container_01_macro.xml :

Code: Select all

<diff> 
	<replace sel="//macros/macro/@class">ship_m</replace>
	<replace sel="//macros/macro/properties/ship/@type">scavenger</replace>
	<replace sel="//macros/macro/properties/purpose/@primary">fight</replace>
</diff> 

Result: s fighter is 'properly' categorized as medium ship, scavenger in-game - so edit works - but still no luck with turrets.

I would appreciate any help with making it work.
Last edited by vonclausewitz on Sun, 26. Sep 21, 19:16, edited 1 time in total.

j.harshaw
EGOSOFT
EGOSOFT
Posts: 1847
Joined: Mon, 23. Nov 15, 18:02

Re: [QUESTION] - M turret doesn't work on S size ship, but exactly why?

Post by j.harshaw » Sat, 25. Sep 21, 17:46

Ship's probably missing an entity to run turret-control scripts. I'm not an artist and don't work directly with the asset templates, but I think it would require a defencenpc connection in the ship's template (or possibly the macro. can also add the connection to defaults.xml, but that would add defencenpcs on all S ships and may impact performance with no functionality). defencenpc would then have to be added on creation and fight.attack.object.medium started on it, although that last might already be done when initializing a ship with the appropriate connections.

j.harshaw
EGOSOFT
EGOSOFT
Posts: 1847
Joined: Mon, 23. Nov 15, 18:02

Re: [QUESTION] - M turret doesn't work on S size ship, but exactly why?

Post by j.harshaw » Sat, 25. Sep 21, 18:15

j.harshaw wrote:
Sat, 25. Sep 21, 17:46
but I think it would require a defencenpc connection in the ship's template (or possibly the macro. can also add the connection to defaults.xml, but that would add defencenpcs on all S ships and may impact performance with no functionality). defencenpc would then have to be added on creation and fight.attack.object.medium started on it, although that last might already be done when initializing a ship with the appropriate connections.
Correction. Just tested in-game, and connection only needs to be added to the ship (i think the macro, but didn't test that route) or defaults.xml. defencenpc added and initialized on ship initialization. May need to patch defencenpcs into existing ships if loading a save, but not sure.

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

Re: [QUESTION] - M turret doesn't work on S size ship, but exactly why?

Post by Shuulo » Sat, 25. Sep 21, 18:41

j.harshaw wrote:
Sat, 25. Sep 21, 18:15
j.harshaw wrote:
Sat, 25. Sep 21, 17:46
but I think it would require a defencenpc connection in the ship's template (or possibly the macro. can also add the connection to defaults.xml, but that would add defencenpcs on all S ships and may impact performance with no functionality). defencenpc would then have to be added on creation and fight.attack.object.medium started on it, although that last might already be done when initializing a ship with the appropriate connections.
Correction. Just tested in-game, and connection only needs to be added to the ship (i think the macro, but didn't test that route) or defaults.xml. defencenpc added and initialized on ship initialization. May need to patch defencenpcs into existing ships if loading a save, but not sure.
So, using the this method, ai will use turrets the normal way and they will be taken into account in OOS as well?

j.harshaw
EGOSOFT
EGOSOFT
Posts: 1847
Joined: Mon, 23. Nov 15, 18:02

Re: [QUESTION] - M turret doesn't work on S size ship, but exactly why?

Post by j.harshaw » Sat, 25. Sep 21, 18:54

Should, yeah. Can't give you a better answer without testing. Nothing I see preventing it.

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

Re: [QUESTION] - M turret doesn't work on S size ship, but exactly why?

Post by Shuulo » Sat, 25. Sep 21, 21:23

j.harshaw wrote:
Sat, 25. Sep 21, 18:54
Should, yeah. Can't give you a better answer without testing. Nothing I see preventing it.
hm, interesting, i remember it didnt work properly last time I tried, fighter in OOS dealt damage only when it was facing the enemy. I may need to try again, maybe my observations were limited.

btw, this should be added to ship component file, not macro:

Code: Select all

 <connection name="defencenpc" tags="defence" value="-1" />

vonclausewitz
Posts: 14
Joined: Sun, 7. Jan 18, 20:15
x3ap

Re: [QUESTION] - M turret doesn't work on S size ship, but exactly why? [SOLVED - see how to add M turret to a small shi

Post by vonclausewitz » Sat, 25. Sep 21, 23:23

Many thanks! I is amazing! I've spent hours, if not days before I decided to ask here on forum, and you guys solved it almost instantly!

I have tested this, mounting two turrets, on the paranid small tranporter, one beam, one gatling, this is result:

https://media.moddb.com/images/mods/1/5 ... hot_59.png

and here

https://media.moddb.com/images/mods/1/5 ... hot_60.png

Thanks, I really wanted to transform small traders into fighter-bombers with turrets, so there would be more various ships, and so it would be little bit like in the Freelancer Discovery mod, where heavy fighters and bombers have small turrets.


Sorry, I don't know if I am posting images in a right way? (I mean, should I use some kind of spoiler or something?)

_____
edit: oversized images changed to links - j.h

j.harshaw
EGOSOFT
EGOSOFT
Posts: 1847
Joined: Mon, 23. Nov 15, 18:02

Re: [QUESTION] - M turret doesn't work on S size ship, but exactly why?

Post by j.harshaw » Sat, 25. Sep 21, 23:41

Glad you got it working. Images look ok here, but think there's a size limit (image dimensions) above which you should post links to them.

edit: right:
General Forum Rules wrote:
Fri, 30. Nov 18, 12:57
Images posted should not exceed 640 x 480 and 100kb in size

vonclausewitz
Posts: 14
Joined: Sun, 7. Jan 18, 20:15
x3ap

Re: [QUESTION] - M turret doesn't work on S size ship, but exactly why?

Post by vonclausewitz » Sun, 26. Sep 21, 00:59

Glad you got it working. Images look ok here, but think there's a size limit (image dimensions) above which you should post links to them.

Thanks, I will remember now.

By the way, because it is quite a similar subject... in vanilla, only L size ships can mount missile turrets, and Medium ships don't. (which is reasonable, because they have small missile storage, and there is no reason to allow turret freely use missiles).

But anyway, I was very curious, personally as I wanted P Xenon corvette to be able to mount missile turret.

So to enable medium ship to mount missile turret, turret needs specific

Code: Select all

tags="turret medium standard missile component hittable"
.

It took me a while to experiment before found it, may be useful to someone. It also works for Small size ships.

Last thing: I have seen, that there were attempts to make Xenon ships playable (https://www.nexusmods.com/x4foundations ... ?tab=posts), but it seems that it doesn't work anymore. I hoped, I could learn myself on that mod, how to make my own Xenon ships pilotable...

I am very much beginner, and I don't feel strong enough to dive into blender/x4 subject. But as you have mentioned such a nice and simple solution for turrets, maybe by any chance you know if there is similar way to make Xenon ships pilotable?
I mean, by adding some <connection>? and editing ship file, the same way, like it You suggested with turrets?

I have managed to add ware, named re-versed xenon XYZ ship, and everything works fine, ie, player can give orders to it, it can be build in shipyard after buying, except player cannot pilot such ship...

j.harshaw
EGOSOFT
EGOSOFT
Posts: 1847
Joined: Mon, 23. Nov 15, 18:02

Re: [QUESTION] - M turret doesn't work on S size ship, but exactly why?

Post by j.harshaw » Sun, 26. Sep 21, 01:39

capturable's trivial. that's just this line in the ship macros:

<capture allow="0" />

pilotable's harder. i don't think they have cockpits or bridges and would need them (at the very least a place to put the captain's post). i'm pretty sure there's a way to force player control of them, but no idea how that would look in first person view.

vonclausewitz
Posts: 14
Joined: Sun, 7. Jan 18, 20:15
x3ap

Re: [QUESTION] - M turret doesn't work on S size ship, but exactly why?

Post by vonclausewitz » Sun, 26. Sep 21, 03:47

pilotable's harder. i don't think they have cockpits or bridges and would need them (at the very least a place to put the captain's post). i'm pretty sure there's a way to force player control of them, but no idea how that would look in first person view.
All right, Rome wasn't build in a one day!
I am very happy with what I got today. You guys made my day with helping with those turrets! Thanks again!

Post Reply

Return to “X4: Foundations - Scripts and Modding”