JavaScript questions that don't deserve their own thread

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
616
Reaction score
612
First Language
English
Primarily Uses
RMMZ
I have a question regarding regarding MZ and Visustella's Skills and States Core: I am following VisuStella MZ Action Sequence: Creating a Custom Skill Cost System With Variables and Pictures tutorial on the official blog and while I can allow the skill in question be usable only when the gauge is full (100 points) I am strugging at putting other limitations, mainly that two characters are in the battle party as I plan to use the gauge to create team attacks. The JS code provided in the tutorial is:
JavaScript:
<JS Skill Enable>
 enabled = $gameVariables.value(4) >= 4;
</JS Skill Enable>

As far as I can tell
JavaScript:
$gameParty.members()[n].isBattleMember()
is a function which checks if an actor is in the party but that's all I can tell.
I don't know what code you're using for your gauge, so I'll just pretend that the $gameVariables.value(4) >= 4 part accurately represents your gauge check. In that case, your note tag could look like this:

Code:
<JS Skill Enable>
enabled = $gameVariables.value(4) >= 4 && $gameActors.actor(x).isBattleMember() && $gameActors.actor(y).isBattleMember();
</JS Skill Enable>

You would replace x and y with the IDs of the two actors that you're talking about.


How do I see the list of actions inside queue during a battle in console?
Please clarify. Are you talking about the actions of a specific battler? Or the actions of all battlers? Or the actions of a specific range of battlers?
 
Last edited:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,976
Reaction score
12,519
First Language
English
Primarily Uses
RMMZ
I am trying to identify which actor an item is being used on. What I have done previously is put the code in the damage formula of the item, and have that item call up a common event which does the business. In case there's any query about how I'm calling the c.e., here is the command - straightforward bog standard method.
1659515256251.png

For the formula I have tried both

$gameVariables[27] = b.id; 0
and

$gameVariables.value[27] = b.id; 0

When selected and used on an actor nothing happens, the console shows 'null' and the item is consumed.
I have a text check on the common event to see if it is being called, and that check never shows, so it looks as if the whole thing is aborted at the start of the process.

Can anyone offer advice on what code to use for this purpose?

Thanks
 

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
616
Reaction score
612
First Language
English
Primarily Uses
RMMZ
I am trying to identify which actor an item is being used on. What I have done previously is put the code in the damage formula of the item, and have that item call up a common event which does the business. In case there's any query about how I'm calling the c.e., here is the command - straightforward bog standard method.
View attachment 236511

For the formula I have tried both

$gameVariables[27] = b.id; 0
and

$gameVariables.value[27] = b.id; 0

When selected and used on an actor nothing happens, the console shows 'null' and the item is consumed.
I have a text check on the common event to see if it is being called, and that check never shows, so it looks as if the whole thing is aborted at the start of the process.

Can anyone offer advice on what code to use for this purpose?

Thanks
You actually don't need JavaScript for that, and you don't need to do anything with the damage formula. MZ has a built-in way to obtain this information: Control Variables -> Game Data -> Last -> Last Target Actor ID

But if you do prefer to access it via script call, then: $gameTemp.lastActionData(4)
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,976
Reaction score
12,519
First Language
English
Primarily Uses
RMMZ
@Arthran I hadn't noticed that 'Last...' had been added since Ace. It seems I have more exploring of the event commands to do than I had thought.

This worked perfectly. Thank you very much.
 

CG-Tespy

Professional Persona Panderer
Veteran
Joined
Jan 5, 2019
Messages
71
Reaction score
47
First Language
Spanish
Primarily Uses
RMMV
Does anyone know any plugins that let you use message bubbles besides Galv's MessageStyles? I'm working on an update to a word-wrapper plugin that I want to have compatible with that kind of plugin. It works fine with Galv's, and I'd like to consider adding support for others.
 

stramin

Veteran
Veteran
Joined
Nov 4, 2012
Messages
342
Reaction score
171
First Language
spanish
Primarily Uses
N/A
What is wrong with this code? (Yanfly buff & States)

Code:
<Custom Apply Effect>
if(user.actorId==2)origin.addState(105);
</Custom Apply Effect>

