Jump to content

XPath Modding Explanation Thread


sphereii

Recommended Posts

19 hours ago, ninjagranny said:

ok  - people who know more than I do - which is 99% of you

I have been fighting with trying to vary zombie xp without editing every  single zombie - tried this

<set xpath="/entity_classes/entity_class[contains(@name, 'zombie')]/property[contains(@name, 'ExperienceGain')]/@value">*.25</set>  

 

set all  occurrences of experiencegain on a zombie entity to  25% of what it was .

 

which "logically" should work as far as I understand BUT it doesnt  

 

please put me out of my misery before i smack my head through a wall  :)

XPath can only find nodes and values and allow changes to them; But it cannot read in the original value enough to do any kind of math on them, so your current path won't result in what you want done.

Link to comment
Share on other sites

27 minutes ago, sphereii said:

XPath can only find nodes and values and allow changes to them; But it cannot read in the original value enough to do any kind of math on them, so your current path won't result in what you want done.

 

Thank you  and  - ill go back to  doing it entity by entity  - and redo each time they change entity names  :) ah well

 

Rather interestingly -  my idea actually breaks the entire game  -  no zombies no animals and the traders is always locked and bounces you 

Im assuming then it sets all to *25  rather than multiplying it and  as zombieboe no longer exists all entities are removed 

Edited by ninjagranny
addition (see edit history)
Link to comment
Share on other sites

16 minutes ago, ninjagranny said:

 

Thank you  and  - ill go back to  doing it entity by entity  - and redo each time they change entity names  :) ah well

 

Rather interestingly -  my idea actually breaks the entire game  -  no zombies no animals and the traders is always locked and bounces you 

Im assuming then it sets all to *25  rather than multiplying it and  as zombieboe no longer exists all entities are removed 

The game is expecting a number, and you are giving it a string. It probably fails, on loading the rest of the entityclasses.xml.

 

Probably a pretty boring playthrough with just the player :)

Link to comment
Share on other sites

  • 2 weeks later...
On 8/24/2020 at 4:56 PM, Reckis said:

Potentially a stupid question here . . .

 

Does /append tell the program where to look for a new localization file?

As far as I know, you can use xpath only inside xml files, which means it cannot be used to alter Localization.txt, if that's what you're wondering.

 

...

 

Sphereii, is there any way to use xpath to edit a single value from a list of values inside value attribute?

 

Example:

 

Change this:

<property name="TEST" value="1,2,3"/>

 

to this:

<property name="TEST" value="1,2,10"/>

Edited by mr.devolver (see edit history)
Link to comment
Share on other sites

1 hour ago, mr.devolver said:

As far as I know, you can use xpath only inside xml files, which means it cannot be used to alter Localization.txt, if that's what you're wondering.

I disagree, I have seen other mod authors change the localization (i.e, changing the description of a perk or item) Unless I am way off base here . . . which I have to admit is entirely possible.

Link to comment
Share on other sites

2 hours ago, Reckis said:

I disagree, I have seen other mod authors change the localization (i.e, changing the description of a perk or item) Unless I am way off base here . . . which I have to admit is entirely possible.

I think localization changes via modlet will overwrite vanilla entries if they exist and will append if they dont.

Link to comment
Share on other sites

2 hours ago, Reckis said:

I disagree, I have seen other mod authors change the localization (i.e, changing the description of a perk or item) Unless I am way off base here . . . which I have to admit is entirely possible.

In Alpha 17, this was possible with my 7 Days to Die Mod Localization Loader script, not only you could add your own localizations to the base game localization files, but you could also change the existing ones, it would happen automatically depending on how you wrote your localization that was supposed to change the vanilla one, but devs were working on their own solution for Alpha 18 and perhaps improved it in Alpha 19. If and how is this particular type of modification possible in base game, I have no idea.

Edited by mr.devolver (see edit history)
Link to comment
Share on other sites

3 minutes ago, mr.devolver said:

In Alpha 17, this was possible with my 7 Days to Die Mod Localization Loader script, not only you could add your own localizations to the base game localization files, but you could also change the existing ones, it would happen automatically depending on how you wrote your localization that was supposed to change the vanilla one, but devs were working on their own solution for Alpha 18 and perhaps improved it in Alpha 19. If and how is this particular type of modification possible in base game, I have no idea.

