JavaScript questions that don't deserve their own thread

● ARCHIVED · READ-ONLY
Started by Shaz 3413 posts Page 19 of 171 View original ↗
  1. I'm trying to make it so actors and enemies die when either HP or MP hits 0. I know with VX Ace it was basically added MP to the death check, but how do you go about doing it in MV? I found where the death state is applied to HP damage around like 9013 in rpg_objects. It uses changeHp, but there is no changeMp. 


    How would I go about doing this?
  2. tsukasa102938 said:
    I'm trying to make it so actors and enemies die when either HP or MP hits 0. I know with VX Ace it was basically added MP to the death check, but how do you go about doing it in MV? I found where the death state is applied to HP damage around like 9013 in rpg_objects. It uses changeHp, but there is no changeMp. 


    How would I go about doing this?

    I believe Himeworks has a Custom Death States plugin to do just that. Just search that plugin name on the forum and you'll find it.
  3. ThePotatoOfFire said:
    I believe Himeworks has a Custom Death States plugin to do just that. Just search that plugin name on the forum and you'll find it.



    Good call! I got it working. Thanks for the really quick reply!
  4. What is the plugin command to refresh the game (like using F5 but forcing it instead)?
  5. window.location.reload()


    Since the game is basically a webpage running inside a browser, you reload it the same way as any other webpage.
  6. How do I check equipped weapons and armor in battle for a damage formula?

    I know it has something to do with a.equips but I don't know how to get it to check weapons and armors from there.  Any help would be appreciated.
  7. lithkast said:
    How do I check equipped weapons and armor in battle for a damage formula?

    I know it has something to do with a.equips but I don't know how to get it to check weapons and armors from there.  Any help would be appreciated.



    What exactly do you want to do with it?


    With a.equips you'll get an array with the equipped items.


    a.equips()[0] would be the weapon object


    1 is the shield


    2 is the head piece


    3 is the body piece


    4 is the accessory
  8. You can use


    a.armors()


    or


    a.weapons()


    to get all armors and weapons, respectively.
  9. lithkast said:
    How do I check equipped weapons and armor in battle for a damage formula?

    I know it has something to do with a.equips but I don't know how to get it to check weapons and armors from there.  Any help would be appreciated.

    Himeworks has a Weapon Damage plugin that lets you reference the equipped weapon in formulas.
  10. I know about hime's plugin ^.^  No my goal wasn't to assign a piece of gear a damage value, but rather get around state usage by seeing if a specific piece of equipment was equipped.  

    I just went with states because its easier.  That being said, for other people who may be having this similar problem...

    I was trying to reference a specific piece of equipment.  The item in question would be an accessory called "God's Ring" and equipping it would allow that character to exceed damage limits.  I was hoping I could reference the item directly for an if statement, but ultimately couldn't figure it out.  Using a state is much easier in that regard.   
  11. Am I doing something wrong?
    I seem to always land in trouble when I use bitmap.blt() in RMMV.


    The below code will fail to produce the image, but the fillRect line works properly.


    var bmp = ImageManager.loadSystem("ctbicon_a_0");
    this.contents.fillRect(0, 0, this.contents.width, itemHeight, this._bgColor);
    this.contents.blt(bmp, 0, 0, 128, 192, 0, 0, 128, 192);


    And this line works for creating a sprite based off a bitmap. 


    this.hazardGaugeBack= new Sprite_Base();
    this.hazardGaugeBack.bitmap = ImageManager.loadSystem('hazback');



    I can then clearRect and fillRect on it, but


    this.hazardGaugeFill.bitmap = ImageManager.loadSystem('hazfillempty');
    var hazFillImage = ImageManager.loadSystem('hazfillnormal');
    this.hazardGaugeFill.bitmap.blt(hazFillImage, sx, 0, sw, 16);



    The moment I try to use a blt, it just won't work. 


    Does anyone know if I'm just doing something wrong?
  12. Your last example seems to be missing some parameters, so that can't work, anyway. For the first example make sure, that:


    - Your given width (the first 128) and height (the first 192) aren't greater, than the source bitmap's dimensions. Otherwise, blt will silently fail.


    - The bitmap has loaded, already. Usually this is done by loading bitmaps during Scene.create and rendering them in Scene.start and later. If you are loading the bitmap dynamically, you'll need to add a load listener, that will wait until it's loaded and draw it, afterwards.


    The easier way would be to simply display another sprite on top of the background. Uses up slightly more memory, but you won't get any issues with asynchronous loading.


    /edit: Here's the (luckily documented) source for the blt function:

    Code:
    /**
     * Performs a block transfer.
     *
     * @method blt
     * @param {Bitmap} source The bitmap to draw
     * @param {Number} sx The x coordinate in the source
     * @param {Number} sy The y coordinate in the source
     * @param {Number} sw The width of the source image
     * @param {Number} sh The height of the source image
     * @param {Number} dx The x coordinate in the destination
     * @param {Number} dy The y coordinate in the destination
     * @param {Number} [dw=sw] The width to draw the image in the destination
     * @param {Number} [dh=sh] The height to draw the image in the destination
     */
    Bitmap.prototype.blt = function(source, sx, sy, sw, sh, dx, dy, dw, dh) {
        dw = dw || sw;
        dh = dh || sh;
        if (sx >= 0 && sy >= 0 && sw > 0 && sh > 0 && dw > 0 && dh > 0 &&
                sx + sw <= source.width && sy + sh <= source.height) {
            this._context.globalCompositeOperation = 'source-over';
            this._context.drawImage(source._canvas, sx, sy, sw, sh, dx, dy, dw, dh);
            this._setDirty();
        }
    };
  13. Iavra said:
    - The bitmap has loaded, already. Usually this is done by loading bitmaps during Scene.create and rendering them in Scene.start and later. If you are loading the bitmap dynamically, you'll need to add a load listener, that will wait until it's loaded and draw it, afterwards.

    The objects(sprites) are currently within a window each, is it possible/recommended to load the bitmap during the Window_~~~.initialize() function? (Would that also mean I have to create any sprites bound to the window in initialize() as well?)

    Iavra said:
    The easier way would be to simply display another sprite on top of the background. Uses up slightly more memory, but you won't get any issues with asynchronous loading.

    Does that mean to create another sprite with a blank bitmap on top of the sprite in question?
  14. Assuming your window is displayed during Scene_Map, you would load the bitmap during Scene_Map.prototype.create. This is because, Scene_Base.prototype.isReady will return false, as long as the ImageManager hasn't finished loading all bitmaps and they are guaranteed to be available in Scene_Map.prototype.start and later.


    The window class itself shouldn't bother with loading images, since it has to draw them und thus assumes, that they are already available.


    As for the additional sprite, you can add it as a child to the parent sprite, like this:


    parentSprite.addChild(sprite);


    This way, it will always be positioned relative to the parent, so you don't have to manually sync them.
  15. I think I got the basic idea and have edited my code to do so!


    It's now working!


    Thank you for your assistance!
  16. I recently found a plugin that allows healing after every battle. This is very useful for my game because I need healing to full after combat. However, I'm having some issues figuring out how to lower mana after battles (TP won't work, as it's used for another aspect). This plugin doesn't contain anything but health, and while useful, I need a bit extra. Here's the code - (Originally written by Gilles Meyer)


    // Only gain HP if not dead
    if(!this.isDead()) {
    var regainHP = this.mhp;
    if(useMaxHp < 1) {
    regainHP = this.hp;
    }
    var onePercent = regainHP/100;
    this.gainHp(onePercent * percentage);
    }
    }
    _Game_Battler_onBattleEnd.call(this,arguments);
    };


    Now, this part works perfectly. In short, what I'm asking is what kind of lines are needed in order to lower all actor's mana. I was unsure if this warranted its own thread, if so, I'd be happy to move it. Thanks.


    Edit: Disregard, figured it out!
  17. Copy pasted from my reddit post:
     


    I'm trying to make a state that changes the element rate of a certain element for certain situations (if then function). I've tried elementRate and calcElementRate and neither have worked. What's the proper syntax for referencing Element Rate?


    E.g. (for simplicity's sake)


    <Custom Select Effect>


    target.elementRate(4) == 1000;


    </Custom Select Effect>


    "4" is the ElementID for fire in my game btw, I just set it to 1000 to see if it would have any obvious effect, which it didn't. Also I'm using Yanfly's buffstatescore plugin. I've tried other notetags too like <Custom Apply Effect> or <Custom Turn Start Effect>, to no avail. If I could just get an example of elementRate being used in a notetag, that'd help a lot. Also have tried "=" "==" "*=".


    I intend to use this to make my burn state make the target take more fire damage, but I want it to scale with how many turns left of the burn there are (elementRate *= 1 + turns left of burn * 0.1) and then consume (remove) the state. So I'll have to reference _stateSteps or perhaps its something else. Anyway just trying to figure out the elementRate portion before I get into that. Oh right, and I'm using most of Yanfly's plugins as well.
  18. Hello there,


    I'm trying to make a effect using Yanfly Lunatic and was wondering if its possible to use Luck as a chance to activate the effect.


    Logic would be something like:


    <Reaction Tag>


    Chance = a.luck * 0.5


    Hit = rand(100)


    if Hit <= Chance then


    (Effect)


    </Reaction Tag>


    Thanks


    As a side question: Anyone made a list of common javascript commands like Formar did on rgss3? That was a big help for someone with low programming skills. :/
  19. I have a question for Yanfly's YEP_GabWindow plugin.  Basically, whenever you open up the menu while a gab is being displayed, it will replay the gab form the start, including the sound effect if you have one set.  I hear this is intentional, but I don't think it fits my game.  It doesn't appear there's an easy way to fix this though.  Can anyone help?
  20. is there a list of things that can plugged into statements like this...


    <Instant Eval>if (user.atk >= 300) instant = true;</Instant Eval>


    I'm curious, not just for this particular example which is Yanfly's Instant Cast, but in general what kind of things can go in these kind of checks. I think I understand checking for switches and variables (I think), but i'm not sure what other things can be put in these.