[XP] HoT DoT Issues

MarioWidjaya123

Veteran
Veteran
Joined
May 16, 2020
Messages
187
Reaction score
6
First Language
English
Primarily Uses
RMXP
i have this script called HoT DoT (A.K.A. Heal over Time Damage over Time (and i think what thats stand for))
Ruby:
#==============================================================================
# HoT DoT
# Author: Shdwlink1993
# Version: 1.04
# Type: Poison Control
#
# Editted by KK20
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# HT Date 1.0b: 1/11/2009
# HT Date 1.01b: 1/12/2009
# HT Date 1.02: 2/19/2012
# HT Date 1.03: 3/20/2012
# HT Date 1.04: 4/08/2012
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# #  This work is protected by the following license:
# #----------------------------------------------------------------------------
# # 
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# # 
# #  You are free:
# # 
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# # 
# #  Under the following conditions:
# # 
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# # 
# #  Noncommercial. You may not use this work for commercial purposes.
# # 
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# # 
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# # 
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# # 
# #  - Nothing in this license impairs or restricts the author's moral rights.
# # 
# #----------------------------------------------------------------------------
# #
# # Note that if you share this file, even after editing it, you must still
# # give proper credit to shdwlink1993.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#                                ~= Function =~
#
# This script is designed to allow you to expand what poison does to your
# character. Poison now is able to affect HP or SP, and take off a fraction or
# a set amount of HP/SP.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#                               ~= Version History =~
#
# Version 1.0b ---------------------------------------------------- [1/11/2009]
# Version 1.01b --------------------------------------------------- [1/12/2009]
# Version 1.02 ---------------------------------------------------- [2/19/2012]
# Version 1.03 ---------------------------------------------------- [3/20/2012]
# Version 1.04 ---------------------------------------------------- [4/08/2012]
#
#  V 1.04 Changes:
#  - DoT that heals will make the screen flash green instead of red
#  - Damage values that were displayed in battle were inaccurate
#  - Percentage based damage was written incorrectly
#
#  V 1.03 Changes:
#  - Percentage-based DoT healed when damage values were positive and visa-versa
#  - Modified how variance was calculated (added explanation in config)
#  - Organized script to be easier on the eyes and added comment lines
#
#  V 1.02 Changes:
#  - Negative damage values damaged instead of healed and visa-versa
#  - Limit_Drain was bugged and has now been fixed
#  - HP and SP damage was being calculated twice (thus actual damage/healing
#    was twice the value the user configured)
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#                              ~= Customization =~
#
# Customization can be found right under where the Poison Database begins.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
#                               ~= Compatability =~
#
# - Low probability of working with the SDK.
# - Will not work with other Poison-editing scripts.
# - Must be placed above Tons of Addons.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

module SL93
 
  def self.hotdot(id)
    case id
    #------------------------------------------------------------------------
    # Poison Database Begins
    #------------------------------------------------------------------------
    #  when STATE_NUMBER then return [TYPE, DAMAGE, VARIANCE, LIMIT_DRAIN]
    #  * STATE_NUMBER is the state you want to be affected by this.
    #  * TYPE refers to the thing sustaining damage.
    #      1 = HP, 2 = SP. If the type is positive, the amount is a literal
    #      number (eg. You lose about 50 HP). If the type is negative, then
    #      the amount is a fraction of the maximum (eg. You lose about 50% of
    #      your HP).
    #  * DAMAGE refers to how much damage is healed/taken.
    #      A Positive amount hurts you and a negative amount heals you.
    #  * VARIANCE refers to how much the damage varies. Positive only.
    #      This depends in part on if TYPE was positive or negative.
    #
    #      Example A: TYPE is positive. VARIANCE is 15.
    #                 Damage/Heal amount can do up to 15 more or 15 less.
    #
    #      Example B: TYPE is negative. VARIANCE is 15.
    #                 Damage/Heal amount can do up to 15% more or 15% less.
    #
    #  * LIMIT_DRAIN refers to if the poison can leave you with 0 HP/SP.
    #      If true, then it is limited, and stops at 1. If false, then it
    #      isn't.
    #------------------------------------------------------------------------
       when 6 then return [-1, -10, 0, false]  # Sleep HP Regen
     when 6 then return [-2, -5, 0, false]   # Sleep SP Regen
    #------------------------------------------------------------------------
    # Poison Database Ends
    #------------------------------------------------------------------------
    end
    return false
  end
 
