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.
Equips change Skill MP Cost (Couldn't think of a better name.)

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 82
Introduction
What this script does is, if you put <mp1> in the notebox of a weapon or armor, it'll make all skills (By default) use up only 1 MP, just like in Final Fantasy.
I based this off FlipelyFlip's MP cost 1 script, but his was pretty chunky, so I made my own based on that.


Script
NOTE: Uses Vampyr Kernel, can be found here.
Code: [Select]
#==============================================================================
# Vampyr Kernel 1.6 - 08/09/2010
#==============================================================================
# This module is necessary to activate and enhance compatibility of all Vampyr's Scripts
#------------------------------------------------------------------------------
module Vampyr_Kernel
 
  @print = false
 
  @scripts = {}
  @warnings = {}
 
  def self.register(script, version, date)
    @scripts[script] = [version, date]
  end
 
  def self.enabled?(script, version=nil)
    if @scripts.has_key?(script)
      if version.nil?
        return true
      elsif @scripts[script][0] >= version
        return true
      else
        if $TEST and @warnings[script] == nil and @print
          print "'#{script}' is obsolete.\r\nSome functions won't work correctly"
          @warnings[script] = ["is obsolete"]
          self.write_log
        end
        return false
      end
    else
      if $TEST and @warnings[script] == nil and @print
        print "Unable to find script '#{script}' or it is placed in wrong place.\r\nSome functions won't work correctly"
        @warnings[script] = ["Unable to find"]
        self.write_log
      end
      return false
    end
  end
 
  def self.show_scripts(alert=true)
    list = "Vampyr Scripts [#{@scripts.size}]:\r\n\r\n"
    @scripts.each { |key, value| list += "#{key.gsub("Vampyr ", "")}  #{value[0]}  #{value[1]}\r\n" }
    list += "\r\nWarnings:\r\n" if @warnings != {}
    @warnings.each { |key, value| list += "#{key} #{value}\r\n" }
    return print list if alert
    return list
  end
 
  def self.write_log
    file = File.new("Vampyr_Log-#{Time.now.strftime("%m_%d_%Y")}.txt", "wb")
    file.write(self.show_scripts(false))
    file.close
  end
 
end

#------------------------------------------------------------------------------
class Object
 
  def check(param)
    self.each_line { |i| return true if i =~ /#{param}/i }
    return false
  end
 
  def read(param, onfail=nil)   
    self.each_line { |i| return i.gsub("#{param} = ", "").chomp if i =~ /#{param} = /i }
    return onfail
  end
 
  def to_b
    return true if self =~ /true/i
    return true if self.to_i > 0
    return false
  end
 
  def getw
    bitmap = Bitmap.new(1, 1)
    width = bitmap.text_size(self.to_s).width
    bitmap.dispose
    return width
  end
 
  def to_rgb
    x = self.delete("#").scan(/../).map { |i| i.to_i(16) }
    return Color.new(x[0].to_f, x[1].to_f, x[2].to_f)
  end
 
  def number?
    return true unless self.scan(/\d/).empty?
    return false
  end
 
  def transform
    return self.to_i if self.number?
    return self.to_s
  end
 
end

#------------------------------------------------------------------------------
class Color
 
  def self.index(i)
    return Cache.system("Window").get_pixel(64+(i%8)*8, 96+(i/8)*8)
  end
 
  def self.get(x, y)
    return Cache.system("Window").get_pixel(x, y)
  end
 
end

#------------------------------------------------------------------------------
class Sprite
 
  def draw_icon(index, x, y, o=255)
    bitmap = Cache.system("Iconset")
    rect = Rect.new(index%16*24, index/16*24, 24, 24)
    self.bitmap.blt(x, y, bitmap, rect, o)
  end
 
  def draw_face(actor, x, y)
    char_name = actor.character_name
    char_index = actor.character_index
    bitmap = Cache.character(char_name)
    sign = char_name[/^[\!\$]./]
    if sign != nil and sign.include?('$')
      cw = bitmap.width / 3
      ch = bitmap.height / 4
    else
      cw = bitmap.width / 12
      ch = bitmap.height / 8
    end
    src_rect = Rect.new((char_index%4*3+1)*cw, (char_index/4*4)*ch, cw, 20)
    self.bitmap.blt(x, y+6, bitmap, src_rect)
  end
 
end

#------------------------------------------------------------------------------
class Bitmap
 
  def draw_outlined_text(*args)
    if args[0].is_a?(Rect)
      x = args[0].x
      y = args[0].y
      w = args[0].width
      h = args[0].height
      s = args[1]
      a = (args[2].nil? ? 0 : args[2])
    else
      x = args[0]; y = args[1]
      w = args[2]; h = args[3]
      s = args[4]
      a = (args[5].nil? ? 0 : args[5])
    end
    font.shadow = false
    color = font.color.clone
    font.color = Color.new(0,0,0)
    draw_text(x-1, y-1, w, h, s, a)
    draw_text(x+1, y-1, w, h, s, a)
    draw_text(x-1, y+1, w, h, s, a)
    draw_text(x+1, y+1, w, h, s, a)
    font.color = color
    draw_text(x, y, w, h, s, a)
  end
 
  def draw_icon(index, x, y, enabled=true)
    bitmap = Cache.system("Iconset")
    rect = Rect.new(index%16*24, index/16*24, 24, 24)
    blt(x, y, bitmap, rect, enabled ? 255 : 128)
  end
 
end

#------------------------------------------------------------------------------
class Game_Map
 
  def in_range?(object)
    return true if object.is_a?(Game_Event) and object.comment_exists?("Force Update")
    return false if object.real_x < (@display_x-(256*3))
    return false if object.real_x > (@display_x+((Graphics.width/32*256)+(256*3)))
    return false if object.real_y < (@display_y-(256*3))
    return false if object.real_y > (@display_y+((Graphics.height/32*256)+(256*3)))
    return true
  end
 
  def update_events
    for event in @events.values
      if in_range?(event) or event.trigger == 3 or
        event.trigger == 4 or event.comment_exists?("Forse Update")
        event.update
      end
    end
    for common_event in @common_events.values
      common_event.update
    end
  end
 
  def name
    return load_data("Data/MapInfos.rvdata")[@map_id].name
  end
 
  def map
    return @map
  end
 
end

#------------------------------------------------------------------------------
class Game_Character
 
  attr_accessor :character_name
  attr_accessor :character_index
  attr_accessor :move_type
  attr_accessor :move_route
  attr_accessor :direction_fix
  attr_accessor :walk_anime
  attr_accessor :step_anime
  attr_accessor :through
  attr_accessor :pattern
  attr_accessor :direction
  attr_accessor :bush_depth
  attr_accessor :blend_type
  attr_accessor :opacity
  attr_accessor :move_speed
  attr_accessor :priority_type
  attr_accessor :width
  attr_accessor :height
  attr_accessor :draw
  attr_accessor :destroy
 
  def in_range?(target, range)
    x = (@x - target.x) * (@x - target.x)
    y = (@y - target.y) * (@y - target.y)
    return true if (x + y) <= (range * range)
    return false
  end
 
  def in_front?(target)
    return true if @direction == 2 and @x == target.x and (@y+1) == target.y
    return true if @direction == 4 and (@x-1) == target.x and @y == target.y
    return true if @direction == 6 and (@x+1) == target.x and @y == target.y
    return true if @direction == 8 and @x == target.x and (@y-1) == target.y
    return false
  end
 
  def in_direction?(target)
    return true if @direction == 2 and target.y >= @y and target.x == @x
    return true if @direction == 4 and target.x <= @x and target.y == @y
    return true if @direction == 6 and target.x >= @x and target.y == @y
    return true if @direction == 8 and target.y <= @y and target.x == @x
    return false
  end
 
  def in_behind?(target)
    return true if @direction == 2 and @x == target.x and @y < target.y
    return true if @direction == 4 and @x > target.x and @y == target.y
    return true if @direction == 6 and @x < target.x and @y == target.y
    return true if @direction == 8 and @x == target.x and @y > target.y
    return false
  end
 
  def in_beside?(target)
    return true if target.direction == 2 and @direction == 4 and target.x == (@x-1) and target.y == @y
    return true if target.direction == 2 and @direction == 6 and target.x == (@x+1) and target.y == @y
    return true if target.direction == 4 and @direction == 2 and target.x == @x and target.y == (@y+1)
    return true if target.direction == 4 and @direction == 8 and target.x == @x and target.y == (@y-1)
    return true if target.direction == 6 and @direction == 2 and target.x == @x and target.y == (@y+1)
    return true if target.direction == 6 and @direction == 8 and target.x == @x and target.y == (@y-1)
    return true if target.direction == 8 and @direction == 4 and target.x == (@x-1) and target.y == @y
    return true if target.direction == 8 and @direction == 6 and target.x == (@x+1) and target.y == @y
    return false
  end
 
  def face_to_face?(target)
    return true if @direction == 2 and target.direction == 8
    return true if @direction == 4 and target.direction == 6
    return true if @direction == 6 and target.direction == 4
    return true if @direction == 8 and target.direction == 2
    return false
  end
 
  def step_back
    old_speed = @move_speed
    old_frequency = @move_frequency
    @move_speed = 6
    @move_frequency = 5
    move_backward
    @move_speed = old_speed
    @move_frequency = old_frequency
  end
 
  def over?(target)
    return true if @x == target.x and @y == target.y
    return false
  end
 
  def jump_to(x, y)
    xx = (x < @x ? -(@x-x) : x > @x ? x-@x : 0)
    yy = (y < @y ? -(@y-y) : y > @y ? y-@y : 0)
    jump(xx, yy)
  end
 
  def move_toward(*params)
    if params[0].is_a?(Numeric)
      x = params[0]
      y = params[1]
    else
      x = params[0].x
      y = params[0].y
    end
    sx = distance_x(x)
    sy = distance_y(y)
    if sx != 0 or sy != 0
      if sx.abs > sy.abs
        sx > 0 ? move_left : move_right
        if @move_failed and sy != 0
          sy > 0 ? move_up : move_down
        end
      else
        sy > 0 ? move_up : move_down
        if @move_failed and sx != 0
          sx > 0 ? move_left : move_right
        end
      end
    end
  end
 
  def move_type_toward(target)
    case rand(6)
      when 0..3; move_toward(target)
      when 4;    move_random
      when 5;    move_forward
    end
  end
 
  def move_away_from(*params)
    if params[0].is_a?(Numeric)
      x = params[0]
      y = params[1]
    else
      x = params[0].x
      y = params[0].y
    end
    sx = distance_x(x)
    sy = distance_y(y)
    if sx != 0 or sy != 0
      if sx.abs > sy.abs
        sx > 0 ? move_right : move_left
        if @move_failed and sy != 0
          sy > 0 ? move_down : move_up
        end
      else
        sy > 0 ? move_down : move_up
        if @move_failed and sx != 0
          sx > 0 ? move_right : move_left
        end
      end
    end
  end
 
  def move_type_away_from(target)
    case rand(6)
      when 0..3; move_away_from(target)
      when 4;    move_random
      when 5;    move_forward
    end
  end
 
  def turn_toward(*params)
    if params[0].is_a?(Numeric)
      x = params[0]
      y = params[1]
    else
      x = params[0].x
      y = params[0].y
    end
    sx = distance_x(x)
    sy = distance_y(y)
    if sx.abs > sy.abs
      sx > 0 ? turn_left : turn_right
    elsif sx.abs < sy.abs
      sy > 0 ? turn_up : turn_down
    end
  end
 
  def distance_x(x)
    sx = @x - x
    if $game_map.loop_horizontal?
      if sx.abs > $game_map.width / 2
        sx -= $game_map.width
      end
    end
    return sx
  end
 
  def distance_y(y)
    sy = @y - y
    if $game_map.loop_vertical?
      if sy.abs > $game_map.height / 2
        sy -= $game_map.height
      end
    end
    return sy
  end
 
  def animation_id=(i)
    @animation_id = (i < 0 ? 1 : i)
  end
 
  def check_event_trigger_touch(x, y)
  end
 
end

#------------------------------------------------------------------------------
class Game_Event < Game_Character
 
  attr_reader :id
 
  def name
    return @event.name
  end
 
  def check_comment(param)
    return nil if @list == nil or @list.size <= 0
    for item in @list
      next unless item.code == 108 or item.code == 408
      if item.parameters[0] =~ /#{param} (.*)/i
        return $1.to_s
      end
    end
    return nil
  end
 
  def comment_exists?(param)
    return false if @list == nil or @list.size <= 0
    for item in @list
      if item.code == 108 or item.code == 408
        if item.parameters[0] =~ /#{param}/i
          return true
        end
      end
    end
    return false
  end
 
end

#------------------------------------------------------------------------------
class Game_Interpreter
 
  def id
    return @original_event_id.to_i
  end
 
  def self_event
    return $game_map.events[id]
  end
 
  def selfswitch(switch, status=nil, event_id=@id)
    key = [$game_map.map_id, event_id, switch]
    if status == nil
      $game_self_switches[key] = !$game_self_switches[key]
    else
      $game_self_switches[key] = status
    end
    $game_map.need_refresh = true
  end
 
end

#------------------------------------------------------------------------------
class Sprite_Base
 
  alias vampyr_kernel_spbase_update update
 
  def update
    vampyr_kernel_spbase_update
    update_animation_fixed
  end
 
  def update_animation_fixed
    return if @animation == nil
    if @animation.position == 3
      if viewport == nil
        @animation_ox = Graphics.width / 2
        @animation_oy = Graphics.height / 2
      else
        @animation_ox = viewport.rect.width / 2
        @animation_oy = viewport.rect.height / 2
      end
    else
      @animation_ox = x - ox + width / 2
      @animation_oy = y - oy + height / 2
      if @animation.position == 0
        @animation_oy -= height / 2
      elsif @animation.position == 2
        @animation_oy += height / 2
      end
    end
  end
 
end

#------------------------------------------------------------------------------
class Sprite_Character < Sprite_Base
 
  alias vampyr_kernel_spchar_update_bitmap update_bitmap
 
  def update_bitmap
    vampyr_kernel_spchar_update_bitmap
    @character.width = @cw if @character.width != @cw
    @character.height = @ch if @character.height != @ch
  end
 
end

#------------------------------------------------------------------------------
Win32API.new("kernel32", "SetPriorityClass", "pi", "i").call(-1, 0x80)h


Actual MP Cost Change script (Uses the Kernel)
Code: [Select]
#This script makes it so that if put <mp1> in the notebox of a weapon or armor, the MP cost of any skill will be reduced to the amount below.

MPchange = 1 #Change this number to change the mp amount skills are reduced to.

module RPG
  class BaseItem
    def mp1?
      self.note.check("<mp1>") #I kept it <mp1> to tribute FlipelyFlip's original.
    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 MPchange
      end
    elsif half_mp_cost
      return skill.mp_cost / 2
    else
      return skill.mp_cost
    end
  end
end

Standalone script, uses FlipelyFlip's module.
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


Credits
-FlipelyFlip
-Vlad, for the Kernel script.
-Xzygon
« Last Edit: December 26, 2010, 08:16:40 AM by Xzygon »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
There is no "check" method for String object. Are you relying on some other script for that method? If so, you should identify what it is and link to it; otherwise the script will throw errors for people without that script.

Otherwise it is a nice little script.

**
Rep:
Level 82
Err, whoops, I didn't realize it was relying on another script. Sorry about that. (I keep doing that with my scripts, I always forget to thoroughly check it...)

****
Rep:
Level 76
Praise the Sun (Arcana)
GIAW 14: 1st Place (Hard Mode)
So, is there a way to make it so that certain items make the MP cost a number different than other armors? For instance, can you make a shirt that make the MP cost for the skills 10, and a robe that makes it 2? I'm just kinda confused and I'm thinking that the script makes the changes the same on each item it affects (Unless that's what it does).