08-30-2005, 01:00 PM
3 person CMS
RPG Fan
Aug 30 2005
I made a 3 person CMS for my game. I hope you enjoy it.
Update:
New Load Command that fully works.
^ In a new script above main!
^ Replace Scene_Load
PS. You WILL get an error if you try and use a party of more than 3 and enter the menu.
RPG Fan
Aug 30 2005
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
I made a 3 person CMS for my game. I hope you enjoy it.
Update:
New Load Command that fully works.
Menu
Code:
#================================
# 3 Person CMS by RPG Fan (R2
# Thanks to Dubealex and XRXS for Location and
# Transparency
#================================
#==============================================================================
# ■ Window_MenuStatus
#------------------------------------------------------------------------------
# メニュー画面でパーティメンバーのステータスを表示するウィンドウです。
#==============================================================================
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 0, 480, 333)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype # "Main" window font
self.contents.font.size = $defaultfontsize
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
if @item_max >= 4
print ("This menu was designed for 3 people")
exit
end
for i in 0...$game_party.actors.size
x = 64
y = i * 100
actor = $game_party.actors[i]
draw_actor_graphic(actor, x - 40, y + 80)
draw_actor_name(actor, x, y)
#draw_actor_class(actor, x + 144, y)
draw_actor_level(actor, x, y + 32)
draw_actor_state(actor, x + 90, y + 32)
draw_actor_exp(actor, x, y + 64)
draw_actor_hp(actor, x + 236, y + 32)
draw_actor_sp(actor, x + 236, y + 64)
end
end
#--------------------------------------------------------------------------
# ● カーソルの矩形更新
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 100, self.width - 32, 96)
end
end
end
class Window_Info < Window_Base
def initialize
super(0,0,640,90)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype # "Number of Steps" window font
self.contents.font.size = $defaultfontsize
refresh
end
def refresh
# Gold
x = 4
y = 0
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
temp_x = x + 120
self.contents.draw_text(4, y, 120-cx-2, 32, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(50-cx, y, cx, 32, $data_system.words.gold, 2)
x += 200
# Playtime
self.contents.font.color = system_color
self.contents.draw_text(x, y, 120, 32, "Play Time")
@total_sec = Graphics.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)
self.contents.font.color = normal_color
self.contents.draw_text(x, y + 32, 120, 32, text, 2)
x += 200
# Location
self.contents.font.color = system_color
self.contents.draw_text(x,y, 120, 32, "Location")
self.contents.font.color = normal_color
self.contents.draw_text(x, y + 32, 120, 32, $game_map.name.to_s, 2)
end
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#=========================================
# ▼ CLASS Game_Map Additional Code Begins
#=========================================
class Game_Map
#Dubealex's Addition (from XRXS) to show Map Name on screen
def name
$map_infos[@map_id]
end
end
#=========================================
# ▲ CLASS Game_Map Additional Code Ends
#=========================================
#=========================================
# ▼ CLASS Scene_Title Additional Code Begins
#=========================================
class Scene_Title
#Dubealex's Addition (from XRXS) to show Map Name on screen
$map_infos = load_data("Data/MapInfos.rxdata")
for key in $map_infos.keys
$map_infos[key] = $map_infos[key].name
end
end
#=========================================
# ▲ CLASS Scene_Title Additional Code Ends
#=========================================
#================================================= =============================
# â– Window_Base
#================================================= =============================
class Window_Base < Window
alias xrxs_mp7_initialize initialize
def initialize(x, y, width, height)
xrxs_mp7_initialize(x, y, width, height)
if $scene.is_a?(Scene_Menu) or
$scene.is_a?(Scene_Item) or
$scene.is_a?(Scene_Skill) or
$scene.is_a?(Scene_Equip) or
$scene.is_a?(Scene_Status) or
$scene.is_a?(Scene_Save) or
$scene.is_a?(Scene_End)
self.back_opacity = 170
end
end
end
#================================================= =============================
# â–¡ XRXS_MP7_Module
#================================================= =============================
module XRXS_MP7_Module
def create_spriteset
@spriteset_bgmap = Spriteset_Map.new
end
def dispose_spriteset
@spriteset_bgmap.dispose
end
end
#================================================= =============================
# â– Scene_Menu
#================================================= =============================
class Scene_Menu
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
end
#================================================= =============================
# â– Scene_Item
#================================================= =============================
class Scene_Item
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
end
#================================================= =============================
# â– Scene_Skill
#================================================= =============================
class Scene_Skill
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
end
#================================================= =============================
# â– Scene_Equip
#================================================= =============================
class Scene_Equip
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
end
#================================================= =============================
# â– Scene_Status
#================================================= =============================
class Scene_Status
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
end
#================================================= =============================
# â– Scene_Save
#================================================= =============================
class Scene_Save
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
end
#================================================= =============================
# â– Scene_End
#================================================= =============================
class Scene_End
include XRXS_MP7_Module
alias xrxs_mp7_main main
def main
create_spriteset
xrxs_mp7_main
dispose_spriteset
end
end
#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
# メニュー画面の処理を行うクラスです。
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# menu_index : コマンドのカーソル初期位置
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
@windows = []
end
#--------------------------------------------------------------------------
# ● メイン処理
#--------------------------------------------------------------------------
def main
# コマンドウィンドウを作成
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "Status"
s5 = "Save"
s6 = "Load"
s7 = "Exit"
@spriteset = Spriteset_Map.new
@windows[0] = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
@windows[0].index = @menu_index
@windows[0].x = 640 - @windows[0].width
# パーティ人数が 0 人の場合
if $game_party.actors.size == 0
# アイテム、スキル、装備、ステータスを無効化
@windows[0].disable_item(0)
@windows[0].disable_item(1)
@windows[0].disable_item(2)
@windows[0].disable_item(3)
end
# セーブ禁止の場合
if $game_system.save_disabled
# セーブを無効にする
@windows[0].disable_item(4)
end
for i in 0..3
if FileTest.exist?("Save#{i+1}.sav")
@load = true
end
end
if @load != true
@load = false
@windows[0].disable_item(5)
end
# info window
@windows[1] = Window_Info.new
@windows[1].y = 480 - @windows[1].height
# ステータスウィンドウを作成
@windows[2] = Window_MenuStatus.new
@windows[2].x = 0
@windows[2].y = 0
# トランジション実行
Graphics.transition
# メインループ
loop do
# ゲーム画面を更新
Graphics.update
# 入力情報を更新
Input.update
# フレーム更新
update
# 画面が切り替わったらループを中断
if $scene != self
break
end
end
# トランジション準備
Graphics.freeze
# ウィンドウを解放
for i in 0...@windows.size
@windows[i].dispose
end
@spriteset.dispose
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
# ウィンドウを更新
for i in 0...@windows.size
@windows[i].update
end
# コマンドウィンドウがアクティブの場合: update_command を呼ぶ
if @windows[0].active
update_command
return
end
# ステータスウィンドウがアクティブの場合: update_status を呼ぶ
if @windows[2].active
update_status
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (コマンドウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_command
# 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)
# パーティ人数が 0 人で、セーブ、ゲーム終了以外のコマンドの場合
if $game_party.actors.size == 0 and @command_window.index < 4
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# コマンドウィンドウのカーソル位置で分岐
case @windows[0].index
when 0 # アイテム
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# アイテム画面に切り替え
$scene = Scene_Item.new
when 1 # スキル
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# ステータスウィンドウをアクティブにする
@windows[0].active = false
@windows[2].active = true
@windows[2].index = 0
when 2 # 装備
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# ステータスウィンドウをアクティブにする
@windows[0].active = false
@windows[2].active = true
@windows[2].index = 0
when 3 # ステータス
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# ステータスウィンドウをアクティブにする
@windows[0].active = false
@windows[2].active = true
@windows[2].index = 0
when 4 # セーブ
# セーブ禁止の場合
if $game_system.save_disabled
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# セーブ画面に切り替え
$scene = Scene_Save.new
when 5
if @load == true
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# ゲーム終了画面に切り替え
$scene = Scene_Load.new(true)
else
$game_system.se_play($data_system.buzzer_se)
end
when 6 # ゲーム終了
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# ゲーム終了画面に切り替え
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (ステータスウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_status
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# コマンドウィンドウをアクティブにする
@windows[0].active = true
@windows[2].active = false
@windows[2].index = -1
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# コマンドウィンドウのカーソル位置で分岐
case @windows[0].index
when 1 # スキル
# このアクターの行動制限が 2 以上の場合
if $game_party.actors[@windows[2].index].restriction >= 2
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# スキル画面に切り替え
$scene = Scene_Skill.new(@windows[2].index)
when 2 # 装備
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# 装備画面に切り替え
$scene = Scene_Equip.new(@windows[2].index)
when 3 # ステータス
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# ステータス画面に切り替え
$scene = Scene_Status.new(@windows[2].index)
end
return
end
end
end
^ In a new script above main!
Scene_Load
Code:
#==============================================================================
# ■ Scene_Load
#------------------------------------------------------------------------------
# ロード画面の処理を行うクラスです。
#==============================================================================
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(from_menu = false)
@from_menu = from_menu
# テンポラリオブジェクトを再作成
$game_temp = Game_Temp.new
# タイムスタンプが最新のファイルを選択
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..3
filename = make_filename(i)
if FileTest.exist?(filename)
file = File.open(filename, "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
end
super("Load from which file")
end
#--------------------------------------------------------------------------
# ● 決定時の処理
#--------------------------------------------------------------------------
def on_decision(filename)
# ファイルが存在しない場合
unless FileTest.exist?(filename)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# ロード SE を演奏
$game_system.se_play($data_system.load_se)
# セーブデータの書き込み
file = File.open(filename, "rb")
read_save_data(file)
file.close
# BGM、BGS を復帰
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
# マップを更新 (並列イベント実行)
$game_map.update
# マップ画面に切り替え
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● キャンセル時の処理
#--------------------------------------------------------------------------
def on_cancel
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# タイトル画面に切り替え
if @from_menu = false
$scene = Scene_Title.new
else
$scene = Scene_Menu.new(5)
end
end
#--------------------------------------------------------------------------
# ● セーブデータの読み込み
# file : 読み込み用ファイルオブジェクト (オープン済み)
#--------------------------------------------------------------------------
def read_save_data(file)
# セーブファイル描画用のキャラクターデータを読み込む
characters = Marshal.load(file)
# プレイ時間計測用のフレームカウントを読み込む
Graphics.frame_count = Marshal.load(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)
# マジックナンバーがセーブ時と異なる場合
# (エディタで編集が加えられている場合)
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
# パーティメンバーをリフレッシュ
$game_party.refresh
end
end
^ Replace Scene_Load
PS. You WILL get an error if you try and use a party of more than 3 and enter the menu.