Jump to content

XPath Modding Explanation Thread


sphereii

Recommended Posts

Hi, I am really new to the modding. Is there any overview about valid tags, attributes, attribute names? Or do I have to go through all existing XML from TFP to check what can be used? Some kind of XSD?

Maybe sb here is able to help me.
I want to play around with action skills. E.g. using a pickaxe increases miner69 skill. In general it already works.

I took this as an example:
 

<effect_group>
  <passive_effect name="HarvestCount" operation="perc_add" level="1,5" value=".2,1" tags="oreWoodHarvest"/>
  <passive_effect name="PlayerExpGain" operation="perc_add" level="1,5" value="-.1,-.4" tags="Harvesting">
    <requirement name="HoldingItemHasTags" tags="perkMiner69r"/>
  </passive_effect>
  ...
</effect_group>

Increasing the XP for the action skill looks like this (just the trigger within the effect_group): 
 

<triggered_effect trigger="onSelfHarvestBlock" action="ModifyCVar" cvar="Miner69er_XP" operation="add" value="4">
  <requirement for stone axe />
</triggered_effect> 
<triggered_effect trigger="onSelfHarvestBlock" action="ModifyCVar" cvar="Miner69er_XP" operation="add" value="6">
  <requirement for iron axe />
</triggered_effect> 
<triggered_effect trigger="onSelfHarvestBlock" action="ModifyCVar" cvar="Miner69er_XP" operation="add" value="8">
  <requirement for steel axe />
</triggered_effect> 

I would like to check the 'TraderStageTemplate' property of an item  (baseTier0-3) to be able to give more XP for a steel axe than a stone axe.
How would I have to implement the <requirement tags to achieve this?
Is there any other requirement possible next to ItemHasTags and HoldingItemHasTags?

Link to comment
Share on other sites

33 minutes ago, Kugi said:

I would like to check the 'TraderStageTemplate' property of an item  (baseTier0-3) to be able to give more XP for a steel axe than a stone axe.
How would I have to implement the <requirement tags to achieve this?
Is there any other requirement possible next to ItemHasTags and HoldingItemHasTags?

 

You are on the right path, but I think you are looking at it from the wrong end.  Instead of looking to have different requirements, look into adding custom tags for the items.

 

Change

 

<requirement name="HoldingItemHasTags" tags="perkMiner69r"/>

 

to something like this

 

<requirement name="HoldingItemHasTags" tags="BFTIronPickaxe"/>

 

and then add the new tag to the item in the items.xml file

 

<item name="meleeToolPickT1IronPickaxe">
    <property name="Tags" value="melee,grunting,medium,tool,longShaft,attStrength,perkMiner69r,perkMotherLode,miningTool,canHaveCosmetic,harvestingSkill,BFTIronPickaxe"/>

 

Link to comment
Share on other sites

Posted (edited)

This is what I also had in mind. But I wanted to avoid this as I would have to update all items for this (my idea was to sooner or later replace almost all skills by action skills). Going this way I also couldn't combine my mod with other mods which add new items/weapons.
But (thinking while typing) I could update all items at once using xpath - if I was able to add a new entry to the list of tags:

Do you know if this is possible? something like <add xpath="" ...

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

Posted (edited)

Another question (which probably also cannot be solved):
I would like to increase the amount of healing provided by a bandage/Medikit - bases on my current level of medic perk  and (more important) also relative to the base amount of healing the item gives.

This is happening within items.xml for medical bandage: 
 

<triggered_effect trigger="onSelfPrimaryActionEnd" action="ModifyCVar" cvar="medicalRegHealthAmount" operation="add" value="30"/>

 

If I now add the following to my medical perk, it works perfectly fine (add a value):

<effect_group>
  <requirement name="ItemHasTags" tags="medical"/>
  <triggered_effect trigger="onSelfPrimaryActionEnd" action="ModifyCVar" cvar="medicalRegHealthAmount" operation="add" value="@HealingMultiplier"/>
</effect_group>

But this adds the same amount of healing to all kind of medical stuff.
What I would like to do instead is this (multiply my facter * base value from the item):
 

<effect_group>
  <requirement name="ItemHasTags" tags="medical"/>
  <triggered_effect trigger="onSelfPrimaryActionEnd" action="ModifyCVar" cvar="medicalRegHealthAmount" operation="multiply" value="@HealingMultiplier"/>
</effect_group>

Unfortunately, this piece of code is being executed before the effect from the bandage has been applied. So, it is HealingFactor*0 (and afterwards + 30) = 30 instead of 30 * HealingFactor.

Is there any way to solve this other than editing all items manually by adding another tag again and checking this tag as a requirement?

