This is just too much work for the user so I cannot really call it useful as a resource [resources are meant to be easy to use and implement]...
but if you'll make it as a tutorial, yes it will be useful...
Also since the damage is calculated when you select a unit, it will not update if the unit is not reselected... so if I for example add something that increases damage while keeping the unit selected, then the additional damage won't be included on the calculated damage... though I see it that the event included can be just a very simple sample of how to use the "system"
You can skip everything above and just read this as I think this is the important part
Instead of if-then-elses, you better just use arrays or hashes [using the unittypeid/rawcode] as key or index so that you can directly retrieve the data for the Damage per die etc without having to check the unit over and over again until you find a match...
the same thing for the items... instead of checking each slot for each type of item, the data should already be saved in a hash where the itemtypeid/rawcode is the key...
doing that would save you from lots of useless if-then-elses... I know it would require you to register everything at map init but that is better than having all those if-then-elses run every time the system is to calculate damage...
For the buff part, what if the buff only increases the base damage? If I'm correct, things like command aura [when increasing damage by %] only takes into account only the base damage [base in the OE + increases due to main attribute] and does not include item damage bonuses...
with the current set-up that would take a lot of work, and a lot of if-then-elses, but if you'll use arrays or hashes, it would be easy to do that...
So, the moral of the lesson? Make the unit and item data registered into the system at maybe map init... then for the calculations, just retrieve the saved data so that you will reduce the number of actions run everytime the system calculates damage...
If you need an example, take this scenario:
I have 100 items in the OE that boosts damage
When I calculate damage, the system will check each slot from 1 to 6 for every item registered into the system. Since there were 100 items registered, it will do the check 600 times just to calculate the total damage bonus from items... it will always run the same number of times without regard to the number of items I have in the inventory...
Now If I registered them first into a hash or an array, I only need 1 action to obtain the damage value of 1 item in my inventory... so 6 actions maximum since you can only have 6 items...
If you don't know how to use hashes or arrays, then learn how to use them...
nonetheless, this is better off as a tutorial than a resource because most of the things here are to be done by the user and there's only a few lines that are actually part of the core [only the calculation part really, all settings etc are to be done by the user]... for systems, the core is the important thing because that is the one that is designed by the creator of the system...