Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # Zetu Engine X4 - Solace Core Script
- # by Zetu
- # --- Created: 06/20/2013
- # --- Updated: 06/27/2013 v1.00
- #===============================================================================
- module ZEX4S
- Imp = {}
- module REGEX
- Float = "[\+\-]?\d+\.\d+"
- Int = "[\+\-]?\d+"
- Param = "mhp|hp|mmp|mp|atk|def|mat|mdf|agi|luk"
- XParam = "hit|eva|cri|cev|mev|mrf|cnt|hrg|mrg|trg"
- SParam = "tgr|grd|rec|pha|mcr|tcr|pdr|mdr|fdr|exr"
- FullParam = "#{Param}|#{XParam}|#{SParam}"
- end
- class MetaTag
- def initialize
- @data = {}
- @data.default = MetaTag.new
- end
- def []=(*params)
- return if params.size == 0
- @data[params[0]] = MetaTag.new unless @data[params[0]]
- @data[params[0]] = params.drop(1)
- end
- def [](*params)
- return @data if params.size == 0
- return @data[params[0]][params.drop(1)]
- end
- end
- end
- class Object
- def convert(string)
- case string
- when /#{ZEX4S::REGEX::Float}/
- return string.to_f
- when /#{ZEX4S::REGEX::Int}/
- return string.to_i
- else
- return string
- end
- end
- def convert_battler_formula(string, battler, ext = {})
- REGEX::FullParam.split("|").each do |param|
- string.gsub(param, battler.send(param.to_sym))
- end
- convert_formula(string, ext)
- end
- def convert_formula(string, ext = {})
- ext.each do |key, value|
- string.gsub!(key, "ext[\"#{key}\"]")
- end
- eval(string)
- end
- def rand_range(min, max)
- min + rand(max - min + 1)
- end
- def get_image(path, filename)
- Cache.load_bitmap(path, filename) rescue nil
- end
- def get_animation(filename)
- get_image("Graphics/Animations/", filename)
- end
- def get_battler(filename)
- get_image("Graphics/Battlers/", filename)
- end
- def get_character(filename)
- get_image("Graphics/Characters/", filename)
- end
- def get_face(filename)
- get_image("Graphics/Faces/", filename)
- end
- def get_parallax(filename)
- get_image("Graphics/Parallaxes/", filename)
- end
- def get_picture(filename)
- get_image("Graphics/Pictures/", filename)
- end
- def get_system(filename)
- get_image("Graphics/System/", filename)
- end
- def get_tileset(filename)
- get_image("Graphics/Tilesets/", filename)
- end
- def in_rect(x, y, rect)
- return false unless rect.x >= x
- return false unless rect.x + rect.width <= x
- return false unless rect.y >= y
- return false unless rect.y + rect.height <= y
- return true
- end
- def in_range(x, y, x1, y1, width, height)
- in_rect(x, y, Rect.new(x1, y1, width, height))
- end
- end
- class String
- def get_value(tag, recieve, default = "")
- self =~ /<#{tag}[:\s]+(#{recieve})>/i ? $1 : default
- end
- def get_integer(tag, default = 0)
- get_value(tag, ZEX4S::REGEX::Int, default).to_i
- end
- def get_float(tag, default = 1.0)
- get_value(tag, ZEX4S::REGEX::Float, default).to_f
- end
- def get_hash(regex, oc1 = nil, oc2 = nil, default = nil)
- hash = Hash.new
- hash.default = default
- self.scan(regex) do |i,j|
- hash[i.convert_to(oc1)] = j.convert_to(oc2)
- end
- return hash
- end
- def convert_to(symbol)
- case symbol
- when :int
- self.to_i
- when :float
- self.to_f / 100
- else
- -1
- end
- end
- def get_full_tag(tag)
- ary = []
- self.scan(/<#{tag}(?:\:\s?(.*?))?>\n?\s*(.*?)\n?\s*<\/#{tag}>/imx) do
- ary.push( [$1, $2.gsub(/\n\s*/, "\n")] )
- end
- return ary
- end
- def each_line
- self.split(/\s*[\n;]+\s*/)
- end
- def get_all_by_tag(string, recieve = ".+", method = nil)
- ary = []
- self.each_line.each do |line|
- if line =~ /<#{string}[:\s]+(#{recieve})>/i
- ary.push $1
- end
- end
- method ? ary.map{|v| v.send(method)} : ary
- end
- end
- class Game_Battler < Game_BattlerBase
- alias zex4s_i initialize
- def initialize
- zex4s_i
- zex4s_initialize
- refresh
- end
- alias zex4s_ier item_element_rate
- def item_element_rate(user, item)
- zex4s_ier(user, item) * post_damage_rate(user, item)
- end
- alias zex4s_mdv make_damage_value
- def make_damage_value(user, item)
- value = item.damage.eval(user, self, $game_variables)
- value *= item_element_rate(user, item)
- value *= pdr if item.physical?
- value *= mdr if item.magical?
- value *= rec if item.damage.recover?
- value = apply_critical(value) if @result.critical
- value = apply_variance(value, item.damage.variance)
- value = apply_guard(value)
- value += post_damage(user, item)
- value *= post_damage_rate(user, item)
- apply_post_effects(user, item)
- @result.make_damage(value.to_i, item)
- end
- def post_damage(user, item)
- 0
- end
- def post_damage_rate(user, item)
- 1.0
- end
- def apply_post_effects(user, item)
- end
- def data_set
- states
- end
- def zex4s_initialize
- end
- end
- class Game_Actor < Game_Battler
- def data_set
- super + [actor] + [self.class]
- end
- def zex4s_initialize
- super
- end
- end
- class Game_Enemey < Game_Battler
- def data_set
- super + [enemy]
- end
- def zex4s_initialize
- super
- end
- end
- #==
- class RPG::BaseItem; def add_note_data; end; end
- class RPG::Actor < RPG::BaseItem; def add_note_data;super;end; end
- class RPG::EquipItem < RPG::BaseItem; def add_note_data;super;end; end
- class RPG::Weapon < RPG::EquipItem; def add_note_data;super;end; end
- class RPG::Armor < RPG::EquipItem; def add_note_data;super;end; end
- class RPG::UsableItem < RPG::BaseItem; def add_note_data;super;end; end
- class RPG::Item < RPG::UsableItem; def add_note_data;super;end; end
- class RPG::Skill < RPG::UsableItem; def add_note_data;super;end; end
- class RPG::State < RPG::BaseItem; def add_note_data;super;end; end
- class RPG::Class < RPG::BaseItem; def add_note_data;super;end; end
- #==
- class Array
- def sum
- self.compact.inject(0) { |r, i| r += i }
- end
- def pi
- self.compact.inject(1.0) { |r, i| r *= i }
- end
- def map_by(symbol)
- self.map do |x|
- x.send symbol
- end
- end
- end
- module DataManager
- class << self; alias zex4s_lnd load_normal_database; end
- def self.load_normal_database
- zex4s_lnd
- zex4s_add_note_data
- end
- def self.zex4s_add_note_data
- [$data_actors, $data_classes, $data_skills, $data_weapons,
- $data_armors, $data_enemies, $data_states].flatten.each do |obj|
- obj.add_note_data if obj
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement