VXAce looking for a script about buffs.

im looking for various scripts for my game, such as:

a script that adds a buff when two "types" of buffs are applied. example: having two or more alcohol buffs grants alcohol poisoning debuff.
my game has many powerful alcohol items, but i want to make sure they won't stack as much.

alternatively, a script to make buffs "mutually exclusive"
example: you cannot have buffs of "same type". applying the buff removes the other.

using scripts would be easier than eventing it for me at least.
You might like these two scripts: Shaz's state add/remove commands and Neon Black's Stacking States.

Note that the stacking script will alter state deletion: if you have 3 times the same state, removing the state with script calls or event commands will only delete one instance of the state, leaving 2 of it.

Put the following patch below the two scripts to allow the adding effect to trigger even as you stack the states:
Ruby:
class Game_Battler < Game_BattlerBase
  #overwrite (replaced the !state?(state_id) condition)
  def add_new_state(state_id)
    unless max_state_stack?(state_id)
      shaz_state_commands_add_new_state(state_id)
      state_add_command(state_id)
    end
  end
end
a script that adds a buff when two "types" of buffs are applied. example: having two or more alcohol buffs grants alcohol poisoning debuff.
Set your state to be stackable twice through the stacking state script.
Then put in the notetag of the state the command:

(replace a with your stacked state id and b with your new state to add)
Ruby:
onadd: add_state(b) if state_stack(a) == 2
alternatively, a script to make buffs "mutually exclusive"
example: you cannot have buffs of "same type". applying the buff removes the other.
If the only way to get such states is by a skill with 100% apply success, you can put in your skill's effect the removal of all other states, that's what I did in one of my games.

Otherwise, you can also play with the remove/add effects from Shaz's script to remove other states when one is added.

If you really have many big families of states like this such that it is annoying to write in the notetags, I can consider writing a small script.
You might like these two scripts: Shaz's state add/remove commands and Neon Black's Stacking States.

Note that the stacking script will alter state deletion: if you have 3 times the same state, removing the state with script calls or event commands will only delete one instance of the state, leaving 2 of it.

Put the following patch below the two scripts to allow the adding effect to trigger even as you stack the states:
Ruby:
class Game_Battler < Game_BattlerBase
  #overwrite (replaced the !state?(state_id) condition)
  def add_new_state(state_id)
    unless max_state_stack?(state_id)
      shaz_state_commands_add_new_state(state_id)
      state_add_command(state_id)
    end
  end
end

Set your state to be stackable twice through the stacking state script.
Then put in the notetag of the state the command:

(replace a with your stacked state id and b with your new state to add)
Ruby:
onadd: add_state(b) if state_stack(a) == 2

If the only way to get such states is by a skill with 100% apply success, you can put in your skill's effect the removal of all other states, that's what I did in one of my games.

Otherwise, you can also play with the remove/add effects from Shaz's script to remove other states when one is added.

If you really have many big families of states like this such that it is annoying to write in the notetags, I can consider writing a small script.
i might try, but what i meant by "stacking" is if you apply two different states of the same "type", a new state is applied (alcohol poisoning)

a certain game changed my vocabulary and when i hear "stacking" it means applying two or more different buffs to become powerful.
having two or more alcohol buffs grants alcohol poisoning debuff.
I can't find it now, but I remember there was something like this, or maybe it was just a discussion.
The closest thing I can find now is Hime - Progressive States. here
But that works on a timing basis not stacking basis, but it does the change to another state as you suggested.
i might try, but what i meant by "stacking" is if you apply two different states of the same "type", a new state is applied (alcohol poisoning)
The reason why I suggested to use a stacking script was because you cannot trigger the onaddeffects from Shaz's script otherwise (it only triggers when a new state is added).
What you can do if you use both scripts is something like this in your notetags for state 'evolution':
Ruby:
max stack[2]
onadd: if state_stack(a) == 2; erase_state(a); remove_state(a); add_state(b); end
(You have to remove the state twice because it is there twice, but erase_state will do it without triggering messages in battle while remove_state will do it)

As for mutually exclusive states, you can put in their notetags:
Ruby:
onadd: [a,b,c].each {|s| remove_state(s)}
Where [a,b,c,...] is an array of state ids you want to remove when your state is added.

Original thread: https://forums.rpgmakerweb.com/threads/looking-for-a-script-about-buffs.180106/