How to script a Party Member Menu check

I've been at this for hours and can't seem to find a solution. I'm writing out a formula for an item and it's supposed to change a variable, which it does, but I only want it to change the variable when I consume the item for the 1st actor, not the actors in slot 2 or 3. I've written this formula but I have no clue what IF statement I should put in there to determine if the 1st actor is consuming the item.

1703992589708.png


Code:
if (v[17] < 18) { v[17]+=1 } if (v[17] > 18) { v[17]=18 }

Any idea on what I'd use for the first IF statement? I've already tried the following without success.

Code:
if ($gameParty.menuActor().index() == 1)
if ($gameParty._menuActorId === 1)
Why go through the stuff with menu indices and stuff? Damage formulae use b whether you're using them in battle or the menu.

Code:
if (b.index()==0)

or
Code:
if (b == $gameParty.leader())

Also:
Code:
if (v[17] < 18) { v[17]+=1 } if (v[17] > 18) { v[17]=18 }
can just be
Code:
v[17] = Math.min(18, v[17]+1)
Why go through the stuff with menu indices and stuff? Damage formulae use b whether you're using them in battle or the menu.

Code:
if (b.index()==0)

or
Code:
if (b == $gameParty.leader())
Apparently taking a break and saying a little prayer... and stumbling across a post that @Trihan made 2 years ago was the solution.

Code:
if $gameParty._targetActorId == 1
was the correct answer to what I was trying to do.

Here's the completed formula for the item. W00t!!
Code:
if ($gameParty._targetActorId == 1 && v[17] < 18) { v[17]+=1 } if (v[17] > 18) { v[17]=18 }
There's nothing wrong with that, but just for the sake of anyone else who may come across the thread, the stuff with b also works perfectly - just tested it 😉
There's nothing wrong with that, but just for the sake of anyone else who may come across the thread, the stuff with b also works perfectly - just tested it 😉
I think there's a learning opportunity for me here. Why does "b" work and not "a", and what's the difference? My apologies in advance for my Olympian-sized newbness. 😳
I think there's a learning opportunity for me here. Why does "b" work and not "a", and what's the difference?
From holding your mouse over the damage formula box:
1703995503424.png


So, logically, straight off, you would want b because that's the target of the skill; the object being affected by it.

As for why you can't reference a outside of battle, just look at the interface - you select an item from the menu, then who you're using it on. There is no step where you select which party member is using the item.

So if there's no user, there is no a.

But you're selecting a target, so there is a b. You can also use target actor ID, but depending on your purpose it would be more convoluted when b is a direct reference to the actual actor.

Also, I'll mention that your code in post 3 may not be the solution to the question you asked in your first post.

You asked how to make sure it's "the 1st actor, not the actors in slot 2 or 3" - when you talk about slots, I'm assuming you mean the members of the party. That you only want it to work on the actor who is the party leader.

When you do targetActorId == 1, that's checking for actor ID 1, regardless of what position they are in the party.

So, I don't know if that's what you actually want and you just asked it confusingly initially. But if you do want that, then the shortest way to type what you want to do is:
Code:
if (b.actorId() == 1) v[17] = Math.min(18, v[17] + 1)
If my interpretation of your first question is correct and you're talking about their position in the party, then you would do:
Code:
if (b.index() == 0) v[17] = Math.min(18, v[17] + 1)
Why does "b" work and not "a", and what's the difference?
a is the placeholder for the skill user, b is the placeholder for the skill target.
that is why in the regular damage formula a.atk is the atttack value of the skill user and b.def is the defense value of the skill target.

and items and skills are internally handled the same way.

EDIT: ninja'd
@ATT_Turan & @Andar
Wow Turan, thank you for schooling me, I really appreciate it. I'm sure others will benefit greatly from your thorough explanation. Both of you, thank you so much! 😎
As for why you can't reference a outside of battle, just look at the interface - you select an item from the menu, then who you're using it on. There is no step where you select which party member is using the item.
I don't think it matters in this case, but technically every action has a user, a.k.a. subject. When using items from the menu, the core scripts (Scene_Item.prototype.user) pick the party member with the highest PHA (Pharmacology) Sp-param.
When using items from the menu, the core scripts (Scene_Item.prototype.user) pick the party member with the highest PHA (Pharmacology) Sp-param.
Oh, that thing no one uses! 😉

But good to know, thank you.
Oh, that thing no one uses! 😉

But good to know, thank you.
I freaked out when I read it uses the Pharma parameter but then I saw the default is 100% so I left it alone. Like most, my project doesn't use pharma either.

Again, thanks for the help guys. 😀

Original thread: https://forums.rpgmakerweb.com/threads/how-to-script-a-party-member-menu-check.164300/