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.

Changes to the status effect system

What I'm requesting is something that will benefit me and probably a lot of other users of RMXP. As it is now, with a skill, you can only make it add or subtract a status effect. The chance of a status effect being inflicted is based on the enemy. So, for example, if you wanted a skill that always does damage and might cause venom and a skill that always causes venom (unless enemy is immune) you couldn't do it unless you made two separate status effects.

I'm requesting a script that lets you determine the chance of a status effect being caused by the skill. I don't know much about scripting, but I imagine something like this - (x/enemy's state efficiency = chance of status inflicting).

So, if 'x' in the script was 50 (50% chance) and the enemy's state efficiency would be 100% (Always hits, if this script wasn't implemented), there would be a 50/100 chance of the state causing.

With this script, most monsters will have 100% state efficiency as you would determine the chance of a state inflicting based on the skill. The exception to this is enemies that are immune to states. This script will need to check so that if the formula works out to 100/0 (I don't think you can have anything divided by 0, though), the state will never be inflicted. However, the damage from the attack (if there is any) will be inflicted.
 
I evolved this script a bit in the last week.

Code:
#==============================================================================
# ** Skill & Equipment - State & Element Percents
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1
# 2007-08-10
# SDK : Version 2.0+ - Parts I
#------------------------------------------------------------------------------
# * Version History :
#
#   Version 1 ---------------------------------------------------- (2007-08-10)
#------------------------------------------------------------------------------
# * Description :
#
#   This script was designed to allow you to set percents that states and
#   elements will be added to your equipment and skills. If you specify a state
#   or element in the database, it automatically gives you that state or 
#   element 100% of the time. With this, you can make it so those states 
#   aren't always added.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#------------------------------------------------------------------------------
# * Customization :
#
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Skill & Equipment State & Element Percents', 'SephirothSpawn', 1, 
  '2007-08-10')
SDK.check_requirements(2.0)

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.enabled?('Skill & Equipment State & Element Percents')

#==============================================================================
# ** SESEPercents
#==============================================================================

module SESEPercents
  #--------------------------------------------------------------------------
  # * Percent Settings
  #--------------------------------------------------------------------------
  Skill_Element_Set       = {}
  Skill_Plus_State_Set    = {}
  Skill_Minus_State_Set   = {}
  Weapon_Element_Set      = {}
  Weapon_Plus_State_set   = {}
  Weapon_Minus_State_Set  = {}
  Armor_Guard_Element_Set = {}
  Armor_Guard_State_Set   = {}
  # Set Blank Defaults - Do Not Delete
  for constant in [Skill_Element_Set, Skill_Plus_State_Set, 
    Skill_Minus_State_Set, Weapon_Element_Set, Weapon_Plus_State_set,
    Weapon_Minus_State_Set, Armor_Guard_Element_Set, Armor_Guard_State_Set]
    constant.default = {}
  end
  #--------------------------------------------------------------------------
  # * Generate List Percents
  #--------------------------------------------------------------------------
  def self.generate_percent_list(default_list, constant)
    # Starts List
    list = {}
    # Pass Through Constant List
    constant.each {|id, p| list[id] = p}
    # Pass Through Default List
    for id in default_list
      next if list.has_key?(id)
      list[id] = 100
    end
    # Return List
    return list
  end
  #--------------------------------------------------------------------------
  # * Generate List
  #--------------------------------------------------------------------------
  def self.generate_list(percent_list, default_list)
    # If Sese On
    if $seph_sesepercents_on
      # Generate List
      list = []
      # Pass Through Percent List
      percent_list.each do |id, prob|
        # Add Id to List
        list << id if rand(100) < prob
      end
      # Return List
      return lise
    end
    # Return Default List
    return default_list
  end
end

#==============================================================================
# ** RPG::Skill
#==============================================================================

