JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 92 of 171 View original ↗
  1. 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!
  2. @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!
  3. @ScorchedGround This works perfectly, thank you so much!
  4. 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>
  5. @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>
  6. ScorchedGround said:
    @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
  7. 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.
  8. JPlaysan said:
    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).
  9. are the player and enemy stats (ATK, DEF, AGI, HP & MHP, TP) in the game floats or integers?
  10. 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
  11. 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.

    Battle System - CTB (YEP) - Yanfly.moe Wiki
  12. 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;
        });
    };
  13. 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.
  14. 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!
  15. TheGentlemanLoser said:
    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.

    MikeMakes said:
    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))

    tiabuni said:
    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.
  16. 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.
  17. TheGentlemanLoser said:
    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.
  18. 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
  19. 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.
  20. Could someone please help me out with a script call for MV?

    What I'm hoping to do is make a script call that will forcibly use an item (id equal to a variable), on an actor (ID also equal to a variable). This script call happens out of battle, by the way.