XP 스크립트

원본: http://www.hbgames.org/forums/viewtopic.php?f=12&t=7212 (이 쓰레드의 두 번째 글)
J.D. Slasha의 편집판: http://www.hbgames.org/forums/viewtopic.php?f=156&t=1502&p=14113

  이전에 편집했던 것에 세이브 장소와 확장자 설정을 추가했습니다.


**원본 내지는 J.D.Slasha의 편집에서 바뀐 점:
- 최대 세이브 갯수를 원하는 대로 설정 가능(원본은 99개)
- RPG Advocate씨의 세이브 덮어쓰기 확인 실장
- 세이브 장소로 지정된 디렉토리가 없을 경우 스크립트에서 자동으로 생성
- 세이브 장소와 확장자 설정 추가.


#==============================================================================
# ■ ASM - advanced save menu
#------------------------------------------------------------------------------
# by squall // squall@loeher.zzn.com
# edited by J.D. Slasha (1-20-06)
# monday the 28th of november 2005
#
# Allows to have up to 99 files.
# Files are stored inside of the folder 'Saves' inside of the game's folder.
# Don't forget to create that folder if it doesn't already exist.
#==============================================================================
# Save overwriting confirm by RPG Advocate
# Merged & Edited by L
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
if Object.const_defined?('SDK')
SDK.log('Advanced Save Menu', 'squall', 1.0, '2005-11-28')

#--------------------------------------------------------------------------
# * Begin SDK Requirement Check
#--------------------------------------------------------------------------
SDK.check_requirements(2.0, [1])

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.enabled?('Advanced Save Menu')

module ASM_Setup
SAVE_DIR = 'Saves/' #Save file location. Default(?): Saves
SAVE_EXT = '.rxdata' #Save file Extension. Default: rxdata
SAVE_MAX_FILES = 12
end

#==============================================================================
# ■ Window_File
#------------------------------------------------------------------------------
#  This window shows a list of recorded save files.
#==============================================================================

class Window_File < Window_Selectable
include ASM_Setup
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize()
super(0, 64, 320, 416)
self.contents = Bitmap.new(width - 32, SAVE_MAX_FILES * 32)
index = $game_temp.last_file_index == nil ? 0 : $game_temp.last_file_index
self.index = index
@item_max = SAVE_MAX_FILES
refresh
end
#--------------------------------------------------------------------------
# ● refresh the window
#--------------------------------------------------------------------------
def refresh
time_stamp = Time.at(0)
for i in 0...SAVE_MAX_FILES
filename = "Save#{i + 1}"+SAVE_EXT
self.contents.draw_text(1, i * 32, 32, 32, (i + 1).to_s, 1)
if FileTest.exist?(SAVE_DIR+filename)
size = File.size(SAVE_DIR+filename)
#if size.between?(1000, 999999)
if size.between?(1024, 1048575)
#size /= 1000
size /= 1024
size_str = "#{size} Kb"
#elsif size > 999999
elsif size > 1048575
#size /= 1000000
size /= 1048576
size_str = "#{size} Mb"
else
size_str = size.to_s
end
time_stamp = File.open(SAVE_DIR+filename, "r").mtime
date = time_stamp.strftime("%m/%d/%Y")
time = time_stamp.strftime("%H:%M")
self.contents.draw_text(38, i * 32, 120, 32, date)
self.contents.draw_text(160, i * 32, 100, 32, time)
self.contents.draw_text(0, i * 32, 284, 32, size_str, 2)
end
end
end
end

#==============================================================================
# ■ Window_FileStatus
#------------------------------------------------------------------------------
#  This window shows the status of the currently selected save file
#==============================================================================

class Window_FileStatus < Window_Base
include ASM_Setup
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize(save_window)
super(320, 64, 320, 416)
self.contents = Bitmap.new(width - 32, height - 32)
@save_window = save_window
@index = @save_window.index
rect = Rect.new(x + 16, y + (height - 32) / 2 + 16, width - 32, (height - 32) / 2)
@viewport = Viewport.new(rect)
@viewport.z = z + 10
refresh
end
#--------------------------------------------------------------------------
# ● dispose the map and the window
#--------------------------------------------------------------------------
def dispose
tilemap_dispose
@viewport.dispose
super
end
#--------------------------------------------------------------------------
# ● refresh the window
#--------------------------------------------------------------------------
def draw_actor_face(actor, x, y)
face = RPG::Cache.character("SaveFaces/" + actor.character_name, actor.character_hue)
fw = face.width
fh = face.height
src_rect = Rect.new(0, 0, fw, fh)
self.contents.blt(x - fw / 23, y - fh, face, src_rect)
end

