Yeah, I am not wanting to store the value anywhere, be able to pull the value from the object and do some math on it at the same time as setting it.
I was able to figure out a better way to add my animals to the groups with some functions like this:
<append xpath="/entitygroups/entitygroup[descendant::entity[@name='animalDoe' and @prob='0.73']]">
<entity name="animalIceburgBabyDeer" prob="0.73" />
</append>
<append xpath="/entitygroups/entitygroup[descendant::entity[@name='animalDoe' and @prob='1']]">
<entity name="animalIceburgBabyDeer" prob="1" />
</append>
With this method, I just have to know what the probabilities are for the animalDoe (which is a quick search with notepad++), and this adds the BabyDeer in all the same spots as the "mom" in the entire entitygroups.xml file. If the probabilities change, it is a quick change and the mod is back in business. I don't care what the Funpimps do to any biome names, game stages, zombie groups, animal groups, etc. I just does not matter to me anymore with the way I am adding my entities to the entitygroups.xml file. VERY future proof.
The current mod I am working on is around 700 lines of XML. It includes (currently, but growing) about 30 entities. Each entity has between 8-12 attributes to set and that could change if the Funpimps decide to change the defaults on an entity. So doing the math on currently about 300 entries in the .xml file and saving it correctly with no typos is really becoming a chore. If I can find a way to automate the process using math, and being able to reference the current vanilla entity, then my life becomes a LOT easier and the chances of a change in the OEM code causing an issue becomes much less. Also reduces the chance of me releasing a mod with an error somewhere that I have to go back and fix.
I will keep poking around with it. May stumble across a way to do it.
Ah, targeting probabilities. I ran into this issue myself when trying to add custom zombies, and having their probabilities match those of existing zombies. I could not find a way to do it other than, basically, what you're doing now. It gets even more hairy when there are a ton of different possible probability values (like for zombieBoe).
In my case, I just looked for the most common probabilities, for each of the zombie types I was replacing, and matched those. For the rest I didn't worry about it and added a "midrange" probability value.
In your particular example, "animalDoe" only appears once in the entire file (in the "WildGameForest" group), so I wouldn't even worry about the probabilities for that one.
Personally, I also wouldn't try to be forward-compatible with future 7D2D alphas. You'll probably have to tweak it when a new alpha comes out, no matter what. As an example, look at the probabilities in the "EnemyAnimals" groups. Those have probabilities that are values like 10, 20, 30, 48... Before this alpha, TFP used probabilities between 0 and 1, so a previous mod would need to be updated anyway.
Also - about XPath - when I say "store" I don't mean "write to the XML." I mean "store in memory." You can't "pull the value from the object" because there's no place to pull it
to.
EDIT: Before this edit, I previously said something here about how XPath has no notion of numbers.
It turns out I was wrong. XPath actually does include functions that operate on numbers.
However - I have no idea if XPath,
as implemented in 7D2D, supports those functions.
Here's an example. Say you want to target probabilities between 0.2 and 0.3:
<insertAfter xpath="/entitygroups/entitygroup/entity[@name='animalDoe' and @prob >= 0.2 and @prob <= 0.3)]">
<entity name="animalIceburgBabyDeer" prob="2.5" />
</insertAfter>
As I said, I have no Earthly idea if those operators are supported in 7D2D. You could try it and find out.
EDIT 2: ...Thinking about it - 7D2D probably does not support these particular operators, because an XML parser will see ">" and think it's the end of the XML tag. But they do exist in XPath, so maybe TFP have some other function that is equivalent?
(I learned about these operators by examining documentation about XPath in general - but XPath is usually used in JavaScript, which is totally different.)