Jump to content

Help with Items.xml


Iceburg71

Recommended Posts

Ok. I wrote a mod (baby animals) and it works. But I am kind of a perfectionist and want things to be right. Namely, I don't want the baby animals having the same range of attack as their parents. A baby bear should NOT have the same reach as the mama bear.

 

I tried to do this once before and never got it to work right. Now I am back at it and I still can't get it to work. At this point I have basically cut and pasted code that works, but mine don't work!very frustrating.

 

Here is my Items.xml. I am currently ONLY working with one animal (baby bear) to get it to work.

 

Items.xml

 

<IceBurg>

<append xpath="/items">

 

<!-- Baby Boar Damage -->

<item name="meleeHandanimalIceburgBabyBoar">

<property name="Extends" value="meleeHandAnimalWolf">

<property class="Action0">

<property name="Range" value="1"/>

<property name="DamageEntity" value="10"/>

<property name="DamageBlock" value="12"/>

</property>

</property>

</item>

 

<!-- Baby Bear Damage -->

<item name="meleeHandanimalIceburgBabyBear">

<property name="Extends" value="meleeHandMaster">

<property name="CreativeMode" value="None"/>

<property name="HoldType" value="46"/>

<property class="Action0">

<property name="Delay" value="1.5"/> <!-- obsolete if rounds per minute exists -->

<property name="Range" value="1"/>

<property name="Sphere" value=".3"/>

<property name="DamageEntity" value="22"/>

<property name="DamageBlock" value="30"/>

<property name="Buff" value="buffInjuryBleedingZombie,buffInjuryStunned0 1"/>

</property>

<effect_group name="meleeHandAnimalBear" tiered="false">

<passive_effect name="ModSlots" operation="base_set" value="0"/>

<!--<passive_effect name="AttacksPerMinute" operation="base_set" value="40"/> A16 1.5 -->

<passive_effect name="BuffProcChance" operation="base_set" value=".75" tags="buffInjuryBleedingZombie"/>

<passive_effect name="BuffProcChance" operation="base_set" value=".4" tags="buffInjuryStunned01"/>

</effect_group>

</item>

 

<!-- Baby Wolf Damage -->

<item name="meleeHandanimalIceburgBabyWolf">

<property name="Extends" value="meleeHandAnimalWolf">

<property class="Action0">

<property name="Range" value="1"/>

<property name="DamageEntity" value="10"/>

<property name="DamageBlock" value="12"/>

</property>

</property>

</item>

 

<!-- Baby Coyote Damage -->

<item name="meleeHandanimalIceburgBabyCoyote">

<property name="Extends" value="meleeHandAnimalCoyote">

<property class="Action0">

<property name="Range" value="1"/>

<property name="DamageEntity" value="7"/>

<property name="DamageBlock" value="4"/>

</property>

</property>

</item>

 

<!-- Baby Mountain Lion Damage -->

<item name="meleeHandanimalIceburgBabyMountainLion">

<property name="Extends" value="meleeHandAnimalDireWolf">

<property class="Action0">

<property name="Range" value="1"/>

<property name="DamageEntity" value="16"/>

<property name="DamageBlock" value="21"/>

</property>

</property>

</item>

 

<!-- Baby Dire Wolf Damage -->

<item name="meleeHandanimalIceburgBabyDireWolf">

<property name="Extends" value="meleeHandAnimalDireWolf">

<property class="Action0">

<property name="Range" value="1"/>

<property name="DamageEntity" value="17"/>

<property name="DamageBlock" value="21"/>

</property>

</property>

</item>

 

<!-- Baby Zombie Dog Damage -->

<item name="meleeHandanimalIceburgBabyZombieDog">

<property name="Extends" value="meleeHandAnimalZombieDog">

<property class="Action0">

<property name="Range" value="1"/>

<property name="DamageEntity" value="6"/>

<property name="DamageBlock" value="10"/>

</property>

</property>

</item>

 

<!-- Baby Zombie Bear Damage -->

<item name="meleeHandanimalIceburgBabyZombieBear">

<property name="Extends" value="meleeHandAnimalZombieBear">

<property class="Action0">

<property name="Range" value="1"/>

<property name="DamageEntity" value="37"/>

<property name="DamageBlock" value="60"/>

</property>

</property>

</item>

 

<!-- Baby Snake Damage -->

<item name="meleeHandanimalIceburgBabySnake">

<property name="Extends" value="meleeHandAnimalSnake">

<property class="Action0">

<property name="Range" value="1"/>

<property name="DamageEntity" value="7"/>

