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

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