State Add/Remove Commands

Sixth and Hime both made scripts that can do that.
Title: State Animations
Author: Hime
Date: Mar 28, 2014

- State Removal Animations v1.1
- Made by: Sixth
State Removal Animations works, but since I'm using Yanfly's Ace Battle Engine, the state addition/removal popups tend to cover the animation up.

Would probably be another thing that my hypothetical workaround in my previous post would be able to fix, by having the animation be tied to a skill targeted at the afflicted actor, which would also deal with the application of the follow-up states. I think the skill would also wait for the popups to disappear, at least according to my (likely off) interpretation of how patient the engine is.

Unfortunately I don't think this script alone is capable of forcing skills and stuff as far as my knowledge goes, such actions would likely have to depend on another script, and not only does that bring into question if said hypothetical other script would even be compatible, it also brings into question if a compatible script even exists. (I've tried looking, but my abysmal Google-fu skills when it comes to script hunting tend to get in the way.)
Since you are not having an issue with this script, it would be best to make a new thread post to discuss this issue.
Since you are not having an issue with this script, it would be best to make a new thread post to discuss this issue.
Fair point. I'll pop a thread in script requests about it.
Hello, me again. I encountered a problem with the commands when there are multiple actors that the state is added to/removed from. I use Yami's Battle Symphony, so my actors are visible in battle, their sprite sheets being used. Since there doesn't seem to be a way to stop them stepping in Yami's script, I tried using Shaz's script to change the spritesheet used. So, for example, when an actor receives a frozen state, they stop moving. The commands in the state note window are these:

onadd: if self.is_a?(Game_Actor); $game_variables[101] = self.id;end

onadd: $game_temp.reserve_common_event(51)

onremove: if self.is_a?(Game_Actor); $game_variables[107] = self.id;end

onremove: $game_temp.reserve_common_event(52)


Where the common event is replacing the graphic (this is event 51):

change graphic.jpg



Now, the problem is that when an enemy freezes more than one actor, only the last one affected gets the change. Everyone else keeps stepping, even though they have the frozen state and it otherwise does what it's supposed to. Same when a state is removed in the same turn for more than one actor - the change only happens for the last one. Does anyone have advice on how to make sure the commands run for every relevant actor? Is it a matter of the engine, of the script, or of the commands in the note window/common event? Thanks for any help.

