Jump to content

Need help with simple mod using [contains(@name, 'x')] function


Recommended Posts

Hi all.

I'm trying to create a simple mod to set the value of SpreadMultiplierAiming to 0 for all guns. Instead of doing this by hardcoding each of the values for every weapon, I would like to use one of these "contains" functions to do it programmatically, and thus support any guns added from mods as well.

 

I know that this line will work for disabling crosshair on aiming for all guns:

<set xpath="/items/item[contains(@name, 'gun')]/property[contains(@name, 'CrosshairOnAim')]/@value">true</set>

 

I am trying to get the same functionality for work for "SpreadMultiplierAiming". The issue I'm having is that this value is nested within an effect_group, and I'm not sure what the syntax would look like here.

I have tried the following:

<set xpath="/items/item[contains(@name, 'gun')]/effect_group/passive_effect[contains(@name, 'SpreadMultiplierAiming')]/@value">0</set>

 

<set xpath="/items/item[contains(@name, 'gun')]/effect_group[contains(@name, 'gun')]/passive_effect[contains(@name, 'SpreadMultiplierAiming')]/@value">0</set>

 

But neither seem to work.

 

Any input would be appreciated!

Thanks😁

Link to comment
Share on other sites

I'm not sure if this is the way to do it or not, but all of my [contains] codes dont use the single quotes... example:
 

/lootcontainers/lootcontainer[contains(@loot_quality_template, qual)]


not sure if the single quotes are needed or not.. are you getting any xpath warnings saying its not appending or anything? seems to me the path is correct.

Also, if you aren't getting any messages about it not appending correctly, do the exportconfigs command and look into that. See if it's putting it in a weird spot or something like that.

  • Thanks 1
Link to comment
Share on other sites

7 hours ago, hiddenyak said:

Hi all.

I'm trying to create a simple mod to set the value of SpreadMultiplierAiming to 0 for all guns. Instead of doing this by hardcoding each of the values for every weapon, I would like to use one of these "contains" functions to do it programmatically, and thus support any guns added from mods as well.

 

I know that this line will work for disabling crosshair on aiming for all guns:


<set xpath="/items/item[contains(@name, 'gun')]/property[contains(@name, 'CrosshairOnAim')]/@value">true</set>

 

I am trying to get the same functionality for work for "SpreadMultiplierAiming". The issue I'm having is that this value is nested within an effect_group, and I'm not sure what the syntax would look like here.

I have tried the following:


<set xpath="/items/item[contains(@name, 'gun')]/effect_group/passive_effect[contains(@name, 'SpreadMultiplierAiming')]/@value">0</set>

 


<set xpath="/items/item[contains(@name, 'gun')]/effect_group[contains(@name, 'gun')]/passive_effect[contains(@name, 'SpreadMultiplierAiming')]/@value">0</set>

 

But neither seem to work.

 

Any input would be appreciated!

Thanks😁

 

 

Either one will work. The second one will only target guns that have an "effect_group" with "gun" in the effect group's name, but as it so happens, that's true of all guns.

 

If you want to make sure you target that passive effect, no matter where it is in the XML, you can start with two slashes ("//"). That means "any node in the XML file." (Technically it means "any descendant of the current node" but 7D2D always starts at the root of the current XML document.)

 

You also don't need the "contains" function, because "SpreadMultiplierAiming" is the full name.

 

But - there are different operations on the spread multiplier. Some passive effects use "base_set", some use "perc_add", and so forth. You're setting all of those values to zero too.

 

This is what I'd do:

<set xpath="//passive_effect[@name='SpreadMultiplierAiming' and @operation='base_set']/@value">0</set>

 

To see if it worked, you can load up the game, go to the console (usually F1), and enter the command "exportcurrentconfigs". That will output the transformed XML files (the console will say where) and you can look at them by hand.

  • Like 1
Link to comment
Share on other sites

33 minutes ago, Telric said:

I'm not sure if this is the way to do it or not, but all of my [contains] codes dont use the single quotes... example:
 


/lootcontainers/lootcontainer[contains(@loot_quality_template, qual)]


not sure if the single quotes are needed or not.. are you getting any xpath warnings saying its not appending or anything? seems to me the path is correct.

Also, if you aren't getting any messages about it not appending correctly, do the exportconfigs command and look into that. See if it's putting it in a weird spot or something like that.

Dude I accidentally had two mods with the same name!! I feel so silly. Thanks for your help it caused me to figure it out!

14 minutes ago, khzmusik said:

 

 

Either one will work. The second one will only target guns that have an "effect_group" with "gun" in the effect group's name, but as it so happens, that's true of all guns.

 

If you want to make sure you target that passive effect, no matter where it is in the XML, you can start with two slashes ("//"). That means "any node in the XML file." (Technically it means "any descendant of the current node" but 7D2D always starts at the root of the current XML document.)

 

You also don't need the "contains" function, because "SpreadMultiplierAiming" is the full name.

 

But - there are different operations on the spread multiplier. Some passive effects use "base_set", some use "perc_add", and so forth. You're setting all of those values to zero too.

 

This is what I'd do:


<set xpath="//passive_effect[@name='SpreadMultiplierAiming' and @operation='base_set']/@value">0</set>

 

To see if it worked, you can load up the game, go to the console (usually F1), and enter the command "exportcurrentconfigs". That will output the transformed XML files (the console will say where) and you can look at them by hand.

Thank you so much man, this is so helpful for me ❤️❤️❤️ 

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...