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.

Wounding System

I am in need of a wound system for a RPGMaker VX project. Essentially, the script needs to add a type of "wound" damage, that cannot be healed using conventional methods; only by a certain NPC and special items or skills. This script must be compatible with Tankentai's normal Side Battle System V.3.4D Also, it would be best if the wound value could be displayed to the immediate left of the HP bar, but a modification to the HP bar itself is not needed. Please notify me if you can attempt this request.
 
well if you can't get a script for it... I'm pretty sure there's a way to set up a "state" that lowers the overall HP of the character. So if he's got like 100hp normally you can create a state that makes him have only 70hp as his max HP. So in a sense this can be a "wound". And with states you can easily designate who or what can cure it and not have regular cures get in the way because they will only heal to the max which the state has modified. Hope that helps if there's no other alternative.
 

Atoa

Member

@BlueScope
No, he want damage that CAN'T be healed.

Basically he wants a type of damage that reduce temporally de maxhp.

It would be really easy if it wasn't the necessary compatibity with Tankentai, since it handle skill differently. Well even with tankentai it wouldn't be hard, but would require the script to take a look at it, and i really dislike tankentai u.u
 
Ah, I see... okay, maxhp actually makes sense then. What I can think of immediately is to use the maphp definition within Game_Actor or Game_Battler or which it is, and reduce it by X if a certain state is true. Should be compatible with anything that doesn't redefine that very same method, and skills/items would just have to address the state, not anything else.
 
Well I can't find that battle system you're using, but guessing that (like most of the battle systems) it doesn't change anything in Game_Battler class you can use this script. :)

EDIT: Sorry didin't see you wanted this for RMVX. I made a RMXP version. I made RMVX version also.

This is RMXP version
[rgss] 
#==============================================================================
# Wound State
# by Drago del Fato
# Version: 1.0.0
# License: Free for non commercial.
#------------------------------------------------------------------------------
# Put above main. If you use this put me in credits.
#==============================================================================
module WoundConsts
   # Put the ID of the state here. I've put Venom state (default ID is 3).
   STATE_ID = 3
end
 
