Turn switch on while actor has state and turn it off when they don't (battles)

Gargoyle77

Veteran
Veteran
Joined
Dec 4, 2017
Messages
81
Reaction score
11
First Language
English
Primarily Uses
RMMV
Hello, everyone! My doubt is the one in the title. During battles, I want a specific switch to be ON while at least 1 actor has a specific state and that same switch to be OFF if no actor (no longer) has the state mentioned.

Thanks for reading!
 
Last edited:

Pots Talos

Veteran
Veteran
Joined
Jun 28, 2012
Messages
175
Reaction score
173
First Language
English
Primarily Uses
RMMV
If you have Yanflys Buffs and States plugin this can be easily done with the Apply and Leave effects.
You would just need to add these into the state note box:

<Custom Apply Effect> $gameSwitches.setValue(num, true); </Custom Apply Effect> <Custom Leave Effect> $gameSwitches.setValue(num, false); </Custom Leave Effect>

Changing the num to whatever switch number you wanted
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,908
Reaction score
8,600
First Language
German
Primarily Uses
RMMV
or you could have a troop event checking for the states and reacting to them.

but a much better question would be an explanation of what the switch is supposed to do, because depending on that it might be easier to handle the effect of the switch directly.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,223
Reaction score
1,182
First Language
English
Primarily Uses
RMMV
Download Yanfly's Buffs & States Core, a free plugin.

In the notes field for the state, you'll put two tags:
Code:
<Custom Apply Effect>
$gameSwitches.setValue(X, true);
</Custom Apply Effect>

<Custom Leave Effect>
$gameSwitches.setValue(X, $gameParty.aliveMembers().some(function(a){return a.isStateAffected(Y)}););
</Custom Leave Effect>

Where X is the ID of the switch you want to toggle, and Y is the ID of the state.
 

Gargoyle77

Veteran
Veteran
Joined
Dec 4, 2017
Messages
81
Reaction score
11
First Language
English
Primarily Uses
RMMV
or you could have a troop event checking for the states and reacting to them.

but a much better question would be an explanation of what the switch is supposed to do, because depending on that it might be easier to handle the effect of the switch directly.
I'm trying to make party members 2, 3 and 4 not be affected by a state when member 1 dies (I'm using Yanfly's row formaton). The problem is that the buff that is applied when in a certain row is not removed when a the actor dies (so the <custom leave effect> won't work). The other option that almost 100% works is using Yanfly's passive aura effects. The only problem is that the aura doesn't go away from the allies even if the source of the aura is dead. And I haven't found how to remove passive auras if the source is killed.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,908
Reaction score
8,600
First Language
German
Primarily Uses
RMMV
in that case the custom leave effect should be the javascript for removing that statefrom the other actors

unfortunately I can't give you that code, but someone like @ATT_Turan should have the knowledge to figure it out.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,223
Reaction score
1,182
First Language
English
Primarily Uses
RMMV
Sorry, but I'm finding your explanation to be rather confusing.
I'm trying to make party members 2, 3 and 4 not be affected by a state when member 1 dies
This English is odd - member 1 can't die so long as members 2-4 have the state? Or you mean you want to remove it from them when 1 dies?
The other option that almost 100% works is using Yanfly's passive aura effects. The only problem is that the aura doesn't go away from the allies even if the source of the aura is dead.
Code:
<Custom Aura Condition>
condition=user.isAlive();
</Custom Aura Condition>
You could also do user.hp>0, or !user.isStateAffected(1), but it's better to use the alive check because that's what the rest of the combat engine refers to.
 

Gargoyle77

Veteran
Veteran
Joined
Dec 4, 2017
Messages
81
Reaction score
11
First Language
English
Primarily Uses
RMMV
Sorry, but I'm finding your explanation to be rather confusing.

This English is odd - member 1 can't die so long as members 2-4 have the state? Or you mean you want to remove it from them when 1 dies?

Code:
<Custom Aura Condition>
condition=user.isAlive();
</Custom Aura Condition>
You could also do user.hp>0, or !user.isStateAffected(1), but it's better to use the alive check because that's what the rest of the combat engine refers to.

Yeah, I want to remove it when 1 dies. Sorry for my English.

I tried the code but it doesn't work. But what I found out that works is that the state that the source of the aura provides to its allies can be removed with a skill but somehow cannot be removed with a common event (I tried using a plugin that triggers a common event when someone dies). Now I'm thinking that there must be a code that makes that at the start of every turn (ally or enemy) that state is removed from all battlers. So if there's no actor 1 that provides the aura, that state will remain removed. Any clue on how to do that?

Btw thanks a lot for your answers. I really appreciate it.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,223
Reaction score
1,182
First Language
English
Primarily Uses
RMMV
I tried the code but it doesn't work.
You put that in the state that creates the aura and it still gave the other state when the main character died? That shouldn't be the case.
But what I found out that works is that the state that the source of the aura provides to its allies can be removed with a skill but somehow cannot be removed with a common event
That tracks, auras are not the same as regular states and aren't designed to be manipulated by the common event commands.

Can you just post screenshots of the skills and states that have to do with this whole mess, please.
 

Latest Threads

Latest Posts

Latest Profile Posts

When you're forced to make a tutorial for something obvious.
246907756_284595507001402_2098549601125689312_n.jpg
one dislike. tragic really ofended me bruh
i only have one decent song and i dont even think it fits for a video game
Update: I finished the combat arena! My goodness, it took a while! There were numerous little bugs to squash.
Maldra wrote on stramin's profile.
Hi regarding the 32 bit -> 64 bit
I am running on a 64 bit windows OS and tried doing this conversion. I converted all of the .exe files that I could find in the KADOKAWA\RPGMV folder using the 4gbpatch.exe file. However, after trying to access RPG Maker MV after this conversion, it simply will not load. Do you have any advice or any ideas?

Forum statistics

Threads
115,932
Messages
1,094,176
Members
151,193
Latest member
Edison0057
Top