Specific item boosts toward specific team members, script maybe?

I was right, let is entirely locally-scoped so those variables don't exist outside of the if statement block. Change it to

Code:
if (!$gameParty.inBattle()) {
  let stats = ["HP", "MP", "ATK", "DEF", "MATK", "MDEF", "AGI", "LUK"];
  let targetActor = $gameParty.targetActor();
  if (targetActor.actorId() === 1) {
    var stat = 2;
    var raise = 10;
    var message = "%1 liked this item and gained %2 %3!".format(targetActor.name(), raise, stats[stat]);
  } else {
    var stat = Math.randomInt(stats.length);
    var raise = Math.randomInt(2) + 1;
    var message = "%1 gained %2 %3.".format(targetActor.name(), raise, stats[stat]);
  }
  targetActor.addParam(stat, raise);
  $gameMessage.add(message);
}
Thanks! I'll go try it out. You should go get some sleep now, this can wait until tomorrow. (Or next week etc, lol)
Just a note that if you plan to translate your game into another language, you should find another way to display the message. What I'd recommend is storing the important details in variables and use a normal message event to display the actual message - something like this (incomplete) code:

JavaScript:
$gameVariables.setValue(10, targetActor.name());
$gameVariables.setValue(11, raise);
$gameVariables.setValue(12, stats[stat]);

Replacing 10, 11, and 12 with the IDs of three unused variables. This would replace the $gameMessage.add line.

Even if you don't plan to translate your game, it might be a little easier for you to edit in the future if the message is in an actual message command.

A more complete (though not copy-pastable) version:

Code:
◆If:Script:!$gameParty.inBattle()
  ◆Script:let stats = ["HP", "MP", "ATK", "DEF", "MATK", "MDEF", "AGI", "LUK"];
  :Script:let targetActor = $gameParty.targetActor();
  :Script:let stat, raise;
  :Script:if (targetActor.actorId() === 1) {
  :Script:  stat = 2; raise = 10;
  :Script:} else {
  :Script:  stat = Math.randomInt(stats.length);
  :Script:  raise = Math.randomInt(2) + 1;
  :Script:}
  :Script:$gameVariables.setValue(10, targetActor.name());
  :Script:$gameVariables.setValue(12, stats[stat]);
  :Script:$gameVariables.setValue(11, raise);
  ◆Text:None, Window, Bottom
  :Text:\v[10] gained \v[11] \v[12]!
  ◆
:End

EDIT: @Trihan - Yeah, I was going to mention that let misuse... but also, I think that script isn't going to fit into the limited size of the script command box? The above example only just barely fits.
Just a note that if you plan to translate your game into another language, you should find another way to display the message. What I'd recommend is storing the important details in variables and use a normal message event to display the actual message - something like this (incomplete) code:

JavaScript:
$gameVariables.setValue(10, targetActor.name());
$gameVariables.setValue(11, raise);
$gameVariables.setValue(12, stats[stat]);

Replacing 10, 11, and 12 with the IDs of three unused variables. This would replace the $gameMessage.add line.

Even if you don't plan to translate your game, it might be a little easier for you to edit in the future if the message is in an actual message command.

A more complete (though not copy-pastable) version:

Code:
◆If:Script:!$gameParty.inBattle()
  ◆Script:let stats = ["HP", "MP", "ATK", "DEF", "MATK", "MDEF", "AGI", "LUK"];
  :Script:let targetActor = $gameParty.targetActor();
  :Script:let stat, raise;
  :Script:if (targetActor.actorId() === 1) {
  :Script:  stat = 2; raise = 10;
  :Script:} else {
  :Script:  stat = Math.randomInt(stats.length);
  :Script:  raise = Math.randomInt(2) + 1;
  :Script:}
  :Script:$gameVariables.setValue(10, targetActor.name());
  :Script:$gameVariables.setValue(12, stats[stat]);
  :Script:$gameVariables.setValue(11, raise);
  ◆Text:None, Window, Bottom
  :Text:\v[10] gained \v[11] \v[12]!
  ◆
:End

