Since the original 1.00m version of BEM doesn't support more than one skill cost this patch provides the function for a skill to have more costs (both MP and Rage costs for example).
1. Copy the script below or download the .txt attachment.
2. Paste the script above main and below any BEM scripts in your project.
3. Use and enjoy!
# ------------------------------------------------------------------------------
# BEM More Skill Costs Patch
# ------------------------------------------------------------------------------
# Author: XIV
# Version: 1.2
# Date: 24.04.2011.
# ==============================================================================
# Credits:
# - Yanfly
#
# Version History:
# - v1.1 - Found the database input bug
# - v1.2 - Fixed cost changes application
#
# Function:
# Since the original 1.00m version of BEM doesn't support more than 1 skill cost
# this patch provides that function.
#
# Scripts required:
# Battle Engine Melody Parts III & V (version 1.00m)
#
# Instruction:
# 1. Paste above main
# 2. Use and enjoy
#
# Tips & Tricks:
# Any constant mana cost should be inputed via notebox since inputing it through
# normal means bugs this script.

# The cost that will be displayed in the menu is going to be the last one you
# set in the "Note" box of the skill, so keep that in mind!
#
# ==============================================================================
#
# *END CUSTOMIZATION
#
# ==============================================================================
class RPG::UsableItem < RPG::BaseItem
#--------------------------------------------------------------------------
# new method: create_default_usableitem_values
#--------------------------------------------------------------------------
def create_default_usableitem_values
@name.gsub!(/\[.*\]/) { "" }
#---
@skill_type = ["ALL"] if self.is_a?(RPG::Skill)
@item_type = ["ALL"] if self.is_a?(RPG::Item)
@hide_in_battle = false
#---
@ptb_turn_cost = 1
@ptb_turn_gain = 0
@ptb_turn_loss = 0
#---
@def_f = 0
@res_f = 0
@dex_f = 0
@agi_f = 0
#--
@cast_ani = 0
if self.is_a?(RPG::Skill) and !self.physical_attack
@cast_ani = YEM::BATTLE_ENGINE::DEFAULT_CAST_ANIMATION
end
@skill_cost = []
#~ @skill_cost.push(self.mp_cost.to_s + " MP") if self.is_a?(RPG::Skill)
@rage_skill = false
@rage_boost = 0
if self.is_a?(RPG::Skill) and self.physical_attack
@rage_boost = YEM::BATTLE_ENGINE::SKILL_SETTINGS[:physical_rage_gain]
elsif self.is_a?(RPG::Skill)
@rage_boost = YEM::BATTLE_ENGINE::SKILL_SETTINGS[:magical_rage_gain]
end
@rage_target = 0
@cooldown = 0
@limited_use = 0
@instant = false
@requirements = {}
@lunatic_effects = {}
@element_growth = {}
@state_growth = {}
#---
@charges = 1
@change_variable = {}
@change_switch = {}
@pharmacology_only = false
@restrict = {:actors => [], :classes => []}
@nullify = {:actors => [], :classes => [], :enemies => []}
@unique_effect = {:pharm => nil, :actor => {}, :class => {}}
#---
@targets = []
@aoe_animation = false
@aoe_image = YEM::BATTLE_ENGINE::TARGET_SETTINGS[:circ_name]
@aoe_blend = YEM::BATTLE_ENGINE::TARGET_SETTINGS[:circ_blend]
@aoe_height = YEM::BATTLE_ENGINE::TARGET_SETTINGS[:circ_height]
@aoe_radius = 0
@rect_image = YEM::BATTLE_ENGINE::TARGET_SETTINGS[:rect_name]
@rect_blend = YEM::BATTLE_ENGINE::TARGET_SETTINGS[:rect_blend]
@rect_type = 0
@rect_value = 0
end
#--------------------------------------------------------------------------
# common cache: yem_cache_usableitem_bem
#--------------------------------------------------------------------------
def yem_cache_usableitem_bem
return if @cached_usableitem_bem; @cached_usableitem_bem = true
create_default_usableitem_values
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when YEM::REGEXP::USABLEITEM::SKILL_TYPE
next unless self.is_a?(RPG::Skill)
@skill_type.push($1.upcase)
when YEM::REGEXP::USABLEITEM::ITEM_TYPE
next unless self.is_a?(RPG::Item)
@item_type.push($1.upcase)
when YEM::REGEXP::USABLEITEM::HIDE_IN_BATTLE
@hide_in_battle = true
#---
when YEM::REGEXP::USABLEITEM::PTB_TURN_COST
next if @instant
@ptb_turn_cost = $1.to_i
when YEM::REGEXP::USABLEITEM::PTB_TURN_GAIN
@ptb_turn_gain = $1.to_i
when YEM::REGEXP::USABLEITEM::PTB_TURN_LOSS
@ptb_turn_loss = $1.to_i
#---
when YEM::REGEXP::USABLEITEM::ELE_GROW
@element_growth[$1.to_i] = $2.to_i
when YEM::REGEXP::USABLEITEM::STA_GROW
@state_growth[$1.to_i] = $2.to_i
#---
when YEM::REGEXP::USABLEITEM::HIT_RATE
next unless self.is_a?(RPG::Skill)
@hit = $1.to_i
when YEM::REGEXP::USABLEITEM::SPEED_RATE
@speed = $1.to_i
when YEM::REGEXP::USABLEITEM::STAT_F
value = $2.to_i
case $1.upcase
when "ATK"; @atk_f = value
when "DEF"; @def_f = value
when "SPI"; @spi_f = value
when "RES"; @res_f = value
when "DEX"; @dex_f = value
when "AGI"; @agi_f = value
end
#---
when YEM::REGEXP::USABLEITEM::CRIT_RATE
@cri_rate = $1.to_i
#---
when YEM::REGEXP::USABLEITEM::CAST_ANI
@cast_ani = $1.to_i
#---
when YEM::REGEXP::USABLEITEM::SKILL_COST
@skill_cost.push($1.to_s.upcase)
case $1.upcase
when /(\d+)[ ]RAGE/i
@rage_skill = true
end
#---
when YEM::REGEXP::USABLEITEM::COST_ICON
@cost_icon = $1.to_i
#---
when YEM::REGEXP::USABLEITEM::RAGE_BOOST
@rage_boost = $1.to_i
when YEM::REGEXP::USABLEITEM::TARG_RAGE
@target_rage = $1.to_i
#---
when YEM::REGEXP::USABLEITEM::COOLDOWN
@cooldown = $1.to_i
when YEM::REGEXP::USABLEITEM::LIMITEDUSE
@limited_use = $1.to_i
#---
when YEM::REGEXP::USABLEITEM::INSTANT
@instant = true
@speed = 10 ** 10
@ptb_turn_cost = 0
@atb_reset = 100
@ctb_reset = 100
#---
when YEM::REGEXP::USABLEITEM::REQUIREMENTS
case $2.upcase
when "STATE", "STATES"
case $1.upcase
when "ANY"; type = :any_state
when "ALL"; type = :all_state
end
when "ELEMENT", "ELEMENTS", "ELE"
case $1.upcase
when "ANY"; type = :any_ele
when "ALL"; type = :all_ele
end
when "SWITCH", "SWITCHES"
case $1.upcase
when "ANY"; type = :any_switch
when "ALL"; type = :all_switch
end
else; next
end
@requirements[type] = [] if @requirements[type] == nil
$3.scan(/\d+/).each { |num|
@requirements[type].push(num.to_i) if num.to_i > 0 }
#---
when YEM::REGEXP::USABLEITEM::CUSTOM_BEFORE
string = $1.upcase; type = :before
@lunatic_effects[type] = [] if @lunatic_effects[type] == nil
@lunatic_effects[type].push(string)
when YEM::REGEXP::USABLEITEM::CUSTOM_DURING
string = $1.upcase; type = :during
@lunatic_effects[type] = [] if @lunatic_effects[type] == nil
@lunatic_effects[type].push(string)
when YEM::REGEXP::USABLEITEM::CUSTOM_AFTER
string = $1.upcase; type = :after
@lunatic_effects[type] = [] if @lunatic_effects[type] == nil
@lunatic_effects[type].push(string)
#---
when YEM::REGEXP::USABLEITEM::CHARGES
next unless self.is_a?(RPG::Item)
@charges = $1.to_i
when YEM::REGEXP::USABLEITEM::CHANGE_VAR
next unless self.is_a?(RPG::Item)
@change_variable[$1.to_i] = $2.to_i
when YEM::REGEXP::USABLEITEM::CHANGE_SWI
next unless self.is_a?(RPG::Item)
case $2.upcase
when "TRUE", "ON"; value = :true
when "FALSE", "OFF"; value = :false
when "TOGGLE"; value = :toggle
else; next
end
@change_switch[$1.to_i] = value
#---
when YEM::REGEXP::USABLEITEM::PHARMA_ONLY
@pharmacology_only = true
when YEM::REGEXP::USABLEITEM::RESTRICT
case $1.upcase
when "ACTOR", "ACTORS"; type = :actors
when "CLASS", "CLASSES"; type = :classes
else; next
end
$2.scan(/\d+/).each { |num|
@restrict[type].push(num.to_i) if num.to_i > 0 }
when YEM::REGEXP::USABLEITEM::NULLIFY
case $1.upcase
when "ACTOR", "ACTORS"; type = :actors
when "CLASS", "CLASSES"; type = :classes
when "ENEMY", "ENEMIES"; type = :enemies
else; next
end
$2.scan(/\d+/).each { |num|
@nullify[type].push(num.to_i) if num.to_i > 0 }
#---
when YEM::REGEXP::USABLEITEM::PHARMA_EFFECT
@unique_effect[:pharm] = $1.to_i
when YEM::REGEXP::USABLEITEM::UNIQUE_EFFECT
next unless self.is_a?(RPG::Item)
case $1.upcase
when "ACTOR"; type = :actor
when "CLASS"; type = :class
else; next
end
@unique_effect[type][$2.to_i] = $3.to_i
#---
when YEM::REGEXP::USABLEITEM::TARGETS
string = $1.to_s.upcase
@targets.push(string)
case string
when /DEAD/i
@for_dead = true
end
#---
case string
when "EVERYBODY"
@for_opponent = true
@for_friend = true
when "ALL BUT USER"
@for_friend = true
@for_opponent = false
when /(\d+)[ ](?:RANDOM|RAND)[ ](.*)/i
@random_targets = $1.to_i
case $2.upcase
when /(?:FOE|FOES)/i
@for_opponent = true
@for_friend = false
when /(?:ALLY|ALLIES)/i
@for_friend = true
@for_opponent = false
end
when /(?:FOE|FOES)/i
@for_opponent = true
@for_friend = false
when /(?:ALLY|ALLIES|USER|USERS)/i
@for_friend = true
@for_opponent = false
end
#---
when YEM::REGEXP::USABLEITEM::AOE_IMAGE
@aoe_image = $1.to_s
when YEM::REGEXP::USABLEITEM::AOE_BLEND
@aoe_blend = $1.to_i
when YEM::REGEXP::USABLEITEM::AOE_HEIGHT
@aoe_height = $1.to_i / 100.0
when YEM::REGEXP::USABLEITEM::AOE_RADIUS
@aoe_radius = [$1.to_i, 3].max
@aoe_animation = true
when YEM::REGEXP::USABLEITEM::RECT_IMAGE
@rect_image = $1.to_s
when YEM::REGEXP::USABLEITEM::RECT_BLEND
@rect_blend = $1.to_i
when YEM::REGEXP::USABLEITEM::RECT_COL
@rect_type = 1
@rect_value = [$1.to_i, 3].max
@aoe_animation = true
when YEM::REGEXP::USABLEITEM::RECT_ROW
@rect_type = 2
@rect_value = [$1.to_i, 3].max
@aoe_animation = true
when YEM::REGEXP::USABLEITEM::RECT_MAP
@rect_type = 3
#---
when YEM::REGEXP::USABLEITEM::TARGET_TEXT_ON
@target_text_enabled = true
@target_text = ""
when YEM::REGEXP::USABLEITEM::TARGET_TEXT_OFF
@target_text_enabled = false
#---
else
if @target_text_enabled
@target_text += line
end
end
} # self.note.split
finish_default_usableitem_values
end # yem_cache_usableitem_bem
end
class Game_Battler
#--------------------------------------------------------------------------
# new method: custom_skill_costs
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# In this section, you can modify the various skill cost types available or
# create your own. By following the examples below, you can effectively
# generate your own skill cost types and using this tag:
#
# <cost: phrase>
#
# Match phrase with a case below and follow the examples below to meet and
# match your custom costs.
#--------------------------------------------------------------------------
def custom_skill_costs(skill, type)
hash = YEM::BATTLE_ENGINE::SKILL_SETTINGS
calc_cost = 0; use_icon = 0; suffix = "%s"; text_cost = "0"
colour = hash[:mp_colour]; font_size = hash[:mp_size]
can_use = []
perform = (type == :perform)
for i in skill.skill_cost
case i
#------------------------------------------------------------------------
# <cost: x mp>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# This allows you to manually adjust the MP costs skills. Although its
# ability is already present within the editor itself, this tag's purpose
# is to allow you to create skills with an MP cost of higher than 999.
# --- Example --- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# <cost: 2000 mp>
# --- WARNING --- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# This is a default-used template. Do not remove this.
#------------------------------------------------------------------------
when /(\d+)[ ](?:MP|SP)/i
#---
calc_cost = $1.to_i
calc_cost = apply_skill_cost_changes(skill, calc_cost, "MP")
calc_cost /= 2 if half_mp_cost
#---
text_cost = calc_cost.to_s
use_icon = Icon.mp_cost
suffix = hash[:mp_suffix]
colour = hash[:mp_colour]
font_size = hash[:mp_size]
can_use.push(@mp >= calc_cost)
if perform
@mp -= calc_cost
end
#------------------------------------------------------------------------
# <cost: x% maxmp>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# This tag allows you to create skills that cost a percentage of the
# battler's MaxMP. That said, this value will always fluctuate depending
# on the MaxMP of the battler.
# --- Example --- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# <cost: 20% maxmp>
#------------------------------------------------------------------------
when /(\d+)([%%])[ ](?:MP|SP|MAXMP|MAXSP)/i
#---
calc_cost = maxmp * $1.to_i / 100
calc_cost = apply_skill_cost_changes(skill, calc_cost, "MP")
calc_cost /= 2 if half_mp_cost
#---
text_cost = calc_cost.to_s
use_icon = Icon.mp_cost
suffix = hash[:mp_suffix]
colour = hash[:mp_colour]
font_size = hash[:mp_size]
can_use.push(@mp >= calc_cost)
@mp -= calc_cost if perform
#------------------------------------------------------------------------
# <cost: x hp>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# If you wish for skills to cost HP instead of MP, apply this tag to the
# skill's notebox. Unlike MP skills, HP skills cannot bring HP to 0 so
# they will stop short if the skill costs more than exact HP.
# --- Example --- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# <cost: 2000 hp>
#------------------------------------------------------------------------
when /(\d+)[ ](?:HP|LP)/i
#---
calc_cost = $1.to_i
calc_cost = apply_skill_cost_changes(skill, calc_cost, "HP")
#---
text_cost = calc_cost.to_s
use_icon = Icon.hp_cost
suffix = hash[:hp_suffix]
colour = hash[:hp_colour]
font_size = hash[:hp_size]
can_use.push(@hp > calc_cost)
@hp -= calc_cost if perform
#------------------------------------------------------------------------
# <cost: x% maxhp>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# To make a skill cost a percentage of the user's MaxHP, use the above
# tag. Just like the tag above, the skill cannot be used if it brings the
# battler's HP to 0 or below.
# --- Example --- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# <cost: 20% maxhp>
#------------------------------------------------------------------------
when /(\d+)([%%])[ ](?:HP|LP|MAXHP|MAXLP)/i
#---
calc_cost = maxhp * $1.to_i / 100
calc_cost = apply_skill_cost_changes(skill, calc_cost, "HP")
#---
text_cost = calc_cost.to_s
use_icon = Icon.hp_cost
suffix = hash[:hp_suffix]
colour = hash[:hp_colour]
font_size = hash[:hp_size]
can_use.push(@hp > calc_cost)
@hp -= calc_cost if perform
#------------------------------------------------------------------------
# <cost: x gold>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# To make skills cost gold, use the tag above. x is the amount of gold
# spent when the skill takes action. Note that enemies do not have any
# restrictions on using gold cost skills.
# --- Example --- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# <cost: 2000 gold>
#------------------------------------------------------------------------
when /(\d+)[ ](?:GOLD|money)/i
#---
if self.actor?
calc_cost = $1.to_i
calc_cost = apply_skill_cost_changes(skill, calc_cost, "GOLD")
else
calc_cost = 0
end
#---
text_cost = calc_cost.to_s
use_icon = Icon.gold_cost
suffix = hash[:gold_suffix]
colour = hash[:gold_colour]
font_size = hash[:gold_size]
can_use.push($game_party.gold > calc_cost)
$game_party.lose_gold(calc_cost) if perform
#------------------------------------------------------------------------
# <cost: x% gold>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# To cost a percentage of the player's total gold, use x%. Just like the
# above tag, enemies using gold cost skills will have no restrictions.
# This skill will consume a percentage of the player's total gold.
# --- Example --- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# <cost: 20% gold>
#------------------------------------------------------------------------
when /(\d+)([%%])[ ](?:GOLD|money)/i
#---
if self.actor?
calc_cost = $game_party.gold * $1.to_i / 100
calc_cost = apply_skill_cost_changes(skill, calc_cost, "GOLD")
else
calc_cost = 0
end
#---
text_cost = $1.to_s
use_icon = Icon.gold_cost
suffix = hash[:gold_suffixp]
colour = hash[:gold_colour]
font_size = hash[:gold_size]
can_use.push($game_party.gold > calc_cost)
$game_party.lose_gold(calc_cost) if perform
#------------------------------------------------------------------------
# <cost: x rage>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Rage is a new stat made to function as a new skill currency. It grows
# as battlers take hits or dish out physical attacks themselves. Use the
# tag above to make a skill cost rage instead of MP.
# --- Example --- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# <cost: 2 rage>
#------------------------------------------------------------------------
when /(\d+)[ ]RAGE/i
#---
calc_cost = $1.to_i
calc_cost = apply_skill_cost_changes(skill, calc_cost, "RAGE")
#---
text_cost = calc_cost.to_s
use_icon = Icon.rage_cost
suffix = hash[:rage_suffix]
colour = hash[:rage_colour]
font_size = hash[:rage_size]
@rage = 0 if @rage == nil
can_use.push(@rage >= calc_cost)
@rage -= calc_cost if perform
#------------------------------------------------------------------------
# <cost: x item:y>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# This will allow you to make a skill cost 2 of an item to use. The y
# value will be the database's relative item ID value. This will check
# whether or not the party's inventory has enough to use. Note that if an
# enemy is using this skill, no items will be consumed.
# --- Example --- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# <cost: 2 item:1>
#------------------------------------------------------------------------
when /(\d+)[ ]ITEM:(\d+)/i
#---
calc_cost = self.enemy? ? 0 : $1.to_i
name = $data_items[$2.to_i].name.upcase
calc_cost = apply_skill_cost_changes(skill, calc_cost, name)
#---
item = $data_items[$2.to_i]
text_cost = calc_cost.to_s
use_icon = item.icon_index
can_use.push($game_party.item_number(item) >= calc_cost)
if perform and self.actor?
calc_cost.times do; $game_party.consume_item(item); end
end
#------------------------------------------------------------------------
# Stop editting past this point.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Values created in the damage formula will be applied here to total HP
# and MP damage after undergoing variance and elemental adjustments.
#------------------------------------------------------------------------
end
end
use_icon = skill.cost_icon if skill.cost_icon != nil
case type
when :perform; return
when :calc_cost; return calc_cost
when :text_cost; return text_cost
when :can_use
for i in can_use
return false if i == false
end
return true
when :use_icon; return use_icon
when :suffix; return suffix
when :font_size; return font_size
when :colour; return colour
end
end
#--------------------------------------------------------------------------
# new method: apply_skill_cost_changes
#--------------------------------------------------------------------------
def apply_skill_cost_changes(skill, cost, type = "MP")
clear_battle_cache if @cache_skill_costs == nil
@cache_skill_costs = {} if @cache_skill_costs != nil
return @cache_skill_costs[skill.id] if @cache_skill_costs[skill.id] != nil
cost = apply_skill_cost_state_per(skill, cost, type)
cost = apply_skill_cost_state_set(skill, cost, type)
@cache_skill_costs[skill.id] = [Integer(cost), 0].max
return @cache_skill_costs[skill.id]
end
end # Game_Battler
None as of yet.
Any constant mana cost should be inputed via notebox ("<cost: x mp>" tag) since inputing it through normal means bugs this script.
If you use any custom skill costs you'll need to implement them into this script or (and I assume if you DO use custom skill costs that you know something about scripting) simply make @skill_cost attribute an array and then push elements into it when a "<cost: >" tag is found in the note box. Then simply check each element of the array for RegExp matches!
This script overwrites some BEM RegExp methods so beware if you use other scripts that use those. Also let me know about any bugs!