Caveat for GetDamageDealtByType
Melkior
Member Posts: 216
The GetDamageDealtByType function currently does NOT work correctly for the OnDamaged placeable object script.
This function allows you to specify a damage type and then it returns how much damage was done of that type of damage (with 0 equalling no damage due to resistance or saves and -1 equalling no damage of that type was even attempted).
With placeable objects, all of the physical damage types (bludgeoning, piercing or slashing) return -1 regardless of the damage type dealt or the weapon used. The only other damage type which I have fully tested is DAMAGE_TYPE_BASE_WEAPON which correctly returns how much base damage was done.
The only way to check the type of damage caused appears to be to use GetDamager to find the attacker and then use GetItemInSlot to find the weapon in their hand, so that you can find out what type of base damage that weapon type does.
There appears to be no way to check whether the blow was struck by the on-hand or off-hand weapon.
I'd appreciate it if someone who has access to edit the wiki would edit the GetDamageDealtByType description to document this limitation. I don't want yet another login+password pair just to make one edit.
This function allows you to specify a damage type and then it returns how much damage was done of that type of damage (with 0 equalling no damage due to resistance or saves and -1 equalling no damage of that type was even attempted).
With placeable objects, all of the physical damage types (bludgeoning, piercing or slashing) return -1 regardless of the damage type dealt or the weapon used. The only other damage type which I have fully tested is DAMAGE_TYPE_BASE_WEAPON which correctly returns how much base damage was done.
The only way to check the type of damage caused appears to be to use GetDamager to find the attacker and then use GetItemInSlot to find the weapon in their hand, so that you can find out what type of base damage that weapon type does.
There appears to be no way to check whether the blow was struck by the on-hand or off-hand weapon.
I'd appreciate it if someone who has access to edit the wiki would edit the GetDamageDealtByType description to document this limitation. I don't want yet another login+password pair just to make one edit.
0
Comments
I believe you can also get LastWeaponUsed() by the Damager instead of item slot.
Thank you for your time,
DJ-WoW
After checking how the scripts work on the pyre object, it looks like that script is only supposed to be triggered if the pyre is attacked by a fire spell, such as fireball. My guess is that it wouldn't work if you attacked the pyre with a physical weapon-in-hand which happened to have fire damage on it. Either that, or it ONLY works for fire damage because that was all that was needed to make the game work. I'd have to do some experiments to be sure, but I'm guessing that with the exception of DAMAGE_TYPE_BASE_WEAPON, the command only returns magic-caused damage, not physically caused damage.
The object which I used was the green, lying-flat boulder which checked all of the DAMAGE_TYPE_* values and then spoke how much damage each caused, if it was greater than zero.
The weapon which I used was a longsword which had added damage properties of 1d6 for all damage types, including all three physical damage types.
I have yet to check it to see if it works as expected on creatures. I presume it will, but I don't know for sure.
Now I'm wondering if it doesn't work for physical damage when the placeable object "absorbs" the damage due to damage resistance? I'll check that next and post an update.
This is bringing back to memory my testing. I agree. These are the same things I found—but I didn't test as thoroughly. I don't see why it would work correctly on creatures though.