RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
(Resolved) Equipment that modifies MP costs

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 71
RMRK Junior
I'm looking for a script that can modify mp costs. the only one I've found was one that can make it an exact number, but what I'm looking for is one that can be change to a % (example: Cure costs 500 mp, if you have Chestguard of Reduced MP Usage equipped, it can make abilities cost 20% less MP, so cure would be 400mp)
Additionally, I'd also like to be able to modify mp costs by exact amounts (but not to exact amounts, like the other script allows already). Example: Fireball costs 100 mp, if you have GRAND MAGISTER'S EPIC ROBE OF AWESOMENESS equipped, it reduces all spell costs by 10, so fireball would cost 90.

as I have grown accustomed to the usage of note tags, I would prefer it be setup through usage of note tags.
Examples:
<MP cost -10%>
<MP cost -50>

IF possible, I would like it so if more than 1 item is equipped with a - MP cost effect, that they stack. For percentages, I would like all percentage reductions to be based on the base MP cost. EX: Cure costs 500. a ring reduces the cost by 10% (down to 450 mp) and a chest reduces it by 20% (down to 350mp, not 360)
« Last Edit: February 21, 2012, 01:16:18 AM by zerothedarklord »

**
Rep:
Level 62
RMRK Junior
The first we have to know is wich maker are you playing with.
The second, maybe we could modify your script without making a new one. So post it here, or say where you found it to check it.

***
Rep:
Level 71
RMRK Junior
it's VX.

Code: [Select]
MP1 = 2

module Flip
  def self.check_note_tags(obj, tag)
    obj.note.each_line { |notetag|
    case notetag
    when tag
      return true
    end
    }
    return false
  end
end


module RPG
  class BaseItem
    def mp1?
      if @mp1.nil?
        txt = Flip.check_note_tags(self, /<(?:mp1)>/i)
        @mp1 = txt
      end
      return @mp1
      end
  end
end

class Game_Actor
  def calc_mp_cost(skill)
    if equips.compact.any? {|equips| equips.mp1?}
      if skill.mp_cost == 0
        return skill.mp_cost
      else
        return MP1
      end
    elsif half_mp_cost
      return skill.mp_cost / 2
    else
      return skill.mp_cost
    end
  end
end

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Should work, not really tested.
Code: [Select]
# By Pacman (for zerothedarklord), 19/2/2012
# Use \mp_change[x] in an equip's notebox to increase MP costs by x (can be
# negative)
# Use \mp_percent[x] in an equip's notebox to alter MP costs by x%. I.e., if
# the note said \mp_percent[50], all skills will cost half as much MP.

module RPG
  class BaseItem
    def mp_change
      return unless self.is_a?(RPG::Armor) || self.is_a?(RPG::Weapon)
      return @mp_change if @mp_change
      @mp_change = self.note[/\\MP[_ ]?CHA?NGE?\[(\d+)\]/i].nil? ? 0 : $1.to_i
      return @mp_change
    end
    def mpp_change
      return unless self.is_a?(RPG::Armor) || self.is_a?(RPG::Weapon)
      return @mpp_change if @mpp_change
      @mpp_change = self.note[/\\MP[_ ]?PER(CENT)?\[(\d+)\]/i].nil? ? 100 :
       $1.to_i
      return @mpp_change
    end
  end
end

class Game_Actor < Game_Battler
  alias equip_mp_cost_calc calc_mp_cost
  def calc_mp_cost(skill, *a)
    orig = equip_mp_cost_calc(skill, *a)
    orig *= 2 if half_mp_cost
    equips.compact.each { |equip|
      orig += equip.mp_change
      orig = ((orig / 100).to_f * equip.mpp_change).to_i
    }
    orig /= 2 if half_mp_cost
    return orig
  end
end
« Last Edit: February 19, 2012, 08:10:55 PM by Pacman »
it's like a metaphor or something i don't know

***
Rep:
Level 71
RMRK Junior
it doesn't seem to be working, also, I wasn't specific, so just in case, this only modifies the equipped character's mp costs, right?

