Permite criar uma habilidade que transforma o alvo da mesma num “escudo-humano”.

Desenvolvimento: XMS

Tradutor: MogHunter

Instruções:

Copie o script para seu projeto e crie um atributo chamado “Cover” e atribua-o à habilidade ou arma desejada.

################################################################################
################################### XMS ########################################
################################################################################
=begin
                                   COVER

--------------------------------------------------------------------------------
Script criado pelo site XMS.
Created by XMS site.
Tradução e tutorial por Moghunter.
--------------------------------------------------------------------------------

CARACTERÍSTICAS
 O personagem que estiver com o status Cover, receberá o dano no lugar
 dos outros personagens.

UTILIZAÇÃO
 Crie um atributo com o nome de "Cover" e atribua a habilidade desejada.

CUSTOMIZAÇÃO
=end
#-------------------------------------------------------------------------------
module Cover_Module  
  #Nome do atributo.
  ELEMENT_NAME_COVER  = "Cobrir"
  #Nome do status(deve ser igual ao do banco de dados).
  STATE_NAME_COVER    = "Cobrir"
  #% para começar a defender o personagem. 
  COVER_HP_PERCENT    = 100 
  #% de chance para defender o personagem. 
  COVER_EFFECT_PERCENT = 100
  #Definição da palavra Covered no momento da defesa. 
  COVER_EFFECT_CHAR    = "Protegido!"
  #Definição ID da animação no momento da defesa. 
  COVER_ANIMATION_ID  = 64
  #Número de personagens que poderá defender. 
  COVER_DEFAULT_NUMBER = 3     
