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.

[Resolved] Anti Recover

VCA

Member

I need a script that recovery item can harm you if your in some kind of state, for example a potion will heal 50HP, but if some enemy did a move that give you a state (for example Anti recover) that if you recover with a Skill or item instead of recovering you, you'll take damage equal to the same amount it was suppose to recover you. If anyone know where i can get this kind of script please post me the name of the script or give me a link to the script.
 
Code:
class Game_Battler

  Opposite_Recovery_States = []

  alias_method :seph_opprecstates_gmbtlr_ae, :attack_effect

  def attack_effect(attacker)

    effective = seph_opprecstates_gmbtlr_ae(attacker)

    reverse_recovery_effect

    return effective

  end

 Â alias_method :seph_opprecstates_gmbtlr_se, :skill_effect

  def skill_effect(user, skill)

    effective = seph_opprecstates_gmbtlr_se(user, skill)

    reverse_recovery_effect

    return effective

  end

  alias_method :seph_opprecstates_gmbtlr_ie, :item_effect

  def item_effect(item)

    effective = seph_opprecstates_gmbtlr_ie(item)

    reverse_recovery_effect

    return effective

  end

  def reverse_recovery_effect

    if self.damage.is_a?(Numeric) && self.damage < 0

      reverse_recovery = false

      for state_id in self.states

        if Opposite_Recovery_States.include?(state_id)

          reverse_recovery = true

          break

        end

      end

      if reverse_recovery

        self.damage *= -1

        2.times {self.hp -= self.damage}

      end

    end

  end

end

Just paste that somewhere above Main. Fill Opposite_Recovery_States = [] with states that reverse the recovery effect. (So if states 3, 4, & 5 caused the recovery to be reversed, Opposite_Recovery_States = [] would be instead Opposite_Recovery_States = [3, 4, 5]).

Let me know if you have any problems with it or it doesn't work.
 

VCA

Member

I got an error while i was testing it out

Here some pic of the error:


ScreenHunter_02Feb052312.jpg




Here is the script:

ScreenHunter_01Feb052311.jpg


Well thanks SephirothSpawn for helping me but i need a little more help. Please help me out here with this error.
 

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