Edited by Kugi
typo (see edit history)
Link to comment
Share on other sites

29 minutes ago, Kugi said:

Unfortunately, this piece of code is being executed before the effect from the bandage has been applied. So, it is HealingFactor*0 (and afterwards + 30) = 30 instead of 30 * HealingFactor.

Is there any way to solve this other than editing all items manually by adding another tag again and checking this tag as a requirement?

 

I'm no expert (so take this with a grain of salt as I don't know if this is the solution without trying it myself), but should the operation be perc_add instead of mutliply?  That is typically how it is setup to do either a percentage increase or decrease in a attritubute when you level up a perk (for example 10% reduction in time would be perc_add and the value -0.1)

 

As for the bandages, try using the tag stopsBleeding instead of medical.  That would only apply to bandages, first aid bandages, first aid kits, and sewing kits.  Since regular bandages and sewing kits don't have the heal ability incorporated into them, it wouldn't give them a heal bonus based on your perk level.

 

That is what I would try first if I was doing what you are trying to do.

Link to comment
Share on other sites

Posted (edited)

Unfortunately, perc_add operation cannot be used within <triggered_effect>.

 

But I found another solution which seems to work.

In my medic perk I set the healing factor like this:

<effect_group>
  <triggered_effect trigger="onSelfPrimaryActionEnd" action="ModifyCVar" cvar="HealingFactor" operation="set" value="@PerkHealingFactor"/>	
  <triggered_effect trigger="onSelfSecondaryActionEnd" target="other" action="ModifyCVar" cvar="HealingFactor" operation="set" value="@PerkHealingFactor"/>	
</effect_group>

And then I extend the buff which handles all healing stuff and apply my healing factor.

<append	 xpath="/buffs/buff[@name='buffHealHealth']">
<effect_group name="Apply Healing Factor from Perk">
  <triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="medicalRegHealthAmount" operation="multiply" value="@HealingFactor"/>
  <triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar=".healHealthAmountDisplay" operation="set" value="@medicalRegHealthAmount"/>
  <triggered_effect trigger="onSelfBuffRemove" action="ModifyCVar" cvar="HealingFactor" operation="set" value="1"/><!--not sure if this is needed-->
</effect_group>
</append>

At this point the medicalRegHealthAmount from the item was already set.
In Singleplayer it seems to work. But I need to check if this also works in multiplayer when healing others. 

Edited by Kugi
new insights (see edit history)
Link to comment
Share on other sites

Posted (edited)

Btw... is there any Discord Channel (or similar) where I could ask for help? I have lots of questions like 

Is there any trigger for lockpicking/opening a chest? Obviously none of the "onSelfXY" trigger works. 
Or: Is there any trigger for taking items out of a forge/workbench?

Or: When using a wrench to disassable an object: Is it possible to find out which object it is?

And I and don't want to spam all of them within this thread.

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

Hi, it's me again, struggeling.

 

Works (while harvesting a car):

<effect_group>
	<triggered_effect trigger="onSelfHarvestBlock" action="ShowToolbeltMessage" message="Harvest vehicle!"/>
</effect_group>

Also works (while shooting a zombie - no crawler):

<effect_group>
	<requirement name="EntityTagCompare" target="other" tags="walker"/>
	<triggered_effect trigger="onSelfDamagedOther" action="ShowToolbeltMessage" message="Hit Walking Zombie!"/>
</effect_group>

Doesn't work (while harvesting a car).

<effect_group>
	<requirement name="EntityTagCompare" target="other" tags="vehicle"/>
	<triggered_effect trigger="onSelfHarvestBlock" action="ShowToolbeltMessage" message="Harvest vehicle!"/>
</effect_group>

 

Any ideas on how to get the last one working?

Link to comment
Share on other sites

  • 1 month later...

Good evening,

 

I am just trying my hand at modding by tweaking some things, the video tutorials in the other threads have been helpful but pretty straightforward so far. However I'm kind of stumped with how to do the following:

 

I wanted to give an inherent nerd outfit buff specifically to any person who is using a skill magazine for a perk they've leveled up.

for example: when a person with N points in Salvage operations reads the Scrapping4Fun magazine, they get a [N * 10] % chance of getting double points, similar to how the nerd outfit gives that buff.

 

I obviously don't want to add a million different buffs, so instead I looked at the class magazines in the items.xml:

