Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Protect

Yea, I got an idea of a skill that will probably need some scripting.

Anyway, this is what it does:

A character('Protector') has a skill called 'Protect'. In Battle he will use it on another character giving him the status of 'Protected', if that other character gets hit during the turn that Protect is used, the 'Protector' should recieve the damage, hence the name. After the turn, it should just be ruled out.

I think it's quite simple and probably wont take much of your time, but I could be wrong.

Thanks in advance,
-Draken
 
Insert this below Scene_Battle somwhere. Set Protect_Skill_ID = 1 to be the id of the skill that will set the status protected.

Code:
class Game_Battler
  Protect_Skill_ID = 1
  attr_accessor :protected
  attr_accessor :protector
  alias seph_protector_gmbtlr_ae attack_effect
  alias seph_protector_gmbtlr_se skill_effect
  def attack_effect(attacker)
    seph_protector_gmbtlr_ae(attacker)
    if self.protected
      return unless self.damage > 0
      damage = self.damage
      self.hp += self.damage
      self.damage = nil
      $game_party.actors.each do |actor|
        if actor.protector
          actor.damage = damage
          actor.hp -= damage
          actor.damage_pop = true
        end
      end
    end
  end
  def skill_effect(user, skill)
    seph_protector_gmbtlr_se(user, skill)
    if skill.id == Protect_Skill_ID
      user.protector = true
      self.protected = true
    end
    if self.protected
      return unless self.damage > 0
      damage = self.damage
      self.hp += self.damage
      self.damage = nil
      $game_party.actors.each do |actor|
        if actor.protector
          actor.damage = damage
          actor.hp -= damage
          actor.damage_pop = true
        end
      end
    end
  end
end

class Scene_Battle
  alias seph_protector_scnbtl_sp2 start_phase2
  def start_phase2
    $game_party.actors.each do |actor|
      actor.protector = false
      actor.protected = false
    end
    seph_protector_scnbtl_sp2
  end
end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top