Extra weapon slots, I think I am almost there....

The place to discuss scripting and game modifications for X Rebirth.

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

Post Reply
Dev disco
Posts: 33
Joined: Wed, 2. Dec 20, 16:35

Extra weapon slots, I think I am almost there....

Post by Dev disco » Mon, 8. Mar 21, 15:38

Hi,

I'd like to have my mining laser (for the loot boxes) AND heavy laser AND railgun installed (cue Queen "I want it all").
I am quite close, I feel, but run into problems when it comes to actually installing the guns at the vendor.

I created these files:

assets\units\player\unit_player_ship.xml

Code: Select all

  <add sel="/components/component[@name='unit_player_ship']/connections">
    <connection name="conn_primaryweapon_extrarail" tags="primary_slot weapon_extrarail ">
      <offset>
        <position x="2.073881" y="2.620501" z="0.1136742"/>
      </offset>
    </connection>
    <connection name="conn_primaryweapon_extrahvlaser" tags="primary_slot weapon_extrahvlaser ">
      <offset>
        <position x="-3.293781" y="-0.1444476" z="-2.879636"/>
      </offset>
    </connection>
  </add>
assets\units\player\macros\unit_player_ship_a_macro.xml (and the other 3)

Code: Select all

   <add sel="/macros/macro/properties/weapons">
    <slot ref="conn_primaryweapon_extrarail"/>
    <slot ref="conn_primaryweapon_extrahvlaser"/>
  </add>
  <replace sel="/macros/macro/properties/upgrades/upgrade[@upgrade='weapon_player_railgun_mk1_macro']">
    <upgrade upgrade="weapon_player_railgun_mk1_macro" tags="primary_slot weapon_extrarail" />
  </replace>
  <replace sel="/macros/macro/properties/upgrades/upgrade[@upgrade='weapon_player_beam_v2_macro']">
    <upgrade upgrade="weapon_player_beam_v2_macro" tags="primary_slot weapon_extrahvlaser" />
  </replace>
assets\props\WeaponSystems\props_wps_beam_v2_player (and a similar one for the railgun)

Code: Select all

	<replace sel="//connection[@name='ShipConnection01']">
		<connection name="ShipConnection01" tags="component  weapon_extrarail">
			<offset>
				<position x="2.49535E-07" y="-2.531064E-02" z="-2.861023E-06"/>
			</offset>
		</connection>
	</replace>
The following code was added to the saves, which seems ok as I didn't buy them yet.

Code: Select all

<weaponcycle>
<slot ref="conn_primaryweapon_extrahvlaser"/>
<slot ref="conn_primaryweapon_extrarail"/>
<cycle index="1" ref="weapon_player_impulse_mk2_macro"/>
</slot>
<slot ref="conn_primaryweapon_mg">
<cycle index="4" ref="weapon_player_machinegun_mk1_macro"/>
</slot>
[....]
The connection of the weapon itself doesn't appear either, which seems ok as well. I am talking about this type of connection:

Code: Select all

<connection connection="conn_primaryweapon_impuls">
<component class="playerweapon" macro="weapon_player_impulse_mk2_macro" connection="shipconnection" lastshottime="0" ammunition="-1" id="[0x104bd]">
<offset>
<position x="-3.294" y="-0.1191" z="-2.88"/>
</offset>
<render>
<parameter flags="32" value="1" owner="[0x104bd]" name="light" subname="scale4" type="glow">
<persistent start="0" duration="-1" value="1" target="1"/>
</parameter>
</render>
<shootcontroller class="playerprimary" starttime="67.9718" angle="0.0872665"/>
</component>
</connection>
When I go to the mechanic I see the new slots and the offered weapons appear in the right slot.
When I buy one the game stalls for a bit. If I open the trader again, the weapon had disappeared (they always have just one for sale), but the weapon isn't installed on my ship.
No weapon cycle entry in the savegame, nor the connection.
What do I miss?

User avatar
KrYcHokE
Posts: 259
Joined: Wed, 2. Dec 15, 13:15
x4

Re: Extra weapon slots, I think I am almost there....

Post by KrYcHokE » Mon, 8. Mar 21, 18:01

You can check how it done in my mod, i will say more when i get to my pc.

Dev disco
Posts: 33
Joined: Wed, 2. Dec 20, 16:35

Re: Extra weapon slots, I think I am almost there....

Post by Dev disco » Mon, 8. Mar 21, 20:13

I have to admit that I studied your mod and the HullRepairLaser one to figure it out up till this point.
As far as I can see I follow the required steps, with one twist: I don't add new guns, but use the ones already available.

Clownmug
Posts: 418
Joined: Wed, 11. Dec 13, 02:39
x4

Re: Extra weapon slots, I think I am almost there....

Post by Clownmug » Thu, 11. Mar 21, 04:30

Dev disco wrote:
Mon, 8. Mar 21, 15:38

The following code was added to the saves, which seems ok as I didn't buy them yet.

Code: Select all

<weaponcycle>
<slot ref="conn_primaryweapon_extrahvlaser"/>
<slot ref="conn_primaryweapon_extrarail"/>
<cycle index="1" ref="weapon_player_impulse_mk2_macro"/>
</slot>
<slot ref="conn_primaryweapon_mg">
<cycle index="4" ref="weapon_player_machinegun_mk1_macro"/>
</slot>
[....]
It looks like there's an extra forward slash at the end of line for the extrarail, don't know if that makes a difference.

