X Tutup
#==============================================================================

#
# ▼ Craze's Script Asylum - Elemental Booster v1.01
# -- Last Updated: 2012.02.03
# -- Level: Normal
# -- Requires: n/a
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["CRZ-ElementalBooster"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.02.03 - Fixed a fatal bug when using items in the menu
# 2012.01.11 - Finished Script
# 2012.01.08 - Started Script
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Traits are cool ways to play with your actors and enemies, but I feel like
# the ability to truly mess with elements is missing.
#
# -----------------------------------------------------------------------------
# Actor/Class/Weapon/Armor/Enemy/State Notetags -
# These notetags go in the those noteboxes in the database.
# All effects stack from all sources.
# -----------------------------------------------------------------------------
# <element x effect: +y%> <element x effect: -y%>
# Sets element x to add or subtract y% from [effect].
# Possible [effect] strings: dmg, eva, hit, cri, crdmg, cnt, mrf, cev
#
# Ex.:
# <element 3 dmg: +15%>
# Fire damage will be raised 15%.
# <element 4 cev: +200%>
# Critical evasion versus Ice is incredibly high (+200%).
# <element 5 hit: -30%>
# Thunder abilities will hit 30% less often.
#
#==============================================================================
# ▼ 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.
#
# Edit the settings in the module below as you see fit.
#
#==============================================================================
# ▼ 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.
#
# Works with YEA Element Reflect, although you probably shouldn't use both.
#
# Put BELOW CRZ Elemental Merger.
# Put BELOW Yanfly Engine Ace.
#
# Aliased methods:
# Game_Battler
# item_element_rate
# apply_critical
# item_hit
# item_eva
# item_cri
# item_cnt
# item_mrf
#
#==============================================================================

#==============================================================================
# ▼ 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.
#==============================================================================

module CRZ
module REGEXP
module BASEITEM

ELEMENT_RATE = /ELEMENT[ ](\d+)[ ](.*):[ ]([\+\-]\d+)([%%])/i

end # BASEITEM
end # REGEXP
end # CRZ


#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager

#--------------------------------------------------------------------------
# alias method: load_database
#--------------------------------------------------------------------------
class <<self; alias load_database_ele_rate load_database; end
def self.load_database
load_database_ele_rate
load_notetags_ele_rate
end

#--------------------------------------------------------------------------
# new method: load_notetags_ele_rate
#--------------------------------------------------------------------------
def self.load_notetags_ele_rate
groups = [$data_enemies, $data_actors,
$data_classes, $data_weapons, $data_armors, $data_states]
for group in groups
for obj in group
next if obj.nil?
obj.load_notetags_ele_rate
end
end
end

end # DataManager


#==============================================================================
# ■ RPG::BaseItem
#==============================================================================

class RPG::BaseItem

#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :elemental_rates

#--------------------------------------------------------------------------
# common cache: load_notetags_ele_rate
#--------------------------------------------------------------------------
def load_notetags_ele_rate
@elemental_rates = []
for i in 0..$data_system.elements.size
@elemental_rates[i] = {}
@elemental_rates[i][:dmg] = 0
@elemental_rates[i][:wdmg] = 0
@elemental_rates[i][:rdmg] = 0
@elemental_rates[i][:eva] = 0
@elemental_rates[i][:hit] = 0
@elemental_rates[i][:cri] = 0
@elemental_rates[i][:crdmg] = 0
@elemental_rates[i][:cnt] = 0
@elemental_rates[i][:mrf] = 0
@elemental_rates[i][:cev] = 0
end
#---
self.note.split(/[\r\n]+/).each { |line|
case line
#---
when CRZ::REGEXP::BASEITEM::ELEMENT_RATE
case $2.upcase
when "DMG", "DAMAGE"
@elemental_rates[$1.to_i][:dmg] += $3.to_i
when "WDMG"
@elemental_rates[$1.to_i][:wdmg] += $3.to_i
when "RDMG"
@elemental_rates[$1.to_i][:rdmg] += $3.to_i
when "EVA", "EVASION", "DODGE"
@elemental_rates[$1.to_i][:eva] += $3.to_i
when "HIT", "ACCURACY", "ACC"
@elemental_rates[$1.to_i][:hit] += $3.to_i
when "CRI", "CRITICAL", "CRIT"
@elemental_rates[$1.to_i][:cri] += $3.to_i
when "CRDMG", "CRITICAL DAMAGE", "CRITDMG"
@elemental_rates[$1.to_i][:crdmg] += $3.to_i
when "CNT", "COUNTER", "COUNTERATTACK"
@elemental_rates[$1.to_i][:cnt] += $3.to_i
when "MRF", "MGCREF", "MAGIC REFLECTION"
@elemental_rates[$1.to_i][:mrf] += $3.to_i
when "CEV", "CRIEVA", "CRITEVA", "CRITICAL EVASION"
@elemental_rates[$1.to_i][:cev] += $3.to_i
end
end
} # self.note.split
#---
end

end # RPG::BaseItem


#==============================================================================
# ■ Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base

attr_reader :subject

end # Scene_Battle


#==============================================================================
# ■ Game_Battler
#==============================================================================

class Game_Battler

def get_damage_boost(i)
rate = 1.0

# Get rates from Weapons
for equip in self.weapons
set = equip.elemental_rates[i]
unless set[:dmg].nil?
rate += (equip.elemental_rates[i][:dmg]) / 100.00
end
end
# Get rates from Armors
for equip in self.armors
set = equip.elemental_rates[i]
unless set[:dmg].nil?
rate += (equip.elemental_rates[i][:dmg]) / 100.00
end
end

# Get rates from States
for state in self.states
set = state.elemental_rates[i]
unless set[:dmg].nil?
rate += (state.elemental_rates[i][:dmg]) / 100.00
end
end
return rate
end
#--------------------------------------------------------------------------
# new method: make_element_shift
#--------------------------------------------------------------------------
def make_element_shift(user, stat, item = nil)
rate = 1.0
return rate unless SceneManager.scene_is?(Scene_Battle)

if item.nil?
return rate if SceneManager.scene.subject.current_action.nil?
item = SceneManager.scene.subject.current_action.item
end

array = []
if $imported["CRZ-ElementalMerger"]
if !user.atk_elements.empty?
array += user.atk_elements if item.physical? and CRZ::ELE_MERGE::PHYS_ATK_ELEMENTS
array += user.atk_elements if item.magical? and CRZ::ELE_MERGE::MAGIC_ATK_ELEMENTS
array += user.atk_elements if item.certain? and CRZ::ELE_MERGE::CERT_ATK_ELEMENTS
end
if item.damage.element_id >= 0
array.push(item.damage.element_id)
end
else # Default method
if item.damage.element_id < 0
array += user.atk_elements if !user.atk_elements.empty?
else
array.push(item.damage.element_id)
end
end # $imported["CRZ-ElementalMerger"]
return rate if array.empty?

case stat
when :eva, :cnt, :mrf, :cev
reader = self # Based on target's effects
else
reader = user
end

for i in array
if reader.actor?
# Get rates from Weapons
for equip in reader.weapons
set = equip.elemental_rates[i]
unless set[stat].nil?
rate += (equip.elemental_rates[i][stat]) / 100.00
end
end
# Get rates from Armors
for equip in reader.armors
set = equip.elemental_rates[i]
unless set[stat].nil?
rate += (equip.elemental_rates[i][stat]) / 100.00
end
end
# Get rates from Actor
set = reader.actor.elemental_rates[i]
unless set[stat].nil?
rate += (reader.actor.elemental_rates[i][stat]) / 100.00
end
# Get rates from Class
set = reader.class.elemental_rates[i]
unless set[stat].nil?
rate += (reader.class.elemental_rates[i][stat]) / 100.00
end

else # Enemy
# Get rates from Enemy
set = reader.enemy.elemental_rates[i]
unless set[stat].nil?
rate += (reader.enemy.elemental_rates[i][stat]) / 100.00
end
end # reader.actor?

# Get rates from States
for state in reader.states
set = state.elemental_rates[i]
unless set[stat].nil?
rate += (state.elemental_rates[i][stat]) / 100.00
end
end
end # for i in array (each element)

rate
end

#--------------------------------------------------------------------------
# alias method: item_element_rate
#--------------------------------------------------------------------------
alias item_element_rate_crz_ee item_element_rate
def item_element_rate(user, item)
rate = item_element_rate_crz_ee(user, item)
if self.element_rate(item.damage.element_id) > 1.0
rate *= make_element_shift(user, :wdmg, item)
elsif self.element_rate(item.damage.element_id) < 1.0
rate *= make_element_shift(user, :rdmg, item)
end
rate
end

#--------------------------------------------------------------------------
# alias method: apply_critical
#--------------------------------------------------------------------------
alias apply_critical_crz_ee apply_critical
def apply_critical(damage)
damage = apply_critical_crz_ee(damage)
user = SceneManager.scene.subject unless SceneManager.scene.subject.nil?
return damage if user.nil?
damage *= make_element_shift(user, :crdmg)
damage
end
#~
#--------------------------------------------------------------------------
# alias method: item_hit
#--------------------------------------------------------------------------
alias item_hit_crz_ee item_hit
def item_hit(user, item)
rate = item_hit_crz_ee(user, item)
rate += make_element_shift(user, :hit, item) - 1.00
rate
end

#--------------------------------------------------------------------------
# alias method: item_eva
#--------------------------------------------------------------------------
alias item_eva_crz_ee item_eva
def item_eva(user, item)
rate = item_eva_crz_ee(user, item)
rate += make_element_shift(user, :eva, item) - 1.00
rate
end

#--------------------------------------------------------------------------
# alias method: item_cri
#--------------------------------------------------------------------------
alias item_cri_crz_ee item_cri
def item_cri(user, item)
rate = item_cri_crz_ee(user, item)
rate += make_element_shift(user, :cri, item) - 1.00
rate
end

#--------------------------------------------------------------------------
# alias method: item_cnt
#--------------------------------------------------------------------------
alias item_cnt_crz_ee item_cnt
def item_cnt(user, item, result = [])
rate = item_cnt_crz_ee(user, item)
rate += make_element_shift(user, :cnt, item) - 1.00
rate -= make_element_shift(user, :cev, item) - 1.00
rate
end

#--------------------------------------------------------------------------
# alias method: item_mrf
#--------------------------------------------------------------------------
alias item_mrf_crz_ee item_mrf
def item_mrf(user, item)
rate = item_mrf_crz_ee(user, item)
rate += make_element_shift(user, :mrf, item) - 1.00
rate
end

end # Game_Battler

#==============================================================================
#
# ▼ End of File
#
#==============================================================================
X Tutup