constant weapontype WEAPON_TYPE_WHOKNOWS = ConvertWeaponType(0)
I've been considering this one, but there are some armor reductions that has the 2 same values; like Pierce has the same reduction against Normal and Large.You can write a function that clones a unit, forces it to attack a dummy (or a few), and calculates what the attack type must be based on the damage actually dealt... but it wouldn't be instant or perfectly accurate.
I don't really like this one. :/A better solution would probably be to precache all units' attack types in a hashtable. Store under the index [Rawcode of Unit-type] for each unit-type. Then load that data later when you want to know. attacktype, weapontype, and damagetype might not be valid objects to save in hashtables, in which case you should probably store the integers used for each *-type when they're defined.
Same as this.depending on how many units you have you could set variables (can be string, or you use an integer for each attack type) for each unit and check for that instead.
if a unit has two different attack types you can check also the attacked unit, wether it's flying, building, etc. and then determine it by that.
it's sort of a big one time effort though
That's why I said "attack a dummy (or a few)". This method would also be less accurate the larger range a unit's attack damage values has (I believe damage dice is the right phrase in the OE); a unit that does 11-11 damage will be easy to determine, but a unit that does 7-13 damage would be much more difficult/come with much greater uncertainty. If your damage range is large enough some reduction values would be within the uncertainty of your % reduction computation and then you couldn't even be sure the attack type you got was correct. Add to that, as I said, that this will take actual time to complete so it can't work as a function call or part of a larger trigger and you end up with a spectacularly awful way to tackle this question. Precache like UreDe4D and I suggested.there are some armor reductions that has the 2 same values
But maybe I could use the new function to set dice of the clones.This method would also be less accurate the larger range a unit's attack damage values has (I believe damage dice is the right phrase in the OE); a unit that does 11-11 damage will be easy to determine, but a unit that does 7-13 damage would be much more difficult/come with much greater uncertainty.
BlzSetUnitDiceSides(u, 1, 0)