Script Title:
Add Actor to Database
RMXP or RMVX:
XP
Detailed Description:
I'm looking for, if possible, a way to add actors to the database (or similar) from scripts in events / common events. Its for a pet / monster raising system. You find a monsters egg, hatch it, the new monster becomes available as a party member, with its own stats, class etc. All monsters in a class will have the same stats, char/battler graphics, ie. at level 1 hp will be 550, at 99 it'll be 5450
Other Scripts I am using (in order):
More than 4 choices
Key items
Add Actor to Database
RMXP or RMVX:
XP
Detailed Description:
I'm looking for, if possible, a way to add actors to the database (or similar) from scripts in events / common events. Its for a pet / monster raising system. You find a monsters egg, hatch it, the new monster becomes available as a party member, with its own stats, class etc. All monsters in a class will have the same stats, char/battler graphics, ie. at level 1 hp will be 550, at 99 it'll be 5450
Other Scripts I am using (in order):
More than 4 choices
#==============================================================================
class Window_Choices < Window_Selectable
#--------------------------------------------------------------------------
def initialize(width)
super(0, 0, width, 32 * $game_temp.choice_text.size + 32)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = $game_temp.choice_text.size
self.index = 0
@width = width
refresh
end
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...$game_temp.choice_text.size
x = 2
y = i * 32
self.contents.draw_text(x, y, @width, 32, $game_temp.choice_text)
end
end
#--------------------------------------------------------------------------
def update_cursor_rect
if @index >= 0
if @width != nil
self.cursor_rect.set(0, @index * 32, @width - 43, 32)
end
else
self.cursor_rect.empty
end
end
end
class Window_Choices < Window_Selectable
#--------------------------------------------------------------------------
def initialize(width)
super(0, 0, width, 32 * $game_temp.choice_text.size + 32)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = $game_temp.choice_text.size
self.index = 0
@width = width
refresh
end
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...$game_temp.choice_text.size
x = 2
y = i * 32
self.contents.draw_text(x, y, @width, 32, $game_temp.choice_text)
end
end
#--------------------------------------------------------------------------
def update_cursor_rect
if @index >= 0
if @width != nil
self.cursor_rect.set(0, @index * 32, @width - 43, 32)
end
else
self.cursor_rect.empty
end
end
end
Key items
#==============================================================================
# ■ Scene_Keyitem
#------------------------------------------------------------------------------
# アイテム画面の処理を行うクラスです。
#==============================================================================
class Scene_Keyitem
#--------------------------------------------------------------------------
# ● メイン処理
#--------------------------------------------------------------------------
def main
# ヘルプウィンドウ、アイテムウィンドウを作成
@help_window = Window_Help.new
@keyitem_window = Window_keyitem.new
# ヘルプウィンドウを関連付け
@keyitem_window.help_window = @help_window
# ターゲットウィンドウを作成 (不可視・非アクティブに設定)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# トランジション実行
Graphics.transition
# メインループ
loop do
# ゲーム画面を更新
Graphics.update
# 入力情報を更新
Input.update
# フレーム更新
update
# 画面が切り替わったらループを中断
if $scene != self
break
end
end
# トランジション準備
Graphics.freeze
# ウィンドウを解放
@help_window.dispose
@keyitem_window.dispose
@target_window.dispose
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
# ウィンドウを更新
@help_window.update
@keyitem_window.update
@target_window.update
# アイテムウィンドウがアクティブの場合: update_item を呼ぶ
if @keyitem_window.active
update_item
return
end
# ターゲットウィンドウがアクティブの場合: update_target を呼ぶ
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (アイテムウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_item
# B ボタンが押された場合
if Input.trigger?(Input::B )
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# メニュー画面に切り替え
$scene = Scene_Menu.new(1)
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムウィンドウで現在選択されているデータを取得
@item = @keyitem_window.item
# 使用アイテムではない場合
unless @item.is_a?(RPG::Item)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 使用できない場合
unless $game_party.item_can_use?(@item.id)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# 効果範囲が味方の場合
if @item.scope >= 3
# ターゲットウィンドウをアクティブ化
@keyitem_window.active = false
@target_window.x = (@keyitem_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# 効果範囲 (単体/全体) に応じてカーソル位置を設定
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# 効果範囲が味方以外の場合
else
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@keyitem_window.draw_item(@keyitem_window.index)
end
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (ターゲットウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_target
# B ボタンが押された場合
if Input.trigger?(Input::B )
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# アイテム切れなどで使用できなくなった場合
unless $game_party.item_can_use?(@item.id)
# アイテムウィンドウの内容を再作成
@keyitem_window.refresh
end
# ターゲットウィンドウを消去
@keyitem_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムを使い切った場合
if $game_party.item_number(@item.id) == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# ターゲットが全体の場合
if @target_window.index == -1
# パーティ全体にアイテムの使用効果を適用
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# ターゲットが単体の場合
if @target_window.index >= 0
# ターゲットのアクターにアイテムの使用効果を適用
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# アイテムを使った場合
if used
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@keyitem_window.draw_item(@keyitem_window.index)
end
# ターゲットウィンドウの内容を再作成
@target_window.refresh
# 全滅の場合
if $game_party.all_dead?
# ゲームオーバー画面に切り替え
$scene = Scene_Gameover.new
return
end
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
# アイテムを使わなかった場合
unless used
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
# ■ Scene_Keyitem
#------------------------------------------------------------------------------
# アイテム画面の処理を行うクラスです。
#==============================================================================
class Scene_Keyitem
#--------------------------------------------------------------------------
# ● メイン処理
#--------------------------------------------------------------------------
def main
# ヘルプウィンドウ、アイテムウィンドウを作成
@help_window = Window_Help.new
@keyitem_window = Window_keyitem.new
# ヘルプウィンドウを関連付け
@keyitem_window.help_window = @help_window
# ターゲットウィンドウを作成 (不可視・非アクティブに設定)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# トランジション実行
Graphics.transition
# メインループ
loop do
# ゲーム画面を更新
Graphics.update
# 入力情報を更新
Input.update
# フレーム更新
update
# 画面が切り替わったらループを中断
if $scene != self
break
end
end
# トランジション準備
Graphics.freeze
# ウィンドウを解放
@help_window.dispose
@keyitem_window.dispose
@target_window.dispose
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
# ウィンドウを更新
@help_window.update
@keyitem_window.update
@target_window.update
# アイテムウィンドウがアクティブの場合: update_item を呼ぶ
if @keyitem_window.active
update_item
return
end
# ターゲットウィンドウがアクティブの場合: update_target を呼ぶ
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (アイテムウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_item
# B ボタンが押された場合
if Input.trigger?(Input::B )
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# メニュー画面に切り替え
$scene = Scene_Menu.new(1)
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムウィンドウで現在選択されているデータを取得
@item = @keyitem_window.item
# 使用アイテムではない場合
unless @item.is_a?(RPG::Item)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 使用できない場合
unless $game_party.item_can_use?(@item.id)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# 効果範囲が味方の場合
if @item.scope >= 3
# ターゲットウィンドウをアクティブ化
@keyitem_window.active = false
@target_window.x = (@keyitem_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# 効果範囲 (単体/全体) に応じてカーソル位置を設定
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# 効果範囲が味方以外の場合
else
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@keyitem_window.draw_item(@keyitem_window.index)
end
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (ターゲットウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_target
# B ボタンが押された場合
if Input.trigger?(Input::B )
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# アイテム切れなどで使用できなくなった場合
unless $game_party.item_can_use?(@item.id)
# アイテムウィンドウの内容を再作成
@keyitem_window.refresh
end
# ターゲットウィンドウを消去
@keyitem_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムを使い切った場合
if $game_party.item_number(@item.id) == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# ターゲットが全体の場合
if @target_window.index == -1
# パーティ全体にアイテムの使用効果を適用
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# ターゲットが単体の場合
if @target_window.index >= 0
# ターゲットのアクターにアイテムの使用効果を適用
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# アイテムを使った場合
if used
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@keyitem_window.draw_item(@keyitem_window.index)
end
# ターゲットウィンドウの内容を再作成
@target_window.refresh
# 全滅の場合
if $game_party.all_dead?
# ゲームオーバー画面に切り替え
$scene = Scene_Gameover.new
return
end
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
# アイテムを使わなかった場合
unless used
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
#==============================================================================
# ■ Window_Item
#------------------------------------------------------------------------------
# アイテム画面、バトル画面で、所持アイテムの一覧を表示するウィンドウです。
#==============================================================================
class Window_keyitem < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 64, 640, 416)
@column_max = 2
refresh
self.index = 0
# 戦闘中の場合はウィンドウを画面中央へ移動し、半透明にする
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# ● アイテムの取得
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# アイテムを追加
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
for x in 0...$key_items_ids.size
if i == $key_items_ids
# ■ Window_Item
#------------------------------------------------------------------------------
# アイテム画面、バトル画面で、所持アイテムの一覧を表示するウィンドウです。
#==============================================================================
class Window_keyitem < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 64, 640, 416)
@column_max = 2
refresh
self.index = 0
# 戦闘中の場合はウィンドウを画面中央へ移動し、半透明にする
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# ● アイテムの取得
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# アイテムを追加
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
for x in 0...$key_items_ids.size
if i == $key_items_ids