JavaScript questions that don't deserve their own thread

Narch

Regular
Regular
Joined
Jan 13, 2017
Messages
89
Reaction score
12
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
8
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 (They keep going)
Regular
Joined
Apr 12, 2020
Messages
826
Reaction score
1,300
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
Regular
Joined
Jun 22, 2017
Messages
795
Reaction score
2,668
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 (They keep going)
Regular
Joined
Apr 12, 2020
Messages
826
Reaction score
1,300
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
Regular
Joined
Jun 22, 2017
Messages
795
Reaction score
2,668
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

日本語学習者
Regular
Joined
Jul 4, 2019
Messages
122
Reaction score
91
First Language
English
Primarily Uses
RMMZ
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
Regular
Joined
Jul 2, 2014
Messages
12,654
Reaction score
11,167
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

Regular
Regular
Joined
Jul 23, 2019
Messages
291
Reaction score
262
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
246
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
 

DrBuni

Regular
Regular
Joined
Dec 27, 2020
Messages
234
Reaction score
144
First Language
.
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

Regular
Regular
Joined
Sep 30, 2015
Messages
215
Reaction score
50
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
20
Reaction score
4
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..."
Regular
Joined
Dec 30, 2020
Messages
373
Reaction score
506
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
Regular
Joined
Jul 2, 2014
Messages
12,654
Reaction score
11,167
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..."
Regular
Joined
Dec 30, 2020
Messages
373
Reaction score
506
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
Regular
Joined
Jul 2, 2014
Messages
12,654
Reaction score
11,167
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
20
Reaction score
4
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

Larvae.gif
They're larvae, not fightae, honest!
I've made a big emphasis on visually representing things to make the game as accessible as possible.

MP.png

Grimoires will consist of 5 - 10 pages of skills (still finalizing that max number)

Since each actor is able to take multiple actions per turn, each skill will cost 1-5 pages
This prevents more powerful skills from being uber spammed during an actors turn.
Cats are so easy. I noticed the gray one would never nap in the office while I worked, so I put a blanket on the spare chair in here and now she won't leave.
1701793108356.png
still work in progress, had not much time at the weekend^^
Oh deer! Have you checked my calendar today already? ;3
1701790624587.png

Forum statistics

Threads
136,767
Messages
1,269,695
Members
180,512
Latest member
reiayanami
Top