Save-Point
Hand Over De-Buffs ACE - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker VX/VXAce (RGSS2/3) Engines (https://www.save-point.org/forum-117.html)
+---- Thread: Hand Over De-Buffs ACE (/thread-8607.html)



Hand Over De-Buffs ACE - kyonides - 12-15-2022

Hand Over De-Buffs ACE

by Kyonides Arkanthes


Introduction

Thinking I think that the title is quite suggestive so I will simply leave the code below for you to use.

It also includes the notes you will need to leave at the skills' noteboxes to make the script work as intended.

You can only leave 1 of those 3 notes at any given time!

Code:
# * Hand Over De-Buffs ACE * #
#   Scripter : Kyonides Arkanthes
#   2022-12-16

# * Instructions:
# Leave a skill note like the following:
# <handover buffs> or <handover debuffs> or <handover all buffs>
# You can only leave 1 of those 3 notes at any given time!

class Game_Battler
  REGEX_BUFFS = /<handover buffs>/i
  REGEX_DEBUFFS = /<handover debuffs>/i
  REGEX_DE_BUFFS = /<handover all buffs/i
  attr_reader :buffs, :buff_turns
  alias :kyon_de_buffs_gm_btlr_iue :item_user_effect
  def item_user_effect(user, item)
    kyon_de_buffs_gm_btlr_iue(user, item)
    return if
    if item.note[REGEX_BUFFS]
      hand_over_buffs(user)
    elsif item.note[REGEX_DEBUFFS]
      hand_over_debuffs(user)
    elsif item.note[REGEX_DE_BUFFS]
      hand_over_all_buffs(user)
    end
  end

  def clear_buff(pos)
    @buffs[pos] = 0
    @buff_turns.delete(pos)
  end

  def hand_over_buffs(user)
    user.buff_turns.keys.sort.each do |n|
      next if user.buffs[n] < 0
      @buffs = user.buffs[n]
      @buff_turns = user.buff_turns[n]
      user.clear_buff(n)
      @result.added_buffs.push(n).uniq!
    end
    user.refresh
    refresh
    @result.success = true
  end

  def hand_over_debuffs(user)
    user.buff_turns.keys.sort.each do |pos|
      next if user.buffs[pos] >= 0
      @buffs[pos] = user.buffs[pos]
      @buff_turns[pos] = user.buff_turns[pos]
      user.clear_buff(pos)
      @result.added_debuffs.push(pos).uniq!
    end
    user.refresh
    refresh
    @result.success = true
  end

  def hand_over_all_buffs(user)
    @buffs = user.buffs.dup
    @buff_turns = user.buff_turns.dup
    @buffs.size.times do |pos|
      if user.buffs[pos] > 0
        @result.added_buffs.push(n).uniq!
      else
        @result.added_debuffs.push(pos).uniq!
      end
    end
    user.clear_buffs
    user.refresh
    refresh
    @result.success = true
  end
end


Terms & Conditions

Free for use in ANY kind of game. Grinning
Please include my nickname in your game credits!
I would love to see that this is not the only script of mine that you are using there. Laughing

Just in case one of your nicknames is Dog Wulfo, let me tell you that Ramen is bad for your diet.


RE: Hand Over Buffs or Debuffs ACE - kyonides - 12-16-2022

The Code Has Been Rewritten! Shocked

Based on my lastest test runs, trying to apply the effect as a damage formula was a NO GO. Sad
Thus, I was in dire need of looking for an alternate way to solve this issue.
Grinning And I finally found it!

I simply needed to define it as Skill Notes and let the game apply any of them as an Item Effect.
By default, the item effects only run IF there was a hit or successful attempt to cast the spell on the target.
That means that I had no reason to worry about that at all! Two Thumbs Up!