def refresh
self.contents.clear
#tilemap_dispose
filename = "Save#{@index + 1}"+SAVE_EXT
return unless FileTest.exist?(SAVE_DIR+filename)
file = File.open(SAVE_DIR+filename, "r")
Marshal.load(file)
frame_count = Marshal.load(file)
for i in 0...6
Marshal.load(file)
end
party = Marshal.load(file)
Marshal.load(file)
map = Marshal.load(file)
for i in 0...party.actors.size
actor = party.actors[i]
#x = i % 1 * 144 +5
x = i % 2 * 144 + 4
#y = i / 1 * 94
#y = i / 2 * 64
y = i / 2 * 94
draw_actor_name(actor, x + 30, y)
draw_actor_level(actor, x + 30, y + 20)
draw_actor_graphic(actor, x + 10, y + 60)
#draw_actor_face(actor,x+10,y+400)
end
total_sec = frame_count / Graphics.frame_rate
hour = total_sec / 60 / 60
min = total_sec / 60 % 60
sec = total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
map_name = load_data("Data/MapInfos.rxdata")[map.map_id].name
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = system_color
#self.contents.draw_text(164, 125, 120, 32, "Play Time: ")
#self.contents.draw_text(164, 170, 120, 32, "Location: ")
self.contents.draw_text(0, 288, 120, 32, "Money:")
self.contents.draw_text(280-cx, 288, cx, 32, $data_system.words.gold, 2)
self.contents.draw_text(0, 320, 120, 32, "Play Time:")
self.contents.draw_text(0, 352, 120, 32, "Location:")
self.contents.font.color = normal_color
#self.contents.draw_text(184, 145, 120, 32, text)
#self.contents.draw_text(184, 190, 120, 32, map_name)
self.contents.draw_text(100, 288, 180-cx-2, 32, party.gold.to_s, 2)
self.contents.draw_text(100, 320, 180, 32, text, 2)
self.contents.draw_text(100, 352, 180, 32, map_name, 2)

#@tilemap = Tilemap.new(@viewport)
#@tilemap.tileset = RPG::Cache.tileset(map.tileset_name)
for i in 0..6
#autotile_name = map.autotile_names[i]
# @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
end
#@tilemap.map_data = map.data
#@tilemap.ox = map.display_x / 4 + 176
#@tilemap.oy = map.display_y / 4 + 148
end
#--------------------------------------------------------------------------
# ● tilemap_dispose
#--------------------------------------------------------------------------
def tilemap_dispose
unless @tilemap == nil
@tilemap.tileset.dispose
for i in 0..6
@tilemap.autotiles[i].dispose
end
@tilemap.dispose
@tilemap = nil
end
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
def update
@tilemap.update if @tilemap != nil
if @index != @save_window.index
@index = @save_window.index
refresh
end
super
end
end

#==============================================================================
# ■ Scene_File
#------------------------------------------------------------------------------
#  Base scene for load and save menus.
#==============================================================================

class Scene_File < SDK::Scene_Base
include ASM_Setup
#--------------------------------------------------------------------------
# ● initialize the scene
#--------------------------------------------------------------------------
def initialize(help_text)
@help_text = help_text
end
#--------------------------------------------------------------------------
# ● main
#--------------------------------------------------------------------------
def main_window
@help_window = Window_Help.new
@help_window.set_text(@help_text)
@file_window = Window_File.new
@status_window = Window_FileStatus.new(@file_window)
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
def update
super
if Input.trigger?(Input::C)
decision
$game_temp.last_file_index = @file_index
return
end
if Input.trigger?(Input::B)
cancel
return
end
end
#--------------------------------------------------------------------------
# ● return the selected file's name
#--------------------------------------------------------------------------
def filename
return "Save#{@file_window.index + 1}"+SAVE_EXT
end
end

#SDK Edit
#==============================================================================
# ■ Scene_Save
#------------------------------------------------------------------------------
#  Save menu
#==============================================================================

