Vis_Mage

Wisp Charmer
Veteran
Joined
Jul 28, 2013
Messages
761
Reaction score
261
First Language
English
Primarily Uses
RMMV
Hello! :kaohi:

Could someone help me with creating a state that can only be applied to a target X times, before they become immune? The idea being that instead of making a boss immune to powerful status effects like Stun, I can instead make it so an enemy can only be stunned up to X times within a battle.

One of Yanfly's Tips and Tricks is pretty close to what I'm looking to do, their Cyclone state.

As an added bonus, if it is possible, could this counter affect multiple different "stun-like" states. For example, I have another state called Stop. If the limit of X stuns per enemy could account for both states, that would be awesome, but not required if it would be too difficult.

Thank you!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
34,763
Reaction score
8,975
First Language
German
Primarily Uses
RMMV
do you want to record it in one battle only?

then reserve eight variables for the possible eight enemies in a battle.
use javascript code on state condition to check what the variable of the corresponding index is - if the result is higher the condition fails and the state can't be applied.
then use javascript code on the execution tag to count up the corresponding variable if the state is applied.
don't forget to null the variables at the beginning of each combat (troop event on turn 0, possibly through base troop event plugin)

Sorry, I can't give you the notetag code itself, but the sequences above should work if you use the correct code.

If you want to store the number of stuns beyond a single battle, you'll need self-variables and things become much trieckier.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
3,214
Reaction score
1,902
First Language
English
Primarily Uses
RMMV
One of Yanfly's Tips and Tricks is pretty close to what I'm looking to do, their Cyclone state.
That's exactly what you want to do, you just need to set them as resistant to the state when the counter reaches whatever number you want. Simply make another state that has the trait of resistance to your stun state, and put in your original stun state:
Code:
<Custom Remove Effect>
// Use whatever variable name you added to the battler in your Custom Apply Effect
// and whatever you want the number of times they can be successfully stunned
if (target._stunTimes == 4)
    target.addState(X);
// Where X is the ID of your state with stun resistance
</Custom Remove Effect>
As an added bonus, if it is possible, could this counter affect multiple different "stun-like" states.
You add whatever states you want it to be resistant to in its traits.
 

Vis_Mage

Wisp Charmer
Veteran
Joined
Jul 28, 2013
Messages
761
Reaction score
261
First Language
English
Primarily Uses
RMMV
Thank you very much for both of your help! :)

I ultimately went with ATT_Turan method, with a few minor changes to the Cyclone notetags to get things working with several different stunning states, without needing several of the "bridge" states.

In case anyone sees this and wants to recreate it for yourself here's my setup.

You'll need 2 new states, in addition to however many states you want to have add to the counter limit.

Add this notetag to all of the states you want the Stun limit to apply to.
In this case, 119 is the Stun Resistance State, and 120 is the Bridge State
Code:
<Custom Apply Effect>
target.addState(120);
</Custom Apply Effect>

<Custom Remove Effect>
// Use whatever variable name you added to the battler in your Custom Apply Effect
// and whatever you want the number of times they can be successfully stunned
if (target._stunTimes == 3)
    target.addState(119);
// Where X is the ID of your state with stun resistance
</Custom Remove Effect>

Make sure the Bridge State only wears off at the end of battle. Otherwise, this state is completely empty besides this note tag.
Code:
<Custom Apply Effect>
// Set the target's default stun times to 0.
target._stunTimes = target._stunTimes || 0;
// Raise the number of times the target has been affected by Stun.
target._stunTimes += 1;
</Custom Apply Effect>

<Custom Remove Effect>
// Clear the number of times the target has been affected by Stun.
target._stunTimes = undefined;
</Custom Remove Effect>

This state is simply set to make the user resistant to all of the stun states.
Set it only to be removed at the end of battle.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
3,214
Reaction score
1,902
First Language
English
Primarily Uses
RMMV
There's no reason for you to use that bridge state, unless you're also using this on your actors (which you didn't say before, you only mentioned bosses).

If you're only using this on enemies, simply put that apply effect directly into the stun state.
 

Vis_Mage

Wisp Charmer
Veteran
Joined
Jul 28, 2013
Messages
761
Reaction score
261
First Language
English
Primarily Uses
RMMV
Oh yeah, I forgot that I wouldn't actually need to reset the stunTimes variable for enemies. Thanks for the heads up!
 

Latest Threads

Latest Profile Posts

1.6 update incoming with quality breakthrough! :kaoluv:

1643254634071.png
I might try the mechanical bull at the fair on Friday... for one of the challenges, if you stay on for two minutes, you win $200. I might give that a try and see if I win--I'm pretty good at holding on to things.
Remaking a more streamlined version of my Remote Move map skill in MZ, just one switch and one variable to handle everything. If you seen the Move skill in Golden Sun before, moving far away items with your mind is pretty cool

MZtestRemoteMove.gif
I don't want to brag or anything but I was entertaining a woman the other night. I told her jokes while she bandaged my foot.
Okay so, I'm using this script, right? And it works. If you press :Y a menu should come up allowing you to choose an item to use. Nothing happens. You press :A to open the event options menu and choose "Use an Item"? The item selection menu appears. I have no idea how I set this up or why it works the way it does. Absolutely bizarre.

Forum statistics

Threads
118,733
Messages
1,118,333
Members
155,889
Latest member
pgimstone
Top