RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Add an Exception to a Script

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 83
I'm probably going make this seem like a lot more trouble than it actually is, but here goes nothing...

I'm trying to create a Skill that puts the user into a positive state called "Charged," which doubles the user's SPI.  My intention is to make the "Charged" state last only for 1 turn.  (Release conditions: After 1 turn, 100% chance.)  Therefore, you use the Skill to put the user into the "Charged" state to double their SPI and then on the next turn, after they take another action, the state will go away.

The Skill/State works perfectly except for when the player uses the skill two times in a row.  The game sees that the user is already in the Charged state and blocks the skill's effect, and then the user loses their Charged state immediately afterward.  I tried to cancel the existing Charged state when you use the skill for the second time (using the "States to Cancel" option and selecting "Charged"), but that too denies the user another turn in the Charged state.

I looked into the Game_Battler script to check out how the game handles changing states.  If these are the correct lines of coding, the script calls for the addition of states first and then the removal of them.

(Lines 94-113)
Spoiler for:
  #--------------------------------------------------------------------------
  # * Get the states that were added due to the previous action
  #--------------------------------------------------------------------------
  def added_states
    result = []
    for i in @added_states
      result.push($data_states)
    end
    return result
  end
If I'm right, this is what is preventing the "States to Cancel" option from working the way I want it to.  What do I need to do to make my "Changed" state bypass this?


EDIT:
Okay, so after looking at it some more I'm pretty sure I got the location in the Game_Battler script wrong.  Here's where I think the problem is now:

431-447
Spoiler for:
  #--------------------------------------------------------------------------
  # * Determine if it is a state that should be offset
  #     state_id : state ID
  #    Returns true when the following conditions are fulfilled.
  #     * The [Offset by Opp.] option is enabled for the new state.
  #     * The [States to Cancel] list of the new state to be added
  #       contains at least one of the current states.
  #    This would apply when, for example, ATK up is applied while ATK down
  #    is already in effect.
  #--------------------------------------------------------------------------
  def state_offset?(state_id)
    return false unless $data_states[state_id].offset_by_opposite
    for i in @states
      return true if $data_states[state_id].state_set.include?(i)
    end
    return false
  end
464-502
Spoiler for:
  #--------------------------------------------------------------------------
  # * Add State
  #     state_id : state ID
  #--------------------------------------------------------------------------
  def add_state(state_id)
    state = $data_states[state_id]        # Get state data
    return if state == nil                # Is data invalid?
    return if state_ignore?(state_id)     # Is it a state should be ignored?
    unless state?(state_id)               # Is this state not added?
      unless state_offset?(state_id)      # Is it a state should be offset?
        @states.push(state_id)            # Add the ID to the @states array
      end
      if state_id == 1                    # If it is incapacitated (state 1)
        @hp = 0                           # Change HP to 0
      end
      unless inputable?                   # If the character cannot act
        @action.clear                     # Clear battle actions
      end
      for i in state.state_set            # Take the [States to Cancel]
        remove_state(i)                   # And actually remove them
        @removed_states.delete(i)         # It will not be displayed
      end
      sort_states                         # Sort states with priority
    end
    @state_turns[state_id] = state.hold_turn    # Set the number of turns
  end
  #--------------------------------------------------------------------------
  # * Remove State
  #     state_id : state ID
  #--------------------------------------------------------------------------
  def remove_state(state_id)
    return unless state?(state_id)        # Is this state not added?
    if state_id == 1 and @hp == 0         # If it is incapacitated (state 1)
      @hp = 1                             # Change HP to 1
    end
    unless state_id == 20
    @states.delete(state_id)              # Remove the ID from the @states
    @state_turns.delete(state_id)         # Remove from the @state_turns
  end
« Last Edit: July 19, 2009, 08:29:01 AM by chronofreak »

********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
Hmmm... I'm just a lowly eventer and I know not how to fix this with scipts, but if you wanted a quick event fix, it seems like the only issue is that you can cast the same spell again when the state is affected already on yourself. This solution probably won't work depending on your situation, or maybe it will work if this happens to fit the bill. Either way, in the troops tab, set conditionals so that if your player is affected by the state, then that spell is removed (unlearned). Else would be that you learn the skill again. So essentially, while the state is affecting you, you can't cast the spell again because you don't actually know it at the time. I haven't tested it. Sounds good in my head.

**
Rep: +0/-0Level 83
...Mm, I'm not sure that'll work.  The issue isn't my not being able to use the spell while my character is in the state; I can use the spell whenever I want.  The problem is that the spell doesn't have an effect the second time in a row that I cast it.  The "new" state is denied because my character is already in that state, and then the "old" state expires after the failed move.  Sorry in advance if I read your post wrong.

********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
You can still event it. Just make it so that the spell your casting calls a common event which erases the state then applies it again.

**
Rep: +0/-0Level 83
Ooh, I see.  I'll try that, thanks.

EDIT:
Cool.  After a few tweaks, I finally made it work.  I had to make a separate clone state with a 0 turn limit because with the event, the 1 turn limit of the original state was doubled, making it last for two turns...  Now the only problem I have is with Tomy's On-Screen Battle Status script (a.k.a. OnScreenStatus)...  The window flickers (closes and instantly reopens) when the common event occurs.
« Last Edit: July 19, 2009, 08:54:42 PM by chronofreak »