Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ¤¢¤ XRXSv5. X,move{ ¤¢¤
- #
- # publish 2010/ 3/ 2
- # update - 5/ 3
- #
- #==============================================================================
- # ƒJƒXƒ^ƒ}ƒCƒYƒ|ƒCƒ“ƒg
- #==============================================================================
- module XRXSV5
- #
- # [X.Move] - —LŒø‚É‚·‚éH
- #
- XMoveEnable = true
- #
- # [X.Move] - ˆÚ“®‘¬“x(1`6)
- #
- XMoveSpeed = 4
- #
- # [ƒiƒiƒ‘€ì] - —LŒø‚É‚·‚éH
- #
- SlantMoveInput = true
- #
- # [ƒiƒiƒƒOƒ‰ƒtƒBƒbƒN] - —LŒø‚É‚·‚éH
- #
- SlantGraphicEnable = true
- #
- # [ƒiƒiƒƒOƒ‰ƒtƒBƒbƒN] - ƒtƒ@ƒCƒ‹–¼•¶ŽšŽ®
- #
- SlantNameS = "$%s-%s-S"
- end
- #==============================================================================
- # XMove‘¬“xÝ’è
- #==============================================================================
- class Game_System
- attr_accessor :xmove_speed
- def xmove_speed
- return (@xmove_speed ? @xmove_speed : XRXSV5::XMoveSpeed)
- end
- end
- #==============================================================================
- # --- X.Move ---
- #==============================================================================
- module XMoveSmoother
- #--------------------------------------------------------------------------
- # ¤ ƒIƒuƒWƒFƒNƒg‰Šú‰»
- #--------------------------------------------------------------------------
- def initialize
- xmove_reset
- super
- end
- #--------------------------------------------------------------------------
- # ‚¸‚ꃊƒZƒbƒg
- #--------------------------------------------------------------------------
- def xmove_reset
- @xf = 0
- @yf = 0
- end
- #--------------------------------------------------------------------------
- # ¤ ˆÚ“®’†”»’è
- #--------------------------------------------------------------------------
- def moving?
- if xmove_disable?
- super
- else
- return (@real_x.to_i != (@x * 256 + @xf * 32) or
- @real_y.to_i != (@y * 256 + @yf * 32) )
- end
- end
- #--------------------------------------------------------------------------
- # ¤ ˆÚ“®Žž‚ÌXV
- #--------------------------------------------------------------------------
- def update_move
- if xmove_disable?
- super
- else
- last_x = @x
- last_y = @y
- @x += @xf / 8.0
- @y += @yf / 8.0
- @move_speed = $game_system.xmove_speed
- super
- @move_speed = 4
- @x = last_x
- @y = last_y
- @real_x.truncate
- @real_y.truncate
- end
- end
- #--------------------------------------------------------------------------
- # ¤ Šg’£’Ês‰Â”\”»’è
- #--------------------------------------------------------------------------
- def passable_x?(x, y)
- result = passable?(x, y)
- result &= passable?(x-1, y) if @xf < 0
- result &= passable?(x+1, y) if @xf > 0
- result &= passable?(x, y-1) if @yf < 0
- result &= passable?(x, y+1) if @yf > 0
- return result
- end
- #--------------------------------------------------------------------------
- # ŽŸ‚̃}ƒX‚Éi‚ñ‚¾‚Æ‚«‚̈—
- #--------------------------------------------------------------------------
- def process_next_mass
- increase_steps
- check_touch_event
- update_encounter
- end
- #--------------------------------------------------------------------------
- # ‰º‚Ɉړ®
- #--------------------------------------------------------------------------
- def move_down(turn_ok = true)
- if xmove_disable?
- super
- elsif @yf != 0 or passable_x?(@x, @y+1)
- turn_down
- @yf += 2
- if @yf == 0
- process_next_mass
- elsif @yf >= 4
- @yf = -4
- @y = $game_map.round_y(@y+1)
- @real_y = (@y-1)*256 + 64
- end
- else
- turn_down if turn_ok
- if not check_event_trigger_touch(@x, @y+1) and turn_ok
- if passable?(@x, @y+1)
- @xf = 0
- process_next_mass
- elsif @xf == 4 and passable?(@x+1, @y+1)
- @xf = 0
- @x = $game_map.round_x(@x+1)
- @real_x = (@x-1)*256 + 128
- process_next_mass
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ¶‚Ɉړ®
- #--------------------------------------------------------------------------
- def move_left(turn_ok = true)
- if xmove_disable?
- super
- elsif @xf != 0 or passable_x?(@x-1, @y)
- turn_left
- @xf -= 2
- if @xf == 0
- process_next_mass
- elsif @xf <= -4
- @xf = 4
- @x = $game_map.round_x(@x-1)
- @real_x = (@x+1)*256 - 64
- end
- else
- turn_left if turn_ok
- if not check_event_trigger_touch(@x-1, @y) and turn_ok
- if passable?(@x-1, @y)
- @yf = 0
- process_next_mass
- elsif @yf == 4 and passable?(@x-1, @y+1)
- @yf = 0
- @y = $game_map.round_x(@y+1)
- @real_y = (@y-1)*256 + 128
- process_next_mass
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ‰E‚Ɉړ®
- #--------------------------------------------------------------------------
- def move_right(turn_ok = true)
- if xmove_disable?
- super
- elsif @xf != 0 or passable_x?(@x+1, @y)
- turn_right
- @xf += 2
- if @xf == 0
- process_next_mass
- elsif @xf >= 6
- @xf = -2
- @x = $game_map.round_x(@x+1)
- @real_x = (@x-1)*256 + 128
- end
- else
- turn_right if turn_ok
- if not check_event_trigger_touch(@x+1, @y) and turn_ok
- if passable?(@x+1, @y)
- @yf = 0
- process_next_mass
- elsif @yf==4 and passable?(@x+1, @y+1)
- @yf = 0
- @y = $game_map.round_x(@y+1)
- @real_y = (@y-1)*256 + 128
- process_next_mass
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ã‚Ɉړ®
- #--------------------------------------------------------------------------
- def move_up(turn_ok = true)
- if xmove_disable?
- super
- elsif @yf != 0 or passable_x?(@x, @y-1)
- turn_up
- @yf -= 2
- if @yf == 0
- process_next_mass
- elsif @yf <= -6
- @yf = 2
- @y = $game_map.round_y(@y-1)
- @real_y = (@y+1)*256 - 128
- end
- else
- turn_up if turn_ok
- if not check_event_trigger_touch(@x, @y-1) and turn_ok
- if passable?(@x, @y-1)
- @xf = 0
- process_next_mass
- elsif @xf == 4 and passable?(@x+1, @y-1)
- @xf = 0
- @x = $game_map.round_x(@x+1)
- @real_x = (@x-1)*256 + 128
- process_next_mass
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ¶‰º‚Ɉړ®
- #--------------------------------------------------------------------------
- def move_lower_left
- if xmove_disable?
- super
- else
- move_down(true)
- move_left(true) unless $game_map.interpreter.running?
- end
- end
- #--------------------------------------------------------------------------
- # ‰E‰º‚Ɉړ®
- #--------------------------------------------------------------------------
- def move_lower_right
- if xmove_disable?
- super
- else
- move_down(true)
- move_right(true) unless $game_map.interpreter.running?
- end
- end
- #--------------------------------------------------------------------------
- # ¶ã‚Ɉړ®
- #--------------------------------------------------------------------------
- def move_upper_left
- if xmove_disable?
- super
- else
- move_up(true)
- move_left(true) unless $game_map.interpreter.running?
- end
- end
- #--------------------------------------------------------------------------
- # ‰Eã‚Ɉړ®
- #--------------------------------------------------------------------------
- def move_upper_right
- if xmove_disable?
- super
- else
- move_up(true)
- move_right(true) unless $game_map.interpreter.running?
- end
- end
- #--------------------------------------------------------------------------
- # ¤ ˆÚ“®ƒ‹[ƒg‚Ì‹§
- #--------------------------------------------------------------------------
- def force_move_route(move_route)
- xmove_reset
- super
- end
- #--------------------------------------------------------------------------
- # ¤ Žw’èˆÊ’u‚Ɉړ®
- #--------------------------------------------------------------------------
- def moveto(x, y)
- xmove_reset
- super
- end
- #--------------------------------------------------------------------------
- # X.ƒ€[ƒu‹@”\‚ð’âŽ~‚·‚é”»’è (ƒCƒxƒ“ƒg’†‚È‚Ç)
- #--------------------------------------------------------------------------
- def xmove_disable?
- return (@move_route_forcing or @move_speed != 4 or in_vehicle?)
- end
- end
- if XRXSV5::XMoveEnable
- class Game_Player < Game_Character
- include XMoveSmoother
- #--------------------------------------------------------------------------
- # œ ˆÚ“®’†‚łȂ¢ê‡‚̈—
- # (false : “¥‚Ý‹N“®ƒCƒxƒ“ƒg‚ƃGƒ“ƒJƒEƒ“ƒg•à”ˆ—‚ð
- # last_moving‚ð–â‚킸‚ɋ֎~‚·‚é)
- #--------------------------------------------------------------------------
- alias xrxsv5_update_nonmoving update_nonmoving
- def update_nonmoving(last_moving)
- xrxsv5_update_nonmoving(false)
- end
- #--------------------------------------------------------------------------
- # œ ³–ʂ̃Cƒxƒ“ƒg‹N“®”»’è
- #--------------------------------------------------------------------------
- alias xrxsv5_check_event_trigger_there check_event_trigger_there
- def check_event_trigger_there(triggers)
- return false if (@yf != 0 and [2,8].include?(@direction)) or
- (@xf != 0 and [4,6].include?(@direction))
- xrxsv5_check_event_trigger_there(triggers)
- end
- #--------------------------------------------------------------------------
- # œ ꊈړ®‚ÌŽÀs
- #--------------------------------------------------------------------------
- alias xrxsv5_perform_transfer perform_transfer
- def perform_transfer
- $game_player.xmove_reset if self.transfer?
- xrxsv5_perform_transfer
- end
- #--------------------------------------------------------------------------
- # œ ‹§“I‚Ɉê•à‘Oi
- #--------------------------------------------------------------------------
- alias xrxsv5_force_move_forward force_move_forward
- def force_move_forward
- xmove_reset
- xrxsv5_force_move_forward
- end
- #--------------------------------------------------------------------------
- # œ ”òs‘D‚Éæ‚é
- #--------------------------------------------------------------------------
- alias xrxsv5_get_on_airship get_on_airship
- def get_on_airship
- xmove_reset
- xrxsv5_get_on_airship
- end
- end
- end
- #==============================================================================
- # ƒiƒiƒƒOƒ‰ƒtƒBƒbƒN‘Ήž‹@”\
- #==============================================================================
- module XSlantGraphic
- attr_accessor :character_slant_mode
- def character_slant_name
- if [1,3,7,9].include?(@direction)
- filename = sprintf(XRXSV5::SlantNameS, @character_name, (@character_index + 1).to_s)
- begin
- Cache.character(filename)
- rescue
- filename = nil
- end
- return filename
- else
- return nil
- end
- end
- def character_name
- name = character_slant_name
- self.character_slant_mode = (name != nil)
- return (self.character_slant_mode ? name : super)
- end
- def character_index
- return (self.character_slant_mode ? 0 : super)
- end
- def direction
- return [0,2,2,6,4,0,6,4,8,8][super]
- end
- def turn_lower_left
- set_direction(1)
- end
- def turn_lower_right
- set_direction(3)
- end
- def turn_upper_left
- set_direction(7)
- end
- def turn_upper_right
- set_direction(9)
- end
- def move_lower_left
- super
- turn_lower_left unless $game_map.interpreter.running?
- end
- def move_lower_right
- super
- turn_lower_right unless $game_map.interpreter.running?
- end
- def move_upper_left
- super
- turn_upper_left unless $game_map.interpreter.running?
- end
- def move_upper_right
- super
- turn_upper_right unless $game_map.interpreter.running?
- end
- end
- class Game_Player < Game_Character
- include XSlantGraphic if XRXSV5::SlantGraphicEnable
- end
- #==============================================================================
- # ƒiƒiƒ‘€ì‹@”\ (Ä’è‹`)
- #==============================================================================
- if XRXSV5::SlantMoveInput
- class Game_Player < Game_Character
- def move_by_input
- return unless movable?
- return if $game_map.interpreter.running?
- case Input.dir8
- when 1; move_lower_left
- when 7; move_upper_left
- when 9; move_upper_right
- when 3; move_lower_right
- when 2; move_down
- when 4; move_left
- when 6; move_right
- when 8; move_up
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment