Beruflich Dokumente
Kultur Dokumente
#
def item_effect_recover_hp(user, item, effect)
#
def item_effect_recover_mp(user, item, effect)
#
def item_effect_gain_tp
#
# * Alias methods
# class Game_Interpreter
#
def command_108
#
# class Window_Base < Window
#
def convert_escape_characters(text)
#
#-----------------------------------------------------------------------------# Instructions:
# To instal the script, open you script editor and paste this script on
# a new section bellow the Materials section.
#
#-----------------------------------------------------------------------------# New functions
#
# * Random number between two vales
# rand_between(min, max)
#
min : min value
#
max : max value
# Can be called from any class, this method return an random value between
# two specific numbers
#
# * Random array value
# <Array>.random
# <Array>.random!
# Returns a random object from the array, the method .random! is destructive,
# removing the value returned from the array.
#
# * Sum of the numeric values of a array
# <Array>.sum
# Returns the sum of all numeric values
#
# * Average of all numeric values from the array
# <Array>.average(float = false)
#
float : float flag
# Returns the average of all numeric values, if floa is true, the value
# returned is a float, otherwise it's a integer.
#
# * Note for events
# <Event>.note
# By default, events doesn't have note boxes. This command allows to use
# comments as note boxes, following the same format as the ones on the
# database. Returns all comments on the active page of the event.
#
# * Comment calls
# <Event>.comment_call
# Another function for comment boxes, by default, they have absolutely no
# effect in game when called. But this method allows to make the comment
# box to behave like an script call, but with the versatility of the
# note boxes. Remember that the commands will only take effect if there
# is scripts to respond to the comment code.
#
#==============================================================================
#==============================================================================
# ** Victor Engine
return false
end
#-------------------------------------------------------------------------# * New method: to_ceil
#-------------------------------------------------------------------------def to_ceil
self > 0 ? self.abs.ceil : -self.abs.ceil
end
end
#==============================================================================
# ** Float
#-----------------------------------------------------------------------------# This is the abstract class for the floating point values.
#==============================================================================
class Float
#-------------------------------------------------------------------------# * New method: float?
#-------------------------------------------------------------------------def float?
return true
end
#-------------------------------------------------------------------------# * New method: ceil?
#-------------------------------------------------------------------------def ceil?
self != self.ceil
end
end
#==============================================================================
# ** Array
#-----------------------------------------------------------------------------# This class store arbitrary Ruby objects.
#==============================================================================
class Array
#-------------------------------------------------------------------------# * New method: array?
#-------------------------------------------------------------------------def array?
return true
end
#------------------------------------------------------------------------# * New method: random
#------------------------------------------------------------------------def random
self[rand(size)]
end
#------------------------------------------------------------------------# * New method: random!
#------------------------------------------------------------------------def random!
self.delete_at(rand(size))
end
#--------------------------------------------------------------------------# * New method: sum
#--------------------------------------------------------------------------def sum
end
#==============================================================================
# ** Cache
#-----------------------------------------------------------------------------# This module loads each of graphics, creates a Bitmap object, and retains it.
# To speed up load times and conserve memory, this module holds the created
# Bitmap object in the internal hash, allowing the program to return
# preexisting objects when the same bitmap is requested again.
#==============================================================================
class << Cache
#-------------------------------------------------------------------------# * Overwrite method: character
#-------------------------------------------------------------------------def character(filename, hue = 0)
load_bitmap("Graphics/Characters/", filename, hue)
end
#-------------------------------------------------------------------------# * New method: cache
#-------------------------------------------------------------------------def cache
@cache
end
end
#==============================================================================
# ** BattleManager
#-----------------------------------------------------------------------------# This module handles the battle processing
#==============================================================================
class << BattleManager
#-------------------------------------------------------------------------# * New method: all_battle_members
#-------------------------------------------------------------------------def all_battle_members
$game_party.members + $game_troop.members
end
#-------------------------------------------------------------------------# * New method: all_dead_members
#-------------------------------------------------------------------------def all_dead_members
$game_party.dead_members + $game_troop.dead_members
end
#-------------------------------------------------------------------------# * New method: all_movable_members
#-------------------------------------------------------------------------def all_movable_members
$game_party.movable_members + $game_troop.movable_members
end
end
#==============================================================================
# ** Game_BattlerBase
#-----------------------------------------------------------------------------# This class handles battlers. It s used as a superclass of the Game_Battler
# classes.
#==============================================================================
class Game_BattlerBase
#-------------------------------------------------------------------------# * Public Instance Variables
#-------------------------------------------------------------------------attr_reader :buffs
#-------------------------------------------------------------------------# * New method: get_param
#-------------------------------------------------------------------------def get_param(text)
case text.upcase
when "MAXHP" then self.mhp
when "MAXMP" then self.mmp
when "MAXTP" then self.max_tp
else eval("self.#{text.downcase}")
end
end
#-------------------------------------------------------------------------# * New method: type
#-------------------------------------------------------------------------def type
list = []
get_all_notes.scan(/<BATTLER TYPE: ((?:\w+ *,? *)+)>/i) do
$1.scan(/(\d+)/i) { list.push(make_symbol($1)) }
end
list.uniq
end
#-------------------------------------------------------------------------# * New method: danger?
#-------------------------------------------------------------------------def danger?
hp < mhp * 25 / 100
end
#-------------------------------------------------------------------------# * New method: sprite
#-------------------------------------------------------------------------def sprite
valid = SceneManager.scene_is?(Scene_Battle) && SceneManager.scene.spriteset
valid ? SceneManager.scene.spriteset.sprite(self) : nil
end
#-------------------------------------------------------------------------# * New method: element_set
#-------------------------------------------------------------------------def element_set(item)
element_set = item.element_set
element_set += atk_elements if item.damage.element_id < 0
element_set.delete(0)
element_set.compact
end
#-------------------------------------------------------------------------# * New method: add_state_normal
#-------------------------------------------------------------------------def add_state_normal(state_id, rate = 1, user = self)
chance = rate
chance *= state_rate(state_id)
chance *= luk_effect_rate(user)
add_state(state_id) if rand < chance
end
#-------------------------------------------------------------------------# * New method: damaged?
#--------------------------------------------------------------------------
def damaged?
@result.hp_damage != 0 || @result.mp_damage != 0 || @result.tp_damage != 0
end
#-------------------------------------------------------------------------# * New method: mtp
#-------------------------------------------------------------------------def mtp
return 100
end
end
#==============================================================================
# ** Game_Battler
#-----------------------------------------------------------------------------# This class deals with battlers. It s used as a superclass of the Game_Actor
# and Game_Enemy classes.
#==============================================================================
class Game_Battler < Game_BattlerBase
#-------------------------------------------------------------------------# * Overwrite method: item_effect_recover_hp
#-------------------------------------------------------------------------def item_effect_recover_hp(user, item, effect)
value = item_value_recover_hp(user, item, effect).to_i
@result.hp_damage -= value
@result.success
= true
self.hp += value
end
#-------------------------------------------------------------------------# * Overwrite method: item_effect_recover_mp
#-------------------------------------------------------------------------def item_effect_recover_mp(user, item, effect)
value = item_value_recover_mp(user, item, effect).to_i
@result.mp_damage -= value
@result.success
= true if value != 0
self.mp += value
end
#-------------------------------------------------------------------------# * Overwrite method: item_effect_gain_tp
#-------------------------------------------------------------------------def item_effect_gain_tp(user, item, effect)
value
= item_value_recover_tp(user, item, effect)
self.tp += value
end
#-------------------------------------------------------------------------# * New method: item_value_recover_hp
#-------------------------------------------------------------------------def item_value_recover_hp(user, item, effect)
value = (mhp * effect.value1 + effect.value2) * rec
value *= user.pha if item.is_a?(RPG::Item)
value
end
#-------------------------------------------------------------------------# * New method: item_value_recover_mp
#-------------------------------------------------------------------------def item_value_recover_mp(user, item, effect)
value = (mmp * effect.value1 + effect.value2) * rec
value *= user.pha if item.is_a?(RPG::Item)
value
end
end
#-------------------------------------------------------------------------# * New method: get_all_objects
#-------------------------------------------------------------------------def get_all_objects(*args)
result = []
result += [self] if !args.include?(:self)
result += [self.class] if !args.include?(:class)
result += equips.compact if !args.include?(:equip)
result += states.compact if !args.include?(:state)
result
end
#-------------------------------------------------------------------------# * New method: in_active_party?
#-------------------------------------------------------------------------def in_active_party?
$game_party.battle_members.include?(self)
end
#-------------------------------------------------------------------------# * New method: in_reserve_party?
#-------------------------------------------------------------------------def in_reserve_party?
$game_party.reserve_members.include?(self)
end
#-------------------------------------------------------------------------# * New method: in_party?
#-------------------------------------------------------------------------def in_party?
$game_party.all_members.include?(self)
end
#-------------------------------------------------------------------------# * New method: map_animation
#-------------------------------------------------------------------------def map_animation(id)
$game_map.actors.each do |member|
member.animation_id = id if member.actor == self
end
end
#-------------------------------------------------------------------------# * New method: on_damage_floor
#-------------------------------------------------------------------------def on_damage_floor?
$game_player.on_damage_floor?
end
end
#==============================================================================
# ** Game_Unit
#-----------------------------------------------------------------------------# This class handles units. It s used as a superclass of the Game_Party and
# Game_Troop classes.
#==============================================================================
class Game_Unit
#-------------------------------------------------------------------------# * New method: refresh
#-------------------------------------------------------------------------def refresh
members.each {|member| member.refresh }
end
end
#==============================================================================
# ** Game_Party
#-----------------------------------------------------------------------------# This class handles the party. It includes information on amount of gold
# and items. The instance of this class is referenced by $game_party.
#==============================================================================
class Game_Party < Game_Unit
#-------------------------------------------------------------------------# * New method: average_level
#-------------------------------------------------------------------------def average_level
battle_members.collect {|actor| actor.level }.average
end
#-------------------------------------------------------------------------# * New method: reserve_members
#-------------------------------------------------------------------------def reserve_members
all_members - battle_members
end
end
#==============================================================================
# ** Game_Map
#-----------------------------------------------------------------------------# This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Map
#-------------------------------------------------------------------------# * New method: event_list
#-------------------------------------------------------------------------def event_list
events.values
end
#-------------------------------------------------------------------------# * New method: note
#-------------------------------------------------------------------------def note
@map ? @map.note : ""
end
#-------------------------------------------------------------------------# * New method: vehicles
#-------------------------------------------------------------------------def vehicles
@vehicles
end
#-------------------------------------------------------------------------# * New method: map_events
#-------------------------------------------------------------------------def map_events
@map.events
end
#-------------------------------------------------------------------------# * New method: actors
#-------------------------------------------------------------------------def actors
[$game_player] + $game_player.followers.visible_followers
end
end
#==============================================================================
# ** Game_CharacterBase
#-----------------------------------------------------------------------------# This class deals with characters. Common to all characters, stores basic
# data, such as coordinates and graphics. It s used as a superclass of the
# Game_Character class.
#==============================================================================
class Game_CharacterBase
#-------------------------------------------------------------------------# * Public Instance Variables
#-------------------------------------------------------------------------attr_accessor :move_speed
attr_accessor :move_frequency
#-------------------------------------------------------------------------# * New method: player?
#-------------------------------------------------------------------------def player?
return false
end
#-------------------------------------------------------------------------# * New method: event?
#-------------------------------------------------------------------------def event?
return false
end
#-------------------------------------------------------------------------# * New method: follower?
#-------------------------------------------------------------------------def follower?
return false
end
#-------------------------------------------------------------------------# * New method: vehicle?
#-------------------------------------------------------------------------def vehicle?
return false
end
#-------------------------------------------------------------------------# * New method: frames
#-------------------------------------------------------------------------def frames
return 3
end
#-------------------------------------------------------------------------# * New method: hue
#-------------------------------------------------------------------------def hue
@hue ? @hue : 0
end
end
#==============================================================================
# ** Game_Character
#-----------------------------------------------------------------------------# This class deals with characters. It s used as a superclass of the
#==============================================================================
# ** Game_Follower
#-----------------------------------------------------------------------------# This class handles the followers. Followers are the actors of the party
# that follows the leader in a line. It s used within the Game_Followers class.
#==============================================================================
class Game_Follower < Game_Character
#-------------------------------------------------------------------------# * New method: follower?
#-------------------------------------------------------------------------def follower?
return true
end
#-------------------------------------------------------------------------# * New method: index
#-------------------------------------------------------------------------def index
@member_index
end
#-------------------------------------------------------------------------# * New method: gathering?
#-------------------------------------------------------------------------def gathering?
$game_player.followers.gathering? && !gather?
end
end
#==============================================================================
# ** Game_Followers
#-----------------------------------------------------------------------------# This class handles the followers. It s a wrapper for the built-in class
# "Array." It s used within the Game_Player class.
#==============================================================================
class Game_Followers
#-------------------------------------------------------------------------# * New method: get_actor
#-------------------------------------------------------------------------def get_actor(id)
list = [$game_player] + visible_followers
list.select {|follower| follower.actor && follower.actor.id == id }.first
end
#-------------------------------------------------------------------------# * Method fix: visble_folloers
#-------------------------------------------------------------------------unless method_defined?(:visible_followers)
def visible_followers; visible_folloers; end
end
end
#==============================================================================
# ** Game_Vehicle
#-----------------------------------------------------------------------------# This class handles vehicles. It s used within the Game_Map class. If there
# are no vehicles on the current map, the coordinates is set to (-1,-1).
#==============================================================================
class Game_Vehicle < Game_Character
#--------------------------------------------------------------------------
#-------------------------------------------------------------------------def note
return ""
if !@page || !@page.list || @page.list.size <= 0
return @notes if @notes && @page.list == @note_page
@note_page = @page.list.dup
comment_list = []
@page.list.each do |item|
next unless item && (item.code == 108 || item.code == 408)
comment_list.push(item.parameters[0])
end
@notes = comment_list.join("\r\n")
@notes
end
end
#==============================================================================
# ** Game_Interpreter
#-----------------------------------------------------------------------------# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
class Game_Interpreter
#-------------------------------------------------------------------------# * Alias method: command_108
#-------------------------------------------------------------------------alias :command_108_ve_basic_module :command_108
def command_108
command_108_ve_basic_module
comment_call
end
#-------------------------------------------------------------------------# * New method: comment_call
#-------------------------------------------------------------------------def comment_call
end
#-------------------------------------------------------------------------# * New method: note
#-------------------------------------------------------------------------def note
@comments ? @comments.join("\r\n") : ""
end
end
#==============================================================================
# ** Game_Animation
#-----------------------------------------------------------------------------# Classe that handles Animation data
#==============================================================================
class Game_Animation
#-------------------------------------------------------------------------# * Public Instance Variables
#-------------------------------------------------------------------------attr_accessor :ox
attr_accessor :oy
attr_accessor :rate
attr_accessor :zoom
attr_accessor :loop
attr_accessor :type
attr_accessor :map_x
attr_accessor :map_y
attr_accessor :mirror
attr_accessor :follow
attr_accessor :height
attr_accessor :bitmap1
attr_accessor :bitmap2
attr_accessor :sprites
attr_accessor :duration
attr_accessor :direction
attr_accessor :duplicated
#-------------------------------------------------------------------------# * New method: initialize
#-------------------------------------------------------------------------def initialize(animation, mirror, user = nil)
@animation = animation
@rate
= animation.name =~ /<RATE: ([+-]?\d+)>/i ? [$1.to_i, 1].max : 4
@zoom
= animation.name =~ /<ZOOM: (\d+)%?>/i ? $1.to_i / 100.0 : 1.0
@follow
= animation.name =~ /<FOLLOW>/i ? true : false
@mirror
= mirror
@duration = frame_max * @rate
@direction = user.anim_direction if user
@sprites = []
bellow
= animation.name =~ /<BELLOW>/i
above
= animation.name =~ /<ABOVE>/i
@height
= bellow ? -1 : above ? 300 : 1
end
#-------------------------------------------------------------------------# * New method: data
#-------------------------------------------------------------------------def data
@animation
end
#-------------------------------------------------------------------------# * New method: id
#-------------------------------------------------------------------------def id
@animation.id
end
#-------------------------------------------------------------------------# * New method: name
#-------------------------------------------------------------------------def name
@animation.name
end
#-------------------------------------------------------------------------# * New method: frame_max
#-------------------------------------------------------------------------def frame_max
@animation.frame_max
end
#-------------------------------------------------------------------------# * New method: position
#-------------------------------------------------------------------------def position
@animation.position
end
#-------------------------------------------------------------------------# * New method: animation1_name
#--------------------------------------------------------------------------
def animation1_name
@animation.animation1_name
end
#-------------------------------------------------------------------------# * New method: animation2_name
#-------------------------------------------------------------------------def animation2_name
@animation.animation2_name
end
#-------------------------------------------------------------------------# * New method: animation1_hue
#-------------------------------------------------------------------------def animation1_hue
@animation.animation1_hue
end
#-------------------------------------------------------------------------# * New method: animation2_hue
#-------------------------------------------------------------------------def animation2_hue
@animation.animation2_hue
end
#-------------------------------------------------------------------------# * New method: frames
#-------------------------------------------------------------------------def frames
@animation.frames
end
#-------------------------------------------------------------------------# * New method: timings
#-------------------------------------------------------------------------def timings
@animation.timings
end
end
#==============================================================================
# ** Sprite_Character
#-----------------------------------------------------------------------------# This sprite is used to display characters. It observes a instance of the
# Game_Character class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Character < Sprite_Base
#-------------------------------------------------------------------------# * Overwrite method: set_character_bitmap
#-------------------------------------------------------------------------def set_character_bitmap
update_character_info
set_bitmap
set_bitmap_position
end
#-------------------------------------------------------------------------# * New method: center_y
#-------------------------------------------------------------------------def actor?
@character.is_a?(Game_Player) || @character.is_a?(Game_Follower)
end
#-------------------------------------------------------------------------# * New method: center_y
#--------------------------------------------------------------------------
def actor
actor? ? @character.actor : nil
end
#-------------------------------------------------------------------------# * New method: update_character_info
#-------------------------------------------------------------------------def update_character_info
end
#-------------------------------------------------------------------------# * New method: hue
#-------------------------------------------------------------------------def hue
@character.hue
end
#-------------------------------------------------------------------------# * New method: set_bitmap
#-------------------------------------------------------------------------def set_bitmap
self.bitmap = Cache.character(set_bitmap_name, hue)
end
#-------------------------------------------------------------------------# * New method: set_bitmap_name
#-------------------------------------------------------------------------def set_bitmap_name
@character_name
end
#-------------------------------------------------------------------------# * New method: set_bitmap_position
#-------------------------------------------------------------------------def set_bitmap_position
sign = get_sign
if sign && sign.include?( $ )
@cw = bitmap.width / @character.frames
@ch = bitmap.height / 4
else
@cw = bitmap.width / (@character.frames * 4)
@ch = bitmap.height / 8
end
self.ox = @cw / 2
self.oy = @ch
end
#-------------------------------------------------------------------------# * New method: get_sign
#-------------------------------------------------------------------------def get_sign
@character_name[/^[\!\$]./]
end
end
#==============================================================================
# ** Sprite_Battler
#-----------------------------------------------------------------------------# This sprite is used to display battlers. It observes a instance of the
# Game_Battler class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Battler < Sprite_Base
#-------------------------------------------------------------------------# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :dmg_mirror
#-------------------------------------------------------------------------# * New method: center_x
#-------------------------------------------------------------------------def center_x
self.ox
end
#-------------------------------------------------------------------------# * New method: center_y
#-------------------------------------------------------------------------def center_y
self.oy / 2
end
end
#==============================================================================
# ** Spriteset_Battle
#-----------------------------------------------------------------------------# This class brings together battle screen sprites. It s used within the
# Scene_Battle class.
#==============================================================================
class Spriteset_Battle
#-------------------------------------------------------------------------# * Public Instance Variables
#-------------------------------------------------------------------------attr_reader :viewport1
#-------------------------------------------------------------------------# * New method: sprite
#-------------------------------------------------------------------------def sprite(subject)
battler_sprites.compact.select {|sprite| sprite.battler == subject }.first
end
end
#==============================================================================
# ** Window_Base
#-----------------------------------------------------------------------------# This is a superclass of all windows in the game.
#==============================================================================
class Window_Base < Window
#-------------------------------------------------------------------------# * Alias method: convert_escape_characters
#-------------------------------------------------------------------------alias :convert_escape_ve_basic_module :convert_escape_characters
def convert_escape_characters(text)
result = text.to_s.clone
result = text_replace(result)
result = convert_escape_ve_basic_module(text)
result
end
#-------------------------------------------------------------------------# * New method: text_replace
#-------------------------------------------------------------------------def text_replace(result)
result.gsub!(/\r/) { "" }
result.gsub!(/\\/) { "\e" }
result
end
end
#==============================================================================
# ** Scene_Battle
#-----------------------------------------------------------------------------# This class performs battle screen processing.
#==============================================================================
class Scene_Battle < Scene_Base
#-------------------------------------------------------------------------# * Public Instance Variables
#-------------------------------------------------------------------------attr_reader :subject
attr_reader :spriteset
end
#==============================================================================
# ** Scene_Battle
#-----------------------------------------------------------------------------# This class performs map screen processing.
#==============================================================================
class Scene_Map < Scene_Base
#-------------------------------------------------------------------------# * Public Instance Variables
#-------------------------------------------------------------------------attr_reader :spriteset
end