Auteur: Yukihiro matsumoto
#============================================
# ¡ 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
#------------------------------------------
# œ ’è”
#------------------------------------------
CENTER_X = (320 - 16) * 4 # ‰æ–Ê’†‰›‚Ì X À•W * 4
CENTER_Y = (240 - 16) * 4 # ‰æ–Ê’†‰›‚Ì Y À•W * 4
#------------------------------------------
# œ ’Ê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
# ƒfƒoƒbƒOƒ‚[ƒh‚ª ON ‚©‚ CTRL ƒL[‚ª‰Ÿ‚³‚ê‚Ä‚¢‚éê‡
if $DEBUG and Input.press?(Input::CTRL)
# ’Ês‰Â
return true
end
super
end
#------------------------------------------
# œ ‰æ–Ê’†‰›‚É—ˆ‚邿‚¤‚Ƀ}ƒbƒv‚Ì•Ž¦ˆÊ’u‚ðÝ’è
#------------------------------------------
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
#------------------------------------------
# œ Žw’èˆÊ’u‚Ɉړ®
# x : X ˥W
# y : Y ˥W
#------------------------------------------
def moveto(x, y)
super
# ƒZƒ“ƒ^ƒŠƒ“ƒO
center(x, y)
# ƒGƒ“ƒJƒEƒ“ƒg ƒJƒEƒ“ƒg‚ðì¬
make_encounter_count
end
#------------------------------------------
# œ •à”‘‰Á
#------------------------------------------
def increase_steps
super
# ˆÚ“®ƒ‹[ƒg‹§’†‚ł͂Ȃ¢ê‡
unless @move_route_forcing
# •à”‘‰Á
$game_party.increase_steps
# •à”‚ª‹ô”‚Ìê‡
if $game_party.steps % 2 == 0
# ƒXƒŠƒbƒvƒ_ƒ[ƒWƒ`ƒFƒbƒN
$game_party.check_map_slip_damage
end
end
end
#------------------------------------------
# œ ƒGƒ“ƒJƒEƒ“ƒg ƒJƒEƒ“ƒgŽæ“¾
#------------------------------------------
def encounter_count
return @encounter_count
end
#------------------------------------------
# œ ƒGƒ“ƒJƒEƒ“ƒg ƒJƒEƒ“ƒgì¬
#------------------------------------------
def make_encounter_count
# ƒTƒCƒRƒ‚ð 2 ŒÂU‚éƒCƒ[ƒW
if $game_map.map_id != 0
n = $game_map.encounter_step
@encounter_count = rand(n) + rand(n) + 1
end
end
#------------------------------------------
# œ ƒŠƒtƒŒƒbƒVƒ…
#------------------------------------------
def refresh
# ƒp[ƒeƒBl”‚ª 0 l‚Ìê‡
if $game_party.actors.size == 0
# ƒLƒƒƒ‰ƒNƒ^[‚̃tƒ@ƒCƒ‹–¼‚ÆF‘Š‚ðƒNƒŠƒA
@character_name = ""
@character_hue = 0
# ƒƒƒbƒhI—¹
return
end
# 擪‚̃AƒNƒ^[‚ðŽæ“¾
actor = $game_party.actors[0]
# ƒLƒƒƒ‰ƒNƒ^[‚̃tƒ@ƒCƒ‹–¼‚ÆF‘Š‚ðÝ’è
@character_name = actor.character_name
@character_hue = actor.character_hue
# •s“§–¾“x‚Ƈ¬•û–@‚ð‰Šú‰»
@opacity = 255
@blend_type = 0
end
#------------------------------------------
# œ “¯ˆÊ’u‚̃Cƒxƒ“ƒg‹N“®”»’è
#------------------------------------------
def check_event_trigger_here(triggers)
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 and event.y == @y and triggers.include?(event.trigger)
# ƒWƒƒƒ“ƒv’†ˆÈŠO‚ÅA‹N“®”»’肪“¯ˆÊ’u‚̃Cƒxƒ“ƒg‚È‚ç
if not event.jumping? and event.over_trigger?
event.start
result = true
end
end
end
return result
end
#------------------------------------------
# œ ³–ʂ̃Cƒxƒ“ƒg‹N“®”»’è
#------------------------------------------
def check_event_trigger_there(triggers)
result = false
# ƒCƒxƒ“ƒgŽÀs’†‚Ìê‡
if $game_system.map_interpreter.running?
return result
end
# ³–Ê‚ÌÀ•W‚ðŒvŽZ
new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# ‘SƒCƒxƒ“ƒg‚̃‹[ƒv
for event in $game_map.events.values
# ƒCƒxƒ“ƒg‚ÌÀ•W‚ƃgƒŠƒK[‚ªˆê’v‚µ‚½ê‡
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
# ƒWƒƒƒ“ƒv’†ˆÈŠO‚ÅA‹N“®”»’肪³–ʂ̃Cƒxƒ“ƒg‚È‚ç
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
# ŠY“–‚·‚éƒCƒxƒ“ƒg‚ªŒ©‚‚©‚ç‚È‚©‚Á‚½ê‡
if result == false
# ³–ʂ̃^ƒCƒ‹‚ªƒJƒEƒ“ƒ^[‚È‚ç
if $game_map.counter?(new_x, new_y)
# 1 ƒ^ƒCƒ‹‰œ‚ÌÀ•W‚ðŒvŽZ
new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# ‘SƒCƒxƒ“ƒg‚̃‹[ƒv
for event in $game_map.events.values
# ƒCƒxƒ“ƒg‚ÌÀ•W‚ƃgƒŠƒK[‚ªˆê’v‚µ‚½ê‡
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
# ƒWƒƒƒ“ƒv’†ˆÈŠO‚ÅA‹N“®”»’肪³–ʂ̃Cƒxƒ“ƒg‚È‚ç
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
end
end
return result
end
#------------------------------------------
# œ ÚGƒCƒxƒ“ƒg‚Ì‹N“®”»’è
#------------------------------------------
def check_event_trigger_touch(x, y)
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 and event.y == y and [1,2].include?(event.trigger)
# ƒWƒƒƒ“ƒv’†ˆÈŠO‚ÅA‹N“®”»’肪³–ʂ̃Cƒxƒ“ƒg‚È‚ç
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
return result
end
#------------------------------------------
# œ ƒtƒŒ[ƒ€XV
#------------------------------------------
def update
# ƒ[ƒJƒ‹•Ï”‚Ɉړ®’†‚©‚Ç‚¤‚©‚ð‹L‰¯
last_moving = moving?
# ˆÚ“®’†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
# •ûŒüƒ{ƒ^ƒ“‚ª‰Ÿ‚³‚ê‚Ä‚¢‚ê‚ÎA‚»‚Ì•ûŒü‚ÖƒvƒŒƒCƒ„[‚ðˆÚ“®
case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
end
# ƒ[ƒJƒ‹•Ï”‚ÉÀ•W‚ð‹L‰¯
last_real_x = @real_x
last_real_y = @real_y
super
# ƒ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
# ˆÚ“®’†‚ł͂Ȃ¢ê‡
unless moving?
# ‘O‰ñƒvƒŒƒCƒ„[‚ªˆÚ“®’†‚¾‚Á‚½ê‡
if last_moving
# “¯ˆÊ’u‚̃Cƒxƒ“ƒg‚Æ‚ÌÚG‚É‚æ‚éƒCƒxƒ“ƒg‹N“®”»’è
result = check_event_trigger_here([1,2])
# ‹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
end
end |
|