JavaScript questions that don't deserve their own thread

Narch

Veteran
Veteran
Joined
Jan 13, 2017
Messages
68
Reaction score
10
First Language
French
Primarily Uses
@Warilized Thanks for the help. Fixing the parentheses worked, and you gave me more tools to fiddle with in the future.
 
Joined
Jul 8, 2021
Messages
2
Reaction score
1
First Language
English
Primarily Uses
RMMV
Hello! I am trying to program a skill for an actor using Yanfly's Skill Core that causes an array of status effects to one target enemy. The more enemies there are in the enemy troop, the more status effects this skill causes. However, the skill produces no effect; I believe it's because I'm not properly storing the amount of enemy battlers in the corresponding variable. (I am quite new to JS and this, among many other things, still eludes me.)

Here's what I have in the skill's note field:

JavaScript:
<Custom Execution>
var group = $gameTroop.aliveMembers()[Math.floor($gameTroop.aliveMembers().length)];
if (group === 4){
target.addState(87);
target.addState(89);
target.addState(92);
target.addState(45);
} else if (group === 3){
target.addState(89);
target.addState(92);
target.addState(45);
} else if (group === 2){
target.addState(92);
target.addState(45);
} else if (group === 1){
target.addState(45);
}
</Custom Execution>

The group number maxes out at 4 because there are no combats in my game with more than 4 enemies in the troop.

If anyone could let me know how to best fix this I would greatly appreciate it!
 

ScorchedGround

Blizzards most disappointed fan (More than ever)
Veteran
Joined
Apr 12, 2020
Messages
620
Reaction score
832
First Language
German
Primarily Uses
RMMV
@LittleMisterFrosty

Firstly, <Custom Execution> does not work because at that point, there is no "target" to add states to. Instead, try <Post-Damage Eval> or <After Eval>.

In this case,
"<Post-Damage Eval>" would mean that the states only get applied when the skill hits.
"<After Eval>" would mean that the states get applied even if the skill misses.
So you would probably want <Post-Damage Eval> in this situation.

Secondly, your assignment of the "group" var is incorrect and way too complicated.
But to your credit, you had the right solution already hidden in there.

Try putting this into your skill instead:
I tidied it up a little to make it more readable, but you can just translate the changes to your notetag if you want to.

JavaScript:
<Post-Damage Eval>
var group = $gameTroop.aliveMembers().length;
if (group >= 1) {target.addState(45);}
if (group >= 2) {target.addState(92);}
if (group >= 3) {target.addState(89);}
if (group >= 4) {target.addState(87);}
</Post-Damage Eval>

Hope this helps!
 
Last edited:

Willibab

The Lord of Whackery
Veteran
Joined
Jun 22, 2017
Messages
247
Reaction score
807
First Language
Norwegian
Primarily Uses
RMMZ
I'd like a passive state or several if needed (that will be global) that does this.

- When your team kills an enemy, your whole team gains 5 mp and the enemies team all loses 5 mp.

- When the enemies team kills one of yours, they all gain 5 mp and your party all loses 5 mp.

Using the yanfly plugins.

I tried this as a start but couldn't get it to work :3

<Custom Establish Effect>
if (target.hp <= 0) {
party.gainMp(5);
}
<Custom Establish Effect>
 

ScorchedGround

Blizzards most disappointed fan (More than ever)
Veteran
Joined
Apr 12, 2020
Messages
620
Reaction score
832
First Language
German
Primarily Uses
RMMV
@Willibab

Not sure if this is the most efficient solution, but it does the trick for me:
Edit: wait hold on I forgot about the lose MP part, give me a second.
Edit2: Okay I fixed it, try this one:

JavaScript:
<Custom Conclude Effect>
if (target.hpRate() <= 0) {

if (user.isActor()) {
targetsFriendly = $gameParty.aliveMembers();
targetsEnemy = $gameTroop.aliveMembers();
} else {
targetsFriendly = $gameTroop.aliveMembers();
targetsEnemy = $gameParty.aliveMembers();
}

for (var i=0; i<targetsFriendly.length; i++) {targetsFriendly[i].gainMp(5);}
for (var i=0; i<targetsEnemy.length; i++) {targetsEnemy[i].gainMp(-5);}
}
</Custom Conclude Effect>
 