end

class Game_Battler
 
  def slip_damage?
    return @states.any? {|i| SL93.hotdot(i) != false }
  end
 
  def slip_damage_effect
    ids = []
    sp_damage = 0
    self.damage = 0
    # Get the HoT/DoT states applied to the character
    for i in @states
      ids.push(i) if SL93.hotdot(i) != false
    end
    
    for i in ids
      # If the state damages/heals by a literal number
      if SL93.hotdot(i)[0] > 0
        damage = SL93.hotdot(i)[1]
      # If the state damages/heals HP by a percent
      elsif SL93.hotdot(i)[0] == -1
        damage = self.maxhp * SL93.hotdot(i)[1] / 100
      # If the state damages/heals SP by a percent
      elsif SL93.hotdot(i)[0] == -2
        damage = self.maxsp * SL93.hotdot(i)[1] / 100
      end
      
      # If damage/heal amount is not zero and variance exists
      if damage != 0 && SL93.hotdot(i)[2] > 0
        # Variance based on literal numbers
        amp = (damage.abs < SL93.hotdot(i)[2] ? damage.abs - 1 : SL93.hotdot(i)[2]) if SL93.hotdot(i)[0] > 0
        # Variance based on percentages
        amp = [damage.abs * SL93.hotdot(i)[2] / 100, 1].max if SL93.hotdot(i)[0] < 0
        # Apply variance amounts to damage/heal amount
        damage += rand(amp+1) + rand(amp+1) - amp
      end
      
      # If HP damage/heal
      if SL93.hotdot(i)[0].abs == 1
        hp = @hp
        # If limit_drain and actual HP damage being done (not healing)
        if SL93.hotdot(i)[3] and damage > 0
          self.hp = [hp - damage,1].max # Leave 1 HP
        else
          self.hp -= damage
        end
        # Add total damage to variable
        self.damage += damage
      # If SP damage/heal
      elsif SL93.hotdot(i)[0].abs == 2
        sp = @sp
        # If limit_drain and actual SP damage being done (not healing)
        if SL93.hotdot(i)[3] and damage > 0
          self.sp = [sp - damage,1].max # Leave 1 SP
        else
          self.sp -= damage
        end
        # Add total SP damage to variable
        sp_damage += damage
      end
    end
    # Modify @damage to be SP damage if no changes to HP were made
    self.damage = sp_damage if self.damage == 0
  end
 
end

class Game_Party
 
  def check_map_slip_damage
    @actors.each {|actor|
      if actor.hp > 0 && actor.slip_damage?
        actor.slip_damage_effect
        if actor.damage <= 0
          # Positive DoT makes green screen
          $game_screen.start_flash(Color.new(0, 255, 0, 128), 4)
        else
          # Negative DoT makes red screen
          $game_screen.start_flash(Color.new(255, 0, 0, 128), 4)
        end
        $game_temp.gameover = $game_party.all_dead?
      end
    }
  end
 
end
and the issue with this script is that is the HP and SP damage/regen can't combine to eachother.

here is my config
Ruby:
    #------------------------------------------------------------------------
    # Poison Database Begins
    #------------------------------------------------------------------------
    #  when STATE_NUMBER then return [TYPE, DAMAGE, VARIANCE, LIMIT_DRAIN]
    #  * STATE_NUMBER is the state you want to be affected by this.
    #  * TYPE refers to the thing sustaining damage.
    #      1 = HP, 2 = SP. If the type is positive, the amount is a literal
    #      number (eg. You lose about 50 HP). If the type is negative, then
    #      the amount is a fraction of the maximum (eg. You lose about 50% of
    #      your HP).
    #  * DAMAGE refers to how much damage is healed/taken.
    #      A Positive amount hurts you and a negative amount heals you.
    #  * VARIANCE refers to how much the damage varies. Positive only.
    #      This depends in part on if TYPE was positive or negative.
    #
    #      Example A: TYPE is positive. VARIANCE is 15.
    #                 Damage/Heal amount can do up to 15 more or 15 less.
    #
    #      Example B: TYPE is negative. VARIANCE is 15.
    #                 Damage/Heal amount can do up to 15% more or 15% less.
    #
    #  * LIMIT_DRAIN refers to if the poison can leave you with 0 HP/SP.
    #      If true, then it is limited, and stops at 1. If false, then it
    #      isn't.
    #------------------------------------------------------------------------
     when 6 then return [-1, -10, 0, false]  # Sleep HP Regen
     when 6 then return [-2, -5, 0, false]   # Sleep SP Regen
    #------------------------------------------------------------------------
    # Poison Database Ends
    #------------------------------------------------------------------------
