Question/s about scriptcall [in regards to transparency]

I was recently trying to help troubleshoot a solution for another user, and in the process, I was trying to use the following:

$gameParty.allMembers()._transparency = true
$gameTroop.allMembers()._transparency = true

I was using this in console (for some troubleshooting ideas), and my thought-process was it would make the party-members all transparent in battle [when true], and the troops all transparent in battle [when true]. Neither seemed to 'work' (they did nothing); can someone more experienced explain?

Secondly, the following, to me, seem to both have the same usage, is this correct, or is there something different about them?

$gamePlayer.setTransparent(true)
$gamePlayer._transparent = true;

Lastly, I remember a tutorial a while back going over opacity, transparency, and another thing that changed the way the player characters look. It reminded me of the Final Fantasy 3/6 (for super nintendo) skill 'Vanish' where the sprite became outlined and a unique look. I can't remember what it is called, as I saw this tutorial years ago and forget it, and was hoping someone knows what it is called in the RMMV code? They specifically used it by typing like 1 line of code into console and showing it happen to the character sprite on the map [in this tutorial], meaning I'm near 100% certainty it's default RMMV java-script.

Thank you for your time in helping me trying to figure out these things.
$gameParty.allMembers()._transparency = true
$gameTroop.allMembers()._transparency = true
These return undefined. I guess they're not functions.
$gamePlayer.setTransparent(true)
$gamePlayer._transparent = true;
These two are the same.
The problem with the first code is that you were defining the list of party members to be transparent, but that's not the same thing as making the party members inside that list transparent.
To do what you want you'll need to write a code that runs through the list and set each member as transparent:

$gameParty.allMembers().forEach(function(member){ member._transparency = true; });
I'd recommend using setTransparent as opposed to setting the property value directly. By default the two approaches are identical, but a plugin might alias it to do something when a character turns visible/invisible. That's why the method exists! 🙂

No idea about your last point, though. Do you think you could find a screenshot or something? 😅
@Hudell Thank you very much for explaining what was happening. To be quite forward with you, I'm not exactly sure how the follow-up would be for me applying your code. Would it be altering a .json file, or can I get the desired results testing in console (and at a later date, using a script for it in actual game)? I'm learning java-script still, so I'm not anywhere near an expert. If you still have time to explain, I'd be more than happy to try and understand your advice.

No idea about your last point, though. Do you think you could find a screenshot or something? 😅

I'll try to remember then that setTransparent is the more intelligent approach -- thank you for clarifying. And unfortunately, the video was from maybe 4 years ago (and I can't even remember how I came across it), and the speaker of that tutorial was speaking in a foreign language, but coding in English, so I could see how they use console still, etc.. The only code I copied down from the tutorial was $game_player.direction == 8. They were showing different ways to alter the player-character using console in MV (like direction, transparency, opacity, etc.).
It should work in the console or using the Script Call command on an event.
It should work in the console or using the Script Call command on an event.

@Hudell If I'm being a mega-noob, my apologies, but I haven't got any desired results from applying it into the console. During battle I entered the following into console:
$gameParty.allMembers().forEach(function(member){ member._transparency = true; });

It says "Undefined" afterwards. If I input:
$gameParty.allMembers()._transparency = true
It says True. Then if I input:
$gameParty.allMembers().forEach(function(member){ member._transparency = true; });
It says "Undefined" still.

Like I said, I'm still learning, so apologies if I'm being a dumby. I tried it with a common event, didn't see any results either. Made an Event (NPC), added the script to it, used action button to start it, then started battle, didn't see anything happen either. I'm presuming something isn't working correctly because of the Undefined? Thank you for any further advice.
In your initial code you also set the $gameTroop list to transparent, so maybe that's what you're missing?

$gameParty.allMembers().forEach(function(member){ member.setTransparent(true) });
$gameTroop.allMembers().forEach(function(member){ member.setTransparent(true) });

I'm not familiar with the battle system so I don't know if it uses $gameParty or $gameTroop, but what you wanted to do in that sample code is achievement with those two lines. The result being undefined is correct too.
@Hudell This is what I am getting returned in console now.

$gameParty.allMembers().forEach(function(member){ member.setTransparent(true) });
Uncaught TypeError: member.setTransparent is not a function
at <anonymous>:1:58
at Array.forEach (<anonymous>)
at <anonymous>:1:25

$gameTroop.allMembers().forEach(function(member){ member.setTransparent(true) });
Uncaught TypeError: member.setTransparent is not a function
at <anonymous>:1:58
at Array.forEach (<anonymous>)
at <anonymous>:1:25


I was under the impression $gameTroop is for enemies, and $gameParty is for the party members (I may be very wrong on this).
So I looked at the actual code on MV now:
$gameParty has a list of actors and $gameTroops has a list of enemies. What you actually need to change is the characters, so neither of them works.

This is what you would need to do:

$gamePlayer.setTransparent(true);
$gamePlayer._followers.forEach(function(follower) { follower.setTransparent(true); });
@Hudell As per your instructions, I have entered them in and tried my best again. I am getting undefined, the same as before, and it doesn't seem to 'work as intended' in battle, because it's not doing anything.

