Alright, let's do this!
So starting from the top, you want an ability that's like Rough Skin, but for sound moves instead of contact moves.
So, to start, let's take a look at the Rough Skin code
Code:
if (target.hasWorkingAbility(:ROUGHSKIN,true) ||
target.hasWorkingAbility(:IRONBARBS,true)) && !user.fainted?
if !user.hasWorkingAbility(:MAGICGUARD)
PBDebug.log("[Ability triggered] #{target.pbThis}'s #{PBAbilities.getName(target.ability)}")
@battle.scene.pbDamageAnimation(user,0)
user.pbReduceHP((user.totalhp/8).floor)
@battle.pbDisplay(_INTL("{1}'s {2} hurt {3}!",target.pbThis,
PBAbilities.getName(target.ability),user.pbThis(true)))
end
end
Now we want to reflect the damage already taken. (You didn't say anything about it but I also made Soundproof pokemon immune to this effect because it's an echo.)
Code:
if target.hasWorkingAbility(:ECHOSHIELD,true) && !user.fainted? && move.isSoundBased?
if !user.hasWorkingAbility(:MAGICGUARD) && !user.hasWorkingAbility(:SOUNDPROOF)
PBDebug.log("[Ability triggered] #{target.pbThis}'s #{PBAbilities.getName(target.ability)}")
@battle.scene.pbDamageAnimation(user,0)
user.pbReduceHP(damage)
@battle.pbDisplay(_INTL("{1}'s {2} hurt {3}!",target.pbThis,
PBAbilities.getName(target.ability),user.pbThis(true)))
end
end
But, we can't just put this code under Rough Skin, because the if block it's sitting in is for contact moves only. We can instead place it under ANGERPOINT because Anger Point is in the block that's just for moves that dealt damage, no contact necessary. (So below line 1477 should be good in a clean project.)