Yes, localization file modifications can be pushed via modlet now and is supposed to even get pushed to clients on servers (A19) but haven't tested it out myself yet.

Link to comment
Share on other sites

2 minutes ago, Laz Man said:

Yes, localization file modifications can be pushed via modlet now and is supposed to even get pushed to clients on servers (A19) but haven't tested it out myself yet.

I haven't played with it that much yet either. In fact, it is only now that I created some actual mods that I learned how to create the actual localization file. Back when I wrote that script, I made it so that it was blindly following the general format most people used for their localizations to make it work. I'm surprised it actually worked well lol

Link to comment
Share on other sites

Trying to change when we get the warnings/debuffs on food, but can't get it to work,

<set xpath="/buffs/buff[@name='buffStatusCheck01']/triggered_effect'[@buff='buffStatusHungry01']/requirement[@name='StatComparePercCurrentToMax']/@value">.3</set>

gives an error about invalid token

Having too much of an headache today to figure out whats wrong >.<

Link to comment
Share on other sites

47 minutes ago, -Holo- said:

Trying to change when we get the warnings/debuffs on food, but can't get it to work,

<set xpath="/buffs/buff[@name='buffStatusCheck01']/triggered_effect'[@buff='buffStatusHungry01']/requirement[@name='StatComparePercCurrentToMax']/@value">.3</set>

gives an error about invalid token

Having too much of an headache today to figure out whats wrong >.<

You have a extra apostrophe after triggered_effect. 

Link to comment
Share on other sites

2 minutes ago, AnsontheToad said:

You have a extra apostrophe after triggered_effect. 

Geez. I think I need new glasses too.

Unfortunatly it did not apply but I managed a few moments of 'doh' and corrected the logic for the code and get it to work! \o/

<set xpath="/buffs/buff[@name='buffStatusCheck01']/effect_group/triggered_effect[@trigger='onSelfBuffUpdate' and @buff='buffStatusHungry01']/requirement[@name='StatComparePercCurrentToMax']/@value">.3</set>

Did the trick!

Link to comment
Share on other sites

  • 4 weeks later...

Hello everyone.  I'm new to modding, and xml coding altogether really.  I've been getting help from someone in direct messages and they provided me with a line of code that, in theory, will change shotgun ammo block damage versus wood blocks so that shotguns won't decimate entire buildings.  The line of code I was given is:
 

<set xpath="/items[@name='ammoShotgunShell']/effect_group[@name='ammoShotgunShell']/passive_effect[@name='BlockDamage'][@value='20']/@value">5.4</set>

I tried it and it did not work.  No errors or warnings, so I'm guessing it loaded without issue.  I figured the value was still too high, since shotgun ammo damage is per pellet so I lowered it to .05.  Still kills 2+ wooden blocks per trigger pull.  Prior to trying the above line of code I had modded it myself using this code:

 

<append item name="ammoShotgunShell">
	<property name="Tags" value="ammo,shotgun"/>
	<property name="DisplayType" value="ammoShotgun"/>
	<property name="HoldType" value="45"/>
	<property name="Meshfile" value="#Other/Items?Misc/sackPrefab.prefab"/>
	<property name="DropMeshfile" value="#Other/Items?Misc/sack_droppedPrefab.prefab"/>
	<property name="Material" value="Mlead_scrap"/>
	<property name="Stacknumber" value="150"/> <!-- STK ammo low -->
	<property name="EconomicValue" value="11"/>
	<property name="Group" value="Ammo/Weapons"/>
	<effect_group name="ammoShotgunShell" tiered="false">
		<passive_effect name="EntityDamage" operation="base_set" value="11.2" tags="perkBoomstick"/>
		<passive_effect name="BlockDamage" operation="base_set" value="5.4" tags="perkBoomstick"/>
		<passive_effect name="BlockDamage" operation="base_add" value=".05" tags="wood"/>				<!-- This is the damage value I need to change -->
		<passive_effect name="RoundRayCount" operation="base_set" value="10" tags="perkBoomstick"/>
		<passive_effect name="TargetArmor" operation="perc_add" value=".4" tags="perkBoomstick"/><display_value name="dTargetArmor" value=".4"/>
		<passive_effect name="MaxRange" operation="base_set" value="10" tags="perkBoomstick"/>
		<passive_effect name="DamageFalloffRange" operation="base_set" value="5" tags="perkBoomstick"/>
		<passive_effect name="EntityPenetrationCount" operation="base_set" value="2" tags="perkBoomstick"/>
		<passive_effect name="BlockPenetrationFactor" operation="base_set" value="51" tags="perkBoomstick"/>
		<passive_effect name="SpreadDegreesVertical" operation="base_set" value="4.5" tags="perkBoomstick"/>
		<passive_effect name="SpreadDegreesHorizontal" operation="base_set" value="4.5" tags="perkBoomstick"/>
		<passive_effect name="SpreadMultiplierAiming" operation="perc_add" value="-.13" tags="perkBoomstick"/>
		<passive_effect name="SpreadMultiplierCrouching" operation="perc_add" value="-.05" tags="perkBoomstick"/>
		<passive_effect name="SpreadMultiplierWalking" operation="perc_add" value=".15" tags="perkBoomstick"/>
		<passive_effect name="SpreadMultiplierRunning" operation="perc_add" value=".3" tags="perkBoomstick"/>
		<passive_effect name="DamageModifier" operation="perc_add" value="-.8" tags="earth"/>
	</effect_group>