<property name="DamageBlock" value="1"/>

</property>

</property>

</item>

 

</append>

</IceBurg>

 

 

 

and here is the error I am getting

 

 

2020-04-21T16:57:43 24.093 ERR XML loader: Loading XML patch file 'items.xml' from mod 'IceBurg_Baby_Animals' failed:

2020-04-21T16:57:43 24.093 EXC The 'property' start tag on line 17 position 5 does not match the end tag of 'item'. Line 34, position 5.

XmlException: The 'property' start tag on line 17 position 5 does not match the end tag of 'item'. Line 34, position 5.

at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) [0x00027] in <f9ec74c9799148aaa919695e2037e193>:0

at System.Xml.XmlTextReaderImpl.Throw (System.String res, System.String[] args) [0x00029] in <f9ec74c9799148aaa919695e2037e193>:0

at System.Xml.XmlTextReaderImpl.ThrowTagMismatch (System.Xml.XmlTextReaderImpl+NodeData startTag) [0x00086] in <f9ec74c9799148aaa919695e2037e193>:0

at System.Xml.XmlTextReaderImpl.ParseEndElement () [0x00085] in <f9ec74c9799148aaa919695e2037e193>:0

at System.Xml.XmlTextReaderImpl.ParseElementContent () [0x00149] in <f9ec74c9799148aaa919695e2037e193>:0

at System.Xml.XmlTextReaderImpl.Read () [0x00085] in <f9ec74c9799148aaa919695e2037e193>:0

at System.Xml.XmlLoader.LoadNode (System.Boolean skipOverWhitespace) [0x0025b] in <f9ec74c9799148aaa919695e2037e193>:0

at System.Xml.XmlLoader.LoadDocSequence (System.Xml.XmlDocument parentDoc) [0x0001b] in <f9ec74c9799148aaa919695e2037e193>:0

at System.Xml.XmlLoader.Load (System.Xml.XmlDocument doc, System.Xml.XmlReader reader, System.Boolean preserveWhitespace) [0x000b4] in <f9ec74c9799148aaa919695e2037e193>:0

at System.Xml.XmlDocument.Load (System.Xml.XmlReader reader) [0x0002e] in <f9ec74c9799148aaa919695e2037e193>:0

at System.Xml.XmlDocument.LoadXml (System.String xml) [0x00018] in <f9ec74c9799148aaa919695e2037e193>:0

at XmlFile.toXml (System.String _data, System.String _filename, System.Boolean _throwExc) [0x0002c] in <3ca2702590144b2c95bd610195728952>:0

at XmlFile..ctor (System.String _text, System.String _directory, System.String _filename, System.Boolean _throwExc) [0x00014] in <3ca2702590144b2c95bd610195728952>:0

at XmlPatcher+<LoadAndPatchConfig>d__0.MoveNext () [0x001af] in <3ca2702590144b2c95bd610195728952>: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)

 

 

 

Any help appreciated because I am baffled. I am doing exactly what others are doing (from what I can see) and it does NOT work.

 

Thanks

 

Link to comment
Share on other sites

Thanks xyth. that got it. Items.xml is now loading and everything seems to work. But I noticed something interesting. Look at the following 2 entries for Items.xml

 

 

<!-- Baby Bear Damage -->

<item name="meleeHandanimalIceburgBabyBear">

<property name="Extends" value="meleeHandMaster">

<property name="CreativeMode" value="None"/>

<property name="HoldType" value="46"/>

<property class="Action0">

<property name="Delay" value="1.5"/> <!-- obsolete if rounds per minute exists -->

<property name="Range" value="1"/>

<property name="Sphere" value=".3"/>

<property name="DamageEntity" value="22"/>

<property name="DamageBlock" value="30"/>

<property name="Buff" value="buffInjuryBleedingZombie,buffInjuryStunned0 1"/>

</property>

</property>

<effect_group name="meleeHandAnimalBear" tiered="false">

<passive_effect name="ModSlots" operation="base_set" value="0"/>

<!--<passive_effect name="AttacksPerMinute" operation="base_set" value="40"/> A16 1.5 -->

<passive_effect name="BuffProcChance" operation="base_set" value=".75" tags="buffInjuryBleedingZombie"/>

<passive_effect name="BuffProcChance" operation="base_set" value=".4" tags="buffInjuryStunned01"/>

</effect_group>

</item>

 

<!-- Baby Wolf Damage -->

<item name="meleeHandanimalIceburgBabyWolf">

<property name="Extends" value="meleeHandMaster"/>

