Sharing MP between Battlers

Was looking for a script that has all the battlers on each team share a "Team MP" resource. So that when one person on a team uses an ability that uses MP...it lowers everyone in that team's MP by that much.

Example:

Team of Billy, Kevin, Bob, and Joe

Kevin uses fireball on enemy 1 which costs 5mp....Billy, Kevin, Bob, and Joe ALL lose 5mp. I'm using the yanfly's instant cast script for spells...so the mp lost will be instant.

This also would apply for enemies as well.

Also would need all battlers (foe and ally) to restore all their mp at the beginning of each turn.

Think this could lead to more interesting battle systems for not just me but the community as well. 

Thank you in advanced for taking the time to look at this post.
free bump cause this could be very useful.
Please do not bump other people's topics, and in any case, you know the rule is 72 hours between bumps.
Here... just plug and play

Code:
module SHARED_MP    #Battle only?  BATTLE_ONLY = trueendclass Game_BattlerBase    alias pay_skill_cost_shared_mp pay_skill_cost  def pay_skill_cost(skill)    if (not SceneManager.scene_is?(Scene_Battle)) and SHARED_MP::BATTLE_ONLY      pay_skill_cost_shared_mp(skill)      return    end    x = skill_mp_cost(skill)    y = skill_tp_cost(skill)    if enemy?      $game_troop.members.each do |enemy|        enemy.mp -= x        enemy.tp -= y      end    elsif actor?      $game_party.battle_members.each do |act|        act.mp -= x        act.tp -= y      end    end  end  endclass Scene_Battle  alias turn_start_shared_mp turn_start  def turn_start    turn_start_shared_mp    unless $game_troop.nil?      $game_troop.members.each do |enemy|        p enemy.name        enemy.mp = enemy.mmp        enemy.tp = 100      end    end    $game_party.battle_members.each do |act|      act.mp = act.mmp      act.tp = 100    end  endend
Glad your interested in this as well Shingamix

Thankyou Engr. Shana for looking into this. I plugged this script into a new project and it didn't work. Do i need to tag skills with a certain script line?

Edit**

Oh never mind, it works perfectly! I forgot to save after adding the script /facepalm. Thank You Engr. Shana!
I'd love to use this some day. Thanks Shana

Original thread: https://forums.rpgmakerweb.com/threads/sharing-mp-between-battlers.22872/