[SOLVED] - XML Patching - Weapons

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

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

FurryFailure
Posts: 5
Joined: Thu, 28. Mar 19, 08:05
x4

[SOLVED] - XML Patching - Weapons

Post by FurryFailure »

I've been trying to make a simple mod to alter the damage values on Bolt Repeaters-after pulling my hair out since I'm new to this-I finally made some progress, everything so far is working well except for one thing, a missing property value from Bolt Repeaters, the "shield" value is not in the .xml for them, I'm wanting to add said value and lower it since I'm trying to make them exceptional against hull to mirror the Ion Blaster:

Code: Select all

File: bullet_gen_turret_m_gatling_01_mk1_macro.xml
Code:
<properties>
      <ammunition value="15" reload="1" />
      <bullet speed="2040" lifetime="1.3" amount="1" barrelamount="2" icon="weapon_gatling_mk1" timediff="0.018" angle="0.18" maxhits="2" ricochet="0.01" restitution="0.3" scale="0" attach="0" />
      <reload rate="10" />
      <damage value="16" repair="0" />
<other stuff>
</properties>
I'm trying to add the shield value to replicate this from a previous modding attempt before I knew about XML Patching:

Code: Select all

<damage value="48" shield="8" repair="0" />
I do know the "shield" value does exist in the game since the Ion Blasters have them:

Code: Select all

File: bullet_arg_m_ion_mk1_macro.xml
Code:
<properties>
      <bullet speed="2496" lifetime="1.85" amount="1" barrelamount="1" icon="weapon_ion_mk1" timediff="0.013" angle="0.13" maxhits="1" ricochet="0" scale="0" attach="0" />
      <heat value="190" />
      <reload rate="3" />
      <damage value="15" shield="228" repair="0" />
<other stuff>
</properties>
I have tried a couple of things such as

Code: Select all

<replace sel="//properties/damage/@shield">8</replace>
and
<add sel="//properties/damage/@shield">8</add>
I tried "replace" in the attempts to alter it since it may be a hidden value left out, but I just get an invalid node error in my debug file, obvious I know, but, I know coding can be like that, I then tried "add" to see if it'll add it but that isn't working either, can someone give me some pointers? I'm clearly not understanding the XML Patching guide too well ( viewtopic.php?t=354310 ).
My only guess so far is that I need to replace the entire <damage> line.. but I'm not too sure how to do that.. :?

This is my xml structure for Bolt Repeaters right now, it's the same for all the gatling bullet files, besides the obvious differences.

Code: Select all

File: bullet_gen_turret_m_gatling_01_mk1_macro.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<!--Exported by: Markus (192.168.3.123) at 04.02.2019_11-21-09-->
<diff>
	<replace sel="//properties/damage/@value">48</replace>
	<add sel="//properties/damage/@shield">8</add>
</diff>

<!--Original (Altered Reference from previous attempt, not Vanilla)
<macros>
  <macro name="bullet_gen_turret_m_gatling_01_mk1_macro" class="bullet">
    <component ref="bullet_gen_s_gatling_01_mk1" />
    <properties>
      <ammunition value="15" reload="1" />
      <bullet speed="2040" lifetime="1.3" amount="1" barrelamount="2" icon="weapon_gatling_mk1" timediff="0.018" angle="0.18" maxhits="2" ricochet="0.01" restitution="0.3" scale="0" attach="0" />
      <reload rate="10" />
      <damage value="48" shield="8" repair="0" />
      <effects>
        <impact ref="impact_gen_s_gatling_01_mk1" />
        <launch ref="muzzle_gen_s_gatling_01_mk1" />
      </effects>
      <weapon system="turret_shortrange" />
    </properties>
  </macro>
</macros>
-->
Edit: Updated title.
Last edited by FurryFailure on Mon, 1. Apr 19, 03:45, edited 2 times in total.
"It costs nothing to speak out, but remaining silent could cost everything" -V
Laptop Build: Manufacturer-MSI, Model-GF627RD, OS-Windows 10 Home 64bit, RAM-16GB DDR4, GPU-Nvidia GeForce 4GB GTX1050, CPU-Intel Core i7-7700HQ 2.80 GHz, Storage-128 SSD (OS) & 1TB HDD (Secondary).
Mysterial
Posts: 668
Joined: Wed, 6. Nov 02, 20:31
x4

Re: [HELP/INFO] - XML Patching - Damage Values

Post by Mysterial »

The way you add an attribute is:

Code: Select all

