The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: zerothedarklord on March 13, 2012, 04:23:08 PM

Title: [VX] Variable state damage
Post by: zerothedarklord on March 13, 2012, 04:23:08 PM
Code: [Select]
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
#_/    ?            Slip Damage - KGC_SlipDamageExtension            ? VX ?
#_/    ?                   Last Update: 2008/03/29                        ?
#_/    ?                Translation by Mr. Anonymous                      ?
#_/-----------------------------------------------------------------------------
#_/  This script allows you to make states with "slip damage" or continual
#_/   damage/recovery outside of battle. This effect is accompanied by a screen
#_/   flash to indictate everytime the actor recieves damage/recovery.
#_/  Recall the "Poisoned" state in Pokemon.
#_/=============================================================================
#_/                         ? Instructions For Usage ?
#_/  To make use of this function, you must insert the <slip> tag into the
#_/   "Notes" box located in the States section of the database.
#_/   
#_/                Format: <slip [HP/MP] Modifier Rate (%), Steps>
#_/   Where HP/MP: Designate HP or MP damage/recovery.
#_/   Where Modifier: Use [ - ] or damage or [ + ] for recovery.
#_/   Where Rate: The desired amount of damage/recovery.
#_/   Where %: [Optional] You may insert % after rate for Max HP or Max MP.
#_/   Where Steps: The amount of steps it takes for the effect to kick in.
#_/
#_/   Ex: <slip HP -5%, 5>
#_/    For every 5 steps, 5 percent of the actor's max hp is lost.
#_/   
#_/   Ex: <slip MP +20, 10>
#_/    For every 10 steps, 20 MP is recovered.
#_/
#_/   Ex: <slip MP -10%>
#_/    After every turn in battle, 10 percent of MP is lost.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_

#==============================================================================#
#                            ? Customization ?                                 #
#==============================================================================#

module KGC
module SlipDamageExtension
  #                     ? Damage Indictation Flash ?
  #  This allows you to change the color of the flash that happens when the
  #   actor loses or gains health due to the Slip Damage state.
  DAMAGE_FLASH_COLOR    = Color.new(255, 0, 0, 64)
  #  This allows you to change the duration (in frames) the flash remains
  #   on-screen.
  DAMAGE_FLASH_DURATION = 4
end
end

#------------------------------------------------------------------------------#

$imported = {} if $imported == nil
$imported["SlipDamageExtension"] = true

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #
#  Unless you know what you're doing, it's best not to alter anything beyond  #
#  this point, as this only affects the tag used for "Notes" in database.     #
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #

#  Whatever word(s) are after the separator ( | ) in the following lines are
#   what are used to determine what is searched for in the "Notes" section of a
#   skill to see if it is an Steal skill.
#  Default Slip Damage State tag is <slip>

module KGC::SlipDamageExtension
  # Regular Expression Module
  module Regexp
    # State Module
    module State
      # Slip Damage tag string
      SLIP_DAMAGE = /<(?:SLIP|slip)\s*([HM]P)?\s*([\-\+]?\d+)([%?])?
        (?:\s*,\s*([\-\+]?\d+))?>/ix
    end
  end
end

#==============================================================================
# ? RPG::State
#==============================================================================