Last edited:

Willibab

The Lord of Whackery
Veteran
Joined
Jun 22, 2017
Messages
247
Reaction score
807
First Language
Norwegian
Primarily Uses
RMMZ
@Willibab

Not sure if this is the most efficient solution, but it does the trick for me:
Edit: wait hold on I forgot about the lose MP part, give me a second.
Edit2: Okay I fixed it, try this one:

JavaScript:
<Custom Conclude Effect>
if (target.hpRate() <= 0) {

if (user.isActor()) {
targetsFriendly = $gameParty.aliveMembers();
targetsEnemy = $gameTroop.aliveMembers();
} else {
targetsFriendly = $gameTroop.aliveMembers();
targetsEnemy = $gameParty.aliveMembers();
}

for (var i=0; i<targetsFriendly.length; i++) {targetsFriendly[i].gainMp(5);}
for (var i=0; i<targetsEnemy.length; i++) {targetsEnemy[i].gainMp(-5);}
}
</Custom Conclude Effect>
>

Works perfectly, thanks! :p
 

JPlaysan

知識は力なり
Veteran
Joined
Jul 4, 2019
Messages
85
Reaction score
54
First Language
English
Primarily Uses
RMMV
Hi there,

I'm wondering how I would go about implementing a cancel option in Yanfly's Save Core plugin to replace the delete option as I don't want to have a delete option there. I currently have Hime's pre-title events plugin and their save sync plugin which is great but there's an issue when I save in-game, return to the title screen, and if/when I choose to delete a save file it does so but I'm able to still access the save menu from continue which I don't want; instead, I'd like the message to show "no saved file data found". This doesn't happen to be an issue if there is no save file data, just when there is saved data and the player chooses to delete their save file for whatever reason.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,749
Reaction score
892
First Language
English
Primarily Uses
RMMV
Hi there,

I'm wondering how I would go about implementing a cancel option in Yanfly's Save Core plugin to replace the delete option as I don't want to have a delete option there.
Open up the plugin and go to line 776 (it should say 'delete' in a few places). At the beginning of the line, type // to comment it out, save the plugin, refresh it in your plugin manager, and save your project.

It will no longer show the Delete option, and a player can still press Escape to back out of the save screen (or file selection) as always.

(Incidentally, this is really a question for Plugin Support, as it is not pertaining generally to JavaScript at all :wink: If you have further questions about it, you should start your own thread).
 

FirestormNeos

Veteran
Veteran
Joined
Jul 23, 2019
Messages
199
Reaction score
155
First Language
English
Primarily Uses
RMMV
are the player and enemy stats (ATK, DEF, AGI, HP & MHP, TP) in the game floats or integers?
 

Beckx

Villager
Member
Joined
Mar 29, 2021
Messages
28
Reaction score
245
First Language
german
Primarily Uses
RMMV
Hey there!
I'm working on my own plugin / menu-windows and was wondering if anyone could point me in the direction where player movement is controlled, when a window is open?
I can't seem to find it, but i guess i'm just blind.

What I'd like to create is an inventory bar that is permanently open (active or inactive would be controlled via custom button or click "inside") so the player should be able to walk around the map with the window present / "open".

I think that should be possible, since it's basically nothing else but a permanently displayed gold window with some fancy stuff inside, so the basic functionality should be there, right?
I guess somewhere in some of the core functions hides a check that i'd need to overwrite, but like i said, can't seem to find it :D
 

tiabuni

Veteran
Veteran
Joined
Dec 27, 2020
Messages
59
Reaction score
21
First Language
Banana
Primarily Uses
RMMV
Is there any way to customize the actor portraits in the turn order row thingy in Yanfly's CTB battle system? The default look really clash with the look of my game. I ask as someone who can't really code.

 

MikeMakes

Veteran
Veteran
Joined
Sep 30, 2015
Messages
206
Reaction score
48
First Language
English
Primarily Uses
How do I hide certain states only when I'm in scene main menu, and not in scene equip menu or battle?