</append>

The above code worked perfectly, but after reading this thread I now know that the above code didn't actually overwrite the vanilla code, it just added a second instance of the ammoShotgunShell to the items.xml file.  

Does anyone know how to make the line of code that I was given work?  I would love to use that since it is simple, easy, and clean.  Please note that both versions of modifying the ammo were tested with Boomstick at max, with a Tier 6 Auto Shotgun with full attachments, and 7/7 shotgun messiah books.  I have asked the person who gave me the code for assistance as well, but I feel like I am asking him for too much help, so I figured I would ask you guys too.  

Thank you in advance.

Link to comment
Share on other sites

Ok guys, please disregard my previous posts.  With some trial and error, and some help from KhaineGB, I figured out how to make it work.  The main goal of my mod was simply to stop the shotguns from demolishing wooden buildings while raiding them.  That meant I needed a way to drastically lower the damage to wood.  Here is the code I came up with to make it work.

<!-- Line 1 changes the block damage of the shotgun ammo -->
<set xpath="/items/item[@name='ammoShotgunShell']/effect_group[@name='ammoShotgunShell']/passive_effect[@name='BlockDamage'][@value='5.4']/@value">1.5</set>
<!-- Line 2 removes the 3rd line of PASSIVE_EFFECT from the shotgun ammo.  Since the third line is the one that directly effects damage to wood -->
<remove xpath="/items/item[@name='ammoShotgunShell']/effect_group[@name='ammoShotgunShell']/passive_effect[3]"/>

I figured there is no need to change the value of the second line of block damage, since it only added more block damage if hitting a wood block, and I needed to reduce the damage to wood blocks, removing that line completely works even better.

 

Took me way too long to figure this one out, but I am happy that I stuck with it.

Link to comment
Share on other sites

Novice Question

Not sure if this is the right place for this....

How can I make this work? 

<triggered_effect trigger="onSelfHarvestBlock" action="ModifyCVar" cvar="X" operation="add" value="1"/>                 

<triggered_effect trigger="onSelfHarvestBlock" action="SetProgressionLevel" progression_name="perkDancing" level="@X"/>

I get an error: "ERR XML loader: Loading and parsing 'progression.xml' failed
FormatException: Input string was not in the correct format: nDigits == 0."

Link to comment
Share on other sites

Got what SHOULD be a quick and easy one for you guys.  Looking to have traders restock daily, since they say they get new stuff every day I figure its high time they actually do.  While I'm at it, since it's the Zombie Apocalypse, I figure the traders should have extended hours and be open 24 hours.  That said, does the following code look right to you guys?  I'm not at home and cannot test it right now.  Thanks.

 

<!-- Changing the reset interval for traders using OR. Trader IDs are 1 = Joel, 2 = Jen, 3 = Player Owned Vending Machine,
4 = World Spawn Vending Machine, 5 = Rented Vending Machine, 6 = Bob, 7 = Hugh, 8 = rekt. -->
<set xpath="traders/trader_info[@id='1' or @id='2' or @id='6' or @id='7' or @1d='8']/@reset_interval">1</set>

