언어 몬스터 도감 스크립트 질문요
2006.02.24 19:35
일본 싸이트에서 퍼온 몬스터 도감 스크립트 인데요.
몬스터와 전투해서 이겨야지 추가 되잔아요.
저는 액알로 만드는 중이라서 그러는데요...
그냥 이벤트에서 추가하는 방법은 없나요??
싸우지 않고 그냥..
자세히좀 알려주세요
#마귀 도감
#
#에너미의 만남 정보는 , 전투 종료시(경험치등을 획득하는 곳)에서 추가됩니다.
#따라서 , 적으로부터 도망쳤을 경우나 지고 이벤트에서의 전투 패배등으로는
#도감에 등록되지 않습니다.
#이 타이밍을 바꾸고 싶은 경우는 각자 고쳐 써 주세요.
#(class Scene_Battle 의 start_phase5 로 추가하고 있습니다. )
#
#그리고 , 군데군데 「아나라이즈」라고 하는 단어가 있습니다만 ,
#현재 , 이 마귀 사전만으로는 기능하고 있지 않습니다. (자 게임에서의 자취)
#Window_MonsterBook_Info 의 것 DROP_ITEM_NEED_ANALYZE 이 true 가 되어 있으면(자)
#드롭 아이템이 표시되지 않게 되기 때문에 , 통상은 false 으로 해 두어 주세요.
#
#주의
#이대로 사용하면(자) , 데이타베이스의 무리의1차례에
#굳이 설정하고 있지 않으면 에러 토합니다.
#대처책으로서는
#1.솔직하게 데이타베이스의 무리의1차례에 뭐든지 좋으니까 설정한다.
#2.Game_Enemy_Book 의 「super(1, 1)#더미」 의 좌측의 숫자의 부분을
# 존재하는 무리ID에게 고쳐 쓴다.
#의 어딘가에 됩니다.
#
#2005.2.6 기능 추가
#도감 완성도의 표시 기능을 추가
#SHOW_COMPLETE_TYPE 로 설정할 수 있습니다.
#이벤트 커멘드의 「스크립트」로
#$game_party.enemy_book_max 로 도감의 총 마귀수(최대수)
#$game_party.enemy_book_now 로 도감의 현재 등록수(현재수)
#$game_party.complete_percentage 로 도감의 완성율(소수점 잘라버림)
#을 취득할 수 있습니다.
#
#2005.2.17
#complete_percentage의 메소드명을
#enemy_book_complete_percentage로 변경(다른 도감과 구별할 수 있도록(듯이))
#이벤트 커멘드의 「스크립트」로 최대 수단계의 취득을 단축할 수 있게 되었습니다.
#enemy_book_max 그리고 도감의 총 마귀수(최대수)
#enemy_book_now 로 도감의 현재 등록수(현재수)
#enemy_book_comp로 도감의 완성율(소수점 잘라버림)
#
#2005.2.18 버그 수정
#complete_percentage의 메소드명을
#enemy_book_complete_percentage로 변경했는데
#complete_percentage라고 호출하고 있었습니다. (단순한 고쳐 쓰고 새고군요)
#
#2005.7.4 기능 추가
#코멘트 기능에 대응.
#전체적으로 여러가지 만졌습니다.
#
#2005.7.4 버그 수정
#세세한 버그를 수정.
module Enemy_Book_Config
#드롭 아이템 표시에 아나라이즈가 필요한지 어떤지
DROP_ITEM_NEED_ANALYZE = false
#회피 수정의 이름
EVA_NAME = "회피"
#도감 완성율의 표시 방법
#0:표시 없음 1:현재수/최대수 2:%표시 3:양쪽 모두
SHOW_COMPLETE_TYPE = 3
#코멘트 기능을 사용하는지 어떤지(요점·코멘트 추가 스크립트 도입)
COMMENT_SYSTEM = false
end
class Game_Temp
attr_accessor :enemy_book_data
alias temp_enemy_book_data_initialize initialize
def initialize
temp_enemy_book_data_initialize
@enemy_book_data = Data_MonsterBook.new
end
end
class Game_Party
attr_accessor :enemy_info # 만난 적 정보(도감용)
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
alias book_info_initialize initialize
def initialize
book_info_initialize
@enemy_info = {}
end
#--------------------------------------------------------------------------
# ● 에너미 정보의 추가(도감용)
# type : 통상 만남인가 아나라이즈나 0:통상 1:아나라이즈 -1:정보 삭제
# 0:무 만남 1:만남제 2:아나라이즈제
#--------------------------------------------------------------------------
def add_enemy_info(enemy_id, type = 0)
case type
when 0
if @enemy_info[enemy_id] == 2
return false
end
@enemy_info[enemy_id] = 1
when 1
@enemy_info[enemy_id] = 2
when -1
@enemy_info[enemy_id] = 0
end
end
#--------------------------------------------------------------------------
# ● 마귀 도감의 최대 등록수를 취득
#--------------------------------------------------------------------------
def enemy_book_max
return $game_temp.enemy_book_data.id_data.size - 1
end
#--------------------------------------------------------------------------
# ● 마귀 도감의 현재 등록수를 취득
#--------------------------------------------------------------------------
def enemy_book_now
now_enemy_info = @enemy_info.keys
# 등록 무시의 속성ID을 취득
no_add = $game_temp.enemy_book_data.no_add_element
new_enemy_info = []
for i in now_enemy_info
enemy = $data_enemies[i]
next if enemy.name == ""
if enemy.element_ranks[no_add] == 1
next
end
new_enemy_info.push(enemy.id)
end
return new_enemy_info.size
end
#--------------------------------------------------------------------------
# ● 마귀 도감의 완성율을 취득
#--------------------------------------------------------------------------
def enemy_book_complete_percentage
e_max = enemy_book_max.to_f
e_now = enemy_book_now.to_f
comp = e_now / e_max * 100
return comp.truncate
end
end
class Interpreter
def enemy_book_max
return $game_party.enemy_book_max
end
def enemy_book_now
return $game_party.enemy_book_now
end
def enemy_book_comp
return $game_party.enemy_book_complete_percentage
end
end
class Scene_Battle
alias add_enemy_info_start_phase5 start_phase5
def start_phase5
for enemy in $game_troop.enemies
# 에너미가 숨고 상태가 아닌 경우
unless enemy.hidden
# 적 만남 정보 추가
$game_party.add_enemy_info(enemy.id, 0)
end
end
add_enemy_info_start_phase5
end
end
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 에너미의 전투후 획득 아이템의 묘화
#--------------------------------------------------------------------------
def draw_enemy_drop_item(enemy, x, y)
self.contents.font.color = normal_color
treasures = []
if enemy.item_id > 0
treasures.push($data_items[enemy.item_id])
end
if enemy.weapon_id > 0
treasures.push($data_weapons[enemy.weapon_id])
end
if enemy.armor_id > 0
treasures.push($data_armors[enemy.armor_id])
end
# 현재 상태로서는 우선1개만 묘화
if treasures.size > 0
item = treasures[0]
bitmap = RPG::Cache.icon(item.icon_name)
opacity = 255
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
name = treasures[0].name
else
self.contents.font.color = disabled_color
name = "No Item"
end
self.contents.draw_text(x+28, y, 212, 32, name)
end
#--------------------------------------------------------------------------
# ● 에너미의 도감ID의 묘화
#--------------------------------------------------------------------------
def draw_enemy_book_id(enemy, x, y)
self.contents.font.color = normal_color
id = $game_temp.enemy_book_data.id_data.index(enemy.id)
self.contents.draw_text(x, y, 32, 32, id.to_s)
end
#--------------------------------------------------------------------------
# ● 에너미의 이름의 묘화
# enemy : 에너미
# x : 묘화처 X 좌표
# y : 묘화처 Y 좌표
#--------------------------------------------------------------------------
def draw_enemy_name(enemy, x, y)
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 152, 32, enemy.name)
end
#--------------------------------------------------------------------------
# ● 에너미 그래픽의 묘화(아나라이즈)
# enemy : 에너미
# x : 묘화처 X 좌표
# y : 묘화처 Y 좌표
#--------------------------------------------------------------------------
def draw_enemy_graphic(enemy, x, y, opacity = 255)
bitmap = RPG::Cache.battler(enemy.battler_name, enemy.battler_hue)
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
x = x + (cw / 2 - x) if cw / 2 > x
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect, opacity)
end
#--------------------------------------------------------------------------
# ● 에너미의 획득EXP의 묘화
# enemy : 에너미
# x : 묘화처 X 좌표
# y : 묘화처 Y 좌표
#--------------------------------------------------------------------------
def draw_enemy_exp(enemy, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 120, 32, "EXP")
self.contents.font.color = normal_color
self.contents.draw_text(x + 120, y, 36, 32, enemy.exp.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 에너미의 획득GOLD의 묘화
# enemy : 에너미
# x : 묘화처 X 좌표
# y : 묘화처 Y 좌표
#--------------------------------------------------------------------------
def draw_enemy_gold(enemy, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 120, 32, $data_system.words.gold)
self.contents.font.color = normal_color
self.contents.draw_text(x + 120, y, 36, 32, enemy.gold.to_s, 2)
end
end
class Game_Enemy_Book < Game_Enemy
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
def initialize(enemy_id)
super(1, 1)#더미
@enemy_id = enemy_id
enemy = $data_enemies[@enemy_id]
@battler_name = enemy.battler_name
@battler_hue = enemy.battler_hue
@hp = maxhp
@sp = maxsp
end
end
class Data_MonsterBook
attr_reader :id_data
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
def initialize
@id_data = enemy_book_id_set
end
#--------------------------------------------------------------------------
# ● 도감용 등록 무시 속성 취득
#--------------------------------------------------------------------------
def no_add_element
no_add = 0
# 등록 무시의 속성ID을 취득
for i in 1...$data_system.elements.size
if $data_system.elements[i] =~ /도감 등록 무효/
no_add = i
break
end
end
return no_add
end
#--------------------------------------------------------------------------
# ● 도감용적ID설정
#--------------------------------------------------------------------------
def enemy_book_id_set
data = [0]
no_add = no_add_element
# 등록 무시의 속성ID을 취득
for i in 1...$data_enemies.size
enemy = $data_enemies[i]
next if enemy.name == ""
if enemy.element_ranks[no_add] == 1
next
end
data.push(enemy.id)
end
return data
end
end
class Window_MonsterBook < Window_Selectable
attr_reader :data
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
def initialize(index=0)
super(0, 64, 640, 416)
@column_max = 2
@book_data = $game_temp.enemy_book_data
@data = @book_data.id_data.dup
@data.shift
#@data.sort!
@item_max = @data.size
self.index = 0
refresh if @item_max > 0
end
#--------------------------------------------------------------------------
# ● 만남 데이터를 취득
#--------------------------------------------------------------------------
def data_set
data = $game_party.enemy_info.keys
data.sort!
newdata = []
for i in data
next if $game_party.enemy_info[i] == 0
# 도감 등록 무시를 고려
if book_id(i) != nil
newdata.push(i)
end
end
return newdata
end
#--------------------------------------------------------------------------
# ● 표시 허가 취득
#--------------------------------------------------------------------------
def show?(id)
if $game_party.enemy_info[id] == 0 or $game_party.enemy_info[id] == nil
return false
else
return true
end
end
#--------------------------------------------------------------------------
# ● 도감용ID취득
#--------------------------------------------------------------------------
def book_id(id)
return @book_data.index(id)
end
#--------------------------------------------------------------------------
# ● 에너미 취득
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 리프레쉬
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
self.contents = Bitmap.new(width - 32, row_max * 32)
#항목수가 0 나오지 않으면 비트 맵을 작성해 , 전 항목을 묘화
if @item_max > 0
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 항목의 묘화
# index : 항목 번호
#--------------------------------------------------------------------------
def draw_item(index)
enemy = $data_enemies[@data[index]]
return if enemy == nil
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.font.color = normal_color
draw_enemy_book_id(enemy, x, y)
if show?(enemy.id)
self.contents.draw_text(x + 28+16, y, 212, 32, enemy.name, 0)
else
self.contents.draw_text(x + 28+16, y, 212, 32, "-----", 0)
return
end
if analyze?(@data[index])
self.contents.font.color = text_color(3)
self.contents.draw_text(x + 256, y, 24, 32, "제", 2)
end
end
#--------------------------------------------------------------------------
# ● 아나라이즈제 화도나
#--------------------------------------------------------------------------
def analyze?(enemy_id)
if $game_party.enemy_info[enemy_id] == 2
return true
else
return false
end
end
end
class Window_MonsterBook_Info < Window_Base
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
def initialize
super(0, 0+64, 640, 480-64)
self.contents = Bitmap.new(width - 32, height - 32)
end
#--------------------------------------------------------------------------
# ● 리프레쉬
#--------------------------------------------------------------------------
def refresh(enemy_id)
self.contents.clear
self.contents.font.size = 22
enemy = Game_Enemy_Book.new(enemy_id)
draw_enemy_graphic(enemy, 96, 240+48+64, 200)
draw_enemy_book_id(enemy, 4, 0)
draw_enemy_name(enemy, 48, 0)
draw_actor_hp(enemy, 288, 0)
draw_actor_sp(enemy, 288+160, 0)
draw_actor_parameter(enemy, 288 , 32, 0)
self.contents.font.color = system_color
self.contents.draw_text(288+160, 32, 120, 32, Enemy_Book_Config::EVA_NAME)
self.contents.font.color = normal_color
self.contents.draw_text(288+160 + 120, 32, 36, 32, enemy.eva.to_s, 2)
draw_actor_parameter(enemy, 288 , 64, 3)
draw_actor_parameter(enemy, 288+160, 64, 4)
draw_actor_parameter(enemy, 288 , 96, 5)
draw_actor_parameter(enemy, 288+160, 96, 6)
draw_actor_parameter(enemy, 288 , 128, 1)
draw_actor_parameter(enemy, 288+160, 128, 2)
draw_enemy_exp(enemy, 288, 160)
draw_enemy_gold(enemy, 288+160, 160)
if analyze?(enemy.id) or !Enemy_Book_Config::DROP_ITEM_NEED_ANALYZE
self.contents.draw_text(288, 192, 96, 32, "Drop Item")
draw_enemy_drop_item(enemy, 288+96+4, 192)
self.contents.font.color = normal_color
#draw_element_guard(enemy, 320-32, 160-16+96)
end
end
#--------------------------------------------------------------------------
# ● 아나라이즈제 화도나
#--------------------------------------------------------------------------
def analyze?(enemy_id)
if $game_party.enemy_info[enemy_id] == 2
return true
else
return false
end
end
end
class Scene_MonsterBook
#--------------------------------------------------------------------------
# ● 메인 처리
#--------------------------------------------------------------------------
def main
$game_temp.enemy_book_data = Data_MonsterBook.new
# 윈도우를 작성
@title_window = Window_Base.new(0, 0, 640, 64)
@title_window.contents = Bitmap.new(640 - 32, 64 - 32)
@title_window.contents.draw_text(4, 0, 320, 32, "마귀 도감", 0)
if Enemy_Book_Config::SHOW_COMPLETE_TYPE != 0
case Enemy_Book_Config::SHOW_COMPLETE_TYPE
when 1
e_now = $game_party.enemy_book_now
e_max = $game_party.enemy_book_max
text = e_now.to_s + "/" + e_max.to_s
when 2
comp = $game_party.enemy_book_complete_percentage
text = comp.to_s + "%"
when 3
e_now = $game_party.enemy_book_now
e_max = $game_party.enemy_book_max
comp = $game_party.enemy_book_complete_percentage
text = e_now.to_s + "/" + e_max.to_s + " " + comp.to_s + "%"
end
if text != nil
@title_window.contents.draw_text(320, 0, 288, 32, text, 2)
end
end
@main_window = Window_MonsterBook.new
@main_window.active = true
# 인포메이션 윈도우를 작성 (불가시·비액티브하게 설정)
@info_window = Window_MonsterBook_Info.new
@info_window.z = 110
@info_window.visible = false
@info_window.active = false
@visible_index = 0
if Enemy_Book_Config::COMMENT_SYSTEM
# 코멘트 윈도우를 작성 (불가시·비액티브하게 설정)
@comment_window = Window_Monster_Book_Comment.new
@comment_window.z = 120
@comment_window.visible = false
@comment_on = false # 코멘트 플래그
end
# 트란지션 실행
Graphics.transition
# 메인 루프
loop do
# 게임 화면을 갱신
Graphics.update
# 입력 정보를 갱신
Input.update
# 프레임 갱신
update
# 화면이 바뀌면(자) 루프를 중단
if $scene != self
break
end
end
# 트란지션 준비
Graphics.freeze
# 윈도우를 해방
@main_window.dispose
@info_window.dispose
@title_window.dispose
@comment_window.dispose if @comment_window != nil
end
#--------------------------------------------------------------------------
# ● 프레임 갱신
#--------------------------------------------------------------------------
def update
# 윈도우를 갱신
@main_window.update
@info_window.update
if @info_window.active
update_info
return
end
# 메인 윈도우가 액티브의 경우: update_target 를 부르는
if @main_window.active
update_main
return
end
end
#--------------------------------------------------------------------------
# ● 프레임 갱신 (메인 윈도우가 액티브의 경우)
#--------------------------------------------------------------------------
def update_main
# B 버튼이 밀렸을 경우
if Input.trigger?(Input::B)
# 캔슬 SE 을 연주
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
# C 버튼이 밀렸을 경우
if Input.trigger?(Input::C)
if @main_window.item == nil or @main_window.show?(@main_window.item) == false
# 버저 SE 를 연주
$game_system.se_play($data_system.buzzer_se)
return
end
# 결정 SE 을 연주
$game_system.se_play($data_system.decision_se)
@main_window.active = false
@info_window.active = true
@info_window.visible = true
@visible_index = @main_window.index
@info_window.refresh(@main_window.item)
if @comment_window != nil
@comment_window.refresh(@main_window.item)
if @comment_on
@comment_window.visible = true
else
@comment_window.visible = false
end
end
return
end
end
#--------------------------------------------------------------------------
# ● 프레임 갱신 (인포메이션 윈도우가 액티브의 경우)
#--------------------------------------------------------------------------
def update_info
# B 버튼이 밀렸을 경우
if Input.trigger?(Input::B)
# 캔슬 SE 을 연주
$game_system.se_play($data_system.cancel_se)
@main_window.active = true
@info_window.active = false
@info_window.visible = false
@comment_window.visible = false if @comment_window != nil
return
end
# C 버튼이 밀렸을 경우
if Input.trigger?(Input::C)
if @comment_window != nil
# 결정 SE 을 연주
$game_system.se_play($data_system.decision_se)
if @comment_on
@comment_on = false
@comment_window.visible = false
else
@comment_on = true
@comment_window.visible = true
end
return
end
end
if Input.trigger?(Input::L)
# 결정 SE 을 연주
$game_system.se_play($data_system.decision_se)
loop_end = false
while loop_end == false
if @visible_index != 0
@visible_index -= 1
else
@visible_index = @main_window.data.size - 1
end
loop_end = true if @main_window.show?(@main_window.data[@visible_index])
end
id = @main_window.data[@visible_index]
@info_window.refresh(id)
@comment_window.refresh(id) if @comment_window != nil
return
end
if Input.trigger?(Input::R)
# 결정 SE 을 연주
$game_system.se_play($data_system.decision_se)
loop_end = false
while loop_end == false
if @visible_index != @main_window.data.size - 1
@visible_index += 1
else
@visible_index = 0
end
loop_end = true if @main_window.show?(@main_window.data[@visible_index])
end
id = @main_window.data[@visible_index]
@info_window.refresh(id)
@comment_window.refresh(id) if @comment_window != nil
return
end
end
몬스터와 전투해서 이겨야지 추가 되잔아요.
저는 액알로 만드는 중이라서 그러는데요...
그냥 이벤트에서 추가하는 방법은 없나요??
싸우지 않고 그냥..
자세히좀 알려주세요
#마귀 도감
#
#에너미의 만남 정보는 , 전투 종료시(경험치등을 획득하는 곳)에서 추가됩니다.
#따라서 , 적으로부터 도망쳤을 경우나 지고 이벤트에서의 전투 패배등으로는
#도감에 등록되지 않습니다.
#이 타이밍을 바꾸고 싶은 경우는 각자 고쳐 써 주세요.
#(class Scene_Battle 의 start_phase5 로 추가하고 있습니다. )
#
#그리고 , 군데군데 「아나라이즈」라고 하는 단어가 있습니다만 ,
#현재 , 이 마귀 사전만으로는 기능하고 있지 않습니다. (자 게임에서의 자취)
#Window_MonsterBook_Info 의 것 DROP_ITEM_NEED_ANALYZE 이 true 가 되어 있으면(자)
#드롭 아이템이 표시되지 않게 되기 때문에 , 통상은 false 으로 해 두어 주세요.
#
#주의
#이대로 사용하면(자) , 데이타베이스의 무리의1차례에
#굳이 설정하고 있지 않으면 에러 토합니다.
#대처책으로서는
#1.솔직하게 데이타베이스의 무리의1차례에 뭐든지 좋으니까 설정한다.
#2.Game_Enemy_Book 의 「super(1, 1)#더미」 의 좌측의 숫자의 부분을
# 존재하는 무리ID에게 고쳐 쓴다.
#의 어딘가에 됩니다.
#
#2005.2.6 기능 추가
#도감 완성도의 표시 기능을 추가
#SHOW_COMPLETE_TYPE 로 설정할 수 있습니다.
#이벤트 커멘드의 「스크립트」로
#$game_party.enemy_book_max 로 도감의 총 마귀수(최대수)
#$game_party.enemy_book_now 로 도감의 현재 등록수(현재수)
#$game_party.complete_percentage 로 도감의 완성율(소수점 잘라버림)
#을 취득할 수 있습니다.
#
#2005.2.17
#complete_percentage의 메소드명을
#enemy_book_complete_percentage로 변경(다른 도감과 구별할 수 있도록(듯이))
#이벤트 커멘드의 「스크립트」로 최대 수단계의 취득을 단축할 수 있게 되었습니다.
#enemy_book_max 그리고 도감의 총 마귀수(최대수)
#enemy_book_now 로 도감의 현재 등록수(현재수)
#enemy_book_comp로 도감의 완성율(소수점 잘라버림)
#
#2005.2.18 버그 수정
#complete_percentage의 메소드명을
#enemy_book_complete_percentage로 변경했는데
#complete_percentage라고 호출하고 있었습니다. (단순한 고쳐 쓰고 새고군요)
#
#2005.7.4 기능 추가
#코멘트 기능에 대응.
#전체적으로 여러가지 만졌습니다.
#
#2005.7.4 버그 수정
#세세한 버그를 수정.
module Enemy_Book_Config
#드롭 아이템 표시에 아나라이즈가 필요한지 어떤지
DROP_ITEM_NEED_ANALYZE = false
#회피 수정의 이름
EVA_NAME = "회피"
#도감 완성율의 표시 방법
#0:표시 없음 1:현재수/최대수 2:%표시 3:양쪽 모두
SHOW_COMPLETE_TYPE = 3
#코멘트 기능을 사용하는지 어떤지(요점·코멘트 추가 스크립트 도입)
COMMENT_SYSTEM = false
end
class Game_Temp
attr_accessor :enemy_book_data
alias temp_enemy_book_data_initialize initialize
def initialize
temp_enemy_book_data_initialize
@enemy_book_data = Data_MonsterBook.new
end
end
class Game_Party
attr_accessor :enemy_info # 만난 적 정보(도감용)
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
alias book_info_initialize initialize
def initialize
book_info_initialize
@enemy_info = {}
end
#--------------------------------------------------------------------------
# ● 에너미 정보의 추가(도감용)
# type : 통상 만남인가 아나라이즈나 0:통상 1:아나라이즈 -1:정보 삭제
# 0:무 만남 1:만남제 2:아나라이즈제
#--------------------------------------------------------------------------
def add_enemy_info(enemy_id, type = 0)
case type
when 0
if @enemy_info[enemy_id] == 2
return false
end
@enemy_info[enemy_id] = 1
when 1
@enemy_info[enemy_id] = 2
when -1
@enemy_info[enemy_id] = 0
end
end
#--------------------------------------------------------------------------
# ● 마귀 도감의 최대 등록수를 취득
#--------------------------------------------------------------------------
def enemy_book_max
return $game_temp.enemy_book_data.id_data.size - 1
end
#--------------------------------------------------------------------------
# ● 마귀 도감의 현재 등록수를 취득
#--------------------------------------------------------------------------
def enemy_book_now
now_enemy_info = @enemy_info.keys
# 등록 무시의 속성ID을 취득
no_add = $game_temp.enemy_book_data.no_add_element
new_enemy_info = []
for i in now_enemy_info
enemy = $data_enemies[i]
next if enemy.name == ""
if enemy.element_ranks[no_add] == 1
next
end
new_enemy_info.push(enemy.id)
end
return new_enemy_info.size
end
#--------------------------------------------------------------------------
# ● 마귀 도감의 완성율을 취득
#--------------------------------------------------------------------------
def enemy_book_complete_percentage
e_max = enemy_book_max.to_f
e_now = enemy_book_now.to_f
comp = e_now / e_max * 100
return comp.truncate
end
end
class Interpreter
def enemy_book_max
return $game_party.enemy_book_max
end
def enemy_book_now
return $game_party.enemy_book_now
end
def enemy_book_comp
return $game_party.enemy_book_complete_percentage
end
end
class Scene_Battle
alias add_enemy_info_start_phase5 start_phase5
def start_phase5
for enemy in $game_troop.enemies
# 에너미가 숨고 상태가 아닌 경우
unless enemy.hidden
# 적 만남 정보 추가
$game_party.add_enemy_info(enemy.id, 0)
end
end
add_enemy_info_start_phase5
end
end
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 에너미의 전투후 획득 아이템의 묘화
#--------------------------------------------------------------------------
def draw_enemy_drop_item(enemy, x, y)
self.contents.font.color = normal_color
treasures = []
if enemy.item_id > 0
treasures.push($data_items[enemy.item_id])
end
if enemy.weapon_id > 0
treasures.push($data_weapons[enemy.weapon_id])
end
if enemy.armor_id > 0
treasures.push($data_armors[enemy.armor_id])
end
# 현재 상태로서는 우선1개만 묘화
if treasures.size > 0
item = treasures[0]
bitmap = RPG::Cache.icon(item.icon_name)
opacity = 255
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
name = treasures[0].name
else
self.contents.font.color = disabled_color
name = "No Item"
end
self.contents.draw_text(x+28, y, 212, 32, name)
end
#--------------------------------------------------------------------------
# ● 에너미의 도감ID의 묘화
#--------------------------------------------------------------------------
def draw_enemy_book_id(enemy, x, y)
self.contents.font.color = normal_color
id = $game_temp.enemy_book_data.id_data.index(enemy.id)
self.contents.draw_text(x, y, 32, 32, id.to_s)
end
#--------------------------------------------------------------------------
# ● 에너미의 이름의 묘화
# enemy : 에너미
# x : 묘화처 X 좌표
# y : 묘화처 Y 좌표
#--------------------------------------------------------------------------
def draw_enemy_name(enemy, x, y)
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 152, 32, enemy.name)
end
#--------------------------------------------------------------------------
# ● 에너미 그래픽의 묘화(아나라이즈)
# enemy : 에너미
# x : 묘화처 X 좌표
# y : 묘화처 Y 좌표
#--------------------------------------------------------------------------
def draw_enemy_graphic(enemy, x, y, opacity = 255)
bitmap = RPG::Cache.battler(enemy.battler_name, enemy.battler_hue)
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
x = x + (cw / 2 - x) if cw / 2 > x
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect, opacity)
end
#--------------------------------------------------------------------------
# ● 에너미의 획득EXP의 묘화
# enemy : 에너미
# x : 묘화처 X 좌표
# y : 묘화처 Y 좌표
#--------------------------------------------------------------------------
def draw_enemy_exp(enemy, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 120, 32, "EXP")
self.contents.font.color = normal_color
self.contents.draw_text(x + 120, y, 36, 32, enemy.exp.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 에너미의 획득GOLD의 묘화
# enemy : 에너미
# x : 묘화처 X 좌표
# y : 묘화처 Y 좌표
#--------------------------------------------------------------------------
def draw_enemy_gold(enemy, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 120, 32, $data_system.words.gold)
self.contents.font.color = normal_color
self.contents.draw_text(x + 120, y, 36, 32, enemy.gold.to_s, 2)
end
end
class Game_Enemy_Book < Game_Enemy
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
def initialize(enemy_id)
super(1, 1)#더미
@enemy_id = enemy_id
enemy = $data_enemies[@enemy_id]
@battler_name = enemy.battler_name
@battler_hue = enemy.battler_hue
@hp = maxhp
@sp = maxsp
end
end
class Data_MonsterBook
attr_reader :id_data
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
def initialize
@id_data = enemy_book_id_set
end
#--------------------------------------------------------------------------
# ● 도감용 등록 무시 속성 취득
#--------------------------------------------------------------------------
def no_add_element
no_add = 0
# 등록 무시의 속성ID을 취득
for i in 1...$data_system.elements.size
if $data_system.elements[i] =~ /도감 등록 무효/
no_add = i
break
end
end
return no_add
end
#--------------------------------------------------------------------------
# ● 도감용적ID설정
#--------------------------------------------------------------------------
def enemy_book_id_set
data = [0]
no_add = no_add_element
# 등록 무시의 속성ID을 취득
for i in 1...$data_enemies.size
enemy = $data_enemies[i]
next if enemy.name == ""
if enemy.element_ranks[no_add] == 1
next
end
data.push(enemy.id)
end
return data
end
end
class Window_MonsterBook < Window_Selectable
attr_reader :data
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
def initialize(index=0)
super(0, 64, 640, 416)
@column_max = 2
@book_data = $game_temp.enemy_book_data
@data = @book_data.id_data.dup
@data.shift
#@data.sort!
@item_max = @data.size
self.index = 0
refresh if @item_max > 0
end
#--------------------------------------------------------------------------
# ● 만남 데이터를 취득
#--------------------------------------------------------------------------
def data_set
data = $game_party.enemy_info.keys
data.sort!
newdata = []
for i in data
next if $game_party.enemy_info[i] == 0
# 도감 등록 무시를 고려
if book_id(i) != nil
newdata.push(i)
end
end
return newdata
end
#--------------------------------------------------------------------------
# ● 표시 허가 취득
#--------------------------------------------------------------------------
def show?(id)
if $game_party.enemy_info[id] == 0 or $game_party.enemy_info[id] == nil
return false
else
return true
end
end
#--------------------------------------------------------------------------
# ● 도감용ID취득
#--------------------------------------------------------------------------
def book_id(id)
return @book_data.index(id)
end
#--------------------------------------------------------------------------
# ● 에너미 취득
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 리프레쉬
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
self.contents = Bitmap.new(width - 32, row_max * 32)
#항목수가 0 나오지 않으면 비트 맵을 작성해 , 전 항목을 묘화
if @item_max > 0
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 항목의 묘화
# index : 항목 번호
#--------------------------------------------------------------------------
def draw_item(index)
enemy = $data_enemies[@data[index]]
return if enemy == nil
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.font.color = normal_color
draw_enemy_book_id(enemy, x, y)
if show?(enemy.id)
self.contents.draw_text(x + 28+16, y, 212, 32, enemy.name, 0)
else
self.contents.draw_text(x + 28+16, y, 212, 32, "-----", 0)
return
end
if analyze?(@data[index])
self.contents.font.color = text_color(3)
self.contents.draw_text(x + 256, y, 24, 32, "제", 2)
end
end
#--------------------------------------------------------------------------
# ● 아나라이즈제 화도나
#--------------------------------------------------------------------------
def analyze?(enemy_id)
if $game_party.enemy_info[enemy_id] == 2
return true
else
return false
end
end
end
class Window_MonsterBook_Info < Window_Base
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
def initialize
super(0, 0+64, 640, 480-64)
self.contents = Bitmap.new(width - 32, height - 32)
end
#--------------------------------------------------------------------------
# ● 리프레쉬
#--------------------------------------------------------------------------
def refresh(enemy_id)
self.contents.clear
self.contents.font.size = 22
enemy = Game_Enemy_Book.new(enemy_id)
draw_enemy_graphic(enemy, 96, 240+48+64, 200)
draw_enemy_book_id(enemy, 4, 0)
draw_enemy_name(enemy, 48, 0)
draw_actor_hp(enemy, 288, 0)
draw_actor_sp(enemy, 288+160, 0)
draw_actor_parameter(enemy, 288 , 32, 0)
self.contents.font.color = system_color
self.contents.draw_text(288+160, 32, 120, 32, Enemy_Book_Config::EVA_NAME)
self.contents.font.color = normal_color
self.contents.draw_text(288+160 + 120, 32, 36, 32, enemy.eva.to_s, 2)
draw_actor_parameter(enemy, 288 , 64, 3)
draw_actor_parameter(enemy, 288+160, 64, 4)
draw_actor_parameter(enemy, 288 , 96, 5)
draw_actor_parameter(enemy, 288+160, 96, 6)
draw_actor_parameter(enemy, 288 , 128, 1)
draw_actor_parameter(enemy, 288+160, 128, 2)
draw_enemy_exp(enemy, 288, 160)
draw_enemy_gold(enemy, 288+160, 160)
if analyze?(enemy.id) or !Enemy_Book_Config::DROP_ITEM_NEED_ANALYZE
self.contents.draw_text(288, 192, 96, 32, "Drop Item")
draw_enemy_drop_item(enemy, 288+96+4, 192)
self.contents.font.color = normal_color
#draw_element_guard(enemy, 320-32, 160-16+96)
end
end
#--------------------------------------------------------------------------
# ● 아나라이즈제 화도나
#--------------------------------------------------------------------------
def analyze?(enemy_id)
if $game_party.enemy_info[enemy_id] == 2
return true
else
return false
end
end
end
class Scene_MonsterBook
#--------------------------------------------------------------------------
# ● 메인 처리
#--------------------------------------------------------------------------
def main
$game_temp.enemy_book_data = Data_MonsterBook.new
# 윈도우를 작성
@title_window = Window_Base.new(0, 0, 640, 64)
@title_window.contents = Bitmap.new(640 - 32, 64 - 32)
@title_window.contents.draw_text(4, 0, 320, 32, "마귀 도감", 0)
if Enemy_Book_Config::SHOW_COMPLETE_TYPE != 0
case Enemy_Book_Config::SHOW_COMPLETE_TYPE
when 1
e_now = $game_party.enemy_book_now
e_max = $game_party.enemy_book_max
text = e_now.to_s + "/" + e_max.to_s
when 2
comp = $game_party.enemy_book_complete_percentage
text = comp.to_s + "%"
when 3
e_now = $game_party.enemy_book_now
e_max = $game_party.enemy_book_max
comp = $game_party.enemy_book_complete_percentage
text = e_now.to_s + "/" + e_max.to_s + " " + comp.to_s + "%"
end
if text != nil
@title_window.contents.draw_text(320, 0, 288, 32, text, 2)
end
end
@main_window = Window_MonsterBook.new
@main_window.active = true
# 인포메이션 윈도우를 작성 (불가시·비액티브하게 설정)
@info_window = Window_MonsterBook_Info.new
@info_window.z = 110
@info_window.visible = false
@info_window.active = false
@visible_index = 0
if Enemy_Book_Config::COMMENT_SYSTEM
# 코멘트 윈도우를 작성 (불가시·비액티브하게 설정)
@comment_window = Window_Monster_Book_Comment.new
@comment_window.z = 120
@comment_window.visible = false
@comment_on = false # 코멘트 플래그
end
# 트란지션 실행
Graphics.transition
# 메인 루프
loop do
# 게임 화면을 갱신
Graphics.update
# 입력 정보를 갱신
Input.update
# 프레임 갱신
update
# 화면이 바뀌면(자) 루프를 중단
if $scene != self
break
end
end
# 트란지션 준비
Graphics.freeze
# 윈도우를 해방
@main_window.dispose
@info_window.dispose
@title_window.dispose
@comment_window.dispose if @comment_window != nil
end
#--------------------------------------------------------------------------
# ● 프레임 갱신
#--------------------------------------------------------------------------
def update
# 윈도우를 갱신
@main_window.update
@info_window.update
if @info_window.active
update_info
return
end
# 메인 윈도우가 액티브의 경우: update_target 를 부르는
if @main_window.active
update_main
return
end
end
#--------------------------------------------------------------------------
# ● 프레임 갱신 (메인 윈도우가 액티브의 경우)
#--------------------------------------------------------------------------
def update_main
# B 버튼이 밀렸을 경우
if Input.trigger?(Input::B)
# 캔슬 SE 을 연주
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
# C 버튼이 밀렸을 경우
if Input.trigger?(Input::C)
if @main_window.item == nil or @main_window.show?(@main_window.item) == false
# 버저 SE 를 연주
$game_system.se_play($data_system.buzzer_se)
return
end
# 결정 SE 을 연주
$game_system.se_play($data_system.decision_se)
@main_window.active = false
@info_window.active = true
@info_window.visible = true
@visible_index = @main_window.index
@info_window.refresh(@main_window.item)
if @comment_window != nil
@comment_window.refresh(@main_window.item)
if @comment_on
@comment_window.visible = true
else
@comment_window.visible = false
end
end
return
end
end
#--------------------------------------------------------------------------
# ● 프레임 갱신 (인포메이션 윈도우가 액티브의 경우)
#--------------------------------------------------------------------------
def update_info
# B 버튼이 밀렸을 경우
if Input.trigger?(Input::B)
# 캔슬 SE 을 연주
$game_system.se_play($data_system.cancel_se)
@main_window.active = true
@info_window.active = false
@info_window.visible = false
@comment_window.visible = false if @comment_window != nil
return
end
# C 버튼이 밀렸을 경우
if Input.trigger?(Input::C)
if @comment_window != nil
# 결정 SE 을 연주
$game_system.se_play($data_system.decision_se)
if @comment_on
@comment_on = false
@comment_window.visible = false
else
@comment_on = true
@comment_window.visible = true
end
return
end
end
if Input.trigger?(Input::L)
# 결정 SE 을 연주
$game_system.se_play($data_system.decision_se)
loop_end = false
while loop_end == false
if @visible_index != 0
@visible_index -= 1
else
@visible_index = @main_window.data.size - 1
end
loop_end = true if @main_window.show?(@main_window.data[@visible_index])
end
id = @main_window.data[@visible_index]
@info_window.refresh(id)
@comment_window.refresh(id) if @comment_window != nil
return
end
if Input.trigger?(Input::R)
# 결정 SE 을 연주
$game_system.se_play($data_system.decision_se)
loop_end = false
while loop_end == false
if @visible_index != @main_window.data.size - 1
@visible_index += 1
else
@visible_index = 0
end
loop_end = true if @main_window.show?(@main_window.data[@visible_index])
end
id = @main_window.data[@visible_index]
@info_window.refresh(id)
@comment_window.refresh(id) if @comment_window != nil
return
end
end