Modding help : Adding a new turret, please help me find the bug.

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

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

Starman01
Posts: 209
Joined: Wed, 20. Jun 07, 13:56
x4

Modding help : Adding a new turret, please help me find the bug.

Post by Starman01 »

Hi all,

i would really appreciate a little help with adding new turrets. I am trying to add a weaker variant by copying and renaming existing files while keeping mesh and turret properties the same, but still something seems to be missing because the ships ingame do not equip them and fly around without L-Turrets. I know I can only change the bullet damage values, but I need an easy version on the ships, while keeping the strong versions for the stations, so I need a new turret.
Here is what I do (example of one turret):

1) Copied the file inside \assets\props\weaponsystems\ and created a new named variant. Maybe I made a mistake here, because I do not know to where exactly "component name" refers too. In my example I created a file calles "turret_xen_l_inv_weak.xml" and inside I made these changes :

Code: Select all

<?xml version="1.0"?>
<components>
	<component name="turret_xen_l_inv_weak" class="turret">
		<source geometry="extensions\vro\assets\props\WeaponSystems\heavy\turret_xen_l_inv_data"/>
		<layers>
			<layer>
				<waypoints/>
				<lights/>
			</layer>
		</layers>
As you can see, i changed "component name" here too. Not sure if I'm supposed to ?

2) Inside \assets\props\weaponsystems\heavy\macros\ i also copied the existing files, and created new variants with a changed name. Inside i refer to the new macro and the component created under 1)

Code: Select all

<macros>
  <macro name="turret_xen_l_obliterator_inv_weak_macro" class="turret">
    <component ref="turret_xen_l_inv_weak" />
    <properties>
      <identification name="{6699,10211}" basename="{6699,10211}" shortname="{6699,10211}" makerrace="xenon" description="{6699,10211}" />
      <bullet class="bullet_xen_turret_l_obliterator_one_weak_macro" />
      <rotationspeed max="15" />
      <reload rate="0.5" time="1" />
      <hull max="35310" threshold="0.2" integrated="1" />
      <weapon angle="20" />
    </properties>
  </macro>
</macros>
No changes beside the names. With this, i think i created a copied entry of the existing turret.

3) Now, to make the turret a weaker version, I changed the bullet file located here : \assets\fx\weaponfx\macros

Created a copy file named : bullet_xen_turret_l_obliterator_one_macro.xml

Code: Select all

<macros>
  <macro name="bullet_xen_turret_l_obliterator_one_weak_macro" class="bullet">
    <component ref="obliterator_bullet" />
    <properties>
      <!-- <ammunition value="2" reload="10" /> -->
      <bullet speed="60000" lifetime="1.5" amount="1" range="15000" barrelamount="1" icon="weapon_beam_mk1" maxhits="1" ricochet="0" scale="1" attach="1" />
      <reload rate ="0.045" />
      <damage value="2000" repair="0" />
      <effects>
        <impact ref="impact_xen_obliterator_turret" />
        <launch ref="muzzle_xen_obliterator_turret" />
      </effects>
      <weapon system="turret_midrange" />
    </properties>
  </macro>
</macros>
Only changed the macro name and damage value inside the file.

4) I created a new wares.xml table entry for the weapon so that it can be found and equipped in the shipyard (not needed for player, it's xenon only)

Code: Select all

    <ware id="turret_xen_l_obliterator_weak" name="{6699,1020}" description="{6699,1020}" group="turrets" transport="equipment" volume="1" tags="equipment noplayerblueprint turret">
      <price min="13092" average="14580" max="16068" />
      <production time="15" amount="1" method="default" name="{20206,101}">
        <primary>
          <ware ware="energycells" amount="20" />
          <ware ware="ore" amount="10" />
          <ware ware="silicon" amount="10" />
        </primary>
      </production>
      <component ref="turret_xen_l_obliterator_weak_macro" amount="1" />
      <restriction licence="generaluseequipment" />
      <use threshold="0" factions="xenon" />
      <owner faction="xenon" />
    </ware>	
    
No change here except "ware id", and "component ref".... Mabye I made an error here in line one, do I need a new "name" ?

5) Last change was a direct edit (no copy) in the ship files. \\assets\units\size_xl\macros

Here i only changed the turret lines :

Code: Select all

            <turrets macro="turret_xen_l_obliterator_weak_macro" path=".." group="group05" exact="1" optional="1" />
            <turrets macro="turret_xen_l_obliterator_weak_macro" path=".." group="group06" exact="1" optional="1" />
            

Thanks for reading through all of this :) Now I wonder what did I miss ? Any help would be highly appreciated ? Wandering Xenons obliterating the universe, but when I just weaken the weapons, then the xenon sectors will be overrun because I weaken the stations too. So I thought I might do it this way, and still have invading xenon ships, even though they are neutered...

Just a disclaimer : These are VRO parts, but i do not plan to release it and leech upon that mod without the creators consent... It's just for learning purpose and my own single player game for the moment.
Folker
Posts: 124
Joined: Fri, 31. Jul 20, 21:56
x4

Re: Modding help : Adding a new turret, please help me find the bug.

Post by Folker »

I see that something is missing, which means that the turrets, bullets, or whatever don't appear. I didn't see your macro file in the messages, so I guess you didn't edit it. If you don't edit it, for the game your turrets don't exist.

I advise you to add it. To do so, go to :

extensions\vro\index

From there, you have two files, “macros” and “components”.

Open the macros.xml file.

Add two lines referencing the turret you've created:

For the turret :
<entry name=“turret_xen_l_obliterator_inv_weak_macro” value=“extensions\vro\assets\props\weaponsystems\heavy\macros\turret_xen_l_obliterator_inv_weak_macro”/>


For the bullet :
<entry name=“bullet_xen_turret_l_obliterator_one_weak_macro” value=“extensions\vro\assets\fx\weaponfx\macros\bullet_xen_turret_l_obliterator_one_weak_macro”/>


Now open the components file, as I've seen that you've also added components, and write :

<entry name=“turret_xen_l_inv_weak” value=“extensions\vro\assets\props\WeaponSystems\heavy\turret_xen_l_inv_weak”/>

I put it in heavy because I saw that you had written in heavy in your code. I also suggest that you move it to \assets\props\weaponsystems\heavy. You can also put it in standard, but you'll need to modify your components.xml.

In your ware file, you made an error : you write : <component ref="turret_xen_l_obliterator_weak_macro" amount="1" />
The name is not the same that your turret, you should write : <component ref="turret_xen_l_obliterator_inv_weak_macro" amount="1" />


From what I've seen, your bullet file looks good, and the ship's turret edit looks good too.

I hope it works out for you
Starman01
Posts: 209
Joined: Wed, 20. Jun 07, 13:56
x4

Re: Modding help : Adding a new turret, please help me find the bug.

Post by Starman01 »

Hi Folker,

sorry for the later reply, but thank you very much for your answer and the time you put into it. So I asume the "index" is the part that I was missing (beside the typo). It's all a bit of a mess now since I changed all heavy xenon turrets, i will start over to make it more clean.

Just for understanding : "component" refers to a "physical" model, like the turret mount while the weapon macro just adds data, right ? In that case, i wouldn't need to change or add the components at all and just create a new weapon data and place it on the same component. I will sit through it all again and try.

Return to “X4: Foundations - Scripts and Modding”