Pimp Dreams from Modders

A couple more requests involving the "csv" XPath operator.

The requests:

  1. Add a "replace" operation that takes the text to replace as an attribute.
  2. Add an "insert" operation that takes a position as an attribute.

  • What are the use cases? Modifying any ordered, delimited list in either the "value" attribute or text of an XML tag. Examples using "AITask" are below.
  • Why would this change make it better? In addition to being easier to use, it also will make mods less likely to break with vanilla changes, and will allow mods to be compatible with each other.
  • Why is this better than other options? Using "csv", the only other option is to entirely replace the attribute or text. This means mods that operate on the same text are not compatible, and cannot be made compatible. It also means that they will not be able to get any changes from a new version of the game, and can break more easily.

Details: (Skip this if you're not interested)

With the switch from "pure" XML to plaintext delimiter-separated lists in the XML body, it is much harder now to surgically modify the content of those lists, and literally impossible if those lists are in order.

An example would be the EAI tasks and targets.

For reference, here's the EAI task list for the spider zombie:

<property name="AITask" value="
Leap|
BreakBlock|
DestroyArea|
Territorial|
ApproachDistraction|
ApproachAndAttackTarget class=EntityPlayer,0,EntityBandit,0,EntityEnemyAnimal|
ApproachSpot|
Look|
Wander|
"/>




Now, let's say that a modder wants the spider zombie to have an attack that is like the mutated zombie. So, they use the mutated zombie's "RangedAttackTarget" task. It should be after the "ApproachDistraction" task and before the "ApproachAndAttackTarget" task, like the mutated zombie.

The final EAI task list might look something like this:

<property name="AITask" value="
Leap|
BreakBlock|
DestroyArea|
Territorial|
ApproachDistraction|
RangedAttackTarget itemType=1;cooldown=4;duration=3;minRange=1;maxRange=6;unreachableRange=18|
ApproachAndAttackTarget class=EntityPlayer,0,EntityBandit,0,EntityEnemyAnimal|
ApproachSpot|
Look|
Wander|
" />




Currently, there is no way to do this via XPath without replacing the entire "AITask" value. But if we had an "insert" option, then they could do something like this:

<csv xpath="//entity_class[@name='zombieSpider']/property[@name='AITask']/@value" delim="|" op="insert" position="5" >
RangedAttackTarget itemType=1;cooldown=4;duration=3;minRange=1;maxRange=6;unreachableRange=18|
</csv>




Next, let's say a different modder wants to make the spider zombie attack all animals, and not just zombie dogs.

This would require substituting "EntityEnemyAnimal" with "EntityAnimal" in the "ApproachAndAttackTarget" list:

<property name="AITask" value="
Leap|
BreakBlock|
DestroyArea|
Territorial|
ApproachDistraction|
ApproachAndAttackTarget class=EntityPlayer,0,EntityBandit,0,EntityAnimal|
ApproachSpot|
Look|
Wander|
"/>




Also in this case, there is no way to do this via XPath without replacing the entire "AITask" value. So these two mods are not compatible and cannot be made compatible.

If we had a "replace" operation, they could do this:

<csv xpath="//entity_class[@name='zombieSpider']/property[@name='AITask']/@value" delim="|" op="replace" value="EntityEnemyAnimal">EntityAnimal</csv>




If the "replace" operation could allow wildcards (the same as the "del" operation), they could also do this:

<csv xpath="//entity_class[@name='zombieSpider']/property[@name='AITask']/@value" delim="|" op="replace" value="ApproachAndAttackTarget*">
ApproachAndAttackTarget class=EntityPlayer,0,EntityBandit,0,EntityAnimal|
</csv>




Hope that is clear.

Thanks!

 
Last edited by a moderator:
Back
Top