Code:
Game_BattlerBase.prototype.stateIcons = function() {
    return this.states().map(function(state) {
        if (!state.meta.hideIcon) return state.iconIndex;
    }).filter(function(iconIndex) {
        return iconIndex > 0;
    });
};
 
Last edited:

SuzuPazuzu

Villager
Member
Joined
Apr 19, 2012
Messages
16
Reaction score
3
First Language
English
Primarily Uses
RMMV
I'm using the Dragonbone integration for MV, and for some weird reason it won't play the various motion aside from damage and idle.

There's a function in here which returns the battler to idle which is what forces the battle back to idle after taking damage, but if I remove that, it stays stuck on the damage motion forever.

As far as I can tell -- aside from initialising, receiving damage, and automatically returning to idle after taking an attack -- the motions do not seem to be updating. I had thought this may be an issue with the animated SVEnemies plugin Yanfly provides, but non-dragonbones enemies animated through this that plugin work just fine. Something in the dragonbones plugin is not receiving and/or issuing regular changes to the battler motions.

I had seen people in this forum have vaguely similar problems but they were never resolved, and I'm wondering if there's a known solution to this issue I haven't found.

As an aside, I forced the auto return to idle function to set the battler to abnormal if they were dying (isDying), which worked, but the battler would then refuse to exit the dying motion. Which is what confirmed to me that it simply isn't updating the motions normally.

Any help appreciated, thanks.

Edit 1:
Putting console logs literally everywhere, it appears that, aside from the situations I listed above, the game is never trying to play a new motion at all. I'm not too familiar with what causes these calls to be made, but they are not - and yet it works fine outside of dragonbones enemies.

Edit 2:
As far as I can tell, it looks like whatever functions update motions aren't calling the specific function that plays the animations. I've searched through the dragonbones js file and am having trouble finding where exactly this would be called from. The scene manager is updating every tick properly it looks like. If anyone has any idea where to start I could potentially follow the breadcrumb trail backwards, but I'm not skilled enough to notice myself.
Aside, it doesn't appear to be a plugin conflict as every plugin that dragonbones isn't reliant on doesn't make a difference, and I haven't edited the plugins it's reliant on in such a way that would cause this.

Edit 3:
Resolved the issue with a workaround.
 
Last edited:

TheGentlemanLoser

"And when we fall, we will fall together..."
Veteran
Joined
Dec 30, 2020
Messages
300
Reaction score
323
First Language
English
Primarily Uses
RMMV
What line or line in rpg_scenes.js do I comment out to get the music not to fade out but to keep playing in Scene_Title when the player selects 'New Game'?

I've got deja vu asking this (like, maybe I asked twice before and kinda forgot?), and very weirdly I seem to have been able to do this on an older project by commenting out line 512 but this exact same approach isn't working on my newest project. Now of course the projects have totally different plugins in plugin orders but none of the plugins SHOULD be overwriting anything about how Scene_Title behaves. Thanks!
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,749
Reaction score
892
First Language
English
Primarily Uses
RMMV
What line or line in rpg_scenes.js do I comment out to get the music not to fade out but to keep playing in Scene_Title when the player selects 'New Game'?

I've got deja vu asking this (like, maybe I asked twice before and kinda forgot?), and very weirdly I seem to have been able to do this on an older project by commenting out line 512 but this exact same approach isn't working on my newest project. Now of course the projects have totally different plugins in plugin orders but none of the plugins SHOULD be overwriting anything about how Scene_Title behaves. Thanks!
That is the correct line to comment out to change that behavior - it works in my game.

Note that this just stops it from fading, it creates a much more obnoxious sudden stop just before the music for your first map starts to play...but that's up to you to get working the way you want.

If you have any plugins that affect your title screen at all, they may be overriding that function, so you might need to find the appropriate equivalent line there.

How do I hide certain states only when I'm in scene main menu, and not in scene equip menu or battle?

Code:
Game_BattlerBase.prototype.stateIcons = function() {
    return this.states().map(function(state) {
        if (!state.meta.hideIcon) return state.iconIndex;
    }).filter(function(iconIndex) {
        return iconIndex > 0;
    });
};
Try
Code:
if (!state.meta.hideIcon || !(SceneManager._scene instanceof Scene_Menu))