EDIT: @Trihan - Yeah, I was going to mention that let misuse... but also, I think that script isn't going to fit into the limited size of the script command box? The above example only just barely fits.

It fits with 1 line left. 🙂 I made sure.
Wow! I never expected this much help. Thanks so much! (You guys are awesome!)

I went ahead and put in the Conditional Branch and then Script. But when I tested this, there are no actual stat gains. Everything else seems to be working fine. Not sure what to do.
Paste what you have now?

It's worth noting that Solar_Flare's rewrite seems to have forgotten to include the line that actually raises the stat. XD
◆If:Script:!$gameParty.inBattle()
◆Script:let stats = ["HP", "MP", "ATK", "DEF", "MATK", "MDEF", "AGI", "LUK"];
: :let targetActor = $gameParty.targetActor();
: :let stat, raise;
: :if (targetActor.actorId() === 3) {
: :stat = 2; raise = 10;
: : } else {
: :stat = Math.randomInt(stats.length);
: :raise = Math.randomInt(2) + 1;
: : }
: :$gameVariables.setValue(10, targetActor.name());
: :$gameVariables.setValue(12, stats[stat]);
: :$gameVariables.setValue(11, raise);
◆Text:None, Window, Bottom
: :\v[10] gained \v[11] \v[12]!
◆
:Else
◆Text:None, Window, Bottom
: :everyone else random stat gain
◆
:End
After the variable settings, add "targetActor.addParam(stat, raise);" back in.
After the variable settings, add "targetActor.addParam(stat, raise);" back in.

I just tried that. It's not going in the last line. Suggestions?

Edit: I moved the line "let stats raise" to the same line as "let target actor" and that seems to be doing the trick!
Thanks so much everyone~!!

Edit2: Oh, even though it is fine the way it is. I would like for a custom message for the boosted stats. (The john liked this item, gained 10+ kind of thing) Is there a way to do that or is there not enough script? I'm not sure where to place it as a message command...

But if not, this is fine the way it is. I really appreciate this! 😀 (I don't want to keep bothering you guys)
You could achieve that using another variable:

Code:
let stats = ["HP", "MP", "ATK", "DEF", "MATK", "MDEF", "AGI", "LUK"], targetActor = $gameParty.targetActor(), stat, raise;
if (targetActor.actorId() === 3) {
  stat = 2; raise = 10;
  $gameVariables.setValue(9, " likes this item and ");
} else {
  stat = Math.randomInt(stats.length); raise = Math.randomInt(2) + 1;
  $gameVariables.setValue(9, " ");
}
$gameVariables.setValue(10, targetActor.name());
$gameVariables.setValue(12, stats[stat]);
$gameVariables.setValue(11, raise);

Then the message would be

\v[10]\v[9]gained \v[11] \v[12]!
Where would I place that though if the Script part is full?
Where would I place that though if the Script part is full?

Paste it as I've written it; I've condensed some lines onto one line to make more room.
Well, I've copied and pasted but the special message for "liked this item" does not come into display. But everything else seems to work.

Edit2: I'm sorry that I am not understanding.
I'm still unable to create a specific message for team members who get bonus effects from the item(s). Can anyone please tell me how to include this?
Petty sure you just need to copy paste the part he provided into a standard text message box. This part:

Code:
\v[10]\v[9]gained \v[11] \v[12]!
That's exactly right.
Maybe I am misunderstanding. Maybe I wasn't clear, that's my fault. What I mean is, two messages.

One that says
\v[10]\v[9]gained \v[11] \v[12]!


And the second that says

"character liked this item! Plus 10,etc"

Edit1: i'll go test this out again and come back. Probably my fault anyways.

Edit2: Nope. The message "liked this item" never displays....
I'd like to finish what I've asked/started here. Seems a waste in help if I just give up?

As I've said, the character specific message does not display.
jzIc2H6.png


The "liked this item and" line is what I'm talking about. The last 3 times I've tested this, this line does not show up at all during in game test play.

I guess I will try again and update here.

Original thread: https://forums.rpgmakerweb.com/threads/specific-item-boosts-toward-specific-team-members-script-maybe.124060/