MP to HP and vice versa

Started by MarkHest, November 03, 2013, 06:18:23 pm

Previous topic - Next topic

KK20

Impossibru--I wasn't getting the error immediately before the activation of a skill. Reflect script is still below it?

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

G_G

Okay, try this Mark. I did what KK20 suggested and removed "Game_Actor < "
#===============================================================================
# HP/SP Reversal
# Author gameus
# Version 1.0
#-------------------------------------------------------------------------------
# Intro:
# Uses skills to take SP and convert it to HP or vica versa. The way it's setup
# is if the target is hit with one of these skills, it takes their HP/SP and
# turns it into the other stat. The skill itself doesn't affect the caster
# itself other than taking SP from the skill cost.
#
# Features:
# Use a fixed rate or a percentage
# Skills can work on enemies or allies
# Easy Setup
#
# Setting Up:
# To define a skill as HP to SP, add the id to the HP2SP array.
# Do the same for SP to HP skills, except add it to SP2HP array.
# To define the skills rate as "fixed" or "percentage", just set the skill
# to the desired rate in the config below. (Examples are provided)
#
# To define the amount of HP or SP to convert, all you do is go into the
# database and set the skill's "Power" attribute. e.g.
# If you have a skill that converts 100 HP to SP, make sure it's setup in the
# config:
#  HP2SP = {
#     skill_id => :fixed,
# }
# Then you go to the database and set teh power to 100. If it's a percentage,
# You just set the power to the percentage you want. e.g. 25% is 25 power.
#
# It is not possible to kill the target by converting HP to SP, but you can
# deplete all of the SP converting it to HP
#
# Compatibility:
# Not tested with SDK
# Not tested with any other skill add-ons but it should work
#
# Credits:
# gameus ~ creating it
# Mark Hest ~ Requesting it
#===============================================================================
module HPSP
  # These are skills that convert HP to SP
  HP2SP = {
    59 => :fixed,
    60 => :percent,
  }
  # These are skills that convert SP to HP
  SP2HP = {
    57 => :fixed,
    58 => :percent,
  }
  # Ignore everything below.
  def self.has?(skill_id)
    return (HP2SP.include?(skill_id) || SP2HP.include?(skill_id))
  end
  def self.type(skill_id)
    return nil if !self.has?(skill_id)
    return :hp if HP2SP.include?(skill_id)
    return :sp if SP2HP.include?(skill_id)
  end
end


class Game_Battler
  alias gg_convert_hpmp_skill_effect_lat skill_effect
  def skill_effect(user, skill)
    if HPSP.has?(skill.id)
      type = HPSP.type(skill.id)
      rate = type == :hp ? HPSP::HP2SP[skill.id] : HPSP::SP2HP[skill.id]
      amount = rate == :fixed ? skill.power : (skill.power * 0.01)
      if type == :hp && self.hp > 1
        amount = (rate == :fixed ? [self.hp - 1, amount].min : self.hp * amount).ceil
        self.hp -= amount.to_i
        self.sp += amount.to_i
        self.damage = "-#{amount} +#{amount}"
      elsif type == :sp && self.sp > 0
        amount = (rate == :fixed ? [self.sp, amount].min : self.sp * amount).ceil
        self.hp += amount.to_i
        self.sp -= amount.to_i
        self.damage = "+#{amount} -#{amount}"
      else
        return false
      end
      return true
    end
    return gg_convert_hpmp_skill_effect_lat(user, skill)
  end
end


And then, I placed Blizzard's Reflection Script under my script and I didn't get the error anymore.

MarkHest

Ah yes, I did change it back to being above it after getting the error. I Changed it back to being under it again and now it works :D Thank you!
   

G_G

What happened is I edited the method under Game_Actor rather than Game_Battler. Blizzard's script edits Game_Battler and tried calling the method when target ended up begin an actor and my method didn't support three arguments.

Ranquil

Just a thought... Shouldn't a MP to HP skill be already possible to do without any additional scripts? Just make a healing spell that costs a certain amount of MP that heals the exact same amount in HP.

Naturally this won't work is it costs a certain percentage of MP or it's a HP to MP skill. :D
Quote from: Some guy on FacebookLife is like a penis. It's short but it feels so long when it gets hard.


Quote from: Steven WinterburnBefore you diagnose yourself with depression or low self-esteem, first make sure that you are not, in fact, just surrounded by assholes.

G_G

An MP to HP does already work, but percentages don't, and the point was, he also wanted an HP to MP skill. Not to mention, this script makes it so whatever target he uses it on, uses the target's MP and HP, not the caster.