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

Discussion in 'RGSSx Script Support' started by Fireworker, Oct 15, 2017.

  1. Fireworker

    Fireworker Veteran Veteran

    Messages:
    116
    Likes Received:
    109
    Location:
    Montreal
    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!
     
    #1
  2. Sixth

    Sixth Veteran Veteran

    Messages:
    2,122
    Likes Received:
    792
    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: Oct 15, 2017
    #2
  3. Fireworker

    Fireworker Veteran Veteran

    Messages:
    116
    Likes Received:
    109
    Location:
    Montreal
    First Language:
    English
    Primarily Uses:
    RMMV
    I'll try and figure it out, I can understand most of it.

    Thanks for the effort xD
     
    #3

Share This Page