Removing a Single State at Random (Lunatic Objects Package - Destruction)

Joined
Jul 23, 2012
Messages
128
Reaction score
140
First Language
English
Primarily Uses
RMMV
I'm looking to add a way of removing only a single state at a time instead of the regular Dispel/Esuna type skills removing absolutely everything at once.

I'm using Yanfly's Lunatic scripts to use their base implemented functions but as I'm not a scripter myself, I'm having trouble wrapping my head around what I'd need to do to get this to work.

I'm assuming it would need to look through each state to determine the states possible for removal so I think that would be an array. I would assume setting Priority x to all "negative" states targetable by Esuna and Priority y to all "positive" states targetable by Dispel would be the right way to get them to be distinct.

Then I assume there's a way to remove a single state at random from those respective lists if they are on an actor.

Thanks to anyone who can help!
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
I never used those "Lunatic" scripts of Yanfly (I always found them overly complicated - still do, as a scripter and as a script user too), but if you have the state IDs in an array already, you can just call the method sample on that array and it will get a random value from the array.
For example:
Code:
ary = [1,2,3,5,6,7,8,9]
random_elem = ary.sample
This way, you can use that random_elem (which is a random element from the ary array) in the rest of your code (in this case, to get the state you want to remove).

To get all states the actor has inflicted on him/herself, you can use the @states instance variable in Game_BattlerBase (or in any other class inheriting from the mentioned one).
Note that calling that variable from outside it's class will return an array of RPG::State objects (so, $game_actors[ID].states, for example), because it will call the method named states instead from the stated class, but if you use it within it's class as an instance variable (so, using @states in any method in the mentioned class), it will return an array of state IDs (and this is what you need here eventually, unless you need to check some other things from the state objects, like their other methods/variables such as their priority settings, etc).

No idea if this was helpful to you or not, but I hope you will get something out of it aside from a head-ache. :D
 
Last edited:
Joined
Jul 23, 2012
Messages
128
Reaction score
140
First Language
English
Primarily Uses
RMMV
I'll try and figure it out, I can understand most of it.

Thanks for the effort xD
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,845
Messages
1,016,961
Members
137,561
Latest member
JaCrispy85
Top