State #6 is Sleep, i want the Sleep State to recover 10% HP and 5% SP (or i think it is +5% SP)
just like in Persona 5 where an enemy or an ally is Asleep they will recover HP and SP until they're awake.
if anyone can figure it out, let me know.
btw @KK20 if you see this, you know what this script is.
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
281
Reaction score
106
First Language
English
Primarily Uses
RMXP
I've modified it so that you can make your configuration consist of more than one array of data per state ID. I'll go ahead and update the topic on CP to include this feature when the request is completed.
Code:
#==============================================================================
# HoT DoT
# Author: Shdwlink1993
# Version: 1.05b
# Type: Poison Control
#
# Editted by KK20
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# HT Date 1.0b: 1/11/2009
# HT Date 1.01b: 1/12/2009
# HT Date 1.02: 2/19/2012
# HT Date 1.03: 3/20/2012
# HT Date 1.04: 4/08/2012
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# 
# #  This work is protected by the following license:
# #----------------------------------------------------------------------------
# #  
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #  
# #  You are free:
# #  
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# #  
# #  Under the following conditions:
# #  
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# #  
# #  Noncommercial. You may not use this work for commercial purposes.
# #  
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# #  
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# #  
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# #  
# #  - Nothing in this license impairs or restricts the author's moral rights.
# #  
# #----------------------------------------------------------------------------
# # 
# # Note that if you share this file, even after editing it, you must still
# # give proper credit to shdwlink1993.
# 
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# 
#                                ~= Function =~
# 
# This script is designed to allow you to expand what poison does to your
# character. Poison now is able to affect HP or SP, and take off a fraction or
# a set amount of HP/SP.
# 
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# 
#                               ~= Version History =~
#
# Version 1.0b ---------------------------------------------------- [1/11/2009]
# Version 1.01b --------------------------------------------------- [1/12/2009]
# Version 1.02 ---------------------------------------------------- [2/19/2012]
# Version 1.03 ---------------------------------------------------- [3/20/2012]
# Version 1.04 ---------------------------------------------------- [4/08/2012]
#
#  V 1.04 Changes:
#  - DoT that heals will make the screen flash green instead of red
#  - Damage values that were displayed in battle were inaccurate
#  - Percentage based damage was written incorrectly
#
#  V 1.03 Changes:
#  - Percentage-based DoT healed when damage values were positive and visa-versa
#  - Modified how variance was calculated (added explanation in config)
#  - Organized script to be easier on the eyes and added comment lines
#
#  V 1.02 Changes:
#  - Negative damage values damaged instead of healed and visa-versa
#  - Limit_Drain was bugged and has now been fixed
#  - HP and SP damage was being calculated twice (thus actual damage/healing
#    was twice the value the user configured)
# 
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# 
#                              ~= Customization =~
# 
# Customization can be found right under where the Poison Database begins.
# 
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# 
#                               ~= Compatability =~
# 
# - Low probability of working with the SDK.
# - Will not work with other Poison-editing scripts.
# - Must be placed above Tons of Addons.
# 
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