<!--  Remove Trader open and close times to make the trader stay open 24 hours. -->
<remove xpath="traders/trader_info[@id='1' or @id='2' or @id='6' or @id='7' or @id='8']/@close_time"/>
<remove xpath="traders/trader_info[@id='1' or @id='2' or @id='6' or @id='7' or @id='8']/@open_time"/>

 

P.S.

I already have these changes modded using individual lines for each trader, but I wanted to see if I could get it to work with the use of OR.  Thanks again!

Link to comment
Share on other sites

I'm not sure where to begin for the next thing I want to tweak.  If you guys might be able to point me in the right direction, I would appreciate it.  First, some quick backstory.

 

While raiding POIs I'll go from room to room doing my best to clear each room with stealth attacks.  With alpha 19 and 19.1 though, there are times when the zombies do not spawn until you are inside the room.  Its as though there spawn isn't being triggered when it should be.  This issue is especially prevalent when dropping into a room from the floor above.  For instance, I will use arrows to open the zombie cabinets and the cabinet will be empty.  The room containing the cabinet will not have any zombies in it either.  As soon as I land in the room, the zombies spawn.   Where would I start looking to modify this so that I can make sure the zombies spawn into a POI before I walk in?  Basically, I want the whole POI to spawn its zombie inhabitants all at once instead of room by room.  Or at the very least increase the distance that the spawn spot triggers at and spawns in the zombie.

Link to comment
Share on other sites

On 11/14/2018 at 4:46 PM, sphereii said:

<gamestage stage="64"> <spawn group="feralHordeStageGS54" num="21" maxAlive="8" duration="2" interval="38" /> <spawn group="feralHordeStageGS59" num="21" maxAlive="8" duration="2" /> <spawn group="feralHordeStageGS64" num="21" maxAlive="8" duration="2" /> <spawn group="ZombiesNight" num="65" maxAlive="1" /> </gamestage>

No longer the vanilla entry!

Link to comment
Share on other sites

Ok, need some help ironing out a couple of issues with a mod I created.  Basically, I made an item called SuperShades that combines all of the eyewear except the Night Vision Goggles into one set of glasses.  They work, I can get a pair through the creative menu, but nothing shows up on the display to tell you what stats they effect or by how much.  Also, the name that pops up in game when hovering over these shades is apparelsupershades instead of Super Shades.  Here is the code for it.  Would greatly appreciate any assistance with this.

<SuperShades>

<!-- Create NEW Super Shades!  In-Game icon will be the same as "Shades".  To be put in items.xml -->
<append xpath="items">
<item name="SuperShades">
	<property name="Extends" value="apparelShades"/>
	<property name="DisplayType" value="apparelSuperShades"/>
	<property name="CustomIcon" value="apparelShades"/>
	<property name="EconomicValue" value="1500"/>
	<property name="CustomIconTint" value="30,30,30"/>
	<property name="Tags" value="head,clothing,canHaveCosmetic,noMods"/>
	<property class="UMA">
		<property name="Overlay0Tint" value="30,30,30"/>
	</property>
	<effect_group tiered="false">
		<passive_effect name="ModSlots" operation="base_set" value="0"/>
		<passive_effect name="AttributeLevel" operation="base_add" value="1" tags="attIntellect"/>
		<display_value name="dIntellect" value="+1"/>
		<passive_effect name="AttributeLevel" tags="attFortitude" operation="base_add" value="1"/>
		<display_value name="dFortitude" value="+1"/>
		<passive_effect name="AttributeLevel" tags="attPerception" operation="base_add" value="1"/>
		<display_value name="dPerception" value="+1"/>
		<passive_effect name="AttributeLevel" tags="attAgility" operation="base_add" value="1"/>
		<display_value name="dAgility" value="+1"/>
		<passive_effect name="AttributeLevel" tags="attStrength" operation="base_add" value="1"/>
		<display_value name="dStrength" value="+1"/>
		<passive_effect name="CraftingTime" operation="perc_add" value="-.2"/>
		<passive_effect name="PlayerExpGain" operation="perc_add" value=".15"/>
		<display_value name="dCraftingTime" value="-.2"/>
		<display_value name="dPlayerExpGain" value=".15"/>
		<passive_effect name="LootGamestage" operation="base_add" value="3,5.2"/>
		<passive_effect name="TreasureBlocksPerReduction" operation="base_add" value="-1"/>
		<display_value name="dTreasureBlocksPerReduction" value="-1"/>
		<passive_effect name="BarteringBuying" operation="base_add" value=".2"/>
		<passive_effect name="BarteringSelling" operation="base_add" value=".2"/>
	</effect_group>