if the actor id is 2, it should add State 105 to the caster of the state, but it doesn't do anything :(
 

stramin

Veteran
Veteran
Joined
Nov 4, 2012
Messages
342
Reaction score
171
First Language
spanish
Primarily Uses
N/A
Thank you so much!

problem solved
 

UmbrotheUmbreon

Legendary Umbreon
Veteran
Joined
Jan 25, 2015
Messages
66
Reaction score
14
First Language
English
Primarily Uses
RMMV
I don't believe this would need its own thread, but if I'm wrong please let me know. I've been trying to mess with how Escape and Defeat is handled in the javascript code. I searched for awhile and found out how to remove the text box that appears when you successfully escape/when you are defeated. However, I wanna go a bit further. For the Defeat function, I want it to not display a text notifying the player that an actor has fallen. I want to then set it up so when the last actor of the party has fallen, the screen flashes once and it waits 60 frames before going to the game over screen. I know how to get the screen flash to work, but I couldn't figure out how to implement the code to wait until the flash stopped before moving to the game over screen.

JavaScript:
BattleManager.processDefeat = function() {
    $gameScreen.startFlash([255, 0, 0, 225], 60);
    if (this._canLose) {
        this.replayBgmAndBgs();
    } else {
        AudioManager.stopBgm();
    }
    this.endBattle(2);
};

This is the code I have that allows the screen to flash, but it happens after announcing the final actor has fallen. I want it to happen when the final actor falls, and without displaying the message they've fallen (currently I only have one actor in this project, but I plan to use this method of defeat/escape in future projects too.) So the questions I am asking are how to make the flash happen when the final actor falls instead of afterwards, how to remove the message saying they've fallen, and how do I make it wait 60 frames before moving to the game over screen once the party is defeated?
 

Nate_Tillern

Villager
Member
Joined
Apr 14, 2019
Messages
19
Reaction score
1
First Language
English
Primarily Uses
RMMV
Does someone know what the syntax would be for checking the scope of a skill in Yanfly's Buffs and States plugin?

Basically I have coded a "cover ally" state which redirects damage aimed at the actor with the state to the actor who applied the state. I would like to include a conditional before the damage redirection that checks whether the scope of the attack is multi targeting or not (and if so, not redirect damage).

Code:
<Custom React Effect>
if (SCOPE OF USED SKILL IS NOT MULTI TARGETING) {
  var dmg = value
  origin.gainHp(-dmg);
  origin.startDamagePopup();
  origin.clearResult();
  value = 0
}
</Custom React Effect>
 

Super015

Veteran
Veteran
Joined
May 12, 2013
Messages
57
Reaction score
9
First Language
Italian
Primarily Uses
RMMV
Hi, I'm trying to change the code to not interrupt the battle BGM when I don't set any ME victory.
I tried to change some things in "rpg_managers.js" and "rpg_scenes" but I can't get the desired result.
I belive that somewhere in the code there's a piece of code that blocks my battle BGM when I win, but I just can't find it!
What I managed to find is the line that makes me start the ME victory and I will take a conditional branch to activate or exclude it based on a switch (or, even better, if the system does not find any ME set in the database).
All this to ensure that in some maps (not all) there is no audio transition between map and battle.
I apologize for any spelling mistakes, I'm not very good at English but I always try to improve... :kaoswt2:
 

Arctica

Veteran
Veteran
Joined
Jul 19, 2021
Messages
214
Reaction score
323
First Language
----
Primarily Uses
N/A
I don't believe this would need its own thread, but if I'm wrong please let me know. I've been trying to mess with how Escape and Defeat is handled in the javascript code. I searched for awhile and found out how to remove the text box that appears when you successfully escape/when you are defeated. However, I wanna go a bit further. For the Defeat function, I want it to not display a text notifying the player that an actor has fallen. I want to then set it up so when the last actor of the party has fallen, the screen flashes once and it waits 60 frames before going to the game over screen. I know how to get the screen flash to work, but I couldn't figure out how to implement the code to wait until the flash stopped before moving to the game over screen.