#-------------------------------------------------------------------------------
end
module Cover_Module
  def get_target_battlers_after_cover!(target_battlers, active_battler = nil)
    target_battlers.sort!{|a,b| (a.hp.to_f/a.maxhp.to_f) <=> (b.hp.to_f/b.maxhp.to_f)}
    actors = $game_party.actors.sort_by{|b| (b.hp.to_f/b.maxhp.to_f)}.reverse
    enemies = $game_troop.enemies.sort_by{|b| (b.hp.to_f/b.maxhp.to_f)}.reverse

    for i in 0...target_battlers.size      
      if target_battlers[i].is_a?(Game_Actor)
        friends = actors
      elsif target_battlers[i].is_a?(Game_Enemy)
        friends = enemies
      end

      for friend in friends
        new_target = get_target_after_cover(active_battler,target_battlers[i],friend)
        if !new_target.equal?(target_battlers[i]) && new_target.current_friend.nil?  #‚©‚΂¤l‚ª‚·‚Å‚É‚©‚΂Á‚Ä‚¢‚½ê‡‚©‚΂¦‚È‚¢
          new_target.effect_message = "#{new_target.name}‚Í#{target_battlers[i].name}‚ð‚©‚Î‚Á‚½I"
          new_target.current_friend = target_battlers[i]
          new_target.current_friend.damage = COVER_EFFECT_CHAR
          target_battlers[i] = new_target
          break
        end
      end
    end
    target_battlers.uniq!()
    for target in target_battlers
      if !target.current_friend.nil?
        target.cover_remain -= 1
        if target.cover_remain <= 0
          target.remove_state(get_cover_state_id())
          target.cover_remain = 0
        end
      end
    end

  end
  def get_target_after_cover(battler, target, coverer)
    if battler.is_a?(Game_Actor)
      if target.is_a?(Game_Actor)
        return target
      end
    end
    if battler.is_a?(Game_Enemy)
      if target.is_a?(Game_Enemy)
        return target
      end
    end
    if !(coverer.movable? && coverer.exist?)
      return target
    end
    if !coverer.state?(get_cover_state_id())
      return target
    end
    if target.state?(get_cover_state_id())
      return target
    end
    if target.equal?(coverer)
      return target
    end
    if !(rand(100) <= COVER_EFFECT_PERCENT)
      return target
    end
    if !(100.0*target.hp.to_f/target.maxhp.to_f <= COVER_HP_PERCENT)
      return target
    end
    if coverer.covered_friends.size.zero?
      return coverer
    else
      for covered_friend in coverer.covered_friends
        if target.equal?(covered_friend)
          return coverer
        end
      end
    end

    return target
  end
  def get_cover_state_id
    result = nil
    if @cover_status_id == nil
      for i in 1 ... $data_states.size
        if $data_states[i].name[/\\A#{STATE_NAME_COVER}\\Z/]
          result = $data_states[i].id
          break
        end
      end
      @cover_status_id = ( result != nil ? result : 0 )
    elsif @cover_status_id > 0
      result = @cover_status_id
    end
    return result
  end

end
class Game_Battler
  include Cover_Module
  attr_accessor :covered_friends              
  attr_accessor :effect_message              
  attr_accessor :current_friend              
  attr_accessor :cover_remain                
  alias before_cover_original_initialize initialize
  def initialize
    before_cover_original_initialize
    @covered_friends = []
    @effect_message = nil
    @current_friend = nil
    @cover_remain = 0
  end
  alias before_cover_original_add_state add_state

  def add_state(state_id, force = false)
    before_cover_original_add_state(state_id, force)
    if state_id == get_cover_state_id()
      self.cover_remain = COVER_DEFAULT_NUMBER  
    end
  end
end
class Scene_Battle
  attr_reader :active_battler
  include Cover_Module
  if self.method_defined?(:make_basic_action_target_set)
    alias :original_make_basic_action_target_set_before_cover :make_basic_action_target_set
    def make_basic_action_target_set
      original_make_basic_action_target_set_before_cover()
      get_target_battlers_after_cover!(@target_battlers, @active_battler)
    end
  end
  alias :original_make_skill_action_result_before_cover :make_skill_action_result
  def make_skill_action_result
    original_make_skill_action_result_before_cover()
    make_cover_skill_action_result()
  end
  alias :original_set_target_battlers_before_cover :set_target_battlers
  def set_target_battlers(scope)
    original_set_target_battlers_before_cover(scope)
    get_target_battlers_after_cover!(@target_battlers, @active_battler)
  end
  def make_cover_skill_action_result
    cover_num = 0
    cover_bool = false
    for i in @skill.element_set
      if !($data_system.elements[i][/^#{ELEMENT_NAME_COVER}/].nil?)
        cover_bool = true
        elm_num = $data_system.elements[i][/([+-]*[0-9]+)/]
        if !(elm_num.nil?)
          cover_num += elm_num.to_i
        end
      end
    end

    if cover_bool.equal?(true)
      if @target_battlers.include?(@active_battler)
        if @target_battlers.size == 1
          if @target_battlers[0].is_a?(Game_Actor) && $game_party.actors.size() > 1
            friends = $game_party.actors.dup
            friends.delete(@active_battler)
            @target_battlers = [friends[rand(friends.size)]]
          elsif @target_battlers[0].is_a?(Game_Enemy) && $game_troop.enemies.size() > 1
            friends = $game_troop.enemies.dup
            friends.delete(@active_battler)
            @target_battlers = [friends[rand(friends.size)]]
          end
        else
          @target_battlers.delete(@active_battler)
        end
      end

      @active_battler.covered_friends = @target_battlers.dup
      @active_battler.add_state(get_cover_state_id())##ƒXƒe[ƒg•t‰ÁŽž‚ɃfƒtƒHƒ‹ƒg‰ñ”‚Å”­“®‰ñ”‚ªÝ’肳‚ê‚é
      if (cover_num > 0)
        @active_battler.cover_remain = cover_num#”­“®‰ñ”‚ª—L‚Á‚½ê‡‚Í‚»‚̉ñ”‚ŏ㏑‚«
      end
      for target in @target_battlers
        target.damage = COVER_EFFECT_CHAR
      end
    end
  end
  alias before_cover_original_update_phase4_step4 update_phase4_step4

  def update_phase4_step4
    before_cover_original_update_phase4_step4()
    for target in @target_battlers
      if target.current_friend != nil
        target.current_friend.animation_id = COVER_ANIMATION_ID
      end
    end
  end
  alias before_cover_original_update_phase4_step5 update_phase4_step5

  def update_phase4_step5
    before_cover_original_update_phase4_step5 
    for target in @target_battlers
      if target.current_friend != nil
        target.current_friend.damage_pop = true
        target.current_friend = nil
      end
    end
  end
end
class Game_Party
  include Cover_Module
  alias before_cover_original_smooth_target_actor smooth_target_actor

  def smooth_target_actor(actor_index)
    if $scene.is_a?(Scene_Battle)
      battler = $scene.active_battler()
    else
      battler = nil
    end

    target = [before_cover_original_smooth_target_actor(actor_index)]
    get_target_battlers_after_cover!(target, battler)

    return target[0]
  end
end  
class Game_Troop
  include Cover_Module
  alias before_cover_original_smooth_target_enemy smooth_target_enemy  

  def smooth_target_enemy(enemy_index)
    if $scene.is_a?(Scene_Battle)
      battler = $scene.active_battler()
    else
      battler = nil
    end

    target = [before_cover_original_smooth_target_enemy(enemy_index)]
    get_target_battlers_after_cover!(target, battler)

    return target[0]
  end
end
Anúncios