Specific item boosts toward specific team members, script maybe?

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,371
Reaction score
1,542
First Language
English
Primarily Uses
RMMV
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);
}
 
Last edited:

evmaster

Cats are the best.
Veteran
Joined
Sep 1, 2015
Messages
513
Reaction score
730
First Language
English
Primarily Uses
RMMV
Thanks! I'll go try it out. You should go get some sleep now, this can wait until tomorrow. (Or next week etc, lol)
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
483
Reaction score
211
First Language
English
Primarily Uses
RMMV
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.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,371
Reaction score
1,542
First Language
English
Primarily Uses
RMMV
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.
 

evmaster

Cats are the best.
Veteran
Joined
Sep 1, 2015
Messages
513
Reaction score
730
First Language
English
Primarily Uses
RMMV
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.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,371
Reaction score
1,542
First Language
English
Primarily Uses
RMMV
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
 

evmaster

Cats are the best.
Veteran
Joined
Sep 1, 2015
Messages
513
Reaction score
730
First Language
English
Primarily Uses
RMMV
◆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
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,371
Reaction score
1,542
First Language
English
Primarily Uses
RMMV
After the variable settings, add "targetActor.addParam(stat, raise);" back in.
 

evmaster

Cats are the best.
Veteran
Joined
Sep 1, 2015
Messages
513
Reaction score
730
First Language
English
Primarily Uses
RMMV
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! :D (I don't want to keep bothering you guys)
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,371
Reaction score
1,542
First Language
English
Primarily Uses
RMMV
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]!
 

evmaster

Cats are the best.
Veteran
Joined
Sep 1, 2015
Messages
513
Reaction score
730
First Language
English
Primarily Uses
RMMV
Where would I place that though if the Script part is full?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,371
Reaction score
1,542
First Language
English
Primarily Uses
RMMV
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.
 

evmaster

Cats are the best.
Veteran
Joined
Sep 1, 2015
Messages
513
Reaction score
730
First Language
English
Primarily Uses
RMMV
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.
 

evmaster

Cats are the best.
Veteran
Joined
Sep 1, 2015
Messages
513
Reaction score
730
First Language
English
Primarily Uses
RMMV
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?
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,318
Reaction score
1,199
First Language
English
Primarily Uses
RMMV
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]!
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,371
Reaction score
1,542
First Language
English
Primarily Uses
RMMV
That's exactly right.
 

evmaster

Cats are the best.
Veteran
Joined
Sep 1, 2015
Messages
513
Reaction score
730
First Language
English
Primarily Uses
RMMV
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....
 

evmaster

Cats are the best.
Veteran
Joined
Sep 1, 2015
Messages
513
Reaction score
730
First Language
English
Primarily Uses
RMMV
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.
 

evmaster

Cats are the best.
Veteran
Joined
Sep 1, 2015
Messages
513
Reaction score
730
First Language
English
Primarily Uses
RMMV

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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Just a heads-up that Slip into Ruby and Jump into Javascript might be a bit slow for now while I'm on the team porting the YEP plugins to VisuStella's MZ suite.
So I managed to build a teleport skill. You can see the progression in the development topic
https://forums.rpgmakerweb.com/index.php?threads/in-dev-multi-hit-target-selection.125049/

Here's how it looks:


But the real question is, can I pull off FF8?

I love these little slime battlers. Really wish I could find more animated ones :'(
The curse of retail: you get ideas, you want to make something with those ideas, but because you're always at friggin' work you can't actually do anything with them.
Quexp wrote on lumimae's profile.
Welcome! :)

Forum statistics

Threads
100,630
Messages
977,962
Members
132,248
Latest member
Dealdeg
Top