class RPG::State
  #--------------------------------------------------------------------------
  # ? ????????????????????
  #--------------------------------------------------------------------------
  def create_slip_damage_extension_cache
    @__slip_damage = false
    @__slip_damage_hp_rate  = 0
    @__slip_damage_hp_value = 0
    @__slip_damage_hp_map   = 0
    @__slip_damage_mp_rate  = 0
    @__slip_damage_mp_value = 0
    @__slip_damage_mp_map   = 0

    self.note.split(/[\r\n]+/).each { |line|
      case line
      when KGC::SlipDamageExtension::Regexp::State::SLIP_DAMAGE
        # ????????
        @__slip_damage = true
        analyse_slip_damage($~)
      end
    }

    # ??????????????????
    unless @__slip_damage
      @__slip_damage_hp_rate = 10
      @__slip_damage_hp_map = 1
    end
  end
  #--------------------------------------------------------------------------
  # ? ???????????
  #--------------------------------------------------------------------------
  def analyse_slip_damage(match)
    # ?????
    if match[1] == nil
      type = :hp
    else
      if match[1] =~ /MP/i
        type = :mp
      else
        type = :hp
      end
    end
    # ???????
    n = match[2].to_i
    # ?? or ????
    is_rate = (match[3] != nil)
    # ?????????
    map_n = (match[4] != nil ? match[4].to_i : 0)

    # ???????????
    case type
    when :hp
      if is_rate
        @__slip_damage_hp_rate -= n
      else
        @__slip_damage_hp_value -= n
      end
      @__slip_damage_hp_map -= map_n
    when :mp
      if is_rate
        @__slip_damage_mp_rate -= n
      else
        @__slip_damage_mp_value -= n
      end
      @__slip_damage_mp_map -= map_n
    end
  end
  #--------------------------------------------------------------------------
  # ? ????????
  #--------------------------------------------------------------------------
  unless $@
    alias slip_damage_KGC_SlipDamageExtension slip_damage
  end
  def slip_damage
    create_slip_damage_extension_cache if @__slip_damage == nil
    return (@__slip_damage || slip_damage_KGC_SlipDamageExtension)
  end
  #--------------------------------------------------------------------------
  # ? HP ???????? (??)
  #--------------------------------------------------------------------------
  def slip_damage_hp_rate
    create_slip_damage_extension_cache if @__slip_damage_hp_rate == nil
    return @__slip_damage_hp_rate
  end
  #--------------------------------------------------------------------------
  # ? HP ???????? (??)
  #--------------------------------------------------------------------------
  def slip_damage_hp_value
    create_slip_damage_extension_cache if @__slip_damage_hp_value == nil
    return @__slip_damage_hp_value
  end
  #--------------------------------------------------------------------------
  # ? HP ???????? (???)
  #--------------------------------------------------------------------------
  def slip_damage_hp_map
    create_slip_damage_extension_cache if @__slip_damage_hp_map == nil
    return @__slip_damage_hp_map
  end
  #--------------------------------------------------------------------------
  # ? MP ???????? (??)
  #--------------------------------------------------------------------------
  def slip_damage_mp_rate
    create_slip_damage_extension_cache if @__slip_damage_mp_rate == nil
    return @__slip_damage_mp_rate
  end
  #--------------------------------------------------------------------------
  # ? MP ???????? (??)
  #--------------------------------------------------------------------------
  def slip_damage_mp_value
    create_slip_damage_extension_cache if @__slip_damage_mp_value == nil
    return @__slip_damage_mp_value
  end
  #--------------------------------------------------------------------------
  # ? MP ???????? (???)
  #--------------------------------------------------------------------------
  def slip_damage_mp_map
    create_slip_damage_extension_cache if @__slip_damage_mp_map == nil
    return @__slip_damage_mp_map
  end
end

#???????????????????????????????????????

