JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 66 of 171 View original ↗
  1. FirestormNeos said:
    In Yanfly's Battle Engine Core plugin, where is the option that lets me move the player character to the left side of the screen and what do I put in so that it performs that?
    Are you talking about yanfly action sequences?
    Category:Action Sequences (MV) - Yanfly.moe Wiki You need the packs at least 1 and 2 to do anything really, and learn how it works on that page.
  2. glaphen said:
    Are you talking about yanfly action sequences?
    Category:Action Sequences (MV) - Yanfly.moe Wiki You need the packs at least 1 and 2 to do anything really, and learn how it works on that page.

    I'm not entirely sure. I want the player character to be on the left side of the screen, facing right. Rather than the default, where it's the other way around.

    Here's a(n edited) "screenshot" of what I'm talking about:
    bruh.png
  3. Really simple question: which of the animations from the sprite sheet is the WALK motion? I see that being quoted but i've never found it anywhere

    1581253486208.png
    1581253509434.png
  4. FirestormNeos said:
    I'm not entirely sure. I want the player character to be on the left side of the screen, facing right. Rather than the default, where it's the other way around.

    Here's a(n edited) "screenshot" of what I'm talking about:
    View attachment 133673

    For that you would probably have to change home positions of the actors in battle engine core to that area then mirror all the images in the sv actor folder, for enemies you would just have to place them where actors would be in troops and mirror all the sv enemies as well.

    matgraz said:
    Really simple question: which of the animations from the sprite sheet is the WALK motion? I see that being quoted but i've never found it anywhere

    View attachment 133676
    View attachment 133677

    "Walk" is idle whenever it's usually referred to in other programs I think. If you want to make an actual walk animation you would probably have to do it manually by changing one of those motions you don't use so like never use sleep and instead use motion sleep: user for example after any walk attempt,
  5. TSR said:
    Hello, I would use this notetag instead:
    Code:
    <Custom Respond Effect>
    if (this.isPhysical() && target.result().hpDamage > 0) {
       dam = target.result().hpDamage;
       user.gainHp(dam)
       target.removeState(state ID);
    }
    </Custom Respond Effect>

    This worked perfectly! You're awesome! Thanks and sorry for the late answer.
  6. glaphen said:
    For that you would probably have to change home positions of the actors in battle engine core to that area

    Okay, and where in the Battle Engine Core do I do that?
  7. FirestormNeos said:
    Okay, and where in the Battle Engine Core do I do that?
    Sideview Home Position X screenWidth - 16 - (maxSize + 2) * 32 + index * 32
    You would have to play around with the math of that to put them where you want, also might have to change step and flinch distance to a negative number.
  8. Please delete! My question was answered in another thread. :]
  9. *Moved to it's own thread*
  10. Hey guys whats the difference between $gameActors._data[1].... and $gameActors.actor(1)....
    If I want to change some stats through script call would it be better to do it with actor() or _data?
    I also noticed that I can address all stats with or without an underscore but I can only change it with underscore
    so this $gameActors._data[1]._hp = 100 would work and that $gameActors._data[1].hp = 100 wouldnt
    and I also can address exparameters through "xparam()", "_xparam[]"(which is changeable) or their shortname "cri, hit" etc.
    its so confusing, I would be grateful if anyone explained how all of that works
  11. This question could very easily merit it's own thread, but I'll try and keep it short.

    In terms of what you get when you use $gameActors._data[1] and $gameActors.actor(1), they are exactly the same. The difference is in how they give you the value.

    $gameActors._data[1] - will just try to spit out the actor, almost no questions asked.
    $gameActors.actor(1) - will first check that the database has an actor 1 in it, then it will make sure that actor 1 has actually been created in the game (if it hasn't, it will create it), then it will give you the actor. If there is no actor in the database it will give you nothing (null).

    Unless I have a very compelling reason to use $gameActors._data, I leave it be. $gameActors.actor can handle exceptions better, and is probably less likely to crash your game if you make a mistake. For example, say I want to change a property of actor 1, something like "$gameActors.actor(1)._hp = 5", if I forget to use the ._hp and instead use "$gameActors.actor(1) = 5" I'll get a message in the console telling me that this doesn't make sense and my game will continue. If I did this using "$gameActors._data[1] = 5", my game will crash immediately.

    Regarding the difference between ".hp" and "._hp" etc. The versions without an underscore are getter properties, they run a function when you use them and return a value. If you look in the rpg_objects.js file and search "Object.defineProperties(Game_BattlerBase" you'll see a whole list of these properties. When defining properties like this there is the option to add a set function, however, this hasn't been utilised in the default MV code so using ".hp = 5" in effect does nothing.

    When deciding which to use, it should be pretty clear that ".hp" isn't going to help you if you need to change an actors hp, but is a safe way of getting the value without any risk of accidentally changing it.

    I would advise against just mashing straight in and using "._hp" etc. to set a value because there are functions that already exist for changing these things that have measures in place to make sure parameters don't exceed their maximums . Hp for instance has the function "gainHp", normal params have "addParam" and so on. That's not to say you should never use the "._hp" style properties, but I normally don't unless I have a reason for using them over an existing function.
  12. @Silva It is always preferable to access an object's data through a function than directly referring to its variable. This is something more in line with C/C++/C# kind of languages where you can set variables to private/public/protected.

    As for the .hp and the ._hp, it is almost always preferable to use .hp since it's a property (meaning it has it will return the hp with a function). The reason why actor.hp -= 100 doesn't work is because the property only defines a get and not a set (I don't know why to be honest):
    Code:
    Object.defineProperties(Game_BattlerBase.prototype, {
        // Hit Points
        hp: { get: function() { return this._hp; }, configurable: true },
        // The rest of the properties
    }

    If there was a set, it would be preferable to use the property rather than accessing the value directly. There are many properties in the MV default code that have a getter and a setter. Check for example:
    Code:
    Object.defineProperty(Sprite.prototype, 'opacity', {
        get: function() {
            return this.alpha * 255;
        },
        set: function(value) {
            this.alpha = value.clamp(0, 255) / 255;
        },
        configurable: true
    });
  13. thanks silva and mushroom cake =)
    I think i understand now
  14. Anyone know the Javascript call for checking if an equipped piece of gear is a certain item?

    TL;DR: I'm making an item that grants a flawless Escape rate when equipped. I tried a custom Escape Rate of like:
    Code:
    base + ($gameVariables.value(xx))

    But w/ the variable being modified by a conditional branch if <X Thing> was equipped. Didn't work, since ESCRate is set at the instantiation of a fight.

    So I very specifically need to know what the call is for "the item matching this ID is equipped on this actor". :p
  15. Unbenannt.PNG
    I have created the state above, but it doesn't work, because if a character cannot move it cannot counter.
    I've put this here in the Javascript Support Forum, because I believe what I like to achieve cannot be done without Javascript. I also don't believe it deserves it's own thread.
    So how I can make my actor have no actions for 2 turns and still be able to counter attack using Javascript?
  16. ZServ said:
    Anyone know the Javascript call for checking if an equipped piece of gear is a certain item?

    TL;DR: I'm making an item that grants a flawless Escape rate when equipped. I tried a custom Escape Rate of like:
    Code:
    base + ($gameVariables.value(xx))

    But w/ the variable being modified by a conditional branch if <X Thing> was equipped. Didn't work, since ESCRate is set at the instantiation of a fight.

    So I very specifically need to know what the call is for "the item matching this ID is equipped on this actor". :p

    You should have some luck using one of the examples below. replace actorId with the actor ID, weaponId with the weapon ID. If you're using the party method replace index with the actors position in the party (0 = leader and so on).

    JavaScript:
    //get actor by actorId
    $gameActors.actor(actorId).hasWeapon($dataWeapons[weaponId]);
    $gameActors.actor(actorId).hasArmor($dataArmors[armorId]);
    
    //alternatively, using party index, works with hasArmor as well
    $gameParty.members(index).hasWeapon($dataWeapons[weaponId]);

    BurningOrca said:
    View attachment 135507
    I have created the state above, but it doesn't work, because if a character cannot move it cannot counter.
    I've put this here in the Javascript Support Forum, because I believe what I like to achieve cannot be done without Javascript. I also don't believe it deserves it's own thread.
    So how I can make my actor have no actions for 2 turns and still be able to counter attack using Javascript?

    In terms of doing this in vanilla MV, I can't think of a solution off the top of my head. You could probably pull this off rather easily with Yanfly's buffs and states core's custom effects to force an attack.
  17. @Silva: Well I tried it with overwritting makeActions and makeActionsTimes, but that leaded to an error as the game didn't create any actions, but it was still able to select e.g. Attack with that Actor.
    So I decided to keep the "Cannot move flag" and instead overwrite the itemCnt like that:

    JavaScript:
    BurningOrca.MyGame.counterRate = Game_Action.prototype.itemCnt;
    
    Game_Action.prototype.itemCnt = function(target)
    {
        if( this.isPhysical() )
        {
            if( !this.isForOne() )
            {
                return 0;
            }
            else if( target.canMove() || target.isStateAffected(13) )
            {
                return target.cnt;
            }
            else
            {
                return 0;
            }
        }
        else
        {
            return 0;
        }
    };

    Because I use Yanfly's Counter Control I also had to overwrite this function:

    JavaScript:
    BurningOrca.MyGame.canBattlerCounter = Game_Battler.prototype.canCounter;
    
    Game_Battler.prototype.canCounter = function()
    {
        if( target.isStateAffected(13) && this.counterTotal() >= this._counters ) return true;
        return Game_Battler.prototype.canCounter.call(this);
    }

    Then it seemed to work. Also now only attacks that hit a single target get countered, which I thought would be the default.
  18. Silva said:
    You should have some luck using one of the examples below. replace actorId with the actor ID, weaponId with the weapon ID. If you're using the party method replace index with the actors position in the party (0 = leader and so on).

    Thanks a ton, Silva! Very helpful :)
  19. Back with another question, a smoll one this time (I think they are small oh no)!


    What's the best way to get an event to affect multiple tiles? For example, 6 tiles straight ahead of the player, or the front left front and front right (a horizontal line of 3 for say a sword swing). I would be using a tool from Galv's tool plugin that calls a common event, so I just need the common event to do that haha!

    I think maybe I should just play a common event that individually targets all the tiles I want to be affected but am not 100% sure how to call that? Like 6 tiles before the player would be 4 directional conditions, plus the six [$gamePlayer.x +1,$gamePlayer.y +1] or player location variable scripts coupled with want used on that tile (in which case if someone could explain how to or the most efficient way of doing so as to not be incredibly messy or lag out someone's poor brick pc)~

    If there is an easy way of plugging this or if someone had an example for what one of the directions should look like for my tiny noob brain I would be happy~ qvq (I wouldn't want to make anyone's life difficult tho aa-)

    MV Tools


    -------------------------------------------------------------------------------

    If these are already answered somewhere I apologize, googled myself into a deep corner of the rpg maker web but I'm blind I guess!
  20. Hello! I've only started using RPG Maker MV this week so I'm really sorry if this is a stupid question/wrong thread to post this question in! (Please do tell me where to post these kinds of questions next time so I know better!)
    The issue I'm having is I'm not really sure how to walk through event tiles? As in I don't want my player to be unable to walk through a particular tile when there's no object there but just an event tile.
    I'm currently trying out on making a small parallax map and I'm using QPlus/QMovement/QM+CollisionMap from https://quxios.github.io/plugins as well as Orange Overlay
    The collider boxes on the events are 48x48 and the player collider box is smaller ( I slightly adjusted the offset for the collider so the player would be able to pass through the gap of the flower table and couch)
    I hope my question makes sense thank you!
    Thank you!