Auteur: Yukihiro matsumoto
#============================================
# ¡ 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
#------------------------------------------
# œ ŒöŠJƒCƒ“ƒXƒ^ƒ“ƒX•Ï”
#------------------------------------------
attr_reader :id # ID
attr_reader :x # ƒ}ƒbƒv X À•W (˜_—À•W)
attr_reader :y # ƒ}ƒbƒv Y À•W (˜_—À•W)
attr_reader :real_x # ƒ}ƒbƒv X À•W (ŽÀÀ•W * 128)
attr_reader :real_y # ƒ}ƒbƒv Y À•W (ŽÀÀ•W * 128)
attr_reader :tile_id # ƒ^ƒCƒ‹ ID (0 ‚È‚ç–³Œø)
attr_reader :character_name # ƒLƒƒƒ‰ƒNƒ^[ ƒtƒ@ƒCƒ‹–¼
attr_reader :character_hue # ƒLƒƒƒ‰ƒNƒ^[ F‘Š
attr_reader :opacity # •s“§–¾“x
attr_reader :blend_type # ‡¬•û–@
attr_reader :direction # Œü‚«
attr_reader :pattern # ƒpƒ^[ƒ“
attr_reader :move_route_forcing # ˆÚ“®ƒ‹[ƒg‹§ƒtƒ‰ƒO
attr_reader :through # ‚·‚蔲‚¯
attr_accessor :animation_id # ƒAƒjƒ[ƒVƒ‡ƒ“ ID
attr_accessor :transparent # “§–¾ó‘Ô
attr_accessor :move_speed
#------------------------------------------
# œ ƒIƒuƒWƒFƒNƒg‰Šú‰»
#------------------------------------------
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?
# ˜_—À•W‚ÆŽÀÀ•W‚ªˆá‚Á‚Ä‚¢‚ê‚Έړ®’†
return (@real_x != @x * 128 or @real_y != @y * 128)
end
#------------------------------------------
# œ ƒWƒƒƒ“ƒv’†”»’è
#------------------------------------------
def jumping?
# ƒWƒƒƒ“ƒvƒJƒEƒ“ƒg‚ª 0 ‚æ‚è‘å‚«‚¯‚ê‚΃Wƒƒƒ“ƒv’†
return @jump_count > 0
end
#------------------------------------------
# œ Žp¨‚Ì‹¸³
#------------------------------------------
def straighten
# ˆÚ“®ŽžƒAƒjƒ‚Ü‚½‚Í’âŽ~ŽžƒAƒjƒ‚ª ON ‚Ìê‡
if @walk_anime or @step_anime
# ƒpƒ^[ƒ“‚ð 0 ‚ÉÝ’è
@pattern = 0
end
# ƒAƒjƒƒJƒEƒ“ƒg‚ðƒNƒŠƒA
@anime_count = 0
# ƒƒbƒN‘O‚ÌŒü‚«‚ðƒNƒŠƒA
@prelock_direction = 0
end
#------------------------------------------
# œ ˆÚ“®ƒ‹[ƒg‚Ì‹§
# move_route : V‚µ‚¢ˆÚ“®ƒ‹[ƒg
#------------------------------------------
def force_move_route(move_route)
# ƒIƒŠƒWƒiƒ‹‚̈ړ®ƒ‹[ƒg‚ð•Û‘¶
if @original_move_route == nil
@original_move_route = @move_route
@original_move_route_index = @move_route_index
end
# ˆÚ“®ƒ‹[ƒg‚ð•ÏX
@move_route = move_route
@move_route_index = 0
# ˆÚ“®ƒ‹[ƒg‹§ƒtƒ‰ƒO‚ðƒZƒbƒg
@move_route_forcing = true
# ƒƒbƒN‘O‚ÌŒü‚«‚ðƒNƒŠƒA
@prelock_direction = 0
# ƒEƒFƒCƒgƒJƒEƒ“ƒg‚ðƒNƒŠƒA
@wait_count = 0
# ƒJƒXƒ^ƒ€ˆÚ“®
move_type_custom
end
#------------------------------------------
# œ ’Ês‰Â””»’è
# x : X À•W
# y : Y À•W
# d : •ûŒü (0,2,4,6,8) ¦ 0 = ‘S•ûŒü’Ês•s‰Â‚Ìꇂ𔻒è (ƒWƒƒƒ“ƒv—p)
#------------------------------------------
def passable?(x, y, d)
# V‚µ‚¢À•W‚ð‹‚ß‚é
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
# À•W‚ªƒ}ƒbƒvŠO‚Ìê‡
unless $game_map.valid?(new_x, new_y)
# ’Ês•s‰Â
return false
end
# ‚·‚蔲‚¯ ON ‚Ìê‡
if @through
# ’Ês‰Â
return true
end
# ˆÚ“®Œ³‚̃^ƒCƒ‹‚©‚çŽw’è•ûŒü‚Éo‚ç‚ê‚È‚¢ê‡
unless $game_map.passable?(x, y, d, self)
# ’Ês•s‰Â
return false
end
# ˆÚ“®æ‚̃^ƒCƒ‹‚ÉŽw’è•ûŒü‚©‚ç“ü‚ê‚È‚¢ê‡
unless $game_map.passable?(new_x, new_y, 10 - d)
# ’Ês•s‰Â
return false
end
# ‘SƒCƒxƒ“ƒg‚̃‹[ƒv
for event in $game_map.events.values
# ƒCƒxƒ“ƒg‚ÌÀ•W‚ªˆÚ“®æ‚ƈê’v‚µ‚½ê‡
if event.x == new_x and event.y == new_y
# ‚·‚蔲‚¯ OFF ‚È‚ç
unless event.through
# Ž©•ª‚ªƒCƒxƒ“ƒg‚Ìê‡
if self != $game_player
# ’Ês•s‰Â
return false
end
# Ž©•ª‚ªƒvƒŒƒCƒ„[‚ÅA‘ŠŽè‚̃Oƒ‰ƒtƒBƒbƒN‚ªƒLƒƒƒ‰ƒNƒ^[‚Ìê‡
if event.character_name != ""
# ’Ês•s‰Â
return false
end
end
end
end
# ƒvƒŒƒCƒ„[‚ÌÀ•W‚ªˆÚ“®æ‚ƈê’v‚µ‚½ê‡
if $game_player.x == new_x and $game_player.y == new_y
# ‚·‚蔲‚¯ OFF ‚È‚ç
unless $game_player.through
# Ž©•ª‚̃Oƒ‰ƒtƒBƒbƒN‚ªƒLƒƒƒ‰ƒNƒ^[‚Ìê‡
if @character_name != ""
# ’Ês•s‰Â
return false
end
end
end
# ’Ês‰Â
return true
end
#------------------------------------------
# œ ƒƒbƒN
#------------------------------------------
def lock
# ‚·‚łɃƒbƒN‚³‚ê‚Ä‚¢‚éê‡
if @locked
# ƒƒƒbƒhI—¹
return
end
# ƒƒbƒN‘O‚ÌŒü‚«‚ð•Û‘¶
@prelock_direction = @direction
# ƒvƒŒƒCƒ„[‚Ì•û‚ðŒü‚
turn_toward_player
# ƒƒbƒN’†ƒtƒ‰ƒO‚ðƒZƒbƒg
@locked = true
end
#------------------------------------------
# œ ƒƒbƒN’†”»’è
#------------------------------------------
def lock?
return @locked
end
#------------------------------------------
# œ ƒƒbƒN‰ðœ
#------------------------------------------
def unlock
# ƒƒbƒN‚³‚ê‚Ä‚¢‚È‚¢ê‡
unless @locked
# ƒƒƒbƒhI—¹
return
end
# ƒƒbƒN’†ƒtƒ‰ƒO‚ðƒNƒŠƒA
@locked = false
# Œü‚«ŒÅ’è‚Å‚È‚¢ê‡
unless @direction_fix
# ƒƒbƒN‘O‚ÌŒü‚«‚ª•Û‘¶‚³‚ê‚Ä‚¢‚ê‚Î
if @prelock_direction != 0
# ƒƒbƒN‘O‚ÌŒü‚«‚𕜋A
@direction = @prelock_direction
end
end
end
#------------------------------------------
# œ Žw’èˆÊ’u‚Ɉړ®
# x : X À•W
# y : Y À•W
#------------------------------------------
def moveto(x, y)
@x = x % $game_map.width
@y = y % $game_map.height
@real_x = @x * 128
@real_y = @y * 128
@prelock_direction = 0
end
#------------------------------------------
# œ ‰æ–Ê X À•W‚̎擾
#------------------------------------------
def screen_x
# ŽÀÀ•W‚ƃ}ƒbƒv‚Ì•Ž¦ˆÊ’u‚©‚ç‰æ–ÊÀ•W‚ð‹‚ß‚é
return (@real_x - $game_map.display_x + 3) / 4 + 16
end
#------------------------------------------
# œ ‰æ–Ê Y À•W‚̎擾
#------------------------------------------
def screen_y
# ŽÀÀ•W‚ƃ}ƒbƒv‚Ì•Ž¦ˆÊ’u‚©‚ç‰æ–ÊÀ•W‚ð‹‚ß‚é
y = (@real_y - $game_map.display_y + 3) / 4 + 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
#------------------------------------------
# œ ‰æ–Ê Z À•W‚̎擾
# height : ƒLƒƒƒ‰ƒNƒ^[‚Ì‚‚³
#------------------------------------------
def screen_z(height = 0)
# Å‘O–Ê‚É•Ž¦ƒtƒ‰ƒO‚ª ON ‚Ìê‡
if @always_on_top
# –³ðŒ‚É 999
return 999
end
# ŽÀÀ•W‚ƃ}ƒbƒv‚Ì•Ž¦ˆÊ’u‚©‚ç‰æ–ÊÀ•W‚ð‹‚ß‚é
z = (@real_y - $game_map.display_y + 3) / 4 + 32
# ƒ^ƒCƒ‹‚Ìê‡
if @tile_id > 0
# ƒ^ƒCƒ‹‚̃vƒ‰ƒCƒIƒŠƒeƒB * 32 ‚ð‘«‚·
return z + $game_map.priorities[@tile_id] * 32
# ƒLƒƒƒ‰ƒNƒ^[‚Ìê‡
else
# ‚‚³‚ª 32 ‚ð’´‚¦‚Ä‚¢‚ê‚Î 31 ‚ð‘«‚·
return z + ((height > 32) ? 31 : 0)
end
end
#------------------------------------------
# œ –΂Ý[‚³‚̎擾
#------------------------------------------
def bush_depth
# ƒ^ƒCƒ‹‚Ìê‡A‚Ü‚½‚ÍÅ‘O–Ê‚É•Ž¦ƒtƒ‰ƒO‚ª ON ‚Ìê‡
if @tile_id > 0 or @always_on_top
return 0
end
# ƒWƒƒƒ“ƒv’†ˆÈŠO‚Ŗ΂ݑ®«‚̃^ƒCƒ‹‚È‚ç 12A‚»‚êˆÈŠO‚È‚ç 0
if @jump_count == 0 and $game_map.bush?(@x, @y)
return 12
else
return 0
end
end
#------------------------------------------
# œ ’nŒ`ƒ^ƒO‚̎擾
#------------------------------------------
def terrain_tag
return $game_map.terrain_tag(@x, @y)
end
end |
|