#==============================================================================
# ? Game_Battler
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # ? ?????????????
  #--------------------------------------------------------------------------
  def slip_damage_effect
    return unless slip_damage?

    slip_damage_effect_hp
    slip_damage_effect_mp
  end
  #--------------------------------------------------------------------------
  # ? HP ?????????????
  #--------------------------------------------------------------------------
  def slip_damage_effect_hp
    return if dead?

    n = 0
    self.states.each { |state|
      next unless state.slip_damage
      n += self.maxhp * state.slip_damage_hp_rate / 100
      n += state.slip_damage_hp_value
    }
    return if n == 0

    @hp_damage = [n, self.hp - 1].min
    self.hp -= @hp_damage
  end
  #--------------------------------------------------------------------------
  # ? MP ?????????????
  #--------------------------------------------------------------------------
  def slip_damage_effect_mp
    return if dead?

    n = 0
    self.states.each { |state|
      next unless state.slip_damage
      n += self.maxmp * state.slip_damage_mp_rate / 100
      n += state.slip_damage_mp_value
    }
    return if n == 0

    @mp_damage = [n, self.mp - 1].min
    self.mp -= @mp_damage
  end
  #--------------------------------------------------------------------------
  # ? ?????????????????
  #--------------------------------------------------------------------------
  def slip_damage_effect_on_walk
    last_hp = self.hp
    last_mp = self.mp
    self.states.each { |state|
      next unless state.slip_damage
      self.hp -= state.slip_damage_hp_map
      self.mp -= state.slip_damage_mp_map
    }
    # ????????????????
    if self.hp < last_hp || self.mp < last_mp
      $game_map.screen.start_flash(
        KGC::SlipDamageExtension::DAMAGE_FLASH_COLOR,
        KGC::SlipDamageExtension::DAMAGE_FLASH_DURATION)
    end
  end
  #--------------------------------------------------------------------------
  # ? ???????????
  #--------------------------------------------------------------------------
  def do_auto_recovery_on_walk
    return if dead?

    if auto_hp_recover
      self.hp += 1
    end
  end
end

#???????????????????????????????????????

#==============================================================================
# ? Game_Party
#==============================================================================

class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # ? ?????? 1 ?????????
  #--------------------------------------------------------------------------
  def on_player_walk
    for actor in members
      if actor.slip_damage?
        actor.slip_damage_effect_on_walk
      end
      actor.do_auto_recovery_on_walk
    end
  end
end
Looking to have a script made that would enable the slip damage of states to vary. Preferably through use of note tags. Here's an example of what I had in mind (and I suppose this could be edited into the existing script which I linked above. Also, that script already contains the <slip> function seen in the example):

Example:
<slip -1600>
<atk_f 100>

Where <atk_f> would make the slip damage be affected by the player's attack stat. I'm not sure if it'd matter, but I'd like the amounts to scale exactly as they do with skills. I would like this to be done also with spirit (<spi_f>) and if possible I'd like it to be able to affect skills as well (in case you want a skill to be influenced by more than 200), but also so that if used with a skill, the default set in the database is over-written with what is in the notebox (so that if you have 100 in the database and <atk_f 200> in the notebox, it'll use 200, rather than 100). I don't know if there needs to be a numerical scale to represent acceptable numbers for use or not, but if so, I'd like the scale to be 0 - 999.

The purpose of this is so that you can make those damage or healing over time abilities that don't always do the same amount per tick. It gets pretty boring seeing your max level curse spell always ticking for 5000 when you feel you should be more powerful than that.
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on March 17, 2012, 12:05:08 AM
Anyone?????
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on March 21, 2012, 09:12:26 AM
????????????
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on March 25, 2012, 07:02:37 PM
bump :D
Title: Re: [VX] Variable state damage
Post by: Illumination™ on March 25, 2012, 11:30:11 PM
I can help you I think, but what do you mean with Note Tags?
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on March 26, 2012, 06:48:55 AM
I would've hoped my description would've been good enough to explain it.... lol.... idk, not really sure how to explain it, not sure how it works. I know however that it makes it extremely easy to use the scripts. If you're not sure, maybe Pacman can give some input, he usually does scripts for me, and he knows exactly what I mean when I say "let's use note tags".

It's one of those scripts where it's like "put (command) in the skill/state/item/enemy's notebox within the database"

Example:
<slip -1600>
<atk_f 100>

