Professional Documents
Culture Documents
#
# class Game_Interpreter
#
def comment_call
#
#-----------------------------------------------------------------------------# Instructions:
# To instal the script, open you script editor and paste this script on
# a new section bellow the Materials section. This script must also
# be bellow the scripts 'Victor Engine - Basic' and
# 'Victor Engine - Multi Frames'.
#
#-----------------------------------------------------------------------------# Comment calls note tags:
# Tags to be used in events comment box, works like a script call.
#
# <actor diagonal on>
# <actor diagonal off>
# These tags allows to turn the diagonal on or off for the player.
#
# <event i diagonal on>
# <event i diagonal off>
# These tags allows to turn the diagonal on or off for events.
#
i : event ID
#
#-----------------------------------------------------------------------------# Comment boxes note tags:
# Tags to be used on events Comment boxes. They're different from the
# comment call, they're called always the even refresh.
#
# <diagonal move>
#
This tag allows the diagonal move for events if VE_DIAGONAL_EVENTS = false
#
It enables the diagonal move only for the page where the comment
#
is located
#
# <block diagonal>
#
This tag disable the diagonal move for events if VE_DIAGONAL_EVENTS = true
#
It disable the diagonal move only for the page where the comment
#
is located
#
#-----------------------------------------------------------------------------# Additional instructions:
#
# To add custom graphic for diagonal movement, you must have a graphic
# with the sufix set on VE_DIAGONAL_SUFIX added to it's name, by default
# this sufix is "[diag]", so you must have a file named "CharName[diag]"
# for a chaset named "CharName". If the diagonal file doesn't exist, it
# will use the normal graphic.
#
#==============================================================================
#==============================================================================
# ** Victor Engine
#-----------------------------------------------------------------------------# Setting module for the Victor Engine
#==============================================================================
module Victor_Engine
#-------------------------------------------------------------------------# * Diagonal graphic sufix
#
Sufix added to the names of diagonal movement graphics.
#-------------------------------------------------------------------------VE_DIAGONAL_SUFIX = "[diag]"
#-------------------------------------------------------------------------# * Set diagonal movement for events
#
If true, automatically all events will have diagonal movement
#
If false, you must add the diagonal movement manually by adding the
#
comment tag for diagonal move on it.
#-------------------------------------------------------------------------VE_DIAGONAL_EVENTS = false
#-------------------------------------------------------------------------# * Fix blocked diagonal movement
# If true, when the diagonal movement is blocked, then the character
# moves straight to the direction not blocked.
#-------------------------------------------------------------------------VE_DIAGONAL_FIX = false
#-------------------------------------------------------------------------# * required
# This method checks for the existance of the basic module and other
# VE scripts required for this script to work, don't edit this
#-------------------------------------------------------------------------def self.required(name, req, version, type = nil)
if !$imported[:ve_basic_module]
msg = "The script '%s' requires the script\n"
msg += "'VE - Basic Module' v%s or higher above it to work properly\n"
msg += "Go to http://victorscripts.wordpress.com/ to download this script.
"
msgbox(sprintf(msg, self.script_name(name), version))
exit
else
self.required_script(name, req, version, type)
end
end
#-------------------------------------------------------------------------# * script_name
# Get the script name base on the imported value, don't edit this
#-------------------------------------------------------------------------def self.script_name(name, ext = "VE")
name = name.to_s.gsub("_", " ").upcase.split
name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
name.join(" ")
end
end
$imported ||= {}
$imported[:ve_diagonal_move] = 1.09
Victor_Engine.required(:ve_diagonal_move, :ve_basic_module, 1.16, :above)
Victor_Engine.required(:ve_diagonal_move, :ve_character_control, 1.10, :bellow)
#==============================================================================
# ** 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_reader :diagonal
#-------------------------------------------------------------------------# * Alias method: init_public_members
#-------------------------------------------------------------------------alias :init_public_members_ve_diagonal_move :init_public_members
def init_public_members
init_public_members_ve_diagonal_move
@diagonal = 0
end
#-------------------------------------------------------------------------# * Alias method: move_straight
#-------------------------------------------------------------------------alias :move_straight_ve_diagonal_move :move_straight
def move_straight(d, turn_ok = true)
@diagonal = 0
move_straight_ve_diagonal_move(d, turn_ok)
end
#-------------------------------------------------------------------------# * Alias method: move_diagonal
#-------------------------------------------------------------------------alias :move_diagonal_ve_diagonal_move :move_diagonal
def move_diagonal(horz, vert)
@diagonal = 1 if diagonal_enabled? && horz == 4 && vert == 2
@diagonal = 3 if diagonal_enabled? && horz == 6 && vert == 2
@diagonal = 7 if diagonal_enabled? && horz == 4 && vert == 8
@diagonal = 9 if diagonal_enabled? && horz == 6 && vert == 8
move_diagonal_ve_diagonal_move(horz, vert)
diagonal_direction if diagonal_enabled?
end
#-------------------------------------------------------------------------# * Alias method: distance_per_frame
#-------------------------------------------------------------------------alias :distance_per_frame_ve_diagonal_move :distance_per_frame
def distance_per_frame
distance = distance_per_frame_ve_diagonal_move
diagonal? ? distance / Math.sqrt(2) : distance
end
#-------------------------------------------------------------------------# * New method: diagonal_enabled?
#-------------------------------------------------------------------------def diagonal_enabled?
@diagonal_enabled
end
#-------------------------------------------------------------------------# * New method: diagonal?
#-------------------------------------------------------------------------def diagonal?
@diagonal && @diagonal != 0
end
end
#==============================================================================
# ** Game_Character
#-----------------------------------------------------------------------------# This class deals with characters. It's used as a superclass of the
# Game_Player and Game_Event classes.
#==============================================================================
class Game_Character < Game_CharacterBase
#--------------------------------------------------------------------------
end
#-------------------------------------------------------------------------# * New method: diagonal_move_fix
#-------------------------------------------------------------------------def perform_move_fix_pixel(horz, vert)
return if @moved || moving?
@move_value = nil
@diagonal = nil
set_direction(horz)
if passable?(@x, @y, horz) && !@moved
move_straight_pixel(horz) if passable?(@x, @y, horz) && !@moved
set_direction(vert)
if passable?(@x, @y, vert) && !@moved
move_straight_pixel(vert) if passable?(@x, @y, vert) && !@moved
end
end
#==============================================================================
# ** Game_Event
#-----------------------------------------------------------------------------# This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================
class Game_Event < Game_Character
#-------------------------------------------------------------------------# * Alias method: clear_page_settings
#-------------------------------------------------------------------------alias :clear_page_settings_ve_diagonal_move :clear_page_settings
def clear_page_settings
clear_page_settings_ve_diagonal_move
@diagonal_enabled = false
end
#-------------------------------------------------------------------------# * Alias method: setup_page_settings
#-------------------------------------------------------------------------alias :setup_page_settings_ve_diagonal_move :setup_page_settings
def setup_page_settings
setup_page_settings_ve_diagonal_move
@diagonal_enabled = VE_DIAGONAL_EVENTS || note =~ /<DIAGONAL MOVE>/i
@diagonal_enabled = false if note =~ /<BLOCK DIAGONAL>/i
end
end
#==============================================================================
# ** Game_Player
#-----------------------------------------------------------------------------# This class handles maps. It includes event starting determinants and map
# scrolling functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Player < Game_Character
#-------------------------------------------------------------------------# * Alias method: initialize
#-------------------------------------------------------------------------alias :initialize_ve_diagonal_move :initialize
def initialize
initialize_ve_diagonal_move
diagonal_on
end
#--------------------------------------------------------------------------
#-----------------------------------------------------------------------------# 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: diagonal_on
#-------------------------------------------------------------------------def diagonal_on
each {|follower| follower.diagonal_on }
end
#-------------------------------------------------------------------------# * New method: diagonal_off
#-------------------------------------------------------------------------def diagonal_off
each {|follower| follower.diagonal_off }
end
end
#==============================================================================
# ** Game_Vehicle
#-----------------------------------------------------------------------------# Esta classe gerencia veculos. Se no houver veculos no mapa atual, a
# coordenada definida como (-1,-1).
# Esta classe usada internamente pela classe Game_Map.
#==============================================================================
class Game_Vehicle < Game_Character
#-------------------------------------------------------------------------# * Alias method: sync_with_player
#-------------------------------------------------------------------------alias :sync_with_player_ve_diagonal_move :sync_with_player
def sync_with_player
sync_with_player_ve_diagonal_move
@diagonal = $game_player.diagonal
diagonal_direction
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
#-------------------------------------------------------------------------# * Alias method: graphic_changed?
#-------------------------------------------------------------------------alias :graphic_changed_ve_diagonal_move :graphic_changed?
def graphic_changed?
graphic_changed_ve_diagonal_move ||
@diagonal != @character.diagonal
end
#-------------------------------------------------------------------------# * New method: update_character_info
#-------------------------------------------------------------------------alias :update_character_info_ve_diagonal_move :update_character_info
def update_character_info
update_character_info_ve_diagonal_move
@diagonal = @character.diagonal
end
#-------------------------------------------------------------------------# * Alias method: update_src_rect
#-------------------------------------------------------------------------alias :update_src_rect_ve_diagonal_move :update_src_rect
def update_src_rect
if @tile_id == 0 && @character.diagonal?
update_diagonal_src_rect
else
update_src_rect_ve_diagonal_move
end
end
#-------------------------------------------------------------------------# * Overwrite method: set_character_diagonal_bitmap
#-------------------------------------------------------------------------alias :set_bitmap_name_ve_diagonal_move :set_bitmap_name
def set_bitmap_name
name = @character_name + ($imported[:ve_visual_equip] ? "" : diagonal_sufix)
character_exist?(name) ? name : set_bitmap_name_ve_diagonal_move
end
#-------------------------------------------------------------------------# * New method: diagonal_sufix
#-------------------------------------------------------------------------def diagonal_sufix
@character.diagonal? ? VE_DIAGONAL_SUFIX : ""
end
#-------------------------------------------------------------------------# * New method: update_diagonal_src_rect
#-------------------------------------------------------------------------def update_diagonal_src_rect
dir = 0 if @diagonal == 1
dir = 1 if @diagonal == 7
dir = 2 if @diagonal == 3
dir = 3 if @diagonal == 9
index = @character.character_index
if $imported[:ve_multi_frames] && @character_name[/\[F(\d+)\]/i]
pattern = @character.pattern
else
pattern = @character.pattern < 3 ? @character.pattern : 1
end
sx = (index % 4 * @character.frames + pattern) * @cw
sy = (index / 4 * 4 + dir) * @ch
self.src_rect.set(sx, sy, @cw, @ch)
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: comment_call
#--------------------------------------------------------------------------