class RPG::Skill
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_sesepercents_rpgskl_es,  :element_set
  alias_method :seph_sesepercents_rpgskl_pss, :plus_state_set
  alias_method :seph_sesepercents_rpgskl_mss, :minus_state_set
  #--------------------------------------------------------------------------
  # * Element Set Percents
  #--------------------------------------------------------------------------
  def element_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgskl_es, 
      SESEPercents::Skill_Element_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Plus State Set Percents
  #--------------------------------------------------------------------------
  def plus_state_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgskl_pss, 
      SESEPercents::Skill_Plus_State_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Minus State Set Percents
  #--------------------------------------------------------------------------
  def minus_state_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgskl_mss, 
      SESEPercents::Skill_Minus_State_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Element Set
  #--------------------------------------------------------------------------
  def element_set
    return SESEPercents.generate_list(element_set_percents, 
      seph_sesepercents_rpgskl_es)
  end
  #--------------------------------------------------------------------------
  # * Plus State Set
  #--------------------------------------------------------------------------
  def plus_state_set
    return SESEPercents.generate_list(plus_state_set_percents, 
      seph_sesepercents_rpgskl_pss)
  end
  #--------------------------------------------------------------------------
  # * Minus State Set
  #--------------------------------------------------------------------------
  def minus_state_set
    return SESEPercents.generate_list(minus_state_set_percents, 
      seph_sesepercents_rpgskl_mss)
  end
end

#==============================================================================
# ** RPG::Weapon
#==============================================================================

class RPG::Weapon
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_sesepercents_rpgwpn_es,  :element_set
  alias_method :seph_sesepercents_rpgwpn_pss, :plus_state_set
  alias_method :seph_sesepercents_rpgwpn_mss, :minus_state_set
  #--------------------------------------------------------------------------
  # * Element Set Percents
  #--------------------------------------------------------------------------
  def element_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgwpn_es, 
      SESEPercents::Weapon_Element_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Plus State Set Percents
  #--------------------------------------------------------------------------
  def plus_state_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgwpn_pss, 
      SESEPercents::Weapon_Plus_State_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Minus State Set Percents
  #--------------------------------------------------------------------------
  def minus_state_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgwpn_mss, 
      SESEPercents::Weapon_Minus_State_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Element Set
  #--------------------------------------------------------------------------
  def element_set
    return SESEPercents.generate_list(element_set_percents, 
      seph_sesepercents_rpgwpn_es)
  end
  #--------------------------------------------------------------------------
  # * Plus State Set
  #--------------------------------------------------------------------------
  def plus_state_set
    return SESEPercents.generate_list(plus_state_set_percents, 
      seph_sesepercents_rpgwpn_pss)
  end
  #--------------------------------------------------------------------------
  # * Minus State Set
  #--------------------------------------------------------------------------
  def minus_state_set
    return SESEPercents.generate_list(minus_state_set_percents, 
      seph_sesepercents_rpgwpn_mss)
  end
end

#==============================================================================
# ** RPG::Armor
#==============================================================================

class RPG::Armor
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_sesepercents_rpgarm_ges, :guard_element_set
  alias_method :seph_sesepercents_rpgarm_gss, :guard_state_set
  #--------------------------------------------------------------------------
  # * Guard Element Set Percents
  #--------------------------------------------------------------------------
  def guard_element_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgarm_ges, 
      SESEPercents::Armor_Guard_Element_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Guard State Set Percents
  #--------------------------------------------------------------------------
  def guard_state_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgarm_gss, 
      SESEPercents::Armor_Guard_State_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Guard Element Set
  #--------------------------------------------------------------------------
  def guard_element_set
    return SESEPercents.generate_list(guard_element_set_percents, 
      seph_sesepercents_rpgarm_ges)
  end
  #--------------------------------------------------------------------------
  # * Guard State Set
  #--------------------------------------------------------------------------
  def guard_state_set
    return SESEPercents.generate_list(guard_state_set_percents, 
      seph_sesepercents_rpgarm_gss)
  end
end

