#==============================================================================
# ■ RPG::Item
#==============================================================================
class RPG::Item
#--------------------------------------------------------------------------
# ○ 盗めるスキルかどうかを返す
#--------------------------------------------------------------------------
def can_steal?
false
end
end
#==============================================================================
# ■ Game_ActionResult
#==============================================================================
class Game_ActionResult
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :steal_skills # 盗まれたスキルIDの配列
#--------------------------------------------------------------------------
# ● クリア
#--------------------------------------------------------------------------
alias tmsksteal_game_actionresult_clear clear
def clear
tmsksteal_game_actionresult_clear
@steal_skills = []
end
#--------------------------------------------------------------------------
# ● 何らかのステータス(能力値かステート)が影響を受けたかの判定
#--------------------------------------------------------------------------
alias tmsksteal_game_actionresult_status_affected? status_affected?
def status_affected?
tmsksteal_game_actionresult_status_affected? || !@steal_skills.empty?
end
end
#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# ● スキル/アイテムの効果適用
#--------------------------------------------------------------------------
alias tmsksteal_game_battler_item_apply item_apply
def item_apply(user, item)
tmsksteal_game_battler_item_apply(user, item)
if enemy? && item.steal_skill? && @result.hit?
enemy.actions.each do |action|
skill = $data_skills[action.skill_id]
next unless skill.can_steal? # 无法被偷窃スキルまたはアイテム
next if user.skill_learn?(skill) # すでに習得済み
@result.steal_skills.push(skill.id)
user.learn_steal_skill(skill.id)
end
end
end
#--------------------------------------------------------------------------
# ● 戦闘終了処理
#--------------------------------------------------------------------------
alias tmsksteal_game_battler_on_battle_end on_battle_end
def on_battle_end
@steal_skills.clear unless enemy?
tmsksteal_game_battler_on_battle_end
end
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● スキルの初期化
#--------------------------------------------------------------------------
alias tmsksteal_game_actor_init_skills init_skills
def init_skills
@steal_skills = []
tmsksteal_game_actor_init_skills
end
#--------------------------------------------------------------------------
# ● 追加スキルの取得
#--------------------------------------------------------------------------
alias tmsksteal_game_actor_added_skills added_skills
def added_skills
result = tmsksteal_game_actor_added_skills
@steal_skills.each {|id| result.push(id) }
result
end
#--------------------------------------------------------------------------
# ● スキルの習得済み判定
#--------------------------------------------------------------------------
alias tmsksteal_game_actor_skill_learn? skill_learn?
def skill_learn?(skill)
return true if tmsksteal_game_actor_skill_learn?(skill)
skill.is_a?(RPG::Skill) && @steal_skills.include?(skill.id)
end
#--------------------------------------------------------------------------
# ○ 盗んだスキルの習得
#--------------------------------------------------------------------------
def learn_steal_skill(skill_id)
@steal_skills.push(skill_id)
end
end
#==============================================================================
# ■ Window_BattleLog
#==============================================================================
class Window_BattleLog < Window_Selectable
#--------------------------------------------------------------------------
# ● 能力強化/弱体の表示
#--------------------------------------------------------------------------
alias tmsksteal_window_battlelog_display_changed_buffs display_changed_buffs
def display_changed_buffs(target)
tmsksteal_window_battlelog_display_changed_buffs(target)
display_steal_skill(target)
end
#--------------------------------------------------------------------------
# ○ 盗んだスキルの表示
#--------------------------------------------------------------------------
def display_steal_skill(target)
target.result.steal_skills.each do |id|
replace_text(sprintf("%sを盗んだ!", $data_skills[id].name))
wait
end
end
end
alias initialize_tre initialize
def initialize
@steal_skill_id = 0
@recent_skill_id = 0
initialize_tre
end
alias item_apply_tre item_apply
def item_apply(user, item)
item_apply_tre(user, item)
if item.is_a?(RPG::Skill)
case item.id
when Steal_Skill_Skill_id
return if user.skills.include?(self.recent_skill_id)
user.steal_skill(self.recent_skill_id)
when 1,2, 76,77,78#可以在这里添加无法被偷的技能
return
else
user.recent_skill_id = item.id
end
end
end
def steal_skill(skill_id)
if self.is_a?(Game_Actor) and skill_id != 0 and skill_id != 1 and skill_id != 2
self.forget_skill(self.steal_skill_id)
self.steal_skill_id = skill_id
self.learn_skill(skill_id)
end
end
alias steal_skill_on_battle_end on_battle_end
def on_battle_end
steal_skill_on_battle_end
if self.is_a?(Game_Actor) and [0,1,2].include?(self.steal_skill_id)
self.forget_skill(self.steal_skill_id)
end
end