Jump to content

Video Tutorial : XPath Modding for Beginners.


Buggi

Recommended Posts

May I suggest you get this mod and make it do what you want. Most of the legwork is already done for you, unless you are just trying to learn.

 

Here

 

 

I think it is a good practice when working with loot to use insertAfter and Before. loot can be tricky sometimes.

 

This will insert after the last vanilla group and then after the last vanilla container, I used "249". I think 250 is max

<configs>
<insertAfter xpath="/lootcontainers/lootgroup[@name='BuriedStashChest']">
<lootgroup name="adminCoin" count="all">
   <item name="meleeBoneShiv" count="4"/>
   <item name="modArmorTripleStoragePocket" count="4"/>
   <item name="cntSecureStorageChest" count="4"/>  
</lootgroup>
</insertAfter>


<insertAfter xpath="/lootcontainers/lootcontainer[@id='116']">


<lootcontainer id="249" count="1" size="8,9" sound_open="UseActions/open_cardboard" sound_close="UseActions/close_cardboard" loot_quality_template="treasureTemplate" destroy_on_close="true">
<item group="adminCoin"/>
</lootcontainer>
</insertAfter>
</configs>

 

thank you for upselling your mods.

 

I've made this mod before, multiple times, and i havnt had this issue since the first time i made it. I dont remember how i fixed it then.

 

I've been modding for over 3 years now, not an expert like some other fantastic people here but, 1. I need more coding experience in gaming. 2. I want stuff on my server to be coded by me. 3. I want everything on my server to be exclusive. 4. I want to make sure the modlets I make are compatible with each other and if I build this overhaul out of modlets I know how to not create redundancies and conflicts. I've spent a week dividing up my planned 20 mods into non-conflicting modlets prior to coding them. and Ive put close to 24 hours into coding this single modlet because I pay attention to detail. lastly, this modlet is a template for 3 other similar mods for my server.

Link to comment
Share on other sites

I don't think he was upselling his mod at all (especially since it wasn't his mod), I think his advice is sound.

 

You can have all the experience in the world, but he's right... looking at other people's work is by far the best way to learn.

Link to comment
Share on other sites

I'm a big fan of yours and Valmods work and spend quite a bit of time referencing your code. Still rather write my own, at least for the experience and to make sure its doing what i want it to do. as i've said before, I've written this piece before. it worked beautifully. Then my teenage stepson got angry we said no and snuck into my office one night and deleted a ♥♥♥♥ ton of stuff off my computer, my 7dtd folder of mods being one of those things, among many programs and games. most of it was super easy to redownload, my modding folder wasnt so much.

Link to comment
Share on other sites

so i am getting this error

 

2019-03-25T23:13:02 62.173 ERR XML loader: Patching 'recipes.xml' from mod 'DW Mods - Dyes Mod' failed
2019-03-25T23:13:02 62.174 EXC XML.Patch (/append/recipe): Patch element does not have an 'xpath' attribute
Exception: XML.Patch (/append/recipe): Patch element does not have an 'xpath' attribute
 at XmlPatcher.singlePatch (.XmlFile _targetFile, System.Xml.XmlElement _patchElement, System.String _patchName) [0x00000] in <filename unknown>:0 
 at XmlPatcher.PatchXml (.XmlFile _xmlFile, .XmlFile _patchXml, System.String _patchName) [0x00000] in <filename unknown>:0 
 at XmlPatcher.LoadAndPatchConfig (System.String _configName) [0x00000] in <filename unknown>:0 
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
Logger:masterLogException(Exception)
Logger:Exception(Exception)
Log:Exception(Exception)
XmlPatcher:LoadAndPatchConfig(String)
<loadSingleXml>c__Iterator1:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

 

and my code looks like this

 

<?xml version="1.0" encoding="UTF-8" ?>

<!--recipes-->

<append xpath="/recipes">

blah blah blah

</append>

 

I copied and pasted the xpath code over from the items one for this mod and the items one has no errors. I've also ran the code through a validator, used ccleaner on my computer, validated the steam files, and started a brand new game. It still says the xpath file isnt coded. any ideas why?

