맵상에서 스테이터스 표시 RGSS2 DAIpage v1.2
●기능과 사용법
MAP상에서 스테이터스를 표시하는 DQ 같은 메뉴입니다.
● 재정의한 곳
Scene_Map(을)를 앨리어스(alias) : 한번 더 선언하여 추가적으로 변수를 넣겠다는 의미입니다.
● 스크립트
#==============================================================================
# ■ 커스터마이즈 포인트
#==============================================================================
module DAI_Map_Status
#----------------------------------------------------------------------------
# ● 기본 설정
#----------------------------------------------------------------------------
# 표시 무효 스윗치 번호.(이 스윗치가 온으로 강제비표시)
OPTION = 1
# 타입.(0:버튼 전환 타입,1:통상시 비표시, 일정시간 조작 없이 표시.)
TYPE = 1
# 윈도우 투명도
OPACITY = 255
# 윈도우의 위치.(0:아래,1:위)
Y = 0
# 스테이트를 표시하지 않는다( true / false )
ST = false
#----------------------------------------------------------------------------
# ● 타입 0 의 때의 설정
#----------------------------------------------------------------------------
# 표시 전환해에 사용하는 버튼
B = Input::Y
#----------------------------------------------------------------------------
# ● 타입 1 의 때의 설정
#----------------------------------------------------------------------------
# 표시까지의 시간(60 = 1초)
TIME = 90
end
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map
#----------------------------------------------------------------------------
# ●개시 처리(앨리어스(alias))
#----------------------------------------------------------------------------
alias start_map_status start
def start
@window_map_status = Window_MapStatus.new
start_map_status
end
#----------------------------------------------------------------------------
# ● 프레임 갱신(앨리어스(alias))
#----------------------------------------------------------------------------
alias update_map_status update
def update
update_map_status
map_status_window_update
end
#--------------------------------------------------------------------------
# ● 종료 처리
#--------------------------------------------------------------------------
alias terminate_map_status terminate
def terminate
terminate_map_status
@window_map_status.dispose
end
#----------------------------------------------------------------------------
# ● 윈도우의 갱신
#----------------------------------------------------------------------------
def map_status_window_update
@window_map_status.close if $game_map.interpreter.running?
@window_map_status.update
if Input.trigger?(DAI_Map_Status::B) && DAI_Map_Status::TYPE != 1
return if $game_map.interpreter.running?
return if $game_switches[DAI_Map_Status::OPTION]
@window_map_status.v ^= true
@window_map_status.refresh
Sound.play_decision
return
elsif DAI_Map_Status::TYPE == 1
if $game_map.interpreter.running?
@window_map_status.count = 0
@window_map_status.v = false
return
end
unless input?
@window_map_status.count += 1
if @window_map_status.count == DAI_Map_Status::TIME
@window_map_status.v = true
@window_map_status.refresh
return
end
else
@window_map_status.count = 0
@window_map_status.v = false
return
end
end
if $game_party.members.size > 0 && @window_map_status.v
map_status_data unless $game_map.interpreter.running?
end
end
#--------------------------------------------------------------------------
# ● 화면 변환의 실행
#--------------------------------------------------------------------------
alias map_status_update_scene_change update_scene_change
def update_scene_change
$game_temp.map_s_last_v = @window_map_status.v
@window_map_status.visible = false unless $game_temp.next_scene.nil?
map_status_update_scene_change
end
#----------------------------------------------------------------------------
# ● 스테이터스의 감시
#----------------------------------------------------------------------------
def map_status_data
if @window_map_status.map_status.size != $game_party.members.size
@window_map_status.data
@window_map_status.refresh
return
end
return if $game_party.members.size == 0
i = 0
for a in $game_party.members
a_s = [a.name, a.hp, a.maxhp, a.mp, a.maxmp, a.states]
s = @window_map_status.map_status[i]
if [s[0], s[1], s[2], s[3], s[4], s[5]] != a_s
@window_map_status.data
@window_map_status.refresh
return
end
i += 0
end
end
#--------------------------------------------------------------------------
# ● 어떠한 키 입력이 있었는지 판정
#--------------------------------------------------------------------------
def input?
return (Input.dir4 != 0 or
Input.trigger?(Input::A) or Input.trigger?(Input::B) or
Input.trigger?(Input::C) or Input.trigger?(Input::X) or
Input.trigger?(Input::Y) or Input.trigger?(Input::Z) or
Input.trigger?(Input::L) or Input.trigger?(Input::R))
end
end
#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# ● 공개 인스턴스 변수
#--------------------------------------------------------------------------
attr_accessor:map_s_last_v # 화면 전환전의 가시 상태
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
alias map_status_initialize initialize
def initialize
map_status_initialize
@map_s_last_v = true
end
end
#==============================================================================
# ■ Window_MapStatus
#==============================================================================
class Window_MapStatus < Window_Base
#--------------------------------------------------------------------------
# ● 공개 인스턴스 변수
#--------------------------------------------------------------------------
attr_accessor:map_status # 스테이터스 보관 유지용 변수
attr_accessor:count # 카운트
attr_accessor:v # 가시 상태
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
def initialize
@count = 0
w = $game_party.members.size * 136
w = 136 if $game_party.members.size == 0
if DAI_Map_Status::Y == 0
y = DAI_Map_Status::ST ? 312 : 288
else
y = 0
end
h = DAI_Map_Status::ST ? 104 : 128
super(0, y, w, h)
self.openness = 0
self.opacity = DAI_Map_Status::OPACITY
@v = $game_temp.map_s_last_v
if $game_switches[DAI_Map_Status::OPTION] or DAI_Map_Status::TYPE == 1
@v = false
end
data
refresh
end
#--------------------------------------------------------------------------
# ● 프레임 갱신
#--------------------------------------------------------------------------
def update
if $game_party.members.size == 0
close
elsif @v
open
elsif
close
end
close if $game_switches[DAI_Map_Status::OPTION]
super
end
#--------------------------------------------------------------------------
# ● 윈도우 내용의 작성
#--------------------------------------------------------------------------
def create_contents
self.contents.dispose
w = $game_party.members.size == 0 ? 1 : 512 / 4 * $game_party.members.size
self.contents = Bitmap.new(w, height - 32)
end
#--------------------------------------------------------------------------
# ● 파라미터의 기억
#--------------------------------------------------------------------------
def data
@map_status = []
for a in $game_party.members
@map_status.push([a.name, a.hp, a.maxhp, a.mp, a.maxmp, a.states])
end
end
#--------------------------------------------------------------------------
# ● 리프레쉬
#--------------------------------------------------------------------------
def refresh
create_contents
width_refresh
draw_contents
end
#--------------------------------------------------------------------------
# ● 윈도우 내용의 묘화
#--------------------------------------------------------------------------
def draw_contents
self.contents.clear
return if $game_party.members.size == 0
for i in 0...$game_party.members.size
actor = $game_party.members[i]
actor_x = i * 512 / 4
draw_actor_name(actor, actor_x, 0)
draw_actor_hp(actor, actor_x, 25)
draw_actor_mp(actor, actor_x, 50)
draw_actor_state(actor, actor_x, 75) unless DAI_Map_Status::ST
end
end
#--------------------------------------------------------------------------
# ● 윈도우폭의 조정
#--------------------------------------------------------------------------
def width_refresh
self.width = self.contents.width + 32
end
end
??