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

Custom Item Drop from Ore Block Not Working with Tool Tag

Hey, been a while since I messed with 7D2D modding, and I've ran into a roadblock and tried a lot of tests to make this work.
I am trying to make it so when mining Iron, Lead, Nitrate, Coal, and Oil, the player has a chance to get a custom item "itemResourceTest".
I specifically want this item to be gained from non-motor tools, so Stone Axe, Iron Pickaxe, Steel Pickaxe.
But also allowing motor tools (Auger) to have a small chance to get the custom item.

So I've made the tag "itemFromPickaxe" and "itemFromAuger"

My items.xml code looks like this:
XML:
<Configs>
    <!-- Add Custom Tag -->
    <append xpath="/items/item[@name='meleeToolRepairT0StoneAxe']/property[@name='Tags']" value=",itemFromPickaxe"/>
    <append xpath="/items/item[@name='meleeToolPickT1IronPickaxe']/property[@name='Tags']" value=",itemFromPickaxe"/>
    <append xpath="/items/item[@name='meleeToolPickT2SteelPickaxe']/property[@name='Tags']" value=",itemFromPickaxe"/>
    
    <!-- Custom Item -->
    <append xpath="/items">
        <item name="itemResourceTest">
            <property name="Extends" value="noteTestersDelightAdmin"/>
            <property name="CreativeMode" value="Player"/>
            <property name="CustomIcon" value="itemResourceTest"/>
            <property name="ItemTypeIcon" value="bundle"/>
            <property name="DescriptionKey" value="itemResourceTest_Desc"/>
            <property class="Action0">
                
                <property name="Random_item" value="resourceSilverNugget,resourceGoldNugget,resourceRawDiamond/>
                
                <property name="Random_item_count" value="1"/>
                <property name="Random_count" value="1"/>
                
                <property name="Unique_random_only" value="true"/>
            </property>
        </item>
    </append>
</Configs>


And my blocks.xml looks like this:
XML:
<Configs>
    <!-- Gained from Pickaxe -->
    <append xpath="blocks/block[@name='terrOreIron' or @name='terrOreLead' or @name='terrOreCoal' or @name='terrOrePotassiumNitrate' or @name='terrOreOilDeposit']">
        <drop event="Harvest" name="itemResourceTest" count="1" tag="itemFromPickaxe"/>
    </append>
</Configs>


I can somewhat confirm blocks.xml isnt the main issue because these work:
XML:
<Configs>
    <!-- Working -->
    <append xpath="blocks/block[@name='terrOreIron' or @name='terrOreLead' or @name='terrOreCoal' or @name='terrOrePotassiumNitrate' or @name='terrOreOilDeposit']">
        <drop event="Harvest" name="itemResourceTest" count="1" tag="oreWoodHarvest" />
    </append>
    
    <!-- Working -->
    <append xpath="blocks/block[@name='terrOreIron' or @name='terrOreLead' or @name='terrOreCoal' or @name='terrOrePotassiumNitrate' or @name='terrOreOilDeposit']">
        <drop event="Harvest" name="itemResourceTest" count="1" />
    </append>
</Configs>


