How To Determine Amount of Spell Damage Mitigated by Immunity?

If a creature is immune to DAMAGE_TYPE_ELECTRICAL like a Shambling Mound, is there a way to know what amount of damage the creature would have taken, when a player casts an electrical spell on the Shambler?

Knowing what that damage would have been, would allow that damage amount to be reflected back to the player as DAMAGE_TYPE_ELECTRICAL. My searching skills must be pretty poor because I can find nothing on this. Is this possible to do?

No direct way. Possible workaround is to edit all electricity spells and store the outgoing damage on a target in local variable etc…

That’s what I was afraid of. Well, plan B then. I could add something to hit points or constitution for every electrical cast on the Shambler … and have those additions slowly bleed off over time. Thanks.