# ‘S•ûŒüƒhƒbƒgˆÚ“® Ver ƒÃ+++
# â€z•zŒ³ÂEÆ’TÆ’|Â[Æ’gURL
# [url=http://members.jcom.home.ne.jp/cogwheel/]http://members.jcom.home.ne.jp/cogwheel/[/url]
Â
#==============================================================================
# ¡ Game_Player
#------------------------------------------------------------------------------
# Â@Æ’vÆ’Å’Æ’Cƒ„Â[‚ðˆµ‚¤ƒNƒ‰ƒX‚Å‚·ÂBÆ’CÆ’xƒ“ƒg‚Ì‹N“®â€Â»â€™Ã¨â€šÃ¢ÂAÆ’}Æ’bÆ’v‚̃XÆ’NÆ’ÂÂ[ƒ‹‚È‚Ç‚Ì
# ‹@â€\‚ðŽÂ‚ÂĂ¢‚Ü‚·ÂB‚±‚̃Nƒ‰ƒX‚̃Cƒ“ƒXÆ’^ƒ“ƒX‚à $game_player ‚ÅŽQÂÆ‚³‚ê‚Ü‚·ÂB
#==============================================================================
Â
class Game_Player < Game_Character
 #--------------------------------------------------------------------------
 # ÂÅ“ ’èÂâ€
 #--------------------------------------------------------------------------
 UP   = 0          # Âã•ûŒü‚Ì—]—T(0 <= UP <= 63)
 SIDE  = 0          # ¶‰E•ûŒü‚Ì—]—T(0 <= SIDE <= 63)
 SLANT = false        # ˆÚ“®ƒ‹Â[Æ’g‚̎΂߈ړ®ŽžÂA‘¬“xÂC³
 #--------------------------------------------------------------------------
 # ÂÅ“ ŒöŠJÆ’Cƒ“ƒXÆ’^ƒ“ƒX•ÃÂâ€
 #--------------------------------------------------------------------------
 attr_reader  :walk           # Æ’vÆ’Å’Â[ƒ„Â[ˆÚ“®‘¬“x
 attr_reader  :event           # ƒCƒxƒ“ƒgŽžˆÚ“®‘¬“x
 attr_accessor :move_speed        # ˆÚ“®‘¬“x
 #--------------------------------------------------------------------------
 # ÂÅ“ Æ’IÆ’uÆ’WÆ’FÆ’NÆ’g‰Šú‰»
 #--------------------------------------------------------------------------
 def initialize
  super
  # @walk:•à Âs‘¬“x @dash:Æ’_Æ’bÆ’Vƒ…ŽžˆÚ“®‘¬“x
  # @event:Æ’CÆ’xƒ“ƒgŽžˆÚ“®‘¬“xÂi0‚ÌŽž‚ÃÂAÆ’CÆ’xƒ“ƒgŽž‚É‘¬“x•ÃÂX‚ð‚µ‚È‚¢Âj
  @walk  = 4
  @dash  = 5
  @event = 4
  @dot_m = true
  @revise_x = 0
  @revise_y = 0
  @move == false
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ Æ’tÆ’Å’Â[ƒ€ÂXÂV
 #--------------------------------------------------------------------------
 alias :update_original :update
 def update
  #Æ’_Æ’bÆ’Vƒ…‹@â€\ÂBÆ’Gƒ“ƒ^Â[Æ’LÂ[‚ª‰Ÿ‚³‚ê‚Ä‚¢‚éŠÔÂAˆÚ“®‘¬“x‚ð•ÃÂX‚·‚éÂB
  unless moving? or $game_system.map_interpreter.running? or
      @move_route_forcing or $game_temp.message_window_showing
   if @walk != @dash
    if Input.press?(Input::C)
     if @move_speed != @dash
      @move_speed = @dash
     end
    else
     if @move_speed != @walk
      @move_speed = @walk
     end
    end
   end
  end
  if @revise_x == nil and @revise_y == nil
   @revise_x = 0
   @revise_y = 0
  end
  unless @dot_m
   update_original
   return
  end
  if @move_route_forcing
   # Æ’ÂÂ[Æ’Jƒ‹•ÃÂâ€â€šÃ‰Ë†Ãšâ€œÂ®â€™â€ ‚©‚Ç‚¤‚©‚ð‹L‰¯
   last_moving = moving?
   # Æ’ÂÂ[Æ’Jƒ‹•ÃÂâ€â€šÃ‰ÂÀ•W‚ð‹L‰¯
   last_real_x = @real_x
   last_real_y = @real_y
   # ÂÀ•W‚ª‚¸‚ê‚Ä‚¢‚éÂê‡
   if (@revise_x != 0 or @revise_y != 0) and not jumping? and @move == true
    if @revise_x != @real_x - @x * 128 or @revise_y != @real_y - @y * 128
     @revise_x = @real_x - @x * 128
     @revise_y = @real_y - @y * 128
    end
    # ˆÚ“®‹——£distance1‚Æ–Ú•W‹——£distance2‚ðÂÃ’è
    distance1 = 2 ** @move_speed
    distance2 = Math.sqrt(@revise_x ** 2 + @revise_y ** 2)
    # ˆÚ“®‹——£‚ª–Ú•W‹——£‚ð‰z‚¦‚½Âê‡
    if distance1 > distance2
     # ‹Â§“I‚É•â³ÂÀ•W‚ð—ë‚É‚·‚é
     @real_x = @real_x - @revise_x
     @real_y = @real_y - @revise_y
     @revise_x = 0
     @revise_y = 0
     anime_update
    # ˆÚ“®‹——£‚ª–Ú•W‹——£‚É’B‚µ‚È‚¢Âê‡
    else
     # ˆÚ“®‹——£•ª–Ú•W‹——£‚ɋ߂ÂÂ
     @real_x -= (distance1 * @revise_x / distance2).round
     @real_y -= (distance1 * @revise_y / distance2).round
     @revise_x = @real_x - @x * 128
     @revise_y = @real_y - @y * 128
     anime_update
    end
   else
    super
   end
  else
   @move = false
   # ˆÚ“®’†ÂAÆ’CÆ’xƒ“ƒgŽÀÂs’†ÂAˆÚ“®ƒ‹Â[Æ’g‹Â§’†ÂA
   # Æ’ÂÆ’bÆ’ZÂ[Æ’WÆ’EÆ’Bƒ“ƒhÆ’E•\Ž¦’†‚Ì‚¢‚¸‚ê‚Å‚à ‚È‚¢Âê‡
   unless moving? or $game_system.map_interpreter.running? or
       @move_route_forcing or $game_temp.message_window_showing
    @event_run = false
    # •ûŒüƒ{Æ’^ƒ“‚ª‰Ÿ‚³‚ê‚Ä‚¢‚ê‚ÎÂA‚»‚Ì•ûŒü‚ÖƒvÆ’Å’Æ’Cƒ„Â[‚ðˆÚ“®
    case Input.dir8
    when 1
     move_lower_left_p
    when 2
     move_down_p
    when 3
     move_lower_right_p
    when 4
     move_left_p
    when 6
     move_right_p
    when 7
     move_upper_left_p
    when 8
     move_up_p
    when 9
     move_upper_right_p
    end
   end
   # Æ’ÂÂ[Æ’Jƒ‹•ÃÂâ€â€šÃ‰ÂÀ•W‚ð‹L‰¯
   last_real_x = @real_x
   last_real_y = @real_y
   # ˆÚ“®Âˆ—Â
   @real_x = @x * 128 + @revise_x
   @real_y = @y * 128 + @revise_y
   # Æ’ÂÂ[Æ’Jƒ‹•ÃÂâ€â€šÃ‰Ë†Ãšâ€œÂ®â€™â€ ‚©‚Ç‚¤‚©‚ð‹L‰¯
   last_moving = moving?
   # ÂÀ•WÂXÂV
   move_on
   # Œ»ÂÂÌÂÀ•W‚ƈȑO‚ÌÂÀ•W‚ªˆÙ‚È‚éÂê‡
   if (last_real_x != @real_x or last_real_y != @real_y)
    @move_distance = 0 if @move_distance == nil
    @move_distance += Math.sqrt((last_real_x - @real_x) ** 2 +
                   (last_real_y - @real_y) ** 2)
    if @move_distance >= 128
     @move_distance %= 128
     increase_steps
    end
    # Æ’AÆ’jÆ’ÂÂ[Æ’Vƒ‡ƒ“‚ðÂXÂV
    anime_update
   elsif @walk_anime
    @pattern = @original_pattern
   end
  end
  # Æ’Lƒƒƒ‰ƒNÆ’^Â[‚ª‰º‚Ɉړ®‚µÂA‚©‚‰æ–ÊÂã‚̈ʒu‚ª’†‰›‚æ‚艺‚ÌÂê‡
  if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
   # Æ’}Æ’bÆ’v‚ð‰º‚ÉƒXÆ’NÆ’ÂÂ[ƒ‹
   $game_map.scroll_down(@real_y - last_real_y)
  end
  # Æ’Lƒƒƒ‰ƒNÆ’^Â[‚ªÂ¶‚Ɉړ®‚µÂA‚©‚‰æ–ÊÂã‚̈ʒu‚ª’†‰›‚æ‚趂ÌÂê‡
  if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
   # Æ’}Æ’bÆ’v‚ð¶‚ɃXÆ’NÆ’ÂÂ[ƒ‹
   $game_map.scroll_left(last_real_x - @real_x)
  end
  # Æ’Lƒƒƒ‰ƒNÆ’^Â[‚ª‰E‚Ɉړ®‚µÂA‚©‚‰æ–ÊÂã‚̈ʒu‚ª’†‰›‚æ‚è‰E‚ÌÂê‡
  if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
   # Æ’}Æ’bÆ’v‚ð‰E‚ɃXÆ’NÆ’ÂÂ[ƒ‹
   $game_map.scroll_right(@real_x - last_real_x)
  end
  # Æ’Lƒƒƒ‰ƒNÆ’^Â[‚ªÂã‚Ɉړ®‚µÂA‚©‚‰æ–ÊÂã‚̈ʒu‚ª’†‰›‚æ‚èÂã‚ÌÂê‡
  if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
   # Æ’}Æ’bÆ’v‚ðÂã‚ɃXÆ’NÆ’ÂÂ[ƒ‹
   $game_map.scroll_up(last_real_y - @real_y)
  end
  # ‘O‰ñƒvÆ’Å’Æ’Cƒ„Â[‚ªˆÚ“®’†‚¾‚½Âê‡
  if last_moving
   # “¯ˆÊ’u‚̃CÆ’xƒ“ƒg‚Æ‚ÌÂÚÂG‚É‚æ‚éƒCÆ’xƒ“ƒg‹N“®â€Â»â€™Ã¨
   result = check_event_trigger_here([1,2])
   if result == true
    if (last_real_x / 128.0).round != @x and
      (last_real_y / 128.0).round != @y
     if @direction == 2 or @direction == 8
      if (last_real_x / 128.0).round > @x
       turn_left
      else
       turn_right
      end
     else
      if (last_real_y / 128.0).round > @y
       turn_up
      else
       turn_down
      end
     end
    elsif (last_real_x / 128.0).round > @x
     turn_left
    elsif (last_real_x / 128.0).round < @x
     turn_right
    elsif (last_real_y / 128.0).round > @y
     turn_up
    elsif (last_real_y / 128.0).round < @y
     turn_down
    end
   end
   # ‹N“®‚µ‚½ƒCÆ’xƒ“ƒg‚ª‚È‚¢Âê‡
   if result == false
    # Æ’fÆ’oÆ’bÆ’Oƒ‚Â[Æ’h‚ª ON ‚©‚ CTRL Æ’LÂ[‚ª‰Ÿ‚³‚ê‚Ä‚¢‚éÂꇂðÂœ‚«
    unless $DEBUG and Input.press?(Input::CTRL)
     # ƒGƒ“ƒJƒEƒ“ƒg ƒJƒEƒ“ƒgƒ_ƒEƒ“
     if @encounter_count > 0
      @encounter_count -= 1
     end
    end
   end
  end
  # C Æ’{Æ’^ƒ“‚ª‰Ÿ‚³‚ꂽÂê‡
  if Input.trigger?(Input::C)
   # “¯ˆÊ’u‚¨‚æ‚ѳ–ʂ̃CÆ’xƒ“ƒg‹N“®â€Â»â€™Ã¨
   check_event_trigger_here([0])
   check_event_trigger_there([0,1,2])
  end
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ˆÚ“®â€Â»â€™Ã¨
 #--------------------------------------------------------------------------
 def moving?
  unless @dot_m
   result = super
   return result
  end
  # ‹Â§ˆÚ“®‚ÌÂꇃIÆ’Å Æ’WÆ’iƒ‹‚Ìâ€Â»â€™Ã¨â€šÃ°â€šÂ³â€šÂ¹â€šÃ©
  if @move_route_forcing
   if @move == false
    return false
   end
   super
  # ’ÊÂÃŽž‚ÃŒ»ÂÀ•W‚ªŽÀÂÀ•W‚ƈقȂéÂꇂ̂Èړ®’†‚Æâ€Â»â€™Ã¨
  else
   return (@x != (@real_x / 128.0).round or @y != (@real_y / 128.0).round)
  end
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ˆÚ“®â€Â»â€™Ã¨
 #--------------------------------------------------------------------------
 def moving_a?
  if @move == false
   if (@move_route.list[@move_route_index].code <= 14 or
     @move_route.list[@move_route_index].code == 25)
    @move = true
   end
   return false
  end
  moving?
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ Æ’tÆ’Å’Â[ƒ€ÂXÂV (Æ’Wƒƒƒ“ƒv)
 #--------------------------------------------------------------------------
 def update_jump
  # ƒWƒƒƒ“ƒvƒJƒEƒ“ƒg‚ð 1 Œ¸‚ç‚·
  @jump_count -= 1
  # ÂV‚µ‚¢ÂÀ•W‚ðŒvŽZ
  @real_x = (@real_x * @jump_count + @x * 128) / (@jump_count + 1)
  @real_y = (@real_y * @jump_count + @y * 128) / (@jump_count + 1)
  if @jump_count == 0
   @revise_x = 0
   @revise_y = 0
  end
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ˆÚ“®ƒ^Æ’CÆ’v : Æ’JÆ’XÆ’^ƒ€
 #--------------------------------------------------------------------------
 def move_type_custom
  unless @dot_m
   super
   return
  end
  # ’âŽ~’†‚Å‚È‚¯‚ê‚Î’†’f
  if jumping? or moving_a?
   return
  end
  # ˆÚ“®ƒRÆ’}ƒ“ƒh‚̃ŠƒXÆ’g‚ÌÂÅŒã‚É“ž’B‚·‚é‚܂Ń‹Â[Æ’v
  while @move_route_index < @move_route.list.size
   # ˆÚ“®ƒRƒ}ƒ“ƒh‚ðŽæ“¾
   command = @move_route.list[@move_route_index]
   # Æ’RÆ’}ƒ“ƒhÆ’RÂ[Æ’h 0 â€Ã” (Æ’Å Æ’XÆ’g‚ÌÂÅŒã) ‚ÌÂê‡
   if command.code == 0
    # Æ’IÆ’vÆ’Vƒ‡ƒ“ [“®Âì‚ðŒJ‚è•Ô‚·] ‚ª ON ‚ÌÂê‡
    if @move_route.repeat
     # ˆÚ“®ƒ‹Â[Æ’g‚̃Cƒ“ƒfÆ’bÆ’NÆ’X‚ðÂʼn‚É–ß‚·
     @move_route_index = 0
    end
    # Æ’IÆ’vÆ’Vƒ‡ƒ“ [“®Âì‚ðŒJ‚è•Ô‚·] ‚ª OFF ‚ÌÂê‡
    unless @move_route.repeat
     # ˆÚ“®ƒ‹Â[Æ’g‹Â§’†‚ÌÂê‡
     if @move_route_forcing and not @move_route.repeat
      # ˆÚ“®ƒ‹Â[Æ’g‚̋§‚ð‰ðÂÅ“
      @move_route_forcing = false
      # Æ’IÆ’Å Æ’WÆ’iƒ‹‚̈ړ®ƒ‹Â[Æ’g‚𕜋A
      @move_route = @original_move_route
      @move_route_index = @original_move_route_index
      @original_move_route = nil
     end
     # ’âŽ~ƒJƒEƒ“ƒg‚ðƒNƒŠƒA
     @stop_count = 0
    end
    return
   end
   # ˆÚ“®ŒnÆ’RÆ’}ƒ“ƒh (‰º‚Ɉړ®Â`Æ’Wƒƒƒ“ƒv) ‚ÌÂê‡
   if command.code <= 14
    # Æ’RÆ’}ƒ“ƒhÆ’RÂ[Æ’h‚Å•ªŠò
    case command.code
    when 1  # ‰º‚Ɉړ®
     move_down
    when 2  # ¶‚Ɉړ®
     move_left
    when 3  # ‰E‚Ɉړ®
     move_right
    when 4  # Âã‚Ɉړ®
     move_up
    when 5  # ¶‰º‚Ɉړ®
     move_lower_left
    when 6  # ‰E‰º‚Ɉړ®
     move_lower_right
    when 7  # ¶Âã‚Ɉړ®
     move_upper_left
    when 8  # ‰EÂã‚Ɉړ®
     move_upper_right
    when 9  # ƒ‰ƒ“ƒ_ƒ€‚Ɉړ®
     move_random
    when 10  # Æ’vÆ’Å’Æ’Cƒ„Â[‚ɋ߂ÂÂ
     move_toward_player
    when 11  # Æ’vÆ’Å’Æ’Cƒ„Â[‚©‚牓‚´‚©‚é
     move_away_from_player
    when 12  # ˆê•à ‘OÂi
     move_forward
    when 13  # ˆê•à Œã‘Þ
     move_backward
    when 14  # ƒWƒƒƒ“ƒv
     jump(command.parameters[0], command.parameters[1])
    end
    # Æ’IÆ’vÆ’Vƒ‡ƒ“ [ˆÚ“®‚Å‚«‚È‚¢ÂꇂֳŽ‹] ‚ª OFF ‚ÅÂAˆÚ“®Ž¸â€s‚ÌÂê‡
    if not @move_route.skippable and not moving? and not jumping?
     return
    end
    @move_route_index += 1
    return
   end
   # Æ’EÆ’FÆ’CÆ’g‚ÌÂê‡
   if command.code == 15
    # Æ’EÆ’FÆ’CÆ’gÆ’JÆ’Eƒ“ƒg‚ðÂÃ’è
    @wait_count = command.parameters[0] * 2 - 1
    @move_route_index += 1
    return
   end
   # Œü‚«•ÃÂXÅ’n‚̃RÆ’}ƒ“ƒh‚ÌÂê‡
   if command.code >= 16 and command.code <= 26
    # Æ’RÆ’}ƒ“ƒhÆ’RÂ[Æ’h‚Å•ªŠò
    case command.code
    when 16  # ‰º‚ðŒü‚Â
     turn_down
    when 17  # ¶‚ðŒü‚Â
     turn_left
    when 18  # ‰E‚ðŒü‚Â
     turn_right
    when 19  # Âã‚ðŒü‚Â
     turn_up
    when 20  # ‰E‚É 90 “x‰ñ“]
     turn_right_90
    when 21  # ¶‚É 90 “x‰ñ“]
     turn_left_90
    when 22  # 180 “x‰ñ“]
     turn_180
    when 23  # ‰E‚©Â¶‚É 90 “x‰ñ“]
     turn_right_or_left_90
    when 24  # ƒ‰ƒ“ƒ_ƒ€‚É•ûŒü“]Š·
     turn_random
    when 25  # Æ’vÆ’Å’Æ’Cƒ„Â[‚Ì•û‚ðŒü‚Â
     turn_toward_player
    when 26  # Æ’vÆ’Å’Æ’Cƒ„Â[‚Ì‹t‚ðŒü‚Â
     turn_away_from_player
    end
    @move_route_index += 1
    return
   end
   # ‚»‚Ì‘¼‚̃RÆ’}ƒ“ƒh‚ÌÂê‡
   if command.code >= 27
    # Æ’RÆ’}ƒ“ƒhÆ’RÂ[Æ’h‚Å•ªŠò
    case command.code
    when 27  # ƒXƒCƒbƒ` ON
     $game_switches[command.parameters[0]] = true
     $game_map.need_refresh = true
    when 28  # ƒXƒCƒbƒ` OFF
     $game_switches[command.parameters[0]] = false
     $game_map.need_refresh = true
    when 29  # ˆÚ“®‘¬“x‚Ì•ÃÂX
     @move_speed = command.parameters[0]
    when 30  # ˆÚ“®•p“x‚Ì•ÃÂX
     @move_frequency = command.parameters[0]
    when 31  # ˆÚ“®ŽžƒAƒjƒ ON
     @walk_anime = true
    when 32  # ˆÚ“®ŽžƒAƒjƒ OFF
     @walk_anime = false
    when 33  # ’âŽ~ŽžƒAƒjƒ ON
     @step_anime = true
    when 34  # ’âŽ~ŽžƒAƒjƒ OFF
     @step_anime = false
    when 35  # Œü‚«ŒÅ’è ON
     @direction_fix = true
    when 36  # Œü‚«ŒÅ’è OFF
     @direction_fix = false
    when 37  # ‚·‚èâ€Â²â€šÂ¯ ON
     @through = true
    when 38  # ‚·‚èâ€Â²â€šÂ¯ OFF
     @through = false
    when 39  # ÂÅ‘O–Ê‚É•\Ž¦ ON
     @always_on_top = true
    when 40  # ÂÅ‘O–Ê‚É•\Ž¦ OFF
     @always_on_top = false
    when 41  # Æ’Oƒ‰ƒtÆ’BÆ’bÆ’N•ÃÂX
     @tile_id = 0
     @character_name = command.parameters[0]
     @character_hue = command.parameters[1]
     if @original_direction != command.parameters[2]
      @direction = command.parameters[2]
      @original_direction = @direction
      @prelock_direction = 0
     end
     if @original_pattern != command.parameters[3]
      @pattern = command.parameters[3]
      @original_pattern = @pattern
     end
    when 42  # •s“§–¾“x‚Ì•ÃÂX
     @opacity = command.parameters[0]
    when 43  # ‡¬•û–@‚Ì•ÃÂX
     @blend_type = command.parameters[0]
    when 44  # SE ‚̉‰‘t
     $game_system.se_play(command.parameters[0])
    when 45  # ƒXƒNƒŠƒvƒg
     result = eval(command.parameters[0])
    end
    @move_route_index += 1
    return
   end
  end
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ‰º‚Ɉړ®
 #--------------------------------------------------------------------------
 def move_down_p
  # ‰º‚ðŒü‚Â
  turn_down
  # ˆÚ“®‹——£‚ðŽZÂo
  distance = 2 ** @move_speed
  down1(((@x * 128 + @revise_x) / 128.0).round,
     ((@y * 128 + @revise_y) / 128.0).round, distance, true)
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ‰º‚Ɉړ®‰Ââ€\‚©‚Ç‚¤‚©‚Ìâ€Â»â€™Ã¨â€šP
 #--------------------------------------------------------------------------
 def down1(x, y, distance, down = false)
  result = down2(x, y, distance)
  if result == false
   @event_run = check_event_trigger_touch(x, y+1)
   return result
  end
  if @revise_x < -SIDE
   result = down2(x, y + 1, distance, 4)
   result &= down2(x - 1, y, distance)
   if result == false
    if down
     move_lower_right_p
     if @revise_x > SIDE
      @revise_x = SIDE
     end
    end
    return result
   end
  elsif @revise_x > SIDE
   result = down2(x, y + 1, distance, 6)
   result &= down2(x + 1, y, distance)
   if result == false
    if down
     move_lower_left_p
     if @revise_x < -SIDE
      @revise_x = -SIDE
     end
    end
    return result
   end
  end
  # ‰º‚Ɉړ®‰Ââ€\‚È‚ç‚΋——£•ªˆÚ“®
  @revise_y += distance
  return result
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ‰º‚Ɉړ®‰Ââ€\‚©‚Ç‚¤‚©‚Ìâ€Â»â€™Ã¨â€šQ
 #--------------------------------------------------------------------------
 def down2(x, y, distance, d = 2)
  if @revise_y + distance > 0
   unless passable?(x, y, d)
    if @revise_y < 0
     @revise_y = 0
    end
    return false
   end
  end
  return true
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ¶‚Ɉړ®
 #--------------------------------------------------------------------------
 def move_left_p
  # ¶‚ðŒü‚Â
  turn_left
  distance = 2 ** @move_speed
  left1(((@x * 128 + @revise_x) / 128.0).round,
     ((@y * 128 + @revise_y) / 128.0).round, distance, true)
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ¶‚Ɉړ®‰Ââ€\‚©‚Ç‚¤‚©‚Ìâ€Â»â€™Ã¨â€šP
 #--------------------------------------------------------------------------
 def left1(x, y, distance, left = false)
  result = left2(x, y, distance)
  if result == false
   @event_run = check_event_trigger_touch(x-1, y)
   return result
  end
  if @revise_y < -UP
   result = left2(x - 1, y, distance, 8)
   result &= left2(x, y - 1, distance)
   if result == false
    if left
     move_lower_left_p
     if @revise_y > 0
      @revise_y = 0
     end
    end
    return result
   end
  elsif @revise_y > 0
   result = left2(x - 1, y, distance, 2)
   result &= left2(x, y + 1, distance)
   if result == false
    if left
     move_upper_left_p
     if @revise_y < -UP
      @revise_y = -UP
     end
    end
    return result
   end
  end
  @revise_x -= distance
  return result
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ¶‚Ɉړ®‰Ââ€\‚©‚Ç‚¤‚©‚Ìâ€Â»â€™Ã¨â€šQ
 #--------------------------------------------------------------------------
 def left2(x, y, distance, d = 4)
  if @revise_x - distance < -SIDE
   unless passable?(x, y, d)
    if @revise_x > -SIDE
     @revise_x = -SIDE
    end
    return false
   end
  end
  return true
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ‰E‚Ɉړ®
 #--------------------------------------------------------------------------
 def move_right_p
   # ‰E‚ðŒü‚Â
   turn_right
  distance = 2 ** @move_speed
  right1(((@x * 128 + @revise_x) / 128.0).round,
      ((@y * 128 + @revise_y) / 128.0).round, distance, true)
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ‰E‚Ɉړ®‰Ââ€\‚©‚Ç‚¤‚©‚Ìâ€Â»â€™Ã¨â€šP
 #--------------------------------------------------------------------------
 def right1(x, y, distance, right = false)
  result = right2(x, y, distance)
  if result == false
   @event_run = check_event_trigger_touch(x+1, y)
   return result
  end
  if @revise_y < -UP
   result = right2(x + 1, y, distance, 8)
   result &= right2(x, y - 1, distance)
   if result == false
    if right
     move_lower_right_p
     if @revise_y > 0
      @revise_y = 0
     end
    end
    return result
   end
  elsif @revise_y > 0
   result = right2(x + 1, y, distance, 2)
   result &= right2(x, y + 1, distance)
   if result == false
    if right
     move_upper_right_p
     if @revise_y < -UP
      @revise_y = -UP
     end
    end
    return result
   end
  end
  @revise_x += distance
  return result
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ‰E‚Ɉړ®‰Ââ€\‚©‚Ç‚¤‚©‚Ìâ€Â»â€™Ã¨â€šQ
 #--------------------------------------------------------------------------
 def right2(x, y, distance, d = 6)
  if @revise_x + distance > SIDE
   unless passable?(x, y, d)
    if @revise_x < SIDE
     @revise_x = SIDE
    end
    return false
   end
  end
  return true
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ Âã‚Ɉړ®
 #--------------------------------------------------------------------------
 def move_up_p
  # Âã‚ðŒü‚Â
  turn_up
  # ‰º‚Ɉړ®
  distance = 2 ** @move_speed
  up1(((@x * 128 + @revise_x) / 128.0).round,
    ((@y * 128 + @revise_y) / 128.0).round, distance, true)
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ Âã‚Ɉړ®‰Ââ€\‚©‚Ç‚¤‚©‚Ìâ€Â»â€™Ã¨â€šP
 #--------------------------------------------------------------------------
 def up1(x, y, distance, up = false)
  result = up2(x, y, distance)
  if result == false
   @event_run = check_event_trigger_touch(x, y-1)
   return result
  end
  if @revise_x < -SIDE
   result = up2(x, y - 1, distance, 4)
   result &= up2(x - 1, y, distance)
   if result == false
    if up
     move_upper_right_p
     if @revise_x > SIDE
      @revise_x = SIDE
     end
    end
    return result
   end
  elsif @revise_x > SIDE
   result = up2(x, y - 1, distance, 6)
   result &= up2(x + 1, y, distance)
   if result == false
    if up
     move_upper_left_p
     if @revise_x < -SIDE
      @revise_x = -SIDE
     end
    end
    return result
   end
  end
  @revise_y -= distance
  return result
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ Âã‚Ɉړ®‰Ââ€\‚©‚Ç‚¤‚©‚Ìâ€Â»â€™Ã¨â€šQ
 #--------------------------------------------------------------------------
 def up2(x, y, distance, d = 8)
  if @revise_y - distance < -UP
   unless passable?(x, y, d)
    if @revise_y > -UP
     @revise_y = -UP
    end
    return false
   end
  end
  return true
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ¶‰º‚Ɉړ®
 #--------------------------------------------------------------------------
 def move_lower_left_p
  # Œü‚«ŒÅ’è‚Å‚È‚¢Âê‡
  unless @direction_fix
   # ‰EŒü‚«‚¾‚½Âꇂö‚ðÂAÂãŒü‚«‚¾‚½Âꇂɺ‚ðŒü‚Â
   @direction = (@direction == 6 ? 4 : @direction == 8 ? 2 : @direction)
  end
  # ¶‰º‚Ɉړ®
  distance = (2 ** @move_speed) / Math.sqrt(2)
  if @direction == 2
   turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
               ((@y * 128 + @revise_y) / 128.0).round, distance)
   turn_down if @event_run
   unless @event_run
    if last_move?(@real_x, @real_y, 2, distance)
     result = check_event_trigger_here([1,2], false)
     if result == true
      return
     end
    end
    move_on
    if @revise_y > 0 and -UP > @revise_y - distance
     @revise_y = 0
    end
    turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
               ((@y * 128 + @revise_y) / 128.0).round, distance)
    turn_left if @event_run
   end
  else
   turn_down unless left1(((@x * 128 + @revise_x) / 128.0).round,
               ((@y * 128 + @revise_y) / 128.0).round, distance)
   turn_left if @event_run
   unless @event_run
    if last_move?(@real_x, @real_y, 4, distance)
     result = check_event_trigger_here([1,2], false)
     if result == true
      return
     end
    end
    move_on
    if  @revise_x + distance> SIDE and -SIDE > @revise_x
     @revise_x = -SIDE
    end
    turn_left unless down1(((@x * 128 + @revise_x) / 128.0).round,
               ((@y * 128 + @revise_y) / 128.0).round, distance)
    turn_down if @event_run
   end
  end
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ‰E‰º‚Ɉړ®
 #--------------------------------------------------------------------------
 def move_lower_right_p
  # Œü‚«ŒÅ’è‚Å‚È‚¢Âê‡
  unless @direction_fix
   # ¶Œü‚«‚¾‚½ÂꇂÉE‚ðÂAÂãŒü‚«‚¾‚½Âꇂɺ‚ðŒü‚Â
   @direction = (@direction == 4 ? 6 : @direction == 8 ? 2 : @direction)
  end
  # ‰E‰º‚Ɉړ®
  distance = (2 ** @move_speed) / Math.sqrt(2)
  if @direction == 2
   turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
               ((@y * 128 + @revise_y) / 128.0).round, distance)
   turn_down if @event_run
   unless @event_run
    if last_move?(@real_x, @real_y, 2, distance)
     result = check_event_trigger_here([1,2], false)
     if result == true
      return
     end
    end
    move_on
    if @revise_y > 0 and -UP > @revise_y - distance
     @revise_y = 0
    end
    turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
               ((@y * 128 + @revise_y) / 128.0).round, distance)
    turn_right if @event_run
   end
  else
   turn_down unless right1(((@x * 128 + @revise_x) / 128.0).round,
               ((@y * 128 + @revise_y) / 128.0).round, distance)
   turn_right if @event_run
   unless @event_run
    if last_move?(@real_x, @real_y, 6, distance)
     result = check_event_trigger_here([1,2], false)
     if result == true
      return
     end
    end
    move_on
    if @revise_x > SIDE and -SIDE > @revise_x - distance
     @revise_x = SIDE
    end
    turn_right unless down1(((@x * 128 + @revise_x) / 128.0).round,
               ((@y * 128 + @revise_y) / 128.0).round, distance)
    turn_down if @event_run
   end
  end
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ¶Âã‚Ɉړ®
 #--------------------------------------------------------------------------
 def move_upper_left_p
  # Œü‚«ŒÅ’è‚Å‚È‚¢Âê‡
  unless @direction_fix
   # ‰EŒü‚«‚¾‚½Âꇂö‚ðÂA‰ºŒü‚«‚¾‚½ÂꇂÃÂã‚ðŒü‚Â
   @direction = (@direction == 6 ? 4 : @direction == 2 ? 8 : @direction)
  end
  # ¶Âã‚Ɉړ®
  distance = (2 ** @move_speed) / Math.sqrt(2)
  if @direction == 8
   turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
              ((@y * 128 + @revise_y) / 128.0).round, distance)
   turn_up if @event_run
   unless @event_run
    if last_move?(@real_x, @real_y, 8, distance)
     result = check_event_trigger_here([1,2], false)
     if result == true
      return
     end
    end
    move_on
    if @revise_y + distance > 0 and -UP > @revise_y
     @revise_y = -UP
    end
    turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
               ((@y * 128 + @revise_y) / 128.0).round, distance)
    turn_left if @event_run
   end
  else
   turn_up unless left1(((@x * 128 + @revise_x) / 128.0).round,
              ((@y * 128 + @revise_y) / 128.0).round, distance)
   turn_left if @event_run
   unless @event_run
    if last_move?(@real_x, @real_y, 4, distance)
     result = check_event_trigger_here([1,2], false)
     if result == true
      return
     end
    end
    move_on
    if @revise_x > SIDE and -SIDE > @revise_x - distance
     @revise_x = SIDE
    end
    turn_left unless up1(((@x * 128 + @revise_x) / 128.0).round,
               ((@y * 128 + @revise_y) / 128.0).round, distance)
    turn_up if @event_run
   end
  end
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ‰EÂã‚Ɉړ®
 #--------------------------------------------------------------------------
 def move_upper_right_p
  # Œü‚«ŒÅ’è‚Å‚È‚¢Âê‡
  unless @direction_fix
   # ¶Œü‚«‚¾‚½ÂꇂÉE‚ðÂA‰ºŒü‚«‚¾‚½ÂꇂÃÂã‚ðŒü‚Â
   @direction = (@direction == 4 ? 6 : @direction == 2 ? 8 : @direction)
  end
  # ‰EÂã‚Ɉړ®
  distance = (2 ** @move_speed) / Math.sqrt(2)
  if @direction == 8
   turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
              ((@y * 128 + @revise_y) / 128.0).round, distance)
   turn_up if @event_run
   unless @event_run
    if last_move?(@real_x, @real_y, 8, distance)
     result = check_event_trigger_here([1,2], false)
     if result == true
      return
     end
    end
    move_on
    if @revise_y + distance > 0 and -UP > @revise_y
     @revise_y = -UP
    end
    turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
               ((@y * 128 + @revise_y) / 128.0).round, distance)
    turn_right if @event_run
   end
  else
   turn_up unless right1(((@x * 128 + @revise_x) / 128.0).round,
              ((@y * 128 + @revise_y) / 128.0).round, distance)
   turn_right if @event_run
   unless @event_run
    if last_move?(@real_x, @real_y, 6, distance)
     result = check_event_trigger_here([1,2], false)
     if result == true
      return
     end
    end
    move_on
    if @revise_x > SIDE and -SIDE > @revise_x - distance
     @revise_x = SIDE
    end
    turn_right unless up1(((@x * 128 + @revise_x) / 128.0).round,
               ((@y * 128 + @revise_y) / 128.0).round, distance)
    turn_up if @event_run
   end
  end
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ “¯ˆÊ’u‚̃CÆ’xƒ“ƒg‹N“®â€Â»â€™Ã¨
 #--------------------------------------------------------------------------
 def check_event_trigger_here(triggers, run = true)
  result = false
  # Æ’CÆ’xƒ“ƒgŽÀÂs’†‚ÌÂê‡
  if $game_system.map_interpreter.running?
   return result
  end
  # ‘SÆ’CÆ’xƒ“ƒg‚̃‹Â[Æ’v
  for event in $game_map.events.values
   # Æ’CÆ’xƒ“ƒg‚ÌÂÀ•W‚ƃgÆ’Å Æ’KÂ[‚ªˆê’v‚µ‚½Âê‡
   if event.x == ((@x * 128 + @revise_x) / 128.0).round and
     event.y == ((@y * 128 + @revise_y) / 128.0).round and
     triggers.include?(event.trigger)
    # Æ’Wƒƒƒ“ƒv’†ˆÈŠO‚ÅÂA‹N“®â€Â»â€™Ã¨â€šÂªâ€œÂ¯Ë†ÃŠâ€™u‚̃CÆ’xƒ“ƒg‚È‚ç
    if not event.jumping? and event.over_trigger?
     if event.list.size > 1
      if run == true
       event.start
      end
      result = true
     end
    end
   end
  end
  return result
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ÂÀ•WÂC³
 #--------------------------------------------------------------------------
 def move_on
  if @y < (@y + @revise_y / 128.0).round
   @y += 1
   @revise_y -= 128
  end
  if @x > (@x + @revise_x / 128.0).round
   @x -= 1
   @revise_x += 128
  end
  if @x < (@x + @revise_x / 128.0).round
   @x += 1
   @revise_x -= 128
  end
  if @y > (@y + @revise_y / 128.0).round
   @y -= 1
   @revise_y += 128
  end
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ Æ’AÆ’jÆ’ÂÂ[Æ’Vƒ‡ƒ“ƒAÆ’bÆ’vÆ’fÂ[Æ’g
 #--------------------------------------------------------------------------
 def anime_update
  # ˆÚ“®ŽžƒAÆ’jƒ‚ª ON ‚ÌÂê‡
  if @walk_anime
   # Æ’AÆ’jÆ’ÂÆ’JÆ’Eƒ“ƒg‚ð 1.5 ‘‚₷
   @anime_count += 1.5
  # ˆÚ“®ŽžƒAÆ’jƒ‚ª OFF ‚ÅÂA’âŽ~ŽžƒAÆ’jƒ‚ª ON ‚ÌÂê‡
  elsif @step_anime
   # Æ’AÆ’jÆ’ÂÆ’JÆ’Eƒ“ƒg‚ð 1 ‘‚₷
   @anime_count += 1
  end
  # Æ’AÆ’jÆ’ÂÆ’JÆ’Eƒ“ƒg‚ªÂÅ‘å’l‚ð’´‚¦‚½Âê‡
  # ¦ÂÅ‘å’l‚ÃÂAŠî–{’l 18 ‚©‚çˆÚ“®‘¬“x * 1 ‚ðˆø‚¢‚½’l
  if @anime_count > 18 - @move_speed * 2
   # ’âŽ~ŽžƒAÆ’jƒ‚ª OFF ‚©‚ ’âŽ~’†‚ÌÂê‡
   if not @step_anime and @stop_count > 0
    # Æ’pÆ’^Â[ƒ“‚ðƒIÆ’Å Æ’WÆ’iƒ‹‚É–ß‚·
    @pattern = @original_pattern
   # ’âŽ~ŽžƒAÆ’jƒ‚ª ON ‚Ü‚½‚à ˆÚ“®’†‚ÌÂê‡
   else
    # Æ’pÆ’^Â[ƒ“‚ðÂXÂV
    @pattern = (@pattern + 1) % 4
   end
   # Æ’AÆ’jÆ’ÂÆ’JÆ’Eƒ“ƒg‚ðƒNÆ’Å Æ’A
   @anime_count = 0
  end
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ Žw’èˆÊ’u‚Ɉړ®
 #--------------------------------------------------------------------------
 # ƒIƒŠƒWƒiƒ‹‚̃Cƒxƒ“ƒg‚ð‰ü–¼
 alias :moveto_original :moveto
 def moveto(x, y)
  # •â³ÂÀ•W‚ð‰Šú‰»
  @revise_x = 0
  @revise_y = 0
  # Æ’IÆ’Å Æ’WÆ’iƒ‹‚̃CÆ’xƒ“ƒg‚ðŒÄ‚ÑÂo‚µ
  moveto_original(x, y)
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ˆÚ“®‚µ‚½‚©‚Ç‚¤‚©‚Ìâ€Â»â€™Ã¨
 #--------------------------------------------------------------------------
 def last_move?(x, y, direction, distance)
  if direction == 2 or direction == 6
   distance *= -1
  end
  if (direction == 2 or direction == 8) and
    (y / 128.0).round != ((y - distance) / 128.0).round
   return true
  end
  if (direction == 4 or direction == 6) and
    (x / 128.0).round != ((x - distance) / 128.0).round
   return true
  end
  return false
 end
end
Â
#==============================================================================
# ¡ Game_Character (•ªŠ„’è‹` 1)
#------------------------------------------------------------------------------
# Â@Æ’Lƒƒƒ‰ƒNÆ’^Â[‚ðˆµ‚¤ƒNƒ‰ƒX‚Å‚·ÂB‚±‚̃Nƒ‰ƒX‚à Game_Player Æ’Nƒ‰ƒX‚Æ Game_Event
# Æ’Nƒ‰ƒX‚̃XÂ[Æ’pÂ[Æ’Nƒ‰ƒX‚Æ‚µ‚ÄŽg—p‚³‚ê‚Ü‚·ÂB
#==============================================================================
Â
class Game_Character
 #--------------------------------------------------------------------------
 # ÂÅ“ ‰æ–Ê X ÂÀ•W‚̎擾
 #--------------------------------------------------------------------------
 def screen_x
  # ŽÀÂÀ•W‚ƃ}Æ’bÆ’v‚Ì•\Ž¦ˆÊ’u‚©‚ç‰æ–ÊÂÀ•W‚ð‹Â‚ß‚é
  return ((@real_x - $game_map.display_x) / 4).ceil + 16
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ ‰æ–Ê Y ÂÀ•W‚̎擾
 #--------------------------------------------------------------------------
 def screen_y
  # ŽÀÂÀ•W‚ƃ}Æ’bÆ’v‚Ì•\Ž¦ˆÊ’u‚©‚ç‰æ–ÊÂÀ•W‚ð‹Â‚ß‚é
  y = ((@real_y - $game_map.display_y) / 4).ceil + 32
  # Æ’Wƒƒƒ“ƒvÆ’JÆ’Eƒ“ƒg‚ɉž‚¶‚Ä Y ÂÀ•W‚𬂳‚‚·‚é
  if @jump_count >= @jump_peak
   n = @jump_count - @jump_peak
  else
   n = @jump_peak - @jump_count
  end
  return y - (@jump_peak * @jump_peak - n * n) / 2
 end
 #--------------------------------------------------------------------------
 # ÂÅ“ Æ’tÆ’Å’Â[ƒ€ÂXÂV (ˆÚ“®)
 #--------------------------------------------------------------------------
 def update_move
  # ˆÚ“®‘¬“x‚©‚çƒ}Æ’bÆ’vÂÀ•WÅ’n‚ł̈ړ®‹——£‚ɕÊ·
  distance = 2 ** @move_speed
  if @x * 128 != @real_x and @y * 128 != @real_y and Game_Player::SLANT
   distance /= Math.sqrt(2)
  end
  # Ëœ_—ÂÂÀ•W‚ªŽÀÂÀ•W‚æ‚艺‚ÌÂê‡
  if @y * 128 > @real_y
   # ‰º‚Ɉړ®
   @real_y = [@real_y + distance, @y * 128].min
  end
  # Ëœ_—ÂÂÀ•W‚ªŽÀÂÀ•W‚æ‚趂ÌÂê‡
  if @x * 128 < @real_x
   # ¶‚Ɉړ®
   @real_x = [@real_x - distance, @x * 128].max
  end
  # Ëœ_—ÂÂÀ•W‚ªŽÀÂÀ•W‚æ‚è‰E‚ÌÂê‡
  if @x * 128 > @real_x
   # ‰E‚Ɉړ®
   @real_x = [@real_x + distance, @x * 128].min
  end
  # Ëœ_—ÂÂÀ•W‚ªŽÀÂÀ•W‚æ‚èÂã‚ÌÂê‡
  if @y * 128 < @real_y
   # Âã‚Ɉړ®
   @real_y = [@real_y - distance, @y * 128].max
  end
  # ˆÚ“®ŽžƒAÆ’jƒ‚ª ON ‚ÌÂê‡
  if @walk_anime
   # Æ’AÆ’jÆ’ÂÆ’JÆ’Eƒ“ƒg‚ð 1.5 ‘‚₷
   @anime_count += 1.5
  # ˆÚ“®ŽžƒAÆ’jƒ‚ª OFF ‚ÅÂA’âŽ~ŽžƒAÆ’jƒ‚ª ON ‚ÌÂê‡
  elsif @step_anime
   # Æ’AÆ’jÆ’ÂÆ’JÆ’Eƒ“ƒg‚ð 1 ‘‚₷
   @anime_count += 1
  end
 end
end
Â
#==============================================================================
# ¡ Game_Event
#------------------------------------------------------------------------------
# Â@Æ’CÆ’xƒ“ƒg‚ðˆµ‚¤ƒNƒ‰ƒX‚Å‚·ÂBÂðŒÂâ€Â»â€™Ã¨â€šÃ‰â€šÃ¦â€šÃ©Æ’CÆ’xƒ“ƒgÆ’yÂ[Æ’WÂØ‚è‘Ö‚¦‚âÂA•À—ñˆ—Â
# Æ’CÆ’xƒ“ƒgŽÀÂs‚È‚Ç‚Ì‹@â€\‚ðŽÂ‚Âè‚èÂAGame_Map Æ’Nƒ‰ƒX‚Ì“à •â€â€šÃ…Žg—p‚³‚ê‚Ü‚·ÂB
#==============================================================================
Â
class Game_Event < Game_Character
 #--------------------------------------------------------------------------
 # ÂÅ“ Æ’CÆ’xƒ“ƒg‹N“®
 #--------------------------------------------------------------------------
 def start
  # ŽÀÂs“à —e‚ª‹ó‚Å‚È‚¢Âê‡
  if @list.size > 1
   # $game_player.event ‚ª0‚Å‚È‚¢Âê‡
   if $game_player.event != 0
    # ˆÚ“®‘¬“x‚ð $game_player.event ‚É‚·‚é
    $game_player.move_speed = $game_player.event
   elsif self.trigger == 0
    $game_player.move_speed = $game_player.walk
   end
   @starting = true
  end
 end
end