Trying to remove a state mid turn (RPG Maker VX Ace)

Hi, I'm really hoping this is the right place to ask this.

I've been toying with Rpg Maker on and off and I've been using a script called Victor - State Changes by Victor Sant, which is a script that changes battler sprites.

So after using that for a bit I had this idea to use the "a.add_state(x)" formula to add an Attack state - to change the attacking battlers sprite into an "attacking" sprite and at the same time I it always inflicts a state that would have changed the targets sprite and I figured I could get a lot of mileage out of that because I'd be able to make different reactions to attacks and buffs or just have characters have different poses for certain attacks. (granted I'd have a lot more states to manage)

The problem here is - that to get this to work like I want, I'd need some way to have these specific states removed mid turn - I've tried using switches and common events/ battle events to remove the effects from everyone when they trigger but that only seems to work when a turn is done so if anyone has any ideas on how to do this I'd love to hear it.

(And if this isn't the right place for this thread if you could move it - I saw there was a script section in the forum rules but that link doesn't seem to work.)
Without a context of the scripts you're using, try to set the state expiration / auto removal timing into Action End and put one as the duration. See if it works
@AquaDog Just a heads up - if it was 'Scripts' that you were looking at, that is where people who have written scripts that they want to share with others can post them. Because of that, all threads for there enter a moderation queue before appearing. 'RGSSx Script Support' is the place to ask for help with a script you already have, and 'RGSS3 Script Requests' is for when you want someone to write something new for you.

I'm going to leave this here to see if there is a non-scripting solution. If there isn't, then it can be moved to the appropropriate forum, depending on what you want.
Thanks - things seem to work a bit better with Turn end, but also I feel like it would probably help things if I showed what I wanted to do exactly, please excuse the messy battle screen though.
Spoiler
wB0kEx9.gif
So basically what's going on here - is that every time something attacks, it adds a state to itself which uses Victors script to change the sprite into an attacking one - and at the same time inflicts a "Hit" status on the target which changes their sprites.

I feel like the attacking sprites seem to work okay-ish. But it takes awhile for the fish to get back up - and the state is only removed because the attack also has an a.remove_state(x) on it - so it only got up because it attacked last, the chicken on the other hand got up fine because the turn ended the second it got hit.

Here's what the beginning of the formula looks like:
a.add_state(32);a.remove_state(33);

I do think that there might be an script solution for this that would make things easier to manage but I just haven't been able to wrap my head around how it works exactly - aside from plugging them in.
@AquaDog Sadly something seems to have gone wrong with your image. All I can see is the imgur icon which takes me to their home page. I think with imgur you have to use the direct link (or a name like that) where the link ends in .png (or whatever type of file you have used for the image).
@AquaDog Sadly something seems to have gone wrong with your image. All I can see is the imgur icon which takes me to their home page. I think with imgur you have to use the direct link (or a name like that) where the link ends in .png (or whatever type of file you have used for the image).

Oh, Ok. It was working for me on my end - but I edited the post now so hopefully you (and anyone else reading) can see what's going on.
It's working fine now.
Ok, so this is just a wild guess since idk what scripts you're using and I haven't tested it yet
Code:
class Game_Battler
 
  def clear_temp_states
    @states.each do |s_id|
      remove_state(s_id) if $data_states[s_id].note[/<temp>/i]
    end
  end
 
end

class Game_Unit
 
  def clear_temp_states
    members.each {|m| m.clear_temp_states}
  end
 
end

class Scene_Battle
  def process_action
    return if scene_changing?
    if !@subject || [email protected]_action
      @subject = BattleManager.next_subject
    end
    clear_state_mid_turn
    return turn_end unless @subject
    if @subject.current_action
      @subject.current_action.prepare
      if @subject.current_action.valid?
        @status_window.open
        execute_action
      end
      @subject.remove_current_action
    end
    process_action_end unless @subject.current_action
  end
 
  def clear_state_mid_turn
    $game_party.clear_temp_states
    $game_troop.clear_temp_states
  end
end
To use it simply put notetag <temp> in state notebox
It should clear the state when other battler take action
Ok, so this is just a wild guess since idk what scripts you're using and I haven't tested it yet
Code:
class Game_Battler
 
  def clear_temp_states
    @states.each do |s_id|
      remove_state(s_id) if $data_states[s_id].note[/<temp>/i]
    end
  end
 
end

class Game_Unit
 
  def clear_temp_states
    members.each {|m| m.clear_temp_states}
  end
 
end

class Scene_Battle
  def process_action
    return if scene_changing?
    if !@subject || [email protected]_action
      @subject = BattleManager.next_subject
    end
    clear_state_mid_turn
    return turn_end unless @subject
    if @subject.current_action
      @subject.current_action.prepare
      if @subject.current_action.valid?
        @status_window.open
        execute_action
      end
      @subject.remove_current_action
    end
    process_action_end unless @subject.current_action
  end
 
  def clear_state_mid_turn
    $game_party.clear_temp_states
    $game_troop.clear_temp_states
  end
end
To use it simply put notetag <temp> in state notebox
It should clear the state when other battler take action

This works perfectly!
The only thing kind of off is the state stays when an enemy fades out from death, but I'm honestly okay with that.

I really wish I could understand how you guys manage to make scripts like this but I guess this isn't the place for asking that.

Anyways, I guess all that's really left to figure out is maybe a way to simplify the formula a bit since the add/remove states takes up a good chunk of it though I might be better off googling around first if there's a way to just make the damage formula longer somehow.

Anyway thanks again! This is amazing - you are a wizard.

So I guess this thread is kind of done then unless anyone else has anything to say.

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-remove-a-state-mid-turn-rpg-maker-vx-ace.89405/