Someone please help me with magic reflection of the enemy.

With the normal script, magic reflection deals the exactly same damage.
However, I want magic reflection logics to be like this:
If the skill formula is "a.mat * 4 - b.mdf * 2", I want that 'a.mat' (caster's mat) to be the enemy's mat and 'b.mdf' (target's mdf) to be the unit's mdf. Otherwise, allies are too weak at the reflection damage while enemies are too strong.

I found out that Scene_Battle script deals with magic reflection and counter attack.
#--------------------------------------------------------------------------
# ● =
#--------------------------------------------------------------------------
def invoke_counter_attack(target, item)
@log_window.display_counter(target, item)
attack_skill = $data_skills[target.attack_skill_id]
@subject.item_apply(target, attack_skill)
refresh_status
@log_window.display_action_results(@subject, attack_skill)
end
#--------------------------------------------------------------------------
# ● =
#--------------------------------------------------------------------------
def invoke_magic_reflection(target, item)
@log_window.display_reflection(target, item)
apply_item_effects(@subject, item)
end
I don't know how to edit them. Any helps?

Original thread: https://forums.rpgmakerweb.com/threads/someone-please-help-me-with-magic-reflection-of-the-enemy.147530/