Jump to content
WCouillard

Kread-EX Vampiric Damage Mod?

Recommended Posts

OK, so, kinda stuck on another mod...

 

I have a script by Kread-EX that let's you assign a notetag to a state, and users with that state will absorb a certain amount of HP as designated by the notetag. What I want to do is also allow this notetag to apply to certain skills, rather than just states. I've successfully modified it to also be able to drain a portion on MP, but getting it to work with skills... not so much. Here is the original script...

 

# :=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  ▼ Vampire State
#  Author: Kread-EX
#
#  For Nessy.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

# Put <vampire: x%> in the state's notebox.

#===========================================================================
# ■ RPG::State
#===========================================================================

class RPG::State < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ● Determine if vampire
  #--------------------------------------------------------------------------
  def vampire
    @vampire ||= @note.match(/<vampire:\s*(\d+)%>/i) {$1.to_i}
    @vampire
  end
end

#===========================================================================
# ■ Game_Battler
#===========================================================================

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # ● Calculate damage
  #--------------------------------------------------------------------------
  alias_method(:krx_vs_gb_mdv, :make_damage_value)
  def make_damage_value(user, item)
    krx_vs_gb_mdv(user, item)
    vamp = user.states.select {|state| state.vampire != nil}
    if vamp && !vamp.empty?
      @result.hp_drain = (@result.hp_damage * vamp.first.vampire.fdiv(100)).round
    end
  end
end

And here is the modified one that also allows MP draining (for States). If anyone could help me to get this to work for specific skills as well as states, I'd love you forever.

 

NOTE: I also added a way to eliminate certain skill IDs from utilizing the vampiric state.

 

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  ▼ Vampire State
#  Author: Kread-EX
#
#  For Nessy.
#
#  Some additional functionality added by WCouillard
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Instructions
#
# Put <vampire: x%> in a state's notebox to allow the actor to absorb x% of
# the damage dealt as HP.
#
# Put <mpvampire: x%> in a state's notebox to allow the actor to absorb x% of
# the damage dealt as MP.
#===========================================================================
# ■ Module VAMP
#===========================================================================
module VAMP
  #--------------------------------------------------------------------------
  # ● List Skill ID's that ignore vampiric effects, even with state applied
  #--------------------------------------------------------------------------
  # ● NOTE: Important to include all HEALING abilities here
  #--------------------------------------------------------------------------
  IGNORE_SKILLS   = [89, 90, 91, 286, 288, 290, 291]
end
#===========================================================================
# ■ RPG::Skill
#===========================================================================

class RPG::Skill < RPG::UsableItem
  #--------------------------------------------------------------------------
  # ● Determine if vampire skill
  #--------------------------------------------------------------------------
  def vampire
    @vampire ||= @note.match(/<vampire:\s*(\d+)%>/i) {$1.to_i}
    @vampire
  end
  #--------------------------------------------------------------------------
  # ● Determine if mp vampire skill
  #--------------------------------------------------------------------------
  def mpvampire
    @mpvampire ||= @note.match(/<mpvampire:\s*(\d+)%>/i) {$1.to_i}
    @mpvampire
  end
end
#===========================================================================
# ■ RPG::State
#===========================================================================

class RPG::State < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ● Determine if vampire state
  #--------------------------------------------------------------------------
  def vampire
    @vampire ||= @note.match(/<vampire:\s*(\d+)%>/i) {$1.to_i}
    @vampire
  end
  #--------------------------------------------------------------------------
  # ● Determine if mp vampire state
  #--------------------------------------------------------------------------
  def mpvampire
    @mpvampire ||= @note.match(/<mpvampire:\s*(\d+)%>/i) {$1.to_i}
    @mpvampire
  end
end

#===========================================================================
# ■ RPG::UsableItem
#===========================================================================

class RPG::UsableItem < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ● Determine if vampire
  #--------------------------------------------------------------------------
  def vampire
    @vampire ||= @note.match(/<vampire:\s*(\d+)%>/i) {$1.to_i}
    @vampire
  end
  #--------------------------------------------------------------------------
  # ● Determine if mp vampire
  #--------------------------------------------------------------------------
  def mpvampire
    @mpvampire ||= @note.match(/<mpvampire:\s*(\d+)%>/i) {$1.to_i}
    @mpvampire
  end
end

#===========================================================================
# ■ Game_Battler
#===========================================================================

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # ● Calculate damage
  #--------------------------------------------------------------------------
  alias_method(:krx_vs_gb_mdv, :make_damage_value)
  def make_damage_value(user, item)
    krx_vs_gb_mdv(user, item)
    vampskill = user.skills.select {|skill| skill.vampire != nil}
    mpvampskill = user.skills.select {|skill| skill.mpvampire != nil}
    vampstate = user.states.select {|state| state.vampire != nil}
    mpvampstate = user.states.select {|state| state.mpvampire != nil}
    if item.is_a?(RPG::Skill)
      for i in 0..VAMP::IGNORE_SKILLS.length
        if item.id.to_s == VAMP::IGNORE_SKILLS[i].to_s
          return
        end
      end
    end
    if vampskill && !vampskill.empty?
      @result.hp_drain = (@result.hp_damage * vampskill.first.vampire.fdiv(100)).round
    end
    if mpvampskill && !mpvampskill.empty?
      @result.mp_drain = (@result.hp_damage * mpvampskill.first.mpvampire.fdiv(100)).round
    end
    if vampstate && !vampstate.empty?
      @result.hp_drain = (@result.hp_damage * vampstate.first.vampire.fdiv(100)).round
    end
    if mpvampstate && !mpvampstate.empty?
      @result.mp_drain = (@result.hp_damage * mpvampstate.first.mpvampire.fdiv(100)).round
    end
  end
end

So, what happens is that any skill now drains, rather than only those with the notetag. Notetagging is something very new to me, despite using VX Ace for like a decade. I never really messed with it. Any assistance greatly appreciated. :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×