module SL93
  
  def self.hotdot(id)
    case id
    #------------------------------------------------------------------------
    # Poison Database Begins
    #------------------------------------------------------------------------
    #  when STATE_NUMBER then return [TYPE, DAMAGE, VARIANCE, LIMIT_DRAIN]
    #  * STATE_NUMBER is the state you want to be affected by this.
    #  * TYPE refers to the thing sustaining damage.
    #      1 = HP, 2 = SP. If the type is positive, the amount is a literal
    #      number (eg. You lose about 50 HP). If the type is negative, then
    #      the amount is a fraction of the maximum (eg. You lose about 50% of
    #      your HP).
    #  * DAMAGE refers to how much damage is healed/taken.
    #      A Positive amount hurts you and a negative amount heals you.
    #  * VARIANCE refers to how much the damage varies. Positive only.
    #      This depends in part on if TYPE was positive or negative.
    #
    #      Example A: TYPE is positive. VARIANCE is 15.
    #                 Damage/Heal amount can do up to 15 more or 15 less.
    #
    #      Example B: TYPE is negative. VARIANCE is 15.
    #                 Damage/Heal amount can do up to 15% more or 15% less.
    #
    #  * LIMIT_DRAIN refers to if the poison can leave you with 0 HP/SP.
    #      If true, then it is limited, and stops at 1. If false, then it
    #      isn't.
    #------------------------------------------------------------------------
    when 6 then return [[-1, -10, 0, false], [-2, -5, 0, false]]
    #------------------------------------------------------------------------
    # Poison Database Ends
    #------------------------------------------------------------------------
    end
    return false
  end
  
end

class Game_Battler
  
  def slip_damage?
    return @states.any? { |i| SL93.hotdot(i) }
  end
  
  def slip_damage_effect
    ids = []
    hp_damage = 0
    sp_damage = 0
    self.damage = 0
    # Get the HoT/DoT states applied to the character
    @states.each { |i| ids << i if SL93.hotdot(i) }
    
    @states.each do |id|
      config = SL93.hotdot(id)
      next unless config
      
      config = [config] unless config.first.is_a?(Array)
      config.each do |state_data|
        # If the state damages/heals by a literal number
        if state_data[0] > 0
          damage = state_data[1]
        # If the state damages/heals HP by a percent
        elsif state_data[0] == -1
          damage = self.maxhp * state_data[1] / 100
        # If the state damages/heals SP by a percent
        elsif state_data[0] == -2
          damage = self.maxsp * state_data[1] / 100
        end
        
        # If damage/heal amount is not zero and variance exists
        if damage != 0 && state_data[2] > 0
          # Variance based on literal numbers
          amp = (damage.abs < state_data[2] ? damage.abs - 1 : state_data[2]) if state_data[0] > 0
          # Variance based on percentages
          amp = [damage.abs * state_data[2] / 100, 1].max if state_data[0] < 0
          # Apply variance amounts to damage/heal amount
          damage += rand(amp+1) + rand(amp+1) - amp
        end
        
        # If HP damage/heal
        if state_data[0].abs == 1
          hp = @hp
          # If limit_drain and actual HP damage being done (not healing)
          if state_data[3] and damage > 0
            self.hp = [hp - damage,1].max # Leave 1 HP
          else
            self.hp -= damage
          end
          # Add total damage to variable
          hp_damage += damage
        # If SP damage/heal
        elsif state_data[0].abs == 2
          sp = @sp
          # If limit_drain and actual SP damage being done (not healing)
          if state_data[3] and damage > 0
            self.sp = [sp - damage,1].max # Leave 1 SP
          else
            self.sp -= damage
          end
          # Add total SP damage to variable
          sp_damage += damage
        end
      end
    end
    
    self.damage = hp_damage
    # Modify @damage to be SP damage if no changes to HP were made
    self.damage = sp_damage if hp_damage == 0
  end
  
end

class Game_Party
  
  def check_map_slip_damage
    @actors.each do |actor|
      if actor.hp > 0 && actor.slip_damage?
        actor.slip_damage_effect
        if actor.damage <= 0
          # Positive DoT makes green screen
          $game_screen.start_flash(Color.new(0, 255, 0, 128), 4)
        else
          # Negative DoT makes red screen
          $game_screen.start_flash(Color.new(255, 0, 0, 128), 4)
        end
        $game_temp.gameover = $game_party.all_dead?
      end
    end
  end
  
end
 

MarioWidjaya123

Veteran
Veteran
Joined
May 16, 2020
Messages
187
Reaction score
6
First Language
English
Primarily Uses
RMXP
i tested it, and it did the trick. thanks.
btw, how do i have ATB bars in this post of mine?
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,090
Members
137,586
Latest member
Usagiis
Top