• Mods are now organized as resources. Use the Mods link above to browse for or submit a mod, tool, or prefab.

    The TFP Official Modding Forum Policy establishes the rules and guidelines for mod creators and mod users.

Changing a passive effect in an effect group?

The xpath tutorial on the wiki is semi-limited, though it goes into all kinds of logical operator detail, I simply want to change a value. I am trying to set the basic 9mm ammo to do 1 damage to blocks, not the default of 6.
Code:
<item name="ammo9mmBulletBall">
    <property name="Tags" value="ammo,ammo9mm"/>
    <property name="DisplayType" value="ammoBullet"/>
    <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="Mbrass"/>
    <property name="MeltTimePerUnit" value=".4"/>
    <property name="Stacknumber" value="300"/> <!-- STK ammo high -->
    <property name="EconomicValue" value="9"/>
    <property name="TraderStageTemplate" value="ammoTier1"/><!-- ammo9mmBulletBall -->
    <property name="Group" value="Ammo/Weapons,Ammo,Ranged Weapons"/>
    <property name="SoundPickup" value="bullets_grab"/>
    <property name="SoundPlace" value="bullets_place"/>

    <effect_group name="ammo9mmBulletBall" tiered="false">
        <passive_effect name="EntityDamage" operation="base_set" value="32" />
        <passive_effect name="BlockDamage" operation="base_set" value="6" />
        <passive_effect name="BlockDamage" operation="base_add" value="100" tags="barrelExplosive"/>
        <passive_effect name="DamageModifier" operation="perc_add" value="-.8" tags="earth"/>
        <passive_effect name="DamageModifier" operation="perc_add" value="2" tags="wood"/>
    </effect_group>
</item>
I kind of think this is the correct path, but there are to passive effects for "BlockDamage" and I have no clue how to tell it which one to use. I don't want to modify the 100 value for exploding barrels.
Code:
<set xpath="/items/item[@name='ammo9mmBulletBall']/effect_group[@name='ammo9mmBulletBall']/passive_effect[@name='BlockDamage']/@value">1</set>
What am I missing here?
 
That logical operator detail is what you want. This should work in this instance, using the 'and' operator, since there is only one BlockDamage-base_set pair.

<set xpath="/items/item[@name='ammo9mmBulletBall']/effect_group/passive_effect[(@name='BlockDamage') and (@operation='base_set')]/@value">1</set>
 
And I found a situation that I am not sure how to handle. I am working on a literally stupid mod to make guns, well, stupid, and I came across this on the 9mm pistol.
Code:
        <passive_effect name="EntityDamage" operation="base_add" value="5" tags="perkGunslinger"/> <!-- damage offset -->
        <passive_effect name="EntityDamage" operation="perc_add" value="-.02,.02" tags="perkGunslinger"/> <!-- random EntityDmg -->
        <passive_effect name="EntityDamage" operation="perc_add" value=".05,.25" tier="2,6" tags="perkGunslinger"/> <!-- tier bonus -->
How do I differentiate the two "perc_add" lines? They both are the same operation AND same tag. Same type of values for input too!
 
You can do something like this where you target specific values.
XML:
<set xpath="/items/item[@name='gunHandgunT0PipePistol']/effect_group/passive_effect[@name='EntityDamage'][@value='-4']/@value">-10</set>
 
Okay, but what if the devs change the value in an update? Is there a way to semi-future-proof it? Most of my modlets continued to work for the three years I was away due to the way I built them. Only two stopped due to UI changes. Is that not possible in this specific scenario?
 
Well, you could remove those EntityDamage nodes and then add them back with your changes, like

Code:
<remove xpath="/items/item[@name='gunHandgunT1Pistol']/effect_group/passive_effect[@name='EntityDamage']" />

<append xpath="/items/item[@name='gunHandgunT1Pistol']/effect_group">

        <passive_effect name="EntityDamage" operation="base_add" value="5" tags="perkGunslinger"/> <!-- damage offset -->
        <passive_effect name="EntityDamage" operation="perc_add" value="-.02,.02" tags="perkGunslinger"/> <!-- random EntityDmg -->
        <passive_effect name="EntityDamage" operation="perc_add" value=".05,.25" tier="2,6" tags="perkGunslinger"/> <!-- tier bonus -->

</append>

Edit: but then again, there might be other dev changes that you'd want to see. If you just go with the original idea it won't just work in a later update, but you will get an error message like "blahblahblah did not apply" meaning it could not match your xpath. That would lead you to the line with the error.
 
Back
Top