</item>
</append>

</SuperShades>

Second half of my issue is the loot.xml file I created to, in theory, allow the new shades to drop in game like the rest of the eyewear.  For that, I get an error code with the following xml file: 

<SuperShades>

<!-- Append loot.xml file to get new Super Shades to drop. Added New Super Shades to all loot groups where other eyewear is located.  Presuming that by dong this, the new Super Shades will have the same chance to drop as all other eyewear?  -->

<append xpath="/loot">
<lootgroup name="groupApparelFaceCover">
	<item name="apparelSuperShades" mods="dye" mod_chance="0"/>		<!-- Add Super Shades to groupApparelFaceCover lootgroup -->
</append>

<append xpath="/loot">
<lootgroup name="sportingGoods">
	<item name="apparelSuperShades" prob=".7"/>						<!-- Add Super Shades to sportingGoods lootgroup -->
</append>

<append xpath="/loot">
<lootgroup name="cothingTestLoot">
	<item name="apparelSuperShades" mods="dye" mod_chance="0"/>				<!-- Add Super Shades to clothingTestLoot lootgroup -->
</append>

</SuperShades>

The error states that the lootgroup on line 3 does not match the closing /append.  I tried changing line 3 to be <lootgroup name="groupApparelFaceCover"/> fixes the error, but I get three WRN messages, each one stating that the <append xpath="/loot"> was not applied.  I'm guessing I get 3 warning since I actually changed lines 3, 8, and 13 since I figured all 3 would error out.

Any help would be greatly appreciated.

Link to comment
Share on other sites

Don't know about your first issue, but your second one is about closing elements correctly, as the original error stated.  You need this kind of structure:

<append>

   <lootgroup>

      <item />  <--  this is a self-closing element.

   </lootgroup>  <-- this closes the lootgroup element, which you're missing

</append>

 

Link to comment
Share on other sites

18 hours ago, Ricowan said:

Don't know about your first issue, but your second one is about closing elements correctly, as the original error stated.  You need this kind of structure:

<append>

   <lootgroup>

      <item />  <--  this is a self-closing element.

   </lootgroup>  <-- this closes the lootgroup element, which you're missing

</append>

 

Thanks Ricowan, I noticed that shortly after I made this post.  I fixed the code to be:
 

<SuperShades>
<!-- Append loot.xml file to get new Super Shades to drop. Added New Super Shades to all loot groups where other eyewear is located.  Presuming that by dong this, the new Super Shades will have the same chance to drop as all other eyewear?  -->

<append xpath="/loot">
<lootgroup name="groupApparelFaceCover">
	<item name="apparelSuperShades" mods="dye" mod_chance="0"/>		<!-- Add Super Shades to groupApparelFaceCover lootgroup -->
</lootgroup>
</append>

<append xpath="/loot">
<lootgroup name="sportingGoods">
	<item name="apparelSuperShades" prob=".7"/>						<!-- Add Super Shades to sportingGoods lootgroup -->
</lootgroup>
</append>

<append xpath="/loot">
<lootgroup name="cothingTestLoot">
	<item name="apparelSuperShades" mods="dye" mod_chance="0"/>				<!-- Add Super Shades to clothingTestLoot lootgroup -->
</lootgroup>
</append>
</SuperShades>

No more errors, but now I get WRN on all three <append xpath="/loot"> lines of code and they do not get applied.  So it's "fixed" yet still not working.  I'll have to dig deeper into the loot.xml file of the vanilla game to try and figure out what I am doing wrong.  I have looked at other mod's xml files for similar stuff, but that's how I got to where we are right now. lmao

Thanks again for any help you all can offer.

 

Link to comment
Share on other sites

It looks like you're trying to add your new lootgroups to an element named "loot", but that doesn't exist in the loot.xml file.  The root node in that file is "lootcontainers".

What happens if you change <append xpath="/loot"> to <append xpath="/lootcontainers"> ?

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
×
×
  • Create New...