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

Joined
Jul 23, 2012
Messages
133
Reaction score
157
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,181
Reaction score
836
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
133
Reaction score
157
First Language
English
Primarily Uses
RMMV
I'll try and figure it out, I can understand most of it.

Thanks for the effort xD
 

Latest Threads

Latest Posts

Latest Profile Posts

Today we be doing an unscheduled stream! Lets get some work done on the titlescreen for Lightestone! <3
www.twitch.tv/riazey
I can't believe it... my mom is going to sign me up for the Planet Fitness down the street! I need to lower my cholesterol according to my doctor, and I'll need to lose some weight to fit into Helen Henny's skirt (I ordered a skirt for my mascot outfit and realized it was a bit too small). My doctor says I need to lose weight anyway.
I blame my lilest bro for the duck suit. Sketched it and realized it had to be added to a mock fashion magazine cover. The titles are actually inside jokes about the place this NPC is from.
EvKECQJVEAw3Qux
Kes
After a few hectic months, my hiatus is over, and I'm now back. Good to see so many familiar names posting. And a forum update while I was away.
V1.3 of Demo, a new concept artist on the team, character voices are coming into light more... I'm happy to say that the fangame is making good progress.

Forum statistics

Threads
108,854
Messages
1,040,081
Members
141,295
Latest member
megmaconqueror
Top