$imported = {} if $imported.nil?
$imported["YEA-SkillCostManager"] = true
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.08.06 - Restore SP-Paramater: TCR
# 2012.01.23 - Compatibility Update: Doppelganger
# 2011.12.11 - Started Script and Finished.
# - Added max and min notetags.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script adds more functionality towards skill costs. Skills can now cost
# HP, more MP, more TP, gold, and even have custom costs. The way the skill
# costs are drawn in the display windows are changed to deliver more effective
# and reliable information to the player. And if four skill costs aren't enough
# to satisfy you, you can even make your own custom skill costs.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Actor Notetags - These notetags go in the actors notebox in the database.
# -----------------------------------------------------------------------------
# <hp cost rate: x%>
# Allows the actor to drop the HP cost of skills to x%.
#
# <tp cost rate: x%>
# Allows the actor to drop the TP cost of skills to x%.
#
# <gold cost rate: x%>
# Allows the actor to drop the Gold cost of skills to x%.
#
# -----------------------------------------------------------------------------
# Class Notetags - These notetags go in the class notebox in the database.
# -----------------------------------------------------------------------------
# <hp cost rate: x%>
# Allows the class to drop the HP cost of skills to x%.
#
# <tp cost rate: x%>
# Allows the class to drop the TP cost of skills to x%.
#
# <gold cost rate: x%>
# Allows the class to drop the Gold cost of skills to x%.
#
# -----------------------------------------------------------------------------
# Skill Notetags - These notetags go in the skills notebox in the database.
# -----------------------------------------------------------------------------
# <hp cost: x>
# Sets the skill's HP cost to x. This function did not exist by default in
# RPG Maker VX Ace.
#
# <hp cost: x%>
# Sets the HP cost to a percentage of the actor's MaxHP. If a normal HP cost is
# present on the skill, too, then this value is added to the HP cost.
#
# <hp cost max: x>
# <hp cost min: x>
# Sets the maximum and minimum range of the HP Cost of the skill. If you do not
# use this tag, there will be no maximum and/or minimum range.
#
# <mp cost: x>
# Sets the skill's MP cost to x. Allows MP cost to exceed 9999, which is RPG
# Maker VX Ace's database editor's maximum limit.
#
# <mp cost: x%>
# Sets the MP cost to a percentage of the actor's MaxMP. If a normal MP cost is
# present on the skill, too, then this value is added to the MP cost.
#
# <mp cost max: x>
# <mp cost min: x>
# Sets the maximum and minimum range of the MP Cost of the skill. If you do not
# use this tag, there will be no maximum and/or minimum range.
#
# <tp cost: x>
# Sets the skill's TP cost to x. Allows TP cost to exceed 100, which is RPG
# Maker VX Ace's database editor's maximum limit.
#
# <tp cost: x%>
# Sets the TP cost to a percentage of the actor's MaxTP. If a normal TP cost is
# present on the skill, too, then this value is added to the TP cost.
#
# <tp cost max: x>
# <tp cost min: x>
# Sets the maximum and minimum range of the TP Cost of the skill. If you do not
# use this tag, there will be no maximum and/or minimum range.
#
# <gold cost: x>
# Sets the skill's gold cost to x. Enemies with skills that cost gold do not
# use gold. If the player does not have enough gold, the skill can't be used.
#
# <gold cost: x%>
# Sets the skill's gold cost equal to a percentage of the party's total gold.
# If both a regular gold cost and a percentile gold cost is used, the total of
# both values will be the skill's gold cost.
#
# <gold cost max: x>
# <gold cost min: x>
# Sets the maximum and minimum range of the Gold Cost of the skill. If you do
# not use this tag, there will be no maximum and/or minimum range.
#
# --- Making Your Own Custom Costs ---
#
# <custom cost: string>
# If you decide to have a custom cost for your game, insert this notetag to
# change what displays in the skill menu visually.
#
# <custom cost colour: x>
# This is the "Window" skin text colour used for the custom cost. By default,
# it is text colour 0, which is the white colour.
#
# <custom cost size: x>
# This is the text font size used for the custom cost in the display windows.
# By default, it is font size 20.
#
# <custom cost icon: x>
# If you wish to use an icon for your custom cost, replace x with the icon ID
# you wish to show in display windows. By default, it is 0 (and not shown).
#
# <custom cost requirement>
# string
# string
# </custom cost requirement>
# Sets the custom cost requirement of the skill with an eval function using the
# strings in between. The strings are a part of one line even if in the notebox
# they are on separate lines.
#
# <custom cost perform>
# string
# string
# </custom cost perform>
# Sets how the custom cost payment is done with an eval function using the
# strings in between. The strings are a part of one line even if in the notebox
# they are on separate lines.
#
# -----------------------------------------------------------------------------
# Weapon Notetags - These notetags go in the weapons notebox in the database.
# -----------------------------------------------------------------------------
# <hp cost rate: x%>
# Allows the weapon to drop the HP cost of skills to x% when worn.
#
# <tp cost rate: x%>
# Allows the weapon to drop the TP cost of skills to x% when worn.
#
# <gold cost rate: x%>
# Allows the weapon to drop the Gold cost of skills to x% when worn.
#
# -----------------------------------------------------------------------------
# Armour Notetags - These notetags go in the armours notebox in the database.
# -----------------------------------------------------------------------------
# <hp cost rate: x%>
# Allows the armour to drop the HP cost of skills to x% when worn.
#
# <tp cost rate: x%>
# Allows the armour to drop the TP cost of skills to x% when worn.
#
# <gold cost rate: x%>
# Allows the armour to drop the TP cost of skills to x% when worn.
#
# -----------------------------------------------------------------------------
# Enemy Notetags - These notetags go in the enemies notebox in the database.
# -----------------------------------------------------------------------------
# <hp cost rate: x%>
# Allows the enemy to drop the HP cost of skills to x%.
#
# <tp cost rate: x%>
# Allows the enemy to drop the TP cost of skills to x%.
#
# -----------------------------------------------------------------------------
# State Notetags - These notetags go in the states notebox in the database.
# -----------------------------------------------------------------------------
# <hp cost rate: x%>
# Allows the state to drop the HP cost of skills to x% when afflicted.
#
# <tp cost rate: x%>
# Allows the state to drop the TP cost of skills to x% when afflicted.
#
# <gold cost rate: x%>
# Allows the state to drop the Gold cost of skills to x% when afflicted.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================
module YEA
module SKILL_COST
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - HP Cost Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# New to this script are HP costs. HP costs require the battler to have
# sufficient HP before being able to use the skill. The text colour that's
# used, the suffix, or whether or not to use an icon. If you do not wish
# to use an icon, set the icon to 0.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
HP_COST_COLOUR = 21 # Colour used from "Window" skin.
HP_COST_SIZE = 20 # Font size used for HP costs.
HP_COST_SUFFIX = "%sHP" # Suffix used for HP costs.
HP_COST_ICON = 0 # Icon used for HP costs. Set 0 to disable.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - MP Cost Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Here, you can change the settings for MP costs: the text colour that's
# used, the suffix, or whether or not to use an icon. If you do not wish
# to use an icon, set the icon to 0.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
MP_COST_COLOUR = 23 # Colour used from "Window" skin. Default: 23
MP_COST_SIZE = 20 # Font size used for MP costs. Default: 24
MP_COST_SUFFIX = "%sMP" # Suffix used for MP costs. No suffix default.
MP_COST_ICON = 0 # Icon used for MP costs. Set 0 to disable.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - TP Cost Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Here, you can change the settings for TP costs: the text colour that's
# used, the suffix, or whether or not to use an icon. If you do not wish
# to use an icon, set the icon to 0.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
TP_COST_COLOUR = 2 # Colour used from "Window" skin. Default: 29
TP_COST_SIZE = 20 # Font size used for TP costs. Default: 24
TP_COST_SUFFIX = "%sTP" # Suffix used for TP costs. No suffix default.
TP_COST_ICON = 0 # Icon used for TP costs. Set 0 to disable.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# - Gold Cost Settings -
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# New to this script are Gold costs. Gold costs require the party to have
# enough gold before being able to use the skill. The text colour that's
# used, the suffix, or whether or not to use an icon. If you do not wish
# to use an icon, set the icon to 0.
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
GOLD_COST_COLOUR = 6 # Colour used from "Window" skin.
GOLD_COST_SIZE = 20 # Font size used for Gold costs.
GOLD_COST_SUFFIX = "%sGold" # Suffix used for Gold costs.
GOLD_COST_ICON = 0 # Icon used for Gold costs. Set 0 to disable.
end # SKILL_COST
end # YEA
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================
#--------------------------------------------------------------------------
# alias method: load_database
#--------------------------------------------------------------------------
class <<self; alias load_database_scm load_database; end
def self.load_database
load_database_scm
load_notetags_scm
end
#--------------------------------------------------------------------------
# new method: load_notetags_scm
#--------------------------------------------------------------------------
def self.load_notetags_scm
groups = [$data_actors, $data_classes, $data_skills, $data_weapons,
$data_armors, $data_enemies, $data_states]
for group in groups
for obj in group
next if obj.nil?
obj.load_notetags_scm
end
end
end
#--------------------------------------------------------------------------
# alias method: skill_cost_payable?
#--------------------------------------------------------------------------
alias game_battlerbase_skill_cost_payable_scm skill_cost_payable?
def skill_cost_payable?(skill)
return false if hp <= skill_hp_cost(skill)
return false unless gold_cost_met?(skill)
return false unless custom_cost_met?(skill)
return game_battlerbase_skill_cost_payable_scm(skill)
end
#--------------------------------------------------------------------------
# new method: gold_cost_met?
#--------------------------------------------------------------------------
def gold_cost_met?(skill)
return true unless actor?
return $game_party.gold >= skill_gold_cost(skill)
end
#--------------------------------------------------------------------------
# new method: custom_cost_met?
#--------------------------------------------------------------------------
def custom_cost_met?(skill)
return true unless skill.use_custom_cost
return eval(skill.custom_cost_requirement)
end
#--------------------------------------------------------------------------
# alias method: pay_skill_cost
#--------------------------------------------------------------------------
alias game_battlerbase_pay_skill_cost_scm pay_skill_cost
def pay_skill_cost(skill)
game_battlerbase_pay_skill_cost_scm(skill)
self.hp -= skill_hp_cost(skill)
$game_party.lose_gold(skill_gold_cost(skill)) if actor?
pay_custom_cost(skill)
end
#--------------------------------------------------------------------------
# new method: pay_custom_cost
#--------------------------------------------------------------------------
def pay_custom_cost(skill)
return unless skill.use_custom_cost
eval(skill.custom_cost_perform)
end
#--------------------------------------------------------------------------
# alias method: skill_mp_cost
#--------------------------------------------------------------------------
alias game_battlerbase_skill_mp_cost_scm skill_mp_cost
def skill_mp_cost(skill)
n = game_battlerbase_skill_mp_cost_scm(skill)
n += skill.mp_cost_percent * mmp * mcr
n = [n.to_i, skill.mp_cost_max].min unless skill.mp_cost_max.nil?
n = [n.to_i, skill.mp_cost_min].max unless skill.mp_cost_min.nil?
return n.to_i
end
#--------------------------------------------------------------------------
# alias method: skill_tp_cost
#--------------------------------------------------------------------------
alias game_battlerbase_skill_tp_cost_scm skill_tp_cost
def skill_tp_cost(skill)
n = game_battlerbase_skill_tp_cost_scm(skill) * tcr_y
n += skill.tp_cost_percent * max_tp * tcr_y
n = [n.to_i, skill.tp_cost_max].min unless skill.tp_cost_max.nil?
n = [n.to_i, skill.tp_cost_min].max unless skill.tp_cost_min.nil?
return n.to_i
end
#--------------------------------------------------------------------------
# new method: tcr_y
#--------------------------------------------------------------------------
def tcr_y
n = 1.0
if actor?
n *= self.actor.tp_cost_rate
n *= self.class.tp_cost_rate
for equip in equips
next if equip.nil?
n *= equip.tp_cost_rate
end
else
n *= self.enemy.tp_cost_rate
if $imported["YEA-Doppelganger"] && !self.class.nil?
n *= self.class.tp_cost_rate
end
end
for state in states
next if state.nil?
n *= state.tp_cost_rate
end
return n
end
#--------------------------------------------------------------------------
# new method: skill_hp_cost
#--------------------------------------------------------------------------
def skill_hp_cost(skill)
n = skill.hp_cost * hcr
n += skill.hp_cost_percent * mhp * hcr
n = [n.to_i, skill.hp_cost_max].min unless skill.hp_cost_max.nil?
n = [n.to_i, skill.hp_cost_min].max unless skill.hp_cost_min.nil?
return n.to_i
end
#--------------------------------------------------------------------------
# new method: hcr
#--------------------------------------------------------------------------
def hcr
n = 1.0
if actor?
n *= self.actor.hp_cost_rate
n *= self.class.hp_cost_rate
for equip in equips
next if equip.nil?
n *= equip.hp_cost_rate
end
else
n *= self.enemy.hp_cost_rate
if $imported["YEA-Doppelganger"] && !self.class.nil?
n *= self.class.hp_cost_rate
end
end
for state in states
next if state.nil?
n *= state.hp_cost_rate
end
return n
end
#--------------------------------------------------------------------------
# new method: skill_gold_cost
#--------------------------------------------------------------------------
def skill_gold_cost(skill)
n = skill.gold_cost * gcr
n += skill.gold_cost_percent * $game_party.gold * gcr
n = [n.to_i, skill.gold_cost_max].min unless skill.gold_cost_max.nil?
n = [n.to_i, skill.gold_cost_min].max unless skill.gold_cost_min.nil?
return n.to_i
end
#--------------------------------------------------------------------------
# new method: gcr
#--------------------------------------------------------------------------
def gcr
n = 1.0
n *= self.actor.gold_cost_rate
n *= self.class.gold_cost_rate
for equip in equips
next if equip.nil?
n *= equip.gold_cost_rate
end
for state in states
next if state.nil?
n *= state.gold_cost_rate
end
return n
end
#--------------------------------------------------------------------------
# new method: draw_custom_skill_cost
#--------------------------------------------------------------------------
def draw_custom_skill_cost(rect, skill)
return unless skill.use_custom_cost
change_color(text_color(skill.custom_cost_colour), enable?(skill))
icon = skill.custom_cost_icon
if icon > 0
draw_icon(icon, rect.x + rect.width-24, rect.y, enable?(skill))
rect.width -= 24
end
contents.font.size = skill.custom_cost_size
text = skill.custom_cost_text
draw_text(rect, text, 2)
cx = text_size(text).width + 4
rect.width -= cx
reset_font_settings
end
end # Window_SkillList
#==============================================================================
#
# ▼ End of File
#
#==============================================================================[/pre]