#==============================================================================
# ** Game_Battler
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_skillstatepercents_gmbtlr_ae, :attack_effect
  alias_method :seph_skillstatepercents_gmbtlr_se, :skill_effect
  #--------------------------------------------------------------------------
  # * Attack Effect
  #--------------------------------------------------------------------------
  def attack_effect(*args)
    # Turn Sese On
    $seph_sesepercents_on = true
    # Gets Skill Effect Result
    result = seph_skillstatepercents_gmbtlr_ae(*args)
    # Turn Sese Off
    $seph_sesepercents_on = false
    # Return Result
    return result
  end
  #--------------------------------------------------------------------------
  # * Skill Effect
  #--------------------------------------------------------------------------
  def skill_effect(*args)
    # Turn Sese On
    $seph_sesepercents_on = true
    # Gets Skill Effect Result
    result = seph_skillstatepercents_gmbtlr_se(*args)
    # Turn Sese Off
    $seph_sesepercents_on = false
    # Return Result
    return result
  end
end
 
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end

Let me know if anything doesn't work.
 
What exactly are the options for?

Like, if I wanted to make skill 1 add state 10 with a 25% chance, where would I put it.

And does this script need the SDK, or will it work without it?

_____

I got an error on this bolded part of code

Code:
  #--------------------------------------------------------------------------
  # * Generate List
  #--------------------------------------------------------------------------
  def self.generate_list(percent_list, default_list)
    # If Sese On
    if $seph_sesepercents_on
      # Generate List
      list = []
      # Pass Through Percent List
      percent_list.each do |id, prob|
        # Add Id to List
        list << id if rand(100) < prob
      end
      # Return List
      [b]return lise[/b]
    end
    # Return Default List
    return default_list
  end
end

I downloaded the SDK, and put it above this script, but I still get the error.
 
Excellent, this seems to work without being reliant on SDK as well.

Are the "Set Element" things for like a skill that, lets say 50% of the time will have the "fire element"?

And do I have to set the states in the database anywhere? Or does this script simply overwrite them?

EDIT: I think I get it. If you want the state to be added solely by the skill's percentage, you just give enemies an 'A' for the state. Then, if you want enemies with furthur protection or bosses, you can set the values and it will give them like double protection. For example, if Poison has a 40% chance of poisoning and the enemy has a 'C' state efficiency against it, it has a 4/10 chance, than a 6/10 chance? However, if the enemy has an 'A' ranking, it will just be a 4/10 chance?

And for the weapons and armors, I assume they work the same way. Like, if you do a normal attack with a weapon, you can make it inflict a state xx% of the time? Except, with armors, it protects against it xx% of the time.

I think I understand this now. Thanks

EDIT 2: Nvm, I guess this requires SDK. rats. Does anyone have a link to the current one? The SDK thread seems to have version 2.3 or something...or is that the newest one?

EDIT 3: I added SDK 2.3, but I still get the same error

Code:
  #--------------------------------------------------------------------------
  # * Plus State Set Percents
  #--------------------------------------------------------------------------
  def plus_state_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgwpn_pss, 
      SESEPercents::Weapon_Plus_State_Set[@id])
  end
 
It doesn't require the SDK, i just always use SDK logging. Any script that only requires part I of the SDK, which anyone and everyone can have in their project without any script conflict, will more than likely not need the SDK unless they use SDK tools such as the SDK module.

All this does is set's a percent that a weapon/skill will have an element/state attached to it when used. That's it. It has nothing to do with further percents of inflicting a state/element. Just a percent of using it. If you set something in the database, the default percent is 100. So unless you redefine a percent in one of the constants, it will added 100 percent of the time.

The current SDK version is 2.3, so the one in the thread is the one you need.

I will look into the code a little further and check to make sure I didn't leave any bugs. I just converted it at the last second to SE & SE from what you requested, so a lot of copy and paste might have left some spelling mistakes.
 
Okay. Do you know what could of caused that error? It said "unititalized constant" for line 167

Code:
      SESEPercents::Weapon_Plus_State_Set[@id])

I don't have anything for the Weapon_Plus_State_Set, so I don't know why its having an error. The error seems to occur whenever I attack.
 
Well, once its all fixed, you just add stuff like this.

For example, if you wanted skill 5 to have a 20% chance to inflict state 2, you would do this

Code:
  Skill_Plus_State_Set    = {[b]5 => {2 => 20}[/b]}
 
Here it is if I don't get to post the V.41 tonight.