(This might be stupid, but could it be solved by simply adding a wait command somewhere, so it doesn't rush through the commands without executing everything properly?)
Hello,
Now, the problem is that when an enemy freezes more than one actor, only the last one affected gets the change.
This is an expected behavior related to how event calls work in battle.

When you cast a skill/item, it first applies its effects (like state addition, damage etc.) for each targets, and then, before proceeding with the next action, it checks if there are some events to call (common events and/or the troops events).
onadd: if self.is_a?(Game_Actor); $game_variables[101] = self.id;end

onadd: $game_temp.reserve_common_event(51)
By doing so, if you add the state to more than one targets, then event 51 will be called after all effects are done and V[101] will have the value of the last affected battler's id, leading to unwanted behavior.
The same goes for your onremove effects.

You might even observe that if the skill used was supposed to call another common event (say 40) and it adds a state calling common event 51, then only one of the two events will be called because the game only remembers a single common event to call.
Does anyone have advice on how to make sure the commands run for every relevant actor?
There are many ways to deal with it, I can't think of one that is truly satisfying, but here is a working solution:
Did you know that your variables could store something else than numbers? You can actually store anything, so you can also turn a variable into an array that will be updated whenever an actors get the state.

First of all, find a way to initialize your variable into an array, for instance in a setup event (called once per game), put the command:
Ruby:
$game_variables[101] = []

Put this in your notetags:
Code:
onadd: $game_variables[101].push(self.id) if self.actor
onadd: $game_temp.reserve_common_event(51)

Then, in your common event, you can do a loop on the array like this:
1757807453056.png

(note that I have not tested this code so feel free to say if something is not working)

Edit: before the end of the loop, don't forget to increase V[103] by 1 otherwise you get an infinite loop!
It seems to be working great 👍Thank you so much, also for explaining what can be done with variables (I was vaguely aware of arrays, but never really thought of implementing them).
I tried this one with N.A.S.T.Y. Extra Stats by having this one in the actor note:
<xstat>
:dex => 10,
:ins => 8,
:mig => 6,
:wlp => 8,
<xstat_end>

I don't wanna make the stats lower than 6, but instead of upgrading them, I want them back to their original. How can I do it?
I don't wanna make the stats lower than 6, but instead of upgrading them, I want them back to their original. How can I do it?
The way N.A.S.T.Y. Extra Stats is made, the extra stats are directly modified by the equipments, the level ups and the eventual script calls. When you say reset them, what do you mean exactly? Do you want their lvl ups formula to be applied or just the base stats?

I wrote a small script that you can add to your project, it adds a method to actors and enemies to reset their xstats (I just took the same code as the one that initialize their extra stats). This will just remove any extra stats added by script calls during the game.

Ruby:
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # new method: reset_xstats
  #--------------------------------------------------------------------------
  def reset_xstats
    @xstat = Z26::Xstats.new(*([0]*Z26::STATS.size))
    equips.compact.each{|item| z26variate_equip(item)}
    Z26::STATS.each{|stat| z26variate_stats(stat, @level)}
  end
end #Game_Actor

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # new method: reset_xstats
  #--------------------------------------------------------------------------
  def reset_xstats
    @xstat = Z26::Xstats.new(*([0]*Z26::STATS.size))
    Z26::STATS.each{|stat| z26variate_stats(stat)}
  end
end #Game_Enemy

Then you can use reset_xstats to an actor or an enemy, for instance with Shaz's script:
onadd: reset_xstats
Should reset the extra stats of the battler receiving the state (I did not test it).
The way N.A.S.T.Y. Extra Stats is made, the extra stats are directly modified by the equipments, the level ups and the eventual script calls. When you say reset them, what do you mean exactly? Do you want their lvl ups formula to be applied or just the base stats?

I wrote a small script that you can add to your project, it adds a method to actors and enemies to reset their xstats (I just took the same code as the one that initialize their extra stats). This will just remove any extra stats added by script calls during the game.

Ruby:
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # new method: reset_xstats
  #--------------------------------------------------------------------------
  def reset_xstats
    @xstat = Z26::Xstats.new(*([0]*Z26::STATS.size))
    equips.compact.each{|item| z26variate_equip(item)}
    Z26::STATS.each{|stat| z26variate_stats(stat, @level)}
  end
end #Game_Actor

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # new method: reset_xstats
  #--------------------------------------------------------------------------
  def reset_xstats
    @xstat = Z26::Xstats.new(*([0]*Z26::STATS.size))
    Z26::STATS.each{|stat| z26variate_stats(stat)}
  end
end #Game_Enemy

Then you can use reset_xstats to an actor or an enemy, for instance with Shaz's script:
onadd: reset_xstats
Should reset the extra stats of the battler receiving the state (I did not test it).
Just the base stats.
Do you want their lvl ups formula to be applied or just the base stats?
Just the base stats.
Actually the level up formulas are the same as the base stat if you don't specify the level in it (I thought there was another entry for level ups). So my script should work for you hopefully ~
Just the base stats.
It works. I used the "reset_xstats" on "onremove"
Actually the level up formulas are the same as the base stat if you don't specify the level in it (I thought there was another entry for level ups). So my script should work for you hopefully ~
Tell me, I had a problem here...
Each time me and my enemy get hit by an attack or by a skill, I gain tp, even though I set 0 to all "gain tp" to 0.

Can you help me out?
Tell me, I had a problem here...
Each time me and my enemy get hit by an attack or by a skill, I gain tp, even though I set 0 to all "gain tp" to 0.
Hello again, this is not really related to this thread so if you have future questions I suggest you ask them in the VX Ace Support or RGSS3 request if it is script-related. (You may also dm me if you want to ask me specifically a question)

By default, whenever a battler takes damage, they will gain tp based on the damage ratio in max hp %.
This behavior cannot be modified without a script. Here is the original method (from Game_Battler):

Ruby:
#--------------------------------------------------------------------------
# * Charge TP by Damage Suffered
#--------------------------------------------------------------------------
def charge_tp_by_damage(damage_rate)
  self.tp += 50 * damage_rate * tcr
end

If you want to totally remove this behavior, you can add this small script above main:
Ruby:
class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # overwrite method: charge_tp_by_damage -> does not modify tp anymore
  #--------------------------------------------------------------------------
  def charge_tp_by_damage(damage_rate); end
end #Game_Battler

Original thread: https://forums.rpgmakerweb.com/threads/state-add-remove-commands.18593/