Where <atk_f> would make the slip damage be affected by the player's attack stat. I'm not sure if it'd matter, but I'd like the amounts to scale exactly as they do with skills. I would like this to be done also with spirit (<spi_f>) and if possible I'd like it to be able to affect skills as well (in case you want a skill to be influenced by more than 200), but also so that if used with a skill, the default set in the database is over-written with what is in the notebox (so that if you have 100 in the database and <atk_f 200> in the notebox, it'll use 200, rather than 100). I don't know if there needs to be a numerical scale to represent acceptable numbers for use or not, but if so, I'd like the scale to be 0 - 999.
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on March 30, 2012, 09:42:22 PM
Bump :D Anyone?
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on April 15, 2012, 11:47:43 PM
Anything?
Title: Re: [VX] Variable state damage
Post by: pacdiggity on April 16, 2012, 08:37:46 AM
I can help you I think, but what do you mean with Note Tags?

He means a specific code or tag in the applicable notebox in the database that is detected and used by the script. They are found with REGEXPs. What he is looking for would be something like this:
Code: [Select]
class RPG::State
  def damage_variable
    return !self.note[/<atk[_ ]?f:?[ ](\d+)>/i].nil? ? $1.to_i : 0
  end
end
That would return, say, 5 in the tag <atk f: 5>. It would also return 5 if the tag was <atkf 5> or <atk_f: 5>. You would then use the damage_variable method of the state to alter stuff and things as usual.
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on April 28, 2012, 03:19:33 AM
so this would work then?
Title: Re: [VX] Variable state damage
Post by: pacdiggity on April 28, 2012, 03:28:25 AM
No, I was just telling Illumination how notetags work.
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on April 28, 2012, 03:53:15 PM
oh, yeah, I'd really like to get this working, would be extremely helpful for my game.
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on May 01, 2012, 07:11:15 AM
Anyone?
Title: Re: [VX] Variable state damage
Post by: Kaidan on May 01, 2012, 05:41:16 PM
Yanfly's Lunatic States Package: Punishment (http://yanflychannel.wordpress.com/rmvxa/battle-scripts/lunatic-states/lsp-punishment/) does this. From Yanfly's site:

Quote
Punish Effect No.5: Stat Slip Damage

Best used with close effect. At the end of the turn, the affected battler will take HP slip damage based on the stat of the of one who casted the status effect onto the battler. Battler cannot die from this effect.

<close effect: stat slip damage x%>

The only problem I can see is that the DoT / slip damage wouldn't kill the target, but I imagine that would be an easy fix if you want lethal slip damage.

Edit: I'm pretty sure this is what you'd need to edit:

Code: [Select]
user.perform_damage_effect
user.hp = [user.hp - dmg, 1].max

The .max function tells the game to leave the target at 1 HP if their HP would be reduced below that by the slip damage.
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on May 02, 2012, 04:13:01 AM
Thanks, but I'm not looking for an add-on to something else, I'm not planning to use extra scripts simply to get the 1 I want to work.

Also, it looks like that one is for Ace.
Title: Re: [VX] Variable state damage
Post by: Kaidan on May 02, 2012, 04:57:49 AM
Yeah, sorry about that. I should learn to read tags.
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on May 02, 2012, 05:08:38 AM
All good, just really hoping I can get this. I figured out the other thing I really wanted, a way to add chance-on-hit effects to abilities, so now I just need to get this and all will be well!
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on May 11, 2012, 12:00:14 AM
*BUMP*
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on June 12, 2012, 05:24:20 AM
bump
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on June 17, 2012, 05:35:45 AM
still really need this..... anyone?
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on June 21, 2012, 03:59:17 AM
just another friendly neighborhood bump :D
Title: Re: [VX] Variable state damage
Post by: zerothedarklord on June 26, 2012, 06:28:26 AM
Was also hoping to see this made with the addition of the ability to make slip damage/healing capable of being critical, something like:

\cancrit[5]

where \cancrit enables it to crit using the character's crit chance, and the number between [ ] is the skill's crit bonus chance. in other words, the character has 20% crit chance, the skill has 5, so it'd have a 25% chance to crit.