Code:
#==============================================================================
# ** Skill & Equipment - State & Element Percents
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1
# 2007-08-10
# SDK : Version 2.0+ - Parts I
#------------------------------------------------------------------------------
# * Version History :
#
#   Version 1 ---------------------------------------------------- (2007-08-10)
#------------------------------------------------------------------------------
# * Description :
#
#   This script was designed to allow you to set percents that states and
#   elements will be added to your equipment and skills. If you specify a state
#   or element in the database, it automatically gives you that state or 
#   element 100% of the time. With this, you can make it so those states 
#   aren't always added.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#------------------------------------------------------------------------------
# * Customization :
#
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Skill & Equipment - State & Element Percents', 'SephirothSpawn', 1, 
  '2007-08-10')
SDK.check_requirements(2.0)

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.enabled?('Skill & Equipment - State & Element Percents')

#==============================================================================
# ** SESEPercents
#==============================================================================

module SESEPercents
  #--------------------------------------------------------------------------
  # * Percent Settings
  #--------------------------------------------------------------------------
  Skill_Element_Set       = {}
  Skill_Plus_State_Set    = {}
  Skill_Minus_State_Set   = {}
  Weapon_Element_Set      = {}
  Weapon_Plus_State_Set   = {}
  Weapon_Minus_State_Set  = {}
  Armor_Guard_Element_Set = {}
  Armor_Guard_State_Set   = {}
  # Set Blank Defaults - Do Not Delete
  for constant in [Skill_Element_Set, Skill_Plus_State_Set, 
    Skill_Minus_State_Set, Weapon_Element_Set, Weapon_Plus_State_Set,
    Weapon_Minus_State_Set, Armor_Guard_Element_Set, Armor_Guard_State_Set]
    constant.default = {}
  end
  #--------------------------------------------------------------------------
  # * Generate List Percents
  #--------------------------------------------------------------------------
  def self.generate_percent_list(default_list, constant)
    # Starts List
    list = {}
    # Pass Through Constant List
    constant.each {|id, p| list[id] = p}
    # Pass Through Default List
    for id in default_list
      next if list.has_key?(id)
      list[id] = 100
    end
    # Return List
    return list
  end
  #--------------------------------------------------------------------------
  # * Generate List
  #--------------------------------------------------------------------------
  def self.generate_list(percent_list, default_list)
    # If Sese On
    if $seph_sesepercents_on
      # Generate List
      list = []
      # Pass Through Percent List
      percent_list.each do |id, prob|
        # Add Id to List
        list << id if rand(100) < prob
      end
      # Return List
      return list
    end
    # Return Default List
    return default_list
  end
end

#==============================================================================
# ** RPG::Skill
#==============================================================================

class RPG::Skill
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_sesepercents_rpgskl_es,  :element_set
  alias_method :seph_sesepercents_rpgskl_pss, :plus_state_set
  alias_method :seph_sesepercents_rpgskl_mss, :minus_state_set
  #--------------------------------------------------------------------------
  # * Element Set Percents
  #--------------------------------------------------------------------------
  def element_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgskl_es, 
      SESEPercents::Skill_Element_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Plus State Set Percents
  #--------------------------------------------------------------------------
  def plus_state_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgskl_pss, 
      SESEPercents::Skill_Plus_State_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Minus State Set Percents
  #--------------------------------------------------------------------------
  def minus_state_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgskl_mss, 
      SESEPercents::Skill_Minus_State_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Element Set
  #--------------------------------------------------------------------------
  def element_set
    return SESEPercents.generate_list(element_set_percents, 
      seph_sesepercents_rpgskl_es)
  end
  #--------------------------------------------------------------------------
  # * Plus State Set
  #--------------------------------------------------------------------------
  def plus_state_set
    return SESEPercents.generate_list(plus_state_set_percents, 
      seph_sesepercents_rpgskl_pss)
  end
  #--------------------------------------------------------------------------
  # * Minus State Set
  #--------------------------------------------------------------------------
  def minus_state_set
    return SESEPercents.generate_list(minus_state_set_percents, 
      seph_sesepercents_rpgskl_mss)
  end
