Skip to content

Caveat for GetDamageDealtByType

MelkiorMelkior Member Posts: 204
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.

Comments

  • DJ_WoWDJ_WoW Member Posts: 51
    Gooday to ya,

    I believe you can also get LastWeaponUsed() by the Damager instead of item slot.

    Thank you for your time,

    DJ-WoW
  • MelkiorMelkior Member Posts: 204
    I've never had occasion to use that command so I didn't know it even existed. TYVM for that comment. I learned something new!
  • ForSeriousForSerious Member Posts: 466
    Interesting. I needed something similar a few years ago. I remember it returning confusing results. Looking at my code now, I ended with just using DAMAGE_TYPE_BASE_WEAPON. It's probably fine for my situation since it would be unfavorable for a player to exploit my code by putting Flame Weapon on.
  • ForSeriousForSerious Member Posts: 466
    But also, in the original campaign, they use "if(GetDamageDealtByType(DAMAGE_TYPE_FIRE) > 0 && GetIsPC(oPC))" on the Plague Victim Pyre placeables and it works correctly.
  • MelkiorMelkior Member Posts: 204
    The pyre is supposed to only be set on fire if you "use" it while holding a torch or if you attack it with a spell which causes fire damage.
    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.
  • MelkiorMelkior Member Posts: 204
    I've just done a check in a test module. I've confirmed that GetDamageDealtByType will ONLY return either elemental damage or cumulative physical damage (DAMAGE_TYPE_BASE_WEAPON). None of the individual physical damage types return a valid value when you cause that damage type to the placeable object.

    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.
  • MelkiorMelkior Member Posts: 204
    Testing confirms, the physical damage types are not reported, even with zero damage resist.
  • ForSeriousForSerious Member Posts: 466
    My favorite exploit (because I found it myself), was using a weapon with fire damage on the pyres and getting 25 XP per hit until destruction. They have fixed that a long time ago.

    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.
Sign In or Register to comment.