#-------------------------------------------------------------
# ● スキルEXP 計算
#------------------------------------------------------------
def make_skill_list(skill_id)
interval = S_INTER[skill_id]
up_interval = ( (interval != nil and interval[@actor_id] != nil) ? interval[@actor_id] : UPDATA_INTERVAL )
slope = S_SLOPE[skill_id]
up_slope = ( (slope != nil and slope[@actor_id] != nil) ? slope[@actor_id] : 1 )
limit = S_LEVEL[skill_id]
limit_lv = ( (limit != nil and limit[@actor_id] != nil) ? limit[@actor_id] : LEVEL_LIMIT )
list = []
list[0] = 0
for lv in 1...limit_lv+1
exp = 0
case SKILL_PATTERN
when 0
exp = up_interval * lv
when 1
exp = list[lv-1] + up_slope * lv + up_interval
end
list[lv] = exp.truncate
end
return list
end
end
class Game_Battler
include Skill_updata
#-----------------------------------------------------------------
# ● スキルの効果適用
# user : スキルの使用者 (バトラー)
# skill : スキル
#-------------------------------------------------------------
alias skill_effect_update skill_effect
def skill_effect(user, skill)
up_flag = false
if user.is_a?(Game_Actor) and ($scene.is_a?(Scene_Battle) or MENU_COUNT)
skill_update_main(user, skill)
skill_base = skill.dup
# 威力上昇
if SKILL_MIGHT_UP
skill.power = user.skill_power[skill.id]
end
# 命中率上昇
if SKILL_HIT_UP
skill.hit = user.skill_hit[skill.id]
end
# 属性変化
if ELEMENT_CHANGE and S_ELEMENT != []
ele1 = S_ELEMENT[skill.id]
if ele1 != nil and ele1[user.id] != nil
ele2 = ele1[user.id]
if ele2 != [] and ele2[user.skill_level[skill.id]] != nil
skill.element_set = ele2[user.skill_level[skill.id]]
end
end
end
# ステート変化
if STATE_CHANGE
if S_STATE_P != []
pst1 = S_STATE_P[skill.id]
if pst1 != nil and pst1[user.id] != nil
pst2 = pst1[user.id]
if pst2 != nil and pst2[user.skill_level[skill.id]] != nil
skill.plus_state_set = pst2[user.skill_level[skill.id]]
# p skill.plus_state_set
end
end
end
if S_STATE_N != []
nst1 = S_STATE_N[skill.id]
if nst1 != nil and nst1[user.id] != nil
nst2 = nst1[user.id]
if nst1 != nil and nst2[user.skill_level[skill.id]] != nil
skill.minus_state_set = nst2[user.skill_level[skill.id]]
end
end
end
end
up_flag = true
end
ret = skill_effect_update(user, skill) # 原物
if up_flag
skill = skill_base
# Miss時には後戻し
if self.damage == "Miss"
skill_use_recount(user, skill)
end
end
return ret
end
#------------------------------------------------------------
# ● スキルアップデータメイン
#-------------------------------------------------------------
def skill_update_main(actor, skill)
# スキル使用回数のカウント
actor.skill_use[skill.id] += 1
# リミット取得
limit = S_LEVEL[skill.id]
s_limit = ( (limit != nil and limit[actor.id] != nil) ? limit[actor.id] : LEVEL_LIMIT)
# 書き換え限界到達
if s_limit == false or actor.skill_level[skill.id] < s_limit
# レベルアップ間隔取得
interval = actor.skill_list[skill.id]
# 書き換え回数到達
if actor.skill_use[skill.id] == interval[actor.skill_level[skill.id]+1]
# スキルレベル上昇
actor.skill_level[skill.id] += 1
actor.skill_up = true
# 威力上昇 = 有効
if SKILL_MIGHT_UP
might = S_MIGHT[skill.id]
might_rate = ((might != nil and might[actor.id] != nil) ? might[actor.id] : MIGHT_RATE)
# 補正値更新
actor.skill_power[skill.id] += skill.power * might_rate / 100
actor.skill_power[skill.id] = actor.skill_power[skill.id].truncate
end
# SP消費減少 = 有効
if SP_COST_DOWN
cost = S_COST[skill.id]
cost_rate = ((cost != nil and cost[actor.id] != nil) ? cost[actor.id] : COST_RATE)
actor.skill_sp_cost[skill.id] -= skill.sp_cost * cost_rate / 100
actor.skill_sp_cost[skill.id] = actor.skill_sp_cost[skill.id].truncate
# SP消費が0以下はありえない
if actor.skill_sp_cost[skill.id] < 0
actor.skill_sp_cost[skill.id] = 0
end
end
# 命中率上昇 = 有効
if SKILL_HIT_UP
hit = S_HIT[skill.id]
hit_rate = ((hit != nil and hit[actor.id] != nil) ? hit[actor.id] : HIT_RATE)
actor.skill_hit[skill.id] += skill.hit * hit_rate / 100
actor.skill_hit[skill.id] = actor.skill_hit[skill.id].truncate
# 100以上はありえない
if actor.skill_hit[skill.id] > 100
actor.skill_hit[skill.id] = 100
end
end
end
end
end
#---------------------------------------------------------
# ● 再カウント
#------------------------------------------------------
def skill_use_recount(actor, skill)
if actor.skill_up
actor.skill_level[skill.id] -= 1
# 威力を再計算
if SKILL_MIGHT_UP
actor.skill_power[skill.id] = skill.power
might = S_MIGHT[skill.id]
might_rate = ((might != nil and might[actor.id] != nil) ? might[actor.id] : MIGHT_RATE)
for i in 1...actor.skill_level[skill.id]
actor.skill_power[skill.id] += skill.power * might_rate / 100
actor.skill_power[skill.id] = actor.skill_power[skill.id].truncate
end
end
# SP消費再計算
if SP_COST_DOWN
actor.skill_sp_cost[skill.id] = skill.sp_cost
cost = S_COST[skill.id]
cost_rate = ((cost != nil and cost[actor.id] != nil) ? cost[actor.id] : COST_RATE)
for i in 1...actor.skill_level[skill.id]
actor.skill_sp_cost[skill.id] -= skill.sp_cost * cost_rate / 100
actor.skill_sp_cost[skill.id] = actor.skill_sp_cost[skill.id].truncate
end
# SP消費が0以下はありえない
if actor.skill_sp_cost[skill.id] < 0
actor.skill_sp_cost[skill.id] = 0
end
end
# 命中率再計算
if SKILL_HIT_UP
actor.skill_hit[skill.id] = skill.hit
hit = S_HIT[skill.id]
hit_rate = ((hit != nil and hit[actor.id] != nil) ? hit[actor.id] : HIT_RATE)
for i in 1...actor.skill_level[skill.id]
actor.skill_hit[skill.id] += skill.hit * hit_rate / 100
actor.skill_hit[skill.id] = actor.skill_hit[skill.id].truncate
end
# 100以上はありえない
if actor.skill_hit[skill.id] > 100
actor.skill_hit[skill.id] = 100
end
end
actor.skill_up = false
end
actor.skill_use[skill.id] -= 1
end
end
#=================================================================
# スキル成長によるアニメーション変化
#=================================================================
class Scene_Battle
include Skill_updata
#--------------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 4 : 対象側アニメーション)
#-----------------------------------------------------------
alias update_phase4_step4_skillup update_phase4_step4
def update_phase4_step4
update_phase4_step4_skillup
if @active_battler.is_a?(Game_Actor) and USE_S_ANIME
s_anime = S_ANIME[@skill.id]
# 設定がないなら無視
if s_anime != nil and s_anime[@active_battler.id] != nil
s_anime_set = s_anime[@active_battler.id]
for i in 0...s_anime_set.size
s_anime_def = s_anime_set
# 規定レベル以上
if @active_battler.skill_level[@skill.id] >= s_anime_def[0]
# 対象側アニメーション
for target in @target_battlers
target.animation_id = s_anime_def[1]
end
end
end
end
end
end
end
#=================================================================
# 以下、レベルアップ表示部分(レベルアップ表示がいらないなら消してもOK)
#=================================================================
class Scene_Battle
include Skill_updata
if SHOW_SKILL_LV_UP
#----------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
#----------------------------------------------------------
alias update_phase4_step2_skillup update_phase4_step2
def update_phase4_step2
if @active_battler.is_a?(Game_Actor)
@active_battler.skill_up = false
end
@skillup = false
update_phase4_step2_skillup # 原物
end
#-------------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 3 : 行動側アニメーション)
#-----------------------------------------------------------
alias update_phase4_step3_skillup update_phase4_step3
def update_phase4_step3
if @active_battler.is_a?(Game_Actor) and @active_battler.skill_up != false
@skillup = true
@skill_up_window = Window_Skillup.new(@active_battler)
if SKILLUP_SE != nil
Audio.se_play("Audio/SE/" + SKILLUP_SE)
sleep(0.1)
end
end
update_phase4_step3_skillup
end
#--------------------------------------------------------------
# ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
#--------------------------------------------------------------
alias update_phase4_step5_skillup update_phase4_step5
def update_phase4_step5
if @active_battler.is_a?(Game_Actor) and @skillup
@skill_up_window.dispose
@active_battler.skill_up = false
@skillup = false
end
update_phase4_step5_skillup # 原物
end
#---------------------------------------------------------------
# ● フレーム更新
#----------------------------------------------------------------
alias update_skillup update
def update
if @active_battler.is_a?(Game_Actor) and @active_battler.skill_up and @skillup
@skill_up_window.contents_opacity -= 4
end
update_skillup # 原物
end
end # if SHOW_SKILL_LV_UP
end
#====================================================================
# 以下、再定義部分を含む(SP消費減少の機能がいらないなら消してもOK)
#====================================================================
class Window_Skill < Window_Selectable
#----------------------------------------------------------------
# ● 項目の描画
# index : 項目番号
#-----------------------------------------------------------------
def draw_item(index)
skill = @data[index]
if @actor.skill_can_use?(skill.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
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))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
#-修正-----
@actor.skill_level[skill.id] = 0 if @actor.skill_level[skill.id] == nil
name_level = skill.name + "(Lv" + @actor.skill_level[skill.id].to_s + ")"
self.contents.draw_text(x + 28, y, 204, 32, name_level, 0)
@actor.skill_sp_cost[skill.id] = skill.sp_cost if @actor.skill_sp_cost[skill.id] == nil
self.contents.draw_text(x + 232, y, 48, 32, @actor.skill_sp_cost[skill.id].to_s, 2)
#----------
end
end
class Scene_Skill
#----------------------------------------------------------
# ● フレーム更新 (ターゲットウィンドウがアクティブの場合)
#-------------------------------------------------------------
def update_target
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# ターゲットウィンドウを消去
@skill_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# SP 切れなどで使用できなくなった場合
unless @actor.skill_can_use?(@skill.id)
# ブザー 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.skill_effect(@actor, @skill)
end
end
# ターゲットが使用者の場合
if @target_window.index <= -2
# ターゲットのアクターにスキルの使用効果を適用
target = $game_party.actors[@target_window.index + 10]
used = target.skill_effect(@actor, @skill)
end
# ターゲットが単体の場合
if @target_window.index >= 0
# ターゲットのアクターにスキルの使用効果を適用
target = $game_party.actors[@target_window.index]
used = target.skill_effect(@actor, @skill)
end
# スキルを使った場合
if used
# スキルの使用時 SE を演奏
$game_system.se_play(@skill.menu_se)
#-----修正---------------------------------------------
@actor.skill_sp_cost[@skill.id] = @skill.sp_cost if @actor.skill_sp_cost[@skill.id] == nil
# SP 消費
@actor.sp -= @actor.skill_sp_cost[@skill.id]
#------------------------------------------------
# 各ウィンドウの内容を再作成
@status_window.refresh
@skill_window.refresh
@target_window.refresh
# 全滅の場合
if $game_party.all_dead?
# ゲームオーバー画面に切り替え
$scene = Scene_Gameover.new
return
end
# コモンイベント ID が有効の場合
if @skill.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @skill.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
class Scene_Battle
include Skill_updata
#------------------------------------------------------
# ● スキルアクション 結果作成
#-------------------------------------------------------
alias make_skill_action_result_skill_update make_skill_action_result
def make_skill_action_result
make_skill_action_result_skill_update
# SP 消費
if SP_COST_DOWN and @active_battler.is_a?(Game_Actor)
@active_battler.sp += @skill.sp_cost
@active_battler.sp -= @active_battler.skill_sp_cost[@skill.id]
end
end
end
class Game_Battler
#--------------------------------------------------------
# ● スキルの使用可能判定
# skill_id : スキル ID
#------------------------------------------------------
alias skill_update_can_use? skill_can_use?
def skill_can_use?(skill_id)
ret = skill_update_can_use?(skill_id)
if !ret and SP_COST_DOWN
# SP が足りない場合は使用不可となった?
if $data_skills[skill_id].sp_cost > self.sp
if self.is_a?(Game_Actor)
skill_sp_cost = self.skill_sp_cost[skill_id]
if skill_sp_cost < self.sp
ret = true
end
end
end
end
return ret
end
end
#===============================================================
# イベントスクリプト操作
#===============================================================
class Interpreter
include Skill_updata
#-----------------------------------------------------------
# ● スキルレベル設定(レベルセット)
# actor_id : アクターID
# skill_id : スキルID
# level : 設定レベル
#-----------------------------------------------------------
def set_skill_level(actor_id, skill_id, level)
actor = $game_actors[actor_id]
skill = $data_skills[skill_id]
# リミット取得
limit = S_LEVEL[skill_id]
s_limit = ( (limit != nil and limit[actor.id] != nil) ? limit[actor.id] : LEVEL_LIMIT)
if level > s_limit or level < 0
return
end
# レベル
actor.skill_level[skill.id] = level
# 使用回数
use_list = actor.skill_list[skill.id]
actor.skill_use[skill.id] = use_list[level]
# 威力を再計算
if SKILL_MIGHT_UP
actor.skill_power[skill.id] = skill.power
might = S_MIGHT[skill.id]
might_rate = ((might != nil and might[actor.id] != nil) ? might[actor.id] : MIGHT_RATE)
for i in 0...level
actor.skill_power[skill.id] += skill.power * might_rate / 100
actor.skill_power[skill.id] = actor.skill_power[skill.id].truncate
end
end
# SP消費再計算
if SP_COST_DOWN
actor.skill_sp_cost[skill.id] = skill.sp_cost
cost = S_COST[skill.id]
cost_rate = ((cost != nil and cost[actor.id] != nil) ? cost[actor.id] : COST_RATE)
for i in 0...level
actor.skill_sp_cost[skill.id] -= skill.sp_cost * cost_rate / 100
actor.skill_sp_cost[skill.id] = actor.skill_sp_cost[skill.id].truncate
end
# SP消費が0以下はありえない
if actor.skill_sp_cost[skill.id] < 0
actor.skill_sp_cost[skill.id] = 0
end
end
# 命中率再計算
if SKILL_HIT_UP
actor.skill_hit[skill.id] = skill.hit
hit = S_HIT[skill.id]
hit_rate = ((hit != nil and hit[actor.id] != nil) ? hit[actor.id] : HIT_RATE)
for i in 0...level
actor.skill_hit[skill.id] += skill.hit * hit_rate / 100
actor.skill_hit[skill.id] = actor.skill_hit[skill.id].truncate
end
# 100以上はありえない
if actor.skill_hit[skill.id] > 100
actor.skill_hit[skill.id] = 100
end
end
end