But yeah, I'm seeing no changes with either the specific change, or the % change.

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
EDITED.

TRY AGAIN.
it's like a metaphor or something i don't know

*
Rep:
Level 82
You should know testing is important in writing code, Pac. It still doesn't work properly.

Code: [Select]
equips.compact.each { |equip|
      orig += equip.mp_change
      orig = ((orig / 100).to_f * equip.mpp_change).to_i
    }

If I take out the mpp_change line, increasing the cost by 10 works fine. But with that line in, I end up with 0 MP cost because you're assigning the result of the formula to orig instead of changing the value of orig. So \mp_percent[10] will modify the MP Cost, but not \mp_change[10].

Also, .to_f doesn't work quite how you might be thinking. When you do the division of (orig / 100) it works it out as an int, because any numeric divided by an int gives an int (this is something I've run into many times so you aren't alone here). That int is then converted to a float, so you'll get:

Code: [Select]
#assume orig (original mp cost) is 5
5 / 100 = 0   # int / int = int
0.to_f = 0.0  # int to float
0.0 * mpp_change = 0.0 * 100 = 0.0 #float * int = float

So the resulting MP cost is 0. If the original MP cost was 150, then the final cost would be 100.

To force a floating point division you need to change the 100 (which is implicitly an int) to 100.0 (which is implicitly a float).

Just a couple of things to watch out for. Assigning when you don't mean to, and that .to_f doesn't quite work how you thought; it just converts the result of the calculation to a float number.

I'm sure you can make some quick fixes to make it work.
« Last Edit: February 20, 2012, 06:40:36 AM by LoganForrests »
(Why do I always feel like it's the end of the world and I'm the last man standing?)

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
:O
I know I should've tested it, but I was doing something last night... whatever it was, it was probably important.
Okay, I'm confident this works.
Code: [Select]
# By Pacman (for zerothedarklord), 20/2/2012
# Thanks LoganForrests for help with this ;o
# Use \mp_add[x] in an equip's notebox to increase MP costs by x
# Use \mp_sub[x] in an equip's notebox to decrease MP cost by x.
# Use \mp_per[x] in an equip's notebox to alter MP costs by x%. I.e., if
# the note said \mp_percent[50], all skills will cost half as much MP.

module RPG
  class BaseItem
    def mp_add
      return unless self.is_a?(RPG::Armor) || self.is_a?(RPG::Weapon)
      return @mp_add if @mp_add
      @mp_add = self.note[/\\MP[_ ]?ADD\[(\d+)\]/i].nil? ? 0 : $1.to_i
      return @mp_add
    end
    def mp_subtract
      return unless self.is_a?(RPG::Armor) || self.is_a?(RPG::Weapon)
      return @mp_subtract if @mp_subtract
      @mp_subtract = self.note[/\\MP[_ ]?SUB\[(\d+)\]/i].nil? ? 0 : $1.to_i
      return @mp_subtract
    end
    def mpp_change
      return unless self.is_a?(RPG::Armor) || self.is_a?(RPG::Weapon)
      return @mpp_change if @mpp_change
      @mpp_change = 100
      if !self.note[/\\MP[_ ]?PER\[(\d+)\]/i].nil?
        @mpp_change = $1.to_i
      end
      return @mpp_change
    end
  end
end

class Game_Actor < Game_Battler
  alias equip_mp_cost_calc calc_mp_cost unless $@
  def calc_mp_cost(skill, *a)
    orig = equip_mp_cost_calc(skill, *a)
    orig *= 2 if half_mp_cost
    old = orig
    equips.compact.each { |equip|
      orig += equip.mp_add
      orig -= equip.mp_subtract
      orig *= equip.mpp_change
      orig /= 100.0
    }
    orig /= 2 if half_mp_cost
    return orig.to_i
  end
end
it's like a metaphor or something i don't know

***
Rep:
Level 71
RMRK Junior
Thanks a lot guys, now I just need to get that state stacking script goin. It works perfectly!