<item name="salvageToolsSkillMagazine">
	<property name="Tags" value="salvageToolsCSM,csm"/>
	<property name="Extends" value="masterSkillMagazine"/>
	<property name="CustomIcon" value="bookScrapping4Fun"/>
	<property name="DescriptionKey" value="salvageToolsSkillMagazineDesc"/>
	<property name="Unlocks" value="craftingSalvageTools"/>

	<effect_group tiered="false">
		<triggered_effect trigger="onSelfPrimaryActionEnd" action="AddProgressionLevel" progression_name="craftingSalvageTools" level="1"/> <!-- level="-1" sets a perk to max level -->
		<triggered_effect trigger="onSelfPrimaryActionEnd" action="GiveExp" exp="50"/>
		<triggered_effect trigger="onSelfPrimaryActionEnd" action="AddProgressionLevel" progression_name="craftingSalvageTools" level="1">
			<requirement name="HasBuff" buff="buffNerdOutfit"/>
			<requirement name="RandomRoll" seed_type="Random" min_max="0,100" operation="LTE" value="@$nerdOutfitSkillPointChance"/>
		</triggered_effect>
  </effect_group>

This is essentially saying, "when players clicks read, give them 1 point. Then, give them another point IF:

 (requirement HasBuff) - They have a nerd outfit on

 (requirement RandomRoll) - they succeed a roll based on the quality of the outfit.

 

Can I add something very similar for what I want? I was thinking just appending to each of the skill magazines, right before the end of the </effect_group> end tag, but this is what I'm currently stuck at:

		<triggered_effect trigger="onSelfPrimaryActionEnd" action="AddProgressionLevel" progression_name="craftingSalvageTools" level="1">
			<requirement name="ProgressionLevel" progression_name="perkSalvageOperations" operation="GTE" value="1"/>
			<requirement name="RandomRoll" seed_type="Random" min_max="0,5" operation="LTE" value="@$perkSalvageOperations"/>
		</triggered_effect>

Does this ... look right at all? whats the best way I can essentially do the nerd outfit criteria, but instead make the requirements:

(requirement) - user has at least 1 pt in corresponding perk skill

(requirement) - succeed a roll based on level of the skill they have invested.

Link to comment
Share on other sites

  • 3 weeks later...

Good day friends, I have such a question - I want to completely rewrite the file biomes.xml how can I realize it? I understand that the command set - changes the current value of the string to your value, apend - adds and in principle through the command set can rewrite all the values for each biome, but I want to do remove biomes.xml and write a completely new biomes.xml

Link to comment
Share on other sites

1 hour ago, goldfantast said:

Good day friends, I have such a question - I want to completely rewrite the file biomes.xml how can I realize it? I understand that the command set - changes the current value of the string to your value, apend - adds and in principle through the command set can rewrite all the values for each biome, but I want to do remove biomes.xml and write a completely new biomes.xml

Use "<remove xpath=""">

 

You can remove anything, from a single line to the complete contents of a file, depending where you point the xpath at.

 

Explained on the first page

 

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

2 hours ago, goldfantast said:

Good day friends, I have such a question - I want to completely rewrite the file biomes.xml how can I realize it? I understand that the command set - changes the current value of the string to your value, apend - adds and in principle through the command set can rewrite all the values for each biome, but I want to do remove biomes.xml and write a completely new biomes.xml

 

Set can be used to change the entire value, Khaine did it in the past for Darkness Falls.  I believe it is something like:

<set xpath="/biomes">



your code here



</set>

 

Couple of things to bring up about doing it this way.

 

  • Using Set to change everything means that any mods you have that make the changes prior to your mod loading up will be erased
  • Mass changing everything means that updates by TFP in the future won't be captured until you update them yourself (even values that you don't modify for your likening).

 

Personally, I would never recommend changing the file this way because of the two reasons above.  I always use remove and set / append / insertAfter / insertBefore in a targeted manner.  That way if something else changes that I am not changing for my purpose. the game will implement those changes without me going back into my code to update those changes.  In addition, it makes it easier to me to make smaller changes down the road when something is not working out the way I want to and easier to located (I use comments in my mods when they start getting lengthy to find the areas I am specifically looking for), and more than likely my mods won't conflict with other mods if someone wants to use mine.

 

Another benefit about using a targeted approach is that I can comment out specific parts of my code to revert back to vanilla settings if I am on the fence on a change and wanting to try it again in vanilla.  Again, the targeted approach makes it easier to do this.

 

Link to comment
Share on other sites

A small modding question.
Are the biome's difficulty bonus display hardcoded? I changed the values on biomes.xml to make it so biome gamestage progression happens in increments of 1 and biome lootstage progression goes in .75, problem is, the game still shows half a skull in the burnt biome. 

I tried doing a wide search on the xmls for words like "biome" "bonus" "difficulty" "display" "skull" but nothing so far in the xui side of things. 
Am I overlooking something here?

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...