Help with Victor's State Cancel's script

Discussion in 'RGSSx Script Support' started by S.Court, Mar 1, 2018.

Thread Status:
Not open for further replies.
  1. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    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: Mar 1, 2018
    #1
  2. Dreadshadow

    Dreadshadow Lv 38 Tech Magician Moderator

    Messages:
    3,835
    Likes Received:
    2,480
    First Language:
    Greek
    Primarily Uses:
    RMMV

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

     
    #2
  3. Roninator2

    Roninator2 Gamer Veteran

    Messages:
    1,635
    Likes Received:
    362
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
  4. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    #4
  5. Roninator2

    Roninator2 Gamer Veteran

    Messages:
    1,635
    Likes Received:
    362
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
  6. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,278
    Likes Received:
    4,797
    Location:
    Riftverse
    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?
     
    #6
  7. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    @TheoAllen Yes, that's what I want to do, sorry for the wrong wording
     
    #7
  8. Mawichan

    Mawichan Veteran Veteran

    Messages:
    55
    Likes Received:
    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.
     
    #8
  9. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,278
    Likes Received:
    4,797
    Location:
    Riftverse
    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>
     
    #9
  10. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    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
     
    #10
  11. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,278
    Likes Received:
    4,797
    Location:
    Riftverse
    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
     
    #11
    S.Court likes this.
  12. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    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
     
    #12
  13. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,278
    Likes Received:
    4,797
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    You know where to edit, right?

    Hmm.... it should be something like this
    Code:
    <cancel state custom>
    !(@result.added_states & [10, 31, 32, 33, 34]).empty?
    </cancel state custom>
    
     
    #13
    S.Court likes this.
  14. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    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>
     
    #14
  15. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,278
    Likes Received:
    4,797
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    True, and it still doesn't work?
     
    #15
  16. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    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
     
    #16
  17. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,278
    Likes Received:
    4,797
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    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?
     
    #17
    S.Court likes this.
  18. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    Uhhh how does it exactly work? I haven't tried it actually

    I'll try the script right now
     
    #18
  19. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,278
    Likes Received:
    4,797
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    Screenshot_151.png
    Something like this?
     
    #19
  20. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    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?
     
    #20
Thread Status:
Not open for further replies.

Share This Page