<add sel="//properties/damage" type="@shield">8</add>
FurryFailure
Posts: 5
Joined: Thu, 28. Mar 19, 08:05
x4

Re: [HELP/INFO] - XML Patching - Damage Values

Post by FurryFailure »

Mysterial wrote: Sat, 30. Mar 19, 23:19 The way you add an attribute is:

Code: Select all

<add sel="//properties/damage" type="@shield">8</add>
This did the trick, thanks, I knew it was something simple.
Some things I found out through doing this is quite interesting, I have to use a negative value for the "shield" attribute to reduce it in-game, adding the attribute doesn't simply reset it in-game, it just takes from the damage value as a flat number then modifies it thereafter, so if I increase the damage value it'll also increase the flat line of the shield value I guess you could say, which will require me to increase the negative value, so if the damage value is 100 and the shield value at 0, the shield damage will be 100, but, if I set the shield to -50 and increase the damage value to 150, the shield damage will then still be 100 while the hull damage will be 150 if that makes sense... atleast as far as I've found, I'm still messing with it, but these are my findings so far and I hope this helps anyone else in future.

That all being said and solved, I do have another question regarding attributes, I want to increase the engagement range, I do have a decent idea after brainstorming with a friend, but I'm not going to be home for a while so I figured I'd ask anyway and hopefully get an answer while I'm out, but, how would I go about increasing the range? my friend and I have an educated guess that it's a combination of Speed and Lifetime, given the game rounds it up to the nearest kilometre on the HUD, it'd make sense that it's the Lifetime value and is dependant on the speed to help balance it, the example my friend gave me is this:
[Lifetime of 2 seconds + Speed of 2,000m/s = traveling 2,000 metres per second for two seconds making it travel for 4,000 metres]
is this the right idea here?

Code: Select all

File:bullet_gen_s_gatling_01_mk2_macro.xml
Code:<bullet speed="2400" lifetime="1.25" amount="1" barrelamount="1" icon="weapon_gatling_mk2" timediff="0.018" angle="0.18" maxhits="2" ricochet="0.01" restitution="0.3" scale="0" attach="0" />
Using this code taking the equation into mind: [Traveling 2,400 metres per second for 1.25 seconds making it travel about 3,000 metres] which is roughly the engagement range of my Mark 2 Small Bolters, Is this correct?
"It costs nothing to speak out, but remaining silent could cost everything" -V
Laptop Build: Manufacturer-MSI, Model-GF627RD, OS-Windows 10 Home 64bit, RAM-16GB DDR4, GPU-Nvidia GeForce 4GB GTX1050, CPU-Intel Core i7-7700HQ 2.80 GHz, Storage-128 SSD (OS) & 1TB HDD (Secondary).
DeadAirRT
Posts: 1124
Joined: Fri, 25. Jan 19, 03:26
x4

Re: [HELP/INFO] - XML Patching - Damage Values

Post by DeadAirRT »

Your interpretation of speed/lifetime is correct for all weapons except beam. Beam is the only weapon that specifically has a range value.
User avatar
Shuulo
Posts: 1633
Joined: Mon, 14. Apr 08, 17:03
x4

Re: [HELP/INFO] - XML Patching - Damage Values

Post by Shuulo »

DeadAirRT wrote: Sun, 31. Mar 19, 06:51 Your interpretation of speed/lifetime is correct for all weapons except beam. Beam is the only weapon that specifically has a range value.
Beam without range parameter will use the same calculations for range as other weapons though.
FurryFailure
Posts: 5
Joined: Thu, 28. Mar 19, 08:05
x4

Re: [HELP/INFO] - XML Patching - Damage Values

Post by FurryFailure »

DeadAirRT wrote: Sun, 31. Mar 19, 06:51 Your interpretation of speed/lifetime is correct for all weapons except beam. Beam is the only weapon that specifically has a range value.
Awesome.

Thanks for the help and replies, I've finally got all the values I need to get this mod of mine working, just gotta tweak everything, I'll probably reuse this thread when I get around to posting it to save making a new one. :D
"It costs nothing to speak out, but remaining silent could cost everything" -V
Laptop Build: Manufacturer-MSI, Model-GF627RD, OS-Windows 10 Home 64bit, RAM-16GB DDR4, GPU-Nvidia GeForce 4GB GTX1050, CPU-Intel Core i7-7700HQ 2.80 GHz, Storage-128 SSD (OS) & 1TB HDD (Secondary).

Return to “X4: Foundations - Scripts and Modding”