end

#==============================================================================
# ** RPG::Weapon
#==============================================================================

class RPG::Weapon
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_sesepercents_rpgwpn_es,  :element_set
  alias_method :seph_sesepercents_rpgwpn_pss, :plus_state_set
  alias_method :seph_sesepercents_rpgwpn_mss, :minus_state_set
  #--------------------------------------------------------------------------
  # * Element Set Percents
  #--------------------------------------------------------------------------
  def element_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgwpn_es, 
      SESEPercents::Weapon_Element_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Plus State Set Percents
  #--------------------------------------------------------------------------
  def plus_state_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgwpn_pss, 
      SESEPercents::Weapon_Plus_State_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Minus State Set Percents
  #--------------------------------------------------------------------------
  def minus_state_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgwpn_mss, 
      SESEPercents::Weapon_Minus_State_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Element Set
  #--------------------------------------------------------------------------
  def element_set
    return SESEPercents.generate_list(element_set_percents, 
      seph_sesepercents_rpgwpn_es)
  end
  #--------------------------------------------------------------------------
  # * Plus State Set
  #--------------------------------------------------------------------------
  def plus_state_set
    return SESEPercents.generate_list(plus_state_set_percents, 
      seph_sesepercents_rpgwpn_pss)
  end
  #--------------------------------------------------------------------------
  # * Minus State Set
  #--------------------------------------------------------------------------
  def minus_state_set
    return SESEPercents.generate_list(minus_state_set_percents, 
      seph_sesepercents_rpgwpn_mss)
  end
end

#==============================================================================
# ** RPG::Armor
#==============================================================================

class RPG::Armor
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_sesepercents_rpgarm_ges, :guard_element_set
  alias_method :seph_sesepercents_rpgarm_gss, :guard_state_set
  #--------------------------------------------------------------------------
  # * Guard Element Set Percents
  #--------------------------------------------------------------------------
  def guard_element_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgarm_ges, 
      SESEPercents::Armor_Guard_Element_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Guard State Set Percents
  #--------------------------------------------------------------------------
  def guard_state_set_percents
    return SESEPercents.generate_percent_list(seph_sesepercents_rpgarm_gss, 
      SESEPercents::Armor_Guard_State_Set[@id])
  end
  #--------------------------------------------------------------------------
  # * Guard Element Set
  #--------------------------------------------------------------------------
  def guard_element_set
    return SESEPercents.generate_list(guard_element_set_percents, 
      seph_sesepercents_rpgarm_ges)
  end
  #--------------------------------------------------------------------------
  # * Guard State Set
  #--------------------------------------------------------------------------
  def guard_state_set
    return SESEPercents.generate_list(guard_state_set_percents, 
      seph_sesepercents_rpgarm_gss)
  end
end

#==============================================================================
# ** Game_Battler
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_skillstatepercents_gmbtlr_ae, :attack_effect
  alias_method :seph_skillstatepercents_gmbtlr_se, :skill_effect
  #--------------------------------------------------------------------------
  # * Attack Effect
  #--------------------------------------------------------------------------
  def attack_effect(*args)
    # Turn Sese On
    $seph_sesepercents_on = true
    # Gets Skill Effect Result
    result = seph_skillstatepercents_gmbtlr_ae(*args)
    # Turn Sese Off
    $seph_sesepercents_on = false
    # Return Result
    return result
  end
  #--------------------------------------------------------------------------
  # * Skill Effect
  #--------------------------------------------------------------------------
  def skill_effect(*args)
    # Turn Sese On
    $seph_sesepercents_on = true
    # Gets Skill Effect Result
    result = seph_skillstatepercents_gmbtlr_se(*args)
    # Turn Sese Off
    $seph_sesepercents_on = false
    # Return Result
    return result
  end
end
 
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end

Let me know if there are any problems with it.
 
It seems to work perfectly. When I set an enemy to anything but 'F' for state efficiency, it will go by the percentage in this script but when 'F' is selected, they will be immune to it regardless.


Wonderful ^_^

One suggestion would be to add how to use it in the comments section, to avoid people asking questions.
 

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