Is there any way to customize the actor portraits in the turn order row thingy in Yanfly's CTB battle system? The default look really clash with the look of my game. I ask as someone who can't really code.
This is really not the right place for that question, as it is not about using JavaScript innately. Also, the answer is in the plugin documentation. The very first notetags listed are:
Code:
<CTB Icon: x>
<CTB Border Color: x>
<CTB Background Color: x>
for customizing the icons.
 
Last edited:

TheGentlemanLoser

"And when we fall, we will fall together..."
Veteran
Joined
Dec 30, 2020
Messages
300
Reaction score
323
First Language
English
Primarily Uses
RMMV
Note that this just stops it from fading, it creates a much more obnoxious sudden stop just before the music for your first map starts to play...but that's up to you to get working the way you want.

Yeah, 'keep playing onto the first map' is what I'm shooting for, and that is how it behaves on this older project with that line commented out. I haven't heard the obnoxious sudden stop behavior yet. Really freaking weird. Again, the projects don't have the same exact plugins in the same order, but they do have like 90% of the same plugins in a logical order and none of those plugins should be overwriting anything in scene_title. Clearly there's something I'm misisng, but what?

Bizarre. I'll keep poking at it occasionally, it's definitely a minor annoyance, but mainly it's such a minor thing I've gotta keep working and ignore it for now.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
1,749
Reaction score
892
First Language
English
Primarily Uses
RMMV
Yeah, 'keep playing onto the first map' is what I'm shooting for, and that is how it behaves on this older project with that line commented out. I haven't heard the obnoxious sudden stop behavior yet. Really freaking weird. Again, the projects don't have the same exact plugins in the same order, but they do have like 90% of the same plugins in a logical order and none of those plugins should be overwriting anything in scene_title. Clearly there's something I'm misisng, but what?

Bizarre. I'll keep poking at it occasionally, it's definitely a minor annoyance, but mainly it's such a minor thing I've gotta keep working and ignore it for now.
What is going wrong? Are you getting a fade even with that command commented out? Do you have the first map either set to the same BGM or having no BGM? (I think having the same would be more likely to work)

But it's hard to troubleshoot without knowing precisely what is actually happening with your project. If you continue to have problems, probably best to post a separate thread about it.
 

SuzuPazuzu

Villager
Member
Joined
Apr 19, 2012
Messages
16
Reaction score
3
First Language
English
Primarily Uses
RMMV
Using YEP StatusMenuCore and I'd like to insert a line of white space between the Level, Health, & Mana parameters and the other parameters (where the red line in the following image is.)
How would I go about this?

c73d245f45696d7afbc857e75acccbc4.png
 

Synysterz

Warper
Member
Joined
Mar 5, 2019
Messages
1
Reaction score
0
First Language
french
Primarily Uses
RMMV
Hello ! I would like to make a skill that repeat himselve on an other enemy (randomly first to begin) if the target is killed by this skill. I've found this Script call ->
' $gameParty.members()[index].forceAction(skillId, targetIndex);
BattleManager.forceAction($gameParty.members()[index]); '
And did this ->View attachment 199046View attachment 199047
but it doesn't work actually, i've replaced index by 1 because my character is the party member 1, SkillId by 32 cause the skill have Id 32 and TargetIndex by -1 for targeting a random enemy.
Sorry if my english is bad.
Edit: I've found an other thread in which someone already ask this question, problem solved.
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

Happy Friday, y'all! I just got home from work and am sitting down with a nice cider, and I'm ready to chill and enjoy myself. Not sure if I'm gonna dive into any of my game-related projects or not tonight.... we'll see how I feel after unwinding for a bit I guess!
Just found out that mint tea made from chocolate mint tastes a bit like hot cocoa with candy cane stirred in. As I'm allergic to chocolate this makes me very happy.
It's special day for me tomorrow so time to vanish for 24 hours lol.
So Deltarune Chapter 2 is supposed to release today... if it's out already, has anyone played it? And I can't because I have a stinking Mac and not a Windows PC.

Forum statistics

Threads
115,140
Messages
1,087,554
Members
149,650
Latest member
devdezzy
Top