class Scene_Save < Scene_File
include ASM_Setup
#--------------------------------------------------------------------------
# ● initialize the save menu
#--------------------------------------------------------------------------
def initialize
super("Select a file to record your progress.")
overwrite_confirm_window
end
#--------------
def overwrite_confirm_window
@confirm_window = Window_Base.new(120, 188, 400, 64) #추가
@confirm_window.contents = Bitmap.new(368, 32)
string = "이 파일에 덮어쓰시겠습니까?"
#@confirm_window.contents.font.name = ["Arial","굴림"]
@confirm_window.contents.font.size = 24
@confirm_window.contents.draw_text(4, 0, 368, 32, string)
@yes_no_window = Window_Command.new(100, ["Yes", "No"])
@confirm_window.visible = false
@confirm_window.z = 1500
@yes_no_window.visible = false
@yes_no_window.active = false
@yes_no_window.index = 1
@yes_no_window.x = 270
@yes_no_window.y = 252
@yes_no_window.z = 1500
@mode = 0 #추가 끝
end
#--------------------------------------------------------------------------
# ● decision key pressed
#--------------------------------------------------------------------------
def decision
Dir.mkdir(SAVE_DIR) unless File.exist?(SAVE_DIR) # Make 'Saves' directory
if FileTest.exist?(SAVE_DIR+filename) #추가-저장할 파일을 덮어쓸 것인가?
@file_window.active = false
@confirm_window.visible = true
@yes_no_window.visible = true
@yes_no_window.active = true
@mode = 1
else
$game_system.se_play($data_system.save_se)
file = File.open(SAVE_DIR+filename, "wb")
write_save_data(file)
file.close
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
return
end
$scene = Scene_Menu.new(4)
end
end
# -----------------------------
def update
if @mode == 0
super
else
#@help_window.update
#@yes_no_window.update
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
if @yes_no_window.index == 0
savename = filename
$game_system.se_play($data_system.save_se)
file = File.open(SAVE_DIR+savename, "wb")
write_save_data(file)
file.close
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
else
$scene = Scene_Menu.new(4)
end
else
@yes_no_window.active = false
@confirm_window.visible = false
@yes_no_window.visible = false
@yes_no_window.active = false
@yes_no_window.index = 1
@file_window.active = true
@mode = 0
end
end
if Input.trigger?(Input::B)
@yes_no_window.active = false
@confirm_window.visible = false
@yes_no_window.visible = false
@yes_no_window.active = false
@yes_no_window.index = 1
@file_window.active = true
@mode = 0
return
end
end
end
#--------------------------------------------------------------------------
# ● cancel key pressed
#--------------------------------------------------------------------------
def cancel
$game_system.se_play($data_system.cancel_se)
if $game_temp.save_calling
$game_temp.save_calling = false
$scene = Scene_Map.new
return
end
$scene = Scene_Menu.new(4)
end
#--------------------------------------------------------------------------
# ● save the current data into the selected file
#--------------------------------------------------------------------------
def write_save_data(file)
write_characters(file)
write_frame(file)
write_setup(file)
write_data(file)
end
#--------------------------------------------------------------------------
# * Make Character Data
#--------------------------------------------------------------------------
def write_characters(file)
# Make character data for drawing save file
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
Marshal.dump(characters, file)
end
#--------------------------------------------------------------------------
# * Write Frame Count
#--------------------------------------------------------------------------
def write_frame(file)
# Wrire frame count for measuring play time
Marshal.dump(Graphics.frame_count, file)
end
#--------------------------------------------------------------------------
# * Write Setup
#--------------------------------------------------------------------------
def write_setup(file)
$game_system.save_count += 1
$game_system.magic_number = $data_system.magic_number
end
#--------------------------------------------------------------------------
# * Write Data
#--------------------------------------------------------------------------
def write_data(file)
# Write each type of game object
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
end
end

#SDK Edit
#==============================================================================
# ■ Scene_Load
#------------------------------------------------------------------------------
#  Load menu
#==============================================================================

