#===============================================================================
=begin
嘲讽技能
2023/1/13
By : 真·可乐
修正了嘲讽状态下,战斗中强制行动无效的问题
2018/7/20
By : Zen Cola
个人lofter :[url]http://zencola.lofter.com/[/url]
=end
#===============================================================================
module Taunt
TAUNTSTATE = 51 #嘲讽状态对应的ID
#判断是否有人嘲讽了的方法
def is_someone_taunt?
$game_party.actors.each do |target|
if target.states.include?(TAUNTSTATE)
return true
break
end
end
return false
end
#判断谁嘲讽了的方法
def who_taunt
taunt = Array.new
$game_party.actors.each do |target|
if target.states.include?(TAUNTSTATE)
next if target.hp0? #死掉就不算了
taunt.push(target)
end
end
return taunt
end
end
class Scene_Battle
include Taunt
alias update_phase4_step2_zen_cola201884 update_phase4_step2
def update_phase4_step2
#让敌人在进行目标选择前再进行一次行动准备
# Make enemy action
for enemy in $game_troop.enemies
if enemy.is_a?(Game_Enemy)
next if enemy.current_action.forcing #2023113 ZK修正了这里
enemy.make_action
end
end
update_phase4_step2_zen_cola201884
end
alias set_target_battlers_zen_cola201884 set_target_battlers
def set_target_battlers(scope)
set_target_battlers_zen_cola201884(scope)
return if !@active_battler.is_a?(Game_Enemy)
#有人嘲讽,此时的技能目标选择
# If battler performing action is enemy
if is_someone_taunt?
@target_battlers.clear
case scope
when 1 # single enemy
#@target_battlers.push($game_party.smooth_target_actor(index))
tat = who_taunt
@target_battlers.push(tat[rand(tat.size)])
when 2 # all enemies
for actor in $game_party.actors
if actor.exist?
@target_battlers.push(actor)
end
end
end
end
end
alias make_basic_action_result_zen_cola2018720 make_basic_action_result
def make_basic_action_result
if is_someone_taunt? and @active_battler.is_a?(Game_Enemy)
if @active_battler.current_action.basic == 0
# Set anaimation ID
@animation1_id = @active_battler.animation1_id
@animation2_id = @active_battler.animation2_id
# If action battler is enemy
if @active_battler.is_a?(Game_Enemy)
if @active_battler.restriction == 3
target = $game_troop.random_target_enemy
elsif @active_battler.restriction == 2
target = $game_party.random_target_actor
else
wt = who_taunt
target = wt[rand(wt.size)]
end
end
# Set array of targeted battlers
@target_battlers = [target]
# Apply normal attack results
for target in @target_battlers
target.attack_effect(@active_battler)
end
return
end
end
make_basic_action_result_zen_cola2018720
end
end
class Game_Enemy
include Taunt
alias make_action_zen_cola2018720 make_action
def make_action
if is_someone_taunt?
make_action_someone_taunt
return
end
make_action_zen_cola2018720
end
#有人嘲讽的情况下选择技能
def make_action_someone_taunt
# Clear current action
self.current_action.clear
# If unable to move
unless self.movable?
# End Method
return
end
# Extract current effective actions
available_actions = []
rating_max = 0
for action in self.actions
#跳过防御逃跑和什么都不干
next if action.kind == 0 and action.basic >= 1 and action.basic <= 3
#跳过无威力和威力为负的技能
next if action.kind == 1 and verifyskill(action.skill_id)
# Confirm turn conditions
n = $game_temp.battle_turn
a = action.condition_turn_a
b = action.condition_turn_b
if (b == 0 and n != a) or
(b > 0 and (n < 1 or n < a or n % b != a % b))
next
end
# Confirm HP conditions
if self.hp * 100.0 / self.maxhp > action.condition_hp
next
end
# Confirm level conditions
if $game_party.max_level < action.condition_level
next
end
# Confirm switch conditions
switch_id = action.condition_switch_id
if switch_id > 0 and $game_switches[switch_id] == false
next
end
# Add this action to applicable conditions
available_actions.push(action)
if action.rating > rating_max
rating_max = action.rating
end
end
# Calculate total with max rating value at 3 (exclude 0 or less)
ratings_total = 0
for action in available_actions
if action.rating > rating_max - 3
ratings_total += action.rating - (rating_max - 3)
end
end
# If ratings total isn't 0
if ratings_total > 0
# Create random numbers
value = rand(ratings_total)
# Set things that correspond to created random numbers as current action
for action in available_actions
if action.rating > rating_max - 3
if value < action.rating - (rating_max - 3)
self.current_action.kind = action.kind
self.current_action.basic = action.basic
self.current_action.skill_id = action.skill_id
self.current_action.decide_random_target_for_enemy
return
else
value -= action.rating - (rating_max - 3)
end
end
end
end
end
#判断技能的威力
def verifyskill(id)
return true if $data_skills[id].power <= 0
end
end