[RMXP] If a status is applied to an ally with an incompatible status (i.e. both statuses are set to remove the other), keep the old, previous status?

level2janitor

Regular
Regular
Joined
Feb 8, 2018
Messages
68
Reaction score
15
First Language
English
Primarily Uses
RMMV
I have a project where (due to the limitations of RPGmaker XP showing only one status at a time), I want to ensure only one status can be applied to a given character at any time so information isn't hidden from the player. So all statuses are generally set to either remove each other or be replaced by a higher-rated status.

However, this means it's very easy to remove a status just by applying a new one and I want to make that harder to do - so by default, I'd like to make new statuses unable to be applied when someone is already afflicted with a status. As-is, it looks like statuses overwrite each other and I can't find a way to undo that.

Alternatively, if there's a script that can make multiple statuses show per character (such as alternating every second between which status is shown), that would work fantastic as well.
 

AkiraKotatsuhime

炬燵姫
Regular
Joined
Jan 2, 2013
Messages
299
Reaction score
208
First Language
DE / ドイツ語
Primarily Uses
N/A
This simplified re-define of Game_Battler#add_state should do it, state-inflicts should be refused if there's already one. Please also test if knockout is still working properly since states with ZeroHP-setting still have to overwrite any state that was previously there instead.

Ruby:
#==============================================================================
# ** Limit Battler States to 1
#------------------------------------------------------------------------------
#  All incoming states will be blocked if there is already one.
#  Applying a ZeroHP-state (like Knockout) will vaporize previous state.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Add State
  #--------------------------------------------------------------------------
  def add_state(si, sf=false)
    return unless $data_states[si]
    unless sf
      @states.each do |i|
        next unless $data_states[i].minus_state_set.include?(si)
        return unless $data_states[si].minus_state_set.include?(i)
      end
    end
    unless state?(si)
      return unless @states.empty? || $data_states[si].zero_hp
      @states.clear
      @states_turn.clear
      @states.push(si)
      @hp = 0 if $data_states[si].zero_hp
    end
    @states_turn[si] = -1 if sf
    unless @states_turn[si] == -1
      @states_turn[si] = $data_states[si].hold_turn
    end
    @current_action.clear unless movable?
    @hp = [@hp, maxhp].min
    @sp = [@sp, maxsp].min
  end
end

~炬燵あ
 
Last edited:

level2janitor

Regular
Regular
Joined
Feb 8, 2018
Messages
68
Reaction score
15
First Language
English
Primarily Uses
RMMV
Unfortunately it crashed and gave me this error when a second status was applied:
1681126463352.png
 

AkiraKotatsuhime

炬燵姫
Regular
Joined
Jan 2, 2013
Messages
299
Reaction score
208
First Language
DE / ドイツ語
Primarily Uses
N/A
Oups. I accidentally did a wrong type of iteration there, it's "each", not "each_index".

~炬燵あ
 

level2janitor

Regular
Regular
Joined
Feb 8, 2018
Messages
68
Reaction score
15
First Language
English
Primarily Uses
RMMV
It's working great now, thank you!
 

level2janitor

Regular
Regular
Joined
Feb 8, 2018
Messages
68
Reaction score
15
First Language
English
Primarily Uses
RMMV
Would it be alright if I could ask you to add in an exception for states with a rating of 0? I only realized after I asked for this script that this would interrupt a lot of hidden states I use for eventing that the player doesn't see.
 

AkiraKotatsuhime

炬燵姫
Regular
Joined
Jan 2, 2013
Messages
299
Reaction score
208
First Language
DE / ドイツ語
Primarily Uses
N/A
Would it be alright if I could ask you to add in an exception for states with a rating of 0? I only realized after I asked for this script that this would interrupt a lot of hidden states I use for eventing that the player doesn't see.
Late answer because I didn't see it before. This might do it, I'm not fully sure about.

Ruby:
#==============================================================================
# ** Limit Battler States to 1 (Zero Exceptor Edition)
#------------------------------------------------------------------------------
#  All incoming states will be blocked if there is already one.
#  Applying a ZeroHP-state (like Knockout) will vaporize previous state.
#  Invisible states (those with rating set to 0) will not block anything.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Add State
  #--------------------------------------------------------------------------
  def add_state(si, sf=false)
    return unless $data_states[si]
    unless sf || $data_states[si].rating == 0
      @states.each do |i|
        next unless $data_states[i].minus_state_set.include?(si)
        return unless $data_states[si].minus_state_set.include?(i)
      end
    end
    unless state?(si)
      unless $data_states[si].zero_hp
        if $data_states[si].rating > 0
          return if @states.any? {|i| $data_states[i].rating > 0 }
        end
        @states.dup.each do |i|
          next if $data_states[i].rating == 0
          @states.delete(i)
          @states_turn.delete(i)
        end
      else
        @states.clear
        @states_turn.clear
      end
      @states.push(si)
      @hp = 0 if $data_states[si].zero_hp
    end
    @states_turn[si] = -1 if sf
    unless @states_turn[si] == -1
      @states_turn[si] = $data_states[si].hold_turn
    end
    @current_action.clear unless movable?
    @hp = [@hp, maxhp].min
    @sp = [@sp, maxsp].min
  end
end

~炬燵あ
 
Last edited:

level2janitor

Regular
Regular
Joined
Feb 8, 2018
Messages
68
Reaction score
15
First Language
English
Primarily Uses
RMMV
Oh, thank you! I notice it just mentions 0-rating statuses won't block anything; do they still get blocked if the target already has a status?
 

AkiraKotatsuhime

炬燵姫
Regular
Joined
Jan 2, 2013
Messages
299
Reaction score
208
First Language
DE / ドイツ語
Primarily Uses
N/A
Seems I had forgotten to properly add that case.

Have added a condition that only will reject a new state if not only any of states present has rating 1 or above, but also the new one. So inflicting something with rating 0 should be fine now.

A state with ZeroHP like [Knockout] will still wipe everything what's there, but theoretically it might not prevent inflicts of new rating-0-states while the character is knocked out.

~炬燵あ
 

Latest Threads

Latest Posts

Latest Profile Posts

I've made a big emphasis on visually representing things to make the game as accessible as possible.

MP.png

Grimoires will consist of 5 - 10 pages of skills (still finalizing that max number)

Since each actor is able to take multiple actions per turn, each skill will cost 1-5 pages
This prevents more powerful skills from being uber spammed during an actors turn.
Cats are so easy. I noticed the gray one would never nap in the office while I worked, so I put a blanket on the spare chair in here and now she won't leave.
1701793108356.png
still work in progress, had not much time at the weekend^^
Oh deer! Have you checked my calendar today already? ;3
1701790624587.png
Whenever the site tells me this, I feel like it's being intentionally antagonistic. Like, just freaking round down!

1701784620294.png

Forum statistics

Threads
136,765
Messages
1,269,682
Members
180,510
Latest member
Nillaw
Top