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.

Drain and osmose script

Code:
# By SephirothSpawn

class RPG::Skill
  # { skill_id => percent or points, ... }
  Hp_Drain_Percent = {}
  Hp_Drain_Points = {}
  Sp_Drain_Percent = {}
  Sp_Drain_Points = {}
  Hp_Drain_Percent.default = 0
  Hp_Drain_Points.default = 0
  Sp_Drain_Percent.default = 0
  Sp_Drain_Points.default = 0
  # [ skill_id, ... ]
  Skills_That_Can_Kill_Draining = []
  def hp_drain_percent
    return Hp_Drain_Percent[@id]
  end
  def hp_drain_points
    return Hp_Drain_Points[@id]
  end
  def sp_drain_percent
    return Sp_Drain_Percent[@id]
  end
  def sp_drain_points
    return Sp_Drain_Points[@id]
  end
  def drain_can_kill?
    return Skills_That_Can_Kill_Draining.include?(@id)
  end
end

class Game_Battler
  alias_method :seph_skilldrains_gmbltr_se, :skill_effect
  def skill_effect(user, skill)
    effective = seph_skilldrains_gmbltr_se(user, skill)
    if effective
      hp_percent = skill.hp_drain_percent
      hp_points = skill.hp_drain_points
      sp_percent = skill.sp_drain_percent
      sp_points = skill.sp_drain_points
      hp_drain = Integer(self.hp * (hp_percent / 100.0)) + hp_points
      sp_drain = Integer(self.sp * (sp_percent / 100.0)) + sp_points
      unless skill.drain_can_kill?
        hp_drain = [hp_drain, self.hp - 1].min
      end
      hp_drain = [hp_drain, self.hp].min
      sp_drain = [sp_drain, self.sp].min
      self.hp - hp_drain
      self.sp - sp_drain
      if self.damage.is_a?(Integer)
        self.damage += hp_drain
      end
      user.hp += hp_drain
      user.sp += sp_drain
    end
    return effective
  end
end

You can use this. You only need to alter this:
Code:
  # { skill_id => percent or points, ... }
  Hp_Drain_Percent = {}
  Hp_Drain_Points = {}
  Sp_Drain_Percent = {}
  Sp_Drain_Points = {}
  Hp_Drain_Percent.default = 0
  Hp_Drain_Points.default = 0
  Sp_Drain_Percent.default = 0
  Sp_Drain_Points.default = 0
  # [ skill_id, ... ]
  Skills_That_Can_Kill_Draining = []

To give skills a hp drain (by percent), add them in this Constant.
Code:
  Hp_Drain_Percent = {}

So say you want skill 3 to take 20% and skill 5 to take 35%
Code:
  Hp_Drain_Percent = {3=>20, 5=>35}

The same goes for the other constants.

I just woke up, so their may be errors and I have gave you a horrible explanation. Let me know in either case.
 
STAY OUT OF MY TERRITORY SEPH!!!!!! (SKILL EFFECTS!! :mad:)

you forgot one thing Seph well two things

Code:
      self.hp - hp_drain
      self.sp - sp_drain

should be -=

second the healed amount will not be shown you didn't set <Game_Battler>.damage_pop to true

--------------------------------
On the other hand I am going to give you this link Bag of Skill Effects and tell you that both of those effects were already done

If you have any questions bring them to my attention
 

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