Help with Victor's State Cancel's script

Hello. I'm using Victor's state cancel script and I'm having doubts about how to use the <cancel state custom> tags.

In concret, I'd like certain to remove a state when the battler is affected by any of certain states list (let's say, if the battler is affected by the state 4, 5, 6 or 7)

How is it possible to do that? Thank you
Moderator note: Moved it to it's right place, by OP's request. Deleted your duplicate post.
This post has similar information
https://forums.rpgmakerweb.com/inde...irement-states-as-resource.86616/#post-791371

Similar, yeah, but this is for MV, I'm using VX Ace
Ok, then
https://forums.rpgmakerweb.com/index.php?threads/yanflys-skill-cost-manager-custom-cost-help.19902/
@Roninator2 I have no idea how custom manager is relevant with state cancel

@S.Court I'm having trouble understanding your word
In short, if a battler affected by a state (say, state id 10), it will be removed if the battler is inflicted by any of state 4, 5, 6, or 7?
@TheoAllen Yes, that's what I want to do, sorry for the wrong wording
You could try

<cancel state custom>
$game_party.actor(actor id).state?(state id)
</cancel state customn>

That checks if a certain actor has certain state.

$game_party.leader.state?(state id)
That one checks if the party leader is inflicted with a certain state.

$game_party.members.any? { |m| m.state?(STATE_ID) }
This checks if any actor has a certain state.

BTW I think when it come party actors, the first acto in the party will be number 0, second will be 1 and so on.

Try those and see how it goes.
No need to include $game_party
Try this
Code:
<cancel state custom>
!(@states & [4,5,6,7]).empty?
</cancel state customn>
No need to include $game_party
Try this
Code:
<cancel state custom>
!(@states & [4,5,6,7]).empty?
</cancel state customn>

There is an oddity with this code, or maybe is how the states are put in the database

Well, the states I used as a testing are a Physical buff (with the state ID 5) and a Physical debuff (with the state ID 10) and I created the respective tags

When the character has the Physical buff and the Physical debuff is applied, it indeed works, but then the character has the Physical debuff and this Physical buff is applied, the buff is immediately and the debuff persists
Well, my tag wasn't mean to work in both ways.

If you want something like
State 5 added -> Remove state 10
State 10 added -> Remove state 5
Then something need to be changed

First, add a new patch (I just change the line order from default script), should be put above all custom scripts
Code:
class Game_Battler
  def add_state(state_id)
    if state_addable?(state_id)
      @result.added_states.push(state_id).uniq!
      add_new_state(state_id) unless state?(state_id)
      reset_state_counts(state_id)
    end
  end
end

And the tag will be like this (for example, state 5)
Code:
<cancel state custom>
@result.added_states.include?(10)
</cancel state custom>
So whenever state 10 is applied, state 5 will be removed. Tag goes the same with state 10
Well, my tag wasn't mean to work in both ways.

If you want something like
State 5 added -> Remove state 10
State 10 added -> Remove state 5
Then something need to be changed

First, add a new patch (I just change the line order from default script), should be put above all custom scripts
Code:
class Game_Battler
  def add_state(state_id)
    if state_addable?(state_id)
      @result.added_states.push(state_id).uniq!
      add_new_state(state_id) unless state?(state_id)
      reset_state_counts(state_id)
    end
  end
end

And the tag will be like this (for example, state 5)
Code:
<cancel state custom>
@result.added_states.include?(10)
</cancel state custom>
So whenever state 10 is applied, state 5 will be removed. Tag goes the same with state 10

Ugh, almost, the state 5 can replace state 10, but doesn't happen the same with state 10 replacing state 5

EDIT: Does this tag work with multiple states as well? For example, let's suppose state 5 can be removed with any of those state: 10, 31, 32, 33, 34
but doesn't happen the same with state 10 replacing state 5
You know where to edit, right?

Does this tag work with multiple states as well? For example, let's suppose state 5 can be removed with any of those state: 10, 31, 32, 33, 34
Hmm.... it should be something like this
Code:
<cancel state custom>
!(@result.added_states & [10, 31, 32, 33, 34]).empty?
</cancel state custom>
You know where to edit, right?

It'd be something like this, right?

For state 5:

Code:
<cancel state custom>
!(@result.added_states & [10, 31, 32, 33, 34, 35, 36]).empty?
</cancel state custom>

For state 10:

Code:
<cancel state custom>
@result.added_states.include?(5)
</cancel state custom>
True, and it still doesn't work?
True, and it still doesn't work?

For some reason, no, state 5 overwrites state 10 but state 10 doesn't overwrite state 5

If there's another way to make this with other script, I'd be glad to hear it. It doesn't have to be with Victor's script
If there's another way to make this with other script, I'd be glad to hear it. It doesn't have to be with Victor's script
You said it.

I made this script originally for my game. Where my character has two modes, offensive and defensive. Applying the state, remove the other one. So both can't be applied. I named this script "State Links"
Code:
class RPG::State
  attr_accessor :link_rem
  attr_accessor :link_add
 
  def load_link_states
    @link_rem = []
    @link_add = []
    note.split(/[\r\n]+/).each do |line|
      case line
      when /<link[\s_]+remove\s*:\s*(.+)>/i
        $1.to_s.split(/,/).each do |state|
          @link_rem.push(state.to_i)
        end
      when /<link[\s_]+add\s*:\s*(.+)>/i
        $1.to_s.split(/,/).each do |state|
          @link_add.push(state.to_i)
        end
      end
    end
  end
 
end

class << DataManager
 
  alias theo_state_link_load_db load_database
  def load_database
    theo_state_link_load_db
    $data_states.compact.each do |st|
      st.load_link_states
    end
  end
 
end

class Game_Battler
 
  alias theo_state_link_add_new_state add_new_state
  def add_new_state(state_id)
    theo_state_link_add_new_state(state_id)
    link_states(state_id)
  end
 
  def link_states(state_id)
    $data_states[state_id].link_rem.each do |stid|
      remove_state(stid)
    end
    $data_states[state_id].link_add.each do |stid|
      add_state(stid)
    end
  end
 
end
The usage would be putting notetag <link remove: 1,2,3,4>
If state 5 is applied, then state 10, 31, 32, 34 will be removed. The tag would be <link remove: 10,31,32,33,34>
If state 10 is applied, then state 5 will be removed. The tag would be <link remove: 5>
If state 1 is applied, it will also apply other states. The tag would be <link add: 2,3,4>

Tell me how it goes.

Edit: Also, is there any reason why you can't just use database for removing states and then add the new one?
Edit: Also, is there any reason why you can't just use database for removing states and then add the new one?

Uhhh how does it exactly work? I haven't tried it actually

I'll try the script right now
Screenshot_151.png

Something like this?

Ohhh like this. Well, the thing is the Debuff can be evaded, and that means the state removal and the state adding doesn't happen exactly at same time and that's exactly why I need.

Anyways, I tested your script and it works perfectly. Thank you. Is there any usage term for this script?

Original thread: https://forums.rpgmakerweb.com/threads/help-with-victors-state-cancels-script.92052/