Probably a very stupid Scripting/Common Event question...

I'm tweaking one of my Common Events lately, but I feel like I'm missing something in my scripting. I want it to add a state to whoever drinks it, but whenever I use it, it only works on one of my actors.


Observe.

Spoiler
16ay9g2.jpg



16l9y0g.jpg



mtxgk5.jpg



orryie.jpg



So, what do I do? Do I just add all my actors in there one by one? I don't want it to effect the entire party at once because it's a single target item. Also, is there any way I can also use this on enemies as well? I have the Selection Control plugin by Yanfly, but I don't know how to make it effect the enemies and damage them too since every time I use it, it plays the animation, but only my one actor is effected so it's currently useless. I figure that I don't have to make multiple Common Events, do I?
Well, in the script part it says actor(1) everywhere. That means it's only going to ever do that for actor 1. The number in the parenthesis tells which actor it effects. Also, I'm curious why you are using a script call and not the event command for changing an actor's state?


But yeah, at some point you need to set a control for which actor you want it to effect. You may have use variables to store the actor number you want and then put the variable in the script call. However probably what I would do is have the common event ask which actor you want to use it on, the set the choices to do those things above for the different actors.
Well, I figured that if I did just the event command of Change State, that it'd effect all of the party at once or something. Like there you saw two chars, Alto and Minuet, and if I put both Change States into the Common Event then it'd effect both of them instead of whoever I used it on.


And the enemies? Because I already have the item set to <Actor or Enemy Select>.
I just meant something like this:

Spoiler
By6VtFF.png



I'm not certain what the Actor or Enemy Select is, but there is also an event command to add a state to an enemy, so I don't know if that would be helpful or not.
Why do I need to use a selection choice at all? This is just one item, a type of potion, and one that can be used in battle. Wouldn't having a choice pop up mean that things are slowed down? The characters already flash, as you can tell, in the item selection screen, so really the choices should already be made clear.
You'll have to replace the '1' in actor(1) with the ID of the Actor using this Item. I'm afraid I can't tell you how to establish that, but if there's a kind soul with that info, you're good to go. It'll work, too, on an enemy if you use the enemy's ID instead of actor(n) (maybe chosen at random from the index of enemies..?).
*is shaking head sadly* Nothing I do is working! Gah! 


I tried scripts in separate Conditional Branches, I tried Event Commands of Change State, I tried making separate Common Events for each of my Actors... nothing!


 And I still don't understand why I need to have the choices thing, since it's just an item! It's a potion called Foul Brew that heals you slightly, and inflicts a state on you, or it explodes. It's not like an event like, "Who shall perform Alchemy?" "What book would you like to read?" There's no reason to have a choice for this, when it's crafted by you and no other potion has this!
When you have the script call $gameActors.actor(1) - the number inside tells which actor is going to receive the state. Each actor has a different number. So if you only ever have 1 in the () it will only ever effect the actor that you have in the #1 slot in the database.


I just used the choices as an example of a method you could use to determine which actor the player wanted to drink the potion. There may be other ways.
Okay, fair enough. But even changing the numbers in my script didn't do anything.
So, if you go into that exact same common event that you posted in the original post, and replace all the 1's with 2's, it still only effects the Actor 1? I'm not trying to nitpick, I'm really truly trying to understand, because we can't help you find the solution without fully understanding the problem.
Just tested. It works on Actor 1 when it's 1 in the Script, and Actor 2 when it's 2. So... *shrugs*
Right. Because that is exactly how it is supposed to work. When you use that script call and put in a specific number, it will always add the state to the actor with that number, because that is exactly what you are telling it to do.


What you need is some way to determine which actor was selected to use the item and put that actor number in the script call. I'm not sure if this can be done with scripting or not.


A coder I was talking to suggested that there may be a way you can add the state to the formula box of the item, though I'm not entirely certain how to work it.
@Little Adventurer  Honestly, I'd do this in the damage formula.  


Why do you use 1-20 as a random number and then only have 4 possibilities for the actions?  You would get the same result by using a random number between 1 and 5 and then just checking for each rather than a range of random numbers.  


What happens if the random number is between 16 and 20?


It looks like you want to give a 4 in 5 chance of a state being applied, and the state is chosen randomly from the 4 listed.  Is that correct?


I will give you the simplified damage formula after you answer those questions.  Also, does the item already have anything in the damage formula?  If so, please post a screenshot of the Item window (from the database).
Actually there's 5. Four states or a chance to explode. I put them there because I wanted to have easier chances of getting the states rather than having it cause damage. Though I guess you're right, maybe I should change that?


I actually didn't think about the damage formula though!

Original thread: https://forums.rpgmakerweb.com/threads/probably-a-very-stupid-scripting-common-event-question.65698/