<property name="CreativeMode" value="None"/>

<property name="HoldType" value="35"/>

<property class="Action0">

<property name="Delay" value=".6"/> <!-- obsolete if rounds per minute exists -->

<property name="Range" value="1"/>

<property name="DamageEntity" value="10"/>

<property name="DamageBlock" value="12"/>

<property name="Buff" value="buffInjuryBleedingZombie"/>

</property>

<effect_group name="meleeHandAnimalWolf" tiered="false">

<passive_effect name="ModSlots" operation="base_set" value="0"/>

<!--<passive_effect name="AttacksPerMinute" operation="base_set" value="85"/> A16 .7 -->

<passive_effect name="DamageModifier" operation="perc_add" value="3" tags="earth"/>

<passive_effect name="BuffProcChance" operation="base_set" value=".4" tags="buffInjuryBleedingZombie"/>

</effect_group>

</item>

 

 

 

The first one "<property name="Extends" value="meleeHandMaster">" does not have a trailing / character and requires the second </property> to close it out.

 

The Second one "<property name="Extends" value="meleeHandMaster"/> has the trailing / character and does NOT require the second </property> to close it out.

 

Items.xml loads correctly and everything seems to work. My question is, which way is correct, or better to do? Is anything getting missed by using or not using the trailing "/" character?

 

I know this mod is silly, but I keep tweaking it to learn more about modding since it is easy to see how the changes I make work in the game.

 

Thanks for all the education so far. It has been fun!

Link to comment
Share on other sites

Thanks xyth. that got it. Items.xml is now loading and everything seems to work. But I noticed something interesting. Look at the following 2 entries for Items.xml

 

 

<!-- Baby Bear Damage -->

<item name="meleeHandanimalIceburgBabyBear">

<property name="Extends" value="meleeHandMaster">

<property name="CreativeMode" value="None"/>

<property name="HoldType" value="46"/>

<property class="Action0">

<property name="Delay" value="1.5"/> <!-- obsolete if rounds per minute exists -->

<property name="Range" value="1"/>

<property name="Sphere" value=".3"/>

<property name="DamageEntity" value="22"/>

<property name="DamageBlock" value="30"/>

<property name="Buff" value="buffInjuryBleedingZombie,buffInjuryStunned0 1"/>

</property>

</property>

<effect_group name="meleeHandAnimalBear" tiered="false">

<passive_effect name="ModSlots" operation="base_set" value="0"/>

<!--<passive_effect name="AttacksPerMinute" operation="base_set" value="40"/> A16 1.5 -->

<passive_effect name="BuffProcChance" operation="base_set" value=".75" tags="buffInjuryBleedingZombie"/>

<passive_effect name="BuffProcChance" operation="base_set" value=".4" tags="buffInjuryStunned01"/>

</effect_group>

</item>

 

<!-- Baby Wolf Damage -->

<item name="meleeHandanimalIceburgBabyWolf">

<property name="Extends" value="meleeHandMaster"/>

<property name="CreativeMode" value="None"/>

<property name="HoldType" value="35"/>

<property class="Action0">

<property name="Delay" value=".6"/> <!-- obsolete if rounds per minute exists -->

<property name="Range" value="1"/>

<property name="DamageEntity" value="10"/>

<property name="DamageBlock" value="12"/>

<property name="Buff" value="buffInjuryBleedingZombie"/>

</property>

<effect_group name="meleeHandAnimalWolf" tiered="false">

<passive_effect name="ModSlots" operation="base_set" value="0"/>

<!--<passive_effect name="AttacksPerMinute" operation="base_set" value="85"/> A16 .7 -->

<passive_effect name="DamageModifier" operation="perc_add" value="3" tags="earth"/>

<passive_effect name="BuffProcChance" operation="base_set" value=".4" tags="buffInjuryBleedingZombie"/>

</effect_group>

</item>

 

 

 

The first one "<property name="Extends" value="meleeHandMaster">" does not have a trailing / character and requires the second </property> to close it out.

 

The Second one "<property name="Extends" value="meleeHandMaster"/> has the trailing / character and does NOT require the second </property> to close it out.

 

Items.xml loads correctly and everything seems to work. My question is, which way is correct, or better to do? Is anything getting missed by using or not using the trailing "/" character?

 

I know this mod is silly, but I keep tweaking it to learn more about modding since it is easy to see how the changes I make work in the game.

 

Thanks for all the education so far. It has been fun!

 

Take a look at the code in this picture. It's the same code, except this one is formatted, so it should give you a better idea of what's going on. Take a look at those two extends here. Do you see the difference now?

 

