赞 | 0 |
VIP | 17 |
好人卡 | 1 |
积分 | 0 |
经验 | 8556 |
最后登录 | 2016-8-12 |
在线时间 | 543 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 48
- 在线时间
- 543 小时
- 注册时间
- 2011-6-25
- 帖子
- 441
|
- #==============================================================================
- # ** Victor Engine - Pixel Movement
- #------------------------------------------------------------------------------
- # Author : Victor Sant
- #
- # Version History:
- # v 1.00 - 2012.05.29 > First relase
- # v 1.01 - 2012.05.29 > Compatibility with Terrain States
- # v 1.02 - 2012.07.03 > Compatibility with Basic Module 1.23
- # v 1.03 - 2012.07.05 > Added 'over event' tag for objects over blocked tiles
- # > Added Steps settings for events
- # v 1.04 - 2012.07.24 > Compatibility with Moving Platform
- # > Added <each step trigger> tag for events
- # v 1.05 - 2012.07.30 > Fixed issue when characters moves toward the same spot
- # v 1.06 - 2012.08.03 > Compatibility with Anti Lag
- # v 1.07 - 2012.08.03 > Fixed collision with tile graphics events
- #------------------------------------------------------------------------------
- # This script allows to replace the tile based movement where the player
- # walks a whole 32 pixel tile each step with one that he walks only 4 pixels.
- # It also give a better collision system for events.
- #------------------------------------------------------------------------------
- # Compatibility
- # Requires the script 'Victor Engine - Basic Module' v 1.25 or higher
- # If used with 'Victor Engine - Animated Battle' place this bellow it.
- # If used with 'Victor Engine - Follower Control' place this bellow it.
- # If used with 'Victor Engine - Follower Options' place this bellow it.
- #
- # * Overwrite methods
- # class Game_Actor < Game_Battler
- # def turn_end_on_map
- #
- # class Game_Map
- # def layered_tiles(x, y)
- # def events_xy(x, y)
- # def events_xy_nt(x, y)
- # def x_with_direction(x, d, times = 1)
- # def y_with_direction(y, d, times = 1)
- # def round_x_with_direction(x, d)
- # def round_y_with_direction
- #
- # class Game_CharacterBase
- # def region_id
- # def move_straight(d, turn_ok = true)
- # def move_diagonal(horz, vert)
- # def collide_with_events?(x, y)
- # def collide_with_vehicles?(x, y)
- #
- # class Game_Player < Game_Character
- # def check_event_trigger_there(triggers)
- # def start_map_event(x, y, triggers, normal)
- # def update_nonmoving(last_moving)
- # def get_on_vehicle
- # def increase_steps
- #
- # class Game_Follower < Game_Character
- # def chase_preceding_character
- #
- # class Game_Event < Game_Character
- # def collide_with_player_characters?(x, y)
- #
- # class Game_Vehicle < Game_Character
- # def land_ok?(x, y, d)
- #
- # * Alias methods
- # class Game_Actor < Game_Battler
- # def check_floor_effect
- #
- # class Game_CharacterBase
- # def init_public_members
- # def update
- #
- # class Game_Character < Game_CharacterBase
- # def move_toward_character(character)
- # def move_toward_position(x, y)
- #
- # class Game_Event < Game_Character
- # def start
- #
- # class Game_Player < Game_Character
- # def get_off_vehicle
- # def clear_transfer_info
- # def update
- #
- # class Game_Event < Game_Character
- # def start
- #
- #------------------------------------------------------------------------------
- # 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 script 'Victor Engine - Basic'
- #
- #------------------------------------------------------------------------------
- # Event Comment boxes note tags:
- # Tags to be used on events Comment boxes.
- #
- # <move steps: x>
- # Setup the number of steps each "Move" command will execute. The default
- # value is 8 (1 tile)
- # x : number of steps
- #
- # <event size: x, y>
- # Collision area size, in pixels for event collisions.
- # x : collision area width
- # y : collision area height
- #
- # <front collision>
- # Events with this tag won't start if the the collision between events and
- # the player occur between their edges.
- #
- # <no side collision fix>
- # Events with this tag won't have the "slide" effect when the edges of the
- # events collide with the player
- #
- # <over tile>
- # Events with this tag will start even when placed over blocked tiles.
- # By default, if the passage is blocked the event don't stat.
- #
- # <each step trigger>
- # By default, events with through or bellow character priority triggers
- # only one time for each 8 steps above them. With this tag though, the
- # event will trigger every step.
- #
- #------------------------------------------------------------------------------
- # Additional instructions:
- #
- # All events and tiles have a "slide" effect when the player faces the edge
- # of a tile or event. I added this function since it would be a pain to
- # be in the exact position to go throug a narrow path.
- # This can be disabled for events, but not for tiles.
- #
- #==============================================================================
- #==============================================================================
- # ** Victor Engine
- #------------------------------------------------------------------------------
- # Setting module for the Victor Engine
- #==============================================================================
- module Victor_Engine
- #--------------------------------------------------------------------------
- # * Player collision area
- # Different from events, player collision don't rely on the graphic size
- # Player collision area can be of 2 types:
- # - 32 x 32 box if VE_PLAYER_BIG_COLLISION = true
- # - 24 x 24 box if VE_PLAYER_BIG_COLLISION = false
- #--------------------------------------------------------------------------
- VE_PLAYER_BIG_COLLISION = true
- #--------------------------------------------------------------------------
- # * 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
- #--------------------------------------------------------------------------
- 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_pixel_movement] = 1.07
- Victor_Engine.required(:ve_pixel_movement, :ve_basic_module, 1.25, :above)
- Victor_Engine.required(:ve_pixel_movement, :ve_map_battle, 1.00, :bellow)
- Victor_Engine.required(:ve_pixel_movement, :ve_diagonal_move, 1.00, :bellow)
- #==============================================================================
- # ** Game_Actor
- #------------------------------------------------------------------------------
- # This class handles actors. It's used within the Game_Actors class
- # ($game_actors) and referenced by the Game_Party class ($game_party).
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # * Overwrite method: turn_end_on_map
- #--------------------------------------------------------------------------
- def turn_end_on_map
- if $game_player.steps % (steps_for_turn * 8) == 0
- on_turn_end
- perform_map_damage_effect if @result.hp_damage > 0
- end
- end
- #--------------------------------------------------------------------------
- # * Alias method: init_public_members
- #--------------------------------------------------------------------------
- alias :check_floor_effect_ve_pixel_movement :check_floor_effect
- def check_floor_effect
- return if check_damage_floor
- check_floor_effect_ve_pixel_movement
- end
- #--------------------------------------------------------------------------
- # * New method: check_damage_floor
- #--------------------------------------------------------------------------
- def check_damage_floor
- $game_player.damage_floor % 8 != 0
- 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
- #--------------------------------------------------------------------------
- # * Overwrite method: layered_tiles
- #--------------------------------------------------------------------------
- def layered_tiles(x, y)
- x2 = (x - 0.5).ceil
- y2 = (y - 0.125).ceil
- [2, 1, 0].collect {|z| tile_id(x2, y2, z) }
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: events_xy
- #--------------------------------------------------------------------------
- def events_xy(x, y)
- event_list.select {|event| event.near?(x, y) }
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: events_xy_nt
- #--------------------------------------------------------------------------
- def events_xy_nt(x, y)
- event_list.select {|event| event.near_nt?(x, y) }
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: x_with_direction
- #--------------------------------------------------------------------------
- def x_with_direction(x, d, times = 1)
- x + (d == 6 ? times * 0.125 : d == 4 ? -times * 0.125 : 0)
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: y_with_direction
- #--------------------------------------------------------------------------
- def y_with_direction(y, d, times = 1)
- y + (d == 2 ? times * 0.125 : d == 8 ? -times * 0.125 : 0)
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: round_x_with_direction
- #--------------------------------------------------------------------------
- def round_x_with_direction(x, d)
- round_x(x + (d == 6 ? 0.125 : d == 4 ? -0.125 : 0))
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: round_y_with_direction
- #--------------------------------------------------------------------------
- def round_y_with_direction(y, d)
- round_y(y + (d == 2 ? 0.125 : d == 8 ? -0.125 : 0))
- end
- #--------------------------------------------------------------------------
- # * New method: check_x_with_direction
- #--------------------------------------------------------------------------
- def check_x_with_direction(x, d)
- round_x(x + (d == 6 ? 1 : d == 4 ? -1 : 0))
- end
- #--------------------------------------------------------------------------
- # * New method: check_y_with_direction
- #--------------------------------------------------------------------------
- def check_y_with_direction(y, d)
- round_y(y + (d == 2 ? 1 : d == 8 ? -1 : 0))
- 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 :next_movement
- attr_accessor :side_collision
- attr_accessor :damage_floor
- attr_accessor :steps
- #--------------------------------------------------------------------------
- # * Overwrite method: region_id
- #--------------------------------------------------------------------------
- def region_id
- $game_map.region_id((@x - 0.5).ceil, (@y - 0.125).ceil)
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: collide_with_events?
- #--------------------------------------------------------------------------
- def collide_with_events?(x, y)
- $game_map.events_xy_nt(x, y).any? do |event|
- event.collision_condition?(x, y, bw, bh, event?, @id, @side_collision)
- end
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: collide_with_vehicles?
- #--------------------------------------------------------------------------
- def collide_with_vehicles?(x, y)
- $game_map.vehicles.compact.any? do |vehicle|
- next if vehicle.map_id != $game_map.map_id
- vehicle.vehicle_collision?(x, y, bw, bh, self)
- end
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: move_straight
- #--------------------------------------------------------------------------
- def move_straight(d, turn_ok = true)
- @move_list += [{d: [d], turn: turn_ok}] * step_times
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: move_straight
- #--------------------------------------------------------------------------
- def move_diagonal(horz, vert)
- @move_list += [{d: [horz, vert], turn: true}] * step_times
- end
- #--------------------------------------------------------------------------
- # * Alias method: init_public_members
- #--------------------------------------------------------------------------
- alias :init_public_members_ve_pixel_movement :init_public_members
- def init_public_members
- init_public_members_ve_pixel_movement
- @move_list = []
- @next_movement = []
- @over_event = 0
- @damage_floor = 0
- @steps = 0
- end
- #--------------------------------------------------------------------------
- # * Alias method: update
- #--------------------------------------------------------------------------
- alias :update_ve_pixel_movement :update
- def update
- update_move_straight
- update_move_diagonal
- update_ve_pixel_movement
- end
- #--------------------------------------------------------------------------
- # * New method: update_move_straight
- #--------------------------------------------------------------------------
- def update_move_straight
- return if moving? || @move_list.empty?
- return if @move_list.first[:d].size > 1
- move = @move_list.shift
- d = move[:d].first
- if passable?(@x, @y, d)
- @diagonal_move = false
- setup_movement(d, d)
- @real_x = $game_map.x_with_direction(@x, reverse_dir(d))
- @real_y = $game_map.y_with_direction(@y, reverse_dir(d))
- @moved = player?
- elsif move[:turn]
- check_event_trigger_move(d)
- end
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: update_move_diagonal
- #--------------------------------------------------------------------------
- def update_move_diagonal
- return if moving? || @move_list.empty?
- return if @move_list.first[:d].size < 2
- move = @move_list.shift
- horz = move[:d].first
- vert = move[:d].last
- if diagonal_passable?(x, y, horz, vert)
- @diagonal_move = true
- setup_movement(horz, vert)
- @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
- @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
- @moved = player?
- end
- end
- #--------------------------------------------------------------------------
- # * New method: character_collision?
- #--------------------------------------------------------------------------
- def character_collision?(x, y, d)
- x2 = $game_map.round_x_with_direction(x, d)
- y2 = $game_map.round_y_with_direction(y, d)
- !collide_with_characters?(x2, y2) || @through || debug_through?
- end
- #--------------------------------------------------------------------------
- # * New method: step_times
- #--------------------------------------------------------------------------
- def step_times
- return 8
- end
- #--------------------------------------------------------------------------
- # * New method: near_nt?
- #--------------------------------------------------------------------------
- def near_nt?(x, y)
- near?(x, y) && !@through
- end
- #--------------------------------------------------------------------------
- # * New method: near?
- #--------------------------------------------------------------------------
- def near?(x, y)
- w = step_over? ? [bw * 0.625, 0.5].max : [bw, 1.0].max
- h = step_over? ? [bh * 0.625, 0.5].max : [bh, 1.0].max
- @real_x > x - w && @real_x < x + w && @real_y > y - h && @real_y < y + h
- end
- #--------------------------------------------------------------------------
- # * New method: setup_movement
- #--------------------------------------------------------------------------
- def setup_movement(horz, vert)
- @x = $game_map.round_x_with_direction(@x, horz)
- @y = $game_map.round_y_with_direction(@y, vert)
- add_next_movement(horz == vert ? horz : [horz, vert])
- set_direction(horz) if @direction == reverse_dir(horz) || horz == vert
- set_direction(vert) if @direction == reverse_dir(vert) && horz != vert
- follower_control_move_update(horz, vert)
- increase_steps
- end
- #--------------------------------------------------------------------------
- # * New method: check_event_trigger_move
- #--------------------------------------------------------------------------
- def check_event_trigger_move(d)
- set_direction(d)
- check_event_trigger_touch_front
- end
- #--------------------------------------------------------------------------
- # * New method: collision_condition?
- #--------------------------------------------------------------------------
- def collision_condition?(x, y, bw, bh, event, event_id, side)
- return false if event && self.id == event_id
- return false unless collision?(x, y, bw, bh)
- return false unless normal_priority? || event
- return false if side && !side_collision?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: follower_control_move_update
- #--------------------------------------------------------------------------
- def follower_control_move_update(horz, vert)
- return unless $imported[:ve_followers_options]
- return unless player? || follower?
- add_move_update(horz == vert ? [horz] : [horz, vert])
- end
- #--------------------------------------------------------------------------
- # * New method: passable?
- #--------------------------------------------------------------------------
- def passable?(x, y, d)
- x = fix_position(x)
- y = fix_position(y)
- passable1 = passable_tile?(x, y, d)
- passable2 = character_collision?(x, y, d)
- fix_movement(x, y, d) if player? && !passable1 && passable2
- fix_collision(x, y, d) if player? && !passable2 && passable1
- passable1 && passable2
- end
- #--------------------------------------------------------------------------
- # * New method: passable_tile?
- #--------------------------------------------------------------------------
- def passable_tile?(x, y, d)
- result = true
- result = passable_down?(x, y) if d == 2
- result = passable_left?(x, y) if d == 4
- result = passable_right?(x, y) if d == 6
- result = passable_up?(x, y) if d == 8
- result
- end
- #--------------------------------------------------------------------------
- # * New method: locked_tile?
- #--------------------------------------------------------------------------
- def locked_tile?(x, y, d = 0)
- list = [2, 4, 6, 8] - [d]
- list.all? {|d| !map_passable?(x, y, d) }
- end
- #--------------------------------------------------------------------------
- # * New method: locked_move?
- #--------------------------------------------------------------------------
- def locked_move?(x, y)
- !passable_down?(x, y) && !passable_left?(x, y)
- !passable_right?(x, y) && !passable_up?(x, y)
- end
- #--------------------------------------------------------------------------
- # * New method: passable_down?
- #--------------------------------------------------------------------------
- def passable_down?(x, y)
- passable_normal?(x.ceil, y.to_i, 2, 4, x.ceil?) &&
- passable_normal?(x.to_i, y.to_i, 2, 6, x.ceil?)
- end
- #--------------------------------------------------------------------------
- # * New method: passable_left?
- #--------------------------------------------------------------------------
- def passable_left?(x, y)
- passable_normal?(x.ceil, y.ceil, 4, 8, y.ceil?) &&
- passable_normal?(x.ceil, y.to_i, 4, 2, y.ceil?)
- end
- #--------------------------------------------------------------------------
- # * New method: passable_right?
- #--------------------------------------------------------------------------
- def passable_right?(x, y)
- passable_normal?(x.to_i, y.ceil, 6, 8, y.ceil?) &&
- passable_normal?(x.to_i, y.to_i, 6, 2, y.ceil?)
- end
- #--------------------------------------------------------------------------
- # * New method: passable_up?
- #--------------------------------------------------------------------------
- def passable_up?(x, y)
- passable_normal?(x.ceil, y.ceil, 8, 4, x.ceil?) &&
- passable_normal?(x.to_i, y.ceil, 8, 6, x.ceil?)
- end
- #--------------------------------------------------------------------------
- # * New method: passable_normal?
- #--------------------------------------------------------------------------
- def passable_normal?(x, y, d, d2, ceil = false)
- x1 = $game_map.round_x(x)
- y1 = $game_map.round_y(y)
- x2 = $game_map.check_x_with_direction(x1, d)
- y2 = $game_map.check_y_with_direction(y1, d)
- x3 = $game_map.round_x_with_direction(x1, d)
- y3 = $game_map.round_y_with_direction(y1, d)
- return false unless $game_map.valid?(x3, y3)
- return true if @through || debug_through?
- return false unless map_passable?(x2, y2, d2) || !ceil
- return false unless move_passable1?(x1, y1, x2, y2, d)
- return false unless move_passable2?(x1, y1, x2, y2, d)
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: move_passable1?
- #--------------------------------------------------------------------------
- def move_passable1?(x1, y1, x2, y2, d)
- map_passable?(x1, y1, d) || map_passable?(x2, y2, d)
- end
- #--------------------------------------------------------------------------
- # * New method: move_passable?
- #--------------------------------------------------------------------------
- def move_passable2?(x1, y1, x2, y2, d)
- map_passable?(x2, y2, reverse_dir(d)) && (map_passable?(x1, y1, d) ||
- locked_tile?(x1, y1))
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement
- #--------------------------------------------------------------------------
- def fix_movement(x, y, d)
- return if (@diagonal && @diagonal != 0) || @diagonal_move
- fix_movement_horiz(x, y, d) if (d == 2 || d == 8) && x.ceil?
- fix_movement_vert(x, y, d) if (d == 4 || d == 6) && y.ceil?
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_horiz
- #--------------------------------------------------------------------------
- def fix_movement_horiz(x, y, d)
- adjust = x - x.to_i
- fix_move_straight(4) if fix_movement_left?(x, y, d) && adjust < 0.5
- fix_move_straight(6) if fix_movement_right?(x, y, d) && adjust > 0.5
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_ver
- #--------------------------------------------------------------------------
- def fix_movement_vert(x, y, d)
- adjust = y - y.to_i
- fix_move_straight(2) if fix_movement_down?(x, y, d) && adjust > 0.5
- fix_move_straight(8) if fix_movement_up?(x, y, d) && adjust < 0.5
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_down?
- #--------------------------------------------------------------------------
- def fix_movement_down?(x, y, d)
- passable_normal?(x.to_i, y.ceil, d, 0, false) && movement_fix?(x, y, 2)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_left?
- #--------------------------------------------------------------------------
- def fix_movement_left?(x, y, d)
- passable_normal?(x.to_i, y.to_i, d, 0, false) && movement_fix?(x, y, 4)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_right?
- #--------------------------------------------------------------------------
- def fix_movement_right?(x, y, d)
- passable_normal?(x.ceil, y.to_i, d, 0, false) && movement_fix?(x, y, 6)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_up?
- #--------------------------------------------------------------------------
- def fix_movement_up?(x, y, d)
- passable_normal?(x.to_i, y.to_i, d, 0, false) && movement_fix?(x, y, 8)
- end
- #--------------------------------------------------------------------------
- # * New method: movement_fix?
- #--------------------------------------------------------------------------
- def movement_fix?(x, y, d)
- passable_tile?(x, y, d) && character_collision?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision
- #--------------------------------------------------------------------------
- def fix_collision(x, y, d)
- return if (@diagonal && @diagonal != 0) || @diagonal_move
- @side_collision = true
- fix_collision_horiz(x, y, d) if (d == 2 || d == 8)
- fix_collision_vert(x, y, d) if (d == 4 || d == 6)
- @side_collision = false
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_horiz
- #--------------------------------------------------------------------------
- def fix_collision_horiz(x, y, d)
- fix_move_straight(4) if fix_collision_left?(x, y, d)
- fix_move_straight(6) if fix_collision_right?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_vert
- #--------------------------------------------------------------------------
- def fix_collision_vert(x, y, d)
- fix_move_straight(2) if fix_collision_down?(x, y, d)
- fix_move_straight(8) if fix_collision_up?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_down?
- #--------------------------------------------------------------------------
- def fix_collision_down?(x, y, d)
- !character_collision?(x, y, d) && collision_fix?(x, y, d, 2)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_left?
- #--------------------------------------------------------------------------
- def fix_collision_left?(x, y, d)
- !character_collision?(x, y, d) && collision_fix?(x, y, d, 4)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_right?
- #--------------------------------------------------------------------------
- def fix_collision_right?(x, y, d)
- !character_collision?(x, y, d) && collision_fix?(x, y, d, 6)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_up?
- #--------------------------------------------------------------------------
- def fix_collision_up?(x, y, d)
- !character_collision?(x, y, d) && collision_fix?(x, y, d, 8)
- end
- #--------------------------------------------------------------------------
- # * New method: collision_fix?
- #--------------------------------------------------------------------------
- def collision_fix?(x, y, d, d2)
- side_collision_fix?(x, y, d, d2, 2) && side_fix?(x, y, d2)
- end
- #--------------------------------------------------------------------------
- # * New method: side_collision_fix?
- #--------------------------------------------------------------------------
- def side_collision_fix?(x, y, d, d2, t)
- t.times.any? do |i|
- x2, y2 = x, y
- y2 += (t - i) * 0.125 if d2 == 2
- x2 -= (t - i) * 0.125 if d2 == 4
- x2 += (t - i) * 0.125 if d2 == 6
- y2 -= (t - i) * 0.125 if d2 == 8
- character_collision?(x2, y2, d)
- end
- end
- #--------------------------------------------------------------------------
- # * New method: side_fix?
- #--------------------------------------------------------------------------
- def side_fix?(x, y, d)
- passable_tile?(x, y, d) && character_collision?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_move_straight
- #--------------------------------------------------------------------------
- def fix_move_straight(d)
- return if moving?
- @x = $game_map.round_x_with_direction(@x, d)
- @y = $game_map.round_y_with_direction(@y, d)
- follower_control_move_update(d, d)
- add_next_movement(d)
- increase_steps
- @moved = player?
- end
- #--------------------------------------------------------------------------
- # * New method: add_next_movement
- #--------------------------------------------------------------------------
- def add_next_movement(d)
- return unless follower? || player?
- return if $imported[:ve_followers_control] && follower_control_block
- return if $game_player.followers.gathering?
- @next_movement.push(d)
- end
- #--------------------------------------------------------------------------
- # * New method: follower_control_block
- #--------------------------------------------------------------------------
- def follower_control_block
- return true if follower? && origin_position
- return true if $game_player.followers.gathering_origin?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: front_collision?
- #--------------------------------------------------------------------------
- def front_collision?(x, y, d)
- return false if (@diagonal && @diagonal != 0) || @diagonal_move
- result = !front_collision_horiz(x, y, d) if (d == 2 || d == 8)
- result = !front_collision_vert(x, y, d) if (d == 4 || d == 6)
- result
- end
- #--------------------------------------------------------------------------
- # * New method: front_collision_horiz
- #--------------------------------------------------------------------------
- def front_collision_horiz(x, y, d)
- side_collision_fix?(x, y, d, 4, 4) || side_collision_fix?(x, y, d, 6, 4)
- end
- #--------------------------------------------------------------------------
- # * New method: front_collision_vert
- #--------------------------------------------------------------------------
- def front_collision_vert(x, y, d)
- side_collision_fix?(x, y, d, 2, 4) || side_collision_fix?(x, y, d, 8, 4)
- end
- #--------------------------------------------------------------------------
- # * New method: step_over?
- #--------------------------------------------------------------------------
- def step_over?
- @through
- end
- #--------------------------------------------------------------------------
- # * New method: bw
- #--------------------------------------------------------------------------
- def bw
- setup_bitmap_dimension unless @bw && character_name == @character_name_wh
- @bw
- end
- #--------------------------------------------------------------------------
- # * New method: bh
- #--------------------------------------------------------------------------
- def bh
- setup_bitmap_dimension unless @bh && character_name == @character_name_wh
- @bh
- end
- #--------------------------------------------------------------------------
- # * New method: setup_bitmap_dimension
- #--------------------------------------------------------------------------
- def setup_bitmap_dimension
- @character_name_wh = character_name
- bitmap = Cache.character(character_name).clone
- sign = @character_name[/^[\!\$]./]
- if character_name != "" && @tile_id == 0 && sign && sign.include?('[code]#==============================================================================
- # ** Victor Engine - Basic Module
- #------------------------------------------------------------------------------
- # Author : Victor Sant
- #
- # Version History:
- # v 1.00 - 2011.12.19 > First relase
- # v 1.01 - 2011.12.21 > Added Event Troop notes
- # v 1.02 - 2011.12.22 > Added character frames value
- # v 1.03 - 2011.12.30 > Added Actor and Enemy notes
- # v 1.04 - 2012.01.01 > Added party average level and map actors
- # v 1.05 - 2012.01.04 > Compatibility with Characters Scripts
- # v 1.06 - 2012.01.07 > Compatibility with Fog and Light Effect
- # > Added new Sprite Character functions
- # v 1.07 - 2012.01.11 > Compatibility with Control Text and Codes
- # v 1.08 - 2012.01.13 > Compatibility with Trait Control
- # v 1.09 - 2012.01.15 > Fixed the Regular Expressions problem with "" and “”
- # v 1.10 - 2012.01.18 > Compatibility with Automatic Battlers
- # v 1.11 - 2012.01.26 > Compatibility with Followers Options
- # Compatibility with Animated Battle beta
- # v 1.12 - 2012.02.08 > Compatibility with Animated Battle
- # v 1.13 - 2012.02.18 > Fix for non RTP dependant encrypted projects
- # v 1.14 - 2012.03.11 > Better version handling and required messages
- # v 1.15 - 2012.03.11 > Added level variable for enemies (to avoid crashes)
- # v 1.16 - 2012.03.21 > Compatibility with Follower Control
- # v 1.17 - 2012.03.22 > Compatibility with Follower Control new method
- # v 1.18 - 2012.03.22 > Added Battler Types tag support
- # v 1.19 - 2012.05.20 > Compatibility with Map Turn Battle
- # v 1.20 - 2012.05.21 > Fix for older RMVXa versions
- # v 1.21 - 2012.05.29 > Compatibility with Pixel Movement
- # v 1.22 - 2012.07.02 > Compatibility with Terrain States
- # v 1.23 - 2012.07.03 > Fix for Pixel Movement
- # v 1.24 - 2012.07.17 > Compatibility with Critical Hit Effects
- # v 1.25 - 2012.07.24 > Compatibility with Moving Plaforms
- # v 1.26 - 2012.07.30 > Compatibility with Automatic Battlers
- # v 1.27 - 2012.08.01 > Compatibility with Custom Slip Effect
- # v 1.28 - 2012.08.03 > Compatibility with Custom Slip Effect v 1.01
- #------------------------------------------------------------------------------
- # This is the basic script for the system from Victory Engine and is
- # required to use the scripts from the engine. This script offer some new
- # functions to be used within many scripts of the engine.
- #------------------------------------------------------------------------------
- # Compatibility
- # Required for the Victor Engine
- #
- # * Overwrite methods
- # class << Cache
- # def self.character(filename)
- #
- # class Sprite_Character < Sprite_Base
- # def set_character_bitmap
- #
- # * 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
- #------------------------------------------------------------------------------
- # Setting module for the Victor Engine
- #==============================================================================
- module Victor_Engine
- #--------------------------------------------------------------------------
- # * New method: required_script
- #--------------------------------------------------------------------------
- def self.required_script(name, req, version, type = 0)
- if type != :bellow && (!$imported[req] || $imported[req] < version)
- msg = "The script '%s' requires the script\n"
- case type
- when :above
- msg += "'%s' v%s or higher above it to work properly\n"
- else
- msg += "'%s' v%s or higher to work properly\n"
- end
- msg += "Go to http://victorscripts.wordpress.com/ to download this script."
- self.exit_message(msg, name, req, version)
- elsif type == :bellow && $imported[req]
- msg = "The script '%s' requires the script\n"
- msg += "'%s' to be put bellow it\n"
- msg += "move the scripts to the proper position"
- self.exit_message(msg, name, req, version)
- end
- end
- #--------------------------------------------------------------------------
- # * New method: exit_message
- #--------------------------------------------------------------------------
- def self.exit_message(message, name, req, version)
- name = self.script_name(name)
- req = self.script_name(req)
- msgbox(sprintf(message, name, req, version))
- exit
- end
- #--------------------------------------------------------------------------
- # * New method: script_name
- #--------------------------------------------------------------------------
- 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_basic_module] = 1.28
- #==============================================================================
- # ** Object
- #------------------------------------------------------------------------------
- # This class is the superclass of all other classes.
- #==============================================================================
- class Object
- #--------------------------------------------------------------------------
- # * Include setting module
- #--------------------------------------------------------------------------
- include Victor_Engine
- #-------------------------------------------------------------------------
- # * New method: rand_between
- #-------------------------------------------------------------------------
- def rand_between(min, max)
- min + rand(max - min + 1)
- end
- #--------------------------------------------------------------------------
- # * New method: numeric?
- #--------------------------------------------------------------------------
- def numeric?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: string?
- #--------------------------------------------------------------------------
- def string?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: array?
- #--------------------------------------------------------------------------
- def array?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: float?
- #--------------------------------------------------------------------------
- def float?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: item?
- #--------------------------------------------------------------------------
- def item?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: skill?
- #--------------------------------------------------------------------------
- def skill?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: file_exist?
- #--------------------------------------------------------------------------
- def file_exist?(path, filename)
- $file_list ||= {}
- $file_list[path + filename] ||= file_test(path, filename)
- $file_list[path + filename]
- end
- #--------------------------------------------------------------------------
- # * New method: get_file_list
- #--------------------------------------------------------------------------
- def file_test(path, filename)
- bitmap = Cache.load_bitmap(path, filename) rescue nil
- bitmap ? true : false
- end
- #--------------------------------------------------------------------------
- # * New method: character_exist?
- #--------------------------------------------------------------------------
- def character_exist?(filename)
- file_exist?("Graphics/Characters/", filename)
- end
- #--------------------------------------------------------------------------
- # * New method: battler_exist?
- #--------------------------------------------------------------------------
- def battler_exist?(filename)
- file_exist?("Graphics/Battlers/", filename)
- end
- #--------------------------------------------------------------------------
- # * New method: get_filename
- #--------------------------------------------------------------------------
- def get_filename
- "[\"'“‘]([^\"'”‘”’]+)[\"'”’]"
- end
- #--------------------------------------------------------------------------
- # * New method: get_all_values
- #--------------------------------------------------------------------------
- def get_all_values(value1, value2 = nil)
- value2 = value1 unless value2
- /<#{value1}>((?:[^<]|<[^\/])*)<\/#{value2}>/im
- end
- #--------------------------------------------------------------------------
- # * New method: make_symbol
- #--------------------------------------------------------------------------
- def make_symbol(string)
- string.downcase.gsub(" ", "_").to_sym
- end
- #--------------------------------------------------------------------------
- # * New method: make_string
- #--------------------------------------------------------------------------
- def make_string(symbol)
- symbol.to_s.gsub("_", " ").upcase
- end
- #--------------------------------------------------------------------------
- # * New method: returing_value
- #--------------------------------------------------------------------------
- def returing_value(i, x)
- i % (x * 2) >= x ? (x * 2) - i % (x * 2) : i % (x * 2)
- end
- #--------------------------------------------------------------------------
- # New method: in_rect?
- #--------------------------------------------------------------------------
- def in_rect?(w, h, x1, y1, x2, y2, fx = 0)
- aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
- bx > ax - aw && bx < ax + aw && by > ay - ah && by < ay + ah
- end
- #--------------------------------------------------------------------------
- # New method: in_radius?
- #--------------------------------------------------------------------------
- def in_radius?(w, h, x1, y1, x2, y2, fx = 0)
- aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
- ((bx - ax) ** 2 / aw ** 2) + ((by - ay) ** 2 / ah ** 2) <= 1
- end
- #--------------------------------------------------------------------------
- # New method: setup_area
- #--------------------------------------------------------------------------
- def setup_area(w, h, x1, y1, x2, y2, fx)
- aw = w
- ah = h * aw
- ax = x1
- ay = y1
- bx = x2
- by = y2
- bx += fx / 4 if ax > bx
- bx -= fx / 4 if ax < bx
- [aw, ah, ax, ay, bx, by]
- end
- end
- #==============================================================================
- # ** String
- #------------------------------------------------------------------------------
- # The string class. Can handle character sequences of arbitrary lengths.
- #==============================================================================
- class String
- #--------------------------------------------------------------------------
- # * New method: string?
- #--------------------------------------------------------------------------
- def string?
- return true
- end
- end
- #==============================================================================
- # ** Numeric
- #------------------------------------------------------------------------------
- # This is the abstract class for numbers.
- #==============================================================================
- class Numeric
- #--------------------------------------------------------------------------
- # * New method: numeric?
- #--------------------------------------------------------------------------
- def numeric?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: ceil?
- #--------------------------------------------------------------------------
- def ceil?
- return false
- 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
- self.inject(0) {|r, n| r += (n.numeric? ? n : 0)}
- end
- #---------------------------------------------------------------------------
- # * New method: average
- #---------------------------------------------------------------------------
- def average(float = false)
- self.sum / [(float ? size.to_f : size.to_i), 1].max
- end
- #---------------------------------------------------------------------------
- # * New method: next_item
- #---------------------------------------------------------------------------
- def next_item
- item = self.shift
- self.push(item)
- item
- end
- #---------------------------------------------------------------------------
- # * New method: previous_item
- #---------------------------------------------------------------------------
- def previous_item
- item = self.pop
- self.unshift(item)
- item
- end
- end
- #==============================================================================
- # ** RPG::Troop::Page
- #------------------------------------------------------------------------------
- # This is the data class for battle events (pages).
- #==============================================================================
- class RPG::Troop::Page
- #--------------------------------------------------------------------------
- # * New method: note
- #--------------------------------------------------------------------------
- def note
- return "" if !@list || @list.size <= 0
- comment_list = []
- @list.each do |item|
- next unless item && (item.code == 108 || item.code == 408)
- comment_list.push(item.parameters[0])
- end
- comment_list.join("\r\n")
- end
- end
- #==============================================================================
- # ** RPG::UsableItem
- #------------------------------------------------------------------------------
- # This is the superclass for skills and items.
- #==============================================================================
- class RPG::UsableItem < RPG::BaseItem
- #--------------------------------------------------------------------------
- # * New method: for_all_targets?
- #--------------------------------------------------------------------------
- def for_all_targets?
- return false
- end
- end
- #==============================================================================
- # ** RPG::Skill
- #------------------------------------------------------------------------------
- # This is the data class for skills.
- #==============================================================================
- class RPG::Skill < RPG::UsableItem
- #--------------------------------------------------------------------------
- # * New method: item?
- #--------------------------------------------------------------------------
- def item?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: skill?
- #--------------------------------------------------------------------------
- def skill?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: type_set
- #--------------------------------------------------------------------------
- def type_set
- [stype_id]
- end
- end
- #==============================================================================
- # ** RPG::Item
- #------------------------------------------------------------------------------
- # This is the data class for items.
- #==============================================================================
- class RPG::Item < RPG::UsableItem
- #--------------------------------------------------------------------------
- # * New method: item?
- #--------------------------------------------------------------------------
- def item?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: skill?
- #--------------------------------------------------------------------------
- def skill?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: type_set
- #--------------------------------------------------------------------------
- def type_set
- [itype_id]
- end
- 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
- #==============================================================================
- # ** 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_cond
- #--------------------------------------------------------------------------
- def get_cond(text)
- case text.upcase
- when "HIGHER" then ">"
- when "LOWER" then "<"
- when "EQUAL" then "=="
- when "DIFFERENT" then "!="
- else "!="
- end
- end
- #--------------------------------------------------------------------------
- # * 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: get_param_id
- #--------------------------------------------------------------------------
- def get_param_id(text)
- case text.upcase
- when "MAXHP", "HP" then 0
- when "MAXMP", "MP" then 1
- when "ATK" then 2
- when "DEF" then 3
- when "MAT" then 4
- when "MDF" then 5
- when "AGI" then 6
- when "LUK" then 7
- 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:
- #--------------------------------------------------------------------------
- def element_set(item)
- element_set = [item.damage.element_id]
- element_set += atk_elements if item.damage.element_id < 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 < state_rate(state_id)
- 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
- #--------------------------------------------------------------------------
- # * New method: cri_rate
- #--------------------------------------------------------------------------
- def cri_rate(user, item)
- user.cri
- end
- #--------------------------------------------------------------------------
- # * New method: cri_eva
- #--------------------------------------------------------------------------
- def cri_eva(user, item)
- cev
- end
- #--------------------------------------------------------------------------
- # * New method: setup_critical
- #--------------------------------------------------------------------------
- def setup_critical(user, item)
- cri_rate(user, item) * (1 - cri_eva(user, item))
- end
- end
- #==============================================================================
- # ** Game_Enemy
- #------------------------------------------------------------------------------
- # This class handles enemy characters. It's used within the Game_Troop class
- # ($game_troop).
- #==============================================================================
- class Game_Enemy < Game_Battler
- #--------------------------------------------------------------------------
- # * New method: note
- #--------------------------------------------------------------------------
- def note
- enemy ? enemy.note : ""
- end
- #--------------------------------------------------------------------------
- # * New method: get_all_notes
- #--------------------------------------------------------------------------
- def get_all_notes(*args)
- notes = ""
- notes += note if !args.include?(:self)
- states.compact.each {|state| notes += state.note } if !args.include?(:state)
- notes
- end
- #--------------------------------------------------------------------------
- # * New method: get_all_objects
- #--------------------------------------------------------------------------
- def get_all_objects(*args)
- result = []
- result += [self] if !args.include?(:self)
- result += states.compact if !args.include?(:state)
- result
- end
- #--------------------------------------------------------------------------
- # * New method: level
- #--------------------------------------------------------------------------
- def level
- return 1
- end
- #--------------------------------------------------------------------------
- # * New method: skill_learn?
- #--------------------------------------------------------------------------
- def skill_learn?(skill)
- skill.skill? && skills.include?(skill)
- end
- #--------------------------------------------------------------------------
- # * New method: skills
- #--------------------------------------------------------------------------
- def skills
- enemy.actions.collect {|action| $data_skills[action.skill_id] }
- end
- end
- #==============================================================================
- # ** Game_Actor
- #------------------------------------------------------------------------------
- # This class handles actors. It's used within the Game_Actors class
- # ($game_actors) and referenced by the Game_Party class ($game_party).
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # * New method: note
- #--------------------------------------------------------------------------
- def note
- actor ? actor.note : ""
- end
- #--------------------------------------------------------------------------
- # * New method: hue
- #--------------------------------------------------------------------------
- def hue
- @hue ? @hue : 0
- end
- #--------------------------------------------------------------------------
- # * New method: get_all_notes
- #--------------------------------------------------------------------------
- def get_all_notes(*args)
- notes = ""
- notes += note if !args.include?(:self)
- notes += self.class.note if !args.include?(:class)
- equips.compact.each {|equip| notes += equip.note } if !args.include?(:equip)
- states.compact.each {|state| notes += state.note } if !args.include?(:state)
- notes
- end
- #--------------------------------------------------------------------------
- # * New method: get_all_objects
- #--------------------------------------------------------------------------
- def get_all_objects(*args)
- result = []
- result += [self] if !args.include?(:self)
- result += [self.class] if !args.include?(:self)
- 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_Player and Game_Event classes.
- #==============================================================================
- class Game_Character < Game_CharacterBase
- #--------------------------------------------------------------------------
- # * New method: move_toward_position
- #--------------------------------------------------------------------------
- def move_toward_position(x, y)
- sx = distance_x_from(x)
- sy = distance_y_from(y)
- if sx.abs > sy.abs
- move_straight(sx > 0 ? 4 : 6)
- move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0
- elsif sy != 0
- move_straight(sy > 0 ? 8 : 2)
- move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0
- end
- end
- #--------------------------------------------------------------------------
- # * New method: move_toward_position
- #--------------------------------------------------------------------------
- def turn_toward_position(x, y)
- sx = distance_x_from(x)
- sy = distance_y_from(y)
- if sx.abs > sy.abs
- set_direction(sx > 0 ? 4 : 6)
- elsif sy != 0
- set_direction(sy > 0 ? 8 : 2)
- end
- end
- end
- #==============================================================================
- # ** Game_Player
- #------------------------------------------------------------------------------
- # This class handles the player.
- # The instance of this class is referenced by $game_map.
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # * New method: player?
- #--------------------------------------------------------------------------
- def player?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: perform_transfer
- #--------------------------------------------------------------------------
- def new_map_id
- @new_map_id
- end
- #--------------------------------------------------------------------------
- # * New method: hue
- #--------------------------------------------------------------------------
- def hue
- actor ? actor.hue : 0
- end
- end
- #==============================================================================
- # ** 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
- #--------------------------------------------------------------------------
- # * New method: vehicle?
- #--------------------------------------------------------------------------
- def vehicle?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: map_id
- #--------------------------------------------------------------------------
- def map_id
- @map_id
- end
- #--------------------------------------------------------------------------
- # * New method: type
- #--------------------------------------------------------------------------
- def type
- @type
- end
- #--------------------------------------------------------------------------
- # * New method: aerial?
- #--------------------------------------------------------------------------
- def aerial?
- type == :airship
- end
- #--------------------------------------------------------------------------
- # * New method: above?
- #--------------------------------------------------------------------------
- def above?
- aerial?
- 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
- #--------------------------------------------------------------------------
- # * New method: name
- #--------------------------------------------------------------------------
- def name
- @event.name
- end
- #--------------------------------------------------------------------------
- # * New method: event?
- #--------------------------------------------------------------------------
- def event?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: erased?
- #--------------------------------------------------------------------------
- def erased?
- @erased
- end
- #--------------------------------------------------------------------------
- # * New method: note
- #--------------------------------------------------------------------------
- def note
- return "" if !@page || [email protected] || @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
- #==============================================================================
- # ** 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?(')
- @bw = bitmap.width / 32.0 / frames
- @bh = bitmap.height / 32.0 / 4
- elsif character_name != "" && @tile_id == 0
- @bw = bitmap.width / 32.0 / (frames * 4)
- @bh = bitmap.height / 32.0 / 8
- else
- @bw = 1.0
- @bh = 1.0
- end
- bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # * New method: collision?
- #--------------------------------------------------------------------------
- def collision?(x, y, w, h)
- ax1, ay1, ax2, ay2 = setup_rect(x, y, w, h)
- bx1, by1, bx2, by2 = setup_rect(@x, @y, bw, bh)
- ax2 > bx1 && ax1 < bx2 && ay2 > by1 && ay1 < by2
- end
- #--------------------------------------------------------------------------
- # * New method: over?
- #--------------------------------------------------------------------------
- def over?(x, y)
- ax1, ay1, ax2, ay2 = setup_rect(x, y - 0.125, 0, 0)
- bx1, by1, bx2, by2 = setup_rect(@real_x, @real_y, bw, bh - 0.125)
- ax2 >= bx1 && ax1 <= bx2 && ay2 >= by1 && ay1 <= by2
- end
- #--------------------------------------------------------------------------
- # * New method: setup_rect
- #--------------------------------------------------------------------------
- def setup_rect(x, y, w, h)
- x1 = x - w / 2.0
- y1 = y - h
- x2 = x1 + w
- y2 = y1 + h
- [x1, y1, x2, y2]
- end
- #--------------------------------------------------------------------------
- # * New method: align_with
- #--------------------------------------------------------------------------
- def align_with(x, y)
- d = @direction
- @x = $game_map.round_x_with_direction(x, 0) if d == 2 || d == 8
- @y = $game_map.round_y_with_direction(y, 0) if d == 6 || d == 4
- dx = (d == 2 || d == 8) ? (@x - @real_x) / 0.125 : 0
- dy = (d == 4 || d == 6) ? (@y - @real_y) / 0.125 : 0
- set_direction(dx > 0 ? 6 : dx < 0 ? 4 : dy > 0 ? 2 : dy < 0 ? 8 : d)
- @real_x = $game_map.x_with_direction(@x, reverse_dir(@direction), dx.abs)
- @real_y = $game_map.y_with_direction(@y, reverse_dir(@direction), dy.abs)
- update_for_align while moving?
- @direction = d
- end
- #--------------------------------------------------------------------------
- # * New method: update_for_align
- #--------------------------------------------------------------------------
- def update_for_align
- SceneManager.scene.update_basic
- SceneManager.scene.spriteset.update
- $game_map.update(true)
- $game_timer.update
- update_animation
- update_move
- end
- #--------------------------------------------------------------------------
- # * New method: fix_position
- #--------------------------------------------------------------------------
- def fix_position(n)
- (n * 64 / 8).round / 8.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
- #--------------------------------------------------------------------------
- # * Alias method: move_toward_character
- #--------------------------------------------------------------------------
- alias :move_toward_character_ve_pixel_movement :move_toward_character
- def move_toward_character(character)
- sx = distance_x_from(character.x)
- sy = distance_y_from(character.y)
- move_toward_character_ve_pixel_movement(character)
- @x = character.x if sx.abs < 1
- @y = character.y if sy.abs < 1
- end
- #--------------------------------------------------------------------------
- # * Alias method: move_toward_position
- #--------------------------------------------------------------------------
- alias :move_toward_position_ve_pixel_movement :move_toward_position
- def move_toward_position(x, y)
- sx = distance_x_from(x)
- sy = distance_y_from(y)
- move_toward_position_ve_pixel_movement(x, y)
- @x = x if sx.abs < 1
- @y = y if sy.abs < 1
- 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
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :over_event
- attr_accessor :land_test
- #--------------------------------------------------------------------------
- # * Overwrite method: check_event_trigger_there
- #--------------------------------------------------------------------------
- def check_event_trigger_there(triggers)
- x2 = $game_map.round_x_with_direction(@x, @direction)
- y2 = $game_map.round_y_with_direction(@y, @direction)
- start_map_event(x2, y2, triggers, true)
- return if $game_map.any_event_starting?
- return unless counter_tile?
- x3 = $game_map.check_x_with_direction(x2, @direction)
- y3 = $game_map.check_y_with_direction(y2, @direction)
- start_map_event(x3, y3, triggers, true)
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: start_map_event
- #--------------------------------------------------------------------------
- def start_map_event(x, y, triggers, normal)
- return if $game_map.interpreter.running?
- $game_map.events_xy(x, y).each do |event|
- event.start if check_event_contiontion(x, y, event, triggers, normal)
- end
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: update_nonmoving
- #--------------------------------------------------------------------------
- def update_nonmoving(last_moving)
- return if $game_map.interpreter.running?
- moved = @moved
- @moved = false
- if last_moving || moved
- $game_party.on_player_walk
- return if check_touch_event
- end
- if movable? && Input.trigger?(:C)
- return if get_on_off_vehicle
- return if check_action_event
- end
- @over_event -= 1 if @over_event > 0 && (last_moving || moved)
- update_encounter if last_moving || moved
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: get_on_vehicle
- #--------------------------------------------------------------------------
- def get_on_vehicle
- setup_vehicle
- enter_vehicle if vehicle
- @vehicle_getting_on
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: increase_steps
- #--------------------------------------------------------------------------
- def increase_steps
- super
- if normal_walk?
- @steps += 1
- $game_player.damage_floor = 0 unless on_damage_floor?
- $game_player.damage_floor += 1
- $game_party.increase_steps if @steps % 8 == 0
- end
- end
- #--------------------------------------------------------------------------
- # * Alias method: get_off_vehicle
- #--------------------------------------------------------------------------
- alias :get_off_vehicle_ve_pixel_movement :get_off_vehicle
- def get_off_vehicle
- clear_next_movement if vehicle.land_ok?(@x, @y, @direction)
- get_off_vehicle_ve_pixel_movement
- end
- #--------------------------------------------------------------------------
- # * Alias method: clear_transfer_info
- #--------------------------------------------------------------------------
- alias :clear_transfer_info_ve_pixel_movement :clear_transfer_info
- def clear_transfer_info
- clear_transfer_info_ve_pixel_movement
- clear_next_movement
- end
- #--------------------------------------------------------------------------
- # * Alias method: update
- #--------------------------------------------------------------------------
- alias :update_ve_gp_pixel_movement :update
- def update
- @followers.move unless $imported[:ve_followers_options]
- update_ve_gp_pixel_movement
- end
- #--------------------------------------------------------------------------
- # * New method: check_event_contiontion
- #--------------------------------------------------------------------------
- def check_event_contiontion(x, y, event, triggers, normal)
- passable = passable_tile?(@x, @y, @direction)
- w = (counter_tile? || !passable) ? 1.0 : bw
- h = (counter_tile? || !passable) ? 1.0 : bh
- return false unless event.trigger_in?(triggers)
- return false unless event.event_priority?(normal)
- return false unless passable || event.over_tile? || counter_tile?
- return false unless event.collision?(x, y, w, h) || !jumping?
- return false unless !event.in_front? || front_collision?(x, y, @direction)
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: counter_tile?
- #--------------------------------------------------------------------------
- def counter_tile?
- x = $game_map.check_x_with_direction(@x, @direction)
- y = $game_map.check_y_with_direction(@y, @direction)
- $game_map.counter?(x, y)
- end
- #--------------------------------------------------------------------------
- # * New method: setup_vehicle
- #--------------------------------------------------------------------------
- def setup_vehicle
- $game_map.vehicles.compact.each do |vehicle|
- next unless vehicle.enter_vechicle?(@x, @y, @direction)
- @vehicle_type = vehicle.type
- break if vehicle
- end
- end
- #--------------------------------------------------------------------------
- # * New method: enter_vehicle
- #--------------------------------------------------------------------------
- def enter_vehicle
- align_with(vehicle.x, vehicle.y) unless in_airship?
- @vehicle_getting_on = true
- force_move_forward unless in_airship?
- @followers.gather
- end
- #--------------------------------------------------------------------------
- # * New method: clear_next_movement
- #--------------------------------------------------------------------------
- def clear_next_movement
- @next_movement.clear
- @followers.clear_next_movement
- end
- #--------------------------------------------------------------------------
- # * New method: step_times
- #--------------------------------------------------------------------------
- def step_times
- (move_route_forcing || not_driving?) ? super : 1
- end
- #--------------------------------------------------------------------------
- # * New method: not_driving?
- #--------------------------------------------------------------------------
- def not_driving?
- vehicle && !vehicle.driving
- end
- #--------------------------------------------------------------------------
- # * New method: move_straight
- #--------------------------------------------------------------------------
- def move_straight(d, turn_ok = true)
- super
- end
- #--------------------------------------------------------------------------
- # * New method: move_diagonal
- #--------------------------------------------------------------------------
- def move_diagonal(horz, vert)
- super
- end
- #--------------------------------------------------------------------------
- # * New method: setup_bitmap_dimension
- #--------------------------------------------------------------------------
- def setup_bitmap_dimension
- @bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
- @bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
- end
- end
- #==============================================================================
- # ** 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
- #--------------------------------------------------------------------------
- # * Overwrite method: chase_preceding_character
- #--------------------------------------------------------------------------
- def chase_preceding_character
- return if $imported[:ve_followers_control] && cant_follow_character
- unless moving?
- if @preceding_character.next_movement.size >= 8 && !gathering?
- next_move = @preceding_character.next_movement.shift
- move_straight(next_move) if next_move.numeric?
- move_diagonal(*next_move) if next_move.array?
- elsif gathering?
- @preceding_character.next_movement.clear
- move_toward_player
- end
- end
- end
- #--------------------------------------------------------------------------
- # * New method: move_straight
- #--------------------------------------------------------------------------
- def move_straight(d, turn_ok = true)
- super
- end
- #--------------------------------------------------------------------------
- # * New method: move_diagonal
- #--------------------------------------------------------------------------
- def move_diagonal(horz, vert)
- super
- end
- #--------------------------------------------------------------------------
- # * New method: movement_size
- #--------------------------------------------------------------------------
- def movement_size
- return 8
- end
- #--------------------------------------------------------------------------
- # * New method: step_times
- #--------------------------------------------------------------------------
- def step_times
- (move_route_forcing || not_driving? || gathering?) ? super : 1
- end
- #--------------------------------------------------------------------------
- # * New method: not_driving?
- #--------------------------------------------------------------------------
- def not_driving?
- $game_player.not_driving?
- end
- #--------------------------------------------------------------------------
- # * New method: setup_bitmap_dimension
- #--------------------------------------------------------------------------
- def setup_bitmap_dimension
- @bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
- @bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
- 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: clear_next_movement
- #--------------------------------------------------------------------------
- def clear_next_movement
- each {|follower| follower.next_movement.clear }
- 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
- #--------------------------------------------------------------------------
- # * Overwrite method: collide_with_player_characters?
- #--------------------------------------------------------------------------
- def collide_with_player_characters?(x, y)
- normal_priority? && player_collision?(x, y)
- end
- #--------------------------------------------------------------------------
- # * Alias method: start
- #--------------------------------------------------------------------------
- alias :start_ve_pixel_movement :start
- def start
- start_ve_pixel_movement
- $game_player.over_event = 8 if step_over? && !step_trigger?
- end
- #--------------------------------------------------------------------------
- # * Alias method: setup_page_settings
- #--------------------------------------------------------------------------
- alias :setup_page_settings_ve_pixel_movement :setup_page_settings
- def setup_page_settings_ve_pixel_movement
- setup_page_settings_ve_anti_lag
- @move_steps = note =~ /<MOVE STEPS: (\d+)>/i ? $1.to_i : nil
- @step_trigger = note =~ /<EACH STEP TRIGGER>/i ? true : false
- @in_front = note =~ /<FRONT COLLISION>/i ? true : false
- @over_tile = note =~ /<OVER TILE>/i ? true : false
- @side_fix = note =~ /<NO SIDE COLLISION FIX>/i ? false : true
- end
- #--------------------------------------------------------------------------
- # * New method: player_collision?
- #--------------------------------------------------------------------------
- def player_collision?(x, y)
- $game_map.actors.any? {|actor| actor.collision?(x, y, bh, bw)}
- end
- #--------------------------------------------------------------------------
- # * New method: event_priority?
- #--------------------------------------------------------------------------
- def event_priority?(normal)
- (normal_priority? == normal || (@through && !normal)) &&
- (normal_priority? || @trigger == 0 || $game_player.over_event == 0)
- end
- #--------------------------------------------------------------------------
- # * New method: check_event_trigger_touch
- #--------------------------------------------------------------------------
- def check_event_trigger_touch(x, y)
- return if $game_map.interpreter.running?
- if @trigger == 2 && $game_player.collision?(x, y, bh, bw)
- start if !jumping? && normal_priority?
- end
- end
- #--------------------------------------------------------------------------
- # * New method: step_over?
- #--------------------------------------------------------------------------
- def step_over?
- super || (@character_name == "" && @tile_id == 0) || @priority_type == 0
- end
- #--------------------------------------------------------------------------
- # * New method: step_times
- #--------------------------------------------------------------------------
- def step_times
- @move_steps ? @move_steps : super
- end
- #--------------------------------------------------------------------------
- # * New method: step_trigger?
- #--------------------------------------------------------------------------
- def step_trigger?
- @step_trigger
- end
- #--------------------------------------------------------------------------
- # * New method: in_front?
- #--------------------------------------------------------------------------
- def in_front?
- @in_front
- end
- #--------------------------------------------------------------------------
- # * New method: over_tile?
- #--------------------------------------------------------------------------
- def over_tile?
- @over_tile
- end
- #--------------------------------------------------------------------------
- # * New method: side_collision?
- #--------------------------------------------------------------------------
- def side_collision?
- @side_fix
- end
- #--------------------------------------------------------------------------
- # * New method: setup_bitmap_dimension
- #--------------------------------------------------------------------------
- def setup_bitmap_dimension
- regexp = /<EVENT SIZE: (\d+), (\d+)>/i
- note =~ regexp ? setup_custom_dimension($1.to_i, $2.to_i) : super
- end
- #--------------------------------------------------------------------------
- # * New method: setup_custom_dimension
- #--------------------------------------------------------------------------
- def setup_custom_dimension(x, y)
- x1 = (x / 8).to_i
- y1 = (y / 8).to_i
- @bw = x1 / 4.0
- @bh = y1 / 4.0
- 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
- #--------------------------------------------------------------------------
- # * Overwrite method: land_ok?
- #--------------------------------------------------------------------------
- def land_ok?(x, y, d)
- @type == :airship ? airship_landable?(x, y) : check_landable?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * New method: land_test
- #--------------------------------------------------------------------------
- def land_test
- @land_test
- end
- #--------------------------------------------------------------------------
- # * New method: step_over?
- #--------------------------------------------------------------------------
- def step_over?
- above? || super
- end
- #--------------------------------------------------------------------------
- # * New method: check_landable?
- #--------------------------------------------------------------------------
- def check_landable?(x, y, d)
- x2 = $game_map.check_x_with_direction(x, d)
- y2 = $game_map.check_y_with_direction(y, d)
- @land_test = true
- result = passable?(x2, y2, d)
- @land_test = false
- result
- end
- #--------------------------------------------------------------------------
- # * New method: airship_landable?
- #--------------------------------------------------------------------------
- def airship_landable?(x, y)
- [2, 4, 6, 8].any? {|d| passable?(x, y, d) }
- end
- #--------------------------------------------------------------------------
- # * New method: passable_normal?
- #--------------------------------------------------------------------------
- def passable_normal?(x, y, d ,d2, ceil = false)
- @land_test ? landable_normal?(x, y, d ,d2, ceil) : super(x, y, d ,d2, ceil)
- end
- #--------------------------------------------------------------------------
- # * New method: landable_normal?
- #--------------------------------------------------------------------------
- def landable_normal?(x, y, d ,d2, ceil)
- x1 = $game_map.round_x(x)
- y1 = $game_map.round_y(y)
- return false unless $game_map.valid?(x1, y1)
- return true if @through || debug_through?
- return false unless map_passable?(x1, y1, d)
- return false unless map_passable?(x1, y1, d2) || !ceil
- return false unless map_passable?(x1, y1, reverse_dir(d))
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: enter_vechicle?
- #--------------------------------------------------------------------------
- def enter_vechicle?(x, y, d)
- return false if @map_id != $game_map.map_id
- x2 = $game_map.round_x_with_direction(x, d)
- y2 = $game_map.round_y_with_direction(y, d)
- x3 = $game_map.check_x_with_direction(@x, reverse_dir(d))
- y3 = $game_map.check_y_with_direction(@y, reverse_dir(d))
- ( above? && collision?(x, y - 0.125, bw * 0.75, bh * 0.75)) ||
- (!above? && collision?(x2, y2, bw, bh) && map_passable?(x3, y3, d))
- end
- #--------------------------------------------------------------------------
- # * New method: vehicle_collision?
- #--------------------------------------------------------------------------
- def vehicle_collision?(x, y, bw, bh, player)
- return false if step_over?
- return false if player.player? && self == player.vehicle
- return false if !collision?(x, y, bw, bh)
- return true
- end
- end
复制代码- #==============================================================================
- # ** Victor Engine - Pixel Movement
- #------------------------------------------------------------------------------
- # Author : Victor Sant
- #
- # Version History:
- # v 1.00 - 2012.05.29 > First relase
- # v 1.01 - 2012.05.29 > Compatibility with Terrain States
- # v 1.02 - 2012.07.03 > Compatibility with Basic Module 1.23
- # v 1.03 - 2012.07.05 > Added 'over event' tag for objects over blocked tiles
- # > Added Steps settings for events
- # v 1.04 - 2012.07.24 > Compatibility with Moving Platform
- # > Added <each step trigger> tag for events
- # v 1.05 - 2012.07.30 > Fixed issue when characters moves toward the same spot
- # v 1.06 - 2012.08.03 > Compatibility with Anti Lag
- # v 1.07 - 2012.08.03 > Fixed collision with tile graphics events
- #------------------------------------------------------------------------------
- # This script allows to replace the tile based movement where the player
- # walks a whole 32 pixel tile each step with one that he walks only 4 pixels.
- # It also give a better collision system for events.
- #------------------------------------------------------------------------------
- # Compatibility
- # Requires the script 'Victor Engine - Basic Module' v 1.25 or higher
- # If used with 'Victor Engine - Animated Battle' place this bellow it.
- # If used with 'Victor Engine - Follower Control' place this bellow it.
- # If used with 'Victor Engine - Follower Options' place this bellow it.
- #
- # * Overwrite methods
- # class Game_Actor < Game_Battler
- # def turn_end_on_map
- #
- # class Game_Map
- # def layered_tiles(x, y)
- # def events_xy(x, y)
- # def events_xy_nt(x, y)
- # def x_with_direction(x, d, times = 1)
- # def y_with_direction(y, d, times = 1)
- # def round_x_with_direction(x, d)
- # def round_y_with_direction
- #
- # class Game_CharacterBase
- # def region_id
- # def move_straight(d, turn_ok = true)
- # def move_diagonal(horz, vert)
- # def collide_with_events?(x, y)
- # def collide_with_vehicles?(x, y)
- #
- # class Game_Player < Game_Character
- # def check_event_trigger_there(triggers)
- # def start_map_event(x, y, triggers, normal)
- # def update_nonmoving(last_moving)
- # def get_on_vehicle
- # def increase_steps
- #
- # class Game_Follower < Game_Character
- # def chase_preceding_character
- #
- # class Game_Event < Game_Character
- # def collide_with_player_characters?(x, y)
- #
- # class Game_Vehicle < Game_Character
- # def land_ok?(x, y, d)
- #
- # * Alias methods
- # class Game_Actor < Game_Battler
- # def check_floor_effect
- #
- # class Game_CharacterBase
- # def init_public_members
- # def update
- #
- # class Game_Character < Game_CharacterBase
- # def move_toward_character(character)
- # def move_toward_position(x, y)
- #
- # class Game_Event < Game_Character
- # def start
- #
- # class Game_Player < Game_Character
- # def get_off_vehicle
- # def clear_transfer_info
- # def update
- #
- # class Game_Event < Game_Character
- # def start
- #
- #------------------------------------------------------------------------------
- # 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 script 'Victor Engine - Basic'
- #
- #------------------------------------------------------------------------------
- # Event Comment boxes note tags:
- # Tags to be used on events Comment boxes.
- #
- # <move steps: x>
- # Setup the number of steps each "Move" command will execute. The default
- # value is 8 (1 tile)
- # x : number of steps
- #
- # <event size: x, y>
- # Collision area size, in pixels for event collisions.
- # x : collision area width
- # y : collision area height
- #
- # <front collision>
- # Events with this tag won't start if the the collision between events and
- # the player occur between their edges.
- #
- # <no side collision fix>
- # Events with this tag won't have the "slide" effect when the edges of the
- # events collide with the player
- #
- # <over tile>
- # Events with this tag will start even when placed over blocked tiles.
- # By default, if the passage is blocked the event don't stat.
- #
- # <each step trigger>
- # By default, events with through or bellow character priority triggers
- # only one time for each 8 steps above them. With this tag though, the
- # event will trigger every step.
- #
- #------------------------------------------------------------------------------
- # Additional instructions:
- #
- # All events and tiles have a "slide" effect when the player faces the edge
- # of a tile or event. I added this function since it would be a pain to
- # be in the exact position to go throug a narrow path.
- # This can be disabled for events, but not for tiles.
- #
- #==============================================================================
- #==============================================================================
- # ** Victor Engine
- #------------------------------------------------------------------------------
- # Setting module for the Victor Engine
- #==============================================================================
- module Victor_Engine
- #--------------------------------------------------------------------------
- # * Player collision area
- # Different from events, player collision don't rely on the graphic size
- # Player collision area can be of 2 types:
- # - 32 x 32 box if VE_PLAYER_BIG_COLLISION = true
- # - 24 x 24 box if VE_PLAYER_BIG_COLLISION = false
- #--------------------------------------------------------------------------
- VE_PLAYER_BIG_COLLISION = true
- #--------------------------------------------------------------------------
- # * 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
- #--------------------------------------------------------------------------
- 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_pixel_movement] = 1.07
- Victor_Engine.required(:ve_pixel_movement, :ve_basic_module, 1.25, :above)
- Victor_Engine.required(:ve_pixel_movement, :ve_map_battle, 1.00, :bellow)
- Victor_Engine.required(:ve_pixel_movement, :ve_diagonal_move, 1.00, :bellow)
- #==============================================================================
- # ** Game_Actor
- #------------------------------------------------------------------------------
- # This class handles actors. It's used within the Game_Actors class
- # ($game_actors) and referenced by the Game_Party class ($game_party).
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # * Overwrite method: turn_end_on_map
- #--------------------------------------------------------------------------
- def turn_end_on_map
- if $game_player.steps % (steps_for_turn * 8) == 0
- on_turn_end
- perform_map_damage_effect if @result.hp_damage > 0
- end
- end
- #--------------------------------------------------------------------------
- # * Alias method: init_public_members
- #--------------------------------------------------------------------------
- alias :check_floor_effect_ve_pixel_movement :check_floor_effect
- def check_floor_effect
- return if check_damage_floor
- check_floor_effect_ve_pixel_movement
- end
- #--------------------------------------------------------------------------
- # * New method: check_damage_floor
- #--------------------------------------------------------------------------
- def check_damage_floor
- $game_player.damage_floor % 8 != 0
- 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
- #--------------------------------------------------------------------------
- # * Overwrite method: layered_tiles
- #--------------------------------------------------------------------------
- def layered_tiles(x, y)
- x2 = (x - 0.5).ceil
- y2 = (y - 0.125).ceil
- [2, 1, 0].collect {|z| tile_id(x2, y2, z) }
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: events_xy
- #--------------------------------------------------------------------------
- def events_xy(x, y)
- event_list.select {|event| event.near?(x, y) }
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: events_xy_nt
- #--------------------------------------------------------------------------
- def events_xy_nt(x, y)
- event_list.select {|event| event.near_nt?(x, y) }
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: x_with_direction
- #--------------------------------------------------------------------------
- def x_with_direction(x, d, times = 1)
- x + (d == 6 ? times * 0.125 : d == 4 ? -times * 0.125 : 0)
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: y_with_direction
- #--------------------------------------------------------------------------
- def y_with_direction(y, d, times = 1)
- y + (d == 2 ? times * 0.125 : d == 8 ? -times * 0.125 : 0)
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: round_x_with_direction
- #--------------------------------------------------------------------------
- def round_x_with_direction(x, d)
- round_x(x + (d == 6 ? 0.125 : d == 4 ? -0.125 : 0))
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: round_y_with_direction
- #--------------------------------------------------------------------------
- def round_y_with_direction(y, d)
- round_y(y + (d == 2 ? 0.125 : d == 8 ? -0.125 : 0))
- end
- #--------------------------------------------------------------------------
- # * New method: check_x_with_direction
- #--------------------------------------------------------------------------
- def check_x_with_direction(x, d)
- round_x(x + (d == 6 ? 1 : d == 4 ? -1 : 0))
- end
- #--------------------------------------------------------------------------
- # * New method: check_y_with_direction
- #--------------------------------------------------------------------------
- def check_y_with_direction(y, d)
- round_y(y + (d == 2 ? 1 : d == 8 ? -1 : 0))
- 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 :next_movement
- attr_accessor :side_collision
- attr_accessor :damage_floor
- attr_accessor :steps
- #--------------------------------------------------------------------------
- # * Overwrite method: region_id
- #--------------------------------------------------------------------------
- def region_id
- $game_map.region_id((@x - 0.5).ceil, (@y - 0.125).ceil)
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: collide_with_events?
- #--------------------------------------------------------------------------
- def collide_with_events?(x, y)
- $game_map.events_xy_nt(x, y).any? do |event|
- event.collision_condition?(x, y, bw, bh, event?, @id, @side_collision)
- end
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: collide_with_vehicles?
- #--------------------------------------------------------------------------
- def collide_with_vehicles?(x, y)
- $game_map.vehicles.compact.any? do |vehicle|
- next if vehicle.map_id != $game_map.map_id
- vehicle.vehicle_collision?(x, y, bw, bh, self)
- end
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: move_straight
- #--------------------------------------------------------------------------
- def move_straight(d, turn_ok = true)
- @move_list += [{d: [d], turn: turn_ok}] * step_times
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: move_straight
- #--------------------------------------------------------------------------
- def move_diagonal(horz, vert)
- @move_list += [{d: [horz, vert], turn: true}] * step_times
- end
- #--------------------------------------------------------------------------
- # * Alias method: init_public_members
- #--------------------------------------------------------------------------
- alias :init_public_members_ve_pixel_movement :init_public_members
- def init_public_members
- init_public_members_ve_pixel_movement
- @move_list = []
- @next_movement = []
- @over_event = 0
- @damage_floor = 0
- @steps = 0
- end
- #--------------------------------------------------------------------------
- # * Alias method: update
- #--------------------------------------------------------------------------
- alias :update_ve_pixel_movement :update
- def update
- update_move_straight
- update_move_diagonal
- update_ve_pixel_movement
- end
- #--------------------------------------------------------------------------
- # * New method: update_move_straight
- #--------------------------------------------------------------------------
- def update_move_straight
- return if moving? || @move_list.empty?
- return if @move_list.first[:d].size > 1
- move = @move_list.shift
- d = move[:d].first
- if passable?(@x, @y, d)
- @diagonal_move = false
- setup_movement(d, d)
- @real_x = $game_map.x_with_direction(@x, reverse_dir(d))
- @real_y = $game_map.y_with_direction(@y, reverse_dir(d))
- @moved = player?
- elsif move[:turn]
- check_event_trigger_move(d)
- end
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: update_move_diagonal
- #--------------------------------------------------------------------------
- def update_move_diagonal
- return if moving? || @move_list.empty?
- return if @move_list.first[:d].size < 2
- move = @move_list.shift
- horz = move[:d].first
- vert = move[:d].last
- if diagonal_passable?(x, y, horz, vert)
- @diagonal_move = true
- setup_movement(horz, vert)
- @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
- @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
- @moved = player?
- end
- end
- #--------------------------------------------------------------------------
- # * New method: character_collision?
- #--------------------------------------------------------------------------
- def character_collision?(x, y, d)
- x2 = $game_map.round_x_with_direction(x, d)
- y2 = $game_map.round_y_with_direction(y, d)
- !collide_with_characters?(x2, y2) || @through || debug_through?
- end
- #--------------------------------------------------------------------------
- # * New method: step_times
- #--------------------------------------------------------------------------
- def step_times
- return 8
- end
- #--------------------------------------------------------------------------
- # * New method: near_nt?
- #--------------------------------------------------------------------------
- def near_nt?(x, y)
- near?(x, y) && !@through
- end
- #--------------------------------------------------------------------------
- # * New method: near?
- #--------------------------------------------------------------------------
- def near?(x, y)
- w = step_over? ? [bw * 0.625, 0.5].max : [bw, 1.0].max
- h = step_over? ? [bh * 0.625, 0.5].max : [bh, 1.0].max
- @real_x > x - w && @real_x < x + w && @real_y > y - h && @real_y < y + h
- end
- #--------------------------------------------------------------------------
- # * New method: setup_movement
- #--------------------------------------------------------------------------
- def setup_movement(horz, vert)
- @x = $game_map.round_x_with_direction(@x, horz)
- @y = $game_map.round_y_with_direction(@y, vert)
- add_next_movement(horz == vert ? horz : [horz, vert])
- set_direction(horz) if @direction == reverse_dir(horz) || horz == vert
- set_direction(vert) if @direction == reverse_dir(vert) && horz != vert
- follower_control_move_update(horz, vert)
- increase_steps
- end
- #--------------------------------------------------------------------------
- # * New method: check_event_trigger_move
- #--------------------------------------------------------------------------
- def check_event_trigger_move(d)
- set_direction(d)
- check_event_trigger_touch_front
- end
- #--------------------------------------------------------------------------
- # * New method: collision_condition?
- #--------------------------------------------------------------------------
- def collision_condition?(x, y, bw, bh, event, event_id, side)
- return false if event && self.id == event_id
- return false unless collision?(x, y, bw, bh)
- return false unless normal_priority? || event
- return false if side && !side_collision?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: follower_control_move_update
- #--------------------------------------------------------------------------
- def follower_control_move_update(horz, vert)
- return unless $imported[:ve_followers_options]
- return unless player? || follower?
- add_move_update(horz == vert ? [horz] : [horz, vert])
- end
- #--------------------------------------------------------------------------
- # * New method: passable?
- #--------------------------------------------------------------------------
- def passable?(x, y, d)
- x = fix_position(x)
- y = fix_position(y)
- passable1 = passable_tile?(x, y, d)
- passable2 = character_collision?(x, y, d)
- fix_movement(x, y, d) if player? && !passable1 && passable2
- fix_collision(x, y, d) if player? && !passable2 && passable1
- passable1 && passable2
- end
- #--------------------------------------------------------------------------
- # * New method: passable_tile?
- #--------------------------------------------------------------------------
- def passable_tile?(x, y, d)
- result = true
- result = passable_down?(x, y) if d == 2
- result = passable_left?(x, y) if d == 4
- result = passable_right?(x, y) if d == 6
- result = passable_up?(x, y) if d == 8
- result
- end
- #--------------------------------------------------------------------------
- # * New method: locked_tile?
- #--------------------------------------------------------------------------
- def locked_tile?(x, y, d = 0)
- list = [2, 4, 6, 8] - [d]
- list.all? {|d| !map_passable?(x, y, d) }
- end
- #--------------------------------------------------------------------------
- # * New method: locked_move?
- #--------------------------------------------------------------------------
- def locked_move?(x, y)
- !passable_down?(x, y) && !passable_left?(x, y)
- !passable_right?(x, y) && !passable_up?(x, y)
- end
- #--------------------------------------------------------------------------
- # * New method: passable_down?
- #--------------------------------------------------------------------------
- def passable_down?(x, y)
- passable_normal?(x.ceil, y.to_i, 2, 4, x.ceil?) &&
- passable_normal?(x.to_i, y.to_i, 2, 6, x.ceil?)
- end
- #--------------------------------------------------------------------------
- # * New method: passable_left?
- #--------------------------------------------------------------------------
- def passable_left?(x, y)
- passable_normal?(x.ceil, y.ceil, 4, 8, y.ceil?) &&
- passable_normal?(x.ceil, y.to_i, 4, 2, y.ceil?)
- end
- #--------------------------------------------------------------------------
- # * New method: passable_right?
- #--------------------------------------------------------------------------
- def passable_right?(x, y)
- passable_normal?(x.to_i, y.ceil, 6, 8, y.ceil?) &&
- passable_normal?(x.to_i, y.to_i, 6, 2, y.ceil?)
- end
- #--------------------------------------------------------------------------
- # * New method: passable_up?
- #--------------------------------------------------------------------------
- def passable_up?(x, y)
- passable_normal?(x.ceil, y.ceil, 8, 4, x.ceil?) &&
- passable_normal?(x.to_i, y.ceil, 8, 6, x.ceil?)
- end
- #--------------------------------------------------------------------------
- # * New method: passable_normal?
- #--------------------------------------------------------------------------
- def passable_normal?(x, y, d, d2, ceil = false)
- x1 = $game_map.round_x(x)
- y1 = $game_map.round_y(y)
- x2 = $game_map.check_x_with_direction(x1, d)
- y2 = $game_map.check_y_with_direction(y1, d)
- x3 = $game_map.round_x_with_direction(x1, d)
- y3 = $game_map.round_y_with_direction(y1, d)
- return false unless $game_map.valid?(x3, y3)
- return true if @through || debug_through?
- return false unless map_passable?(x2, y2, d2) || !ceil
- return false unless move_passable1?(x1, y1, x2, y2, d)
- return false unless move_passable2?(x1, y1, x2, y2, d)
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: move_passable1?
- #--------------------------------------------------------------------------
- def move_passable1?(x1, y1, x2, y2, d)
- map_passable?(x1, y1, d) || map_passable?(x2, y2, d)
- end
- #--------------------------------------------------------------------------
- # * New method: move_passable?
- #--------------------------------------------------------------------------
- def move_passable2?(x1, y1, x2, y2, d)
- map_passable?(x2, y2, reverse_dir(d)) && (map_passable?(x1, y1, d) ||
- locked_tile?(x1, y1))
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement
- #--------------------------------------------------------------------------
- def fix_movement(x, y, d)
- return if (@diagonal && @diagonal != 0) || @diagonal_move
- fix_movement_horiz(x, y, d) if (d == 2 || d == 8) && x.ceil?
- fix_movement_vert(x, y, d) if (d == 4 || d == 6) && y.ceil?
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_horiz
- #--------------------------------------------------------------------------
- def fix_movement_horiz(x, y, d)
- adjust = x - x.to_i
- fix_move_straight(4) if fix_movement_left?(x, y, d) && adjust < 0.5
- fix_move_straight(6) if fix_movement_right?(x, y, d) && adjust > 0.5
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_ver
- #--------------------------------------------------------------------------
- def fix_movement_vert(x, y, d)
- adjust = y - y.to_i
- fix_move_straight(2) if fix_movement_down?(x, y, d) && adjust > 0.5
- fix_move_straight(8) if fix_movement_up?(x, y, d) && adjust < 0.5
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_down?
- #--------------------------------------------------------------------------
- def fix_movement_down?(x, y, d)
- passable_normal?(x.to_i, y.ceil, d, 0, false) && movement_fix?(x, y, 2)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_left?
- #--------------------------------------------------------------------------
- def fix_movement_left?(x, y, d)
- passable_normal?(x.to_i, y.to_i, d, 0, false) && movement_fix?(x, y, 4)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_right?
- #--------------------------------------------------------------------------
- def fix_movement_right?(x, y, d)
- passable_normal?(x.ceil, y.to_i, d, 0, false) && movement_fix?(x, y, 6)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_up?
- #--------------------------------------------------------------------------
- def fix_movement_up?(x, y, d)
- passable_normal?(x.to_i, y.to_i, d, 0, false) && movement_fix?(x, y, 8)
- end
- #--------------------------------------------------------------------------
- # * New method: movement_fix?
- #--------------------------------------------------------------------------
- def movement_fix?(x, y, d)
- passable_tile?(x, y, d) && character_collision?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision
- #--------------------------------------------------------------------------
- def fix_collision(x, y, d)
- return if (@diagonal && @diagonal != 0) || @diagonal_move
- @side_collision = true
- fix_collision_horiz(x, y, d) if (d == 2 || d == 8)
- fix_collision_vert(x, y, d) if (d == 4 || d == 6)
- @side_collision = false
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_horiz
- #--------------------------------------------------------------------------
- def fix_collision_horiz(x, y, d)
- fix_move_straight(4) if fix_collision_left?(x, y, d)
- fix_move_straight(6) if fix_collision_right?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_vert
- #--------------------------------------------------------------------------
- def fix_collision_vert(x, y, d)
- fix_move_straight(2) if fix_collision_down?(x, y, d)
- fix_move_straight(8) if fix_collision_up?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_down?
- #--------------------------------------------------------------------------
- def fix_collision_down?(x, y, d)
- !character_collision?(x, y, d) && collision_fix?(x, y, d, 2)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_left?
- #--------------------------------------------------------------------------
- def fix_collision_left?(x, y, d)
- !character_collision?(x, y, d) && collision_fix?(x, y, d, 4)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_right?
- #--------------------------------------------------------------------------
- def fix_collision_right?(x, y, d)
- !character_collision?(x, y, d) && collision_fix?(x, y, d, 6)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_up?
- #--------------------------------------------------------------------------
- def fix_collision_up?(x, y, d)
- !character_collision?(x, y, d) && collision_fix?(x, y, d, 8)
- end
- #--------------------------------------------------------------------------
- # * New method: collision_fix?
- #--------------------------------------------------------------------------
- def collision_fix?(x, y, d, d2)
- side_collision_fix?(x, y, d, d2, 2) && side_fix?(x, y, d2)
- end
- #--------------------------------------------------------------------------
- # * New method: side_collision_fix?
- #--------------------------------------------------------------------------
- def side_collision_fix?(x, y, d, d2, t)
- t.times.any? do |i|
- x2, y2 = x, y
- y2 += (t - i) * 0.125 if d2 == 2
- x2 -= (t - i) * 0.125 if d2 == 4
- x2 += (t - i) * 0.125 if d2 == 6
- y2 -= (t - i) * 0.125 if d2 == 8
- character_collision?(x2, y2, d)
- end
- end
- #--------------------------------------------------------------------------
- # * New method: side_fix?
- #--------------------------------------------------------------------------
- def side_fix?(x, y, d)
- passable_tile?(x, y, d) && character_collision?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_move_straight
- #--------------------------------------------------------------------------
- def fix_move_straight(d)
- return if moving?
- @x = $game_map.round_x_with_direction(@x, d)
- @y = $game_map.round_y_with_direction(@y, d)
- follower_control_move_update(d, d)
- add_next_movement(d)
- increase_steps
- @moved = player?
- end
- #--------------------------------------------------------------------------
- # * New method: add_next_movement
- #--------------------------------------------------------------------------
- def add_next_movement(d)
- return unless follower? || player?
- return if $imported[:ve_followers_control] && follower_control_block
- return if $game_player.followers.gathering?
- @next_movement.push(d)
- end
- #--------------------------------------------------------------------------
- # * New method: follower_control_block
- #--------------------------------------------------------------------------
- def follower_control_block
- return true if follower? && origin_position
- return true if $game_player.followers.gathering_origin?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: front_collision?
- #--------------------------------------------------------------------------
- def front_collision?(x, y, d)
- return false if (@diagonal && @diagonal != 0) || @diagonal_move
- result = !front_collision_horiz(x, y, d) if (d == 2 || d == 8)
- result = !front_collision_vert(x, y, d) if (d == 4 || d == 6)
- result
- end
- #--------------------------------------------------------------------------
- # * New method: front_collision_horiz
- #--------------------------------------------------------------------------
- def front_collision_horiz(x, y, d)
- side_collision_fix?(x, y, d, 4, 4) || side_collision_fix?(x, y, d, 6, 4)
- end
- #--------------------------------------------------------------------------
- # * New method: front_collision_vert
- #--------------------------------------------------------------------------
- def front_collision_vert(x, y, d)
- side_collision_fix?(x, y, d, 2, 4) || side_collision_fix?(x, y, d, 8, 4)
- end
- #--------------------------------------------------------------------------
- # * New method: step_over?
- #--------------------------------------------------------------------------
- def step_over?
- @through
- end
- #--------------------------------------------------------------------------
- # * New method: bw
- #--------------------------------------------------------------------------
- def bw
- setup_bitmap_dimension unless @bw && character_name == @character_name_wh
- @bw
- end
- #--------------------------------------------------------------------------
- # * New method: bh
- #--------------------------------------------------------------------------
- def bh
- setup_bitmap_dimension unless @bh && character_name == @character_name_wh
- @bh
- end
- #--------------------------------------------------------------------------
- # * New method: setup_bitmap_dimension
- #--------------------------------------------------------------------------
- def setup_bitmap_dimension
- @character_name_wh = character_name
- bitmap = Cache.character(character_name).clone
- sign = @character_name[/^[\!\$]./]
- if character_name != "" && @tile_id == 0 && sign && sign.include?('[code]#==============================================================================
- # ** Victor Engine - Basic Module
- #------------------------------------------------------------------------------
- # Author : Victor Sant
- #
- # Version History:
- # v 1.00 - 2011.12.19 > First relase
- # v 1.01 - 2011.12.21 > Added Event Troop notes
- # v 1.02 - 2011.12.22 > Added character frames value
- # v 1.03 - 2011.12.30 > Added Actor and Enemy notes
- # v 1.04 - 2012.01.01 > Added party average level and map actors
- # v 1.05 - 2012.01.04 > Compatibility with Characters Scripts
- # v 1.06 - 2012.01.07 > Compatibility with Fog and Light Effect
- # > Added new Sprite Character functions
- # v 1.07 - 2012.01.11 > Compatibility with Control Text and Codes
- # v 1.08 - 2012.01.13 > Compatibility with Trait Control
- # v 1.09 - 2012.01.15 > Fixed the Regular Expressions problem with "" and “”
- # v 1.10 - 2012.01.18 > Compatibility with Automatic Battlers
- # v 1.11 - 2012.01.26 > Compatibility with Followers Options
- # Compatibility with Animated Battle beta
- # v 1.12 - 2012.02.08 > Compatibility with Animated Battle
- # v 1.13 - 2012.02.18 > Fix for non RTP dependant encrypted projects
- # v 1.14 - 2012.03.11 > Better version handling and required messages
- # v 1.15 - 2012.03.11 > Added level variable for enemies (to avoid crashes)
- # v 1.16 - 2012.03.21 > Compatibility with Follower Control
- # v 1.17 - 2012.03.22 > Compatibility with Follower Control new method
- # v 1.18 - 2012.03.22 > Added Battler Types tag support
- # v 1.19 - 2012.05.20 > Compatibility with Map Turn Battle
- # v 1.20 - 2012.05.21 > Fix for older RMVXa versions
- # v 1.21 - 2012.05.29 > Compatibility with Pixel Movement
- # v 1.22 - 2012.07.02 > Compatibility with Terrain States
- # v 1.23 - 2012.07.03 > Fix for Pixel Movement
- # v 1.24 - 2012.07.17 > Compatibility with Critical Hit Effects
- # v 1.25 - 2012.07.24 > Compatibility with Moving Plaforms
- # v 1.26 - 2012.07.30 > Compatibility with Automatic Battlers
- # v 1.27 - 2012.08.01 > Compatibility with Custom Slip Effect
- # v 1.28 - 2012.08.03 > Compatibility with Custom Slip Effect v 1.01
- #------------------------------------------------------------------------------
- # This is the basic script for the system from Victory Engine and is
- # required to use the scripts from the engine. This script offer some new
- # functions to be used within many scripts of the engine.
- #------------------------------------------------------------------------------
- # Compatibility
- # Required for the Victor Engine
- #
- # * Overwrite methods
- # class << Cache
- # def self.character(filename)
- #
- # class Sprite_Character < Sprite_Base
- # def set_character_bitmap
- #
- # * 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
- #------------------------------------------------------------------------------
- # Setting module for the Victor Engine
- #==============================================================================
- module Victor_Engine
- #--------------------------------------------------------------------------
- # * New method: required_script
- #--------------------------------------------------------------------------
- def self.required_script(name, req, version, type = 0)
- if type != :bellow && (!$imported[req] || $imported[req] < version)
- msg = "The script '%s' requires the script\n"
- case type
- when :above
- msg += "'%s' v%s or higher above it to work properly\n"
- else
- msg += "'%s' v%s or higher to work properly\n"
- end
- msg += "Go to http://victorscripts.wordpress.com/ to download this script."
- self.exit_message(msg, name, req, version)
- elsif type == :bellow && $imported[req]
- msg = "The script '%s' requires the script\n"
- msg += "'%s' to be put bellow it\n"
- msg += "move the scripts to the proper position"
- self.exit_message(msg, name, req, version)
- end
- end
- #--------------------------------------------------------------------------
- # * New method: exit_message
- #--------------------------------------------------------------------------
- def self.exit_message(message, name, req, version)
- name = self.script_name(name)
- req = self.script_name(req)
- msgbox(sprintf(message, name, req, version))
- exit
- end
- #--------------------------------------------------------------------------
- # * New method: script_name
- #--------------------------------------------------------------------------
- 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_basic_module] = 1.28
- #==============================================================================
- # ** Object
- #------------------------------------------------------------------------------
- # This class is the superclass of all other classes.
- #==============================================================================
- class Object
- #--------------------------------------------------------------------------
- # * Include setting module
- #--------------------------------------------------------------------------
- include Victor_Engine
- #-------------------------------------------------------------------------
- # * New method: rand_between
- #-------------------------------------------------------------------------
- def rand_between(min, max)
- min + rand(max - min + 1)
- end
- #--------------------------------------------------------------------------
- # * New method: numeric?
- #--------------------------------------------------------------------------
- def numeric?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: string?
- #--------------------------------------------------------------------------
- def string?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: array?
- #--------------------------------------------------------------------------
- def array?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: float?
- #--------------------------------------------------------------------------
- def float?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: item?
- #--------------------------------------------------------------------------
- def item?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: skill?
- #--------------------------------------------------------------------------
- def skill?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: file_exist?
- #--------------------------------------------------------------------------
- def file_exist?(path, filename)
- $file_list ||= {}
- $file_list[path + filename] ||= file_test(path, filename)
- $file_list[path + filename]
- end
- #--------------------------------------------------------------------------
- # * New method: get_file_list
- #--------------------------------------------------------------------------
- def file_test(path, filename)
- bitmap = Cache.load_bitmap(path, filename) rescue nil
- bitmap ? true : false
- end
- #--------------------------------------------------------------------------
- # * New method: character_exist?
- #--------------------------------------------------------------------------
- def character_exist?(filename)
- file_exist?("Graphics/Characters/", filename)
- end
- #--------------------------------------------------------------------------
- # * New method: battler_exist?
- #--------------------------------------------------------------------------
- def battler_exist?(filename)
- file_exist?("Graphics/Battlers/", filename)
- end
- #--------------------------------------------------------------------------
- # * New method: get_filename
- #--------------------------------------------------------------------------
- def get_filename
- "[\"'“‘]([^\"'”‘”’]+)[\"'”’]"
- end
- #--------------------------------------------------------------------------
- # * New method: get_all_values
- #--------------------------------------------------------------------------
- def get_all_values(value1, value2 = nil)
- value2 = value1 unless value2
- /<#{value1}>((?:[^<]|<[^\/])*)<\/#{value2}>/im
- end
- #--------------------------------------------------------------------------
- # * New method: make_symbol
- #--------------------------------------------------------------------------
- def make_symbol(string)
- string.downcase.gsub(" ", "_").to_sym
- end
- #--------------------------------------------------------------------------
- # * New method: make_string
- #--------------------------------------------------------------------------
- def make_string(symbol)
- symbol.to_s.gsub("_", " ").upcase
- end
- #--------------------------------------------------------------------------
- # * New method: returing_value
- #--------------------------------------------------------------------------
- def returing_value(i, x)
- i % (x * 2) >= x ? (x * 2) - i % (x * 2) : i % (x * 2)
- end
- #--------------------------------------------------------------------------
- # New method: in_rect?
- #--------------------------------------------------------------------------
- def in_rect?(w, h, x1, y1, x2, y2, fx = 0)
- aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
- bx > ax - aw && bx < ax + aw && by > ay - ah && by < ay + ah
- end
- #--------------------------------------------------------------------------
- # New method: in_radius?
- #--------------------------------------------------------------------------
- def in_radius?(w, h, x1, y1, x2, y2, fx = 0)
- aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
- ((bx - ax) ** 2 / aw ** 2) + ((by - ay) ** 2 / ah ** 2) <= 1
- end
- #--------------------------------------------------------------------------
- # New method: setup_area
- #--------------------------------------------------------------------------
- def setup_area(w, h, x1, y1, x2, y2, fx)
- aw = w
- ah = h * aw
- ax = x1
- ay = y1
- bx = x2
- by = y2
- bx += fx / 4 if ax > bx
- bx -= fx / 4 if ax < bx
- [aw, ah, ax, ay, bx, by]
- end
- end
- #==============================================================================
- # ** String
- #------------------------------------------------------------------------------
- # The string class. Can handle character sequences of arbitrary lengths.
- #==============================================================================
- class String
- #--------------------------------------------------------------------------
- # * New method: string?
- #--------------------------------------------------------------------------
- def string?
- return true
- end
- end
- #==============================================================================
- # ** Numeric
- #------------------------------------------------------------------------------
- # This is the abstract class for numbers.
- #==============================================================================
- class Numeric
- #--------------------------------------------------------------------------
- # * New method: numeric?
- #--------------------------------------------------------------------------
- def numeric?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: ceil?
- #--------------------------------------------------------------------------
- def ceil?
- return false
- 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
- self.inject(0) {|r, n| r += (n.numeric? ? n : 0)}
- end
- #---------------------------------------------------------------------------
- # * New method: average
- #---------------------------------------------------------------------------
- def average(float = false)
- self.sum / [(float ? size.to_f : size.to_i), 1].max
- end
- #---------------------------------------------------------------------------
- # * New method: next_item
- #---------------------------------------------------------------------------
- def next_item
- item = self.shift
- self.push(item)
- item
- end
- #---------------------------------------------------------------------------
- # * New method: previous_item
- #---------------------------------------------------------------------------
- def previous_item
- item = self.pop
- self.unshift(item)
- item
- end
- end
- #==============================================================================
- # ** RPG::Troop::Page
- #------------------------------------------------------------------------------
- # This is the data class for battle events (pages).
- #==============================================================================
- class RPG::Troop::Page
- #--------------------------------------------------------------------------
- # * New method: note
- #--------------------------------------------------------------------------
- def note
- return "" if !@list || @list.size <= 0
- comment_list = []
- @list.each do |item|
- next unless item && (item.code == 108 || item.code == 408)
- comment_list.push(item.parameters[0])
- end
- comment_list.join("\r\n")
- end
- end
- #==============================================================================
- # ** RPG::UsableItem
- #------------------------------------------------------------------------------
- # This is the superclass for skills and items.
- #==============================================================================
- class RPG::UsableItem < RPG::BaseItem
- #--------------------------------------------------------------------------
- # * New method: for_all_targets?
- #--------------------------------------------------------------------------
- def for_all_targets?
- return false
- end
- end
- #==============================================================================
- # ** RPG::Skill
- #------------------------------------------------------------------------------
- # This is the data class for skills.
- #==============================================================================
- class RPG::Skill < RPG::UsableItem
- #--------------------------------------------------------------------------
- # * New method: item?
- #--------------------------------------------------------------------------
- def item?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: skill?
- #--------------------------------------------------------------------------
- def skill?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: type_set
- #--------------------------------------------------------------------------
- def type_set
- [stype_id]
- end
- end
- #==============================================================================
- # ** RPG::Item
- #------------------------------------------------------------------------------
- # This is the data class for items.
- #==============================================================================
- class RPG::Item < RPG::UsableItem
- #--------------------------------------------------------------------------
- # * New method: item?
- #--------------------------------------------------------------------------
- def item?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: skill?
- #--------------------------------------------------------------------------
- def skill?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: type_set
- #--------------------------------------------------------------------------
- def type_set
- [itype_id]
- end
- 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
- #==============================================================================
- # ** 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_cond
- #--------------------------------------------------------------------------
- def get_cond(text)
- case text.upcase
- when "HIGHER" then ">"
- when "LOWER" then "<"
- when "EQUAL" then "=="
- when "DIFFERENT" then "!="
- else "!="
- end
- end
- #--------------------------------------------------------------------------
- # * 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: get_param_id
- #--------------------------------------------------------------------------
- def get_param_id(text)
- case text.upcase
- when "MAXHP", "HP" then 0
- when "MAXMP", "MP" then 1
- when "ATK" then 2
- when "DEF" then 3
- when "MAT" then 4
- when "MDF" then 5
- when "AGI" then 6
- when "LUK" then 7
- 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:
- #--------------------------------------------------------------------------
- def element_set(item)
- element_set = [item.damage.element_id]
- element_set += atk_elements if item.damage.element_id < 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 < state_rate(state_id)
- 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
- #--------------------------------------------------------------------------
- # * New method: cri_rate
- #--------------------------------------------------------------------------
- def cri_rate(user, item)
- user.cri
- end
- #--------------------------------------------------------------------------
- # * New method: cri_eva
- #--------------------------------------------------------------------------
- def cri_eva(user, item)
- cev
- end
- #--------------------------------------------------------------------------
- # * New method: setup_critical
- #--------------------------------------------------------------------------
- def setup_critical(user, item)
- cri_rate(user, item) * (1 - cri_eva(user, item))
- end
- end
- #==============================================================================
- # ** Game_Enemy
- #------------------------------------------------------------------------------
- # This class handles enemy characters. It's used within the Game_Troop class
- # ($game_troop).
- #==============================================================================
- class Game_Enemy < Game_Battler
- #--------------------------------------------------------------------------
- # * New method: note
- #--------------------------------------------------------------------------
- def note
- enemy ? enemy.note : ""
- end
- #--------------------------------------------------------------------------
- # * New method: get_all_notes
- #--------------------------------------------------------------------------
- def get_all_notes(*args)
- notes = ""
- notes += note if !args.include?(:self)
- states.compact.each {|state| notes += state.note } if !args.include?(:state)
- notes
- end
- #--------------------------------------------------------------------------
- # * New method: get_all_objects
- #--------------------------------------------------------------------------
- def get_all_objects(*args)
- result = []
- result += [self] if !args.include?(:self)
- result += states.compact if !args.include?(:state)
- result
- end
- #--------------------------------------------------------------------------
- # * New method: level
- #--------------------------------------------------------------------------
- def level
- return 1
- end
- #--------------------------------------------------------------------------
- # * New method: skill_learn?
- #--------------------------------------------------------------------------
- def skill_learn?(skill)
- skill.skill? && skills.include?(skill)
- end
- #--------------------------------------------------------------------------
- # * New method: skills
- #--------------------------------------------------------------------------
- def skills
- enemy.actions.collect {|action| $data_skills[action.skill_id] }
- end
- end
- #==============================================================================
- # ** Game_Actor
- #------------------------------------------------------------------------------
- # This class handles actors. It's used within the Game_Actors class
- # ($game_actors) and referenced by the Game_Party class ($game_party).
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # * New method: note
- #--------------------------------------------------------------------------
- def note
- actor ? actor.note : ""
- end
- #--------------------------------------------------------------------------
- # * New method: hue
- #--------------------------------------------------------------------------
- def hue
- @hue ? @hue : 0
- end
- #--------------------------------------------------------------------------
- # * New method: get_all_notes
- #--------------------------------------------------------------------------
- def get_all_notes(*args)
- notes = ""
- notes += note if !args.include?(:self)
- notes += self.class.note if !args.include?(:class)
- equips.compact.each {|equip| notes += equip.note } if !args.include?(:equip)
- states.compact.each {|state| notes += state.note } if !args.include?(:state)
- notes
- end
- #--------------------------------------------------------------------------
- # * New method: get_all_objects
- #--------------------------------------------------------------------------
- def get_all_objects(*args)
- result = []
- result += [self] if !args.include?(:self)
- result += [self.class] if !args.include?(:self)
- 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_Player and Game_Event classes.
- #==============================================================================
- class Game_Character < Game_CharacterBase
- #--------------------------------------------------------------------------
- # * New method: move_toward_position
- #--------------------------------------------------------------------------
- def move_toward_position(x, y)
- sx = distance_x_from(x)
- sy = distance_y_from(y)
- if sx.abs > sy.abs
- move_straight(sx > 0 ? 4 : 6)
- move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0
- elsif sy != 0
- move_straight(sy > 0 ? 8 : 2)
- move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0
- end
- end
- #--------------------------------------------------------------------------
- # * New method: move_toward_position
- #--------------------------------------------------------------------------
- def turn_toward_position(x, y)
- sx = distance_x_from(x)
- sy = distance_y_from(y)
- if sx.abs > sy.abs
- set_direction(sx > 0 ? 4 : 6)
- elsif sy != 0
- set_direction(sy > 0 ? 8 : 2)
- end
- end
- end
- #==============================================================================
- # ** Game_Player
- #------------------------------------------------------------------------------
- # This class handles the player.
- # The instance of this class is referenced by $game_map.
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # * New method: player?
- #--------------------------------------------------------------------------
- def player?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: perform_transfer
- #--------------------------------------------------------------------------
- def new_map_id
- @new_map_id
- end
- #--------------------------------------------------------------------------
- # * New method: hue
- #--------------------------------------------------------------------------
- def hue
- actor ? actor.hue : 0
- end
- end
- #==============================================================================
- # ** 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
- #--------------------------------------------------------------------------
- # * New method: vehicle?
- #--------------------------------------------------------------------------
- def vehicle?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: map_id
- #--------------------------------------------------------------------------
- def map_id
- @map_id
- end
- #--------------------------------------------------------------------------
- # * New method: type
- #--------------------------------------------------------------------------
- def type
- @type
- end
- #--------------------------------------------------------------------------
- # * New method: aerial?
- #--------------------------------------------------------------------------
- def aerial?
- type == :airship
- end
- #--------------------------------------------------------------------------
- # * New method: above?
- #--------------------------------------------------------------------------
- def above?
- aerial?
- 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
- #--------------------------------------------------------------------------
- # * New method: name
- #--------------------------------------------------------------------------
- def name
- @event.name
- end
- #--------------------------------------------------------------------------
- # * New method: event?
- #--------------------------------------------------------------------------
- def event?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: erased?
- #--------------------------------------------------------------------------
- def erased?
- @erased
- end
- #--------------------------------------------------------------------------
- # * New method: note
- #--------------------------------------------------------------------------
- def note
- return "" if !@page || [email protected] || @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
- #==============================================================================
- # ** 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?(')
- @bw = bitmap.width / 32.0 / frames
- @bh = bitmap.height / 32.0 / 4
- elsif character_name != "" && @tile_id == 0
- @bw = bitmap.width / 32.0 / (frames * 4)
- @bh = bitmap.height / 32.0 / 8
- else
- @bw = 1.0
- @bh = 1.0
- end
- bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # * New method: collision?
- #--------------------------------------------------------------------------
- def collision?(x, y, w, h)
- ax1, ay1, ax2, ay2 = setup_rect(x, y, w, h)
- bx1, by1, bx2, by2 = setup_rect(@x, @y, bw, bh)
- ax2 > bx1 && ax1 < bx2 && ay2 > by1 && ay1 < by2
- end
- #--------------------------------------------------------------------------
- # * New method: over?
- #--------------------------------------------------------------------------
- def over?(x, y)
- ax1, ay1, ax2, ay2 = setup_rect(x, y - 0.125, 0, 0)
- bx1, by1, bx2, by2 = setup_rect(@real_x, @real_y, bw, bh - 0.125)
- ax2 >= bx1 && ax1 <= bx2 && ay2 >= by1 && ay1 <= by2
- end
- #--------------------------------------------------------------------------
- # * New method: setup_rect
- #--------------------------------------------------------------------------
- def setup_rect(x, y, w, h)
- x1 = x - w / 2.0
- y1 = y - h
- x2 = x1 + w
- y2 = y1 + h
- [x1, y1, x2, y2]
- end
- #--------------------------------------------------------------------------
- # * New method: align_with
- #--------------------------------------------------------------------------
- def align_with(x, y)
- d = @direction
- @x = $game_map.round_x_with_direction(x, 0) if d == 2 || d == 8
- @y = $game_map.round_y_with_direction(y, 0) if d == 6 || d == 4
- dx = (d == 2 || d == 8) ? (@x - @real_x) / 0.125 : 0
- dy = (d == 4 || d == 6) ? (@y - @real_y) / 0.125 : 0
- set_direction(dx > 0 ? 6 : dx < 0 ? 4 : dy > 0 ? 2 : dy < 0 ? 8 : d)
- @real_x = $game_map.x_with_direction(@x, reverse_dir(@direction), dx.abs)
- @real_y = $game_map.y_with_direction(@y, reverse_dir(@direction), dy.abs)
- update_for_align while moving?
- @direction = d
- end
- #--------------------------------------------------------------------------
- # * New method: update_for_align
- #--------------------------------------------------------------------------
- def update_for_align
- SceneManager.scene.update_basic
- SceneManager.scene.spriteset.update
- $game_map.update(true)
- $game_timer.update
- update_animation
- update_move
- end
- #--------------------------------------------------------------------------
- # * New method: fix_position
- #--------------------------------------------------------------------------
- def fix_position(n)
- (n * 64 / 8).round / 8.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
- #--------------------------------------------------------------------------
- # * Alias method: move_toward_character
- #--------------------------------------------------------------------------
- alias :move_toward_character_ve_pixel_movement :move_toward_character
- def move_toward_character(character)
- sx = distance_x_from(character.x)
- sy = distance_y_from(character.y)
- move_toward_character_ve_pixel_movement(character)
- @x = character.x if sx.abs < 1
- @y = character.y if sy.abs < 1
- end
- #--------------------------------------------------------------------------
- # * Alias method: move_toward_position
- #--------------------------------------------------------------------------
- alias :move_toward_position_ve_pixel_movement :move_toward_position
- def move_toward_position(x, y)
- sx = distance_x_from(x)
- sy = distance_y_from(y)
- move_toward_position_ve_pixel_movement(x, y)
- @x = x if sx.abs < 1
- @y = y if sy.abs < 1
- 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
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :over_event
- attr_accessor :land_test
- #--------------------------------------------------------------------------
- # * Overwrite method: check_event_trigger_there
- #--------------------------------------------------------------------------
- def check_event_trigger_there(triggers)
- x2 = $game_map.round_x_with_direction(@x, @direction)
- y2 = $game_map.round_y_with_direction(@y, @direction)
- start_map_event(x2, y2, triggers, true)
- return if $game_map.any_event_starting?
- return unless counter_tile?
- x3 = $game_map.check_x_with_direction(x2, @direction)
- y3 = $game_map.check_y_with_direction(y2, @direction)
- start_map_event(x3, y3, triggers, true)
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: start_map_event
- #--------------------------------------------------------------------------
- def start_map_event(x, y, triggers, normal)
- return if $game_map.interpreter.running?
- $game_map.events_xy(x, y).each do |event|
- event.start if check_event_contiontion(x, y, event, triggers, normal)
- end
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: update_nonmoving
- #--------------------------------------------------------------------------
- def update_nonmoving(last_moving)
- return if $game_map.interpreter.running?
- moved = @moved
- @moved = false
- if last_moving || moved
- $game_party.on_player_walk
- return if check_touch_event
- end
- if movable? && Input.trigger?(:C)
- return if get_on_off_vehicle
- return if check_action_event
- end
- @over_event -= 1 if @over_event > 0 && (last_moving || moved)
- update_encounter if last_moving || moved
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: get_on_vehicle
- #--------------------------------------------------------------------------
- def get_on_vehicle
- setup_vehicle
- enter_vehicle if vehicle
- @vehicle_getting_on
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: increase_steps
- #--------------------------------------------------------------------------
- def increase_steps
- super
- if normal_walk?
- @steps += 1
- $game_player.damage_floor = 0 unless on_damage_floor?
- $game_player.damage_floor += 1
- $game_party.increase_steps if @steps % 8 == 0
- end
- end
- #--------------------------------------------------------------------------
- # * Alias method: get_off_vehicle
- #--------------------------------------------------------------------------
- alias :get_off_vehicle_ve_pixel_movement :get_off_vehicle
- def get_off_vehicle
- clear_next_movement if vehicle.land_ok?(@x, @y, @direction)
- get_off_vehicle_ve_pixel_movement
- end
- #--------------------------------------------------------------------------
- # * Alias method: clear_transfer_info
- #--------------------------------------------------------------------------
- alias :clear_transfer_info_ve_pixel_movement :clear_transfer_info
- def clear_transfer_info
- clear_transfer_info_ve_pixel_movement
- clear_next_movement
- end
- #--------------------------------------------------------------------------
- # * Alias method: update
- #--------------------------------------------------------------------------
- alias :update_ve_gp_pixel_movement :update
- def update
- @followers.move unless $imported[:ve_followers_options]
- update_ve_gp_pixel_movement
- end
- #--------------------------------------------------------------------------
- # * New method: check_event_contiontion
- #--------------------------------------------------------------------------
- def check_event_contiontion(x, y, event, triggers, normal)
- passable = passable_tile?(@x, @y, @direction)
- w = (counter_tile? || !passable) ? 1.0 : bw
- h = (counter_tile? || !passable) ? 1.0 : bh
- return false unless event.trigger_in?(triggers)
- return false unless event.event_priority?(normal)
- return false unless passable || event.over_tile? || counter_tile?
- return false unless event.collision?(x, y, w, h) || !jumping?
- return false unless !event.in_front? || front_collision?(x, y, @direction)
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: counter_tile?
- #--------------------------------------------------------------------------
- def counter_tile?
- x = $game_map.check_x_with_direction(@x, @direction)
- y = $game_map.check_y_with_direction(@y, @direction)
- $game_map.counter?(x, y)
- end
- #--------------------------------------------------------------------------
- # * New method: setup_vehicle
- #--------------------------------------------------------------------------
- def setup_vehicle
- $game_map.vehicles.compact.each do |vehicle|
- next unless vehicle.enter_vechicle?(@x, @y, @direction)
- @vehicle_type = vehicle.type
- break if vehicle
- end
- end
- #--------------------------------------------------------------------------
- # * New method: enter_vehicle
- #--------------------------------------------------------------------------
- def enter_vehicle
- align_with(vehicle.x, vehicle.y) unless in_airship?
- @vehicle_getting_on = true
- force_move_forward unless in_airship?
- @followers.gather
- end
- #--------------------------------------------------------------------------
- # * New method: clear_next_movement
- #--------------------------------------------------------------------------
- def clear_next_movement
- @next_movement.clear
- @followers.clear_next_movement
- end
- #--------------------------------------------------------------------------
- # * New method: step_times
- #--------------------------------------------------------------------------
- def step_times
- (move_route_forcing || not_driving?) ? super : 1
- end
- #--------------------------------------------------------------------------
- # * New method: not_driving?
- #--------------------------------------------------------------------------
- def not_driving?
- vehicle && !vehicle.driving
- end
- #--------------------------------------------------------------------------
- # * New method: move_straight
- #--------------------------------------------------------------------------
- def move_straight(d, turn_ok = true)
- super
- end
- #--------------------------------------------------------------------------
- # * New method: move_diagonal
- #--------------------------------------------------------------------------
- def move_diagonal(horz, vert)
- super
- end
- #--------------------------------------------------------------------------
- # * New method: setup_bitmap_dimension
- #--------------------------------------------------------------------------
- def setup_bitmap_dimension
- @bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
- @bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
- end
- end
- #==============================================================================
- # ** 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
- #--------------------------------------------------------------------------
- # * Overwrite method: chase_preceding_character
- #--------------------------------------------------------------------------
- def chase_preceding_character
- return if $imported[:ve_followers_control] && cant_follow_character
- unless moving?
- if @preceding_character.next_movement.size >= 8 && !gathering?
- next_move = @preceding_character.next_movement.shift
- move_straight(next_move) if next_move.numeric?
- move_diagonal(*next_move) if next_move.array?
- elsif gathering?
- @preceding_character.next_movement.clear
- move_toward_player
- end
- end
- end
- #--------------------------------------------------------------------------
- # * New method: move_straight
- #--------------------------------------------------------------------------
- def move_straight(d, turn_ok = true)
- super
- end
- #--------------------------------------------------------------------------
- # * New method: move_diagonal
- #--------------------------------------------------------------------------
- def move_diagonal(horz, vert)
- super
- end
- #--------------------------------------------------------------------------
- # * New method: movement_size
- #--------------------------------------------------------------------------
- def movement_size
- return 8
- end
- #--------------------------------------------------------------------------
- # * New method: step_times
- #--------------------------------------------------------------------------
- def step_times
- (move_route_forcing || not_driving? || gathering?) ? super : 1
- end
- #--------------------------------------------------------------------------
- # * New method: not_driving?
- #--------------------------------------------------------------------------
- def not_driving?
- $game_player.not_driving?
- end
- #--------------------------------------------------------------------------
- # * New method: setup_bitmap_dimension
- #--------------------------------------------------------------------------
- def setup_bitmap_dimension
- @bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
- @bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
- 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: clear_next_movement
- #--------------------------------------------------------------------------
- def clear_next_movement
- each {|follower| follower.next_movement.clear }
- 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
- #--------------------------------------------------------------------------
- # * Overwrite method: collide_with_player_characters?
- #--------------------------------------------------------------------------
- def collide_with_player_characters?(x, y)
- normal_priority? && player_collision?(x, y)
- end
- #--------------------------------------------------------------------------
- # * Alias method: start
- #--------------------------------------------------------------------------
- alias :start_ve_pixel_movement :start
- def start
- start_ve_pixel_movement
- $game_player.over_event = 8 if step_over? && !step_trigger?
- end
- #--------------------------------------------------------------------------
- # * Alias method: setup_page_settings
- #--------------------------------------------------------------------------
- alias :setup_page_settings_ve_pixel_movement :setup_page_settings
- def setup_page_settings_ve_pixel_movement
- setup_page_settings_ve_anti_lag
- @move_steps = note =~ /<MOVE STEPS: (\d+)>/i ? $1.to_i : nil
- @step_trigger = note =~ /<EACH STEP TRIGGER>/i ? true : false
- @in_front = note =~ /<FRONT COLLISION>/i ? true : false
- @over_tile = note =~ /<OVER TILE>/i ? true : false
- @side_fix = note =~ /<NO SIDE COLLISION FIX>/i ? false : true
- end
- #--------------------------------------------------------------------------
- # * New method: player_collision?
- #--------------------------------------------------------------------------
- def player_collision?(x, y)
- $game_map.actors.any? {|actor| actor.collision?(x, y, bh, bw)}
- end
- #--------------------------------------------------------------------------
- # * New method: event_priority?
- #--------------------------------------------------------------------------
- def event_priority?(normal)
- (normal_priority? == normal || (@through && !normal)) &&
- (normal_priority? || @trigger == 0 || $game_player.over_event == 0)
- end
- #--------------------------------------------------------------------------
- # * New method: check_event_trigger_touch
- #--------------------------------------------------------------------------
- def check_event_trigger_touch(x, y)
- return if $game_map.interpreter.running?
- if @trigger == 2 && $game_player.collision?(x, y, bh, bw)
- start if !jumping? && normal_priority?
- end
- end
- #--------------------------------------------------------------------------
- # * New method: step_over?
- #--------------------------------------------------------------------------
- def step_over?
- super || (@character_name == "" && @tile_id == 0) || @priority_type == 0
- end
- #--------------------------------------------------------------------------
- # * New method: step_times
- #--------------------------------------------------------------------------
- def step_times
- @move_steps ? @move_steps : super
- end
- #--------------------------------------------------------------------------
- # * New method: step_trigger?
- #--------------------------------------------------------------------------
- def step_trigger?
- @step_trigger
- end
- #--------------------------------------------------------------------------
- # * New method: in_front?
- #--------------------------------------------------------------------------
- def in_front?
- @in_front
- end
- #--------------------------------------------------------------------------
- # * New method: over_tile?
- #--------------------------------------------------------------------------
- def over_tile?
- @over_tile
- end
- #--------------------------------------------------------------------------
- # * New method: side_collision?
- #--------------------------------------------------------------------------
- def side_collision?
- @side_fix
- end
- #--------------------------------------------------------------------------
- # * New method: setup_bitmap_dimension
- #--------------------------------------------------------------------------
- def setup_bitmap_dimension
- regexp = /<EVENT SIZE: (\d+), (\d+)>/i
- note =~ regexp ? setup_custom_dimension($1.to_i, $2.to_i) : super
- end
- #--------------------------------------------------------------------------
- # * New method: setup_custom_dimension
- #--------------------------------------------------------------------------
- def setup_custom_dimension(x, y)
- x1 = (x / 8).to_i
- y1 = (y / 8).to_i
- @bw = x1 / 4.0
- @bh = y1 / 4.0
- 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
- #--------------------------------------------------------------------------
- # * Overwrite method: land_ok?
- #--------------------------------------------------------------------------
- def land_ok?(x, y, d)
- @type == :airship ? airship_landable?(x, y) : check_landable?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * New method: land_test
- #--------------------------------------------------------------------------
- def land_test
- @land_test
- end
- #--------------------------------------------------------------------------
- # * New method: step_over?
- #--------------------------------------------------------------------------
- def step_over?
- above? || super
- end
- #--------------------------------------------------------------------------
- # * New method: check_landable?
- #--------------------------------------------------------------------------
- def check_landable?(x, y, d)
- x2 = $game_map.check_x_with_direction(x, d)
- y2 = $game_map.check_y_with_direction(y, d)
- @land_test = true
- result = passable?(x2, y2, d)
- @land_test = false
- result
- end
- #--------------------------------------------------------------------------
- # * New method: airship_landable?
- #--------------------------------------------------------------------------
- def airship_landable?(x, y)
- [2, 4, 6, 8].any? {|d| passable?(x, y, d) }
- end
- #--------------------------------------------------------------------------
- # * New method: passable_normal?
- #--------------------------------------------------------------------------
- def passable_normal?(x, y, d ,d2, ceil = false)
- @land_test ? landable_normal?(x, y, d ,d2, ceil) : super(x, y, d ,d2, ceil)
- end
- #--------------------------------------------------------------------------
- # * New method: landable_normal?
- #--------------------------------------------------------------------------
- def landable_normal?(x, y, d ,d2, ceil)
- x1 = $game_map.round_x(x)
- y1 = $game_map.round_y(y)
- return false unless $game_map.valid?(x1, y1)
- return true if @through || debug_through?
- return false unless map_passable?(x1, y1, d)
- return false unless map_passable?(x1, y1, d2) || !ceil
- return false unless map_passable?(x1, y1, reverse_dir(d))
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: enter_vechicle?
- #--------------------------------------------------------------------------
- def enter_vechicle?(x, y, d)
- return false if @map_id != $game_map.map_id
- x2 = $game_map.round_x_with_direction(x, d)
- y2 = $game_map.round_y_with_direction(y, d)
- x3 = $game_map.check_x_with_direction(@x, reverse_dir(d))
- y3 = $game_map.check_y_with_direction(@y, reverse_dir(d))
- ( above? && collision?(x, y - 0.125, bw * 0.75, bh * 0.75)) ||
- (!above? && collision?(x2, y2, bw, bh) && map_passable?(x3, y3, d))
- end
- #--------------------------------------------------------------------------
- # * New method: vehicle_collision?
- #--------------------------------------------------------------------------
- def vehicle_collision?(x, y, bw, bh, player)
- return false if step_over?
- return false if player.player? && self == player.vehicle
- return false if !collision?(x, y, bw, bh)
- return true
- end
- end
复制代码 )
@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[/code])
@bw = bitmap.width / 32.0 / frames
@bh = bitmap.height / 32.0 / 4
elsif character_name != "" && @tile_id == 0
@bw = bitmap.width / 32.0 / (frames * 4)
@bh = bitmap.height / 32.0 / 8
else
@bw = 1.0
@bh = 1.0
end
bitmap.dispose
end
#--------------------------------------------------------------------------
# * New method: collision?
#--------------------------------------------------------------------------
def collision?(x, y, w, h)
ax1, ay1, ax2, ay2 = setup_rect(x, y, w, h)
bx1, by1, bx2, by2 = setup_rect(@x, @y, bw, bh)
ax2 > bx1 && ax1 < bx2 && ay2 > by1 && ay1 < by2
end
#--------------------------------------------------------------------------
# * New method: over?
#--------------------------------------------------------------------------
def over?(x, y)
ax1, ay1, ax2, ay2 = setup_rect(x, y - 0.125, 0, 0)
bx1, by1, bx2, by2 = setup_rect(@real_x, @real_y, bw, bh - 0.125)
ax2 >= bx1 && ax1 <= bx2 && ay2 >= by1 && ay1 <= by2
end
#--------------------------------------------------------------------------
# * New method: setup_rect
#--------------------------------------------------------------------------
def setup_rect(x, y, w, h)
x1 = x - w / 2.0
y1 = y - h
x2 = x1 + w
y2 = y1 + h
[x1, y1, x2, y2]
end
#--------------------------------------------------------------------------
# * New method: align_with
#--------------------------------------------------------------------------
def align_with(x, y)
d = @direction
@x = $game_map.round_x_with_direction(x, 0) if d == 2 || d == 8
@y = $game_map.round_y_with_direction(y, 0) if d == 6 || d == 4
dx = (d == 2 || d == 8) ? (@x - @real_x) / 0.125 : 0
dy = (d == 4 || d == 6) ? (@y - @real_y) / 0.125 : 0
set_direction(dx > 0 ? 6 : dx < 0 ? 4 : dy > 0 ? 2 : dy < 0 ? 8 : d)
@real_x = $game_map.x_with_direction(@x, reverse_dir(@direction), dx.abs)
@real_y = $game_map.y_with_direction(@y, reverse_dir(@direction), dy.abs)
update_for_align while moving?
@direction = d
end
#--------------------------------------------------------------------------
# * New method: update_for_align
#--------------------------------------------------------------------------
def update_for_align
SceneManager.scene.update_basic
SceneManager.scene.spriteset.update
$game_map.update(true)
$game_timer.update
update_animation
update_move
end
#--------------------------------------------------------------------------
# * New method: fix_position
#--------------------------------------------------------------------------
def fix_position(n)
(n * 64 / 8).round / 8.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
#--------------------------------------------------------------------------
# * Alias method: move_toward_character
#--------------------------------------------------------------------------
alias :move_toward_character_ve_pixel_movement :move_toward_character
def move_toward_character(character)
sx = distance_x_from(character.x)
sy = distance_y_from(character.y)
move_toward_character_ve_pixel_movement(character)
@x = character.x if sx.abs < 1
@y = character.y if sy.abs < 1
end
#--------------------------------------------------------------------------
# * Alias method: move_toward_position
#--------------------------------------------------------------------------
alias :move_toward_position_ve_pixel_movement :move_toward_position
def move_toward_position(x, y)
sx = distance_x_from(x)
sy = distance_y_from(y)
move_toward_position_ve_pixel_movement(x, y)
@x = x if sx.abs < 1
@y = y if sy.abs < 1
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
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :over_event
attr_accessor :land_test
#--------------------------------------------------------------------------
# * Overwrite method: check_event_trigger_there
#--------------------------------------------------------------------------
def check_event_trigger_there(triggers)
x2 = $game_map.round_x_with_direction(@x, @direction)
y2 = $game_map.round_y_with_direction(@y, @direction)
start_map_event(x2, y2, triggers, true)
return if $game_map.any_event_starting?
return unless counter_tile?
x3 = $game_map.check_x_with_direction(x2, @direction)
y3 = $game_map.check_y_with_direction(y2, @direction)
start_map_event(x3, y3, triggers, true)
end
#--------------------------------------------------------------------------
# * Overwrite method: start_map_event
#--------------------------------------------------------------------------
def start_map_event(x, y, triggers, normal)
return if $game_map.interpreter.running?
$game_map.events_xy(x, y).each do |event|
event.start if check_event_contiontion(x, y, event, triggers, normal)
end
end
#--------------------------------------------------------------------------
# * Overwrite method: update_nonmoving
#--------------------------------------------------------------------------
def update_nonmoving(last_moving)
return if $game_map.interpreter.running?
moved = @moved
@moved = false
if last_moving || moved
$game_party.on_player_walk
return if check_touch_event
end
if movable? && Input.trigger?(:C)
return if get_on_off_vehicle
return if check_action_event
end
@over_event -= 1 if @over_event > 0 && (last_moving || moved)
update_encounter if last_moving || moved
end
#--------------------------------------------------------------------------
# * Overwrite method: get_on_vehicle
#--------------------------------------------------------------------------
def get_on_vehicle
setup_vehicle
enter_vehicle if vehicle
@vehicle_getting_on
end
#--------------------------------------------------------------------------
# * Overwrite method: increase_steps
#--------------------------------------------------------------------------
def increase_steps
super
if normal_walk?
@steps += 1
$game_player.damage_floor = 0 unless on_damage_floor?
$game_player.damage_floor += 1
$game_party.increase_steps if @steps % 8 == 0
end
end
#--------------------------------------------------------------------------
# * Alias method: get_off_vehicle
#--------------------------------------------------------------------------
alias :get_off_vehicle_ve_pixel_movement :get_off_vehicle
def get_off_vehicle
clear_next_movement if vehicle.land_ok?(@x, @y, @direction)
get_off_vehicle_ve_pixel_movement
end
#--------------------------------------------------------------------------
# * Alias method: clear_transfer_info
#--------------------------------------------------------------------------
alias :clear_transfer_info_ve_pixel_movement :clear_transfer_info
def clear_transfer_info
clear_transfer_info_ve_pixel_movement
clear_next_movement
end
#--------------------------------------------------------------------------
# * Alias method: update
#--------------------------------------------------------------------------
alias :update_ve_gp_pixel_movement :update
def update
@followers.move unless $imported[:ve_followers_options]
update_ve_gp_pixel_movement
end
#--------------------------------------------------------------------------
# * New method: check_event_contiontion
#--------------------------------------------------------------------------
def check_event_contiontion(x, y, event, triggers, normal)
passable = passable_tile?(@x, @y, @direction)
w = (counter_tile? || !passable) ? 1.0 : bw
h = (counter_tile? || !passable) ? 1.0 : bh
return false unless event.trigger_in?(triggers)
return false unless event.event_priority?(normal)
return false unless passable || event.over_tile? || counter_tile?
return false unless event.collision?(x, y, w, h) || !jumping?
return false unless !event.in_front? || front_collision?(x, y, @direction)
return true
end
#--------------------------------------------------------------------------
# * New method: counter_tile?
#--------------------------------------------------------------------------
def counter_tile?
x = $game_map.check_x_with_direction(@x, @direction)
y = $game_map.check_y_with_direction(@y, @direction)
$game_map.counter?(x, y)
end
#--------------------------------------------------------------------------
# * New method: setup_vehicle
#--------------------------------------------------------------------------
def setup_vehicle
$game_map.vehicles.compact.each do |vehicle|
next unless vehicle.enter_vechicle?(@x, @y, @direction)
@vehicle_type = vehicle.type
break if vehicle
end
end
#--------------------------------------------------------------------------
# * New method: enter_vehicle
#--------------------------------------------------------------------------
def enter_vehicle
align_with(vehicle.x, vehicle.y) unless in_airship?
@vehicle_getting_on = true
force_move_forward unless in_airship?
@followers.gather
end
#--------------------------------------------------------------------------
# * New method: clear_next_movement
#--------------------------------------------------------------------------
def clear_next_movement
@next_movement.clear
@followers.clear_next_movement
end
#--------------------------------------------------------------------------
# * New method: step_times
#--------------------------------------------------------------------------
def step_times
(move_route_forcing || not_driving?) ? super : 1
end
#--------------------------------------------------------------------------
# * New method: not_driving?
#--------------------------------------------------------------------------
def not_driving?
vehicle && !vehicle.driving
end
#--------------------------------------------------------------------------
# * New method: move_straight
#--------------------------------------------------------------------------
def move_straight(d, turn_ok = true)
super
end
#--------------------------------------------------------------------------
# * New method: move_diagonal
#--------------------------------------------------------------------------
def move_diagonal(horz, vert)
super
end
#--------------------------------------------------------------------------
# * New method: setup_bitmap_dimension
#--------------------------------------------------------------------------
def setup_bitmap_dimension
@bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
@bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
end
end
#==============================================================================
# ** 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
#--------------------------------------------------------------------------
# * Overwrite method: chase_preceding_character
#--------------------------------------------------------------------------
def chase_preceding_character
return if $imported[:ve_followers_control] && cant_follow_character
unless moving?
if @preceding_character.next_movement.size >= 8 && !gathering?
next_move = @preceding_character.next_movement.shift
move_straight(next_move) if next_move.numeric?
move_diagonal(*next_move) if next_move.array?
elsif gathering?
@preceding_character.next_movement.clear
move_toward_player
end
end
end
#--------------------------------------------------------------------------
# * New method: move_straight
#--------------------------------------------------------------------------
def move_straight(d, turn_ok = true)
super
end
#--------------------------------------------------------------------------
# * New method: move_diagonal
#--------------------------------------------------------------------------
def move_diagonal(horz, vert)
super
end
#--------------------------------------------------------------------------
# * New method: movement_size
#--------------------------------------------------------------------------
def movement_size
return 8
end
#--------------------------------------------------------------------------
# * New method: step_times
#--------------------------------------------------------------------------
def step_times
(move_route_forcing || not_driving? || gathering?) ? super : 1
end
#--------------------------------------------------------------------------
# * New method: not_driving?
#--------------------------------------------------------------------------
def not_driving?
$game_player.not_driving?
end
#--------------------------------------------------------------------------
# * New method: setup_bitmap_dimension
#--------------------------------------------------------------------------
def setup_bitmap_dimension
@bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
@bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
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: clear_next_movement
#--------------------------------------------------------------------------
def clear_next_movement
each {|follower| follower.next_movement.clear }
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
#--------------------------------------------------------------------------
# * Overwrite method: collide_with_player_characters?
#--------------------------------------------------------------------------
def collide_with_player_characters?(x, y)
normal_priority? && player_collision?(x, y)
end
#--------------------------------------------------------------------------
# * Alias method: start
#--------------------------------------------------------------------------
alias :start_ve_pixel_movement :start
def start
start_ve_pixel_movement
$game_player.over_event = 8 if step_over? && !step_trigger?
end
#--------------------------------------------------------------------------
# * Alias method: setup_page_settings
#--------------------------------------------------------------------------
alias :setup_page_settings_ve_pixel_movement :setup_page_settings
def setup_page_settings_ve_pixel_movement
setup_page_settings_ve_anti_lag
@move_steps = note =~ /<MOVE STEPS: (\d+)>/i ? $1.to_i : nil
@step_trigger = note =~ /<EACH STEP TRIGGER>/i ? true : false
@in_front = note =~ /<FRONT COLLISION>/i ? true : false
@over_tile = note =~ /<OVER TILE>/i ? true : false
@side_fix = note =~ /<NO SIDE COLLISION FIX>/i ? false : true
end
#--------------------------------------------------------------------------
# * New method: player_collision?
#--------------------------------------------------------------------------
def player_collision?(x, y)
$game_map.actors.any? {|actor| actor.collision?(x, y, bh, bw)}
end
#--------------------------------------------------------------------------
# * New method: event_priority?
#--------------------------------------------------------------------------
def event_priority?(normal)
(normal_priority? == normal || (@through && !normal)) &&
(normal_priority? || @trigger == 0 || $game_player.over_event == 0)
end
#--------------------------------------------------------------------------
# * New method: check_event_trigger_touch
#--------------------------------------------------------------------------
def check_event_trigger_touch(x, y)
return if $game_map.interpreter.running?
if @trigger == 2 && $game_player.collision?(x, y, bh, bw)
start if !jumping? && normal_priority?
end
end
#--------------------------------------------------------------------------
# * New method: step_over?
#--------------------------------------------------------------------------
def step_over?
super || (@character_name == "" && @tile_id == 0) || @priority_type == 0
end
#--------------------------------------------------------------------------
# * New method: step_times
#--------------------------------------------------------------------------
def step_times
@move_steps ? @move_steps : super
end
#--------------------------------------------------------------------------
# * New method: step_trigger?
#--------------------------------------------------------------------------
def step_trigger?
@step_trigger
end
#--------------------------------------------------------------------------
# * New method: in_front?
#--------------------------------------------------------------------------
def in_front?
@in_front
end
#--------------------------------------------------------------------------
# * New method: over_tile?
#--------------------------------------------------------------------------
def over_tile?
@over_tile
end
#--------------------------------------------------------------------------
# * New method: side_collision?
#--------------------------------------------------------------------------
def side_collision?
@side_fix
end
#--------------------------------------------------------------------------
# * New method: setup_bitmap_dimension
#--------------------------------------------------------------------------
def setup_bitmap_dimension
regexp = /<EVENT SIZE: (\d+), (\d+)>/i
note =~ regexp ? setup_custom_dimension($1.to_i, $2.to_i) : super
end
#--------------------------------------------------------------------------
# * New method: setup_custom_dimension
#--------------------------------------------------------------------------
def setup_custom_dimension(x, y)
x1 = (x / 8).to_i
y1 = (y / 8).to_i
@bw = x1 / 4.0
@bh = y1 / 4.0
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
#--------------------------------------------------------------------------
# * Overwrite method: land_ok?
#--------------------------------------------------------------------------
def land_ok?(x, y, d)
@type == :airship ? airship_landable?(x, y) : check_landable?(x, y, d)
end
#--------------------------------------------------------------------------
# * New method: land_test
#--------------------------------------------------------------------------
def land_test
@land_test
end
#--------------------------------------------------------------------------
# * New method: step_over?
#--------------------------------------------------------------------------
def step_over?
above? || super
end
#--------------------------------------------------------------------------
# * New method: check_landable?
#--------------------------------------------------------------------------
def check_landable?(x, y, d)
x2 = $game_map.check_x_with_direction(x, d)
y2 = $game_map.check_y_with_direction(y, d)
@land_test = true
result = passable?(x2, y2, d)
@land_test = false
result
end
#--------------------------------------------------------------------------
# * New method: airship_landable?
#--------------------------------------------------------------------------
def airship_landable?(x, y)
[2, 4, 6, 8].any? {|d| passable?(x, y, d) }
end
#--------------------------------------------------------------------------
# * New method: passable_normal?
#--------------------------------------------------------------------------
def passable_normal?(x, y, d ,d2, ceil = false)
@land_test ? landable_normal?(x, y, d ,d2, ceil) : super(x, y, d ,d2, ceil)
end
#--------------------------------------------------------------------------
# * New method: landable_normal?
#--------------------------------------------------------------------------
def landable_normal?(x, y, d ,d2, ceil)
x1 = $game_map.round_x(x)
y1 = $game_map.round_y(y)
return false unless $game_map.valid?(x1, y1)
return true if @through || debug_through?
return false unless map_passable?(x1, y1, d)
return false unless map_passable?(x1, y1, d2) || !ceil
return false unless map_passable?(x1, y1, reverse_dir(d))
return true
end
#--------------------------------------------------------------------------
# * New method: enter_vechicle?
#--------------------------------------------------------------------------
def enter_vechicle?(x, y, d)
return false if @map_id != $game_map.map_id
x2 = $game_map.round_x_with_direction(x, d)
y2 = $game_map.round_y_with_direction(y, d)
x3 = $game_map.check_x_with_direction(@x, reverse_dir(d))
y3 = $game_map.check_y_with_direction(@y, reverse_dir(d))
( above? && collision?(x, y - 0.125, bw * 0.75, bh * 0.75)) ||
(!above? && collision?(x2, y2, bw, bh) && map_passable?(x3, y3, d))
end
#--------------------------------------------------------------------------
# * New method: vehicle_collision?
#--------------------------------------------------------------------------
def vehicle_collision?(x, y, bw, bh, player)
return false if step_over?
return false if player.player? && self == player.vehicle
return false if !collision?(x, y, bw, bh)
return true
end
end[/code]- #==============================================================================
- # ** Victor Engine - Pixel Movement
- #------------------------------------------------------------------------------
- # Author : Victor Sant
- #
- # Version History:
- # v 1.00 - 2012.05.29 > First relase
- # v 1.01 - 2012.05.29 > Compatibility with Terrain States
- # v 1.02 - 2012.07.03 > Compatibility with Basic Module 1.23
- # v 1.03 - 2012.07.05 > Added 'over event' tag for objects over blocked tiles
- # > Added Steps settings for events
- # v 1.04 - 2012.07.24 > Compatibility with Moving Platform
- # > Added <each step trigger> tag for events
- # v 1.05 - 2012.07.30 > Fixed issue when characters moves toward the same spot
- # v 1.06 - 2012.08.03 > Compatibility with Anti Lag
- # v 1.07 - 2012.08.03 > Fixed collision with tile graphics events
- #------------------------------------------------------------------------------
- # This script allows to replace the tile based movement where the player
- # walks a whole 32 pixel tile each step with one that he walks only 4 pixels.
- # It also give a better collision system for events.
- #------------------------------------------------------------------------------
- # Compatibility
- # Requires the script 'Victor Engine - Basic Module' v 1.25 or higher
- # If used with 'Victor Engine - Animated Battle' place this bellow it.
- # If used with 'Victor Engine - Follower Control' place this bellow it.
- # If used with 'Victor Engine - Follower Options' place this bellow it.
- #
- # * Overwrite methods
- # class Game_Actor < Game_Battler
- # def turn_end_on_map
- #
- # class Game_Map
- # def layered_tiles(x, y)
- # def events_xy(x, y)
- # def events_xy_nt(x, y)
- # def x_with_direction(x, d, times = 1)
- # def y_with_direction(y, d, times = 1)
- # def round_x_with_direction(x, d)
- # def round_y_with_direction
- #
- # class Game_CharacterBase
- # def region_id
- # def move_straight(d, turn_ok = true)
- # def move_diagonal(horz, vert)
- # def collide_with_events?(x, y)
- # def collide_with_vehicles?(x, y)
- #
- # class Game_Player < Game_Character
- # def check_event_trigger_there(triggers)
- # def start_map_event(x, y, triggers, normal)
- # def update_nonmoving(last_moving)
- # def get_on_vehicle
- # def increase_steps
- #
- # class Game_Follower < Game_Character
- # def chase_preceding_character
- #
- # class Game_Event < Game_Character
- # def collide_with_player_characters?(x, y)
- #
- # class Game_Vehicle < Game_Character
- # def land_ok?(x, y, d)
- #
- # * Alias methods
- # class Game_Actor < Game_Battler
- # def check_floor_effect
- #
- # class Game_CharacterBase
- # def init_public_members
- # def update
- #
- # class Game_Character < Game_CharacterBase
- # def move_toward_character(character)
- # def move_toward_position(x, y)
- #
- # class Game_Event < Game_Character
- # def start
- #
- # class Game_Player < Game_Character
- # def get_off_vehicle
- # def clear_transfer_info
- # def update
- #
- # class Game_Event < Game_Character
- # def start
- #
- #------------------------------------------------------------------------------
- # 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 script 'Victor Engine - Basic'
- #
- #------------------------------------------------------------------------------
- # Event Comment boxes note tags:
- # Tags to be used on events Comment boxes.
- #
- # <move steps: x>
- # Setup the number of steps each "Move" command will execute. The default
- # value is 8 (1 tile)
- # x : number of steps
- #
- # <event size: x, y>
- # Collision area size, in pixels for event collisions.
- # x : collision area width
- # y : collision area height
- #
- # <front collision>
- # Events with this tag won't start if the the collision between events and
- # the player occur between their edges.
- #
- # <no side collision fix>
- # Events with this tag won't have the "slide" effect when the edges of the
- # events collide with the player
- #
- # <over tile>
- # Events with this tag will start even when placed over blocked tiles.
- # By default, if the passage is blocked the event don't stat.
- #
- # <each step trigger>
- # By default, events with through or bellow character priority triggers
- # only one time for each 8 steps above them. With this tag though, the
- # event will trigger every step.
- #
- #------------------------------------------------------------------------------
- # Additional instructions:
- #
- # All events and tiles have a "slide" effect when the player faces the edge
- # of a tile or event. I added this function since it would be a pain to
- # be in the exact position to go throug a narrow path.
- # This can be disabled for events, but not for tiles.
- #
- #==============================================================================
- #==============================================================================
- # ** Victor Engine
- #------------------------------------------------------------------------------
- # Setting module for the Victor Engine
- #==============================================================================
- module Victor_Engine
- #--------------------------------------------------------------------------
- # * Player collision area
- # Different from events, player collision don't rely on the graphic size
- # Player collision area can be of 2 types:
- # - 32 x 32 box if VE_PLAYER_BIG_COLLISION = true
- # - 24 x 24 box if VE_PLAYER_BIG_COLLISION = false
- #--------------------------------------------------------------------------
- VE_PLAYER_BIG_COLLISION = true
- #--------------------------------------------------------------------------
- # * 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
- #--------------------------------------------------------------------------
- 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_pixel_movement] = 1.07
- Victor_Engine.required(:ve_pixel_movement, :ve_basic_module, 1.25, :above)
- Victor_Engine.required(:ve_pixel_movement, :ve_map_battle, 1.00, :bellow)
- Victor_Engine.required(:ve_pixel_movement, :ve_diagonal_move, 1.00, :bellow)
- #==============================================================================
- # ** Game_Actor
- #------------------------------------------------------------------------------
- # This class handles actors. It's used within the Game_Actors class
- # ($game_actors) and referenced by the Game_Party class ($game_party).
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # * Overwrite method: turn_end_on_map
- #--------------------------------------------------------------------------
- def turn_end_on_map
- if $game_player.steps % (steps_for_turn * 8) == 0
- on_turn_end
- perform_map_damage_effect if @result.hp_damage > 0
- end
- end
- #--------------------------------------------------------------------------
- # * Alias method: init_public_members
- #--------------------------------------------------------------------------
- alias :check_floor_effect_ve_pixel_movement :check_floor_effect
- def check_floor_effect
- return if check_damage_floor
- check_floor_effect_ve_pixel_movement
- end
- #--------------------------------------------------------------------------
- # * New method: check_damage_floor
- #--------------------------------------------------------------------------
- def check_damage_floor
- $game_player.damage_floor % 8 != 0
- 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
- #--------------------------------------------------------------------------
- # * Overwrite method: layered_tiles
- #--------------------------------------------------------------------------
- def layered_tiles(x, y)
- x2 = (x - 0.5).ceil
- y2 = (y - 0.125).ceil
- [2, 1, 0].collect {|z| tile_id(x2, y2, z) }
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: events_xy
- #--------------------------------------------------------------------------
- def events_xy(x, y)
- event_list.select {|event| event.near?(x, y) }
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: events_xy_nt
- #--------------------------------------------------------------------------
- def events_xy_nt(x, y)
- event_list.select {|event| event.near_nt?(x, y) }
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: x_with_direction
- #--------------------------------------------------------------------------
- def x_with_direction(x, d, times = 1)
- x + (d == 6 ? times * 0.125 : d == 4 ? -times * 0.125 : 0)
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: y_with_direction
- #--------------------------------------------------------------------------
- def y_with_direction(y, d, times = 1)
- y + (d == 2 ? times * 0.125 : d == 8 ? -times * 0.125 : 0)
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: round_x_with_direction
- #--------------------------------------------------------------------------
- def round_x_with_direction(x, d)
- round_x(x + (d == 6 ? 0.125 : d == 4 ? -0.125 : 0))
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: round_y_with_direction
- #--------------------------------------------------------------------------
- def round_y_with_direction(y, d)
- round_y(y + (d == 2 ? 0.125 : d == 8 ? -0.125 : 0))
- end
- #--------------------------------------------------------------------------
- # * New method: check_x_with_direction
- #--------------------------------------------------------------------------
- def check_x_with_direction(x, d)
- round_x(x + (d == 6 ? 1 : d == 4 ? -1 : 0))
- end
- #--------------------------------------------------------------------------
- # * New method: check_y_with_direction
- #--------------------------------------------------------------------------
- def check_y_with_direction(y, d)
- round_y(y + (d == 2 ? 1 : d == 8 ? -1 : 0))
- 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 :next_movement
- attr_accessor :side_collision
- attr_accessor :damage_floor
- attr_accessor :steps
- #--------------------------------------------------------------------------
- # * Overwrite method: region_id
- #--------------------------------------------------------------------------
- def region_id
- $game_map.region_id((@x - 0.5).ceil, (@y - 0.125).ceil)
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: collide_with_events?
- #--------------------------------------------------------------------------
- def collide_with_events?(x, y)
- $game_map.events_xy_nt(x, y).any? do |event|
- event.collision_condition?(x, y, bw, bh, event?, @id, @side_collision)
- end
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: collide_with_vehicles?
- #--------------------------------------------------------------------------
- def collide_with_vehicles?(x, y)
- $game_map.vehicles.compact.any? do |vehicle|
- next if vehicle.map_id != $game_map.map_id
- vehicle.vehicle_collision?(x, y, bw, bh, self)
- end
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: move_straight
- #--------------------------------------------------------------------------
- def move_straight(d, turn_ok = true)
- @move_list += [{d: [d], turn: turn_ok}] * step_times
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: move_straight
- #--------------------------------------------------------------------------
- def move_diagonal(horz, vert)
- @move_list += [{d: [horz, vert], turn: true}] * step_times
- end
- #--------------------------------------------------------------------------
- # * Alias method: init_public_members
- #--------------------------------------------------------------------------
- alias :init_public_members_ve_pixel_movement :init_public_members
- def init_public_members
- init_public_members_ve_pixel_movement
- @move_list = []
- @next_movement = []
- @over_event = 0
- @damage_floor = 0
- @steps = 0
- end
- #--------------------------------------------------------------------------
- # * Alias method: update
- #--------------------------------------------------------------------------
- alias :update_ve_pixel_movement :update
- def update
- update_move_straight
- update_move_diagonal
- update_ve_pixel_movement
- end
- #--------------------------------------------------------------------------
- # * New method: update_move_straight
- #--------------------------------------------------------------------------
- def update_move_straight
- return if moving? || @move_list.empty?
- return if @move_list.first[:d].size > 1
- move = @move_list.shift
- d = move[:d].first
- if passable?(@x, @y, d)
- @diagonal_move = false
- setup_movement(d, d)
- @real_x = $game_map.x_with_direction(@x, reverse_dir(d))
- @real_y = $game_map.y_with_direction(@y, reverse_dir(d))
- @moved = player?
- elsif move[:turn]
- check_event_trigger_move(d)
- end
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: update_move_diagonal
- #--------------------------------------------------------------------------
- def update_move_diagonal
- return if moving? || @move_list.empty?
- return if @move_list.first[:d].size < 2
- move = @move_list.shift
- horz = move[:d].first
- vert = move[:d].last
- if diagonal_passable?(x, y, horz, vert)
- @diagonal_move = true
- setup_movement(horz, vert)
- @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
- @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
- @moved = player?
- end
- end
- #--------------------------------------------------------------------------
- # * New method: character_collision?
- #--------------------------------------------------------------------------
- def character_collision?(x, y, d)
- x2 = $game_map.round_x_with_direction(x, d)
- y2 = $game_map.round_y_with_direction(y, d)
- !collide_with_characters?(x2, y2) || @through || debug_through?
- end
- #--------------------------------------------------------------------------
- # * New method: step_times
- #--------------------------------------------------------------------------
- def step_times
- return 8
- end
- #--------------------------------------------------------------------------
- # * New method: near_nt?
- #--------------------------------------------------------------------------
- def near_nt?(x, y)
- near?(x, y) && !@through
- end
- #--------------------------------------------------------------------------
- # * New method: near?
- #--------------------------------------------------------------------------
- def near?(x, y)
- w = step_over? ? [bw * 0.625, 0.5].max : [bw, 1.0].max
- h = step_over? ? [bh * 0.625, 0.5].max : [bh, 1.0].max
- @real_x > x - w && @real_x < x + w && @real_y > y - h && @real_y < y + h
- end
- #--------------------------------------------------------------------------
- # * New method: setup_movement
- #--------------------------------------------------------------------------
- def setup_movement(horz, vert)
- @x = $game_map.round_x_with_direction(@x, horz)
- @y = $game_map.round_y_with_direction(@y, vert)
- add_next_movement(horz == vert ? horz : [horz, vert])
- set_direction(horz) if @direction == reverse_dir(horz) || horz == vert
- set_direction(vert) if @direction == reverse_dir(vert) && horz != vert
- follower_control_move_update(horz, vert)
- increase_steps
- end
- #--------------------------------------------------------------------------
- # * New method: check_event_trigger_move
- #--------------------------------------------------------------------------
- def check_event_trigger_move(d)
- set_direction(d)
- check_event_trigger_touch_front
- end
- #--------------------------------------------------------------------------
- # * New method: collision_condition?
- #--------------------------------------------------------------------------
- def collision_condition?(x, y, bw, bh, event, event_id, side)
- return false if event && self.id == event_id
- return false unless collision?(x, y, bw, bh)
- return false unless normal_priority? || event
- return false if side && !side_collision?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: follower_control_move_update
- #--------------------------------------------------------------------------
- def follower_control_move_update(horz, vert)
- return unless $imported[:ve_followers_options]
- return unless player? || follower?
- add_move_update(horz == vert ? [horz] : [horz, vert])
- end
- #--------------------------------------------------------------------------
- # * New method: passable?
- #--------------------------------------------------------------------------
- def passable?(x, y, d)
- x = fix_position(x)
- y = fix_position(y)
- passable1 = passable_tile?(x, y, d)
- passable2 = character_collision?(x, y, d)
- fix_movement(x, y, d) if player? && !passable1 && passable2
- fix_collision(x, y, d) if player? && !passable2 && passable1
- passable1 && passable2
- end
- #--------------------------------------------------------------------------
- # * New method: passable_tile?
- #--------------------------------------------------------------------------
- def passable_tile?(x, y, d)
- result = true
- result = passable_down?(x, y) if d == 2
- result = passable_left?(x, y) if d == 4
- result = passable_right?(x, y) if d == 6
- result = passable_up?(x, y) if d == 8
- result
- end
- #--------------------------------------------------------------------------
- # * New method: locked_tile?
- #--------------------------------------------------------------------------
- def locked_tile?(x, y, d = 0)
- list = [2, 4, 6, 8] - [d]
- list.all? {|d| !map_passable?(x, y, d) }
- end
- #--------------------------------------------------------------------------
- # * New method: locked_move?
- #--------------------------------------------------------------------------
- def locked_move?(x, y)
- !passable_down?(x, y) && !passable_left?(x, y)
- !passable_right?(x, y) && !passable_up?(x, y)
- end
- #--------------------------------------------------------------------------
- # * New method: passable_down?
- #--------------------------------------------------------------------------
- def passable_down?(x, y)
- passable_normal?(x.ceil, y.to_i, 2, 4, x.ceil?) &&
- passable_normal?(x.to_i, y.to_i, 2, 6, x.ceil?)
- end
- #--------------------------------------------------------------------------
- # * New method: passable_left?
- #--------------------------------------------------------------------------
- def passable_left?(x, y)
- passable_normal?(x.ceil, y.ceil, 4, 8, y.ceil?) &&
- passable_normal?(x.ceil, y.to_i, 4, 2, y.ceil?)
- end
- #--------------------------------------------------------------------------
- # * New method: passable_right?
- #--------------------------------------------------------------------------
- def passable_right?(x, y)
- passable_normal?(x.to_i, y.ceil, 6, 8, y.ceil?) &&
- passable_normal?(x.to_i, y.to_i, 6, 2, y.ceil?)
- end
- #--------------------------------------------------------------------------
- # * New method: passable_up?
- #--------------------------------------------------------------------------
- def passable_up?(x, y)
- passable_normal?(x.ceil, y.ceil, 8, 4, x.ceil?) &&
- passable_normal?(x.to_i, y.ceil, 8, 6, x.ceil?)
- end
- #--------------------------------------------------------------------------
- # * New method: passable_normal?
- #--------------------------------------------------------------------------
- def passable_normal?(x, y, d, d2, ceil = false)
- x1 = $game_map.round_x(x)
- y1 = $game_map.round_y(y)
- x2 = $game_map.check_x_with_direction(x1, d)
- y2 = $game_map.check_y_with_direction(y1, d)
- x3 = $game_map.round_x_with_direction(x1, d)
- y3 = $game_map.round_y_with_direction(y1, d)
- return false unless $game_map.valid?(x3, y3)
- return true if @through || debug_through?
- return false unless map_passable?(x2, y2, d2) || !ceil
- return false unless move_passable1?(x1, y1, x2, y2, d)
- return false unless move_passable2?(x1, y1, x2, y2, d)
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: move_passable1?
- #--------------------------------------------------------------------------
- def move_passable1?(x1, y1, x2, y2, d)
- map_passable?(x1, y1, d) || map_passable?(x2, y2, d)
- end
- #--------------------------------------------------------------------------
- # * New method: move_passable?
- #--------------------------------------------------------------------------
- def move_passable2?(x1, y1, x2, y2, d)
- map_passable?(x2, y2, reverse_dir(d)) && (map_passable?(x1, y1, d) ||
- locked_tile?(x1, y1))
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement
- #--------------------------------------------------------------------------
- def fix_movement(x, y, d)
- return if (@diagonal && @diagonal != 0) || @diagonal_move
- fix_movement_horiz(x, y, d) if (d == 2 || d == 8) && x.ceil?
- fix_movement_vert(x, y, d) if (d == 4 || d == 6) && y.ceil?
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_horiz
- #--------------------------------------------------------------------------
- def fix_movement_horiz(x, y, d)
- adjust = x - x.to_i
- fix_move_straight(4) if fix_movement_left?(x, y, d) && adjust < 0.5
- fix_move_straight(6) if fix_movement_right?(x, y, d) && adjust > 0.5
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_ver
- #--------------------------------------------------------------------------
- def fix_movement_vert(x, y, d)
- adjust = y - y.to_i
- fix_move_straight(2) if fix_movement_down?(x, y, d) && adjust > 0.5
- fix_move_straight(8) if fix_movement_up?(x, y, d) && adjust < 0.5
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_down?
- #--------------------------------------------------------------------------
- def fix_movement_down?(x, y, d)
- passable_normal?(x.to_i, y.ceil, d, 0, false) && movement_fix?(x, y, 2)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_left?
- #--------------------------------------------------------------------------
- def fix_movement_left?(x, y, d)
- passable_normal?(x.to_i, y.to_i, d, 0, false) && movement_fix?(x, y, 4)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_right?
- #--------------------------------------------------------------------------
- def fix_movement_right?(x, y, d)
- passable_normal?(x.ceil, y.to_i, d, 0, false) && movement_fix?(x, y, 6)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_movement_up?
- #--------------------------------------------------------------------------
- def fix_movement_up?(x, y, d)
- passable_normal?(x.to_i, y.to_i, d, 0, false) && movement_fix?(x, y, 8)
- end
- #--------------------------------------------------------------------------
- # * New method: movement_fix?
- #--------------------------------------------------------------------------
- def movement_fix?(x, y, d)
- passable_tile?(x, y, d) && character_collision?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision
- #--------------------------------------------------------------------------
- def fix_collision(x, y, d)
- return if (@diagonal && @diagonal != 0) || @diagonal_move
- @side_collision = true
- fix_collision_horiz(x, y, d) if (d == 2 || d == 8)
- fix_collision_vert(x, y, d) if (d == 4 || d == 6)
- @side_collision = false
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_horiz
- #--------------------------------------------------------------------------
- def fix_collision_horiz(x, y, d)
- fix_move_straight(4) if fix_collision_left?(x, y, d)
- fix_move_straight(6) if fix_collision_right?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_vert
- #--------------------------------------------------------------------------
- def fix_collision_vert(x, y, d)
- fix_move_straight(2) if fix_collision_down?(x, y, d)
- fix_move_straight(8) if fix_collision_up?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_down?
- #--------------------------------------------------------------------------
- def fix_collision_down?(x, y, d)
- !character_collision?(x, y, d) && collision_fix?(x, y, d, 2)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_left?
- #--------------------------------------------------------------------------
- def fix_collision_left?(x, y, d)
- !character_collision?(x, y, d) && collision_fix?(x, y, d, 4)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_right?
- #--------------------------------------------------------------------------
- def fix_collision_right?(x, y, d)
- !character_collision?(x, y, d) && collision_fix?(x, y, d, 6)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_collision_up?
- #--------------------------------------------------------------------------
- def fix_collision_up?(x, y, d)
- !character_collision?(x, y, d) && collision_fix?(x, y, d, 8)
- end
- #--------------------------------------------------------------------------
- # * New method: collision_fix?
- #--------------------------------------------------------------------------
- def collision_fix?(x, y, d, d2)
- side_collision_fix?(x, y, d, d2, 2) && side_fix?(x, y, d2)
- end
- #--------------------------------------------------------------------------
- # * New method: side_collision_fix?
- #--------------------------------------------------------------------------
- def side_collision_fix?(x, y, d, d2, t)
- t.times.any? do |i|
- x2, y2 = x, y
- y2 += (t - i) * 0.125 if d2 == 2
- x2 -= (t - i) * 0.125 if d2 == 4
- x2 += (t - i) * 0.125 if d2 == 6
- y2 -= (t - i) * 0.125 if d2 == 8
- character_collision?(x2, y2, d)
- end
- end
- #--------------------------------------------------------------------------
- # * New method: side_fix?
- #--------------------------------------------------------------------------
- def side_fix?(x, y, d)
- passable_tile?(x, y, d) && character_collision?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * New method: fix_move_straight
- #--------------------------------------------------------------------------
- def fix_move_straight(d)
- return if moving?
- @x = $game_map.round_x_with_direction(@x, d)
- @y = $game_map.round_y_with_direction(@y, d)
- follower_control_move_update(d, d)
- add_next_movement(d)
- increase_steps
- @moved = player?
- end
- #--------------------------------------------------------------------------
- # * New method: add_next_movement
- #--------------------------------------------------------------------------
- def add_next_movement(d)
- return unless follower? || player?
- return if $imported[:ve_followers_control] && follower_control_block
- return if $game_player.followers.gathering?
- @next_movement.push(d)
- end
- #--------------------------------------------------------------------------
- # * New method: follower_control_block
- #--------------------------------------------------------------------------
- def follower_control_block
- return true if follower? && origin_position
- return true if $game_player.followers.gathering_origin?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: front_collision?
- #--------------------------------------------------------------------------
- def front_collision?(x, y, d)
- return false if (@diagonal && @diagonal != 0) || @diagonal_move
- result = !front_collision_horiz(x, y, d) if (d == 2 || d == 8)
- result = !front_collision_vert(x, y, d) if (d == 4 || d == 6)
- result
- end
- #--------------------------------------------------------------------------
- # * New method: front_collision_horiz
- #--------------------------------------------------------------------------
- def front_collision_horiz(x, y, d)
- side_collision_fix?(x, y, d, 4, 4) || side_collision_fix?(x, y, d, 6, 4)
- end
- #--------------------------------------------------------------------------
- # * New method: front_collision_vert
- #--------------------------------------------------------------------------
- def front_collision_vert(x, y, d)
- side_collision_fix?(x, y, d, 2, 4) || side_collision_fix?(x, y, d, 8, 4)
- end
- #--------------------------------------------------------------------------
- # * New method: step_over?
- #--------------------------------------------------------------------------
- def step_over?
- @through
- end
- #--------------------------------------------------------------------------
- # * New method: bw
- #--------------------------------------------------------------------------
- def bw
- setup_bitmap_dimension unless @bw && character_name == @character_name_wh
- @bw
- end
- #--------------------------------------------------------------------------
- # * New method: bh
- #--------------------------------------------------------------------------
- def bh
- setup_bitmap_dimension unless @bh && character_name == @character_name_wh
- @bh
- end
- #--------------------------------------------------------------------------
- # * New method: setup_bitmap_dimension
- #--------------------------------------------------------------------------
- def setup_bitmap_dimension
- @character_name_wh = character_name
- bitmap = Cache.character(character_name).clone
- sign = @character_name[/^[\!\$]./]
- if character_name != "" && @tile_id == 0 && sign && sign.include?('[code]#==============================================================================
- # ** Victor Engine - Basic Module
- #------------------------------------------------------------------------------
- # Author : Victor Sant
- #
- # Version History:
- # v 1.00 - 2011.12.19 > First relase
- # v 1.01 - 2011.12.21 > Added Event Troop notes
- # v 1.02 - 2011.12.22 > Added character frames value
- # v 1.03 - 2011.12.30 > Added Actor and Enemy notes
- # v 1.04 - 2012.01.01 > Added party average level and map actors
- # v 1.05 - 2012.01.04 > Compatibility with Characters Scripts
- # v 1.06 - 2012.01.07 > Compatibility with Fog and Light Effect
- # > Added new Sprite Character functions
- # v 1.07 - 2012.01.11 > Compatibility with Control Text and Codes
- # v 1.08 - 2012.01.13 > Compatibility with Trait Control
- # v 1.09 - 2012.01.15 > Fixed the Regular Expressions problem with "" and “”
- # v 1.10 - 2012.01.18 > Compatibility with Automatic Battlers
- # v 1.11 - 2012.01.26 > Compatibility with Followers Options
- # Compatibility with Animated Battle beta
- # v 1.12 - 2012.02.08 > Compatibility with Animated Battle
- # v 1.13 - 2012.02.18 > Fix for non RTP dependant encrypted projects
- # v 1.14 - 2012.03.11 > Better version handling and required messages
- # v 1.15 - 2012.03.11 > Added level variable for enemies (to avoid crashes)
- # v 1.16 - 2012.03.21 > Compatibility with Follower Control
- # v 1.17 - 2012.03.22 > Compatibility with Follower Control new method
- # v 1.18 - 2012.03.22 > Added Battler Types tag support
- # v 1.19 - 2012.05.20 > Compatibility with Map Turn Battle
- # v 1.20 - 2012.05.21 > Fix for older RMVXa versions
- # v 1.21 - 2012.05.29 > Compatibility with Pixel Movement
- # v 1.22 - 2012.07.02 > Compatibility with Terrain States
- # v 1.23 - 2012.07.03 > Fix for Pixel Movement
- # v 1.24 - 2012.07.17 > Compatibility with Critical Hit Effects
- # v 1.25 - 2012.07.24 > Compatibility with Moving Plaforms
- # v 1.26 - 2012.07.30 > Compatibility with Automatic Battlers
- # v 1.27 - 2012.08.01 > Compatibility with Custom Slip Effect
- # v 1.28 - 2012.08.03 > Compatibility with Custom Slip Effect v 1.01
- #------------------------------------------------------------------------------
- # This is the basic script for the system from Victory Engine and is
- # required to use the scripts from the engine. This script offer some new
- # functions to be used within many scripts of the engine.
- #------------------------------------------------------------------------------
- # Compatibility
- # Required for the Victor Engine
- #
- # * Overwrite methods
- # class << Cache
- # def self.character(filename)
- #
- # class Sprite_Character < Sprite_Base
- # def set_character_bitmap
- #
- # * 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
- #------------------------------------------------------------------------------
- # Setting module for the Victor Engine
- #==============================================================================
- module Victor_Engine
- #--------------------------------------------------------------------------
- # * New method: required_script
- #--------------------------------------------------------------------------
- def self.required_script(name, req, version, type = 0)
- if type != :bellow && (!$imported[req] || $imported[req] < version)
- msg = "The script '%s' requires the script\n"
- case type
- when :above
- msg += "'%s' v%s or higher above it to work properly\n"
- else
- msg += "'%s' v%s or higher to work properly\n"
- end
- msg += "Go to http://victorscripts.wordpress.com/ to download this script."
- self.exit_message(msg, name, req, version)
- elsif type == :bellow && $imported[req]
- msg = "The script '%s' requires the script\n"
- msg += "'%s' to be put bellow it\n"
- msg += "move the scripts to the proper position"
- self.exit_message(msg, name, req, version)
- end
- end
- #--------------------------------------------------------------------------
- # * New method: exit_message
- #--------------------------------------------------------------------------
- def self.exit_message(message, name, req, version)
- name = self.script_name(name)
- req = self.script_name(req)
- msgbox(sprintf(message, name, req, version))
- exit
- end
- #--------------------------------------------------------------------------
- # * New method: script_name
- #--------------------------------------------------------------------------
- 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_basic_module] = 1.28
- #==============================================================================
- # ** Object
- #------------------------------------------------------------------------------
- # This class is the superclass of all other classes.
- #==============================================================================
- class Object
- #--------------------------------------------------------------------------
- # * Include setting module
- #--------------------------------------------------------------------------
- include Victor_Engine
- #-------------------------------------------------------------------------
- # * New method: rand_between
- #-------------------------------------------------------------------------
- def rand_between(min, max)
- min + rand(max - min + 1)
- end
- #--------------------------------------------------------------------------
- # * New method: numeric?
- #--------------------------------------------------------------------------
- def numeric?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: string?
- #--------------------------------------------------------------------------
- def string?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: array?
- #--------------------------------------------------------------------------
- def array?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: float?
- #--------------------------------------------------------------------------
- def float?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: item?
- #--------------------------------------------------------------------------
- def item?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: skill?
- #--------------------------------------------------------------------------
- def skill?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: file_exist?
- #--------------------------------------------------------------------------
- def file_exist?(path, filename)
- $file_list ||= {}
- $file_list[path + filename] ||= file_test(path, filename)
- $file_list[path + filename]
- end
- #--------------------------------------------------------------------------
- # * New method: get_file_list
- #--------------------------------------------------------------------------
- def file_test(path, filename)
- bitmap = Cache.load_bitmap(path, filename) rescue nil
- bitmap ? true : false
- end
- #--------------------------------------------------------------------------
- # * New method: character_exist?
- #--------------------------------------------------------------------------
- def character_exist?(filename)
- file_exist?("Graphics/Characters/", filename)
- end
- #--------------------------------------------------------------------------
- # * New method: battler_exist?
- #--------------------------------------------------------------------------
- def battler_exist?(filename)
- file_exist?("Graphics/Battlers/", filename)
- end
- #--------------------------------------------------------------------------
- # * New method: get_filename
- #--------------------------------------------------------------------------
- def get_filename
- "[\"'“‘]([^\"'”‘”’]+)[\"'”’]"
- end
- #--------------------------------------------------------------------------
- # * New method: get_all_values
- #--------------------------------------------------------------------------
- def get_all_values(value1, value2 = nil)
- value2 = value1 unless value2
- /<#{value1}>((?:[^<]|<[^\/])*)<\/#{value2}>/im
- end
- #--------------------------------------------------------------------------
- # * New method: make_symbol
- #--------------------------------------------------------------------------
- def make_symbol(string)
- string.downcase.gsub(" ", "_").to_sym
- end
- #--------------------------------------------------------------------------
- # * New method: make_string
- #--------------------------------------------------------------------------
- def make_string(symbol)
- symbol.to_s.gsub("_", " ").upcase
- end
- #--------------------------------------------------------------------------
- # * New method: returing_value
- #--------------------------------------------------------------------------
- def returing_value(i, x)
- i % (x * 2) >= x ? (x * 2) - i % (x * 2) : i % (x * 2)
- end
- #--------------------------------------------------------------------------
- # New method: in_rect?
- #--------------------------------------------------------------------------
- def in_rect?(w, h, x1, y1, x2, y2, fx = 0)
- aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
- bx > ax - aw && bx < ax + aw && by > ay - ah && by < ay + ah
- end
- #--------------------------------------------------------------------------
- # New method: in_radius?
- #--------------------------------------------------------------------------
- def in_radius?(w, h, x1, y1, x2, y2, fx = 0)
- aw, ah, ax, ay, bx, by = setup_area(w, h, x1, y1, x2, y2, fx)
- ((bx - ax) ** 2 / aw ** 2) + ((by - ay) ** 2 / ah ** 2) <= 1
- end
- #--------------------------------------------------------------------------
- # New method: setup_area
- #--------------------------------------------------------------------------
- def setup_area(w, h, x1, y1, x2, y2, fx)
- aw = w
- ah = h * aw
- ax = x1
- ay = y1
- bx = x2
- by = y2
- bx += fx / 4 if ax > bx
- bx -= fx / 4 if ax < bx
- [aw, ah, ax, ay, bx, by]
- end
- end
- #==============================================================================
- # ** String
- #------------------------------------------------------------------------------
- # The string class. Can handle character sequences of arbitrary lengths.
- #==============================================================================
- class String
- #--------------------------------------------------------------------------
- # * New method: string?
- #--------------------------------------------------------------------------
- def string?
- return true
- end
- end
- #==============================================================================
- # ** Numeric
- #------------------------------------------------------------------------------
- # This is the abstract class for numbers.
- #==============================================================================
- class Numeric
- #--------------------------------------------------------------------------
- # * New method: numeric?
- #--------------------------------------------------------------------------
- def numeric?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: ceil?
- #--------------------------------------------------------------------------
- def ceil?
- return false
- 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
- self.inject(0) {|r, n| r += (n.numeric? ? n : 0)}
- end
- #---------------------------------------------------------------------------
- # * New method: average
- #---------------------------------------------------------------------------
- def average(float = false)
- self.sum / [(float ? size.to_f : size.to_i), 1].max
- end
- #---------------------------------------------------------------------------
- # * New method: next_item
- #---------------------------------------------------------------------------
- def next_item
- item = self.shift
- self.push(item)
- item
- end
- #---------------------------------------------------------------------------
- # * New method: previous_item
- #---------------------------------------------------------------------------
- def previous_item
- item = self.pop
- self.unshift(item)
- item
- end
- end
- #==============================================================================
- # ** RPG::Troop::Page
- #------------------------------------------------------------------------------
- # This is the data class for battle events (pages).
- #==============================================================================
- class RPG::Troop::Page
- #--------------------------------------------------------------------------
- # * New method: note
- #--------------------------------------------------------------------------
- def note
- return "" if !@list || @list.size <= 0
- comment_list = []
- @list.each do |item|
- next unless item && (item.code == 108 || item.code == 408)
- comment_list.push(item.parameters[0])
- end
- comment_list.join("\r\n")
- end
- end
- #==============================================================================
- # ** RPG::UsableItem
- #------------------------------------------------------------------------------
- # This is the superclass for skills and items.
- #==============================================================================
- class RPG::UsableItem < RPG::BaseItem
- #--------------------------------------------------------------------------
- # * New method: for_all_targets?
- #--------------------------------------------------------------------------
- def for_all_targets?
- return false
- end
- end
- #==============================================================================
- # ** RPG::Skill
- #------------------------------------------------------------------------------
- # This is the data class for skills.
- #==============================================================================
- class RPG::Skill < RPG::UsableItem
- #--------------------------------------------------------------------------
- # * New method: item?
- #--------------------------------------------------------------------------
- def item?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: skill?
- #--------------------------------------------------------------------------
- def skill?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: type_set
- #--------------------------------------------------------------------------
- def type_set
- [stype_id]
- end
- end
- #==============================================================================
- # ** RPG::Item
- #------------------------------------------------------------------------------
- # This is the data class for items.
- #==============================================================================
- class RPG::Item < RPG::UsableItem
- #--------------------------------------------------------------------------
- # * New method: item?
- #--------------------------------------------------------------------------
- def item?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: skill?
- #--------------------------------------------------------------------------
- def skill?
- return false
- end
- #--------------------------------------------------------------------------
- # * New method: type_set
- #--------------------------------------------------------------------------
- def type_set
- [itype_id]
- end
- 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
- #==============================================================================
- # ** 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_cond
- #--------------------------------------------------------------------------
- def get_cond(text)
- case text.upcase
- when "HIGHER" then ">"
- when "LOWER" then "<"
- when "EQUAL" then "=="
- when "DIFFERENT" then "!="
- else "!="
- end
- end
- #--------------------------------------------------------------------------
- # * 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: get_param_id
- #--------------------------------------------------------------------------
- def get_param_id(text)
- case text.upcase
- when "MAXHP", "HP" then 0
- when "MAXMP", "MP" then 1
- when "ATK" then 2
- when "DEF" then 3
- when "MAT" then 4
- when "MDF" then 5
- when "AGI" then 6
- when "LUK" then 7
- 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:
- #--------------------------------------------------------------------------
- def element_set(item)
- element_set = [item.damage.element_id]
- element_set += atk_elements if item.damage.element_id < 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 < state_rate(state_id)
- 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
- #--------------------------------------------------------------------------
- # * New method: cri_rate
- #--------------------------------------------------------------------------
- def cri_rate(user, item)
- user.cri
- end
- #--------------------------------------------------------------------------
- # * New method: cri_eva
- #--------------------------------------------------------------------------
- def cri_eva(user, item)
- cev
- end
- #--------------------------------------------------------------------------
- # * New method: setup_critical
- #--------------------------------------------------------------------------
- def setup_critical(user, item)
- cri_rate(user, item) * (1 - cri_eva(user, item))
- end
- end
- #==============================================================================
- # ** Game_Enemy
- #------------------------------------------------------------------------------
- # This class handles enemy characters. It's used within the Game_Troop class
- # ($game_troop).
- #==============================================================================
- class Game_Enemy < Game_Battler
- #--------------------------------------------------------------------------
- # * New method: note
- #--------------------------------------------------------------------------
- def note
- enemy ? enemy.note : ""
- end
- #--------------------------------------------------------------------------
- # * New method: get_all_notes
- #--------------------------------------------------------------------------
- def get_all_notes(*args)
- notes = ""
- notes += note if !args.include?(:self)
- states.compact.each {|state| notes += state.note } if !args.include?(:state)
- notes
- end
- #--------------------------------------------------------------------------
- # * New method: get_all_objects
- #--------------------------------------------------------------------------
- def get_all_objects(*args)
- result = []
- result += [self] if !args.include?(:self)
- result += states.compact if !args.include?(:state)
- result
- end
- #--------------------------------------------------------------------------
- # * New method: level
- #--------------------------------------------------------------------------
- def level
- return 1
- end
- #--------------------------------------------------------------------------
- # * New method: skill_learn?
- #--------------------------------------------------------------------------
- def skill_learn?(skill)
- skill.skill? && skills.include?(skill)
- end
- #--------------------------------------------------------------------------
- # * New method: skills
- #--------------------------------------------------------------------------
- def skills
- enemy.actions.collect {|action| $data_skills[action.skill_id] }
- end
- end
- #==============================================================================
- # ** Game_Actor
- #------------------------------------------------------------------------------
- # This class handles actors. It's used within the Game_Actors class
- # ($game_actors) and referenced by the Game_Party class ($game_party).
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # * New method: note
- #--------------------------------------------------------------------------
- def note
- actor ? actor.note : ""
- end
- #--------------------------------------------------------------------------
- # * New method: hue
- #--------------------------------------------------------------------------
- def hue
- @hue ? @hue : 0
- end
- #--------------------------------------------------------------------------
- # * New method: get_all_notes
- #--------------------------------------------------------------------------
- def get_all_notes(*args)
- notes = ""
- notes += note if !args.include?(:self)
- notes += self.class.note if !args.include?(:class)
- equips.compact.each {|equip| notes += equip.note } if !args.include?(:equip)
- states.compact.each {|state| notes += state.note } if !args.include?(:state)
- notes
- end
- #--------------------------------------------------------------------------
- # * New method: get_all_objects
- #--------------------------------------------------------------------------
- def get_all_objects(*args)
- result = []
- result += [self] if !args.include?(:self)
- result += [self.class] if !args.include?(:self)
- 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_Player and Game_Event classes.
- #==============================================================================
- class Game_Character < Game_CharacterBase
- #--------------------------------------------------------------------------
- # * New method: move_toward_position
- #--------------------------------------------------------------------------
- def move_toward_position(x, y)
- sx = distance_x_from(x)
- sy = distance_y_from(y)
- if sx.abs > sy.abs
- move_straight(sx > 0 ? 4 : 6)
- move_straight(sy > 0 ? 8 : 2) if !@move_succeed && sy != 0
- elsif sy != 0
- move_straight(sy > 0 ? 8 : 2)
- move_straight(sx > 0 ? 4 : 6) if !@move_succeed && sx != 0
- end
- end
- #--------------------------------------------------------------------------
- # * New method: move_toward_position
- #--------------------------------------------------------------------------
- def turn_toward_position(x, y)
- sx = distance_x_from(x)
- sy = distance_y_from(y)
- if sx.abs > sy.abs
- set_direction(sx > 0 ? 4 : 6)
- elsif sy != 0
- set_direction(sy > 0 ? 8 : 2)
- end
- end
- end
- #==============================================================================
- # ** Game_Player
- #------------------------------------------------------------------------------
- # This class handles the player.
- # The instance of this class is referenced by $game_map.
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # * New method: player?
- #--------------------------------------------------------------------------
- def player?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: perform_transfer
- #--------------------------------------------------------------------------
- def new_map_id
- @new_map_id
- end
- #--------------------------------------------------------------------------
- # * New method: hue
- #--------------------------------------------------------------------------
- def hue
- actor ? actor.hue : 0
- end
- end
- #==============================================================================
- # ** 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
- #--------------------------------------------------------------------------
- # * New method: vehicle?
- #--------------------------------------------------------------------------
- def vehicle?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: map_id
- #--------------------------------------------------------------------------
- def map_id
- @map_id
- end
- #--------------------------------------------------------------------------
- # * New method: type
- #--------------------------------------------------------------------------
- def type
- @type
- end
- #--------------------------------------------------------------------------
- # * New method: aerial?
- #--------------------------------------------------------------------------
- def aerial?
- type == :airship
- end
- #--------------------------------------------------------------------------
- # * New method: above?
- #--------------------------------------------------------------------------
- def above?
- aerial?
- 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
- #--------------------------------------------------------------------------
- # * New method: name
- #--------------------------------------------------------------------------
- def name
- @event.name
- end
- #--------------------------------------------------------------------------
- # * New method: event?
- #--------------------------------------------------------------------------
- def event?
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: erased?
- #--------------------------------------------------------------------------
- def erased?
- @erased
- end
- #--------------------------------------------------------------------------
- # * New method: note
- #--------------------------------------------------------------------------
- def note
- return "" if !@page || [email protected] || @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
- #==============================================================================
- # ** 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?(')
- @bw = bitmap.width / 32.0 / frames
- @bh = bitmap.height / 32.0 / 4
- elsif character_name != "" && @tile_id == 0
- @bw = bitmap.width / 32.0 / (frames * 4)
- @bh = bitmap.height / 32.0 / 8
- else
- @bw = 1.0
- @bh = 1.0
- end
- bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # * New method: collision?
- #--------------------------------------------------------------------------
- def collision?(x, y, w, h)
- ax1, ay1, ax2, ay2 = setup_rect(x, y, w, h)
- bx1, by1, bx2, by2 = setup_rect(@x, @y, bw, bh)
- ax2 > bx1 && ax1 < bx2 && ay2 > by1 && ay1 < by2
- end
- #--------------------------------------------------------------------------
- # * New method: over?
- #--------------------------------------------------------------------------
- def over?(x, y)
- ax1, ay1, ax2, ay2 = setup_rect(x, y - 0.125, 0, 0)
- bx1, by1, bx2, by2 = setup_rect(@real_x, @real_y, bw, bh - 0.125)
- ax2 >= bx1 && ax1 <= bx2 && ay2 >= by1 && ay1 <= by2
- end
- #--------------------------------------------------------------------------
- # * New method: setup_rect
- #--------------------------------------------------------------------------
- def setup_rect(x, y, w, h)
- x1 = x - w / 2.0
- y1 = y - h
- x2 = x1 + w
- y2 = y1 + h
- [x1, y1, x2, y2]
- end
- #--------------------------------------------------------------------------
- # * New method: align_with
- #--------------------------------------------------------------------------
- def align_with(x, y)
- d = @direction
- @x = $game_map.round_x_with_direction(x, 0) if d == 2 || d == 8
- @y = $game_map.round_y_with_direction(y, 0) if d == 6 || d == 4
- dx = (d == 2 || d == 8) ? (@x - @real_x) / 0.125 : 0
- dy = (d == 4 || d == 6) ? (@y - @real_y) / 0.125 : 0
- set_direction(dx > 0 ? 6 : dx < 0 ? 4 : dy > 0 ? 2 : dy < 0 ? 8 : d)
- @real_x = $game_map.x_with_direction(@x, reverse_dir(@direction), dx.abs)
- @real_y = $game_map.y_with_direction(@y, reverse_dir(@direction), dy.abs)
- update_for_align while moving?
- @direction = d
- end
- #--------------------------------------------------------------------------
- # * New method: update_for_align
- #--------------------------------------------------------------------------
- def update_for_align
- SceneManager.scene.update_basic
- SceneManager.scene.spriteset.update
- $game_map.update(true)
- $game_timer.update
- update_animation
- update_move
- end
- #--------------------------------------------------------------------------
- # * New method: fix_position
- #--------------------------------------------------------------------------
- def fix_position(n)
- (n * 64 / 8).round / 8.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
- #--------------------------------------------------------------------------
- # * Alias method: move_toward_character
- #--------------------------------------------------------------------------
- alias :move_toward_character_ve_pixel_movement :move_toward_character
- def move_toward_character(character)
- sx = distance_x_from(character.x)
- sy = distance_y_from(character.y)
- move_toward_character_ve_pixel_movement(character)
- @x = character.x if sx.abs < 1
- @y = character.y if sy.abs < 1
- end
- #--------------------------------------------------------------------------
- # * Alias method: move_toward_position
- #--------------------------------------------------------------------------
- alias :move_toward_position_ve_pixel_movement :move_toward_position
- def move_toward_position(x, y)
- sx = distance_x_from(x)
- sy = distance_y_from(y)
- move_toward_position_ve_pixel_movement(x, y)
- @x = x if sx.abs < 1
- @y = y if sy.abs < 1
- 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
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :over_event
- attr_accessor :land_test
- #--------------------------------------------------------------------------
- # * Overwrite method: check_event_trigger_there
- #--------------------------------------------------------------------------
- def check_event_trigger_there(triggers)
- x2 = $game_map.round_x_with_direction(@x, @direction)
- y2 = $game_map.round_y_with_direction(@y, @direction)
- start_map_event(x2, y2, triggers, true)
- return if $game_map.any_event_starting?
- return unless counter_tile?
- x3 = $game_map.check_x_with_direction(x2, @direction)
- y3 = $game_map.check_y_with_direction(y2, @direction)
- start_map_event(x3, y3, triggers, true)
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: start_map_event
- #--------------------------------------------------------------------------
- def start_map_event(x, y, triggers, normal)
- return if $game_map.interpreter.running?
- $game_map.events_xy(x, y).each do |event|
- event.start if check_event_contiontion(x, y, event, triggers, normal)
- end
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: update_nonmoving
- #--------------------------------------------------------------------------
- def update_nonmoving(last_moving)
- return if $game_map.interpreter.running?
- moved = @moved
- @moved = false
- if last_moving || moved
- $game_party.on_player_walk
- return if check_touch_event
- end
- if movable? && Input.trigger?(:C)
- return if get_on_off_vehicle
- return if check_action_event
- end
- @over_event -= 1 if @over_event > 0 && (last_moving || moved)
- update_encounter if last_moving || moved
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: get_on_vehicle
- #--------------------------------------------------------------------------
- def get_on_vehicle
- setup_vehicle
- enter_vehicle if vehicle
- @vehicle_getting_on
- end
- #--------------------------------------------------------------------------
- # * Overwrite method: increase_steps
- #--------------------------------------------------------------------------
- def increase_steps
- super
- if normal_walk?
- @steps += 1
- $game_player.damage_floor = 0 unless on_damage_floor?
- $game_player.damage_floor += 1
- $game_party.increase_steps if @steps % 8 == 0
- end
- end
- #--------------------------------------------------------------------------
- # * Alias method: get_off_vehicle
- #--------------------------------------------------------------------------
- alias :get_off_vehicle_ve_pixel_movement :get_off_vehicle
- def get_off_vehicle
- clear_next_movement if vehicle.land_ok?(@x, @y, @direction)
- get_off_vehicle_ve_pixel_movement
- end
- #--------------------------------------------------------------------------
- # * Alias method: clear_transfer_info
- #--------------------------------------------------------------------------
- alias :clear_transfer_info_ve_pixel_movement :clear_transfer_info
- def clear_transfer_info
- clear_transfer_info_ve_pixel_movement
- clear_next_movement
- end
- #--------------------------------------------------------------------------
- # * Alias method: update
- #--------------------------------------------------------------------------
- alias :update_ve_gp_pixel_movement :update
- def update
- @followers.move unless $imported[:ve_followers_options]
- update_ve_gp_pixel_movement
- end
- #--------------------------------------------------------------------------
- # * New method: check_event_contiontion
- #--------------------------------------------------------------------------
- def check_event_contiontion(x, y, event, triggers, normal)
- passable = passable_tile?(@x, @y, @direction)
- w = (counter_tile? || !passable) ? 1.0 : bw
- h = (counter_tile? || !passable) ? 1.0 : bh
- return false unless event.trigger_in?(triggers)
- return false unless event.event_priority?(normal)
- return false unless passable || event.over_tile? || counter_tile?
- return false unless event.collision?(x, y, w, h) || !jumping?
- return false unless !event.in_front? || front_collision?(x, y, @direction)
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: counter_tile?
- #--------------------------------------------------------------------------
- def counter_tile?
- x = $game_map.check_x_with_direction(@x, @direction)
- y = $game_map.check_y_with_direction(@y, @direction)
- $game_map.counter?(x, y)
- end
- #--------------------------------------------------------------------------
- # * New method: setup_vehicle
- #--------------------------------------------------------------------------
- def setup_vehicle
- $game_map.vehicles.compact.each do |vehicle|
- next unless vehicle.enter_vechicle?(@x, @y, @direction)
- @vehicle_type = vehicle.type
- break if vehicle
- end
- end
- #--------------------------------------------------------------------------
- # * New method: enter_vehicle
- #--------------------------------------------------------------------------
- def enter_vehicle
- align_with(vehicle.x, vehicle.y) unless in_airship?
- @vehicle_getting_on = true
- force_move_forward unless in_airship?
- @followers.gather
- end
- #--------------------------------------------------------------------------
- # * New method: clear_next_movement
- #--------------------------------------------------------------------------
- def clear_next_movement
- @next_movement.clear
- @followers.clear_next_movement
- end
- #--------------------------------------------------------------------------
- # * New method: step_times
- #--------------------------------------------------------------------------
- def step_times
- (move_route_forcing || not_driving?) ? super : 1
- end
- #--------------------------------------------------------------------------
- # * New method: not_driving?
- #--------------------------------------------------------------------------
- def not_driving?
- vehicle && !vehicle.driving
- end
- #--------------------------------------------------------------------------
- # * New method: move_straight
- #--------------------------------------------------------------------------
- def move_straight(d, turn_ok = true)
- super
- end
- #--------------------------------------------------------------------------
- # * New method: move_diagonal
- #--------------------------------------------------------------------------
- def move_diagonal(horz, vert)
- super
- end
- #--------------------------------------------------------------------------
- # * New method: setup_bitmap_dimension
- #--------------------------------------------------------------------------
- def setup_bitmap_dimension
- @bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
- @bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
- end
- end
- #==============================================================================
- # ** 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
- #--------------------------------------------------------------------------
- # * Overwrite method: chase_preceding_character
- #--------------------------------------------------------------------------
- def chase_preceding_character
- return if $imported[:ve_followers_control] && cant_follow_character
- unless moving?
- if @preceding_character.next_movement.size >= 8 && !gathering?
- next_move = @preceding_character.next_movement.shift
- move_straight(next_move) if next_move.numeric?
- move_diagonal(*next_move) if next_move.array?
- elsif gathering?
- @preceding_character.next_movement.clear
- move_toward_player
- end
- end
- end
- #--------------------------------------------------------------------------
- # * New method: move_straight
- #--------------------------------------------------------------------------
- def move_straight(d, turn_ok = true)
- super
- end
- #--------------------------------------------------------------------------
- # * New method: move_diagonal
- #--------------------------------------------------------------------------
- def move_diagonal(horz, vert)
- super
- end
- #--------------------------------------------------------------------------
- # * New method: movement_size
- #--------------------------------------------------------------------------
- def movement_size
- return 8
- end
- #--------------------------------------------------------------------------
- # * New method: step_times
- #--------------------------------------------------------------------------
- def step_times
- (move_route_forcing || not_driving? || gathering?) ? super : 1
- end
- #--------------------------------------------------------------------------
- # * New method: not_driving?
- #--------------------------------------------------------------------------
- def not_driving?
- $game_player.not_driving?
- end
- #--------------------------------------------------------------------------
- # * New method: setup_bitmap_dimension
- #--------------------------------------------------------------------------
- def setup_bitmap_dimension
- @bw = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
- @bh = VE_PLAYER_BIG_COLLISION ? 1.0 : 0.75
- 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: clear_next_movement
- #--------------------------------------------------------------------------
- def clear_next_movement
- each {|follower| follower.next_movement.clear }
- 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
- #--------------------------------------------------------------------------
- # * Overwrite method: collide_with_player_characters?
- #--------------------------------------------------------------------------
- def collide_with_player_characters?(x, y)
- normal_priority? && player_collision?(x, y)
- end
- #--------------------------------------------------------------------------
- # * Alias method: start
- #--------------------------------------------------------------------------
- alias :start_ve_pixel_movement :start
- def start
- start_ve_pixel_movement
- $game_player.over_event = 8 if step_over? && !step_trigger?
- end
- #--------------------------------------------------------------------------
- # * Alias method: setup_page_settings
- #--------------------------------------------------------------------------
- alias :setup_page_settings_ve_pixel_movement :setup_page_settings
- def setup_page_settings_ve_pixel_movement
- setup_page_settings_ve_anti_lag
- @move_steps = note =~ /<MOVE STEPS: (\d+)>/i ? $1.to_i : nil
- @step_trigger = note =~ /<EACH STEP TRIGGER>/i ? true : false
- @in_front = note =~ /<FRONT COLLISION>/i ? true : false
- @over_tile = note =~ /<OVER TILE>/i ? true : false
- @side_fix = note =~ /<NO SIDE COLLISION FIX>/i ? false : true
- end
- #--------------------------------------------------------------------------
- # * New method: player_collision?
- #--------------------------------------------------------------------------
- def player_collision?(x, y)
- $game_map.actors.any? {|actor| actor.collision?(x, y, bh, bw)}
- end
- #--------------------------------------------------------------------------
- # * New method: event_priority?
- #--------------------------------------------------------------------------
- def event_priority?(normal)
- (normal_priority? == normal || (@through && !normal)) &&
- (normal_priority? || @trigger == 0 || $game_player.over_event == 0)
- end
- #--------------------------------------------------------------------------
- # * New method: check_event_trigger_touch
- #--------------------------------------------------------------------------
- def check_event_trigger_touch(x, y)
- return if $game_map.interpreter.running?
- if @trigger == 2 && $game_player.collision?(x, y, bh, bw)
- start if !jumping? && normal_priority?
- end
- end
- #--------------------------------------------------------------------------
- # * New method: step_over?
- #--------------------------------------------------------------------------
- def step_over?
- super || (@character_name == "" && @tile_id == 0) || @priority_type == 0
- end
- #--------------------------------------------------------------------------
- # * New method: step_times
- #--------------------------------------------------------------------------
- def step_times
- @move_steps ? @move_steps : super
- end
- #--------------------------------------------------------------------------
- # * New method: step_trigger?
- #--------------------------------------------------------------------------
- def step_trigger?
- @step_trigger
- end
- #--------------------------------------------------------------------------
- # * New method: in_front?
- #--------------------------------------------------------------------------
- def in_front?
- @in_front
- end
- #--------------------------------------------------------------------------
- # * New method: over_tile?
- #--------------------------------------------------------------------------
- def over_tile?
- @over_tile
- end
- #--------------------------------------------------------------------------
- # * New method: side_collision?
- #--------------------------------------------------------------------------
- def side_collision?
- @side_fix
- end
- #--------------------------------------------------------------------------
- # * New method: setup_bitmap_dimension
- #--------------------------------------------------------------------------
- def setup_bitmap_dimension
- regexp = /<EVENT SIZE: (\d+), (\d+)>/i
- note =~ regexp ? setup_custom_dimension($1.to_i, $2.to_i) : super
- end
- #--------------------------------------------------------------------------
- # * New method: setup_custom_dimension
- #--------------------------------------------------------------------------
- def setup_custom_dimension(x, y)
- x1 = (x / 8).to_i
- y1 = (y / 8).to_i
- @bw = x1 / 4.0
- @bh = y1 / 4.0
- 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
- #--------------------------------------------------------------------------
- # * Overwrite method: land_ok?
- #--------------------------------------------------------------------------
- def land_ok?(x, y, d)
- @type == :airship ? airship_landable?(x, y) : check_landable?(x, y, d)
- end
- #--------------------------------------------------------------------------
- # * New method: land_test
- #--------------------------------------------------------------------------
- def land_test
- @land_test
- end
- #--------------------------------------------------------------------------
- # * New method: step_over?
- #--------------------------------------------------------------------------
- def step_over?
- above? || super
- end
- #--------------------------------------------------------------------------
- # * New method: check_landable?
- #--------------------------------------------------------------------------
- def check_landable?(x, y, d)
- x2 = $game_map.check_x_with_direction(x, d)
- y2 = $game_map.check_y_with_direction(y, d)
- @land_test = true
- result = passable?(x2, y2, d)
- @land_test = false
- result
- end
- #--------------------------------------------------------------------------
- # * New method: airship_landable?
- #--------------------------------------------------------------------------
- def airship_landable?(x, y)
- [2, 4, 6, 8].any? {|d| passable?(x, y, d) }
- end
- #--------------------------------------------------------------------------
- # * New method: passable_normal?
- #--------------------------------------------------------------------------
- def passable_normal?(x, y, d ,d2, ceil = false)
- @land_test ? landable_normal?(x, y, d ,d2, ceil) : super(x, y, d ,d2, ceil)
- end
- #--------------------------------------------------------------------------
- # * New method: landable_normal?
- #--------------------------------------------------------------------------
- def landable_normal?(x, y, d ,d2, ceil)
- x1 = $game_map.round_x(x)
- y1 = $game_map.round_y(y)
- return false unless $game_map.valid?(x1, y1)
- return true if @through || debug_through?
- return false unless map_passable?(x1, y1, d)
- return false unless map_passable?(x1, y1, d2) || !ceil
- return false unless map_passable?(x1, y1, reverse_dir(d))
- return true
- end
- #--------------------------------------------------------------------------
- # * New method: enter_vechicle?
- #--------------------------------------------------------------------------
- def enter_vechicle?(x, y, d)
- return false if @map_id != $game_map.map_id
- x2 = $game_map.round_x_with_direction(x, d)
- y2 = $game_map.round_y_with_direction(y, d)
- x3 = $game_map.check_x_with_direction(@x, reverse_dir(d))
- y3 = $game_map.check_y_with_direction(@y, reverse_dir(d))
- ( above? && collision?(x, y - 0.125, bw * 0.75, bh * 0.75)) ||
- (!above? && collision?(x2, y2, bw, bh) && map_passable?(x3, y3, d))
- end
- #--------------------------------------------------------------------------
- # * New method: vehicle_collision?
- #--------------------------------------------------------------------------
- def vehicle_collision?(x, y, bw, bh, player)
- return false if step_over?
- return false if player.player? && self == player.vehicle
- return false if !collision?(x, y, bw, bh)
- return true
- end
- end
复制代码 |
|