Link to comment
Share on other sites

  • 1 month later...
  • 4 months later...

I haven't, been responding to most questions on my Discord.

 

And to respond to the first post on this page, he needs an xml tag wrapping the entire mod,

like this

<somenamehere>

<append...>

</append>

</somenamehere>

Link to comment
Share on other sites

  • 5 months later...
May I suggest you get this mod and make it do what you want. Most of the legwork is already done for you, unless you are just trying to learn.

 

Here

 

 

I think it is a good practice when working with loot to use insertAfter and Before. loot can be tricky sometimes.

 

This will insert after the last vanilla group and then after the last vanilla container, I used "249". I think 250 is max

<configs>
<insertAfter xpath="/lootcontainers/lootgroup[@name='BuriedStashChest']">
<lootgroup name="adminCoin" count="all">
<item name="meleeBoneShiv" count="4"/>
<item name="modArmorTripleStoragePocket" count="4"/>
<item name="cntSecureStorageChest" count="4"/>
</lootgroup>
</insertAfter>


<insertAfter xpath="/lootcontainers/lootcontainer[@id='116']">


<lootcontainer id="249" count="1" size="8,9" sound_open="UseActions/open_cardboard" sound_close="UseActions/close_cardboard" loot_quality_template="treasureTemplate" destroy_on_close="true">
<item group="adminCoin"/>
</lootcontainer>
</insertAfter>
</configs>

 

sadly this github is not longer available.

 

Link to comment
Share on other sites

somebody please refresh my memory because its been so long sine I've written xpath, am I missing something here?

 

 

<modSurvivorsKit>

 

 

<set xpath="/entity_classes/entity_class[@name=playerMale]/property[@name=ItemsOnEnterGame.GameModeSurvival]/@value">hitMe,meleeTorch,keystoneBlock,meleeToolSt oneAxeTazas</set>

<set xpath="/entity_classes/entity_class[@name=playerMale]/property[@name=ItemsOnEnterGame.GameModeSurvivalSP]/@value">hitMe,meleeTorch,keystoneBlock,meleeToolSt oneAxeTazas</set>

<set xpath="/entity_classes/entity_class[@name=playerMale]/property[@name=ItemsOnEnterGame.GameModeSurvivalMP]/@value">hitMe,meleetorch,keystoneBlock,meleeToolSt oneAxeTazas</set>

 

 

 

</modSurvivorsKit>

Link to comment
Share on other sites

I haven't, been responding to most questions on my Discord.

 

And to respond to the first post on this page, he needs an xml tag wrapping the entire mod,

like this

<somenamehere>

<append...>

</append>

</somenamehere>

 

discord? how might i findd you there?

 

Link to comment
Share on other sites

  • 4 months later...

Tutorial is still very valid, all the information on XPATH still applies. I updated the title and thumbnail of the video to reflect it applies to the game in general now not just a specific Alpha. And unless the devs dramatically change the system should apply for the foreseeable future.

Discord link in is the about page of my channel.

Link to comment
Share on other sites

Thank you for adding the video tutorial. I think I learn better by example using visual means with reading as extra support.

 

Just something very simple as it's all a bit of a blur in there while I learn the terminology, hierarchy, dependencies, and all manner of others.

 

Exploding Zombie Bones

These bones have replaced the crossbow stone bolt ammo and have also taken a little bit from the exploding crossbow bolts for good effect. I wanted to use chickens but I have no idea how to take the model over to the items. Using bones was much easier because it is already in the same items hierarchy for that area. In any case, Potassium Nitrate is found when harvesting rotten carcasses and those Zombie Bones could fit this context better :)

Following the tutorial, I could see how we can grab XPath code from one area and apply it to a mod.

 

A few (low quality resolution) pikkies to show the effect.

 

Spoiler

Load up your explosive bone.

 

20200818225539_1.thumb.jpg.d59429ae3139fcff400da4b62f397056.jpg

 

Take aim and fire.

 