JavaScript:
BattleManager.processDefeat = function() {
    $gameScreen.startFlash([255, 0, 0, 225], 60);
    if (this._canLose) {
        this.replayBgmAndBgs();
    } else {
        AudioManager.stopBgm();
    }
    this.endBattle(2);
};

This is the code I have that allows the screen to flash, but it happens after announcing the final actor has fallen. I want it to happen when the final actor falls, and without displaying the message they've fallen (currently I only have one actor in this project, but I plan to use this method of defeat/escape in future projects too.) So the questions I am asking are how to make the flash happen when the final actor falls instead of afterwards, how to remove the message saying they've fallen, and how do I make it wait 60 frames before moving to the game over screen once the party is defeated?
You may try working with this:

Code:
Game_Actor.prototype.performCollapse = function() {
    Game_Battler.prototype.performCollapse.call(this);
    if ($gameParty.inBattle()) {
        SoundManager.playActorCollapse();
    }
};
(note: this is from MZ, but MV should have a similar method inside its rmmv_objects.js file)
 

Sagi007

Veteran
Veteran
Joined
Jul 29, 2015
Messages
36
Reaction score
3
First Language
nederlands
Primarily Uses
RPGMaker MV:
Want to set variable 15 to be equal to 2nd partymember's actor id.
pretty sure it something like $gameVariables.setValue(15, something);
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,571
Reaction score
3,635
First Language
English
Primarily Uses
RMMV
RPGMaker MV:
Want to set variable 15 to be equal to 2nd partymember's actor id.
pretty sure it something like $gameVariables.setValue(15, something);
Code:
$gameVariables.setValue(15, $gameParty.members()[1].actorId());

Also, just to mention it, depending on how you're using this there's no need to use JavaScipt.

You can use event commands to do Control Variable -> Game Data -> Party -> Member #2
 

UmbrotheUmbreon

Legendary Umbreon
Veteran
Joined
Jan 25, 2015
Messages
66
Reaction score
14
First Language
English
Primarily Uses
RMMV
You may try working with this:

Code:
Game_Actor.prototype.performCollapse = function() {
    Game_Battler.prototype.performCollapse.call(this);
    if ($gameParty.inBattle()) {
        SoundManager.playActorCollapse();
    }
};
(note: this is from MZ, but MV should have a similar method inside its rmmv_objects.js file)

I found the code and it did what I wanted with actor collapsing and playing the screen flash. Now I am struggling with the defeat scene being handled. I want it to wait ten frames before fading the BGM, then wait 60 frames to move to the Game Over screen.

JavaScript:
BattleManager.processDefeat = function() {
    if (this._canLose) {
        this.replayBgmAndBgs();
    } else {
        interpreter.wait(10);
        AudioManager.stopBgm();
        interpreter.wait(60);
    }
    this.endBattle(2);
};

I feel like I'm missing something with how I'm adding wait time into the coding. I get a reference error saying "interpreter is not defined" so I must be leaving out something. The problem is I don't know what
 

UmbrotheUmbreon

Legendary Umbreon
Veteran
Joined
Jan 25, 2015
Messages
66
Reaction score
14
First Language
English
Primarily Uses
RMMV
Try $gameMap._interpreter instead.
So it no longer gives me an error, but I set the wait time to be 600 frames (to make sure it actually worked), and it doesn't. It still just goes right to the game over screen without waiting at all.

I probably should clarify the battle system I'm using a bit more. It's typical side view turn based RPG that uses a battle background.
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

DamageEvil_6.png added!
index.php

Sometimes I wonder why I still try and recruit others to help with my games. It never works.
ScreenShot_10_3_2022_4_27_17.png
welp, thanks to Luna MV, I was able to add the Balloon as a window... thus allowing me to edit the font color and outline... so now it looks like comic bubbles above characters. I have NO idea why I couldn't get this to work through more conventional means, but here we are.
CUTE CUTE CUTE.gif
I cannot cease doing cute art
War and Wonder is a 100% choice-based open-world visual novel.
1664821313732.png
1664821466359.png
1664821547746.png

Forum statistics

Threads
125,760
Messages
1,173,295
Members
164,918
Latest member
DarkEchoid
Top