0HyfUvt.png

Link to comment
Share on other sites

To expand:

<property></property>

 

This syntax allows nested properties. In Mr.Devolvers example, the Action0 for each animal shows it well.

 

If you don't have any reason to use a nested property, the <property /> syntax is just a convenient shorthand, but in every respect the same as a <property></property> syntax that has no nested properties. I prefer using <property /> syntax whenever possible because it's shorter and imo easier to read. But either way is fine, it's just important that every tag is closed one way or the other.

Link to comment
Share on other sites

Ok. that is great info. Thanks. I guess the big question I have about all that then is there any functionality difference between the 2 ways presented in my partial .xml file?? Or another way of asking it... Is what I am trying to do considered a nested property? I am guessing the "action0" stuff is.

Link to comment
Share on other sites

I didn't look too closely to wat you were doing at first. There is definitely a difference between the two in your case. Technically both are validXML syntax, but that's not the same as being in a format 7D2D can understand. For background, XML is not unique to 7D2D, it's simply a way to store any arbitrary data in a consistent format. For instance:

<item name="meleeHandAnimalBear">
    <property name="Extends" value="meleeHandMaster"/>
    <property name="CreativeMode" value="None"/>
    <property name="HoldType" value="46"/>
    <property class="Action0">
       <property name="Delay" value="1.5"/> <!-- obsolete if rounds per minute exists -->
       <property name="Range" value="3.6"/>
       <property name="Sphere" value=".3"/>
       <property name="DamageEntity" value="30"/>
       <property name="DamageBlock" value="40"/>
       <property name="Buff" value="buffInjuryBleedingZombie,buffInjuryStunned0 1"/>
   </property>
   <effect_group name="meleeHandAnimalBear" tiered="false">
       <passive_effect name="ModSlots" operation="base_set" value="0"/>
       <!--<passive_effect name="AttacksPerMinute" operation="base_set" value="40"/> A16 1.5 -->
       <passive_effect name="BuffProcChance" operation="base_set" value=".75" tags="buffInjuryBleedingZombie"/>
       <passive_effect name="BuffProcChance" operation="base_set" value=".4" tags="buffInjuryStunned01"/>
   </effect_group>
</item>

 

