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.
 
Give me a bit, and I will throw something together.

The plan is, you tell what percents the state has like so:

Code:
class RPG::Skill
  # skill_id => { state_id => percnt, ... }
  Plus_State_Set = {}
end

From here, we alias our plus_state method in rpg skill class. After that, we just run through our states set in the database. If they have been reset in the Plus_State_Set hash, it uses the percents in there, otherwise it uses 100 as the percent. It will randomly choose which states to add on a perm. basis.

The problem with this is, every time you call plus_state_set, you will get something random. So we will need to use the caller method in module Kernel, so only do this when the we call it from skill_effect in Game_Battler. I have never used this before, so just give me until tomorrow to figure it out.
 
Didn't you used to be able to do that in RM2K/3? I remember each status effect had their own infliction chances based on the letter ranks A-E (A usually being 100% chance, E usually being 0% chance). RMXP seems to have taken that out. The element rank numbers are still there in the script (in Game_Actor and Game_Enemy, it has 200,150,100,etc. in brackets), but I can't find the ones for states...
 
now that you mention it im also having prob with the weapon state effect
i added the knockout state for my weapon so when i fight theres a low chance of 1 hit KOing my enemies
but instead its like a 80%-100% chance of 1 hit kills @_@

THANKS if someone made the script kaze950 wants







cuz i also want it :shifty01:
 
I don't have time to test this, but this should work. I could have used the caller function, but I am too lazy and just cheated and used this.

Code:
class RPG::Skill
  #   State_Percents = { skill_id => { state_id => prob, ... }, ... }
  State_Percents = {}
  alias_method :seph_skillstatepercents_rpgskl_pss, :plus_state_set
  def plus_state_set
    pss = seph_skillstatepercents_rpgskl_pss
    if $seph_skillstatepercents_is_battler
      if State_Percents.has_key?(@id)
        State_Percents[@id].each do |state_id, prob|
          if pss.include?(state_id)
            pss.delete(state_id) if rand(100) > prob
          end
        end
      end
    end
    return pss
  end
end

class Game_Battler
  alias_method :seph_skillstatepercents_gmbtlr_se, :skill_effect
  def skill_effect(*args)
    $seph_skillstatepercents_is_battler = true
    seph_skillstatepercents_gmbtlr_se(*args)
    $seph_skillstatepercents_is_battler = false
  end
end

Now just alter this:
Code:
  State_Percents = {}

With skill_id => { state_id => prob, ... }. If you are confused, give me your exact skill id, each state and the probability to add the state.
 
Hmm, it doesn't seem to work. If the skill doesn't add the state via the database, it won't add the state even if it says it should in the script. When I do this, skills that should have a 100% chance of inflicting a state have the default chance (60%). This is how my script is (80 and 81 are the same skill, an instant death one)

Code:
class RPG::Skill
  #   State_Percents = { skill_id => { state_id => prob, ... }, ... }
  State_Percents = {80 => {1 => 10}, 81 => {1 => 100}}
  alias_method :seph_skillstatepercents_rpgskl_pss, :plus_state_set
  def plus_state_set
    pss = seph_skillstatepercents_rpgskl_pss
    if $seph_skillstatepercents_is_battler
      if State_Percents.has_key?(@id)
        State_Percents[@id].each do |state_id, prob|
          if pss.include?(state_id)
            pss.delete(state_id) if rand(100) > prob
          end
        end
      end
    end
    return pss
  end
end

class Game_Battler
  alias_method :seph_skillstatepercents_gmbtlr_se, :skill_effect
  def skill_effect(*args)
    $seph_skillstatepercents_is_battler = true
    seph_skillstatepercents_gmbtlr_se(*args)
    $seph_skillstatepercents_is_battler = false
  end
end

Is it set up wrong or do I need another script or something?
 
I have fixed it so we if you set stats just with scripts, they don't have to be added in the database too.

However, this script just gives a percent to add the states with the skills. It doesn't modify the original addition of states using a percent.
 
Sorry, forgot to update it. Here you go. I haven't had time to comment it yet, so check in my test bed v.41 for the official release.

Code:
class RPG::Skill
  State_Percents = {}
  alias_method :seph_skillstatepercents_rpgskl_pss, :plus_state_set
  def plus_state_set
    pss = seph_skillstatepercents_rpgskl_pss
    if $seph_skillstatepercents_is_battler
      if State_Percents.has_key?(@id)
        State_Percents[@id].each do |state_id, prob|
          if pss.include?(state_id)
            pss.delete(state_id) if rand(100) > prob
            next
          end
          pss << state_id if prob < rand(100)
        end
      end
    end
    return pss
  end
end

class Game_Battler
  alias_method :seph_skillstatepercents_gmbtlr_se, :skill_effect
  def skill_effect(*args)
    $seph_skillstatepercents_is_battler = true
    seph_skillstatepercents_gmbtlr_se(*args)
    $seph_skillstatepercents_is_battler = false
  end
end

If you could, think you could do some beta testing for me? Let me know that the states aren't always in the skill's state array and such.
 
Code:
class RPG::Skill
  State_Percents = {80 => {1 => 10}, 81 => {1 => 100}}
  alias_method :seph_skillstatepercents_rpgskl_pss, :plus_state_set
  def plus_state_set
    pss = seph_skillstatepercents_rpgskl_pss
    if $seph_skillstatepercents_is_battler
      if State_Percents.has_key?(@id)
        State_Percents[@id].each do |state_id, prob|
          if pss.include?(state_id)
            pss.delete(state_id) if rand(100) > prob
            next
          end
          pss << state_id if prob < rand(100)
        end
      end
    end
    return pss
  end
end

class Game_Battler
  alias_method :seph_skillstatepercents_gmbtlr_se, :skill_effect
  def skill_effect(*args)
    $seph_skillstatepercents_is_battler = true
    seph_skillstatepercents_gmbtlr_se(*args)
    $seph_skillstatepercents_is_battler = false
  end
end

Hmm, I have it set up like that. But when I use skill 81, the knockout effect doesn't apply. I don't have the skill add knockout in the database, and I tested it with the enemies having C state efficiency and A state efficiency
 

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