Help with Victor's State Cancel's script

Status
Not open for further replies.

S.Court

Veteran
Veteran
Joined
Oct 17, 2012
Messages
394
Reaction score
98
First Language
Español
Primarily Uses
RMVXA
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
 
Last edited:

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ

Moved it to it's right place, by OP's request. Deleted your duplicate post.

 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,594
Reaction score
6,525
First Language
Indonesian
Primarily Uses
RMVXA
@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?
 

S.Court

Veteran
Veteran
Joined
Oct 17, 2012
Messages
394
Reaction score
98
First Language
Español
Primarily Uses
RMVXA
@TheoAllen Yes, that's what I want to do, sorry for the wrong wording
 

Mawichan

Veteran
Veteran
Joined
Jan 24, 2018
Messages
55
Reaction score
6
First Language
Spanish
Primarily Uses
RMVXA
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.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,594
Reaction score
6,525
First Language
Indonesian
Primarily Uses
RMVXA
No need to include $game_party
Try this
Code:
<cancel state custom>
!(@states & [4,5,6,7]).empty?
</cancel state customn>
 

S.Court

Veteran
Veteran
Joined
Oct 17, 2012
Messages
394
Reaction score
98
First Language
Español
Primarily Uses
RMVXA
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
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,594
Reaction score
6,525
First Language
Indonesian
Primarily Uses
RMVXA
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
 

S.Court

Veteran
Veteran
Joined
Oct 17, 2012
Messages
394
Reaction score
98
First Language
Español
Primarily Uses
RMVXA
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
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,594
Reaction score
6,525
First Language
Indonesian
Primarily Uses
RMVXA
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>
 

S.Court

Veteran
Veteran
Joined
Oct 17, 2012
Messages
394
Reaction score
98
First Language
Español
Primarily Uses
RMVXA
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>
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,594
Reaction score
6,525
First Language
Indonesian
Primarily Uses
RMVXA
True, and it still doesn't work?
 

S.Court

Veteran
Veteran
Joined
Oct 17, 2012
Messages
394
Reaction score
98
First Language
Español
Primarily Uses
RMVXA
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
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,594
Reaction score
6,525
First Language
Indonesian
Primarily Uses
RMVXA
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?
 

S.Court

Veteran
Veteran
Joined
Oct 17, 2012
Messages
394
Reaction score
98
First Language
Español
Primarily Uses
RMVXA
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
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,594
Reaction score
6,525
First Language
Indonesian
Primarily Uses
RMVXA
Screenshot_151.png
Something like this?
 

S.Court

Veteran
Veteran
Joined
Oct 17, 2012
Messages
394
Reaction score
98
First Language
Español
Primarily Uses
RMVXA
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?
 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

Are we allowed to post about non-RPG Maker games? And, if so, would any of you be interested in a short, proof of concept type non-euclidian puzzle game?
I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:

Forum statistics

Threads
105,883
Messages
1,017,232
Members
137,607
Latest member
Maddo
Top