Im trying to make a skill that gives the enemy battler a debuff state that they lost one turn or a couple of turns ago, how exactly should I go with this? I've tried using a conditional branch through a common event but I'm lost trying to figure out how to get that previous state since the enemy wont have it by the time the common event runs.
Reapplying prior state to a target.
RPG Maker MZ Supportits as you say. you cant really fetch that data as you didnt prepare to catch in the first place. you can use either Turan's Eval Tags or the Visustella skills and states plugin to do it.
im using eval tags for the example, but the visustella plugin has equivalents.
add an effect to each of your negative states so that whenever theyre removed, they save a bit of data to the battler that indicates they had that state on prior
Code:
<State Remove Eval>
user._pastStates = user._pastStates || [];
user._pastStates.push(stateId)
</State Remove Eval>
then your skill can use that same data to re-inflict the state.
Code:
<Action Post-Apply Eval>
if (target._pastStates)
target.addState(target._pastStates[Math.random(target._pastStates.length)]);
</Action Post-Apply Eval>
you could also use an invisible state that gets added to each battler on state removal to indicate they they had the state before, but chances are the database isnt organized well enough to make using that very convenient
I have Visustella Skills And States plugins, I'll get Turan's Eval Tags and see if your method works!
You should not do that - my plugin is an alternative to VisuStella, if you try to put it in a project with other plugins that do the same thing one of them will stop working correctly.
As @Robro33 said in his post, just look up the equivalent notetags in the VisuStella instructions.
I'm sadly not super well-versed in which notetags I should be looking for and how to transfer the script he wrote in VisuStella, all I've found is the JS notetags for adding states and removing.
If that's the notetags I need, then I'll give it a try and see.
that one is my bad. the skill tag im thinking of is from the visustella battle core plugin, not the skills and states plugin. but otherwise, the content is the same. you might have to replace "stateId" with "state.id" though
The only tags I could find that match your script are the <JS Command Visible>, nothing else seems to show up for the State Removal and the Action-Post Apply, unless I'm wrong.
Also the part where you mention adding an effect to a state, do you mean a collapse effect? I want to have the states go off without any effects or animation if possible (at least for now until I figure all this out) Do forgive me for my ignorance if I don't see what you are implying.
for state removal, its <JS On Erase State> from the skills and state plugin as you said youve found. the skill's notetag is <JS Post-Apply> from the battle core
Dont worry, the confusion is understandable. when i said to add an effect, it was the notetag i was referring to. No need to add any "effects" from the database, we're just working with the notebox here
Thanks for the clarification, I added the skill script into the notetag.
As for the states script, do I just add it to the notetag of all the states that can comeback through that skill and then change the (stateID) to match their names? or just by adding it suffices.
give each state youd like the skill to work on that notetag. there is no need to change anything about it except maybe "stateId" to say "state.Id" if the visustella plugin gives an error for it
It doesn't seem to be working, I've changed it to both "stateId" and "state.Id" in all the states to try out and no results.
Here's how I have it added on my end, for both the states and the skill.
the skill needs to do "something", or else the post apply notetag doesnt run. try doing something that results in nothing like attaching an empty common event or making it deal 0 damage and it should run
Changed it to that (Tried both making it deal 0 damage and attaching an empty common event), and I'm still not getting any results, It's not giving the previous expired state to the enemy.
oh. i see what i did now.
I meant for the "i" in "state.id" to be lowercase
i wrote it the first time, but not the second
I meant for the "i" in "state.id" to be lowercase
i wrote it the first time, but not the second
I changed all the state effects to "state.id" and It's not working, could it be a conflicting plugin or something along those lines?
I double checked and I have the skill set to an empty common event, the states have all the correct effect.
Does it matter if the state has a duration? It's the only thing that I can spot that differs from the rest of my states.
making sure, youve saved the project before testing tight? notetag changes dont take effect until you do
as long as the state was removed, it should work with the state
EDIT: took a closer look at what i initially gave you now. I meant "randomInt", not "random"
as long as the state was removed, it should work with the state
EDIT: took a closer look at what i initially gave you now. I meant "randomInt", not "random"
It works! Thanks for the hard work and guiding me! I'll post the updated script here if anyone else needs it:
Skill:
<JS Post-Apply>if (target._pastStates) target.addState(target._pastStates[Math.randomInt(target._pastStates.length)]);</JS Post-Apply>State:
<JS On Erase State>user._pastStates = user._pastStates || [];user._pastStates.push(state.id)</JS On Erase State>Only nitpicks I have, is that, while it works, it seems to randomly go to other states from time to time, but besides that it works like a charm.
yeah, it chooses a random state youve already applied. how would you like it changed? the newest state added?
That is what I had in mind, yes. The most recent expired state.
ok, i thought from the first post that it should have been able to work if multiple states were applied. its a quick adjustment then.
Code:
<JS On Erase State>
user._pastState = state.id;
</JS On Erase State>
<JS Post-Apply>
if (target._pastState)
target.addState(target._pastState);
</JS Post-Apply>
Original thread: https://forums.rpgmakerweb.com/threads/reapplying-prior-state-to-a-target.172142/