class Scene_Load < Scene_File
include ASM_Setup
#--------------------------------------------------------------------------
# ● initialize the menu
#--------------------------------------------------------------------------
def initialize
$game_temp = Game_Temp.new
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..SAVE_MAX_FILES-1
filename = "Save#{i + 1}"+SAVE_EXT
if FileTest.exist?(SAVE_DIR+filename)
file = File.open(SAVE_DIR+filename, "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
end
super("Select a file to load.")
end
#--------------------------------------------------------------------------
# ● decision key pressed
#--------------------------------------------------------------------------
def decision
unless FileTest.exist?(SAVE_DIR+filename)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.load_se)
file = File.open(SAVE_DIR+filename, "rb")
read_save_data(file)
file.close
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
$game_map.update
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● cancel key pressed
#--------------------------------------------------------------------------
def cancel
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# ● load the selected file
#--------------------------------------------------------------------------
def read_save_data(file)
read_characters(file)
read_frame(file)
read_data(file)
read_edit
read_refresh
end
#--------------------------------------------------------------------------
# * Read Character Data
#--------------------------------------------------------------------------
def read_characters(file)
# Read character data for drawing save file
characters = Marshal.load(file)
end
#--------------------------------------------------------------------------
# * Read Frame Count
#--------------------------------------------------------------------------
def read_frame(file)
# Read frame count for measuring play time
Graphics.frame_count = Marshal.load(file)
end
#--------------------------------------------------------------------------
# * Read Data
#--------------------------------------------------------------------------
def read_data(file)
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
end
#--------------------------------------------------------------------------
# * Read Edit
#--------------------------------------------------------------------------
def read_edit
# If magic number is different from when saving
# (if editing was added with editor)
if $game_system.magic_number != $data_system.magic_number
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
end
#--------------------------------------------------------------------------
# * Refresh Game Party
#--------------------------------------------------------------------------
def read_refresh
# Refresh party members
$game_party.refresh
end
end


#SDK2 Edit
#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# This class performs title screen processing.
#==============================================================================

class Scene_Title < SDK::Scene_Base
#--------------------------------------------------------------------------
# * Main Test Initialization
#--------------------------------------------------------------------------
def main_test_continue
# Set Continued Enabled Flag
@continue_enabled = (Dir.glob(ASM_Setup::SAVE_DIR+'Save*'+ASM_Setup::SAVE_EXT).size > 0)
end
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
end


List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6153
1021 키입력 한글입력스크립트 16 file 아방스 2007.11.09 11823
1020 온라인 채팅 가능 온라인 스크립트 배포 107 file 아방스 2009.01.03 10680
1019 온라인 RPG 만들기 xp 온라인 스크립트 33 아방스 2007.11.09 9592
1018 맵/타일 [유니크급] RPG XP 게임을 3D화로 보자! Neo Mode7 script / 52 file 쉴더 2009.02.28 9441
1017 온라인 온라인 스크립트 Unis Net RMXP 공식 배포! 25 file 뮤바보 2011.12.25 9400
1016 온라인 광넷[ 광땡 온라인 + 넷플레이 ] 62 - 하늘 - 2009.08.02 9003
1015 전투 [액알]neo_a-rpg_module_1[1][1].2 스크립트 83 file 은빛바람 2009.10.03 8298
1014 이름입력 대화창에 얼굴, 이름 띄우기 37 킬라롯 2008.11.09 7496
1013 온라인 넷플레이1.7.0+abs5.5+한챗 49 쀍뛝쒧 2009.01.24 7286
1012 메뉴 메이플스토리처럼 메뉴를^^ 57 file 딸기님 2010.07.13 7140
1011 메시지 대화창에 얼굴 그래픽 띠우기 73 아방스 2007.11.09 7117
1010 스킬 ABP액알 v1.2 스킬추가, 버그수정판 36 file 백호 2009.02.22 6919
1009 전투 [신기술 체험] 강회된 횡스크롤 액알 13 file 백호 2009.02.22 6841
1008 메뉴 온라인메뉴처럼!! 메이플 메뉴처럼!! 변신~스크립트 33 WMN 2008.03.17 6815
1007 그래픽 화면을 부드럽게 해주는스크립트[ 아주 유용] 56 file - 하늘 - 2009.08.05 6561
1006 온라인 Mr.Metring NPE 1.0 [RPG XP 온라인 스크립트] 35 아방스 2009.01.07 6535
1005 이름입력 케릭터 위에 또는 NPC 위에 이름 뛰우기 [헬악이님 제공] 49 file 아방스 2007.11.09 6406
1004 액터 시트르산의 XP용 감정 말풍선 표시 스크립트 37 file 시트르산 2011.01.25 6110
1003 HUD 주인공,NPC이름 머리 나타내기 49 file 송긔 2010.11.28 6060
1002 전투 액알 스크립트 24 백호 2009.02.22 6013
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 52 Next
/ 52