Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Make weapons consume MP

Is there a way to make weapons actually use up MP so like a sword could use up 5 MP every time it is used and an ultimate axe of power uses 200 MP each turn.
Thanks :smile:
 
Code:
# Weapons Use MP (VX)

# By SephirothSpawn

 

class RPG::Weapon

  # weapon_id => mp_cost

  MP_Use = {}

  MP_Use.default = 0

  def mp_use

    return MP_Use[@id]

  end

end

 

class Game_Battler

  alias_method :seph_weaponsusemp_gmbtlr_madv, :make_attack_damage_value

  def make_attack_damage_value(attacker)

    make_attack_damage_value(attacker)

    if attacker.is_a?(Game_Actor)

      for weapon in attacker.weapons

        attacker.mp -= weapon.mp_use

      end

    end

  end

end

Insert in the materials section
 

Jason

Awesome Bro

Well I'd say you do something like this;

Code:
 

# Weapons Use MP (VX)

# By SephirothSpawn

 

class RPG::Weapon

  # weapon_id => mp_cost

  MP_Use = {1 => 5, 2 => 10}

  MP_Use.default = 0

  def mp_use

    return MP_Use[@id]

  end

end

 

class Game_Battler

  alias_method :seph_weaponsusemp_gmbtlr_madv, :make_attack_damage_value

  def make_attack_damage_value(attacker)

    make_attack_damage_value(attacker)

    if attacker.is_a?(Game_Actor)

      for weapon in attacker.weapons

        attacker.mp -= weapon.mp_use

      end

    end

  end

end

 

If you can see what I wrote after MP_Use;
# weapon_id => mp_cost
MP_Use = {1 => 5, 2 => 10}

So Weapon 1 in the database uses 5MP per attack, Weapon 2 in the database uses 10MP per attack.

Thats just a guess though I haven't even opened this and tried it, lol.
 
Thanks for clarifying that for me jbrist. I was on my way to work and didn't have time to clarify.

Luckily, if you have used one of my scripts, I use the same technique in all of them, so you learn to do this pretty quick.
 

Jason

Awesome Bro

SephirothSpawn":3ei5foql said:
Thanks for clarifying that for me jbrist. I was on my way to work and didn't have time to clarify.

Luckily, if you have used one of my scripts, I use the same technique in all of them, so you learn to do this pretty quick.

No problem lol, I just wish I could make arrays lol, I have no idea how to do them, and it'd make life so much easier.
 

Jason

Awesome Bro

Mr_Smith":1kecb9rb said:
And something you guys didnt say either, under that is the default MP cost, so if the weapon is not clarified in the thingy above it, it takes the MP cost from the default.

Yeah but that should be pretty self explanitory, or so I should think.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top