class Game_Battler
 
    def item_effect(item)
    # Clear critical flag
    self.critical = false
    # If item scope is for ally with 1 or more HP, and your own HP = 0,
    # or item scope is for ally with 0 HP, and your own HP = 1 or more
    if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
       ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
      # End Method
      return false
    end
    # Clear effective flag
    effective = false
    # Set effective flag if common ID is effective
    effective |= item.common_event_id > 0
    # Determine hit
    hit_result = (rand(100) < item.hit)
    # Set effective flag is skill is uncertain
    effective |= item.hit < 100
    # If hit occurs
    if hit_result == true
      # Calculate amount of recovery
      recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
      recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
      if recover_hp < 0
        recover_hp += self.pdef * item.pdef_f / 20
        recover_hp += self.mdef * item.mdef_f / 20
        recover_hp = [recover_hp, 0].min
      end
      # Element correction
      recover_hp *= elements_correct(item.element_set)
      recover_hp /= 100
      recover_sp *= elements_correct(item.element_set)
      recover_sp /= 100
      # Dispersion
      if item.variance > 0 and recover_hp.abs > 0
        amp = [recover_hp.abs * item.variance / 100, 1].max
        recover_hp += rand(amp+1) + rand(amp+1) - amp
      end
      if item.variance > 0 and recover_sp.abs > 0
        amp = [recover_sp.abs * item.variance / 100, 1].max
        recover_sp += rand(amp+1) + rand(amp+1) - amp
      end
      # If recovery code is negative
      if recover_hp < 0
        # Guard correction
        if self.guarding?
          recover_hp /= 2
        end
      end
     
      recover_hp = 0 if @states.include?(WoundConsts::STATE_ID)
     
      # Set damage value and reverse HP recovery amount
      self.damage = -recover_hp
      # HP and SP recovery
      last_hp = self.hp
      last_sp = self.sp
      self.hp += recover_hp
      self.sp += recover_sp
      effective |= self.hp != last_hp
      effective |= self.sp != last_sp
      # State change
      @state_changed = false
      effective |= states_plus(item.plus_state_set)
      effective |= states_minus(item.minus_state_set)
      # If parameter value increase is effective
      if item.parameter_type > 0 and item.parameter_points != 0
        # Branch by parameter
        case item.parameter_type
        when 1  # Max HP
          @maxhp_plus += item.parameter_points
        when 2  # Max SP
          @maxsp_plus += item.parameter_points
        when 3  # Strength
          @str_plus += item.parameter_points
        when 4  # Dexterity
          @dex_plus += item.parameter_points
        when 5  # Agility
          @agi_plus += item.parameter_points
        when 6  # Intelligence
          @int_plus += item.parameter_points
        end
        # Set to effective flag
        effective = true
      end
      # If HP recovery rate and recovery amount are 0
      if item.recover_hp_rate == 0 and item.recover_hp == 0
        # Set damage to empty string
        self.damage = ""
        # If SP recovery rate / recovery amount are 0, and parameter increase
        # value is ineffective.
        if item.recover_sp_rate == 0 and item.recover_sp == 0 and
           (item.parameter_type == 0 or item.parameter_points == 0)
          # If state is unchanged
          unless @state_changed
            # Set damage to "Miss"
            self.damage = "Miss"
          end
        end
      end
    # If miss occurs
    else
      # Set damage to "Miss"
      self.damage = "Miss"
    end
    # If not in battle
    unless $game_temp.in_battle
      # Set damage to nil
      self.damage = nil
    end
    # End Method
    return effective
  end
 
    def skill_effect(user, skill)
    # Clear critical flag
    self.critical = false
    # If skill scope is for ally with 1 or more HP, and your own HP = 0,
    # or skill scope is for ally with 0, and your own HP = 1 or more
    if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
       ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
      # End Method
      return false
    end
    # Clear effective flag
    effective = false
    # Set effective flag if common ID is effective
    effective |= skill.common_event_id > 0
    # First hit detection
    hit = skill.hit
    if skill.atk_f > 0
      hit *= user.hit / 100
    end
    hit_result = (rand(100) < hit)
    # Set effective flag if skill is uncertain
    effective |= hit < 100
    # If hit occurs
    if hit_result == true
      # Calculate power
      power = skill.power + user.atk * skill.atk_f / 100
      if power > 0
        power -= self.pdef * skill.pdef_f / 200
        power -= self.mdef * skill.mdef_f / 200
        power = [power, 0].max
      end
      # Calculate rate
      rate = 20
      rate += (user.str * skill.str_f / 100)
      rate += (user.dex * skill.dex_f / 100)
      rate += (user.agi * skill.agi_f / 100)
      rate += (user.int * skill.int_f / 100)
      # Calculate basic damage
      self.damage = power * rate / 20
      # Element correction
      self.damage *= elements_correct(skill.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end
      # Dispersion
      if skill.variance > 0 and self.damage.abs > 0
        amp = [self.damage.abs * skill.variance / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # Second hit detection
      eva = 8 * self.agi / user.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
      # Set effective flag if skill is uncertain
      effective |= hit < 100
    end
    # If hit occurs
    if hit_result == true
      # If physical attack has power other than 0
      if skill.power != 0 and skill.atk_f > 0
        # State Removed by Shock
        remove_states_shock
        # Set to effective flag
        effective = true
      end
     
      self.damage = 0 if @states.include?(WoundConsts::STATE_ID) && self.damage < 0
     
      # Substract damage from HP
      last_hp = self.hp
      self.hp -= self.damage
      effective |= self.hp != last_hp
      # State change
      @state_changed = false
      effective |= states_plus(skill.plus_state_set)
      effective |= states_minus(skill.minus_state_set)
      # If power is 0
      if skill.power == 0
        # Set damage to an empty string
        self.damage = ""
        # If state is unchanged
        unless @state_changed
          # Set damage to "Miss"
          self.damage = "Miss"
        end
      end
    # If miss occurs
    else
      # Set damage to "Miss"
      self.damage = "Miss"
    end
    # If not in battle
    unless $game_temp.in_battle
      # Set damage to nil
      self.damage = nil
    end
    # End Method
    return effective
  end
 
end
 
[/rgss]

This is RMVX version
[rgss] 
#==============================================================================
# Wound State
# by Drago del Fato
# Version: 1.0.0
# License: Free for non commercial.
#------------------------------------------------------------------------------
# Put above main. If you use this put me in credits.
#==============================================================================
module WoundConsts
  STATE_ID = 2
end
 
class Game_Battler
 
  def calc_hp_recovery(user, item)
    result = maxhp * item.hp_recovery_rate / 100 + item.hp_recovery
    result *= 2 if user.pharmacology    # Pharmacology doubles the effect
    return 0 if @states.include?(WoundConsts::STATE_ID)
    return result
  end
 
    def make_obj_damage_value(user, obj)
    damage = obj.base_damage                        # get base damage
    if damage > 0                                   # a positive number?
      damage += user.atk * 4 * obj.atk_f / 100      # Attack F of the user
      damage += user.spi * 2 * obj.spi_f / 100      # Spirit F of the user
      unless obj.ignore_defense                     # Except for ignore defense
        damage -= self.def * 2 * obj.atk_f / 100    # Attack F of the target
        damage -= self.spi * 1 * obj.spi_f / 100    # Spirit F of the target
      end
      damage = 0 if damage < 0                      # If negative, make 0
    elsif damage < 0                                # a negative number?
      damage -= user.atk * 4 * obj.atk_f / 100      # Attack F of the user
      damage -= user.spi * 2 * obj.spi_f / 100      # Spirit F of the user
    end
    damage *= elements_max_rate(obj.element_set)    # elemental adjustment
    damage /= 100
    damage = apply_variance(damage, obj.variance)   # variance
    damage = apply_guard(damage)                    # guard adjustment
    if obj.damage_to_mp  
      @mp_damage = damage                           # damage MP
    else
      @hp_damage = (@states.include?(WoundConsts::STATE_ID) && damage < 0) ? 0 : damage
    end
  end
end
 
[/rgss]

Make a state in the database and call it Wound or whatever you will, then in script modifiy STATE_ID to the ID number of that state in the database (for example if you see 008: Wound in states in database then write STATE_ID = 8).
 
Thank you Drago, but it does actually modify all/most of the code used to calculate damage and hp. The script worked for the most part, but it caused a graphics error in which the HUD moved halfway off screen and the hp bars for the actors didn't change until the start of the new turn.

These are the scripts being used: http://www.rpgmakervx.net/index.php?sho ... entry41901

I now see that it has been updated to version 3.4E now. So disregard the earlier version and use this one.

This wound system is close to what I am wanting, but for better reference: http://wiki.mabinogiworld.com/index.php ... und#Wounds

My team is looking for a wound system similar to that of the MMORPG Mabinogi. Monsters in this game have a monster-specific percentage chance to cause a percentage of their attacks damage to add wound damage on top of the normal damage.
 
Well from what I understand you want this:

RMVX
[rgss] 
#==============================================================================
# Wound State
# by Drago del Fato
# Version: 1.2.1
# License: Free for non commercial.
#------------------------------------------------------------------------------
# Put above main. If you use this put me in credits.
#==============================================================================
module WoundConsts
  # Put the ID of the state here. I've put Venom state (default ID is 2).
  STATE_ID = 17
end
 
class Game_Interpreter
 
  def wound_all(amount)
    for actor in $game_party.members
      actor.wound(amount)
    end
  end
 
  def wound_one(actor_id, amount)
    for actor in $game_party.members
      actor.wound(amount) if actor.id == actor_id
    end
  end
 
end
 
class Game_Battler
 
  alias new_initialize initialize
  def initialize
    @wound_maxhp = 0
    new_initialize
  end
 
  def wound(amount)
    @wound_maxhp -= amount
    self.hp -= amount
  end
 
    def recover_all
    @hp = maxhp
    @mp = maxmp
    @wound_maxhp = maxhp
    for i in @states.clone do remove_state(i) end
  end
 
  def maxhp=(new_maxhp)
    @maxhp_plus += new_maxhp - self.maxhp
    @maxhp_plus = [[@maxhp_plus, -9999].max, 9999].min
    @hp = [@hp, self.maxhp].min
    if @states.include?(WoundConsts::STATE_ID) == false
     @wound_maxhp = self.maxhp
    end
  end
 
  def calc_hp_recovery(user, item)
    result = maxhp * item.hp_recovery_rate / 100 + item.hp_recovery
    result *= 2 if user.pharmacology    # Pharmacology doubles the effect
    if @states.include?(WoundConsts::STATE_ID)
     result = @wound_maxhp - self.hp if self.hp + result > @wound_maxhp
    end
    return result
  end
 
    def make_obj_damage_value(user, obj)
    damage = obj.base_damage                        # get base damage
    if damage > 0                                   # a positive number?
      damage += user.atk * 4 * obj.atk_f / 100      # Attack F of the user
      damage += user.spi * 2 * obj.spi_f / 100      # Spirit F of the user
      unless obj.ignore_defense                     # Except for ignore defense
        damage -= self.def * 2 * obj.atk_f / 100    # Attack F of the target
        damage -= self.spi * 1 * obj.spi_f / 100    # Spirit F of the target
      end
      damage = 0 if damage < 0                      # If negative, make 0
    elsif damage < 0                                # a negative number?
      damage -= user.atk * 4 * obj.atk_f / 100      # Attack F of the user
      damage -= user.spi * 2 * obj.spi_f / 100      # Spirit F of the user
    end
    damage *= elements_max_rate(obj.element_set)    # elemental adjustment
    damage /= 100
    damage = apply_variance(damage, obj.variance)   # variance
    damage = apply_guard(damage)                    # guard adjustment
    if obj.damage_to_mp  
      @mp_damage = damage                           # damage MP
    else
      if (@states.include?(WoundConsts::STATE_ID) && damage < 0)
       damage = (@wound_maxhp - self.hp) * -1 if self.hp - damage > @wound_maxhp
      end
      @hp_damage = damage
    end
  end
 
    def remove_state(state_id)
    return unless state?(state_id)        # Is this state not added?
    if state_id == 1 and @hp == 0         # If it is incapacitated (state 1)
      @hp = 1                             # Change HP to 1
    end
    @wound_maxhp = self.maxhp if state_id == WoundConsts::STATE_ID
    @states.delete(state_id)              # Remove the ID from the @states
    @state_turns.delete(state_id)         # Remove from the @state_turns
  end
 
  alias execute_damage_v2 execute_damage
  def execute_damage(user)
      if user.action.kind == 1
        if $data_skills[user.action.skill_id].plus_state_set.include?(WoundConsts::STATE_ID)
          @wound_maxhp = self.hp - @hp_damage
        end
      end
      execute_damage_v2(user)
  end
 
end
 
[/rgss]

Which means when Wound Damage is inflicted it cannot be healed normally (using potions or skills), but normal damage can be healed.

I've tested it with 3.4E version and it's works ok. :)

Few things:
- You can heal characters ONLY when the Wound state is removed, not before.
- To inflict wound damage through events call script in event and write (of course you need to inflict wound State first):

To wound entire party:
wound_all(amount of hp here)

To wound a specific character
wound_one(character ID, amount of HP)
 
I've tested your system out now, but when I use a heal skill or use any healing item, it heals all damage, hp and wound. Also, I didn't understand why everyone was trying to make this a status effect, but I think I see why now, so, I will try to explain it one more time.

Essentially what this script needs to add is another type of damage, which for practicality I will call wound_damage to differentiate between hp_damage.

Hp_damage is for any and all attacks and/or skills; hp_damage is your typical health points and measure of vitality within the actor.
Wound_damage is for any type of severe damage such as a crack in a bone after a blunt attack or a stab's puncture wound, something that can't be healed instantly.

Wound_damage should be completely separate from hp_damage, which is why I request some type of gauge, or just a percentage (wound_damage over maxhp) written in a string format next to the actor's hp bar itself.

What I want to be able to do, is allow for a certain percentage of an enemies attack to be transferred into wound damage, while still doing the same amount of hp damage (Critical attacks doing more wound than normal attacks of course), but, this only happening a fraction of the time an enemy attacks.
It wound be perfect if I could set up the exact percentages within an enemies' bios or data and have the script call on that variable to calculate everything else.

Again, Drago I thank you for your time and patience. I apologize that I have not been specific enough even though the forum clearly says to be overly-specific.
 

Atoa

Member

making it an state is the easier way, and probably the only good way of doing it without messing with the tankentai itself

i was thinking of making an new variable for Game_Battler something like

Code:
class Game_Battler

 

  attr_accessor :wound_hp

  

  alias clear_extra_values_wound clear_extra_values

  def clear_extra_values

    clear_extra_values_wound

    @wound_hp = 0

  end

 

  alias maxhp_wound maxhp

  def maxhp

    base = maxhp_wound 

    wound = [[@wound_hp, 0].max, base / 2].min #so wound damage don't reduce maxhp bellow half, you can change it as you want

    return [[base - wound, 1].max, maxhp_limit].min

  end

end

Then i would use notetags to set the chance and the amount of "wound" damage, but that's is the part that would need to mess with tankentai, since it change several of the battle handling methods.
And from tankentai, i want distance.
 
@aedriam
Well, true you should have been more specific, since this would really need a lot of fiddling around. And as Atoa said I would need to change some things in Tankentai's Battle System (one of the things being showing the wound damage percentage). I can do it but it will take some time.
 

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