I've used $gamePlayer.setTransparent(true) on the world-map before to make the entire party transparent on the world map. But this does not work in battle (nor does adding
$gamePlayer._followers.forEach(function(follower) { follower.setTransparent(true); });
seem to have any change on it either), and was part of the reason I felt it best to inquire by way of a thread, to try and learn how it actually works so I can be fully capable of using transparency down the line, in battle if needed. Obviously, others can reference this thread if/when a solution is found which helps everyone learn.

If a solution comes to fruition, I'd say it might be helpful if the discrepancy can be made as to what the working code is to apply it to the enemy/enemies, and what code makes it apply to the party. Also, does it have to apply to the entire enemies/party, or is it an easy answer to provide how to make it only apply to say members 1,3 but not 2,4.

I appreciate the patience to try and help I [and ultimately the community] find a solution for this.
First, to clarify: Array.forEach does not have a return value, hence the undefined you're seeing in the console. 😮‍💨

I did some revision of the game code and it looks like:
  • Map characters inherit from Game_CharacterBase, which offers the setTransparent method. Party followers automatically have many of their properties synced to the player each frame:
    Spoiler: rpg_objects.js excerpt
    JavaScript:
    Game_Follower.prototype.update = function() {
        Game_Character.prototype.update.call(this);
        this.setMoveSpeed($gamePlayer.realMoveSpeed());
        this.setOpacity($gamePlayer.opacity());
        this.setBlendMode($gamePlayer.blendMode());
        this.setWalkAnime($gamePlayer.hasWalkAnime());
        this.setStepAnime($gamePlayer.hasStepAnime());
        this.setDirectionFix($gamePlayer.isDirectionFixed());
        this.setTransparent($gamePlayer.isTransparent());
    };
    As such, you can't set their transparency individually, but as you've mentioned, you can make them all vanish using $gamePlayer.setTransparent(true); (or, equivalently, using the Change Transparency event command).

  • Battlers inherit from Game_BattlerBase and Game_Battler, neither of which provide a setTransparent method by default. One thing you can do natively is "hide" a battler, which basically removes them from battle (by default this is used for escapes and mid-battle appearances):
    JavaScript:
    $gameParty.leader().hide();  // party leader vanishes
    $gameParty.leader().escape();  // hide, remove remaining actions, play escape SE
    $gameParty.members()[2].show();  // 3rd party member reappears (if hidden)
    $gameTroop.members().forEach(function(m) { m.escape(); });  // all enemies escape
    However, since hidden battlers are essentially gone from the battle, hiding all members of a unit will cause a victory/defeat.

    One level deeper: by default the battler sprite opacity is impacted by various effects (hide, appear, collapse, blink), making any manual changes of enemy sprite opacity last only until the next opacity-changing effect (e.g. blink on getting hit). Actors seem OK in that respect, though! You can use script calls like this when on the battle screen:
    JavaScript:
    // Make party leader battler 50% opaque
    SceneManager._scene._spriteset._actorSprites[0].opacity = 128;
    // Make all party battlers invisible
    SceneManager._scene._spriteset._actorSprites.forEach(function(m) { m.opacity = 0; });
    // Make first troop member's battler 75% opaque until next opacity-altering effect
    SceneManager._scene._spriteset._enemySprites[0].opacity = 192;
    It's kinda ugly because the sprites aren't designed to be accessed from a global scope. 😴

The only code I copied down from the tutorial was $game_player.direction == 8. They were showing different ways to alter the player-character using console in MV (like direction, transparency, opacity, etc.).
$game_player is from VX Ace; in MV (as you've correctly stated) it's $gamePlayer. It may also be worth noting that plugins are perfectly capable of adding new script calls. 🙂
-Trimmed-
This was a fantastic presentation on explaining how some of these things work. This is how I learn best -- your //comments explaining after each code really helped make it clear how everything is occurring. The troubleshooting I was trying to circumvent for the other user was in regards to them having difficulty with desired results by setting opacity to 0, so I thought hmm -- wonder if just setting transparency ON for the desired troops/members would work (although, I'm not sure if opacity 0 is the same exact thing basically as transparency ON), and it got me to making this thread thinking if transparency can be used in the battle itself (obviously it was a little more complicated than a quick band-aid). Also, when you go into explaining about enemy opacity resetting, that's something I would have never known, so these teachings are useful bits of knowledge, perfect.


$game_player is from VX Ace; in MV (as you've correctly stated) it's $gamePlayer. It may also be worth noting that plugins are perfectly capable of adding new script calls. 🙂

Hey, this is a great find. I'm sorry on the confusion for that, that's my mistake -- I actually looked back to see when I created the file that I put that in, and I created it 2 days after MV released (I presumed it was in regards to MV; I do own VXAce as well, and used it a little before I got MV, so chances are that tutorial was actually on VXAce then, getting me prepared for MV). As I noted, it helped teach the watcher about how the character movement worked, opacity, transparency, etc.. So whatever that 'Vanish' thing was that outlines that character, it was probably VXAce then. I'm not sure if you'd be familiar with it then, or if MV even has it. I genuinely don't believe any plugins were involved though, as I was using the console alongside (I had 0 plugins) so that I myself could see the changes for how the tutorial's instructions were applying in the console/game. Great perception you got, and I'll try to tinker around and see the interesting things I can do with what you just taught ^_^

Original thread: https://forums.rpgmakerweb.com/threads/question-s-about-scriptcall-in-regards-to-transparency.125306/