State Add/Remove Commands

● ARCHIVED · READ-ONLY
Started by Shaz 20 posts View original ↗
  1. State Add/Remove Commands v1.01
    Shaz
    Introduction
    This script lets you enter RGSS script commands to be run when a state is added or removed. Like calling a common event when a state is added, or setting one state to be replaced by another after a certain number of turns.

    Versions
    Spoiler
    Code:
     1.01  26 May 14  Fix issue with + sign in regular expressions

    Features
    - Make something happen when a state is removed.
    - Multiple commands may be run for a single state.

    How to Use
    Paste the script into a new slot below Materials.
    In a state's note box, enter onadd: command or onremove: command, where command is any valid RGSS script command.
    If a command requires more than will fit in the note box, allow it to wrap to the next line automatically - do NOT use the enter key to go to a new line.
    Anything from onadd: or onremove: to the next manual line break will be executed.
    You may have several onadd: or onremove: commands for a single state.

    Script
    Get it here

    Examples
    If you want to call common event 8 when a state is added, enter the following as the note:


     
    Code:
    onadd: $game_temp.reserve_common_event(8)
    If you want state 16 to be added when state 15 is removed (replace one state with another), enter the following into the note of state 15:
    Code:
    onremove: add_state(16)
    If you want to add a new state when state 20 is removed, and that new state will be 21 if the battler’s hp is 50% or higher, and 22 if lower, enter the following into the note of state 20 (allow it to wrap automatically)
    Code:
    onremove: if hp_rate < 0.5; add_state(20); else; add_state(21); end;
    You could also enter this to achieve the same thing:
    Code:
    onremove: add_state(hp_rate < 0.5 ? 20 : 21)
    Feel free to provide a scenario in the comments, and I will give you the command you should use. Game_Interpreter is a good place to look, and any of the properties or methods in Game_Battler or Game_BattlerBase can be used.

    FAQ



    Credit and Thanks
    - Shaz

    Author's Notes
    Free to use in commercial games. Please give credit.
  2. Thanks a lot, Shaz~ ^_^
  3. this is nice Shaz
  4. Did exactly what I needed~
  5. The link is broken :/
  6. Excellent work on this one, I can see the possibilities.
  7. Yes,it works,sorry.It was my browser that was causing the problem.
  8. I just wanted to say thank you for this. I have been searching for a solution to my problem for several days and finally found this. /highfive
  9. Hey, is there a way to have a state add another one, when it expires, but not when it gets cured by an item?
  10. Try setting up your item so that it removes this state, AND removes the new state that would have been added. IF you add them both as features, making sure the order is correct (remove this state first, remove the new state second), it should work. It SHOULD remove this state, which will trigger adding the new state, and then will remove the new state.


    If that doesn't work, I'd make the item call a common event that removes this state, and then removes the new state.
  11. Ice Cluster said:
    Hey, is there a way to have a state add another one, when it expires, but not when it gets cured by an item?
    You need to make the following assumption: a state that expires without curing, means that it has zero turns left. What gets tricky is when you have a cure effect that occurs WHEN the state expires, but that's a special case.

    In that case, you can say something like

    onremove: add_state(YOUR_NEW_STATE) if @state_turns[THIS_STATE_ID] == 0Or possibly 1, I don't remember exactly whether it is reduced to zero or not.Alternatively, you can use this, which attaches itself to the "state expire" logic: progressive states, which follows basically the same logic I have described.
  12. lol - did you check the thread that question was posted in Hime? ;)
  13. No. Which is why I edited in a solution using the current script afterwards.
  14. Thanks for the quick answers. I'll try out your solutions.
  15. When I try to have it, on a fresh project, so that on removal, a state recovers the battler's MP, it won't work.

    I just tried

    onremove: self.mp += 100in the notes box of a state and had it so it removes itself after 1 turn, just to test it out.

    And yet the state fades and the call does nothing.

    onremove: self.add_state(2)works just fine.

    Would this have something to do with the fact that this script only deals with Battlerbase?

    The original idea was to have it so that when MP is zero, you have to wait a certain number of turns for an MP Rejuvination state to wear off then the battler's MP would be restored. Kind of like in Kingdom Hearts 2, where you cast Curaga and it full heals your party yet puts your MP at unusable till a certain amount of time passes.
  16. It's meant to work on Game_BattlerBase (mp wouldn't be available if it didn't).


    I have figured out WHY it's not working. I don't understand it, or have a fix yet. I will appeal to the gurus of regular expressions.
  17. Alrighty, I await your solution *salutes*

    And that's so strange because you would think your script would be able to handle it.
  18. It's a funny regular expression thing. Regular expressions and I do not like each other very much.