20200818225553_1.thumb.jpg.30735ec7ecbfc2a2daf0cf5b2bf63046.jpg

 

Load up again.

 

20200818225558_1.thumb.jpg.e39f3a35faf73ffda51706317b50b169.jpg

 

It's over.

 

20200818225616_1.thumb.jpg.71f1e04e7f302b44289e13347f651e13.jpg

 

The impact is the same as high explosive bolts so very familiar.

 

20200818232448_1.thumb.jpg.53e8aec428d11e9d4f6e713a1bcd8f97.jpg

 

Here is the code if anyone is interested.

 

ModInfo.xml

<?xml version="1.0" encoding="UTF-8" ?>
<xml>
	<ModInfo>
		<Name value="Exploding Zombie Bones" />
		<Description value="XPath Modding for Beginners by Buggi  - Exploding zombie bones to replace stone bolts." />
		<Author value="arramus" />
		<Version value="A19" />
		<Website value="https://community.7daystodie.com/topic/9538-video-tutorial-xpath-modding-for-beginners/" />
	</ModInfo>
</xml>

Config/items.xml

<modtutorial>
	<append xpath="/items">
<item name="ammoCrossbowBoltStone">
	<property name="Tags" value="ammo,ranged,attAgility,perkArchery,perkPenetrator"/>
	<property name="DisplayType" value="ammoArrow"/>
	<property name="Meshfile" value="#Other/Items?Crafting/femur.fbx"/>
	<property name="HoldType" value="45"/>
	<property name="HandMeshfile" value="#Other/Items?Misc/sackPrefab.prefab"/>
	<property name="DropMeshfile" value="#Other/Items?Misc/sack_droppedPrefab.prefab"/>
	<property name="Material" value="Mwood"/>
	<property name="IsSticky" value="true"/>
	<property name="StickyOffset" value=".1"/>
	<property name="StickyColliderUp" value="2"/>
	<property name="StickyColliderRadius" value=".05"/>
	<property name="StickyColliderLength" value=".75"/>
	<property name="Stacknumber" value="150"/> <!-- STK ammo low -->
	<property name="FuelValue" value="8"/>
	<property name="EconomicValue" value="12"/>
	<property name="EconomicBundleSize" value="5"/>
	<property name="Group" value="Ammo/Weapons"/>
	<property class="Action1">
		<property name="Class" value="Projectile"/>
		<property name="Explosion.ParticleIndex" value="11"/>
		<property name="Gravity" value="-3"/>
		<property name="FlyTime" value="0"/>
		<property name="LifeTime" value="14"/>
		<!-- <property name="DamageBonus.earth" value="0"/>
		<property name="DamageBonus.metal" value="0"/>
		<property name="DamageBonus.cloth" value="0"/> -->
	</property>

	<effect_group name="ammoCrossbowBoltExploding" tiered="false"> <!-- ammoCrossbowBoltExploding -->
		<passive_effect name="EntityDamage" operation="base_set" value="65"/>
		<passive_effect name="BlockDamage" operation="base_set" value="1"/>
		<passive_effect name="DamageModifier" operation="perc_set" value=".1" tags="wood"/>
		<passive_effect name="DamageModifier" operation="perc_set" value="0" tags="earth,metal,cloth"/>
		<passive_effect name="ProjectileVelocity" operation="base_set" value="67.5"/>
	</effect_group>
</item>
	 </append>
</modtutorial>

The damage was lowered to 65 and this lets the zombies with higher 'health' recover while lower 'health' zombies are down in one shot.

 

Things I would like to do with this for the future are:

- Make harvesting carcass bones provide exploding bone ammo as standalone just like finding regular ammo.

- Make the bones align better in the crossbow.

- Add it for the bows.

- Tweak and balance. (Self damage, reduce damage for low level players, remove ability to use scope, etc.)

 

I did hit a chicken from 30 or so meters away and it was an obvious hit with the explosion. The chicken carcass remained intact for harvesting.

 

Once again, thanks again for the tutorial. I am actually only a little bit in as the introductory recipe section made me want to try something out.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...