#============================================================================== # ¡á Game_Player #------------------------------------------------------------------------------ # ¡¡Ç÷¹À̾ Ãë±ÞÇϴ Ŭ·¡½ºÀÔ´Ï´Ù. À̺¥Æ®ÀÇ ±âµ¿ ÆÇÁ¤À̳ª, ¸ÊÀÇ ½ºÅ©·ÑµîÀÇ # ±â´ÉÀ» °¡Áö°í ÀÖ½À´Ï´Ù. ÀÌ Å¬·¡½ºÀÇ ÀνºÅϽº´Â $game_player ·Î ÂüÁ¶µË´Ï´Ù. #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # ¡Ü Á¤¼ö #-------------------------------------------------------------------------- CENTER_X = (320 - 16) * 4 # È­¸é Áß¾ÓÀÇ X ÁÂÇ¥ * 4 CENTER_Y = (240 - 16) * 4 # È­¸é Áß¾ÓÀÇ Y ÁÂÇ¥ * 4 #-------------------------------------------------------------------------- # ¡Ü ÅëÇà °¡´É ÆÇÁ¤ # x : X ÁÂÇ¥ # y : Y ÁÂÇ¥ # d : ¹æÇâ (0,2,4,6,8) ¡Ø 0 = Àü¹æÇâ ÅëÇà ºÒ°¡ÀÇ °æ¿ì¸¦ ÆÇÁ¤ (Á¡ÇÁ¿ë) #-------------------------------------------------------------------------- def passable? (x, y, d) # »õ·Î¿î ÁÂÇ¥¸¦ ¿ä±¸ÇÑ´Ù new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0) new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0) # ÁÂÇ¥°¡ ¸Ê¿ÜÀÇ °æ¿ì unless $game_map.valid? (new_x, new_y) # ÅëÇà ºÒ°¡ return false end # µð¹ö±× ¸ðµå°¡ ON ¶ÇÇÑ CTRL Å°°¡ ¹Ð¸®°í ÀÖ´Â °æ¿ì if $DEBUG and Input.press? (Input::CTRL) # ÅëÇà°¡´É return true end super end #-------------------------------------------------------------------------- # ¡Ü È­¸é Áß¾Ó¿¡ ¿Àµµ·Ï(µíÀÌ) ¸ÊÀÇ Ç¥½Ã À§Ä¡¸¦ ¼³Á¤ #-------------------------------------------------------------------------- def center(x, y) max_x = ($game_map.width - 20) * 128 max_y = ($game_map.height - 15) * 128 $game_map.display_x = [0, [x * 128 - CENTER_X, max_x]. min]. max $game_map.display_y = [0, [y * 128 - CENTER_Y, max_y]. min]. max end #-------------------------------------------------------------------------- # ¡Ü ÁöÁ¤ À§Ä¡¿¡ À̵¿ # x : X ÁÂÇ¥ # y : Y ÁÂÇ¥ #-------------------------------------------------------------------------- def moveto(x, y) super # ¼¾Å͸µ center(x, y) # ¿£Ä«¿îƮī¿îÆ®¸¦ ÀÛ¼º make_encounter_count end #-------------------------------------------------------------------------- # ¡Ü º¸¼ö Áõ°¡ #-------------------------------------------------------------------------- def increase_steps super # À̵¿ ·çÆ® °­Á¦ÁßÀÌ ¾Æ´Ñ °æ¿ì unless @move_route_forcing # º¸¼ö Áõ°¡ $game_party.increase_steps # º¸¼ö°¡ ¦¼öÀÇ °æ¿ì if $game_party.steps % 2 == 0 # ½½¸³ µ¥¹ÌÁö üũ $game_party.check_map_slip_damage end end end #-------------------------------------------------------------------------- # ¡Ü ¿£Ä«¿îƮī¿îÆ® Ãëµæ #-------------------------------------------------------------------------- def encounter_count return @encounter_count end #-------------------------------------------------------------------------- # ¡Ü ¿£Ä«¿îƮī¿îÆ® ÀÛ¼º #-------------------------------------------------------------------------- def make_encounter_count # ÁÖ»çÀ§¸¦ 2 °³ °ÅÀýÇÏ´Â À̹ÌÁö n = $game_map.encounter_step @encounter_count = rand(n) + rand(n) + 1 end #-------------------------------------------------------------------------- # ¡Ü ¸®ÇÁ·¹½¬ #-------------------------------------------------------------------------- def refresh # ÆÄƼ Àοø¼ö°¡ 0 ¸íÀÇ °æ¿ì if $game_party.actors.size == 0 # ij¸¯ÅÍÀÇ ÆÄÀϸí°ú »ö»óÀ» Ŭ¸®¾î @character_name = "" @character_hue = 0 # ¸Þ¼Òµå Á¾·á return end # ¼±µÎÀÇ ¿¢Å͸¦ Ãëµæ actor = $game_party.actors[0] # ij¸¯ÅÍÀÇ ÆÄÀϸí°ú »ö»óÀ» ¼³Á¤ @character_name = actor.character_name @character_hue = actor.character_hue # ºÒÅõ¸íµµ¿Í ÇÕ¼º ¹æ¹ýÀ» ÃʱâÈ­ @opacity = 255 @blend_type = 0 end #-------------------------------------------------------------------------- # ¡Ü µ¿À§Ä¡ÀÇ À̺¥Æ® ±âµ¿ ÆÇÁ¤ #-------------------------------------------------------------------------- def check_event_trigger_here(triggers) result = false # À̺¥Æ® ½ÇÇàÁßÀÇ °æ¿ì if $game_system.map_interpreter.running? return result end # ÀüÀ̺¥Æ®ÀÇ ·çÇÁ for event in $game_map.events.values # À̺¥Æ®ÀÇ ÁÂÇ¥¿Í Æ®¸®°Å°¡ ÀÏÄ¡ÇßÀ» °æ¿ì if event.x == @x and event.y == @y and triggers.include? (event.trigger) # ±âµ¿ ÆÇÁ¤ÀÌ µ¿À§Ä¡ÀÇ À̺¥Æ®¶ó¸é if event.over_trigger? event.start result = true end end end return result end #-------------------------------------------------------------------------- # ¡Ü Á¤¸éÀÇ À̺¥Æ® ±âµ¿ ÆÇÁ¤ #-------------------------------------------------------------------------- def check_event_trigger_there(triggers) result = false # À̺¥Æ® ½ÇÇàÁßÀÇ °æ¿ì if $game_system.map_interpreter.running? return result end # Á¤¸éÀÇ ÁÂÇ¥¸¦ °è»ê new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0) new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0) # ÀüÀ̺¥Æ®ÀÇ ·çÇÁ for event in $game_map.events.values # À̺¥Æ®ÀÇ ÁÂÇ¥¿Í Æ®¸®°Å°¡ ÀÏÄ¡ÇßÀ» °æ¿ì if event.x == new_x and event.y == new_y and triggers.include? (event.trigger) # ±âµ¿ ÆÇÁ¤ÀÌ Á¤¸éÀÇ À̺¥Æ®¶ó¸é unless event.over_trigger? event.start result = true end end end # ÇØ´çÇÏ´Â À̺¥Æ®°¡ ¹ß°ßµÇÁö ¾Ê¾Ò´ø °æ¿ì if result == false # Á¤¸éÀÇ Å¸ÀÏÀÌ Ä«¿îÅͶó¸é if $game_map.counter? (new_x, new_y) # 1 ŸÀϾÈÂÊÀÇ ÁÂÇ¥¸¦ °è»ê new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0) new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0) # ÀüÀ̺¥Æ®ÀÇ ·çÇÁ for event in $game_map.events.values # À̺¥Æ®ÀÇ ÁÂÇ¥¿Í Æ®¸®°Å°¡ ÀÏÄ¡ÇßÀ» °æ¿ì if event.x == new_x and event.y == new_y and triggers.include? (event.trigger) # ±âµ¿ ÆÇÁ¤ÀÌ Á¤¸éÀÇ À̺¥Æ®¶ó¸é unless event.over_trigger? event.start result = true end end end end end return result end #-------------------------------------------------------------------------- # ¡Ü Á¢ÃË À̺¥Æ®ÀÇ ±âµ¿ ÆÇÁ¤ #-------------------------------------------------------------------------- def check_event_trigger_touch(x, y) result = false # À̺¥Æ® ½ÇÇàÁßÀÇ °æ¿ì if $game_system.map_interpreter.running? return result end # ÀüÀ̺¥Æ®ÀÇ ·çÇÁ for event in $game_map.events.values # À̺¥Æ®ÀÇ ÁÂÇ¥¿Í Æ®¸®°Å°¡ ÀÏÄ¡ÇßÀ» °æ¿ì if event.x == x and event.y == y and [1,2]. include? (event.trigger) # ±âµ¿ ÆÇÁ¤ÀÌ Á¤¸éÀÇ À̺¥Æ®¶ó¸é unless event.over_trigger? event.start result = true end end end return result end #-------------------------------------------------------------------------- # ¡Ü ÇÁ·¹ÀÓ °»½Å #-------------------------------------------------------------------------- def update # ·ÎÄà º¯¼ö¿¡ À̵¿ÁßÀΰ¡ ¾î¶²°¡¸¦ ±â¾ï last_moving = moving? # À̵¿Áß, À̺¥Æ® ½ÇÇàÁß, À̵¿ ·çÆ® °­Á¦Áß, # ¸Þ¼¼Áö À©µµ¿ì Ç¥½ÃÁßÀÇ ¸ÓÁö¾Ê¾Æµµ ¾Æ´Ñ °æ¿ì unless moving? or $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing # ¹æÇâ ¹öÆ°ÀÌ ¹Ð¸®°í ÀÖÀ¸¸é, ±× ¹æÇâ¿¡ Ç÷¹À̾ À̵¿ # ========================================================================== # ¹æÇâÀ» º¸Á¸ direction = @direction case Input.dir8 when 1 # ÁÂÇÏ move_left move_down # ¹æÇâ °íÁ¤ÀÌ ¾Æ´Ñ °æ¿ì unless @direction_fix # ¿À¸¥ÂÊ ¹æÇâÀ̾ú´ø °æ¿ì´Â ¿ÞÂÊÀ» , ¿À¸§»õ¿´´ø °æ¿ì´Â ¾Æ·¡¸¦ ÇâÇÏ´Â @direction = (direction == 6 ? 4 : direction == 8 ? 2 : direction) end when 2 # ÇÏ move_down when 3 # ¿ìÇÏ move_down move_right # ¹æÇâ °íÁ¤ÀÌ ¾Æ´Ñ °æ¿ì unless @direction_fix # ÁÂÇâÀ̾ú´ø °æ¿ì´Â ¿À¸¥ÂÊÀ» , ¿À¸§»õ¿´´ø °æ¿ì´Â ¾Æ·¡¸¦ ÇâÇÏ´Â @direction = (direction == 4 ? 6 : direction == 8 ? 2 : direction) end when 4 # Á move_left when 6 # ¿ì move_right when 7 # Á»ó move_up move_left # ¹æÇâ °íÁ¤ÀÌ ¾Æ´Ñ °æ¿ì unless @direction_fix # ¿À¸¥ÂÊ ¹æÇâÀ̾ú´ø °æ¿ì´Â ¿ÞÂÊÀ» , ÇÏÇâÀ̾ú´ø °æ¿ì´Â À§¸¦ ÇâÇÏ´Â @direction = (direction == 6 ? 4 : direction == 2 ? 8 : direction) end when 8 # »ó move_up when 9 # ¿ì»ó move_right move_up # ¹æÇâ °íÁ¤ÀÌ ¾Æ´Ñ °æ¿ì unless @direction_fix # ÁÂÇâÀ̾ú´ø °æ¿ì´Â ¿À¸¥ÂÊÀ» , ÇÏÇâÀ̾ú´ø °æ¿ì´Â À§¸¦ ÇâÇÏ´Â @direction = (direction == 4 ? 6 : direction == 2 ? 8 : direction) end end # ========================================================================== end # ·ÎÄà º¯¼ö¿¡ ÁÂÇ¥¸¦ ±â¾ï last_real_x = @real_x last_real_y = @real_y super # ij¸¯ÅÍ°¡ ¾Æ·¡·Î À̵¿ÇØ, ÇÑÆí È­¸é»óÀÇ À§Ä¡°¡ Áß¾Ó¿¡¼­(º¸´Ù) ¾Æ·¡ÀÇ °æ¿ì if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y # ¸ÊÀ» ¾Æ·¡¿¡ ½ºÅ©·Ñ $game_map.scroll_down(@real_y - last_real_y) end # ij¸¯ÅÍ°¡ ¿ÞÂÊÀ¸·Î À̵¿ÇØ, ÇÑÆí È­¸é»óÀÇ À§Ä¡°¡ Áß¾Ó¿¡¼­(º¸´Ù) ¿ÞÂÊÀÇ °æ¿ì if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X # ¸ÊÀ» ¿ÞÂÊÀ¸·Î ½ºÅ©·Ñ $game_map.scroll_left(last_real_x - @real_x) end # ij¸¯ÅÍ°¡ ¿À¸¥ÂÊÀ¸·Î À̵¿ÇØ, ÇÑÆí È­¸é»óÀÇ À§Ä¡°¡ Áß¾Ó¿¡¼­(º¸´Ù) ¿À¸¥ÂÊÀÇ °æ¿ì if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X # ¸ÊÀ» ¿À¸¥ÂÊÀ¸·Î ½ºÅ©·Ñ $game_map.scroll_right(@real_x - last_real_x) end # ij¸¯ÅÍ°¡ À§·Î À̵¿ÇØ, ÇÑÆí È­¸é»óÀÇ À§Ä¡°¡ Áß¾Ó¿¡¼­(º¸´Ù) À§ÀÇ °æ¿ì if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y # ¸ÊÀ» À§¿¡ ½ºÅ©·Ñ $game_map.scroll_up(last_real_y - @real_y) end # À̵¿ÁßÀÌ ¾Æ´Ñ °æ¿ì unless moving? # Àüȸ Ç÷¹À̾ À̵¿ÁßÀ̾ú´ø °æ¿ì if last_moving # µ¿À§Ä¡ÀÇ À̺¥Æ®¿ÍÀÇ Á¢ÃË¿¡ ÀÇÇÑ À̺¥Æ® ±âµ¿ ÆÇÁ¤ result = check_event_trigger_here([1,2]) # ±âµ¿ÇÑ À̺¥Æ®°¡ ¾ø´Â °æ¿ì if result == false # µð¹ö±× ¸ðµå°¡ ON ¶ÇÇÑ CTRL Å°°¡ ¹Ð¸®°í ÀÖ´Â °æ¿ì¸¦ Á¦¿ÜÇØ unless $DEBUG and Input.press? (Input::CTRL) # ¿£Ä«¿îƮī¿îÆ®´Ù¿î if @encounter_count > 0 @encounter_count -= 1 end end end end # C ¹öÆ°ÀÌ ¹Ð·ÈÀ» °æ¿ì if Input.trigger? (Input::C) # µ¿À§Ä¡ ¹× Á¤¸éÀÇ À̺¥Æ® ±âµ¿ ÆÇÁ¤ check_event_trigger_here([0]) check_event_trigger_there([0,1,2]) end end end end