I've also tried a few different methods for adding and testing the custom tag:
XML:
<Configs>
    <!-- Add tags to Minning Tools -->
    
    <!-- Doesnt work or doesnt work with Blocks.xml -->
    <!-- Attempt to add a tag to existing tags -->
    <!--
    <append xpath="/items/item[@name='meleeToolRepairT0StoneAxe']/property[@name='Tags']" value=",itemFromPickaxe"/>
    <append xpath="/items/item[@name='meleeToolPickT1IronPickaxe']/property[@name='Tags']" value=",itemFromPickaxe"/>
    <append xpath="/items/item[@name='meleeToolPickT2SteelPickaxe']/property[@name='Tags']" value=",itemFromPickaxe"/>
    -->
    
    <!-- Doesnt work or doesnt work with Blocks.xml -->
    <!-- Alternate Attempt to add a tag to existing tags -->
    <!--
    <append xpath="/items/item[@name='meleeToolRepairT0StoneAxe']/property[@name='Tags']/@value">
    ,itemFromPickaxe
    </append>
    <append xpath="/items/item[@name='meleeToolPickT1IronPickaxe']/property[@name='Tags']/@value">
    ,itemFromPickaxe
    </append>
    <append xpath="/items/item[@name='meleeToolPickT2SteelPickaxe']/property[@name='Tags']/@value">
    ,itemFromPickaxe
    </append>
    -->
    
    <!-- Doesnt work or doesnt work with Blocks.xml -->
    <!-- Recreate tags with custom tag included -->
    <!--
    <set xpath="/items/item[@name='meleeToolRepairT0StoneAxe']/property[@name='Tags']/@value">
        melee,grunting,medium,tool,longShaft,attStrength,perkMiner69r,perkMotherLode,miningTool,canHaveCosmetic,harvestingSkill,itemFromPickaxe
    </set>
    <set xpath="/items/item[@name='meleeToolPickT1IronPickaxe']/property[@name='Tags']/@value">
        melee,grunting,medium,tool,longShaft,attStrength,perkMiner69r,perkMotherLode,miningTool,canHaveCosmetic,harvestingSkill,itemFromPickaxe
    </set>
    <set xpath="/items/item[@name='meleeToolPickT2SteelPickaxe']/property[@name='Tags']/@value">
        melee,grunting,medium,tool,longShaft,attStrength,perkMiner69r,perkMotherLode,miningTool,canHaveCosmetic,harvestingSkill,itemFromPickaxe
    </set>
    -->
</Configs>


So im thinking 2 issues:
ONE: The tag is not being properly added.
TWO: The game does NOT read from the weapon's tags you're holding while mining? Instead looks at character's tags / stats (When looking at vanila blocks.xml the tag "artOfMiningLuckyStrikeHarvest" works for harvesting silver, gold, diamonds. if applying that tag to custom item, it works)
 
It's your path code

at the end you should have [@name='Tags']/@value">,itemFromPickaxe</append>

or go with csv coding and it would look something like this (from my code as an example)

Code:
    <csv xpath="//item[@name='questRewardPipeMachineGunBundle']/property[@class]/property[@name='Create_item']/@value" delim="," op="add">ammo9mmBulletBall</csv>

ONE: The tag is not being properly added.
TWO: The game does NOT read from the weapon's tags you're holding while mining? Instead looks at character's tags / stats (When looking at vanila blocks.xml the tag "artOfMiningLuckyStrikeHarvest" works for harvesting silver, gold, diamonds. if applying that tag to custom item, it works)
Post automatically merged:

Here is another example from a mod I did a long time ago using append to add tags

Code:
    <append xpath="/items/item[@name='gunShotgunT0PipeShotgun']/property[@name='Tags']/@value">,PipeShotgun,noMods</append>
 
Still having issues with the item.xml & tags method, even trying your 2 options its still having issues not working.
So I decided to test an alternate method to see if its an issue with an Item's Tags communicating with Blocks / blocks.xml

So I made a progression.xml and tested this, which makes it work:
XML:
<Configs>
    <append xpath="/progression/perks">
        <perk name="perkItemFromMining" parent="skillStrengthConstruction" name_key="perkItemFromMiningName" desc_key="perkItemFromMiningDesc" icon="ui_game_symbol_boxer">
            <!-- Perk's Effects -->
           
            <!-- functions properly -->
            <!-- Test 2 :: No perk level related stuff -->
            <effect_group name="bsg_item_from_mining_pickaxe">
                <requirement name="!ItemHasTags" tags="motorTool"/>
                <passive_effect name="HarvestCount" operation="base_set" value="1" tags="itemFromPickaxe"/>
            </effect_group>
           
           
            <!-- functions properly -->
            <!-- Test 1 :: Perk level related stuff -->
            <!-- NOTE :: Removed stuff like <level_requirements> and <effect_description> because Test 2 doesnt need that stuff -->
            <!--
            <effect_group name="bsg_item_from_mining_pickaxe">
                <requirement name="!ItemHasTags" tags="motorTool"/>
                <passive_effect name="HarvestCount" operation="base_set" level="0,1,2,3,4,5" value="1,1,1,1,1,1" tags="itemFromPickaxe"/>
            </effect_group>
            -->
        </perk>
    </append>
