adding mp cost to weapon use

I have certain weapons that when equipped, should cost a little mp.

I have scripts that allow me to input damage formulas for my weapons but it lacks a feature for mp cost.

I have scripts that allow me to specify normal attack for the Actor, but doing this goes beyond what I need

and will only make it so that the actor, not the weapon uses a certain skill[iD].

Is there anything that I can use where I just plug in something like:

<mp> 3 </mp>

in a weapons tag?
What does it mean to use a weapon?
I simply mean to equip it and attack with it. I should have worded that differently. i can see why one might confuse using with consuming as if it were an item.
You can find any weapon attack replace script and change the related weapon's attack with a skill similar to the normal attack, but with MP cost.
You can find any weapon attack replace script and change the related weapon's attack with a skill similar to the normal attack, but with MP cost.
I had two scripts for this. But both gave me some sort of issue. The one I have now works the best, but it doesn't allow for mp cost.

Yanfly's made my loaded games crash because of how it is designed.
Use this.

Spoiler
Code:
module SHD  module REGEXP    ATTACK_ID = /<attack skill id: (\d+)>/i    ATTACK_ID_PRIO = /<attack skill id: (\d+), (\d+)>/i  endendclass RPG::BaseItem    def attack_id    load_notetags_define_attack_feat if @attack_id.nil?    @attack_id  end    def attack_id_priority    load_notetags_define_attack_feat if @attack_id_priority.nil?    @attack_id_priority  end    def load_notetags_define_attack_feat    @attack_id = 1    @attack_id_priority = 0    self.note.split(/[\r\n]+/).each do |line|      case line      when SHD::REGEXP::ATTACK_ID        @attack_id = $1.to_i        @attack_id_priority = 1      when SHD::REGEXP::ATTACK_ID_PRIO        @attack_id = $1.to_i        @attack_id_priority = $2.to_i      end    end  end  endclass Game_BattlerBase    alias :asiex_ft :attack_skill_id  def attack_skill_id    feature_objects.inject([asiex_ft, 0]) { |r, o|      o.attack_id_priority > r[1] ? [o.attack_id, o.attack_id_priority] : r    }[0]  end  end
max_by priority would probably be cleaner.
So, collect, add the default, and max_by?

Spoiler
Code:
module SHD  module REGEXP    ATTACK_ID = /<attack skill id: (\d+)>/i    ATTACK_ID_PRIO = /<attack skill id: (\d+), (\d+)>/i  endendclass RPG::BaseItem    def attack_id    load_notetags_define_attack_feat if @attack_id.nil?    @attack_id  end    def load_notetags_define_attack_feat    @attack_id = [1, 0]    self.note.split(/[\r\n]+/).each do |line|      case line      when SHD::REGEXP::ATTACK_ID        @attack_id[0] = $1.to_i        @attack_id[1] = 1      when SHD::REGEXP::ATTACK_ID_PRIO        @attack_id[0] = $1.to_i        @attack_id[1] = $2.to_i      end    end  end  endclass Game_BattlerBase    alias :asiex_ft :attack_skill_id  def attack_skill_id    (feature_objects.collect{|o| o.attack_id} << [asiex_ft, 0]).max_by{|e| e[1]}[0]  end  end
I was thinking just get the one with highest priority, and then figure out whether you want to return that, or the default attack skill.

Code:
alias :asiex_ft :attack_skill_iddef attack_skill_id  obj = feature_objects.max_by{|obj|obj.attack_id[1]}  obj.attack_id[1] > 0 ? asiex_ft[0] : obj.attack_id[0]end
But that's cause I typically find inject or fold operations in general to be kind of difficult to read since I don't use them very often.
@CWells - then just make sure to use a new game first instead of loading? if the game is still in development I don't really see any problems... plus there's the object reinitializer script that can help you with starting a loaded game just after you put yanfly's script
I will try the patch and reinstall Yanfly script first.

Nevermind that fix. It is bugged and removes armor upon load.

then just make sure to use a new game first instead of loading?
This isn't a short game. At some point a player will have to save. The game being incomplete now isn't the issue at all.

I think I have an idea. Maybe an ammo script will be of good use.
This isn't a short game. At some point a player will have to save. The game being incomplete now isn't the issue at all.
I am using that script and if the save file was created when the script is already there it doesn't error anymore... It only errors when you load a save that was created before the script was added... That is the normal behavior of most scripts that only write the data during object initialization... Which most of Yanfly's scripts does


That should be the way it works, unless it's actually a compatibility problem with another script...
I managed to work my way around it, thanks for the suggestions. I've decided on something I'm happy with and is consistent with my designing plan.

Original thread: https://forums.rpgmakerweb.com/threads/adding-mp-cost-to-weapon-use.25775/