This is valid XML. The rules for valid XML can be seen here: https://www.w3resource.com/xml/well-formed.php Notice there's no rules for what each tag can even be called. That's because whatever application is going to read the data, decides what format needs to be in for it to understand it. In this case, since it's directly from the base Items.xml file, this is also in the format that 7D2D needs it in. Now lets take a look and compare that to your Baby Bear:

 

 
[left][color=#9A9999][font=inherit]<!-- Baby Bear Damage -->[/font][/color]
[color=#9A9999][font=inherit]<item name="meleeHandanimalIceburgBabyBear">[/font][/color][/left]


[left]   [color=#9A9999][font=inherit]<property name="Extends" value="meleeHandMaster">[/font][/color][/left]


[left]        [color=#9A9999][font=inherit]<property name="CreativeMode" value="None"/>[/font][/color][/left]


[left]        [color=#9A9999][font=inherit]<property name="HoldType" value="46"/>[/font][/color][/left]


[left]        [color=#9A9999][font=inherit]<property class="Action0">[/font][/color][/left]


[left]            [color=#9A9999][font=inherit]<property name="Delay" value="1.5"/> <!-- obsolete if rounds per minute exists -->[/font][/color][/left]


[left]            [color=#9A9999][font=inherit]<property name="Range" value="1"/>[/font][/color][/left]


[left]            [color=#9A9999][font=inherit]<property name="Sphere" value=".3"/>[/font][/color][/left]


[left]            [color=#9A9999][font=inherit]<property name="DamageEntity" value="22"/>[/font][/color][/left]


[left]            [color=#9A9999][font=inherit]<property name="DamageBlock" value="30"/>[/font][/color][/left]


[left]            [color=#9A9999][font=inherit]<property name="Buff" value="buffInjuryBleedingZombie,buffInjuryStunned0 1"/>[/font][/color][/left]


[left]        [color=#9A9999][font=inherit]</property>[/font][/color][/left]


[left]    [color=#9A9999][font=inherit]</property>[/font][/color][/left]


[left]    [color=#9A9999][font=inherit]<effect_group name="meleeHandAnimalBear" tiered="false">[/font][/color][/left]


[left]        [color=#9A9999][font=inherit]<passive_effect name="ModSlots" operation="base_set" value="0"/>[/font][/color][/left]


[left]        [color=#9A9999][font=inherit]<!--<passive_effect name="AttacksPerMinute" operation="base_set" value="40"/> A16 1.5 -->[/font][/color][/left]


[left]        [color=#9A9999][font=inherit]<passive_effect name="BuffProcChance" operation="base_set" value=".75" tags="buffInjuryBleedingZombie"/>[/font][/color][/left]


[left]        [color=#9A9999][font=inherit]<passive_effect name="BuffProcChance" operation="base_set" value=".4" tags="buffInjuryStunned01"/>[/font][/color][/left]


[left]    [color=#9A9999][font=inherit]</effect_group>[/font][/color][/left]


[left][color=#9A9999][font=inherit]</item>

 

 

 

So lets talk about what's going to happen here. 7D[/font][/color] is going to come in, and load the data for your meleeHandanimalIceburgBabyBear from this file. It's going to pull up that "Extends" property for your meleeHandanimalIceburgBabyBear, see that it extends meleeHandMaster, and move on. Next (I actually have no idea the exact order it does these in, but that doesn't matter for our purposes) it will look for a property called "CreativeMode" belonging to your meleeHandanimalIceburgBabyBear. Here is where it will run into a problem, in your code, there is no "CreativeMode" property belonging to your meleeHandanimalIceburgBabyBear. Instead, the "CreativeMode" property in your code, is a property of the "Extends" property. The same problem will occur with each of the properties following in your code. Now, the reason it appears to work, is because of that "Extends" property. That's telling it to use this other item as a base item, so any properties it can't find in your new item, it will instead go get from the base item. [/left]

 

<item name="meleeHandMaster">
    <property name="Tags" value="blunt,melee,light,perkFlurryOfBlows"/>
   <property name="CreativeMode" value="None"/>
   <property name="HoldType" value="9"/>
   <property name="Material" value="Morganic"/>
   <property name="Canhold" value="false"/>
   <property name="Stacknumber" value="1"/>
   <property name="Candrop" value="false"/>
   <property class="Action0"><!-- AttackAction -->
       <property name="Class" value="Melee"/>
       <property name="Delay" value=".8"/> <!-- obsolete if rounds per minute exists -->
       <property name="Range" value="1.65"/> <!-- This not what "clientside melee combat" means. =) This is the adjustment afterwards due to code changes. -->
       <property name="Sphere" value=".1"/>
       <property name="Block_range" value="2.5"/>
       <property name="DamageEntity" value="10"/>
       <property name="DamageBlock" value="16"/>
       <property name="Sound_start" value="swoosh"/>
   </property>
   <effect_group name="meleeHandMaster" tiered="false">
       <passive_effect name="DamageFalloffRange" operation="base_set" value="1.65"/>
   </effect_group>
</item>
[/Code]

 
So it probably [i][b]appeared[/b][/i] to be working, because the values in meleeHandMaster are lower than the values in meleeHandAnimalBear. But it definitely isn't using those values you tried to set as is.
 
 
 
So now let's fix it! Delete the second </property> closing tag, and change the "Extends" Line to either:
[code]
[color=#9A9999][font=inherit]<property name="Extends" value="meleeHandMaster"></property>

Or

<property name="Extends" value="meleeHandMaster"/>

 

Those two examples are what I was talking about in my previous comment. Those two formats are 100% identical, but only because there is absolutely nothing else between the open and close tags of the first example. Anything in between the open and close tags is a child of the element it's inside of. But, because it's so incredibly common to have no children for an element, the second syntax was created as a shorthand. I would say it's the prefferred method anywhere possible, it's clean, and it helps prevent accidentally adding elements inside of another element. Of course, you can't make every line self close like that, for instance:

[/font][/color]
<item name="meleeHandMaster"/>
[color=#9A9999][font=inherit]

[/font][/color]

If we did that, the item wouldn't have any of the child properties it needs to describe it's behavior. Likewise with the "Action0" property, if that line self closed, it wouldn't have the "Delay" and other properties it needs to function.

 

 

Final note, I'm not sure what you're using to edit these xml files, but I highly recommend downloading Notepad++. Then inside Notepad++ hit Plugins->Plugin Admin..., and install XML Tools from there. Once Notepad++ reloads, open any XML file and hit Plugins->XML Tools->Pretty Print. That will format the code nicely for you, and automatically line up closing tags with indents like in Mr.Devolvers screenshot. After you make some changes, hit pretty print again, and it should help make it obvious if you're missing closing tags, or have put one in the wrong place.

 

 

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...