</Configs>


Also here is the attempts from your suggestion:
XML Attempt:
XML:
<append xpath="/items/item[@name='meleeToolRepairT0StoneAxe']/property[@name='Tags']/@value">,unidGemstoneFromPickaxe</append>
    <append xpath="/items/item[@name='meleeToolPickT1IronPickaxe']/property[@name='Tags']/@value">,unidGemstoneFromPickaxe</append>
    <append xpath="/items/item[@name='meleeToolPickT2SteelPickaxe']/property[@name='Tags']/@value">,unidGemstoneFromPickaxe</append>


CVS Attempt:
XML:
<csv xpath="//item[@name='meleeToolRepairT0StoneAxe']/property[@name='Tags']/@value" delim="," op="add">unidGemstoneFromPickaxe</csv>
    <csv xpath="//item[@name='meleeToolPickT1IronPickaxe']/property[@name='Tags']/@value" delim="," op="add">unidGemstoneFromPickaxe</csv>
    <csv xpath="//item[@name='meleeToolPickT2SteelPickaxe']/property[@name='Tags']/@value" delim="," op="add">unidGemstoneFromPickaxe</csv>
 
You could try using a buff, something like:

<!--buffs.xml-->
<configs>
<append xpath="/buffs">
<!--give the player a buff. see append code below.
Buff will call a game event to give player item:
IF player is holding an item that has the tag 'itemFromPickaxe'
AND block being hit or destroyed has the tag 'giveItemFromPickaxe'
AND random change is positive.
-->
<buff name="buffItemFromPickaxe" hidden="true" remove_on_death="false">
<stack_type value="ignore"/>
<duration value="0"/>

<effect_group>
<requirement name="HoldingItemHasTags" tags="itemFromPickaxe"/>
<triggered_effect trigger="onSelfDamagedBlock" action="CallGameEvent" event="giveItemFromPickaxe" TriggerHasTags="dropFromPickaxe">
<requirement name="RandomRoll" seed_type="Random" min_max="0,100" operation="LTE" value="10"/></triggered_effect> <!--10% change for drop-->
<triggered_effect trigger="onSelfDestroyedBlock" action="CallGameEvent" event="giveItemFromPickaxe" TriggerHasTags="dropFromPickaxe">
<requirement name="RandomRoll" seed_type="Random" min_max="0,100" operation="LTE" value="20"/></triggered_effect> <!--20% change for drop-->
</effect_group>
</buffs>
</append>


<!--add the buffItemFromPickaxe on startup if player doesn't already have it-->
<append xpath="/buffs/buff[@name='buffStatusCheck01']">
<effect_group>
<triggered_effect trigger="onSelfEnteredGame" action="AddBuff" buff="buffItemFromPickaxe">
<requirement name="!HasBuff" buff="buffItemFromPickaxe"/></triggered_effect>
</effect_group>
</append>
</configs>

<!--blocks.xml-->
<configs>
<!--add the tag 'dropFromPickaxe' to the ores so that TriggerHasTags works-->
<append xpath="blocks/block[@name='terrOreIron' or @name='terrOreLead' or @name='terrOreCoal' or @name='terrOrePotassiumNitrate' or @name='terrOreOilDeposit']/property[@name='Tags']/@value">,dropFromPickaxe</append>
</configs>

<!--gameevents.xml-->
<configs>
<append xpath="/gameevents">
<!--action sequence to give player the item 'itemResourceTest'
AND some xp
-->
<action_sequence name="giveItemFromPickaxe">
<property name="action_type" value="Game"/>
<action class="AddItems">
<property name="added_items" value="itemResourceTest" />
<property name="added_item_counts" value="1" />
</action>
<action class="AddXP">
<property name="xp_amount" value="75" />
</action>
</action_sequence>
</append>
</configs>

cheers
 
Back
Top