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

sleepy_sealion

Need to work harder!
Veteran
Joined
Jan 4, 2018
Messages
245
Reaction score
429
First Language
English
Primarily Uses
RMVXA
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.)
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,600
Reaction score
6,552
First Language
Indonesian
Primarily Uses
RMVXA
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
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
@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.
 

sleepy_sealion

Need to work harder!
Veteran
Joined
Jan 4, 2018
Messages
245
Reaction score
429
First Language
English
Primarily Uses
RMVXA
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.
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.
 
Last edited:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
@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).
 

sleepy_sealion

Need to work harder!
Veteran
Joined
Jan 4, 2018
Messages
245
Reaction score
429
First Language
English
Primarily Uses
RMVXA
@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.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
It's working fine now.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,600
Reaction score
6,552
First Language
Indonesian
Primarily Uses
RMVXA
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 || !@subject.current_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
 

sleepy_sealion

Need to work harder!
Veteran
Joined
Jan 4, 2018
Messages
245
Reaction score
429
First Language
English
Primarily Uses
RMVXA
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 || !@subject.current_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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,051
Messages
1,018,549
Members
137,836
Latest member
T62352536256t362
Top