#============================================================================== # ○ポイント制パラメーター成長 Ver1.03 # for RGSS2 # 西瓜 / Space not far # http://muspell.raindrop.jp/ # レベルアップなどで得たポイントを割り振ることで # 能力値を上げることの出来るシステムです。 #============================================================================== # ■更新履歴 # Ver1.03 # ・キャラ初期化時ポイントが初期化されない不具合を修正。 # ・PP_DIGITS_MAXを編集したときカーソル位置がおかしなことになる # 不具合を修正。 # Ver1.02 # ・パラメータ上昇上限を追加。 # Ver1.01 # ・PPと間違ってSP(○ポイント制スキル習得で使用されている項目)と #  記述してしまい、正常に動作していなかったのを修正。 #============================================================================== # イベントコマンドのスクリプトでsnf_grow_pp(増加値, アクターID)と # 記述することでそのIDのアクターのポイントを増加値分プラスすることができます。 # アクターIDを0にしたり省略したりした場合、パーティ全員にプラスされます。 # また、増加値にマイナスの値を設定することも可能です。 module SNF PP_WORD = "PP" # ポイントの名称 NEEDPP_WORD = "必要PP" # 必要ポイント PP_HEAD = "パラメーター振り分け画面" # 振り分け画面の見出し PP_FROMSTATUS = true # ステータス画面から決定キーを押すと移行するようにするか?(true/false) # false の場合は各自改造して利用してください。 PP_FROMSTATUS_MES = "決定キー:パラメーター振り分け画面" # true の場合、ステータス画面に表示する説明 PP_LIMIT_EXIST = true # 上昇回数に上限を設けるか否か?(true/false) PP_LIMIT = [1000, 1000, 100, 100, 100, 100] # [最大HP,最大MP,攻撃力,防御力,精神力,敏捷性]の上昇上限 PP_LIMITOVER_TEXT = "これ以上成長させられません" # 上昇上限を超過している時表示されるテキスト PP_COSTOVER_TEXT = "必要PPが足りません" # 必要PPが足りない時表示されるテキスト DEFAULT_PP = 100 # 各アクターの初期ポイント GLOW_PP = 10 # レベルアップ時に上昇するポイント PP_DIGITS_MAX = 2 # 一度に振り分けられるポイントの最大桁数 PP_RETURN = Scene_Menu.new(3) # 終了時に戻るシーン def self.pp_cost(value, index) # ■必要ポイントの算出 # ここを改変することで能力値ごとに必要な # ポイントの計算式を変えることが出来ます。 # value:上昇能力値 result:必要ポイント # よくわからない人は諦めてください。 case index when 0 # 最大HP result = value * 2 when 1 # 最大MP result = value * 4 when 2 # 攻撃力 result = value * 6 when 3 # 防御力 result = value * 6 when 4 # 精神力 result = value * 6 when 5 # 敏捷性 result = value * 6 end return result # ■豆知識 # +:加算 -:減算 *:乗算 /:除算 **:二乗 end end class Scene_GrowStatus < Scene_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 # actor_index : アクターインデックス #-------------------------------------------------------------------------- def initialize(actor_index = 0) @actor_index = actor_index end #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super @wait_count = 0 create_menu_background @actor = $game_party.members[@actor_index] @status_window = Window_GrowStatus.new(@actor) @input_window = Window_GrowInput.new(172, 108, 544, 64, @actor) @limit_window = Window_GrowLimit.new @limit_window.opacity = 0 @limit_window.contents_opacity = 0 end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- def terminate super dispose_menu_background @status_window.dispose @input_window.dispose @limit_window.dispose end #-------------------------------------------------------------------------- # ● 元の画面へ戻る #-------------------------------------------------------------------------- def return_scene $scene = SNF::PP_RETURN end #-------------------------------------------------------------------------- # ● 次のアクターの画面に切り替え #-------------------------------------------------------------------------- def next_actor @actor_index += 1 @actor_index %= $game_party.members.size $scene = Scene_GrowStatus.new(@actor_index) end #-------------------------------------------------------------------------- # ● 前のアクターの画面に切り替え #-------------------------------------------------------------------------- def prev_actor @actor_index += $game_party.members.size - 1 @actor_index %= $game_party.members.size $scene = Scene_GrowStatus.new(@actor_index) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update if @wait_count > 0 @wait_count -= 1 end update_menu_background @input_window.update @status_window.update @input_window.refresh(@status_window.index) if @status_window.active == true if Input.trigger?(Input::B) Sound.play_cancel return_scene elsif Input.trigger?(Input::R) Sound.play_cursor next_actor elsif Input.trigger?(Input::L) Sound.play_cursor prev_actor elsif Input.trigger?(Input::C) @wait_count = 1 # リピートよけ Sound.play_decision number = 0 @input_window.digits_max = SNF::PP_DIGITS_MAX @input_window.number = number @input_window.y = 172 + 24 * @status_window.index @input_window.visible = true @input_window.active = true @status_window.active = false @input_window.refresh(@status_window.index) end elsif @limit_window.active @input_window.active = false if Input.trigger?(Input::C) @wait_count = 1 # リピートよけ @input_window.active = true @limit_window.contents_opacity = 0 @limit_window.active = false end elsif if @input_window.active input_number end end super end def input_number if Input.trigger?(Input::C) if @actor.pp < @input_window.need_pp(@input_window.number,@status_window.index) Sound.play_buzzer @limit_window.refresh(1) @limit_window.contents_opacity = 255 @limit_window.active = true return false end if SNF::PP_LIMIT_EXIST # 上昇上限判定 case @status_window.index when 0 temp = @actor.maxhp_pp when 1 temp = @actor.maxmp_pp when 2 temp = @actor.atk_pp when 3 temp = @actor.def_pp when 4 temp = @actor.spi_pp when 5 temp = @actor.agi_pp end if (temp + @input_window.number) > SNF::PP_LIMIT[@status_window.index] Sound.play_buzzer @limit_window.refresh @limit_window.contents_opacity = 255 @limit_window.active = true return false end end Sound.play_decision @actor.pp -= @input_window.need_pp(@input_window.number, @status_window.index) case @status_window.index when 0 @actor.maxhp += @input_window.number @actor.maxhp_pp += @input_window.number when 1 @actor.maxmp += @input_window.number @actor.maxmp_pp += @input_window.number when 2 @actor.atk += @input_window.number @actor.atk_pp += @input_window.number when 3 @actor.def += @input_window.number @actor.def_pp += @input_window.number when 4 @actor.spi += @input_window.number @actor.spi_pp += @input_window.number when 5 @actor.agi += @input_window.number @actor.agi_pp += @input_window.number end @status_window.refresh @input_window.visible = false @input_window.active = false @status_window.active = true elsif Input.trigger?(Input::B) Sound.play_cancel @input_window.visible = false @input_window.active = false @status_window.active = true end end end if SNF::PP_FROMSTATUS class Scene_Status < Scene_Base alias snf_pp_update update def update snf_pp_update update_menu_background @status_window.update if Input.trigger?(Input::C) Sound.play_decision $scene = Scene_GrowStatus.new(@actor_index) end super end end class Window_Status < Window_Base #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- alias snf_pp_refresh refresh def refresh snf_pp_refresh self.contents.font.size = Font.default_size - 4 self.contents.font.color = system_color self.contents.draw_text(256, 360, 256, WLH, SNF::PP_FROMSTATUS_MES, 2) self.contents.font.color = normal_color self.contents.font.size = Font.default_size end end end class Game_Actor #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :pp attr_accessor :maxhp_pp attr_accessor :maxmp_pp attr_accessor :atk_pp attr_accessor :def_pp attr_accessor :spi_pp attr_accessor :agi_pp alias snf_pp_initialize initialize def initialize(actor_id) snf_pp_initialize(actor_id) @pp = SNF::DEFAULT_PP @maxhp_pp = 0 @maxmp_pp = 0 @atk_pp = 0 @def_pp = 0 @spi_pp = 0 @agi_pp = 0 end #-------------------------------------------------------------------------- # ● セットアップ # actor_id : アクター ID #-------------------------------------------------------------------------- alias snf_pp_setup setup def setup(actor_id) snf_pp_setup(actor_id) @pp = SNF::DEFAULT_PP @maxhp_pp = 0 @maxmp_pp = 0 @atk_pp = 0 @def_pp = 0 @spi_pp = 0 @agi_pp = 0 end end class Game_Actor < Game_Battler alias snf_pp_level_up level_up def level_up self.pp += SNF::GLOW_PP snf_pp_level_up # メソッド呼び戻し end end class Game_Interpreter #-------------------------------------------------------------------------- # ● PP の増減 #-------------------------------------------------------------------------- def snf_grow_pp(value, actor_id = 0) iterate_actor_id(actor_id) do |actor| actor.pp += value end return true end end class Window_GrowStatus < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 # x : ウィンドウの X 座標 # y : ウィンドウの Y 座標 #-------------------------------------------------------------------------- def initialize(actor) super(0, 0, 544, 416) @actor = actor refresh @column_max = 1 self.active = true self.index = 0 end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear @item_max = 6 draw_actor_face(@actor, 56, 68) draw_actor_name(@actor, 204, 68) draw_actor_graphic(@actor, 184, 112) draw_actor_class(@actor, 204, 90) wlh2 = WLH self.contents.font.color = system_color self.contents.draw_text(24, 24, 240, wlh2, SNF::PP_HEAD) self.contents.draw_text(204, 124, 64, wlh2, SNF::PP_WORD) self.contents.font.color = normal_color self.contents.draw_text(268, 124, 48, wlh2, @actor.pp, 2) self.contents.font.color = system_color x = 52 y = 172 self.contents.draw_text(x, y + wlh2 * 0, 60, wlh2, Vocab::hp) self.contents.draw_text(x, y + wlh2 * 1, 60, wlh2, Vocab::mp) self.contents.draw_text(x, y + wlh2 * 2, 60, wlh2, Vocab::atk) self.contents.draw_text(x, y + wlh2 * 3, 60, wlh2, Vocab::def) self.contents.draw_text(x, y + wlh2 * 4, 60, wlh2, Vocab::spi) self.contents.draw_text(x, y + wlh2 * 5, 60, wlh2, Vocab::agi) x += 76 self.contents.font.color = normal_color self.contents.draw_text(x, y + wlh2 * 0, 40, wlh2, @actor.maxhp, 2) self.contents.draw_text(x, y + wlh2 * 1, 40, wlh2, @actor.maxmp, 2) self.contents.draw_text(x, y + wlh2 * 2, 40, wlh2, @actor.atk, 2) self.contents.draw_text(x, y + wlh2 * 3, 40, wlh2, @actor.def, 2) self.contents.draw_text(x, y + wlh2 * 4, 40, wlh2, @actor.spi, 2) self.contents.draw_text(x, y + wlh2 * 5, 40, wlh2, @actor.agi, 2) x += 56 gc1 = Color.new(192, 192, 128) gc2 = Color.new(192, 192, 128) =begin for i in 0..5 gw = 352 case i when 0 ; para = @actor.maxhp when 1 ; para = @actor.maxmp when 2 ; para = @actor.atk when 3 ; para = @actor.def when 4 ; para = @actor.spi when 5 ; para = @actor.agi end gw *= para if i <= 1 gw /= 9999 else gw /= 999 end gw *= 10 self.contents.gradient_fill_rect(x, y + 18 + wlh2 * i, gw, 4, gc1 ,gc2) end =end end def update_cursor if @index < 0 # カーソルなし self.cursor_rect.empty else self.cursor_rect.set(48, 172 + 24 * @index, 124, 24) end end end class Window_GrowInput < Window_Base attr_accessor :status_index #-------------------------------------------------------------------------- # ● オブジェクト初期化 # digits_max : 桁数 #-------------------------------------------------------------------------- def initialize(x, y, weight, height, actor) super(x, y, weight, height) @actor = actor @number = 0 @digits_max = SNF::PP_DIGITS_MAX @index = SNF::PP_DIGITS_MAX - 1 self.visible = false self.opacity = 0 self.active = false self.z += 9999 update_cursor end #-------------------------------------------------------------------------- # ● 数値の取得 #-------------------------------------------------------------------------- def number return @number end #-------------------------------------------------------------------------- # ● 数値の設定 # number : 新しい数値 #-------------------------------------------------------------------------- def number=(number) @number = [[number, 0].max, 10 ** @digits_max - 1].min end #-------------------------------------------------------------------------- # ● 桁数の取得 #-------------------------------------------------------------------------- def digits_max return @digits_max end #-------------------------------------------------------------------------- # ● 桁数の設定 # digits_max : 新しい桁数 #-------------------------------------------------------------------------- def digits_max=(digits_max) @digits_max = digits_max #refresh end #-------------------------------------------------------------------------- # ● カーソルを右に移動 # wrap : ラップアラウンド許可 #-------------------------------------------------------------------------- def cursor_right(wrap) if @index < @digits_max - 1 or wrap @index = (@index + 1) % @digits_max end end #-------------------------------------------------------------------------- # ● カーソルを左に移動 # wrap : ラップアラウンド許可 #-------------------------------------------------------------------------- def cursor_left(wrap) if @index > 0 or wrap @index = (@index + @digits_max - 1) % @digits_max end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super if self.active if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN) place = 10 ** (@digits_max - 1 - @index) n = @number / place % 10 @number -= n * place n = (n + 1) % 10 if Input.repeat?(Input::UP) n = (n + 9) % 10 if Input.repeat?(Input::DOWN) Sound.play_cursor @number += n * place end last_index = @index if Input.repeat?(Input::RIGHT) cursor_right(Input.trigger?(Input::RIGHT)) end if Input.repeat?(Input::LEFT) cursor_left(Input.trigger?(Input::LEFT)) end if @index != last_index Sound.play_cursor end update_cursor end end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh(status_index) @status_index = status_index if @pp != need_pp(@number,status_index) self.contents.clear self.contents.font.color = normal_color s = sprintf("%0*d", @digits_max, @number) for i in 0...@digits_max self.contents.draw_text(48 + i * 16, 0, 16, WLH, s[i,1], 1) end self.contents.draw_text(24, 0, 32, WLH, "+") self.contents.font.color = system_color self.contents.draw_text(128, 0, 104, WLH, SNF::NEEDPP_WORD) self.contents.font.color = (@actor.pp >= need_pp(@number,status_index)) ? normal_color : crisis_color self.contents.draw_text(216, 0, 64, WLH, need_pp(@number,status_index), 2) self.contents.font.color = normal_color @pp = need_pp(@number,status_index) end end def need_pp(value, index) return SNF.pp_cost(value, index) end #-------------------------------------------------------------------------- # ● カーソルの更新 #-------------------------------------------------------------------------- def update_cursor self.cursor_rect.set(48 + @index * 16, 0, 16, WLH) end end class Window_GrowLimit < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 360, 544, WLH + 32) self.active = false end def refresh(n = 0) case n when 0 self.contents.clear self.contents.draw_text(0, 0, 544, WLH, SNF::PP_LIMITOVER_TEXT, 1) when 1 self.contents.clear self.contents.draw_text(0, 0, 544, WLH, SNF::PP_COSTOVER_TEXT, 1) end end end