#============================================================================== # ¡á Game_Character (ºÐÇÒ Á¤ÀÇ 1) #------------------------------------------------------------------------------ # ¡¡Ä³¸¯Å͸¦ Ãë±ÞÇϴ Ŭ·¡½ºÀÔ´Ï´Ù. ÀÌ Å¬·¡½º´Â Game_Player Ŭ·¡½º¿Í Game_Event # Ŭ·¡½ºÀÇ ½´ÆÛ Å¬·¡½º·Î¼­ »ç¿ëµË´Ï´Ù. #============================================================================== class Game_Character #-------------------------------------------------------------------------- # ¡Ü °ø°³ ÀνºÅϽº º¯¼ö #-------------------------------------------------------------------------- attr_reader :id # ID attr_reader :x # ¸Ê X ÁÂÇ¥ (³í¸® ÁÂÇ¥) attr_reader :y # ¸Ê Y ÁÂÇ¥ (³í¸® ÁÂÇ¥) attr_reader :real_x # ¸Ê X ÁÂÇ¥ (¿­¸Å ÁÂÇ¥ * 128) attr_reader :real_y # ¸Ê Y ÁÂÇ¥ (¿­¸Å ÁÂÇ¥ * 128) attr_reader :tile_id # ŸÀÏ ID (0 À̶ó¸é ¹«È¿) attr_reader :character_name # ij¸¯ÅÍ ÆÄÀϸí attr_reader :character_hue # ij¸¯ÅÍ »ö»ó attr_reader :opacity # ºÒÅõ¸íµµ attr_reader :blend_type # ÇÕ¼º ¹æ¹ý attr_reader :direction # ¹æÇâ attr_reader :pattern # ÆÐÅÏ attr_reader :move_route_forcing # À̵¿ ·çÆ® °­Á¦ Ç÷¡±× attr_reader :through # ºüÁ®³ª°¡°í attr_accessor :animation_id # ¾Ö´Ï¸ÞÀÌ¼Ç ID attr_accessor :transparent # Åõ¸í»óÅ #-------------------------------------------------------------------------- # ¡Ü ¿ÀºêÁ§Æ® ÃʱâÈ­ #-------------------------------------------------------------------------- def initialize @id = 0 @x = 0 @y = 0 @real_x = 0 @real_y = 0 @tile_id = 0 @character_name = "" @character_hue = 0 @opacity = 255 @blend_type = 0 @direction = 2 @pattern = 0 @move_route_forcing = false @through = false @animation_id = 0 @transparent = false @original_direction = 2 @original_pattern = 0 @move_type = 0 @move_speed = 4 @move_frequency = 6 @move_route = nil @move_route_index = 0 @original_move_route = nil @original_move_route_index = 0 @walk_anime = true @step_anime = false @direction_fix = false @always_on_top = false @anime_count = 0 @stop_count = 0 @jump_count = 0 @jump_peak = 0 @wait_count = 0 @locked = false @prelock_direction = 0 end #-------------------------------------------------------------------------- # ¡Ü À̵¿Áß ÆÇÁ¤ #-------------------------------------------------------------------------- def moving? # ³í¸® ÁÂÇ¥¿Í ¿­¸Å ÁÂÇ¥°¡ Â÷ÀÌ°¡ ³ª¸é À̵¿Áß return (@real_x != @x * 128 or @real_y != @y * 128) end #-------------------------------------------------------------------------- # ¡Ü Á¡ÇÁÁß ÆÇÁ¤ #-------------------------------------------------------------------------- def jumping? # Á¡ÇÁ Ä«¿îÆ®°¡ 0 º¸´Ù Å©¸é Á¡ÇÁÁß return @jump_count > 0 end #-------------------------------------------------------------------------- # ¡Ü ÀÚ¼¼ÀÇ ±³Á¤ #-------------------------------------------------------------------------- def straighten # À̵¿½Ã ¾Ö´Ï¸ÞÀÌ¼Ç ¶Ç´Â Á¤Áö½Ã ¾Ö´Ï¸ÞÀ̼ÇÀÌ ON ÀÇ °æ¿ì if @walk_anime or @step_anime # ÆÐÅÏÀ» 0 À¸·Î ¼³Á¤ @pattern = 0 end # ¾Ö´Ï¸ÞÀÌ¼Ç Ä«¿îÆ®¸¦ Ŭ¸®¾î @anime_count = 0 # ¶ôÀüÀÇ ¹æÇâÀ» Ŭ¸®¾î @prelock_direction = 0 end #-------------------------------------------------------------------------- # ¡Ü À̵¿ ·çÆ®ÀÇ °­Á¦ # move_route : »õ·Î¿î À̵¿ ·çÆ® #-------------------------------------------------------------------------- def force_move_route(move_route) # ¿À¸®Áö³¯ÀÇ À̵¿ ·çÆ®¸¦ º¸Á¸ if @original_move_route == nil @original_move_route = @move_route @original_move_route_index = @move_route_index end # À̵¿ ·çÆ®¸¦ º¯°æ @move_route = move_route @move_route_index = 0 # À̵¿ ·çÆ® °­Á¦ Ç÷¡±×¸¦ ¼¼Æ® @move_route_forcing = true # ¶ôÀüÀÇ ¹æÇâÀ» Ŭ¸®¾î @prelock_direction = 0 # ¿þÀÌÆ® Ä«¿îÆ®¸¦ Ŭ¸®¾î @wait_count = 0 # Ä¿½ºÅÒ À̵¿ move_type_custom end #-------------------------------------------------------------------------- # ¡Ü ÅëÇà °¡´É ÆÇÁ¤ # x : X ÁÂÇ¥ # y : Y ÁÂÇ¥ # d : ¹æÇâ (0,2,4,6,8) ¡Ø 0 = Àü¹æÇâ ÅëÇà ºÒ°¡ÀÇ °æ¿ì¸¦ ÆÇÁ¤ (Á¡ÇÁ¿ë) #-------------------------------------------------------------------------- def passable? (x, y, d) # »õ·Î¿î ÁÂÇ¥¸¦ ¿ä±¸ÇÑ´Ù new_x = x + (d == 6 ? 0.5 : d == 4 ? -0.5 : 0) new_y = y + (d == 2 ? 0.5 : d == 8 ? -0.5 : 0) # ÁÂÇ¥°¡ ¸Ê¿ÜÀÇ °æ¿ì unless $game_map.valid? (new_x, new_y) # ÅëÇà ºÒ°¡ return false end # ºüÁ®³ª°¡°í ON ÀÇ °æ¿ì if @through # ÅëÇà°¡´É return true end # À̵¿¿øÀÇ Å¸ÀϷκÎÅÍ ÁöÁ¤ ¹æÇâÀ¸·Î ³ª¿Ã ¼ö ¾ø´Â °æ¿ì unless $game_map.passable? (x, y, d, self) # ÅëÇà ºÒ°¡ return false end # À̵¿Ã³ÀÇ Å¸ÀÏ·Î ÁöÁ¤ ¹æÇâÀ¸·ÎºÎÅÍ ³ÖÁö ¾Ê´Â °æ¿ì unless $game_map.passable? (new_x, new_y, 10 - d) # ÅëÇà ºÒ°¡ return false end # ÀüÀ̺¥Æ®ÀÇ ·çÇÁ for event in $game_map.events.values # À̺¥Æ®ÀÇ ÁÂÇ¥°¡ À̵¿Ã³¿Í ÀÏÄ¡ÇßÀ» °æ¿ì if event.x == new_x and event.y == new_y # ºüÁ®³ª°¡°í OFF ¶ó¸é unless event.through # ÀÚ½ÅÀÌ À̺¥Æ®ÀÇ °æ¿ì if self != $game_player # ÅëÇà ºÒ°¡ return false end # ÀÚ½ÅÀÌ Ç÷¹À̾î·Î, »ó´ëÀÇ ±×·¡ÇÈÀÌ Ä³¸¯ÅÍÀÇ °æ¿ì if event.character_name != "" # ÅëÇà ºÒ°¡ return false end end end end # Ç÷¹À̾îÀÇ ÁÂÇ¥°¡ À̵¿Ã³¿Í ÀÏÄ¡ÇßÀ» °æ¿ì if $game_player.x == new_x and $game_player.y == new_y # ºüÁ®³ª°¡°í OFF ¶ó¸é unless $game_player.through # ÀÚ½ÅÀÇ ±×·¡ÇÈÀÌ Ä³¸¯ÅÍÀÇ °æ¿ì if @character_name != "" # ÅëÇà ºÒ°¡ return false end end end # ÅëÇà°¡´É return true end #-------------------------------------------------------------------------- # ¡Ü ¶ô #-------------------------------------------------------------------------- def lock # ¹ú½á ¶ô µÇ°í ÀÖ´Â °æ¿ì if @locked # ¸Þ¼Òµå Á¾·á return end # ¶ôÀüÀÇ ¹æÇâÀ» º¸Á¸ @prelock_direction = @direction # Ç÷¹À̾îÀÇ ºÐÀ» ÇâÇÑ´Ù turn_toward_player # ¶ôÁß Ç÷¡±×¸¦ ¼¼Æ® @locked = true end #-------------------------------------------------------------------------- # ¡Ü ¶ôÁß ÆÇÁ¤ #-------------------------------------------------------------------------- def lock? return @locked end #-------------------------------------------------------------------------- # ¡Ü ¶ô ÇØÁ¦ #-------------------------------------------------------------------------- def unlock # ¶ôµÇ¾î ÀÖÁö ¾ÊÀº °æ¿ì unless @locked # ¸Þ¼Òµå Á¾·á return end # ¶ôÁß Ç÷¡±×¸¦ Ŭ¸®¾î @locked = false # ¹æÇâ °íÁ¤ÀÌ ¾Æ´Ñ °æ¿ì unless @direction_fix # ¶ôÀüÀÇ ¹æÇâÀÌ º¸Á¸µÇ°í ÀÖÀ¸¸é if @prelock_direction != 0 # ¶ôÀüÀÇ ¹æÇâÀ» º¹±Í @direction = @prelock_direction end end end #-------------------------------------------------------------------------- # ¡Ü ÁöÁ¤ À§Ä¡¿¡ À̵¿ # x : X ÁÂÇ¥ # y : Y ÁÂÇ¥ #-------------------------------------------------------------------------- def moveto(x, y) @x = x @y = y @real_x = x * 128 @real_y = y * 128 end #-------------------------------------------------------------------------- # ¡Ü È­¸é X ÁÂÇ¥ÀÇ Ãëµæ #-------------------------------------------------------------------------- def screen_x # ¿­¸Å ÁÂÇ¥¿Í ¸ÊÀÇ Ç¥½Ã À§Ä¡¿¡¼­ È­¸é ÁÂÇ¥¸¦ ¿ä±¸ÇÑ´Ù return (@real_x - $game_map.display_x) / 4 + 16 end #-------------------------------------------------------------------------- # ¡Ü È­¸é Y ÁÂÇ¥ÀÇ Ãëµæ #-------------------------------------------------------------------------- def screen_y # ¿­¸Å ÁÂÇ¥¿Í ¸ÊÀÇ Ç¥½Ã À§Ä¡¿¡¼­ È­¸é ÁÂÇ¥¸¦ ¿ä±¸ÇÑ´Ù y = (@real_y - $game_map.display_y) / 4 + 32 # Á¡ÇÁ Ä«¿îÆ®¿¡ ÀÀÇØ Y ÁÂÇ¥¸¦ ÀÛ°Ô ÇÑ´Ù 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 #-------------------------------------------------------------------------- # ¡Ü È­¸é Z ÁÂÇ¥ÀÇ Ãëµæ # height : ij¸¯ÅÍÀÇ ³ôÀÌ #-------------------------------------------------------------------------- def screen_z(height = 0) # ¸Ç ¾Õ¸é¿¡ Ç¥½Ã Ç÷¡±×°¡ ON ÀÇ °æ¿ì if @always_on_top # ¹«Á¶°Ç 999 return 999 end # ¿­¸Å ÁÂÇ¥¿Í ¸ÊÀÇ Ç¥½Ã À§Ä¡¿¡¼­ È­¸é ÁÂÇ¥¸¦ ¿ä±¸ÇÑ´Ù z = (@real_y - $game_map.display_y) / 4 if @real_y % 128 > 0 z += (131 - @real_y % 128) / 4 end # ŸÀÏÀÇ °æ¿ì if @tile_id > 0 # ŸÀÏÀÇ priority * 32 ¸¦ ´õÇÑ´Ù return z + $game_map.priorities[@tile_id] * 32 # ij¸¯ÅÍÀÇ °æ¿ì else # ³ôÀÌ°¡ 32 ¸¦ ³Ñ°í ÀÖÀ¸¸é 31 À» ´õÇÑ´Ù return z + ((height > 32) ? 31 : 0) end end #-------------------------------------------------------------------------- # ¡Ü ¼öÇ® ±íÀÌÀÇ Ãëµæ #-------------------------------------------------------------------------- def bush_depth # ŸÀÏÀÇ °æ¿ì, ¶Ç´Â ¸Ç ¾Õ¸é¿¡ Ç¥½Ã Ç÷¡±×°¡ ON ÀÇ °æ¿ì if @tile_id > 0 or @always_on_top return 0 end # Á¡ÇÁÁß ÀÌ¿Ü·Î ¼öÇ® ¼Ó¼ºÀÇ Å¸ÀÏÀ̶ó¸é 12, ±× À̿ܶó¸é 0 if @jump_count == 0 and $game_map.bush? (@x, @y) return 12 else return 0 end end #-------------------------------------------------------------------------- # ¡Ü ÁöÇü ű×ÀÇ Ãëµæ #-------------------------------------------------------------------------- def terrain_tag return $game_map.terrain_tag(@x, @y) end end