Dev disco
Posts: 33
Joined: Wed, 2. Dec 20, 16:35

Re: Extra weapon slots, I think I am almost there....

Post by Dev disco » Thu, 11. Mar 21, 15:54

Thanks, but I bet that's my doing while posting the code and rearranging some bits for clarity.

For some reason the railgun seems to behave now, it's just the heavy laser that's causing me headaches.

I guess just the railgun in its own slot serves the purpose quite well, though. Testing now, will upload in the weekend.

Dev disco
Posts: 33
Joined: Wed, 2. Dec 20, 16:35

Re: Extra weapon slots, I think I am almost there....

Post by Dev disco » Sun, 14. Mar 21, 21:34

Hrmpfff... still not working, only when I force it in a game start things go as I planned.

dertien
Posts: 274
Joined: Tue, 22. Feb 05, 13:27
x2

Re: Extra weapon slots, I think I am almost there....

Post by dertien » Thu, 18. Mar 21, 07:36

A bit late to the party, but if you're still scratching your head over this...

Here is a mod that adds new drones to the game and new weapons - 4 repair drones and 2 repair lasers.

https://www.nexusmods.com/xrebirth/mods ... le_id=1739

The drones are buyable from the drone trader. I changed it a bit to my liking since I found the repair speed too OP and the mod is not fully working as it should since the repair drone shows up as an assassin drone when you access the remote operation menu.

I was able to put the correct name there, but I changed it also because

1) I didn't need the repair lasers - I have them on my modded Skunk - The Gladius Mod -
2) I wanted to have an extra way of repairing the ship via a remote controlled drone, and I don't see the point of 4 drones doing the same albeit a bit faster, so I removed all but the MK1 and gave it a decent repair speed, but not that much that it felt like a cheat.
3) In my ship file I added the following lines to the 0001-L044.xml file so the drone would show up as 'repair drone' in the list of drones on board:

Code: Select all

<t id="703">Beholder ROV</t>
 <t id="704">Repair ROV</t>
 <t id="705">The Repair ROV was developed for environments where a manned vehicle would be too cumbersome to fit or where operators' lives would be put at risk, like engine exhaust maintenance and repair. It comes in 4 different versions from the Mk1 up to the Mk4 with the latter having more potent repair abilities, but also coming with a heftier price tag. It can not resurrect wrecks, but it can repair modules, hulls and resore shields albeit slowly.</t>
I removed the mining laser from my Skunk Overhaul Mod.

So I guess the answer to your problem is, do for your guns what was done here for the drones :

If you look at the code in the MD folder:

You will find a file called: NPC_itemtrader.xml

in the lines of code you will find something like this:

Code: Select all

<set_value name="$IM_missileMacroList" exact="[
		[ware.spe_repair_mk1, 1, 2, 75],
		[ware.spe_drone_hacker_mk2, 1, 2, 5],
[ware.spe_drone_scanner_mk4, 1, 2, 5]]"/>
(I removed the repair mk2, mk3 and mk4 drones since I found that one drone type with a regen value of 50 will do and will not feel like cheating when you are resurrecting hulls from destroyed ships.) I also have on board my ship a selection of two repair lasers that go into slot 1, instead of the mining lasers. I found it a wiser choice to be able to repatch Cap ships instead of shooting rocks in to smaller rocks.

... and in the same folder you find setup.xml with the following code:

Code: Select all

[
                [
                    [ware.spe_drone_scanner_mk1, 4, 8, 100],
                    [ware.spe_drone_scanner_mk2, 2, 4, 50],
                    [ware.spe_drone_scanner_mk3, 1, 2, 25],
                    [ware.spe_drone_interceptor, 3, 7, 90],
                    [ware.spe_drone_hacker, 2, 6, 60],
                    [ware.spe_drone_demolition, 1, 5, 50],
                    [ware.spe_drone_shieldwall, 2, 6, 60],
                    [ware.spe_drone_shieldboost, 1, 5, 50],
                    [ware.drp_interceptor_mk1, 8, 18, 90],
                    [ware.drp_interceptor_mk2, 7, 16, 80],
                    [ware.drp_intrepid_mk1, 6, 14, 70],
                    [ware.drp_intrepid_mk2, 5, 12, 60],
                    [ware.drp_overrun_mk1, 4, 10, 50],
                    [ware.drp_overrun_mk2, 3, 8, 40],
		    [ware.spe_repair_mk1, 1, 2, 75],
                    [ware.spe_drone_hacker_mk2, 1, 2, 5],
                    [ware.spe_drone_scanner_mk4, 1, 2, 5]
                ]
            ]

Notice that on the bottom line where the scanner drone mk4 is, there is no comma behind the bracket. THIS is IMPORTANT if you add new lines to your setup.

I would say if you find the NPC xml file for the mechanic (the one above is the drone dealer) and you add your own wares to this list, they should show up where they should when you trade with the mechanic.

Hope this helps.

Here is the link to this mod that I changed to my liking:

https://www.mediafire.com/file/z3g3p9nj ... Z.rar/file

and here is the mod of my modified skunk that should work with 4.30

https://www.mediafire.com/file/srrsmzwg ... l.rar/file

Post Reply

Return to “X Rebirth - Scripts and Modding”