I was surprised to hear this doesn't exist yet, since it's a rather basic feature and needed for many ideas. If it's not too difficult, please consider adding it soon!
I'd like a new function in the faction XML to specify a list of resources that destroying an unit will give the attacker. If a value is specified, that amount of the resource is given, whereas specifying a percentage gives that amount from what the faction which owns it has. If specifying a negative value, the attacker would actually lose that resource when destroying an enemy building, although that would make little sense. A flag should specify if to also deduct that amount from the owner faction and how much, or if to just make those resources appear to the attacker. If the attacking faction does not use the resource or have where to store it, there's no effect. The function I have in mind would be something like this:
<resources-death><resource name, amount, loss/></resources-death>
Example 1: A faction has a building which can be looted of half of the resources it was build with. It costs 100 gold and 50 stone to build. When it comes to the gold, the owning faction will also lose half of what's being looted. Also, 5% of the faction's entire wood stock will be taken away entirely. The code would be:
<resource name="gold" amount="50" loss="50%"/>
<resource name="stone" amount="25" loss="0%"/>
<resource name="wood" amount="5%" loss="100%"/>
Example 2: The attacking faction uses an unique resource called X, which is optional and can only be extracted by destroying a certain building from another faction. That faction however doesn't use the X resource in any way itself. Implicitly, the resource can only be obtained if the attacker is playing against this faction so they have the building to destroy. The victim faction's building would have this code:
<resource name="X" amount="50" loss="0%"/>
Before anyone asks, yes, I'm aware this is already possible in Lua for scenarios. To properly do it as part of a faction however, it must also be possible within the XML files of units, otherwise it will not be consistent and won't work in normal battles.